phaser.min.js 1002 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727
  1. /* Phaser v2.0.7 - http://phaser.io - @photonstorm - (c) 2014 Photon Storm Ltd. */
  2. (function() {
  3. var a = this,
  4. b = b || {};
  5. 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. if (this.width <= 0 || this.height <= 0) return !1;
  47. var c = this.x;
  48. if (a >= c && a <= c + this.width) {
  49. var d = this.y;
  50. if (b >= d && b <= d + this.height) return !0
  51. }
  52. return !1
  53. }, b.Rectangle.prototype.constructor = b.Rectangle, b.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Polygon = function(a) {
  54. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  55. for (var c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  56. a = c
  57. }
  58. this.points = a
  59. }, b.Polygon.prototype.clone = function() {
  60. for (var a = [], c = 0; c < this.points.length; c++) a.push(this.points[c].clone());
  61. return new b.Polygon(a)
  62. }, b.Polygon.prototype.contains = function(a, b) {
  63. for (var c = !1, d = 0, e = this.points.length - 1; d < this.points.length; e = d++) {
  64. var f = this.points[d].x,
  65. g = this.points[d].y,
  66. h = this.points[e].x,
  67. i = this.points[e].y,
  68. j = g > b != i > b && (h - f) * (b - g) / (i - g) + f > a;
  69. j && (c = !c)
  70. }
  71. return c
  72. }, b.Polygon.prototype.constructor = b.Polygon, b.Circle = function(a, b, c) {
  73. this.x = a || 0, this.y = b || 0, this.radius = c || 0
  74. }, b.Circle.prototype.clone = function() {
  75. return new b.Circle(this.x, this.y, this.radius)
  76. }, b.Circle.prototype.contains = function(a, b) {
  77. if (this.radius <= 0) return !1;
  78. var c = this.x - a,
  79. d = this.y - b,
  80. e = this.radius * this.radius;
  81. return c *= c, d *= d, e >= c + d
  82. }, b.Circle.prototype.getBounds = function() {
  83. return new b.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height)
  84. }, b.Circle.prototype.constructor = b.Circle, b.Ellipse = function(a, b, c, d) {
  85. this.x = a || 0, this.y = b || 0, this.width = c || 0, this.height = d || 0
  86. }, b.Ellipse.prototype.clone = function() {
  87. return new b.Ellipse(this.x, this.y, this.width, this.height)
  88. }, b.Ellipse.prototype.contains = function(a, b) {
  89. if (this.width <= 0 || this.height <= 0) return !1;
  90. var c = (a - this.x) / this.width,
  91. d = (b - this.y) / this.height;
  92. return c *= c, d *= d, 1 >= c + d
  93. }, b.Ellipse.prototype.getBounds = function() {
  94. return new b.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height)
  95. }, b.Ellipse.prototype.constructor = b.Ellipse, b.Matrix = function() {
  96. this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0
  97. }, b.Matrix.prototype.fromArray = function(a) {
  98. this.a = a[0], this.b = a[1], this.c = a[3], this.d = a[4], this.tx = a[2], this.ty = a[5]
  99. }, b.Matrix.prototype.toArray = function(a) {
  100. this.array || (this.array = new Float32Array(9));
  101. var b = this.array;
  102. 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
  103. }, b.identityMatrix = new b.Matrix, b.determineMatrixArrayType = function() {
  104. return "undefined" != typeof Float32Array ? Float32Array : Array
  105. }, b.Matrix2 = b.determineMatrixArrayType(), b.DisplayObject = function() {
  106. 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
  107. }, b.DisplayObject.prototype.constructor = b.DisplayObject, b.DisplayObject.prototype.setInteractive = function(a) {
  108. this.interactive = a
  109. }, Object.defineProperty(b.DisplayObject.prototype, "interactive", {
  110. get: function() {
  111. return this._interactive
  112. },
  113. set: function(a) {
  114. this._interactive = a, this.stage && (this.stage.dirty = !0)
  115. }
  116. }), Object.defineProperty(b.DisplayObject.prototype, "worldVisible", {
  117. get: function() {
  118. var a = this;
  119. do {
  120. if (!a.visible) return !1;
  121. a = a.parent
  122. } while (a);
  123. return !0
  124. }
  125. }), Object.defineProperty(b.DisplayObject.prototype, "mask", {
  126. get: function() {
  127. return this._mask
  128. },
  129. set: function(a) {
  130. this._mask && (this._mask.isMask = !1), this._mask = a, this._mask && (this._mask.isMask = !0)
  131. }
  132. }), Object.defineProperty(b.DisplayObject.prototype, "filters", {
  133. get: function() {
  134. return this._filters
  135. },
  136. set: function(a) {
  137. if (a) {
  138. for (var b = [], c = 0; c < a.length; c++)
  139. for (var d = a[c].passes, e = 0; e < d.length; e++) b.push(d[e]);
  140. this._filterBlock = {
  141. target: this,
  142. filterPasses: b
  143. }
  144. }
  145. this._filters = a
  146. }
  147. }), Object.defineProperty(b.DisplayObject.prototype, "cacheAsBitmap", {
  148. get: function() {
  149. return this._cacheAsBitmap
  150. },
  151. set: function(a) {
  152. this._cacheAsBitmap !== a && (a ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = a)
  153. }
  154. }), b.DisplayObject.prototype.updateTransform = function() {
  155. this.rotation !== this.rotationCache && (this.rotationCache = this.rotation, this._sr = Math.sin(this.rotation), this._cr = Math.cos(this.rotation));
  156. var a = this.parent.worldTransform,
  157. b = this.worldTransform,
  158. c = this.pivot.x,
  159. d = this.pivot.y,
  160. e = this._cr * this.scale.x,
  161. f = -this._sr * this.scale.y,
  162. g = this._sr * this.scale.x,
  163. h = this._cr * this.scale.y,
  164. i = this.position.x - e * c - d * f,
  165. j = this.position.y - h * d - c * g,
  166. k = a.a,
  167. l = a.b,
  168. m = a.c,
  169. n = a.d;
  170. 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
  171. }, b.DisplayObject.prototype.getBounds = function(a) {
  172. return a = a, b.EmptyRectangle
  173. }, b.DisplayObject.prototype.getLocalBounds = function() {
  174. return this.getBounds(b.identityMatrix)
  175. }, b.DisplayObject.prototype.setStageReference = function(a) {
  176. this.stage = a, this._interactive && (this.stage.dirty = !0)
  177. }, b.DisplayObject.prototype.generateTexture = function(a) {
  178. var c = this.getLocalBounds(),
  179. d = new b.RenderTexture(0 | c.width, 0 | c.height, a);
  180. return d.render(this, new b.Point(-c.x, -c.y)), d
  181. }, b.DisplayObject.prototype.updateCache = function() {
  182. this._generateCachedSprite()
  183. }, b.DisplayObject.prototype._renderCachedSprite = function(a) {
  184. this._cachedSprite.worldAlpha = this.worldAlpha, a.gl ? b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a) : b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a)
  185. }, b.DisplayObject.prototype._generateCachedSprite = function() {
  186. this._cacheAsBitmap = !1;
  187. var a = this.getLocalBounds();
  188. if (this._cachedSprite) this._cachedSprite.texture.resize(0 | a.width, 0 | a.height);
  189. else {
  190. var c = new b.RenderTexture(0 | a.width, 0 | a.height);
  191. this._cachedSprite = new b.Sprite(c), this._cachedSprite.worldTransform = this.worldTransform
  192. }
  193. var d = this._filters;
  194. 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
  195. }, b.DisplayObject.prototype._destroyCachedSprite = function() {
  196. this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null)
  197. }, b.DisplayObject.prototype._renderWebGL = function(a) {
  198. a = a
  199. }, b.DisplayObject.prototype._renderCanvas = function(a) {
  200. a = a
  201. }, Object.defineProperty(b.DisplayObject.prototype, "x", {
  202. get: function() {
  203. return this.position.x
  204. },
  205. set: function(a) {
  206. this.position.x = a
  207. }
  208. }), Object.defineProperty(b.DisplayObject.prototype, "y", {
  209. get: function() {
  210. return this.position.y
  211. },
  212. set: function(a) {
  213. this.position.y = a
  214. }
  215. }), b.DisplayObjectContainer = function() {
  216. b.DisplayObject.call(this), this.children = []
  217. }, b.DisplayObjectContainer.prototype = Object.create(b.DisplayObject.prototype), b.DisplayObjectContainer.prototype.constructor = b.DisplayObjectContainer, Object.defineProperty(b.DisplayObjectContainer.prototype, "width", {
  218. get: function() {
  219. return this.scale.x * this.getLocalBounds().width
  220. },
  221. set: function(a) {
  222. var b = this.getLocalBounds().width;
  223. this.scale.x = 0 !== b ? a / (b / this.scale.x) : 1, this._width = a
  224. }
  225. }), Object.defineProperty(b.DisplayObjectContainer.prototype, "height", {
  226. get: function() {
  227. return this.scale.y * this.getLocalBounds().height
  228. },
  229. set: function(a) {
  230. var b = this.getLocalBounds().height;
  231. this.scale.y = 0 !== b ? a / (b / this.scale.y) : 1, this._height = a
  232. }
  233. }), b.DisplayObjectContainer.prototype.addChild = function(a) {
  234. return this.addChildAt(a, this.children.length)
  235. }, b.DisplayObjectContainer.prototype.addChildAt = function(a, b) {
  236. 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;
  237. throw new Error(a + " The index " + b + " supplied is out of bounds " + this.children.length)
  238. }, b.DisplayObjectContainer.prototype.swapChildren = function(a, b) {
  239. if (a !== b) {
  240. var c = this.children.indexOf(a),
  241. d = this.children.indexOf(b);
  242. if (0 > c || 0 > d) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
  243. this.children[c] = b, this.children[d] = a
  244. }
  245. }, b.DisplayObjectContainer.prototype.getChildAt = function(a) {
  246. if (a >= 0 && a < this.children.length) return this.children[a];
  247. throw new Error("Supplied index does not exist in the child list, or the supplied DisplayObject must be a child of the caller")
  248. }, b.DisplayObjectContainer.prototype.removeChild = function(a) {
  249. return this.removeChildAt(this.children.indexOf(a))
  250. }, b.DisplayObjectContainer.prototype.removeChildAt = function(a) {
  251. var b = this.getChildAt(a);
  252. return this.stage && b.removeStageReference(), b.parent = void 0, this.children.splice(a, 1), b
  253. }, b.DisplayObjectContainer.prototype.removeChildren = function(a, b) {
  254. var c = a || 0,
  255. d = "number" == typeof b ? b : this.children.length,
  256. e = d - c;
  257. if (e > 0 && d >= e) {
  258. for (var f = this.children.splice(c, e), g = 0; g < f.length; g++) {
  259. var h = f[g];
  260. this.stage && h.removeStageReference(), h.parent = void 0
  261. }
  262. return f
  263. }
  264. throw new Error("Range Error, numeric values are outside the acceptable range")
  265. }, b.DisplayObjectContainer.prototype.updateTransform = function() {
  266. if (this.visible && (b.DisplayObject.prototype.updateTransform.call(this), !this._cacheAsBitmap))
  267. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].updateTransform()
  268. }, b.DisplayObjectContainer.prototype.getBounds = function(a) {
  269. if (0 === this.children.length) return b.EmptyRectangle;
  270. if (a) {
  271. var c = this.worldTransform;
  272. this.worldTransform = a, this.updateTransform(), this.worldTransform = c
  273. }
  274. for (var d, e, f, g = 1 / 0, h = 1 / 0, i = -1 / 0, j = -1 / 0, k = !1, l = 0, m = this.children.length; m > l; l++) {
  275. var n = this.children[l];
  276. n.visible && (k = !0, d = this.children[l].getBounds(a), g = g < d.x ? g : d.x, h = h < d.y ? h : d.y, e = d.width + d.x, f = d.height + d.y, i = i > e ? i : e, j = j > f ? j : f)
  277. }
  278. if (!k) return b.EmptyRectangle;
  279. var o = this._bounds;
  280. return o.x = g, o.y = h, o.width = i - g, o.height = j - h, o
  281. }, b.DisplayObjectContainer.prototype.getLocalBounds = function() {
  282. var a = this.worldTransform;
  283. this.worldTransform = b.identityMatrix;
  284. for (var c = 0, d = this.children.length; d > c; c++) this.children[c].updateTransform();
  285. var e = this.getBounds();
  286. return this.worldTransform = a, e
  287. }, b.DisplayObjectContainer.prototype.setStageReference = function(a) {
  288. this.stage = a, this._interactive && (this.stage.dirty = !0);
  289. for (var b = 0, c = this.children.length; c > b; b++) {
  290. var d = this.children[b];
  291. d.setStageReference(a)
  292. }
  293. }, b.DisplayObjectContainer.prototype.removeStageReference = function() {
  294. for (var a = 0, b = this.children.length; b > a; a++) {
  295. var c = this.children[a];
  296. c.removeStageReference()
  297. }
  298. this._interactive && (this.stage.dirty = !0), this.stage = null
  299. }, b.DisplayObjectContainer.prototype._renderWebGL = function(a) {
  300. if (this.visible && !(this.alpha <= 0)) {
  301. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  302. var b, c;
  303. if (this._mask || this._filters) {
  304. 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);
  305. a.spriteBatch.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), a.spriteBatch.start()
  306. } else
  307. for (b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  308. }
  309. }, b.DisplayObjectContainer.prototype._renderCanvas = function(a) {
  310. if (this.visible !== !1 && 0 !== this.alpha) {
  311. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  312. this._mask && a.maskManager.pushMask(this._mask, a.context);
  313. for (var b = 0, c = this.children.length; c > b; b++) {
  314. var d = this.children[b];
  315. d._renderCanvas(a)
  316. }
  317. this._mask && a.maskManager.popMask(a.context)
  318. }
  319. }, b.Sprite = function(a) {
  320. 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
  321. }, b.Sprite.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Sprite.prototype.constructor = b.Sprite, Object.defineProperty(b.Sprite.prototype, "width", {
  322. get: function() {
  323. return this.scale.x * this.texture.frame.width
  324. },
  325. set: function(a) {
  326. this.scale.x = a / this.texture.frame.width, this._width = a
  327. }
  328. }), Object.defineProperty(b.Sprite.prototype, "height", {
  329. get: function() {
  330. return this.scale.y * this.texture.frame.height
  331. },
  332. set: function(a) {
  333. this.scale.y = a / this.texture.frame.height, this._height = a
  334. }
  335. }), b.Sprite.prototype.setTexture = function(a) {
  336. this.texture = a, this.cachedTint = 16777215
  337. }, b.Sprite.prototype.onTextureUpdate = function() {
  338. this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height)
  339. }, b.Sprite.prototype.getBounds = function(a) {
  340. var b = this.texture.frame.width,
  341. c = this.texture.frame.height,
  342. d = b * (1 - this.anchor.x),
  343. e = b * -this.anchor.x,
  344. f = c * (1 - this.anchor.y),
  345. g = c * -this.anchor.y,
  346. h = a || this.worldTransform,
  347. i = h.a,
  348. j = h.c,
  349. k = h.b,
  350. l = h.d,
  351. m = h.tx,
  352. n = h.ty,
  353. o = i * e + k * g + m,
  354. p = l * g + j * e + n,
  355. q = i * d + k * g + m,
  356. r = l * g + j * d + n,
  357. s = i * d + k * f + m,
  358. t = l * f + j * d + n,
  359. u = i * e + k * f + m,
  360. v = l * f + j * e + n,
  361. w = -1 / 0,
  362. x = -1 / 0,
  363. y = 1 / 0,
  364. z = 1 / 0;
  365. 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;
  366. var A = this._bounds;
  367. return A.x = y, A.width = w - y, A.y = z, A.height = x - z, this._currentBounds = A, A
  368. }, b.Sprite.prototype._renderWebGL = function(a) {
  369. if (this.visible && !(this.alpha <= 0)) {
  370. var b, c;
  371. if (this._mask || this._filters) {
  372. var d = a.spriteBatch;
  373. for (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);
  374. d.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), d.start()
  375. } else
  376. for (a.spriteBatch.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  377. }
  378. }, b.Sprite.prototype._renderCanvas = function(a) {
  379. if (this.visible !== !1 && 0 !== this.alpha) {
  380. if (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) {
  381. 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);
  382. var c = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width,
  383. d = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
  384. 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)
  385. }
  386. for (var e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
  387. this._mask && a.maskManager.popMask(a.context)
  388. }
  389. }, b.Sprite.fromFrame = function(a) {
  390. var c = b.TextureCache[a];
  391. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache' + this);
  392. return new b.Sprite(c)
  393. }, b.Sprite.fromImage = function(a, c, d) {
  394. var e = b.Texture.fromImage(a, c, d);
  395. return new b.Sprite(e)
  396. }, b.SpriteBatch = function(a) {
  397. b.DisplayObjectContainer.call(this), this.textureThing = a, this.ready = !1
  398. }, b.SpriteBatch.prototype = Object.create(b.DisplayObjectContainer.prototype), b.SpriteBatch.constructor = b.SpriteBatch, b.SpriteBatch.prototype.initWebGL = function(a) {
  399. this.fastSpriteBatch = new b.WebGLFastSpriteBatch(a), this.ready = !0
  400. }, b.SpriteBatch.prototype.updateTransform = function() {
  401. b.DisplayObject.prototype.updateTransform.call(this)
  402. }, b.SpriteBatch.prototype._renderWebGL = function(a) {
  403. !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())
  404. }, b.SpriteBatch.prototype._renderCanvas = function(a) {
  405. var c = a.context;
  406. c.globalAlpha = this.worldAlpha, b.DisplayObject.prototype.updateTransform.call(this);
  407. for (var d = this.worldTransform, e = !0, f = 0; f < this.children.length; f++) {
  408. var g = this.children[f];
  409. if (g.visible) {
  410. var h = g.texture,
  411. i = h.frame;
  412. if (c.globalAlpha = this.worldAlpha * g.alpha, g.rotation % (2 * Math.PI) === 0) 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, 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 | 0, i.width * g.scale.x, i.height * g.scale.y);
  413. else {
  414. e || (e = !0), b.DisplayObject.prototype.updateTransform.call(g);
  415. var j = g.worldTransform;
  416. 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, g.anchor.x * -i.width + .5 | 0, g.anchor.y * -i.height + .5 | 0, i.width, i.height)
  417. }
  418. }
  419. }
  420. }, b.AbstractFilter = function(a, b) {
  421. this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = b || {}, this.fragmentSrc = a || []
  422. }, b.FilterBlock = function() {
  423. this.visible = !0, this.renderable = !0
  424. }, b.Text = function(a, c) {
  425. 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)
  426. }, b.Text.prototype = Object.create(b.Sprite.prototype), b.Text.prototype.constructor = b.Text, Object.defineProperty(b.Text.prototype, "width", {
  427. get: function() {
  428. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width
  429. },
  430. set: function(a) {
  431. this.scale.x = a / this.texture.frame.width, this._width = a
  432. }
  433. }), Object.defineProperty(b.Text.prototype, "height", {
  434. get: function() {
  435. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height
  436. },
  437. set: function(a) {
  438. this.scale.y = a / this.texture.frame.height, this._height = a
  439. }
  440. }), b.Text.prototype.setStyle = function(a) {
  441. 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
  442. }, b.Text.prototype.setText = function(a) {
  443. this.text = a.toString() || " ", this.dirty = !0
  444. }, b.Text.prototype.updateText = function() {
  445. this.context.font = this.style.font;
  446. var a = this.text;
  447. this.style.wordWrap && (a = this.wordWrap(this.text));
  448. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = 0; e < b.length; e++) {
  449. var f = this.context.measureText(b[e]).width;
  450. c[e] = f, d = Math.max(d, f)
  451. }
  452. var g = d + this.style.strokeThickness;
  453. this.style.dropShadow && (g += this.style.dropShadowDistance), this.canvas.width = g + this.context.lineWidth;
  454. var h = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness,
  455. i = h * b.length;
  456. 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";
  457. var j, k;
  458. if (this.style.dropShadow) {
  459. this.context.fillStyle = this.style.dropShadowColor;
  460. var l = Math.sin(this.style.dropShadowAngle) * this.style.dropShadowDistance,
  461. m = Math.cos(this.style.dropShadowAngle) * this.style.dropShadowDistance;
  462. for (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)
  463. }
  464. 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);
  465. this.updateTexture()
  466. }, b.Text.prototype.updateTexture = function() {
  467. 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
  468. }, b.Text.prototype._renderWebGL = function(a) {
  469. this.requiresUpdate && (this.requiresUpdate = !1, b.updateWebGLTexture(this.texture.baseTexture, a.gl)), b.Sprite.prototype._renderWebGL.call(this, a)
  470. }, b.Text.prototype.updateTransform = function() {
  471. this.dirty && (this.updateText(), this.dirty = !1), b.Sprite.prototype.updateTransform.call(this)
  472. }, b.Text.prototype.determineFontHeight = function(a) {
  473. var c = b.Text.heightCache[a];
  474. if (!c) {
  475. var d = document.getElementsByTagName("body")[0],
  476. e = document.createElement("div"),
  477. f = document.createTextNode("M");
  478. 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)
  479. }
  480. return c
  481. }, b.Text.prototype.wordWrap = function(a) {
  482. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  483. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  484. var h = this.context.measureText(f[g]).width,
  485. i = h + this.context.measureText(" ").width;
  486. 0 === g || i > e ? (g > 0 && (b += "\n"), b += f[g], e = this.style.wordWrapWidth - h) : (e -= i, b += " " + f[g])
  487. }
  488. d < c.length - 1 && (b += "\n")
  489. }
  490. return b
  491. }, b.Text.prototype.destroy = function(a) {
  492. this.context = null, this.canvas = null, this.texture.destroy(void 0 === a ? !0 : a)
  493. }, b.Text.heightCache = {}, b.BitmapText = function(a, c) {
  494. b.DisplayObjectContainer.call(this), this._pool = [], this.setText(a), this.setStyle(c), this.updateText(), this.dirty = !1
  495. }, b.BitmapText.prototype = Object.create(b.DisplayObjectContainer.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setText = function(a) {
  496. this.text = a || " ", this.dirty = !0
  497. }, b.BitmapText.prototype.setStyle = function(a) {
  498. a = a || {}, a.align = a.align || "left", this.style = a;
  499. var c = a.font.split(" ");
  500. 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
  501. }, b.BitmapText.prototype.updateText = function() {
  502. for (var a = b.BitmapText.fonts[this.fontName], c = new b.Point, d = null, e = [], f = 0, g = [], h = 0, i = this.fontSize / a.size, j = 0; j < this.text.length; j++) {
  503. var k = this.text.charCodeAt(j);
  504. if (/(?:\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;
  505. else {
  506. var l = a.chars[k];
  507. l && (d && l[d] && (c.x += l.kerning[d]), e.push({
  508. texture: l.texture,
  509. line: h,
  510. charCode: k,
  511. position: new b.Point(c.x + l.xOffset, c.y + l.yOffset)
  512. }), c.x += l.xAdvance, d = k)
  513. }
  514. }
  515. g.push(c.x), f = Math.max(f, c.x);
  516. var m = [];
  517. for (j = 0; h >= j; j++) {
  518. var n = 0;
  519. "right" === this.style.align ? n = f - g[j] : "center" === this.style.align && (n = (f - g[j]) / 2), m.push(n)
  520. }
  521. var o = this.children.length,
  522. p = e.length,
  523. q = this.tint || 16777215;
  524. for (j = 0; p > j; j++) {
  525. var r = o > j ? this.children[j] : this._pool.pop();
  526. 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)
  527. }
  528. for (; this.children.length > p;) {
  529. var s = this.getChildAt(this.children.length - 1);
  530. this._pool.push(s), this.removeChild(s)
  531. }
  532. this.textWidth = f * i, this.textHeight = (c.y + a.lineHeight) * i
  533. }, b.BitmapText.prototype.updateTransform = function() {
  534. this.dirty && (this.updateText(), this.dirty = !1), b.DisplayObjectContainer.prototype.updateTransform.call(this)
  535. }, b.BitmapText.fonts = {}, b.Stage = function(a) {
  536. 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)
  537. }, b.Stage.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.setInteractionDelegate = function(a) {
  538. this.interactionManager.setTargetDomElement(a)
  539. }, b.Stage.prototype.updateTransform = function() {
  540. this.worldAlpha = 1;
  541. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].updateTransform();
  542. this.dirty && (this.dirty = !1, this.interactionManager.dirty = !0), this.interactive && this.interactionManager.update()
  543. }, b.Stage.prototype.setBackgroundColor = function(a) {
  544. this.backgroundColor = a || 0, this.backgroundColorSplit = b.hex2rgb(this.backgroundColor);
  545. var c = this.backgroundColor.toString(16);
  546. c = "000000".substr(0, 6 - c.length) + c, this.backgroundColorString = "#" + c
  547. }, b.Stage.prototype.getMousePosition = function() {
  548. return this.interactionManager.mouse.global
  549. };
  550. for (var 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"];
  551. window.requestAnimationFrame || (window.requestAnimationFrame = function(a) {
  552. var b = (new Date).getTime(),
  553. d = Math.max(0, 16 - (b - c)),
  554. e = window.setTimeout(function() {
  555. a(b + d)
  556. }, d);
  557. return c = b + d, e
  558. }), window.cancelAnimationFrame || (window.cancelAnimationFrame = function(a) {
  559. clearTimeout(a)
  560. }), window.requestAnimFrame = window.requestAnimationFrame, b.hex2rgb = function(a) {
  561. return [(a >> 16 & 255) / 255, (a >> 8 & 255) / 255, (255 & a) / 255]
  562. }, b.rgb2hex = function(a) {
  563. return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
  564. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  565. var a = Array.prototype.slice;
  566. return function(b) {
  567. function c() {
  568. var f = e.concat(a.call(arguments));
  569. d.apply(this instanceof c ? this : b, f)
  570. }
  571. var d = this,
  572. e = a.call(arguments, 1);
  573. if ("function" != typeof d) throw new TypeError;
  574. return c.prototype = function f(a) {
  575. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  576. }(d.prototype), c
  577. }
  578. }()), b.AjaxRequest = function() {
  579. var a = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Microsoft.XMLHTTP"];
  580. if (!window.ActiveXObject) return window.XMLHttpRequest ? new window.XMLHttpRequest : !1;
  581. for (var b = 0; b < a.length; b++) try {
  582. return new window.ActiveXObject(a[b])
  583. } catch (c) {}
  584. }, b.canUseNewCanvasBlendModes = function() {
  585. var a = document.createElement("canvas");
  586. a.width = 1, a.height = 1;
  587. var b = a.getContext("2d");
  588. return 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]
  589. }, b.getNextPowerOfTwo = function(a) {
  590. if (a > 0 && 0 === (a & a - 1)) return a;
  591. for (var b = 1; a > b;) b <<= 1;
  592. return b
  593. }, b.EventTarget = function() {
  594. var a = {};
  595. this.addEventListener = this.on = function(b, c) {
  596. void 0 === a[b] && (a[b] = []), -1 === a[b].indexOf(c) && a[b].unshift(c)
  597. }, this.dispatchEvent = this.emit = function(b) {
  598. if (a[b.type] && a[b.type].length)
  599. for (var c = a[b.type].length - 1; c >= 0; c--) a[b.type][c](b)
  600. }, this.removeEventListener = this.off = function(b, c) {
  601. if (void 0 !== a[b]) {
  602. var d = a[b].indexOf(c); - 1 !== d && a[b].splice(d, 1)
  603. }
  604. }, this.removeAllEventListeners = function(b) {
  605. var c = a[b];
  606. c && (c.length = 0)
  607. }
  608. }, b.PolyK = {}, b.PolyK.Triangulate = function(a) {
  609. var c = !0,
  610. d = a.length >> 1;
  611. if (3 > d) return [];
  612. for (var e = [], f = [], g = 0; d > g; g++) f.push(g);
  613. g = 0;
  614. for (var h = d; h > 3;) {
  615. var i = f[(g + 0) % h],
  616. j = f[(g + 1) % h],
  617. k = f[(g + 2) % h],
  618. l = a[2 * i],
  619. m = a[2 * i + 1],
  620. n = a[2 * j],
  621. o = a[2 * j + 1],
  622. p = a[2 * k],
  623. q = a[2 * k + 1],
  624. r = !1;
  625. if (b.PolyK._convex(l, m, n, o, p, q, c)) {
  626. r = !0;
  627. for (var s = 0; h > s; s++) {
  628. var t = f[s];
  629. if (t !== i && t !== j && t !== k && b.PolyK._PointInTriangle(a[2 * t], a[2 * t + 1], l, m, n, o, p, q)) {
  630. r = !1;
  631. break
  632. }
  633. }
  634. }
  635. if (r) e.push(i, j, k), f.splice((g + 1) % h, 1), h--, g = 0;
  636. else if (g++ > 3 * h) {
  637. if (!c) return window.console.log("PIXI Warning: shape too complex to fill"), [];
  638. for (e = [], f = [], g = 0; d > g; g++) f.push(g);
  639. g = 0, h = d, c = !1
  640. }
  641. }
  642. return e.push(f[0], f[1], f[2]), e
  643. }, b.PolyK._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  644. var i = g - c,
  645. j = h - d,
  646. k = e - c,
  647. l = f - d,
  648. m = a - c,
  649. n = b - d,
  650. o = i * i + j * j,
  651. p = i * k + j * l,
  652. q = i * m + j * n,
  653. r = k * k + l * l,
  654. s = k * m + l * n,
  655. t = 1 / (o * r - p * p),
  656. u = (r * q - p * s) * t,
  657. v = (o * s - p * q) * t;
  658. return u >= 0 && v >= 0 && 1 > u + v
  659. }, b.PolyK._convex = function(a, b, c, d, e, f, g) {
  660. return (b - d) * (e - c) + (c - a) * (f - d) >= 0 === g
  661. }, b.initDefaultShaders = function() {}, b.CompileVertexShader = function(a, c) {
  662. return b._CompileShader(a, c, a.VERTEX_SHADER)
  663. }, b.CompileFragmentShader = function(a, c) {
  664. return b._CompileShader(a, c, a.FRAGMENT_SHADER)
  665. }, b._CompileShader = function(a, b, c) {
  666. var d = b.join("\n"),
  667. e = a.createShader(c);
  668. return a.shaderSource(e, d), a.compileShader(e), a.getShaderParameter(e, a.COMPILE_STATUS) ? e : (window.console.log(a.getShaderInfoLog(e)), null)
  669. }, b.compileProgram = function(a, c, d) {
  670. var e = b.CompileFragmentShader(a, d),
  671. f = b.CompileVertexShader(a, c),
  672. g = a.createProgram();
  673. 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
  674. }, b.PixiShader = function(a) {
  675. 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()
  676. }, b.PixiShader.prototype.init = function() {
  677. var a = this.gl,
  678. c = b.compileProgram(a, this.vertexSrc || b.PixiShader.defaultVertexSrc, this.fragmentSrc);
  679. 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];
  680. for (var d in this.uniforms) this.uniforms[d].uniformLocation = a.getUniformLocation(c, d);
  681. this.initUniforms(), this.program = c
  682. }, b.PixiShader.prototype.initUniforms = function() {
  683. this.textureCount = 1;
  684. var a, b = this.gl;
  685. for (var c in this.uniforms) {
  686. a = this.uniforms[c];
  687. var d = a.type;
  688. "sampler2D" === d ? (a._init = !1, null !== a.value && this.initSampler2D(a)) : "mat2" === d || "mat3" === d || "mat4" === d ? (a.glMatrix = !0, a.glValueLength = 1, "mat2" === d ? a.glFunc = b.uniformMatrix2fv : "mat3" === d ? a.glFunc = b.uniformMatrix3fv : "mat4" === d && (a.glFunc = b.uniformMatrix4fv)) : (a.glFunc = b["uniform" + d], a.glValueLength = "2f" === d || "2i" === d ? 2 : "3f" === d || "3i" === d ? 3 : "4f" === d || "4i" === d ? 4 : 1)
  689. }
  690. }, b.PixiShader.prototype.initSampler2D = function(a) {
  691. if (a.value && a.value.baseTexture && a.value.baseTexture.hasLoaded) {
  692. var b = this.gl;
  693. if (b.activeTexture(b["TEXTURE" + this.textureCount]), b.bindTexture(b.TEXTURE_2D, a.value.baseTexture._glTextures[b.id]), a.textureData) {
  694. var c = a.textureData,
  695. d = c.magFilter ? c.magFilter : b.LINEAR,
  696. e = c.minFilter ? c.minFilter : b.LINEAR,
  697. f = c.wrapS ? c.wrapS : b.CLAMP_TO_EDGE,
  698. g = c.wrapT ? c.wrapT : b.CLAMP_TO_EDGE,
  699. h = c.luminance ? b.LUMINANCE : b.RGBA;
  700. if (c.repeat && (f = b.REPEAT, g = b.REPEAT), b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL, !!c.flipY), c.width) {
  701. var i = c.width ? c.width : 512,
  702. j = c.height ? c.height : 2,
  703. k = c.border ? c.border : 0;
  704. b.texImage2D(b.TEXTURE_2D, 0, h, i, j, k, h, b.UNSIGNED_BYTE, null)
  705. } else b.texImage2D(b.TEXTURE_2D, 0, h, b.RGBA, b.UNSIGNED_BYTE, a.value.baseTexture.source);
  706. 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)
  707. }
  708. b.uniform1i(a.uniformLocation, this.textureCount), a._init = !0, this.textureCount++
  709. }
  710. }, b.PixiShader.prototype.syncUniforms = function() {
  711. this.textureCount = 1;
  712. var a, c = this.gl;
  713. for (var 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))
  714. }, b.PixiShader.prototype.destroy = function() {
  715. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  716. }, 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) {
  717. 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()
  718. }, b.PixiFastShader.prototype.init = function() {
  719. var a = this.gl,
  720. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  721. 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
  722. }, b.PixiFastShader.prototype.destroy = function() {
  723. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  724. }, b.StripShader = function(a) {
  725. 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()
  726. }, b.StripShader.prototype.init = function() {
  727. var a = this.gl,
  728. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  729. 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
  730. }, b.PrimitiveShader = function(a) {
  731. 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()
  732. }, b.PrimitiveShader.prototype.init = function() {
  733. var a = this.gl,
  734. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  735. 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
  736. }, b.PrimitiveShader.prototype.destroy = function() {
  737. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  738. }, b.ComplexPrimitiveShader = function(a) {
  739. 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()
  740. }, b.ComplexPrimitiveShader.prototype.init = function() {
  741. var a = this.gl,
  742. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  743. 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
  744. }, b.ComplexPrimitiveShader.prototype.destroy = function() {
  745. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  746. }, b.WebGLGraphics = function() {}, b.WebGLGraphics.renderGraphics = function(a, c) {
  747. var d, e = c.gl,
  748. f = c.projection,
  749. g = c.offset,
  750. h = c.shaderManager.primitiveShader;
  751. a.dirty && b.WebGLGraphics.updateGraphics(a, e);
  752. for (var i = a._webGL[e.id], j = 0; j < i.data.length; j++) 1 === i.data[j].mode ? (d = i.data[j], c.stencilManager.pushStencil(a, d, c), e.drawElements(e.TRIANGLE_FAN, 4, e.UNSIGNED_SHORT, 2 * (d.indices.length - 4)), c.stencilManager.popStencil(a, d, c), this.last = d.mode) : (d = i.data[j], c.shaderManager.setShader(h), h = c.shaderManager.primitiveShader, 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, d.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, d.indexBuffer), e.drawElements(e.TRIANGLE_STRIP, d.indices.length, e.UNSIGNED_SHORT, 0))
  753. }, b.WebGLGraphics.updateGraphics = function(a, c) {
  754. var d = a._webGL[c.id];
  755. d || (d = a._webGL[c.id] = {
  756. lastIndex: 0,
  757. data: [],
  758. gl: c
  759. }), a.dirty = !1;
  760. var e;
  761. if (a.clearDirty) {
  762. for (a.clearDirty = !1, e = 0; e < d.data.length; e++) {
  763. var f = d.data[e];
  764. f.reset(), b.WebGLGraphics.graphicsDataPool.push(f)
  765. }
  766. d.data = [], d.lastIndex = 0
  767. }
  768. var g;
  769. for (e = d.lastIndex; e < a.graphicsData.length; e++) {
  770. var h = a.graphicsData[e];
  771. 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++
  772. }
  773. for (e = 0; e < d.data.length; e++) g = d.data[e], g.dirty && g.upload()
  774. }, b.WebGLGraphics.switchMode = function(a, c) {
  775. var d;
  776. 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
  777. }, b.WebGLGraphics.buildRectangle = function(a, c) {
  778. var d = a.points,
  779. e = d[0],
  780. f = d[1],
  781. g = d[2],
  782. h = d[3];
  783. if (a.fill) {
  784. var i = b.hex2rgb(a.fillColor),
  785. j = a.fillAlpha,
  786. k = i[0] * j,
  787. l = i[1] * j,
  788. m = i[2] * j,
  789. n = c.points,
  790. o = c.indices,
  791. p = n.length / 6;
  792. 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)
  793. }
  794. if (a.lineWidth) {
  795. var q = a.points;
  796. a.points = [e, f, e + g, f, e + g, f + h, e, f + h, e, f], b.WebGLGraphics.buildLine(a, c), a.points = q
  797. }
  798. }, b.WebGLGraphics.buildRoundedRectangle = function(a, c) {
  799. var d = a.points,
  800. e = d[0],
  801. f = d[1],
  802. g = d[2],
  803. h = d[3],
  804. i = d[4],
  805. j = [];
  806. 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) {
  807. var k = b.hex2rgb(a.fillColor),
  808. l = a.fillAlpha,
  809. m = k[0] * l,
  810. n = k[1] * l,
  811. o = k[2] * l,
  812. p = c.points,
  813. q = c.indices,
  814. r = p.length / 6,
  815. s = b.PolyK.Triangulate(j),
  816. t = 0;
  817. for (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);
  818. for (t = 0; t < j.length; t++) p.push(j[t], j[++t], m, n, o, l)
  819. }
  820. if (a.lineWidth) {
  821. var u = a.points;
  822. a.points = j, b.WebGLGraphics.buildLine(a, c), a.points = u
  823. }
  824. }, b.WebGLGraphics.quadraticBezierCurve = function(a, b, c, d, e, f) {
  825. function g(a, b, c) {
  826. var d = b - a;
  827. return a + d * c
  828. }
  829. for (var h, i, j, k, l, m, n = 20, o = [], p = 0, q = 0; n >= q; q++) p = q / n, h = g(a, c, p), i = g(b, d, p), j = g(c, e, p), k = g(d, f, p), l = g(h, j, p), m = g(i, k, p), o.push(l, m);
  830. return o
  831. }, b.WebGLGraphics.buildCircle = function(a, c) {
  832. var d = a.points,
  833. e = d[0],
  834. f = d[1],
  835. g = d[2],
  836. h = d[3],
  837. i = 40,
  838. j = 2 * Math.PI / i,
  839. k = 0;
  840. if (a.fill) {
  841. var l = b.hex2rgb(a.fillColor),
  842. m = a.fillAlpha,
  843. n = l[0] * m,
  844. o = l[1] * m,
  845. p = l[2] * m,
  846. q = c.points,
  847. r = c.indices,
  848. s = q.length / 6;
  849. for (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++);
  850. r.push(s - 1)
  851. }
  852. if (a.lineWidth) {
  853. var t = a.points;
  854. for (a.points = [], k = 0; i + 1 > k; k++) a.points.push(e + Math.sin(j * k) * g, f + Math.cos(j * k) * h);
  855. b.WebGLGraphics.buildLine(a, c), a.points = t
  856. }
  857. }, b.WebGLGraphics.buildLine = function(a, c) {
  858. var d = 0,
  859. e = a.points;
  860. if (0 !== e.length) {
  861. if (a.lineWidth % 2)
  862. for (d = 0; d < e.length; d++) e[d] += .5;
  863. var f = new b.Point(e[0], e[1]),
  864. g = new b.Point(e[e.length - 2], e[e.length - 1]);
  865. if (f.x === g.x && f.y === g.y) {
  866. e = e.slice(), e.pop(), e.pop(), g = new b.Point(e[e.length - 2], e[e.length - 1]);
  867. var h = g.x + .5 * (f.x - g.x),
  868. i = g.y + .5 * (f.y - g.y);
  869. e.unshift(h, i), e.push(h, i)
  870. }
  871. var j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G = c.points,
  872. H = c.indices,
  873. I = e.length / 2,
  874. J = e.length,
  875. K = G.length / 6,
  876. L = a.lineWidth / 2,
  877. M = b.hex2rgb(a.lineColor),
  878. N = a.lineAlpha,
  879. O = M[0] * N,
  880. P = M[1] * N,
  881. Q = M[2] * N;
  882. for (l = e[0], m = e[1], n = e[2], o = e[3], r = -(m - o), s = l - n, F = Math.sqrt(r * r + s * s), r /= F, s /= F, r *= L, s *= L, G.push(l - r, m - s, O, P, Q, N), G.push(l + r, m + s, O, P, Q, N), d = 1; I - 1 > d; d++) l = e[2 * (d - 1)], m = e[2 * (d - 1) + 1], n = e[2 * d], o = e[2 * d + 1], p = e[2 * (d + 1)], q = e[2 * (d + 1) + 1], r = -(m - o), s = l - n, F = Math.sqrt(r * r + s * s), r /= F, s /= F, r *= L, s *= L, t = -(o - q), u = n - p, F = Math.sqrt(t * t + u * u), t /= F, u /= F, t *= L, u *= L, x = -s + m - (-s + o), y = -r + n - (-r + l), z = (-r + l) * (-s + o) - (-r + n) * (-s + m), A = -u + q - (-u + o), B = -t + n - (-t + p), C = (-t + p) * (-u + o) - (-t + n) * (-u + q), D = x * B - A * y, Math.abs(D) < .1 ? (D += 10.1, G.push(n - r, o - s, O, P, Q, N), G.push(n + r, o + s, O, P, Q, N)) : (j = (y * C - B * z) / D, k = (A * z - x * C) / D, E = (j - n) * (j - n) + (k - o) + (k - o), E > 19600 ? (v = r - t, w = s - u, F = Math.sqrt(v * v + w * w), v /= F, w /= F, v *= L, w *= L, G.push(n - v, o - w), G.push(O, P, Q, N), G.push(n + v, o + w), G.push(O, P, Q, N), G.push(n - v, o - w), G.push(O, P, Q, N), J++) : (G.push(j, k), G.push(O, P, Q, N), G.push(n - (j - n), o - (k - o)), G.push(O, P, Q, N)));
  883. for (l = e[2 * (I - 2)], m = e[2 * (I - 2) + 1], n = e[2 * (I - 1)], o = e[2 * (I - 1) + 1], r = -(m - o), s = l - n, F = Math.sqrt(r * r + s * s), r /= F, s /= F, r *= L, s *= L, G.push(n - r, o - s), G.push(O, P, Q, N), G.push(n + r, o + s), G.push(O, P, Q, N), H.push(K), d = 0; J > d; d++) H.push(K++);
  884. H.push(K - 1)
  885. }
  886. }, b.WebGLGraphics.buildComplexPoly = function(a, c) {
  887. var d = a.points.slice();
  888. if (!(d.length < 6)) {
  889. var e = c.indices;
  890. c.points = d, c.alpha = a.fillAlpha, c.color = b.hex2rgb(a.fillColor);
  891. for (var f, g, h = 1 / 0, i = -1 / 0, j = 1 / 0, k = -1 / 0, l = 0; l < d.length; l += 2) f = d[l], g = d[l + 1], h = h > f ? f : h, i = f > i ? f : i, j = j > g ? g : j, k = g > k ? g : k;
  892. d.push(h, j, i, j, i, k, h, k);
  893. var m = d.length / 2;
  894. for (l = 0; m > l; l++) e.push(l)
  895. }
  896. }, b.WebGLGraphics.buildPoly = function(a, c) {
  897. var d = a.points;
  898. if (!(d.length < 6)) {
  899. var e = c.points,
  900. f = c.indices,
  901. g = d.length / 2,
  902. h = b.hex2rgb(a.fillColor),
  903. i = a.fillAlpha,
  904. j = h[0] * i,
  905. k = h[1] * i,
  906. l = h[2] * i,
  907. m = b.PolyK.Triangulate(d),
  908. n = e.length / 6,
  909. o = 0;
  910. for (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);
  911. for (o = 0; g > o; o++) e.push(d[2 * o], d[2 * o + 1], j, k, l, i)
  912. }
  913. }, b.WebGLGraphics.graphicsDataPool = [], b.WebGLGraphicsData = function(a) {
  914. 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
  915. }, b.WebGLGraphicsData.prototype.reset = function() {
  916. this.points = [], this.indices = [], this.lastIndex = 0
  917. }, b.WebGLGraphicsData.prototype.upload = function() {
  918. var a = this.gl;
  919. 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
  920. }, b.glContexts = [], b.WebGLRenderer = function(a, c, d, e, f, g) {
  921. 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 = {
  922. alpha: this.transparent,
  923. antialias: !!f,
  924. premultipliedAlpha: !!e,
  925. stencil: !0,
  926. preserveDrawingBuffer: g
  927. };
  928. var h = null;
  929. if (["experimental-webgl", "webgl"].forEach(function(a) {
  930. try {
  931. h = h || this.view.getContext(a, this.options)
  932. } catch (b) {}
  933. }, this), !h) throw new Error("This browser does not support webGL. Try using the canvas renderer" + this);
  934. 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)
  935. }, b.WebGLRenderer.prototype.constructor = b.WebGLRenderer, b.WebGLRenderer.prototype.render = function(a) {
  936. if (!this.contextLost) {
  937. 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)));
  938. var c = this.gl;
  939. 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))
  940. }
  941. }, b.WebGLRenderer.prototype.renderDisplayObject = function(a, c, d) {
  942. 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()
  943. }, b.WebGLRenderer.updateTextures = function() {
  944. var a = 0;
  945. for (a = 0; a < b.Texture.frameUpdates.length; a++) b.WebGLRenderer.updateTextureFrame(b.Texture.frameUpdates[a]);
  946. for (a = 0; a < b.texturesToDestroy.length; a++) b.WebGLRenderer.destroyTexture(b.texturesToDestroy[a]);
  947. b.texturesToUpdate.length = 0, b.texturesToDestroy.length = 0, b.Texture.frameUpdates.length = 0
  948. }, b.WebGLRenderer.destroyTexture = function(a) {
  949. for (var c = a._glTextures.length - 1; c >= 0; c--) {
  950. var d = a._glTextures[c],
  951. e = b.glContexts[c];
  952. e && d && e.deleteTexture(d)
  953. }
  954. a._glTextures.length = 0
  955. }, b.WebGLRenderer.updateTextureFrame = function(a) {
  956. a._updateWebGLuvs()
  957. }, b.WebGLRenderer.prototype.resize = function(a, b) {
  958. 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
  959. }, b.createWebGLTexture = function(a, c) {
  960. 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]
  961. }, b.updateWebGLTexture = function(a, c) {
  962. 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)
  963. }, b.WebGLRenderer.prototype.handleContextLost = function(a) {
  964. a.preventDefault(), this.contextLost = !0
  965. }, b.WebGLRenderer.prototype.handleContextRestored = function() {
  966. try {
  967. this.gl = this.view.getContext("experimental-webgl", this.options)
  968. } catch (a) {
  969. try {
  970. this.gl = this.view.getContext("webgl", this.options)
  971. } catch (c) {
  972. throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this)
  973. }
  974. }
  975. var d = this.gl;
  976. 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);
  977. for (var e in b.TextureCache) {
  978. var f = b.TextureCache[e].baseTexture;
  979. f._glTextures = []
  980. }
  981. this.contextLost = !1
  982. }, b.WebGLRenderer.prototype.destroy = function() {
  983. 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
  984. }, b.WebGLRenderer.glContextId = 0, b.WebGLBlendModeManager = function(a) {
  985. this.gl = a, this.currentBlendMode = 99999
  986. }, b.WebGLBlendModeManager.prototype.setBlendMode = function(a) {
  987. if (this.currentBlendMode === a) return !1;
  988. this.currentBlendMode = a;
  989. var c = b.blendModesWebGL[this.currentBlendMode];
  990. return this.gl.blendFunc(c[0], c[1]), !0
  991. }, b.WebGLBlendModeManager.prototype.destroy = function() {
  992. this.gl = null
  993. }, b.WebGLMaskManager = function(a) {
  994. this.maskStack = [], this.maskPosition = 0, this.setContext(a), this.reverse = !1, this.count = 0
  995. }, b.WebGLMaskManager.prototype.setContext = function(a) {
  996. this.gl = a
  997. }, b.WebGLMaskManager.prototype.pushMask = function(a, c) {
  998. var d = c.gl;
  999. a.dirty && b.WebGLGraphics.updateGraphics(a, d), a._webGL[d.id].data.length && c.stencilManager.pushStencil(a, a._webGL[d.id].data[0], c)
  1000. }, b.WebGLMaskManager.prototype.popMask = function(a, b) {
  1001. var c = this.gl;
  1002. b.stencilManager.popStencil(a, a._webGL[c.id].data[0], b)
  1003. }, b.WebGLMaskManager.prototype.destroy = function() {
  1004. this.maskStack = null, this.gl = null
  1005. }, b.WebGLStencilManager = function(a) {
  1006. this.stencilStack = [], this.setContext(a), this.reverse = !0, this.count = 0
  1007. }, b.WebGLStencilManager.prototype.setContext = function(a) {
  1008. this.gl = a
  1009. }, b.WebGLStencilManager.prototype.pushStencil = function(a, b, c) {
  1010. var d = this.gl;
  1011. 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);
  1012. var e = this.count;
  1013. 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++
  1014. }, b.WebGLStencilManager.prototype.bindGraphics = function(a, c, d) {
  1015. this._currentGraphics = a;
  1016. var e, f = this.gl,
  1017. g = d.projection,
  1018. h = d.offset;
  1019. 1 === c.mode ? (e = d.shaderManager.complexPrimativeShader, d.shaderManager.setShader(e), f.uniformMatrix3fv(e.translationMatrix, !1, a.worldTransform.toArray(!0)), f.uniform2f(e.projectionVector, g.x, -g.y), f.uniform2f(e.offsetVector, -h.x, -h.y), f.uniform3fv(e.tintColor, b.hex2rgb(a.tint)), f.uniform3fv(e.color, c.color), f.uniform1f(e.alpha, a.worldAlpha * c.alpha), f.bindBuffer(f.ARRAY_BUFFER, c.buffer), f.vertexAttribPointer(e.aVertexPosition, 2, f.FLOAT, !1, 8, 0), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, c.indexBuffer)) : (e = d.shaderManager.primitiveShader, d.shaderManager.setShader(e), f.uniformMatrix3fv(e.translationMatrix, !1, a.worldTransform.toArray(!0)), f.uniform2f(e.projectionVector, g.x, -g.y), f.uniform2f(e.offsetVector, -h.x, -h.y), f.uniform3fv(e.tintColor, b.hex2rgb(a.tint)), f.uniform1f(e.alpha, a.worldAlpha), f.bindBuffer(f.ARRAY_BUFFER, c.buffer), f.vertexAttribPointer(e.aVertexPosition, 2, f.FLOAT, !1, 24, 0), f.vertexAttribPointer(e.colorAttribute, 4, f.FLOAT, !1, 24, 8), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, c.indexBuffer))
  1020. }, b.WebGLStencilManager.prototype.popStencil = function(a, b, c) {
  1021. var d = this.gl;
  1022. if (this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length) d.disable(d.STENCIL_TEST);
  1023. else {
  1024. var e = this.count;
  1025. 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)
  1026. }
  1027. }, b.WebGLStencilManager.prototype.destroy = function() {
  1028. this.maskStack = null, this.gl = null
  1029. }, b.WebGLShaderManager = function(a) {
  1030. this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [], this.shaderMap = [];
  1031. for (var b = 0; b < this.maxAttibs; b++) this.attribState[b] = !1;
  1032. this.setContext(a)
  1033. }, b.WebGLShaderManager.prototype.setContext = function(a) {
  1034. 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)
  1035. }, b.WebGLShaderManager.prototype.setAttribs = function(a) {
  1036. var b;
  1037. for (b = 0; b < this.tempAttribState.length; b++) this.tempAttribState[b] = !1;
  1038. for (b = 0; b < a.length; b++) {
  1039. var c = a[b];
  1040. this.tempAttribState[c] = !0
  1041. }
  1042. var d = this.gl;
  1043. for (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))
  1044. }, b.WebGLShaderManager.prototype.setShader = function(a) {
  1045. return this._currentId === a._UID ? !1 : (this._currentId = a._UID, this.currentShader = a, this.gl.useProgram(a.program), this.setAttribs(a.attributes), !0)
  1046. }, b.WebGLShaderManager.prototype.destroy = function() {
  1047. this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null
  1048. }, b.WebGLSpriteBatch = function(a) {
  1049. this.vertSize = 6, this.size = 2e3;
  1050. var b = 4 * this.size * this.vertSize,
  1051. c = 6 * this.size;
  1052. this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.lastIndexCount = 0;
  1053. for (var 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;
  1054. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.setContext(a), this.dirty = !0, this.textures = [], this.blendModes = []
  1055. }, b.WebGLSpriteBatch.prototype.setContext = function(a) {
  1056. 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
  1057. }, b.WebGLSpriteBatch.prototype.begin = function(a) {
  1058. this.renderSession = a, this.shader = this.renderSession.shaderManager.defaultShader, this.start()
  1059. }, b.WebGLSpriteBatch.prototype.end = function() {
  1060. this.flush()
  1061. }, b.WebGLSpriteBatch.prototype.render = function(a) {
  1062. var b = a.texture;
  1063. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = b.baseTexture);
  1064. var c = b._uvs;
  1065. if (c) {
  1066. var d, e, f, g, h = a.worldAlpha,
  1067. i = a.tint,
  1068. j = this.vertices,
  1069. k = a.anchor.x,
  1070. l = a.anchor.y;
  1071. if (b.trim) {
  1072. var m = b.trim;
  1073. e = m.x - k * m.width, d = e + b.crop.width, g = m.y - l * m.height, f = g + b.crop.height
  1074. } else d = b.frame.width * (1 - k), e = b.frame.width * -k, f = b.frame.height * (1 - l), g = b.frame.height * -l;
  1075. var n = 4 * this.currentBatchSize * this.vertSize,
  1076. o = a.worldTransform,
  1077. p = o.a,
  1078. q = o.c,
  1079. r = o.b,
  1080. s = o.d,
  1081. t = o.tx,
  1082. u = o.ty;
  1083. j[n++] = p * e + r * g + t, j[n++] = s * g + q * e + u, j[n++] = c.x0, j[n++] = c.y0, j[n++] = h, j[n++] = i, j[n++] = p * d + r * g + t, j[n++] = s * g + q * d + u, j[n++] = c.x1, j[n++] = c.y1, j[n++] = h, j[n++] = i, j[n++] = p * d + r * f + t, j[n++] = s * f + q * d + u, j[n++] = c.x2, j[n++] = c.y2, j[n++] = h, j[n++] = i, j[n++] = p * e + r * f + t, j[n++] = s * f + q * e + u, j[n++] = c.x3, j[n++] = c.y3, j[n++] = h, j[n++] = i, this.textures[this.currentBatchSize] = a.texture.baseTexture, this.blendModes[this.currentBatchSize] = a.blendMode, this.currentBatchSize++
  1084. }
  1085. }, b.WebGLSpriteBatch.prototype.renderTilingSprite = function(a) {
  1086. var c = a.tilingTexture;
  1087. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = c.baseTexture), a._uvs || (a._uvs = new b.TextureUvs);
  1088. var d = a._uvs;
  1089. a.tilePosition.x %= c.baseTexture.width * a.tileScaleOffset.x, a.tilePosition.y %= c.baseTexture.height * a.tileScaleOffset.y;
  1090. var e = a.tilePosition.x / (c.baseTexture.width * a.tileScaleOffset.x),
  1091. f = a.tilePosition.y / (c.baseTexture.height * a.tileScaleOffset.y),
  1092. g = a.width / c.baseTexture.width / (a.tileScale.x * a.tileScaleOffset.x),
  1093. h = a.height / c.baseTexture.height / (a.tileScale.y * a.tileScaleOffset.y);
  1094. 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;
  1095. var i = a.worldAlpha,
  1096. j = a.tint,
  1097. k = this.vertices,
  1098. l = a.width,
  1099. m = a.height,
  1100. n = a.anchor.x,
  1101. o = a.anchor.y,
  1102. p = l * (1 - n),
  1103. q = l * -n,
  1104. r = m * (1 - o),
  1105. s = m * -o,
  1106. t = 4 * this.currentBatchSize * this.vertSize,
  1107. u = a.worldTransform,
  1108. v = u.a,
  1109. w = u.c,
  1110. x = u.b,
  1111. y = u.d,
  1112. z = u.tx,
  1113. A = u.ty;
  1114. 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++
  1115. }, b.WebGLSpriteBatch.prototype.flush = function() {
  1116. if (0 !== this.currentBatchSize) {
  1117. var a = this.gl;
  1118. if (this.renderSession.shaderManager.setShader(this.renderSession.shaderManager.defaultShader), this.dirty) {
  1119. this.dirty = !1, a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  1120. var b = this.renderSession.projection;
  1121. a.uniform2f(this.shader.projectionVector, b.x, b.y);
  1122. var c = 4 * this.vertSize;
  1123. 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)
  1124. }
  1125. if (this.currentBatchSize > .5 * this.size) a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertices);
  1126. else {
  1127. var d = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1128. a.bufferSubData(a.ARRAY_BUFFER, 0, d)
  1129. }
  1130. for (var e, f, 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++;
  1131. this.renderBatch(i, g, h), this.currentBatchSize = 0
  1132. }
  1133. }, b.WebGLSpriteBatch.prototype.renderBatch = function(a, c, d) {
  1134. if (0 !== c) {
  1135. var e = this.gl;
  1136. 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, 6 * d * 2), this.renderSession.drawCount++
  1137. }
  1138. }, b.WebGLSpriteBatch.prototype.stop = function() {
  1139. this.flush()
  1140. }, b.WebGLSpriteBatch.prototype.start = function() {
  1141. this.dirty = !0
  1142. }, b.WebGLSpriteBatch.prototype.destroy = function() {
  1143. this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null
  1144. }, b.WebGLFastSpriteBatch = function(a) {
  1145. this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize;
  1146. var b = 4 * this.size * this.vertSize,
  1147. c = 6 * this.maxSize;
  1148. this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.vertexBuffer = null, this.indexBuffer = null, this.lastIndexCount = 0;
  1149. for (var 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;
  1150. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(a)
  1151. }, b.WebGLFastSpriteBatch.prototype.setContext = function(a) {
  1152. 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)
  1153. }, b.WebGLFastSpriteBatch.prototype.begin = function(a, b) {
  1154. this.renderSession = b, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = a.worldTransform.toArray(!0), this.start()
  1155. }, b.WebGLFastSpriteBatch.prototype.end = function() {
  1156. this.flush()
  1157. }, b.WebGLFastSpriteBatch.prototype.render = function(a) {
  1158. var b = a.children,
  1159. c = b[0];
  1160. if (c.texture._uvs) {
  1161. this.currentBaseTexture = c.texture.baseTexture, c.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(c.blendMode));
  1162. for (var d = 0, e = b.length; e > d; d++) this.renderSprite(b[d]);
  1163. this.flush()
  1164. }
  1165. }, b.WebGLFastSpriteBatch.prototype.renderSprite = function(a) {
  1166. if (a.visible && (a.texture.baseTexture === this.currentBaseTexture || (this.flush(), this.currentBaseTexture = a.texture.baseTexture, a.texture._uvs))) {
  1167. var b, c, d, e, f, g, h, i, j = this.vertices;
  1168. if (b = a.texture._uvs, c = a.texture.frame.width, d = a.texture.frame.height, a.texture.trim) {
  1169. var k = a.texture.trim;
  1170. f = k.x - a.anchor.x * k.width, e = f + a.texture.crop.width, h = k.y - a.anchor.y * k.height, g = h + a.texture.crop.height
  1171. } else e = a.texture.frame.width * (1 - a.anchor.x), f = a.texture.frame.width * -a.anchor.x, g = a.texture.frame.height * (1 - a.anchor.y), h = a.texture.frame.height * -a.anchor.y;
  1172. i = 4 * this.currentBatchSize * this.vertSize, j[i++] = f, j[i++] = h, j[i++] = a.position.x, j[i++] = a.position.y, j[i++] = a.scale.x, j[i++] = a.scale.y, j[i++] = a.rotation, j[i++] = b.x0, j[i++] = b.y1, j[i++] = a.alpha, j[i++] = e, j[i++] = h, j[i++] = a.position.x, j[i++] = a.position.y, j[i++] = a.scale.x, j[i++] = a.scale.y, j[i++] = a.rotation, j[i++] = b.x1, j[i++] = b.y1, j[i++] = a.alpha, j[i++] = e, j[i++] = g, j[i++] = a.position.x, j[i++] = a.position.y, j[i++] = a.scale.x, j[i++] = a.scale.y, j[i++] = a.rotation, j[i++] = b.x2, j[i++] = b.y2, j[i++] = a.alpha, j[i++] = f, j[i++] = g, j[i++] = a.position.x, j[i++] = a.position.y, j[i++] = a.scale.x, j[i++] = a.scale.y, j[i++] = a.rotation, j[i++] = b.x3, j[i++] = b.y3, j[i++] = a.alpha, this.currentBatchSize++, this.currentBatchSize >= this.size && this.flush()
  1173. }
  1174. }, b.WebGLFastSpriteBatch.prototype.flush = function() {
  1175. if (0 !== this.currentBatchSize) {
  1176. var a = this.gl;
  1177. if (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);
  1178. else {
  1179. var c = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1180. a.bufferSubData(a.ARRAY_BUFFER, 0, c)
  1181. }
  1182. a.drawElements(a.TRIANGLES, 6 * this.currentBatchSize, a.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++
  1183. }
  1184. }, b.WebGLFastSpriteBatch.prototype.stop = function() {
  1185. this.flush()
  1186. }, b.WebGLFastSpriteBatch.prototype.start = function() {
  1187. var a = this.gl;
  1188. a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  1189. var b = this.renderSession.projection;
  1190. a.uniform2f(this.shader.projectionVector, b.x, b.y), a.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix);
  1191. var c = 4 * this.vertSize;
  1192. 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)
  1193. }, b.WebGLFilterManager = function(a, b) {
  1194. this.transparent = b, this.filterStack = [], this.offsetX = 0, this.offsetY = 0, this.setContext(a)
  1195. }, b.WebGLFilterManager.prototype.setContext = function(a) {
  1196. this.gl = a, this.texturePool = [], this.initShaderBuffers()
  1197. }, b.WebGLFilterManager.prototype.begin = function(a, b) {
  1198. this.renderSession = a, this.defaultShader = a.shaderManager.defaultShader;
  1199. var c = this.renderSession.projection;
  1200. this.width = 2 * c.x, this.height = 2 * -c.y, this.buffer = b
  1201. }, b.WebGLFilterManager.prototype.pushFilter = function(a) {
  1202. var c = this.gl,
  1203. d = this.renderSession.projection,
  1204. e = this.renderSession.offset;
  1205. a._filterArea = a.target.filterArea || a.target.getBounds(), this.filterStack.push(a);
  1206. var f = a.filterPasses[0];
  1207. this.offsetX += a._filterArea.x, this.offsetY += a._filterArea.y;
  1208. var g = this.texturePool.pop();
  1209. g ? g.resize(this.width, this.height) : g = new b.FilterTexture(this.gl, this.width, this.height), c.bindTexture(c.TEXTURE_2D, g.texture);
  1210. var h = a._filterArea,
  1211. i = f.padding;
  1212. 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
  1213. }, b.WebGLFilterManager.prototype.popFilter = function() {
  1214. var a = this.gl,
  1215. c = this.filterStack.pop(),
  1216. d = c._filterArea,
  1217. e = c._glFilterTexture,
  1218. f = this.renderSession.projection,
  1219. g = this.renderSession.offset;
  1220. if (c.filterPasses.length > 1) {
  1221. 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);
  1222. var h = e,
  1223. i = this.texturePool.pop();
  1224. 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);
  1225. for (var j = 0; j < c.filterPasses.length - 1; j++) {
  1226. var k = c.filterPasses[j];
  1227. 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);
  1228. var l = h;
  1229. h = i, i = l
  1230. }
  1231. a.enable(a.BLEND), e = h, this.texturePool.push(i)
  1232. }
  1233. var m = c.filterPasses[c.filterPasses.length - 1];
  1234. this.offsetX -= d.x, this.offsetY -= d.y;
  1235. var n = this.width,
  1236. o = this.height,
  1237. p = 0,
  1238. q = 0,
  1239. r = this.buffer;
  1240. if (0 === this.filterStack.length) a.colorMask(!0, !0, !0, !0);
  1241. else {
  1242. var s = this.filterStack[this.filterStack.length - 1];
  1243. d = s._filterArea, n = d.width, o = d.height, p = d.x, q = d.y, r = s._glFilterTexture.frameBuffer
  1244. }
  1245. f.x = n / 2, f.y = -o / 2, g.x = p, g.y = q, d = c._filterArea;
  1246. var t = d.x - p,
  1247. u = d.y - q;
  1248. 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
  1249. }, b.WebGLFilterManager.prototype.applyFilterPass = function(a, c, d, e) {
  1250. var f = this.gl,
  1251. g = a.shaders[f.id];
  1252. 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++
  1253. }, b.WebGLFilterManager.prototype.initShaderBuffers = function() {
  1254. var a = this.gl;
  1255. 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)
  1256. }, b.WebGLFilterManager.prototype.destroy = function() {
  1257. var a = this.gl;
  1258. this.filterStack = null, this.offsetX = 0, this.offsetY = 0;
  1259. for (var b = 0; b < this.texturePool.length; b++) this.texturePool[b].destroy();
  1260. this.texturePool = null, a.deleteBuffer(this.vertexBuffer), a.deleteBuffer(this.uvBuffer), a.deleteBuffer(this.colorBuffer), a.deleteBuffer(this.indexBuffer)
  1261. }, b.FilterTexture = function(a, c, d, e) {
  1262. 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)
  1263. }, b.FilterTexture.prototype.clear = function() {
  1264. var a = this.gl;
  1265. a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT)
  1266. }, b.FilterTexture.prototype.resize = function(a, b) {
  1267. if (this.width !== a || this.height !== b) {
  1268. this.width = a, this.height = b;
  1269. var c = this.gl;
  1270. 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)
  1271. }
  1272. }, b.FilterTexture.prototype.destroy = function() {
  1273. var a = this.gl;
  1274. a.deleteFramebuffer(this.frameBuffer), a.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
  1275. }, b.CanvasMaskManager = function() {}, b.CanvasMaskManager.prototype.pushMask = function(a, c) {
  1276. c.save();
  1277. var d = a.alpha,
  1278. e = a.worldTransform;
  1279. c.setTransform(e.a, e.c, e.b, e.d, e.tx, e.ty), b.CanvasGraphics.renderGraphicsMask(a, c), c.clip(), a.worldAlpha = d
  1280. }, b.CanvasMaskManager.prototype.popMask = function(a) {
  1281. a.restore()
  1282. }, b.CanvasTinter = function() {}, b.CanvasTinter.getTintedTexture = function(a, c) {
  1283. var d = a.texture;
  1284. c = b.CanvasTinter.roundColor(c);
  1285. var e = "#" + ("00000" + (0 | c).toString(16)).substr(-6);
  1286. if (d.tintCache = d.tintCache || {}, d.tintCache[e]) return d.tintCache[e];
  1287. var f = b.CanvasTinter.canvas || document.createElement("canvas");
  1288. if (b.CanvasTinter.tintMethod(d, c, f), b.CanvasTinter.convertTintToImage) {
  1289. var g = new Image;
  1290. g.src = f.toDataURL(), d.tintCache[e] = g
  1291. } else d.tintCache[e] = f, b.CanvasTinter.canvas = null;
  1292. return f
  1293. }, b.CanvasTinter.tintWithMultiply = function(a, b, c) {
  1294. var d = c.getContext("2d"),
  1295. e = a.frame;
  1296. 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)
  1297. }, b.CanvasTinter.tintWithOverlay = function(a, b, c) {
  1298. var d = c.getContext("2d"),
  1299. e = a.frame;
  1300. 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)
  1301. }, b.CanvasTinter.tintWithPerPixel = function(a, c, d) {
  1302. var e = d.getContext("2d"),
  1303. f = a.frame;
  1304. 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);
  1305. for (var 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;
  1306. e.putImageData(k, 0, 0)
  1307. }, b.CanvasTinter.roundColor = function(a) {
  1308. var c = b.CanvasTinter.cacheStepsPerColorChannel,
  1309. d = b.hex2rgb(a);
  1310. 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)
  1311. }, 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) {
  1312. 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", {
  1313. alpha: this.transparent
  1314. }), this.refresh = !0, this.view.width = this.width, this.view.height = this.height, this.count = 0, this.maskManager = new b.CanvasMaskManager, this.renderSession = {
  1315. context: this.context,
  1316. maskManager: this.maskManager,
  1317. scaleMode: null,
  1318. smoothProperty: null,
  1319. roundPixels: !1
  1320. }, "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")
  1321. }, b.CanvasRenderer.prototype.constructor = b.CanvasRenderer, b.CanvasRenderer.prototype.render = function(a) {
  1322. 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)
  1323. }, b.CanvasRenderer.prototype.resize = function(a, b) {
  1324. this.width = a, this.height = b, this.view.width = a, this.view.height = b
  1325. }, b.CanvasRenderer.prototype.renderDisplayObject = function(a, b) {
  1326. this.renderSession.context = b || this.context, a._renderCanvas(this.renderSession)
  1327. }, b.CanvasRenderer.prototype.renderStripFlat = function(a) {
  1328. var b = this.context,
  1329. c = a.verticies,
  1330. d = c.length / 2;
  1331. this.count++, b.beginPath();
  1332. for (var e = 1; d - 2 > e; e++) {
  1333. var f = 2 * e,
  1334. g = c[f],
  1335. h = c[f + 2],
  1336. i = c[f + 4],
  1337. j = c[f + 1],
  1338. k = c[f + 3],
  1339. l = c[f + 5];
  1340. b.moveTo(g, j), b.lineTo(h, k), b.lineTo(i, l)
  1341. }
  1342. b.fillStyle = "#FF0000", b.fill(), b.closePath()
  1343. }, b.CanvasRenderer.prototype.renderStrip = function(a) {
  1344. var b = this.context,
  1345. c = a.verticies,
  1346. d = a.uvs,
  1347. e = c.length / 2;
  1348. this.count++;
  1349. for (var f = 1; e - 2 > f; f++) {
  1350. var g = 2 * f,
  1351. h = c[g],
  1352. i = c[g + 2],
  1353. j = c[g + 4],
  1354. k = c[g + 1],
  1355. l = c[g + 3],
  1356. m = c[g + 5],
  1357. n = d[g] * a.texture.width,
  1358. o = d[g + 2] * a.texture.width,
  1359. p = d[g + 4] * a.texture.width,
  1360. q = d[g + 1] * a.texture.height,
  1361. r = d[g + 3] * a.texture.height,
  1362. s = d[g + 5] * a.texture.height;
  1363. b.save(), b.beginPath(), b.moveTo(h, k), b.lineTo(i, l), b.lineTo(j, m), b.closePath(), b.clip();
  1364. var t = n * r + q * p + o * s - r * p - q * o - n * s,
  1365. u = h * r + q * j + i * s - r * j - q * i - h * s,
  1366. v = n * i + h * p + o * j - i * p - h * o - n * j,
  1367. w = n * r * j + q * i * p + h * o * s - h * r * p - q * o * j - n * i * s,
  1368. x = k * r + q * m + l * s - r * m - q * l - k * s,
  1369. y = n * l + k * p + o * m - l * p - k * o - n * m,
  1370. z = n * r * m + q * l * p + k * o * s - k * r * p - q * o * m - n * l * s;
  1371. b.transform(u / t, x / t, v / t, y / t, w / t, z / t), b.drawImage(a.texture.baseTexture.source, 0, 0), b.restore()
  1372. }
  1373. }, b.CanvasBuffer = function(a, b) {
  1374. 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
  1375. }, b.CanvasBuffer.prototype.clear = function() {
  1376. this.context.clearRect(0, 0, this.width, this.height)
  1377. }, b.CanvasBuffer.prototype.resize = function(a, b) {
  1378. this.width = this.canvas.width = a, this.height = this.canvas.height = b
  1379. }, b.CanvasGraphics = function() {}, b.CanvasGraphics.renderGraphics = function(a, c) {
  1380. for (var d = a.worldAlpha, e = "", f = 0; f < a.graphicsData.length; f++) {
  1381. var g = a.graphicsData[f],
  1382. h = g.points;
  1383. if (c.strokeStyle = e = "#" + ("00000" + (0 | g.lineColor).toString(16)).substr(-6), c.lineWidth = g.lineWidth, g.type === b.Graphics.POLY) {
  1384. c.beginPath(), c.moveTo(h[0], h[1]);
  1385. for (var i = 1; i < h.length / 2; i++) c.lineTo(h[2 * i], h[2 * i + 1]);
  1386. 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())
  1387. } else if (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]));
  1388. else if (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());
  1389. else if (g.type === b.Graphics.ELIP) {
  1390. var j = g.points,
  1391. k = 2 * j[2],
  1392. l = 2 * j[3],
  1393. m = j[0] - k / 2,
  1394. n = j[1] - l / 2;
  1395. c.beginPath();
  1396. var o = .5522848,
  1397. p = k / 2 * o,
  1398. q = l / 2 * o,
  1399. r = m + k,
  1400. s = n + l,
  1401. t = m + k / 2,
  1402. u = n + l / 2;
  1403. 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())
  1404. } else if (g.type === b.Graphics.RREC) {
  1405. var v = h[0],
  1406. w = h[1],
  1407. x = h[2],
  1408. y = h[3],
  1409. z = h[4],
  1410. A = Math.min(x, y) / 2 | 0;
  1411. 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())
  1412. }
  1413. }
  1414. }, b.CanvasGraphics.renderGraphicsMask = function(a, c) {
  1415. var d = a.graphicsData.length;
  1416. if (0 !== d) {
  1417. d > 1 && (d = 1, window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));
  1418. for (var e = 0; 1 > e; e++) {
  1419. var f = a.graphicsData[e],
  1420. g = f.points;
  1421. if (f.type === b.Graphics.POLY) {
  1422. c.beginPath(), c.moveTo(g[0], g[1]);
  1423. for (var h = 1; h < g.length / 2; h++) c.lineTo(g[2 * h], g[2 * h + 1]);
  1424. g[0] === g[g.length - 2] && g[1] === g[g.length - 1] && c.closePath()
  1425. } else if (f.type === b.Graphics.RECT) c.beginPath(), c.rect(g[0], g[1], g[2], g[3]), c.closePath();
  1426. else if (f.type === b.Graphics.CIRC) c.beginPath(), c.arc(g[0], g[1], g[2], 0, 2 * Math.PI), c.closePath();
  1427. else if (f.type === b.Graphics.ELIP) {
  1428. var i = f.points,
  1429. j = 2 * i[2],
  1430. k = 2 * i[3],
  1431. l = i[0] - j / 2,
  1432. m = i[1] - k / 2;
  1433. c.beginPath();
  1434. var n = .5522848,
  1435. o = j / 2 * n,
  1436. p = k / 2 * n,
  1437. q = l + j,
  1438. r = m + k,
  1439. s = l + j / 2,
  1440. t = m + k / 2;
  1441. 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()
  1442. } else if (f.type === b.Graphics.RREC) {
  1443. var u = g[0],
  1444. v = g[1],
  1445. w = g[2],
  1446. x = g[3],
  1447. y = g[4],
  1448. z = Math.min(w, x) / 2 | 0;
  1449. 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()
  1450. }
  1451. }
  1452. }
  1453. }, b.Graphics = function() {
  1454. 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 = {
  1455. points: []
  1456. }, this._webGL = [], this.isMask = !1, this.bounds = null, this.boundsPadding = 10, this.dirty = !0
  1457. }, b.Graphics.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Graphics.prototype.constructor = b.Graphics, Object.defineProperty(b.Graphics.prototype, "cacheAsBitmap", {
  1458. get: function() {
  1459. return this._cacheAsBitmap
  1460. },
  1461. set: function(a) {
  1462. this._cacheAsBitmap = a, this._cacheAsBitmap ? this._generateCachedSprite() : (this.destroyCachedSprite(), this.dirty = !0)
  1463. }
  1464. }), b.Graphics.prototype.lineStyle = function(a, c, d) {
  1465. 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 = {
  1466. lineWidth: this.lineWidth,
  1467. lineColor: this.lineColor,
  1468. lineAlpha: this.lineAlpha,
  1469. fillColor: this.fillColor,
  1470. fillAlpha: this.fillAlpha,
  1471. fill: this.filling,
  1472. points: [],
  1473. type: b.Graphics.POLY
  1474. }, this.graphicsData.push(this.currentPath), this
  1475. }, b.Graphics.prototype.moveTo = function(a, c) {
  1476. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = this.currentPath = {
  1477. lineWidth: this.lineWidth,
  1478. lineColor: this.lineColor,
  1479. lineAlpha: this.lineAlpha,
  1480. fillColor: this.fillColor,
  1481. fillAlpha: this.fillAlpha,
  1482. fill: this.filling,
  1483. points: [],
  1484. type: b.Graphics.POLY
  1485. }, this.currentPath.points.push(a, c), this.graphicsData.push(this.currentPath), this
  1486. }, b.Graphics.prototype.lineTo = function(a, b) {
  1487. return this.currentPath.points.push(a, b), this.dirty = !0, this
  1488. }, b.Graphics.prototype.quadraticCurveTo = function(a, b, c, d) {
  1489. 0 === this.currentPath.points.length && this.moveTo(0, 0);
  1490. var e, f, g = 20,
  1491. h = this.currentPath.points;
  1492. 0 === h.length && this.moveTo(0, 0);
  1493. for (var 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);
  1494. return this.dirty = !0, this
  1495. }, b.Graphics.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
  1496. 0 === this.currentPath.points.length && this.moveTo(0, 0);
  1497. for (var g, h, i, j, k, l = 20, m = this.currentPath.points, n = m[m.length - 2], o = m[m.length - 1], p = 0, q = 1; l > q; q++) p = q / l, g = 1 - p, h = g * g, i = h * g, j = p * p, k = j * p, m.push(i * n + 3 * h * p * a + 3 * g * j * c + k * e, i * o + 3 * h * p * b + 3 * g * j * d + k * f);
  1498. return this.dirty = !0, this
  1499. }, b.Graphics.prototype.arcTo = function(a, b, c, d, e) {
  1500. 0 === this.currentPath.points.length && this.moveTo(a, b);
  1501. var f = this.currentPath.points,
  1502. g = f[f.length - 2],
  1503. h = f[f.length - 1],
  1504. i = h - b,
  1505. j = g - a,
  1506. k = d - b,
  1507. l = c - a,
  1508. m = Math.abs(i * l - j * k);
  1509. if (1e-8 > m || 0 === e) f.push(a, b);
  1510. else {
  1511. var n = i * i + j * j,
  1512. o = k * k + l * l,
  1513. p = i * k + j * l,
  1514. q = e * Math.sqrt(n) / m,
  1515. r = e * Math.sqrt(o) / m,
  1516. s = q * p / n,
  1517. t = r * p / o,
  1518. u = q * l + r * j,
  1519. v = q * k + r * i,
  1520. w = j * (r + s),
  1521. x = i * (r + s),
  1522. y = l * (q + t),
  1523. z = k * (q + t),
  1524. A = Math.atan2(x - v, w - u),
  1525. B = Math.atan2(z - v, y - u);
  1526. this.arc(u + a, v + b, e, A, B, j * k > l * i)
  1527. }
  1528. return this.dirty = !0, this
  1529. }, b.Graphics.prototype.arc = function(a, b, c, d, e, f) {
  1530. var g = a + Math.cos(d) * c,
  1531. h = b + Math.sin(d) * c,
  1532. i = this.currentPath.points;
  1533. 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;
  1534. !f && d >= e ? e += 2 * Math.PI : f && e >= d && (d += 2 * Math.PI);
  1535. var j = f ? -1 * (d - e) : e - d,
  1536. k = Math.abs(j) / (2 * Math.PI) * 40;
  1537. if (0 === j) return this;
  1538. for (var 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++) {
  1539. var s = r + q * r,
  1540. t = l + d + m * s,
  1541. u = Math.cos(t),
  1542. v = -Math.sin(t);
  1543. i.push((n * u + o * v) * c + a, (n * -v + o * u) * c + b)
  1544. }
  1545. return this.dirty = !0, this
  1546. }, b.Graphics.prototype.drawPath = function(a) {
  1547. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = this.currentPath = {
  1548. lineWidth: this.lineWidth,
  1549. lineColor: this.lineColor,
  1550. lineAlpha: this.lineAlpha,
  1551. fillColor: this.fillColor,
  1552. fillAlpha: this.fillAlpha,
  1553. fill: this.filling,
  1554. points: [],
  1555. type: b.Graphics.POLY
  1556. }, this.graphicsData.push(this.currentPath), this.currentPath.points = this.currentPath.points.concat(a), this.dirty = !0, this
  1557. }, b.Graphics.prototype.beginFill = function(a, b) {
  1558. return this.filling = !0, this.fillColor = a || 0, this.fillAlpha = arguments.length < 2 ? 1 : b, this
  1559. }, b.Graphics.prototype.endFill = function() {
  1560. return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this
  1561. }, b.Graphics.prototype.drawRect = function(a, c, d, e) {
  1562. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1563. lineWidth: this.lineWidth,
  1564. lineColor: this.lineColor,
  1565. lineAlpha: this.lineAlpha,
  1566. fillColor: this.fillColor,
  1567. fillAlpha: this.fillAlpha,
  1568. fill: this.filling,
  1569. points: [a, c, d, e],
  1570. type: b.Graphics.RECT
  1571. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1572. }, b.Graphics.prototype.drawRoundedRect = function(a, c, d, e, f) {
  1573. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1574. lineWidth: this.lineWidth,
  1575. lineColor: this.lineColor,
  1576. lineAlpha: this.lineAlpha,
  1577. fillColor: this.fillColor,
  1578. fillAlpha: this.fillAlpha,
  1579. fill: this.filling,
  1580. points: [a, c, d, e, f],
  1581. type: b.Graphics.RREC
  1582. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1583. }, b.Graphics.prototype.drawCircle = function(a, c, d) {
  1584. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1585. lineWidth: this.lineWidth,
  1586. lineColor: this.lineColor,
  1587. lineAlpha: this.lineAlpha,
  1588. fillColor: this.fillColor,
  1589. fillAlpha: this.fillAlpha,
  1590. fill: this.filling,
  1591. points: [a, c, d, d],
  1592. type: b.Graphics.CIRC
  1593. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1594. }, b.Graphics.prototype.drawEllipse = function(a, c, d, e) {
  1595. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1596. lineWidth: this.lineWidth,
  1597. lineColor: this.lineColor,
  1598. lineAlpha: this.lineAlpha,
  1599. fillColor: this.fillColor,
  1600. fillAlpha: this.fillAlpha,
  1601. fill: this.filling,
  1602. points: [a, c, d, e],
  1603. type: b.Graphics.ELIP
  1604. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1605. }, b.Graphics.prototype.clear = function() {
  1606. return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this.clearDirty = !0, this.graphicsData = [], this.bounds = null, this
  1607. }, b.Graphics.prototype.generateTexture = function() {
  1608. var a = this.getBounds(),
  1609. c = new b.CanvasBuffer(a.width, a.height),
  1610. d = b.Texture.fromCanvas(c.canvas);
  1611. return c.context.translate(-a.x, -a.y), b.CanvasGraphics.renderGraphics(this, c.context), d
  1612. }, b.Graphics.prototype._renderWebGL = function(a) {
  1613. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  1614. if (this._cacheAsBitmap) return this.dirty && (this._generateCachedSprite(), b.updateWebGLTexture(this._cachedSprite.texture.baseTexture, a.gl), this.dirty = !1), this._cachedSprite.alpha = this.alpha, void b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a);
  1615. 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) {
  1616. a.spriteBatch.currentBlendMode = this.blendMode;
  1617. var c = b.blendModesWebGL[a.spriteBatch.currentBlendMode];
  1618. a.spriteBatch.gl.blendFunc(c[0], c[1])
  1619. }
  1620. if (b.WebGLGraphics.renderGraphics(this, a), this.children.length) {
  1621. a.spriteBatch.start();
  1622. for (var d = 0, e = this.children.length; e > d; d++) this.children[d]._renderWebGL(a);
  1623. a.spriteBatch.stop()
  1624. }
  1625. this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this.mask, a), a.drawCount++, a.spriteBatch.start()
  1626. }
  1627. }, b.Graphics.prototype._renderCanvas = function(a) {
  1628. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  1629. var c = a.context,
  1630. d = this.worldTransform;
  1631. 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);
  1632. for (var e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
  1633. this._mask && a.maskManager.popMask(a.context)
  1634. }
  1635. }, b.Graphics.prototype.getBounds = function(a) {
  1636. this.bounds || this.updateBounds();
  1637. var b = this.bounds.x,
  1638. c = this.bounds.width + this.bounds.x,
  1639. d = this.bounds.y,
  1640. e = this.bounds.height + this.bounds.y,
  1641. f = a || this.worldTransform,
  1642. g = f.a,
  1643. h = f.c,
  1644. i = f.b,
  1645. j = f.d,
  1646. k = f.tx,
  1647. l = f.ty,
  1648. m = g * c + i * e + k,
  1649. n = j * e + h * c + l,
  1650. o = g * b + i * e + k,
  1651. p = j * e + h * b + l,
  1652. q = g * b + i * d + k,
  1653. r = j * d + h * b + l,
  1654. s = g * c + i * d + k,
  1655. t = j * d + h * c + l,
  1656. u = m,
  1657. v = n,
  1658. w = m,
  1659. x = n;
  1660. 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;
  1661. var y = this._bounds;
  1662. return y.x = w, y.width = u - w, y.y = x, y.height = v - x, y
  1663. }, b.Graphics.prototype.updateBounds = function() {
  1664. for (var a, c, d, e, f, g = 1 / 0, h = -1 / 0, i = 1 / 0, j = -1 / 0, k = 0; k < this.graphicsData.length; k++) {
  1665. var l = this.graphicsData[k],
  1666. m = l.type,
  1667. n = l.lineWidth;
  1668. if (a = l.points, m === b.Graphics.RECT) c = a[0] - n / 2, d = a[1] - n / 2, e = a[2] + n, f = a[3] + n, g = g > c ? c : g, h = c + e > h ? c + e : h, i = i > d ? c : i, j = d + f > j ? d + f : j;
  1669. else if (m === b.Graphics.CIRC || m === b.Graphics.ELIP) c = a[0], d = a[1], e = a[2] + n / 2, f = a[3] + n / 2, g = g > c - e ? c - e : g, h = c + e > h ? c + e : h, i = i > d - f ? d - f : i, j = d + f > j ? d + f : j;
  1670. else
  1671. for (var o = 0; o < a.length; o += 2) c = a[o], d = a[o + 1], g = g > c - n ? c - n : g, h = c + n > h ? c + n : h, i = i > d - n ? d - n : i, j = d + n > j ? d + n : j
  1672. }
  1673. var p = this.boundsPadding;
  1674. this.bounds = new b.Rectangle(g - p, i - p, h - g + 2 * p, j - i + 2 * p)
  1675. }, b.Graphics.prototype._generateCachedSprite = function() {
  1676. var a = this.getLocalBounds();
  1677. if (this._cachedSprite) this._cachedSprite.buffer.resize(a.width, a.height);
  1678. else {
  1679. var c = new b.CanvasBuffer(a.width, a.height),
  1680. d = b.Texture.fromCanvas(c.canvas);
  1681. this._cachedSprite = new b.Sprite(d), this._cachedSprite.buffer = c, this._cachedSprite.worldTransform = this.worldTransform
  1682. }
  1683. 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
  1684. }, b.Graphics.prototype.destroyCachedSprite = function() {
  1685. this._cachedSprite.texture.destroy(!0), this._cachedSprite = null
  1686. }, b.Graphics.POLY = 0, b.Graphics.RECT = 1, b.Graphics.CIRC = 2, b.Graphics.ELIP = 3, b.Graphics.RREC = 4, b.Strip = function(a) {
  1687. 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
  1688. }, b.Strip.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Strip.prototype.constructor = b.Strip, b.Strip.prototype._renderWebGL = function(a) {
  1689. !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())
  1690. }, b.Strip.prototype._initWebGL = function(a) {
  1691. var b = a.gl;
  1692. 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)
  1693. }, b.Strip.prototype._renderStrip = function(a) {
  1694. var c = a.gl,
  1695. d = a.projection,
  1696. e = a.offset,
  1697. f = a.shaderManager.stripShader;
  1698. 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)
  1699. }, b.Strip.prototype._renderCanvas = function(a) {
  1700. var b = a.context,
  1701. c = this.worldTransform;
  1702. 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);
  1703. var d = this,
  1704. e = d.verticies,
  1705. f = d.uvs,
  1706. g = e.length / 2;
  1707. this.count++;
  1708. for (var h = 0; g - 2 > h; h++) {
  1709. var i = 2 * h,
  1710. j = e[i],
  1711. k = e[i + 2],
  1712. l = e[i + 4],
  1713. m = e[i + 1],
  1714. n = e[i + 3],
  1715. o = e[i + 5],
  1716. p = (j + k + l) / 3,
  1717. q = (m + n + o) / 3,
  1718. r = j - p,
  1719. s = m - q,
  1720. t = Math.sqrt(r * r + s * s);
  1721. 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);
  1722. var u = f[i] * d.texture.width,
  1723. v = f[i + 2] * d.texture.width,
  1724. w = f[i + 4] * d.texture.width,
  1725. x = f[i + 1] * d.texture.height,
  1726. y = f[i + 3] * d.texture.height,
  1727. z = f[i + 5] * d.texture.height;
  1728. b.save(), b.beginPath(), b.moveTo(j, m), b.lineTo(k, n), b.lineTo(l, o), b.closePath(), b.clip();
  1729. var A = u * y + x * w + v * z - y * w - x * v - u * z,
  1730. B = j * y + x * l + k * z - y * l - x * k - j * z,
  1731. C = u * k + j * w + v * l - k * w - j * v - u * l,
  1732. D = u * y * l + x * k * w + j * v * z - j * y * w - x * v * l - u * k * z,
  1733. E = m * y + x * o + n * z - y * o - x * n - m * z,
  1734. F = u * n + m * w + v * o - n * w - m * v - u * o,
  1735. G = u * y * o + x * n * w + m * v * z - m * y * w - x * v * o - u * n * z;
  1736. b.transform(B / A, E / A, C / A, F / A, D / A, G / A), b.drawImage(d.texture.baseTexture.source, 0, 0), b.restore()
  1737. }
  1738. }, b.Strip.prototype.onTextureUpdate = function() {
  1739. this.updateFrame = !0
  1740. }, b.Rope = function(a, c) {
  1741. 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()
  1742. }, b.Rope.prototype = Object.create(b.Strip.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.refresh = function() {
  1743. var a = this.points;
  1744. if (!(a.length < 1)) {
  1745. var b = this.uvs,
  1746. c = a[0],
  1747. d = this.indices,
  1748. e = this.colors;
  1749. 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;
  1750. for (var f, g, h, i = a.length, j = 1; i > j; j++) f = a[j], g = 4 * j, h = j / (i - 1), j % 2 ? (b[g] = h, b[g + 1] = 0, b[g + 2] = h, b[g + 3] = 1) : (b[g] = h, b[g + 1] = 0, b[g + 2] = h, b[g + 3] = 1), g = 2 * j, e[g] = 1, e[g + 1] = 1, g = 2 * j, d[g] = g, d[g + 1] = g + 1, c = f
  1751. }
  1752. }, b.Rope.prototype.updateTransform = function() {
  1753. var a = this.points;
  1754. if (!(a.length < 1)) {
  1755. var c, d = a[0],
  1756. e = {
  1757. x: 0,
  1758. y: 0
  1759. };
  1760. this.count -= .2;
  1761. for (var f, g, h, i, j, k = this.verticies, l = a.length, m = 0; l > m; m++) f = a[m], g = 4 * m, c = m < a.length - 1 ? a[m + 1] : f, e.y = -(c.x - d.x), e.x = c.y - d.y, h = 10 * (1 - m / (l - 1)), h > 1 && (h = 1), i = Math.sqrt(e.x * e.x + e.y * e.y), j = this.texture.height / 2, e.x /= i, e.y /= i, e.x *= j, e.y *= j, k[g] = f.x + e.x, k[g + 1] = f.y + e.y, k[g + 2] = f.x - e.x, k[g + 3] = f.y - e.y, d = f;
  1762. b.DisplayObjectContainer.prototype.updateTransform.call(this)
  1763. }
  1764. }, b.Rope.prototype.setTexture = function(a) {
  1765. this.texture = a
  1766. }, b.TilingSprite = function(a, c, d) {
  1767. 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
  1768. }, b.TilingSprite.prototype = Object.create(b.Sprite.prototype), b.TilingSprite.prototype.constructor = b.TilingSprite, Object.defineProperty(b.TilingSprite.prototype, "width", {
  1769. get: function() {
  1770. return this._width
  1771. },
  1772. set: function(a) {
  1773. this._width = a
  1774. }
  1775. }), Object.defineProperty(b.TilingSprite.prototype, "height", {
  1776. get: function() {
  1777. return this._height
  1778. },
  1779. set: function(a) {
  1780. this._height = a
  1781. }
  1782. }), b.TilingSprite.prototype.setTexture = function(a) {
  1783. this.texture !== a && (this.texture = a, this.refreshTexture = !0, this.cachedTint = 16777215)
  1784. }, b.TilingSprite.prototype._renderWebGL = function(a) {
  1785. if (this.visible !== !1 && 0 !== this.alpha) {
  1786. var c, d;
  1787. 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);
  1788. a.spriteBatch.stop(), this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(a), a.spriteBatch.start()
  1789. }
  1790. }, b.TilingSprite.prototype._renderCanvas = function(a) {
  1791. if (this.visible !== !1 && 0 !== this.alpha) {
  1792. var c = a.context;
  1793. this._mask && a.maskManager.pushMask(this._mask, c), c.globalAlpha = this.worldAlpha;
  1794. var d, e, f = this.worldTransform;
  1795. if (c.setTransform(f.a, f.c, f.b, f.d, f.tx, f.ty), !this.__tilePattern || this.refreshTexture) {
  1796. if (this.generateTilingTexture(!1), !this.tilingTexture) return;
  1797. this.__tilePattern = c.createPattern(this.tilingTexture.baseTexture.source, "repeat")
  1798. }
  1799. this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]);
  1800. var g = this.tilePosition,
  1801. h = this.tileScale;
  1802. for (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), d = 0, e = this.children.length; e > d; d++) this.children[d]._renderCanvas(a)
  1803. }
  1804. }, b.TilingSprite.prototype.getBounds = function() {
  1805. var a = this._width,
  1806. b = this._height,
  1807. c = a * (1 - this.anchor.x),
  1808. d = a * -this.anchor.x,
  1809. e = b * (1 - this.anchor.y),
  1810. f = b * -this.anchor.y,
  1811. g = this.worldTransform,
  1812. h = g.a,
  1813. i = g.c,
  1814. j = g.b,
  1815. k = g.d,
  1816. l = g.tx,
  1817. m = g.ty,
  1818. n = h * d + j * f + l,
  1819. o = k * f + i * d + m,
  1820. p = h * c + j * f + l,
  1821. q = k * f + i * c + m,
  1822. r = h * c + j * e + l,
  1823. s = k * e + i * c + m,
  1824. t = h * d + j * e + l,
  1825. u = k * e + i * d + m,
  1826. v = -1 / 0,
  1827. w = -1 / 0,
  1828. x = 1 / 0,
  1829. y = 1 / 0;
  1830. 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;
  1831. var z = this._bounds;
  1832. return z.x = x, z.width = v - x, z.y = y, z.height = w - y, this._currentBounds = z, z
  1833. }, b.TilingSprite.prototype.onTextureUpdate = function() {}, b.TilingSprite.prototype.generateTilingTexture = function(a) {
  1834. if (this.texture.baseTexture.hasLoaded) {
  1835. var c, d, e = this.texture,
  1836. f = e.frame,
  1837. g = f.width !== e.baseTexture.width || f.height !== e.baseTexture.height,
  1838. h = !1;
  1839. if (a ? (c = b.getNextPowerOfTwo(f.width), d = b.getNextPowerOfTwo(f.height), (f.width !== c || f.height !== d) && (h = !0)) : g && (c = f.width, d = f.height, h = !0), h) {
  1840. var i;
  1841. this.tilingTexture && this.tilingTexture.isTiling ? (i = this.tilingTexture.canvasBuffer, i.resize(c, d), this.tilingTexture.baseTexture.width = c, this.tilingTexture.baseTexture.height = d, this.tilingTexture.needsUpdate = !0) : (i = new b.CanvasBuffer(c, d), this.tilingTexture = b.Texture.fromCanvas(i.canvas), this.tilingTexture.canvasBuffer = i, this.tilingTexture.isTiling = !0), i.context.drawImage(e.baseTexture.source, e.crop.x, e.crop.y, e.crop.width, e.crop.height, 0, 0, c, d), this.tileScaleOffset.x = f.width / c, this.tileScaleOffset.y = f.height / d
  1842. } else this.tilingTexture && this.tilingTexture.isTiling && this.tilingTexture.destroy(!0), this.tileScaleOffset.x = 1, this.tileScaleOffset.y = 1, this.tilingTexture = e;
  1843. this.refreshTexture = !1, this.tilingTexture.baseTexture._powerOf2 = !0
  1844. }
  1845. }, b.BaseTextureCache = {}, b.texturesToUpdate = [], b.texturesToDestroy = [], b.BaseTextureCacheIdGenerator = 0, b.BaseTexture = function(a, c) {
  1846. 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) {
  1847. 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);
  1848. else {
  1849. var d = this;
  1850. this.source.onload = function() {
  1851. d.hasLoaded = !0, d.width = d.source.width, d.height = d.source.height;
  1852. for (var a = 0; a < d._glTextures.length; a++) d._dirty[a] = !0;
  1853. d.dispatchEvent({
  1854. type: "loaded",
  1855. content: d
  1856. })
  1857. }, this.source.onerror = function() {
  1858. d.dispatchEvent({
  1859. type: "error",
  1860. content: d
  1861. })
  1862. }
  1863. }
  1864. this.imageUrl = null, this._powerOf2 = !1
  1865. }
  1866. }, b.BaseTexture.prototype.constructor = b.BaseTexture, b.BaseTexture.prototype.destroy = function() {
  1867. 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)
  1868. }, b.BaseTexture.prototype.updateSourceImage = function(a) {
  1869. this.hasLoaded = !1, this.source.src = null, this.source.src = a
  1870. }, b.BaseTexture.fromImage = function(a, c, d) {
  1871. var e = b.BaseTextureCache[a];
  1872. if (void 0 === c && -1 === a.indexOf("data:") && (c = !0), !e) {
  1873. var f = new Image;
  1874. c && (f.crossOrigin = ""), f.src = a, e = new b.BaseTexture(f, d), e.imageUrl = a, b.BaseTextureCache[a] = e
  1875. }
  1876. return e
  1877. }, b.BaseTexture.fromCanvas = function(a, c) {
  1878. a._pixiId || (a._pixiId = "canvas_" + b.TextureCacheIdGenerator++);
  1879. var d = b.BaseTextureCache[a._pixiId];
  1880. return d || (d = new b.BaseTexture(a, c), b.BaseTextureCache[a._pixiId] = d), d
  1881. }, b.TextureCache = {}, b.FrameCache = {}, b.TextureCacheIdGenerator = 0, b.Texture = function(a, c) {
  1882. 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);
  1883. else {
  1884. var d = this;
  1885. a.addEventListener("loaded", function() {
  1886. d.onBaseTextureLoaded()
  1887. })
  1888. }
  1889. }, b.Texture.prototype.constructor = b.Texture, b.Texture.prototype.onBaseTextureLoaded = function() {
  1890. var a = this.baseTexture;
  1891. 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({
  1892. type: "update",
  1893. content: this
  1894. })
  1895. }, b.Texture.prototype.destroy = function(a) {
  1896. a && this.baseTexture.destroy(), this.valid = !1
  1897. }, b.Texture.prototype.setFrame = function(a) {
  1898. 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);
  1899. 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)
  1900. }, b.Texture.prototype._updateWebGLuvs = function() {
  1901. this._uvs || (this._uvs = new b.TextureUvs);
  1902. var a = this.crop,
  1903. c = this.baseTexture.width,
  1904. d = this.baseTexture.height;
  1905. 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
  1906. }, b.Texture.fromImage = function(a, c, d) {
  1907. var e = b.TextureCache[a];
  1908. return e || (e = new b.Texture(b.BaseTexture.fromImage(a, c, d)), b.TextureCache[a] = e), e
  1909. }, b.Texture.fromFrame = function(a) {
  1910. var c = b.TextureCache[a];
  1911. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache ');
  1912. return c
  1913. }, b.Texture.fromCanvas = function(a, c) {
  1914. var d = b.BaseTexture.fromCanvas(a, c);
  1915. return new b.Texture(d)
  1916. }, b.Texture.addTextureToCache = function(a, c) {
  1917. b.TextureCache[c] = a
  1918. }, b.Texture.removeTextureFromCache = function(a) {
  1919. var c = b.TextureCache[a];
  1920. return delete b.TextureCache[a], delete b.BaseTextureCache[a], c
  1921. }, b.Texture.frameUpdates = [], b.TextureUvs = function() {
  1922. this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0
  1923. }, b.RenderTexture = function(a, c, d, e) {
  1924. 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) {
  1925. var f = this.renderer.gl;
  1926. 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)
  1927. } else this.render = this.renderCanvas, this.textureBuffer = new b.CanvasBuffer(this.width, this.height), this.baseTexture.source = this.textureBuffer.canvas;
  1928. this.valid = !0, b.Texture.frameUpdates.push(this)
  1929. }, b.RenderTexture.prototype = Object.create(b.Texture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.resize = function(a, c, d) {
  1930. (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))
  1931. }, b.RenderTexture.prototype.clear = function() {
  1932. this.renderer.type === b.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear()
  1933. }, b.RenderTexture.prototype.renderWebGL = function(a, c, d) {
  1934. var e = this.renderer.gl;
  1935. 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();
  1936. var f = a.children,
  1937. g = a.worldTransform;
  1938. 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);
  1939. for (var h = 0, i = f.length; i > h; h++) f[h].updateTransform();
  1940. 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
  1941. }, b.RenderTexture.prototype.renderCanvas = function(a, c, d) {
  1942. var e = a.children,
  1943. f = a.worldTransform;
  1944. a.worldTransform = b.RenderTexture.tempMatrix, c ? (a.worldTransform.tx = c.x, a.worldTransform.ty = c.y) : (a.worldTransform.tx = 0, a.worldTransform.ty = 0);
  1945. for (var g = 0, h = e.length; h > g; g++) e[g].updateTransform();
  1946. d && this.textureBuffer.clear();
  1947. var i = this.textureBuffer.context;
  1948. this.renderer.renderDisplayObject(a, i), i.setTransform(1, 0, 0, 1, 0, 0), a.worldTransform = f
  1949. }, 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() {
  1950. return a.PIXI = b
  1951. }()) : a.PIXI = b
  1952. }).call(this),
  1953. function() {
  1954. var a = this,
  1955. b = b || {
  1956. VERSION: "2.0.7",
  1957. GAMES: [],
  1958. AUTO: 0,
  1959. CANVAS: 1,
  1960. WEBGL: 2,
  1961. HEADLESS: 3,
  1962. NONE: 0,
  1963. LEFT: 1,
  1964. RIGHT: 2,
  1965. UP: 3,
  1966. DOWN: 4,
  1967. SPRITE: 0,
  1968. BUTTON: 1,
  1969. IMAGE: 2,
  1970. GRAPHICS: 3,
  1971. TEXT: 4,
  1972. TILESPRITE: 5,
  1973. BITMAPTEXT: 6,
  1974. GROUP: 7,
  1975. RENDERTEXTURE: 8,
  1976. TILEMAP: 9,
  1977. TILEMAPLAYER: 10,
  1978. EMITTER: 11,
  1979. POLYGON: 12,
  1980. BITMAPDATA: 13,
  1981. CANVAS_FILTER: 14,
  1982. WEBGL_FILTER: 15,
  1983. ELLIPSE: 16,
  1984. SPRITEBATCH: 17,
  1985. RETROFONT: 18,
  1986. POINTER: 19,
  1987. blendModes: {
  1988. NORMAL: 0,
  1989. ADD: 1,
  1990. MULTIPLY: 2,
  1991. SCREEN: 3,
  1992. OVERLAY: 4,
  1993. DARKEN: 5,
  1994. LIGHTEN: 6,
  1995. COLOR_DODGE: 7,
  1996. COLOR_BURN: 8,
  1997. HARD_LIGHT: 9,
  1998. SOFT_LIGHT: 10,
  1999. DIFFERENCE: 11,
  2000. EXCLUSION: 12,
  2001. HUE: 13,
  2002. SATURATION: 14,
  2003. COLOR: 15,
  2004. LUMINOSITY: 16
  2005. },
  2006. scaleModes: {
  2007. DEFAULT: 0,
  2008. LINEAR: 0,
  2009. NEAREST: 1
  2010. }
  2011. };
  2012. if (PIXI.InteractionManager = PIXI.InteractionManager || function() {}, PIXI.dontSayHello = !0, b.Utils = {
  2013. getProperty: function(a, b) {
  2014. 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++;
  2015. return a ? a[d] : null
  2016. },
  2017. setProperty: function(a, b, c) {
  2018. 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++;
  2019. return a && (a[e] = c), a
  2020. },
  2021. transposeArray: function(a) {
  2022. for (var b = new Array(a[0].length), c = 0; c < a[0].length; c++) {
  2023. b[c] = new Array(a.length - 1);
  2024. for (var d = a.length - 1; d > -1; d--) b[c][d] = a[d][c]
  2025. }
  2026. return b
  2027. },
  2028. rotateArray: function(a, c) {
  2029. if ("string" != typeof c && (c = (c % 360 + 360) % 360), 90 === c || -270 === c || "rotateLeft" === c) a = b.Utils.transposeArray(a), a = a.reverse();
  2030. else if (-90 === c || 270 === c || "rotateRight" === c) a = a.reverse(), a = b.Utils.transposeArray(a);
  2031. else if (180 === Math.abs(c) || "rotate180" === c) {
  2032. for (var d = 0; d < a.length; d++) a[d].reverse();
  2033. a = a.reverse()
  2034. }
  2035. return a
  2036. },
  2037. parseDimension: function(a, b) {
  2038. var c = 0,
  2039. d = 0;
  2040. 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
  2041. },
  2042. shuffle: function(a) {
  2043. for (var b = a.length - 1; b > 0; b--) {
  2044. var c = Math.floor(Math.random() * (b + 1)),
  2045. d = a[b];
  2046. a[b] = a[c], a[c] = d
  2047. }
  2048. return a
  2049. },
  2050. pad: function(a, b, c, d) {
  2051. if ("undefined" == typeof b) var b = 0;
  2052. if ("undefined" == typeof c) var c = " ";
  2053. if ("undefined" == typeof d) var d = 3;
  2054. var e = 0;
  2055. if (b + 1 >= a.length) switch (d) {
  2056. case 1:
  2057. a = new Array(b + 1 - a.length).join(c) + a;
  2058. break;
  2059. case 3:
  2060. var f = Math.ceil((e = b - a.length) / 2),
  2061. g = e - f;
  2062. a = new Array(g + 1).join(c) + a + new Array(f + 1).join(c);
  2063. break;
  2064. default:
  2065. a += new Array(b + 1 - a.length).join(c)
  2066. }
  2067. return a
  2068. },
  2069. isPlainObject: function(a) {
  2070. if ("object" != typeof a || a.nodeType || a === a.window) return !1;
  2071. try {
  2072. if (a.constructor && !{}.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) return !1
  2073. } catch (b) {
  2074. return !1
  2075. }
  2076. return !0
  2077. },
  2078. extend: function() {
  2079. var a, c, d, e, f, g, h = arguments[0] || {},
  2080. i = 1,
  2081. j = arguments.length,
  2082. k = !1;
  2083. for ("boolean" == typeof h && (k = h, h = arguments[1] || {}, i = 2), j === i && (h = this, --i); j > i; i++)
  2084. if (null != (a = arguments[i]))
  2085. 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));
  2086. return h
  2087. },
  2088. mixin: function(a, c) {
  2089. if (!a || "object" != typeof a) return c;
  2090. for (var d in a) {
  2091. var e = a[d];
  2092. if (!e.childNodes && !e.cloneNode) {
  2093. var f = typeof a[d];
  2094. 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]
  2095. }
  2096. }
  2097. return c
  2098. }
  2099. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  2100. var a = Array.prototype.slice;
  2101. return function(b) {
  2102. function c() {
  2103. var f = e.concat(a.call(arguments));
  2104. d.apply(this instanceof c ? this : b, f)
  2105. }
  2106. var d = this,
  2107. e = a.call(arguments, 1);
  2108. if ("function" != typeof d) throw new TypeError;
  2109. return c.prototype = function f(a) {
  2110. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  2111. }(d.prototype), c
  2112. }
  2113. }()), Array.isArray || (Array.isArray = function(a) {
  2114. return "[object Array]" == Object.prototype.toString.call(a)
  2115. }), Array.prototype.forEach || (Array.prototype.forEach = function(a) {
  2116. "use strict";
  2117. if (void 0 === this || null === this) throw new TypeError;
  2118. var b = Object(this),
  2119. c = b.length >>> 0;
  2120. if ("function" != typeof a) throw new TypeError;
  2121. for (var d = arguments.length >= 2 ? arguments[1] : void 0, e = 0; c > e; e++) e in b && a.call(d, b[e], e, b)
  2122. }), "function" != typeof window.Uint32Array) {
  2123. var c = function(a) {
  2124. var b = new Array;
  2125. window[a] = function(a) {
  2126. if ("number" == typeof a) {
  2127. Array.call(this, a), this.length = a;
  2128. for (var b = 0; b < this.length; b++) this[b] = 0
  2129. } else {
  2130. Array.call(this, a.length), this.length = a.length;
  2131. for (var b = 0; b < this.length; b++) this[b] = a[b]
  2132. }
  2133. }, window[a].prototype = b, window[a].constructor = window[a]
  2134. };
  2135. c("Uint32Array"), c("Int16Array")
  2136. }
  2137. window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), b.Circle = function(a, b, c) {
  2138. 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
  2139. }, b.Circle.prototype = {
  2140. circumference: function() {
  2141. return 2 * Math.PI * this._radius
  2142. },
  2143. setTo: function(a, b, c) {
  2144. return this.x = a, this.y = b, this._diameter = c, this._radius = .5 * c, this
  2145. },
  2146. copyFrom: function(a) {
  2147. return this.setTo(a.x, a.y, a.diameter)
  2148. },
  2149. copyTo: function(a) {
  2150. return a.x = this.x, a.y = this.y, a.diameter = this._diameter, a
  2151. },
  2152. distance: function(a, c) {
  2153. 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)
  2154. },
  2155. clone: function(a) {
  2156. return "undefined" == typeof a ? a = new b.Circle(this.x, this.y, this.diameter) : a.setTo(this.x, this.y, this.diameter), a
  2157. },
  2158. contains: function(a, c) {
  2159. return b.Circle.contains(this, a, c)
  2160. },
  2161. circumferencePoint: function(a, c, d) {
  2162. return b.Circle.circumferencePoint(this, a, c, d)
  2163. },
  2164. offset: function(a, b) {
  2165. return this.x += a, this.y += b, this
  2166. },
  2167. offsetPoint: function(a) {
  2168. return this.offset(a.x, a.y)
  2169. },
  2170. toString: function() {
  2171. return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"
  2172. }
  2173. }, b.Circle.prototype.constructor = b.Circle, Object.defineProperty(b.Circle.prototype, "diameter", {
  2174. get: function() {
  2175. return this._diameter
  2176. },
  2177. set: function(a) {
  2178. a > 0 && (this._diameter = a, this._radius = .5 * a)
  2179. }
  2180. }), Object.defineProperty(b.Circle.prototype, "radius", {
  2181. get: function() {
  2182. return this._radius
  2183. },
  2184. set: function(a) {
  2185. a > 0 && (this._radius = a, this._diameter = 2 * a)
  2186. }
  2187. }), Object.defineProperty(b.Circle.prototype, "left", {
  2188. get: function() {
  2189. return this.x - this._radius
  2190. },
  2191. set: function(a) {
  2192. a > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - a
  2193. }
  2194. }), Object.defineProperty(b.Circle.prototype, "right", {
  2195. get: function() {
  2196. return this.x + this._radius
  2197. },
  2198. set: function(a) {
  2199. a < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.x
  2200. }
  2201. }), Object.defineProperty(b.Circle.prototype, "top", {
  2202. get: function() {
  2203. return this.y - this._radius
  2204. },
  2205. set: function(a) {
  2206. a > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - a
  2207. }
  2208. }), Object.defineProperty(b.Circle.prototype, "bottom", {
  2209. get: function() {
  2210. return this.y + this._radius
  2211. },
  2212. set: function(a) {
  2213. a < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.y
  2214. }
  2215. }), Object.defineProperty(b.Circle.prototype, "area", {
  2216. get: function() {
  2217. return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
  2218. }
  2219. }), Object.defineProperty(b.Circle.prototype, "empty", {
  2220. get: function() {
  2221. return 0 === this._diameter
  2222. },
  2223. set: function(a) {
  2224. a === !0 && this.setTo(0, 0, 0)
  2225. }
  2226. }), b.Circle.contains = function(a, b, c) {
  2227. if (a.radius > 0 && b >= a.left && b <= a.right && c >= a.top && c <= a.bottom) {
  2228. var d = (a.x - b) * (a.x - b),
  2229. e = (a.y - c) * (a.y - c);
  2230. return d + e <= a.radius * a.radius
  2231. }
  2232. return !1
  2233. }, b.Circle.equals = function(a, b) {
  2234. return a.x == b.x && a.y == b.y && a.diameter == b.diameter
  2235. }, b.Circle.intersects = function(a, c) {
  2236. return b.Math.distance(a.x, a.y, c.x, c.y) <= a.radius + c.radius
  2237. }, b.Circle.circumferencePoint = function(a, c, d, e) {
  2238. 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
  2239. }, b.Circle.intersectsRectangle = function(a, b) {
  2240. var c = Math.abs(a.x - b.x - b.halfWidth),
  2241. d = b.halfWidth + a.radius;
  2242. if (c > d) return !1;
  2243. var e = Math.abs(a.y - b.y - b.halfHeight),
  2244. f = b.halfHeight + a.radius;
  2245. if (e > f) return !1;
  2246. if (c <= b.halfWidth || e <= b.halfHeight) return !0;
  2247. var g = c - b.halfWidth,
  2248. h = e - b.halfHeight,
  2249. i = g * g,
  2250. j = h * h,
  2251. k = a.radius * a.radius;
  2252. return k >= i + j
  2253. }, PIXI.Circle = b.Circle, b.Point = function(a, b) {
  2254. a = a || 0, b = b || 0, this.x = a, this.y = b
  2255. }, b.Point.prototype = {
  2256. copyFrom: function(a) {
  2257. return this.setTo(a.x, a.y)
  2258. },
  2259. invert: function() {
  2260. return this.setTo(this.y, this.x)
  2261. },
  2262. setTo: function(a, b) {
  2263. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2264. },
  2265. set: function(a, b) {
  2266. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2267. },
  2268. add: function(a, b) {
  2269. return this.x += a, this.y += b, this
  2270. },
  2271. subtract: function(a, b) {
  2272. return this.x -= a, this.y -= b, this
  2273. },
  2274. multiply: function(a, b) {
  2275. return this.x *= a, this.y *= b, this
  2276. },
  2277. divide: function(a, b) {
  2278. return this.x /= a, this.y /= b, this
  2279. },
  2280. clampX: function(a, c) {
  2281. return this.x = b.Math.clamp(this.x, a, c), this
  2282. },
  2283. clampY: function(a, c) {
  2284. return this.y = b.Math.clamp(this.y, a, c), this
  2285. },
  2286. clamp: function(a, c) {
  2287. return this.x = b.Math.clamp(this.x, a, c), this.y = b.Math.clamp(this.y, a, c), this
  2288. },
  2289. clone: function(a) {
  2290. return "undefined" == typeof a ? a = new b.Point(this.x, this.y) : a.setTo(this.x, this.y), a
  2291. },
  2292. copyTo: function(a) {
  2293. return a.x = this.x, a.y = this.y, a
  2294. },
  2295. distance: function(a, c) {
  2296. return b.Point.distance(this, a, c)
  2297. },
  2298. equals: function(a) {
  2299. return a.x === this.x && a.y === this.y
  2300. },
  2301. angle: function(a, c) {
  2302. 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)
  2303. },
  2304. angleSq: function(a) {
  2305. return this.subtract(a).angle(a.subtract(this))
  2306. },
  2307. rotate: function(a, c, d, e, f) {
  2308. return b.Point.rotate(this, a, c, d, e, f)
  2309. },
  2310. getMagnitude: function() {
  2311. return Math.sqrt(this.x * this.x + this.y * this.y)
  2312. },
  2313. getMagnitudeSq: function() {
  2314. return this.x * this.x + this.y * this.y
  2315. },
  2316. setMagnitude: function(a) {
  2317. return this.normalize().multiply(a, a)
  2318. },
  2319. normalize: function() {
  2320. if (!this.isZero()) {
  2321. var a = this.getMagnitude();
  2322. this.x /= a, this.y /= a
  2323. }
  2324. return this
  2325. },
  2326. isZero: function() {
  2327. return 0 === this.x && 0 === this.y
  2328. },
  2329. dot: function(a) {
  2330. return this.x * a.x + this.y * a.y
  2331. },
  2332. cross: function(a) {
  2333. return this.x * a.y - this.y * a.x
  2334. },
  2335. perp: function() {
  2336. return this.setTo(-this.y, this.x)
  2337. },
  2338. rperp: function() {
  2339. return this.setTo(this.y, -this.x)
  2340. },
  2341. normalRightHand: function() {
  2342. return this.setTo(-1 * this.y, this.x)
  2343. },
  2344. toString: function() {
  2345. return "[{Point (x=" + this.x + " y=" + this.y + ")}]"
  2346. }
  2347. }, b.Point.prototype.constructor = b.Point, b.Point.add = function(a, c, d) {
  2348. return "undefined" == typeof d && (d = new b.Point), d.x = a.x + c.x, d.y = a.y + c.y, d
  2349. }, b.Point.subtract = function(a, c, d) {
  2350. return "undefined" == typeof d && (d = new b.Point), d.x = a.x - c.x, d.y = a.y - c.y, d
  2351. }, b.Point.multiply = function(a, c, d) {
  2352. return "undefined" == typeof d && (d = new b.Point), d.x = a.x * c.x, d.y = a.y * c.y, d
  2353. }, b.Point.divide = function(a, c, d) {
  2354. return "undefined" == typeof d && (d = new b.Point), d.x = a.x / c.x, d.y = a.y / c.y, d
  2355. }, b.Point.equals = function(a, b) {
  2356. return a.x === b.x && a.y === b.y
  2357. }, b.Point.angle = function(a, b) {
  2358. return Math.atan2(a.y - b.y, a.x - b.x)
  2359. }, b.Point.angleSq = function(a, b) {
  2360. return a.subtract(b).angle(b.subtract(a))
  2361. }, b.Point.negative = function(a, c) {
  2362. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.x, -a.y)
  2363. }, b.Point.multiplyAdd = function(a, c, d, e) {
  2364. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + c.x * d, a.y + c.y * d)
  2365. }, b.Point.interpolate = function(a, c, d, e) {
  2366. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + (c.x - a.x) * d, a.y + (c.y - a.y) * d)
  2367. }, b.Point.perp = function(a, c) {
  2368. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.y, a.x)
  2369. }, b.Point.rperp = function(a, c) {
  2370. return "undefined" == typeof c && (c = new b.Point), c.setTo(a.y, -a.x)
  2371. }, b.Point.distance = function(a, c, d) {
  2372. 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)
  2373. }, b.Point.project = function(a, c, d) {
  2374. "undefined" == typeof d && (d = new b.Point);
  2375. var e = a.dot(c) / c.getMagnitudeSq();
  2376. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  2377. }, b.Point.projectUnit = function(a, c, d) {
  2378. "undefined" == typeof d && (d = new b.Point);
  2379. var e = a.dot(c);
  2380. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  2381. }, b.Point.normalRightHand = function(a, c) {
  2382. return "undefined" == typeof c && (c = new b.Point), c.setTo(-1 * a.y, a.x)
  2383. }, b.Point.normalize = function(a, c) {
  2384. "undefined" == typeof c && (c = new b.Point);
  2385. var d = a.getMagnitude();
  2386. return 0 !== d && c.setTo(a.x / d, a.y / d), c
  2387. }, b.Point.rotate = function(a, c, d, e, f, g) {
  2388. 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))
  2389. }, b.Point.centroid = function(a, c) {
  2390. 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");
  2391. var d = a.length;
  2392. if (1 > d) throw new Error("Phaser.Point. Parameter 'points' array must not be empty");
  2393. if (1 === d) return c.copyFrom(a[0]), c;
  2394. for (var e = 0; d > e; e++) b.Point.add(c, a[e], c);
  2395. return c.divide(d, d), c
  2396. }, PIXI.Point = b.Point, b.Rectangle = function(a, b, c, d) {
  2397. a = a || 0, b = b || 0, c = c || 0, d = d || 0, this.x = a, this.y = b, this.width = c, this.height = d
  2398. }, b.Rectangle.prototype = {
  2399. offset: function(a, b) {
  2400. return this.x += a, this.y += b, this
  2401. },
  2402. offsetPoint: function(a) {
  2403. return this.offset(a.x, a.y)
  2404. },
  2405. setTo: function(a, b, c, d) {
  2406. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2407. },
  2408. floor: function() {
  2409. this.x = Math.floor(this.x), this.y = Math.floor(this.y)
  2410. },
  2411. floorAll: function() {
  2412. this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height)
  2413. },
  2414. copyFrom: function(a) {
  2415. return this.setTo(a.x, a.y, a.width, a.height)
  2416. },
  2417. copyTo: function(a) {
  2418. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2419. },
  2420. inflate: function(a, c) {
  2421. return b.Rectangle.inflate(this, a, c)
  2422. },
  2423. size: function(a) {
  2424. return b.Rectangle.size(this, a)
  2425. },
  2426. clone: function(a) {
  2427. return b.Rectangle.clone(this, a)
  2428. },
  2429. contains: function(a, c) {
  2430. return b.Rectangle.contains(this, a, c)
  2431. },
  2432. containsRect: function(a) {
  2433. return b.Rectangle.containsRect(this, a)
  2434. },
  2435. equals: function(a) {
  2436. return b.Rectangle.equals(this, a)
  2437. },
  2438. intersection: function(a, c) {
  2439. return b.Rectangle.intersection(this, a, c)
  2440. },
  2441. intersects: function(a, c) {
  2442. return b.Rectangle.intersects(this, a, c)
  2443. },
  2444. intersectsRaw: function(a, c, d, e, f) {
  2445. return b.Rectangle.intersectsRaw(this, a, c, d, e, f)
  2446. },
  2447. union: function(a, c) {
  2448. return b.Rectangle.union(this, a, c)
  2449. },
  2450. toString: function() {
  2451. return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"
  2452. }
  2453. }, Object.defineProperty(b.Rectangle.prototype, "halfWidth", {
  2454. get: function() {
  2455. return Math.round(this.width / 2)
  2456. }
  2457. }), Object.defineProperty(b.Rectangle.prototype, "halfHeight", {
  2458. get: function() {
  2459. return Math.round(this.height / 2)
  2460. }
  2461. }), Object.defineProperty(b.Rectangle.prototype, "bottom", {
  2462. get: function() {
  2463. return this.y + this.height
  2464. },
  2465. set: function(a) {
  2466. this.height = a <= this.y ? 0 : this.y - a
  2467. }
  2468. }), Object.defineProperty(b.Rectangle.prototype, "bottomRight", {
  2469. get: function() {
  2470. return new b.Point(this.right, this.bottom)
  2471. },
  2472. set: function(a) {
  2473. this.right = a.x, this.bottom = a.y
  2474. }
  2475. }), Object.defineProperty(b.Rectangle.prototype, "left", {
  2476. get: function() {
  2477. return this.x
  2478. },
  2479. set: function(a) {
  2480. this.width = a >= this.right ? 0 : this.right - a, this.x = a
  2481. }
  2482. }), Object.defineProperty(b.Rectangle.prototype, "right", {
  2483. get: function() {
  2484. return this.x + this.width
  2485. },
  2486. set: function(a) {
  2487. this.width = a <= this.x ? 0 : a - this.x
  2488. }
  2489. }), Object.defineProperty(b.Rectangle.prototype, "volume", {
  2490. get: function() {
  2491. return this.width * this.height
  2492. }
  2493. }), Object.defineProperty(b.Rectangle.prototype, "perimeter", {
  2494. get: function() {
  2495. return 2 * this.width + 2 * this.height
  2496. }
  2497. }), Object.defineProperty(b.Rectangle.prototype, "centerX", {
  2498. get: function() {
  2499. return this.x + this.halfWidth
  2500. },
  2501. set: function(a) {
  2502. this.x = a - this.halfWidth
  2503. }
  2504. }), Object.defineProperty(b.Rectangle.prototype, "centerY", {
  2505. get: function() {
  2506. return this.y + this.halfHeight
  2507. },
  2508. set: function(a) {
  2509. this.y = a - this.halfHeight
  2510. }
  2511. }), Object.defineProperty(b.Rectangle.prototype, "randomX", {
  2512. get: function() {
  2513. return this.x + Math.random() * this.width
  2514. }
  2515. }), Object.defineProperty(b.Rectangle.prototype, "randomY", {
  2516. get: function() {
  2517. return this.y + Math.random() * this.height
  2518. }
  2519. }), Object.defineProperty(b.Rectangle.prototype, "top", {
  2520. get: function() {
  2521. return this.y
  2522. },
  2523. set: function(a) {
  2524. a >= this.bottom ? (this.height = 0, this.y = a) : this.height = this.bottom - a
  2525. }
  2526. }), Object.defineProperty(b.Rectangle.prototype, "topLeft", {
  2527. get: function() {
  2528. return new b.Point(this.x, this.y)
  2529. },
  2530. set: function(a) {
  2531. this.x = a.x, this.y = a.y
  2532. }
  2533. }), Object.defineProperty(b.Rectangle.prototype, "empty", {
  2534. get: function() {
  2535. return !this.width || !this.height
  2536. },
  2537. set: function(a) {
  2538. a === !0 && this.setTo(0, 0, 0, 0)
  2539. }
  2540. }), b.Rectangle.prototype.constructor = b.Rectangle, b.Rectangle.inflate = function(a, b, c) {
  2541. return a.x -= b, a.width += 2 * b, a.y -= c, a.height += 2 * c, a
  2542. }, b.Rectangle.inflatePoint = function(a, c) {
  2543. return b.Rectangle.inflate(a, c.x, c.y)
  2544. }, b.Rectangle.size = function(a, c) {
  2545. return "undefined" == typeof c || null === c ? c = new b.Point(a.width, a.height) : c.setTo(a.width, a.height), c
  2546. }, b.Rectangle.clone = function(a, c) {
  2547. 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
  2548. }, b.Rectangle.contains = function(a, b, c) {
  2549. return a.width <= 0 || a.height <= 0 ? !1 : b >= a.x && b <= a.right && c >= a.y && c <= a.bottom
  2550. }, b.Rectangle.containsRaw = function(a, b, c, d, e, f) {
  2551. return e >= a && a + c >= e && f >= b && b + d >= f
  2552. }, b.Rectangle.containsPoint = function(a, c) {
  2553. return b.Rectangle.contains(a, c.x, c.y)
  2554. }, b.Rectangle.containsRect = function(a, b) {
  2555. return a.volume > b.volume ? !1 : a.x >= b.x && a.y >= b.y && a.right <= b.right && a.bottom <= b.bottom
  2556. }, b.Rectangle.equals = function(a, b) {
  2557. return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
  2558. }, b.Rectangle.intersection = function(a, c, d) {
  2559. 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
  2560. }, b.Rectangle.intersects = function(a, b) {
  2561. 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)
  2562. }, b.Rectangle.intersectsRaw = function(a, b, c, d, e, f) {
  2563. return "undefined" == typeof f && (f = 0), !(b > a.right + f || c < a.left - f || d > a.bottom + f || e < a.top - f)
  2564. }, b.Rectangle.union = function(a, c, d) {
  2565. 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))
  2566. }, PIXI.Rectangle = b.Rectangle, PIXI.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Line = function(a, c, d, e) {
  2567. 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)
  2568. }, b.Line.prototype = {
  2569. setTo: function(a, b, c, d) {
  2570. return this.start.setTo(a, b), this.end.setTo(c, d), this
  2571. },
  2572. fromSprite: function(a, b, c) {
  2573. 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)
  2574. },
  2575. intersects: function(a, c, d) {
  2576. return b.Line.intersectsPoints(this.start, this.end, a.start, a.end, c, d)
  2577. },
  2578. pointOnLine: function(a, b) {
  2579. return (a - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (b - this.start.y)
  2580. },
  2581. pointOnSegment: function(a, b) {
  2582. var c = Math.min(this.start.x, this.end.x),
  2583. d = Math.max(this.start.x, this.end.x),
  2584. e = Math.min(this.start.y, this.end.y),
  2585. f = Math.max(this.start.y, this.end.y);
  2586. return this.pointOnLine(a, b) && a >= c && d >= a && b >= e && f >= b
  2587. },
  2588. coordinatesOnLine: function(a, b) {
  2589. "undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = []);
  2590. var c = Math.round(this.start.x),
  2591. d = Math.round(this.start.y),
  2592. e = Math.round(this.end.x),
  2593. f = Math.round(this.end.y),
  2594. g = Math.abs(e - c),
  2595. h = Math.abs(f - d),
  2596. i = e > c ? 1 : -1,
  2597. j = f > d ? 1 : -1,
  2598. k = g - h;
  2599. b.push([c, d]);
  2600. for (var l = 1; c != e || d != f;) {
  2601. var m = k << 1;
  2602. m > -h && (k -= h, c += i), g > m && (k += g, d += j), l % a === 0 && b.push([c, d]), l++
  2603. }
  2604. return b
  2605. }
  2606. }, Object.defineProperty(b.Line.prototype, "length", {
  2607. get: function() {
  2608. 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))
  2609. }
  2610. }), Object.defineProperty(b.Line.prototype, "angle", {
  2611. get: function() {
  2612. return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x)
  2613. }
  2614. }), Object.defineProperty(b.Line.prototype, "slope", {
  2615. get: function() {
  2616. return (this.end.y - this.start.y) / (this.end.x - this.start.x)
  2617. }
  2618. }), Object.defineProperty(b.Line.prototype, "perpSlope", {
  2619. get: function() {
  2620. return -((this.end.x - this.start.x) / (this.end.y - this.start.y))
  2621. }
  2622. }), Object.defineProperty(b.Line.prototype, "x", {
  2623. get: function() {
  2624. return Math.min(this.start.x, this.end.x)
  2625. }
  2626. }), Object.defineProperty(b.Line.prototype, "y", {
  2627. get: function() {
  2628. return Math.min(this.start.y, this.end.y)
  2629. }
  2630. }), Object.defineProperty(b.Line.prototype, "left", {
  2631. get: function() {
  2632. return Math.min(this.start.x, this.end.x)
  2633. }
  2634. }), Object.defineProperty(b.Line.prototype, "right", {
  2635. get: function() {
  2636. return Math.max(this.start.x, this.end.x)
  2637. }
  2638. }), Object.defineProperty(b.Line.prototype, "top", {
  2639. get: function() {
  2640. return Math.min(this.start.y, this.end.y)
  2641. }
  2642. }), Object.defineProperty(b.Line.prototype, "bottom", {
  2643. get: function() {
  2644. return Math.max(this.start.y, this.end.y)
  2645. }
  2646. }), Object.defineProperty(b.Line.prototype, "width", {
  2647. get: function() {
  2648. return Math.abs(this.start.x - this.end.x)
  2649. }
  2650. }), Object.defineProperty(b.Line.prototype, "height", {
  2651. get: function() {
  2652. return Math.abs(this.start.y - this.end.y)
  2653. }
  2654. }), b.Line.intersectsPoints = function(a, c, d, e, f, g) {
  2655. "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = new b.Point);
  2656. var h = c.y - a.y,
  2657. i = e.y - d.y,
  2658. j = a.x - c.x,
  2659. k = d.x - e.x,
  2660. l = c.x * a.y - a.x * c.y,
  2661. m = e.x * d.y - d.x * e.y,
  2662. n = h * k - i * j;
  2663. if (0 === n) return null;
  2664. if (g.x = (j * m - k * l) / n, g.y = (i * l - h * m) / n, f) {
  2665. var o = (e.y - d.y) * (c.x - a.x) - (e.x - d.x) * (c.y - a.y),
  2666. p = ((e.x - d.x) * (a.y - d.y) - (e.y - d.y) * (a.x - d.x)) / o,
  2667. q = ((c.x - a.x) * (a.y - d.y) - (c.y - a.y) * (a.x - d.x)) / o;
  2668. return p >= 0 && 1 >= p && q >= 0 && 1 >= q ? g : null
  2669. }
  2670. return g
  2671. }, b.Line.intersects = function(a, c, d, e) {
  2672. return b.Line.intersectsPoints(a.start, a.end, c.start, c.end, d, e)
  2673. }, b.Ellipse = function(a, c, d, e) {
  2674. 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
  2675. }, b.Ellipse.prototype = {
  2676. setTo: function(a, b, c, d) {
  2677. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2678. },
  2679. copyFrom: function(a) {
  2680. return this.setTo(a.x, a.y, a.width, a.height)
  2681. },
  2682. copyTo: function(a) {
  2683. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2684. },
  2685. clone: function(a) {
  2686. 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
  2687. },
  2688. contains: function(a, c) {
  2689. return b.Ellipse.contains(this, a, c)
  2690. },
  2691. toString: function() {
  2692. return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"
  2693. }
  2694. }, b.Ellipse.prototype.constructor = b.Ellipse, Object.defineProperty(b.Ellipse.prototype, "left", {
  2695. get: function() {
  2696. return this.x
  2697. },
  2698. set: function(a) {
  2699. this.x = a
  2700. }
  2701. }), Object.defineProperty(b.Ellipse.prototype, "right", {
  2702. get: function() {
  2703. return this.x + this.width
  2704. },
  2705. set: function(a) {
  2706. this.width = a < this.x ? 0 : this.x + a
  2707. }
  2708. }), Object.defineProperty(b.Ellipse.prototype, "top", {
  2709. get: function() {
  2710. return this.y
  2711. },
  2712. set: function(a) {
  2713. this.y = a
  2714. }
  2715. }), Object.defineProperty(b.Ellipse.prototype, "bottom", {
  2716. get: function() {
  2717. return this.y + this.height
  2718. },
  2719. set: function(a) {
  2720. this.height = a < this.y ? 0 : this.y + a
  2721. }
  2722. }), Object.defineProperty(b.Ellipse.prototype, "empty", {
  2723. get: function() {
  2724. return 0 === this.width || 0 === this.height
  2725. },
  2726. set: function(a) {
  2727. a === !0 && this.setTo(0, 0, 0, 0)
  2728. }
  2729. }), b.Ellipse.contains = function(a, b, c) {
  2730. if (a.width <= 0 || a.height <= 0) return !1;
  2731. var d = (b - a.x) / a.width - .5,
  2732. e = (c - a.y) / a.height - .5;
  2733. return d *= d, e *= e, .25 > d + e
  2734. }, b.Ellipse.prototype.getBounds = function() {
  2735. return new b.Rectangle(this.x, this.y, this.width, this.height)
  2736. }, PIXI.Ellipse = b.Ellipse, b.Polygon = function(a) {
  2737. if (this.type = b.POLYGON, a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  2738. for (var c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  2739. a = c
  2740. }
  2741. this._points = a
  2742. }, b.Polygon.prototype = {
  2743. clone: function() {
  2744. for (var a = [], c = 0; c < this.points.length; c++) a.push(this.points[c].clone());
  2745. return new b.Polygon(a)
  2746. },
  2747. contains: function(a, b) {
  2748. for (var c = !1, d = 0, e = this.points.length - 1; d < this.points.length; e = d++) {
  2749. var f = this.points[d].x,
  2750. g = this.points[d].y,
  2751. h = this.points[e].x,
  2752. i = this.points[e].y,
  2753. j = g > b != i > b && (h - f) * (b - g) / (i - g) + f > a;
  2754. j && (c = !c)
  2755. }
  2756. return c
  2757. }
  2758. }, b.Polygon.prototype.constructor = b.Polygon, Object.defineProperty(b.Polygon.prototype, "points", {
  2759. get: function() {
  2760. return this._points
  2761. },
  2762. set: function(a) {
  2763. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  2764. for (var c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  2765. a = c
  2766. }
  2767. this._points = a
  2768. }
  2769. }), Object.defineProperty(b.Polygon.prototype, "area", {
  2770. get: function() {
  2771. var a, b, c, d, e, f = Number.MAX_VALUE,
  2772. g = 0;
  2773. for (e = 0; e < this.points.length; e++) this.points[e].y < f && (f = this.points[e].y);
  2774. 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;
  2775. return g
  2776. }
  2777. }), PIXI.Polygon = b.Polygon, b.Camera = function(a, c, d, e, f, g) {
  2778. 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 = {
  2779. x: !1,
  2780. y: !1
  2781. }, this.target = null, this._edge = 0, this.displayObject = null, this.scale = null
  2782. }, b.Camera.FOLLOW_LOCKON = 0, b.Camera.FOLLOW_PLATFORMER = 1, b.Camera.FOLLOW_TOPDOWN = 2, b.Camera.FOLLOW_TOPDOWN_TIGHT = 3, b.Camera.prototype = {
  2783. follow: function(a, c) {
  2784. "undefined" == typeof c && (c = b.Camera.FOLLOW_LOCKON), this.target = a;
  2785. var d;
  2786. switch (c) {
  2787. case b.Camera.FOLLOW_PLATFORMER:
  2788. var e = this.width / 8,
  2789. f = this.height / 3;
  2790. this.deadzone = new b.Rectangle((this.width - e) / 2, (this.height - f) / 2 - .25 * f, e, f);
  2791. break;
  2792. case b.Camera.FOLLOW_TOPDOWN:
  2793. d = Math.max(this.width, this.height) / 4, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2794. break;
  2795. case b.Camera.FOLLOW_TOPDOWN_TIGHT:
  2796. d = Math.max(this.width, this.height) / 8, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2797. break;
  2798. case b.Camera.FOLLOW_LOCKON:
  2799. this.deadzone = null;
  2800. break;
  2801. default:
  2802. this.deadzone = null
  2803. }
  2804. },
  2805. unfollow: function() {
  2806. this.target = null
  2807. },
  2808. focusOn: function(a) {
  2809. this.setPosition(Math.round(a.x - this.view.halfWidth), Math.round(a.y - this.view.halfHeight))
  2810. },
  2811. focusOnXY: function(a, b) {
  2812. this.setPosition(Math.round(a - this.view.halfWidth), Math.round(b - this.view.halfHeight))
  2813. },
  2814. update: function() {
  2815. this.target && this.updateTarget(), this.bounds && this.checkBounds(), this.displayObject.position.x = -this.view.x, this.displayObject.position.y = -this.view.y
  2816. },
  2817. updateTarget: function() {
  2818. 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)
  2819. },
  2820. setBoundsToWorld: function() {
  2821. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  2822. },
  2823. checkBounds: function() {
  2824. 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()
  2825. },
  2826. setPosition: function(a, b) {
  2827. this.view.x = a, this.view.y = b, this.bounds && this.checkBounds()
  2828. },
  2829. setSize: function(a, b) {
  2830. this.view.width = a, this.view.height = b
  2831. },
  2832. reset: function() {
  2833. this.target = null, this.view.x = 0, this.view.y = 0
  2834. }
  2835. }, b.Camera.prototype.constructor = b.Camera, Object.defineProperty(b.Camera.prototype, "x", {
  2836. get: function() {
  2837. return this.view.x
  2838. },
  2839. set: function(a) {
  2840. this.view.x = a, this.bounds && this.checkBounds()
  2841. }
  2842. }), Object.defineProperty(b.Camera.prototype, "y", {
  2843. get: function() {
  2844. return this.view.y
  2845. },
  2846. set: function(a) {
  2847. this.view.y = a, this.bounds && this.checkBounds()
  2848. }
  2849. }), Object.defineProperty(b.Camera.prototype, "width", {
  2850. get: function() {
  2851. return this.view.width
  2852. },
  2853. set: function(a) {
  2854. this.view.width = a
  2855. }
  2856. }), Object.defineProperty(b.Camera.prototype, "height", {
  2857. get: function() {
  2858. return this.view.height
  2859. },
  2860. set: function(a) {
  2861. this.view.height = a
  2862. }
  2863. }), b.State = function() {
  2864. 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
  2865. }, b.State.prototype = {
  2866. preload: function() {},
  2867. loadUpdate: function() {},
  2868. loadRender: function() {},
  2869. create: function() {},
  2870. update: function() {},
  2871. render: function() {},
  2872. paused: function() {},
  2873. pauseUpdate: function() {},
  2874. shutdown: function() {}
  2875. }, b.State.prototype.constructor = b.State, b.StateManager = function(a, b) {
  2876. 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
  2877. }, b.StateManager.prototype = {
  2878. boot: function() {
  2879. 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))
  2880. },
  2881. add: function(a, c, d) {
  2882. "undefined" == typeof d && (d = !1);
  2883. var e;
  2884. 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
  2885. },
  2886. remove: function(a) {
  2887. 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]
  2888. },
  2889. start: function(a, b, c) {
  2890. "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)))
  2891. },
  2892. restart: function(a, b) {
  2893. "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))
  2894. },
  2895. dummy: function() {},
  2896. preUpdate: function() {
  2897. 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))
  2898. },
  2899. checkState: function(a) {
  2900. if (this.states[a]) {
  2901. var b = !1;
  2902. 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
  2903. }
  2904. return console.warn("Phaser.StateManager - No state found with the key: " + a), !1
  2905. },
  2906. link: function(a) {
  2907. 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
  2908. },
  2909. setCurrentState: function(a) {
  2910. 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 = []
  2911. },
  2912. getCurrentState: function() {
  2913. return this.states[this.current]
  2914. },
  2915. loadComplete: function() {
  2916. this._created === !1 && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0
  2917. },
  2918. pause: function() {
  2919. this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game)
  2920. },
  2921. resume: function() {
  2922. this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game)
  2923. },
  2924. update: function() {
  2925. this._created && this.onUpdateCallback ? this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2926. },
  2927. pauseUpdate: function() {
  2928. this._created && this.onPauseUpdateCallback ? this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2929. },
  2930. preRender: function() {
  2931. this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game)
  2932. },
  2933. render: function() {
  2934. 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)
  2935. },
  2936. destroy: function() {
  2937. 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
  2938. }
  2939. }, b.StateManager.prototype.constructor = b.StateManager, b.LinkedList = function() {
  2940. this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0
  2941. }, b.LinkedList.prototype = {
  2942. add: function(a) {
  2943. 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)
  2944. },
  2945. reset: function() {
  2946. this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0
  2947. },
  2948. remove: function(a) {
  2949. return 1 === this.total ? (this.reset(), void(a.next = a.prev = null)) : (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), void this.total--)
  2950. },
  2951. callAll: function(a) {
  2952. if (this.first && this.last) {
  2953. var b = this.first;
  2954. do b && b[a] && b[a].call(b), b = b.next; while (b != this.last.next)
  2955. }
  2956. }
  2957. }, b.LinkedList.prototype.constructor = b.LinkedList, b.ArrayList = function() {
  2958. this.total = 0, this.position = 0, this.list = []
  2959. }, b.ArrayList.prototype = {
  2960. add: function(a) {
  2961. return this.exists(a) || (this.list.push(a), this.total++), a
  2962. },
  2963. getIndex: function(a) {
  2964. return this.list.indexOf(a)
  2965. },
  2966. exists: function(a) {
  2967. return this.list.indexOf(a) > -1
  2968. },
  2969. reset: function() {
  2970. this.list.length = 0, this.total = 0
  2971. },
  2972. remove: function(a) {
  2973. var b = this.list.indexOf(a);
  2974. return b > -1 ? (this.list.splice(b, 1), this.total--, a) : void 0
  2975. },
  2976. setAll: function(a, b) {
  2977. for (var c = this.list.length; c--;) this.list[c] && this.list[c][a] && (this.list[c][a] = b)
  2978. },
  2979. callAll: function(a) {
  2980. 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)
  2981. }
  2982. }, Object.defineProperty(b.ArrayList.prototype, "first", {
  2983. get: function() {
  2984. return this.position = 0, this.total > 0 ? this.list[0] : null
  2985. }
  2986. }), Object.defineProperty(b.ArrayList.prototype, "next", {
  2987. get: function() {
  2988. return this.position < this.total ? (this.position++, this.list[this.position]) : null
  2989. }
  2990. }), b.ArrayList.prototype.constructor = b.ArrayList, b.Signal = function() {
  2991. this._bindings = [], this._prevParams = null;
  2992. var a = this;
  2993. this.dispatch = function() {
  2994. b.Signal.prototype.dispatch.apply(a, arguments)
  2995. }
  2996. }, b.Signal.prototype = {
  2997. memorize: !1,
  2998. _shouldPropagate: !0,
  2999. active: !0,
  3000. validateListener: function(a, b) {
  3001. if ("function" != typeof a) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", b))
  3002. },
  3003. _registerListener: function(a, c, d, e) {
  3004. var f, g = this._indexOfListener(a, d);
  3005. if (-1 !== g) {
  3006. if (f = this._bindings[g], f.isOnce() !== c) throw new Error("You cannot add" + (c ? "" : "Once") + "() then add" + (c ? "Once" : "") + "() the same listener without removing the relationship first.")
  3007. } else f = new b.SignalBinding(this, a, c, d, e), this._addBinding(f);
  3008. return this.memorize && this._prevParams && f.execute(this._prevParams), f
  3009. },
  3010. _addBinding: function(a) {
  3011. var b = this._bindings.length;
  3012. do b--; while (this._bindings[b] && a._priority <= this._bindings[b]._priority);
  3013. this._bindings.splice(b + 1, 0, a)
  3014. },
  3015. _indexOfListener: function(a, b) {
  3016. for (var c, d = this._bindings.length; d--;)
  3017. if (c = this._bindings[d], c._listener === a && c.context === b) return d;
  3018. return -1
  3019. },
  3020. has: function(a, b) {
  3021. return -1 !== this._indexOfListener(a, b)
  3022. },
  3023. add: function(a, b, c) {
  3024. return this.validateListener(a, "add"), this._registerListener(a, !1, b, c)
  3025. },
  3026. addOnce: function(a, b, c) {
  3027. return this.validateListener(a, "addOnce"), this._registerListener(a, !0, b, c)
  3028. },
  3029. remove: function(a, b) {
  3030. this.validateListener(a, "remove");
  3031. var c = this._indexOfListener(a, b);
  3032. return -1 !== c && (this._bindings[c]._destroy(), this._bindings.splice(c, 1)), a
  3033. },
  3034. removeAll: function(a) {
  3035. "undefined" == typeof a && (a = null);
  3036. 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();
  3037. this._bindings.length = 0
  3038. },
  3039. getNumListeners: function() {
  3040. return this._bindings.length
  3041. },
  3042. halt: function() {
  3043. this._shouldPropagate = !1
  3044. },
  3045. dispatch: function() {
  3046. if (this.active) {
  3047. var a, b = Array.prototype.slice.call(arguments),
  3048. c = this._bindings.length;
  3049. if (this.memorize && (this._prevParams = b), c) {
  3050. a = this._bindings.slice(), this._shouldPropagate = !0;
  3051. do c--; while (a[c] && this._shouldPropagate && a[c].execute(b) !== !1)
  3052. }
  3053. }
  3054. },
  3055. forget: function() {
  3056. this._prevParams = null
  3057. },
  3058. dispose: function() {
  3059. this.removeAll(), delete this._bindings, delete this._prevParams
  3060. },
  3061. toString: function() {
  3062. return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"
  3063. }
  3064. }, b.Signal.prototype.constructor = b.Signal, b.SignalBinding = function(a, b, c, d, e) {
  3065. this._listener = b, this._isOnce = c, this.context = d, this._signal = a, this._priority = e || 0
  3066. }, b.SignalBinding.prototype = {
  3067. active: !0,
  3068. params: null,
  3069. execute: function(a) {
  3070. var b, c;
  3071. 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
  3072. },
  3073. detach: function() {
  3074. return this.isBound() ? this._signal.remove(this._listener, this.context) : null
  3075. },
  3076. isBound: function() {
  3077. return !!this._signal && !!this._listener
  3078. },
  3079. isOnce: function() {
  3080. return this._isOnce
  3081. },
  3082. getListener: function() {
  3083. return this._listener
  3084. },
  3085. getSignal: function() {
  3086. return this._signal
  3087. },
  3088. _destroy: function() {
  3089. delete this._signal, delete this._listener, delete this.context
  3090. },
  3091. toString: function() {
  3092. return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"
  3093. }
  3094. }, b.SignalBinding.prototype.constructor = b.SignalBinding, b.Filter = function(a, c, d) {
  3095. this.game = a, this.type = b.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = {
  3096. time: {
  3097. type: "1f",
  3098. value: 0
  3099. },
  3100. resolution: {
  3101. type: "2f",
  3102. value: {
  3103. x: 256,
  3104. y: 256
  3105. }
  3106. },
  3107. mouse: {
  3108. type: "2f",
  3109. value: {
  3110. x: 0,
  3111. y: 0
  3112. }
  3113. }
  3114. }, this.fragmentSrc = d || []
  3115. }, b.Filter.prototype = {
  3116. init: function() {},
  3117. setResolution: function(a, b) {
  3118. this.uniforms.resolution.value.x = a, this.uniforms.resolution.value.y = b
  3119. },
  3120. update: function(a) {
  3121. "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()
  3122. },
  3123. destroy: function() {
  3124. this.game = null
  3125. }
  3126. }, b.Filter.prototype.constructor = b.Filter, Object.defineProperty(b.Filter.prototype, "width", {
  3127. get: function() {
  3128. return this.uniforms.resolution.value.x
  3129. },
  3130. set: function(a) {
  3131. this.uniforms.resolution.value.x = a
  3132. }
  3133. }), Object.defineProperty(b.Filter.prototype, "height", {
  3134. get: function() {
  3135. return this.uniforms.resolution.value.y
  3136. },
  3137. set: function(a) {
  3138. this.uniforms.resolution.value.y = a
  3139. }
  3140. }), b.Plugin = function(a, b) {
  3141. "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
  3142. }, b.Plugin.prototype = {
  3143. preUpdate: function() {},
  3144. update: function() {},
  3145. render: function() {},
  3146. postRender: function() {},
  3147. destroy: function() {
  3148. this.game = null, this.parent = null, this.active = !1, this.visible = !1
  3149. }
  3150. }, b.Plugin.prototype.constructor = b.Plugin, b.PluginManager = function(a) {
  3151. this.game = a, this.plugins = [], this._len = 0, this._i = 0
  3152. }, b.PluginManager.prototype = {
  3153. add: function(a) {
  3154. var b = Array.prototype.splice.call(arguments, 1),
  3155. c = !1;
  3156. 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
  3157. },
  3158. remove: function(a) {
  3159. for (this._i = this._len; this._i--;)
  3160. if (this.plugins[this._i] === a) return a.destroy(), this.plugins.splice(this._i, 1), void this._len--
  3161. },
  3162. removeAll: function() {
  3163. for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
  3164. this.plugins.length = 0, this._len = 0
  3165. },
  3166. preUpdate: function() {
  3167. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate()
  3168. },
  3169. update: function() {
  3170. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update()
  3171. },
  3172. postUpdate: function() {
  3173. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate()
  3174. },
  3175. render: function() {
  3176. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render()
  3177. },
  3178. postRender: function() {
  3179. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender()
  3180. },
  3181. destroy: function() {
  3182. this.removeAll(), this.game = null
  3183. }
  3184. }, b.PluginManager.prototype.constructor = b.PluginManager, b.Stage = function(a, c, d) {
  3185. 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)
  3186. }, b.Stage.prototype = Object.create(PIXI.Stage.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.preUpdate = function() {
  3187. this.currentRenderOrderID = 0;
  3188. for (var a = this.children.length, b = 0; a > b; b++) this.children[b].preUpdate()
  3189. }, b.Stage.prototype.update = function() {
  3190. for (var a = this.children.length; a--;) this.children[a].update()
  3191. }, b.Stage.prototype.postUpdate = function() {
  3192. if (this.game.world.camera.target) {
  3193. this.game.world.camera.target.postUpdate(), this.game.world.camera.update();
  3194. for (var a = this.children.length; a--;) this.children[a] !== this.game.world.camera.target && this.children[a].postUpdate()
  3195. } else {
  3196. this.game.world.camera.update();
  3197. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3198. }
  3199. 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)
  3200. }, b.Stage.prototype.parseConfig = function(a) {
  3201. 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)
  3202. }, b.Stage.prototype.boot = function() {
  3203. b.Canvas.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.game.width, this.game.height);
  3204. var a = this;
  3205. this._onChange = function(b) {
  3206. return a.visibilityChange(b)
  3207. }, b.Canvas.setUserSelect(this.game.canvas, "none"), b.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility()
  3208. }, b.Stage.prototype.checkVisibility = function() {
  3209. 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
  3210. }, b.Stage.prototype.visibilityChange = function(a) {
  3211. return "pagehide" === a.type || "blur" === a.type || "pageshow" === a.type || "focus" === a.type ? void("pagehide" === a.type || "blur" === a.type ? this.game.focusLoss(a) : ("pageshow" === a.type || "focus" === a.type) && this.game.focusGain(a)) : void(this.disableVisibilityChange || (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden ? this.game.gamePaused(a) : this.game.gameResumed(a)))
  3212. }, b.Stage.prototype.setBackgroundColor = function(a) {
  3213. if ("string" == typeof a) {
  3214. var c = b.Color.hexToColor(a);
  3215. this._backgroundColor = b.Color.getColor(c.r, c.g, c.b)
  3216. } else {
  3217. var c = b.Color.getRGB(a);
  3218. this._backgroundColor = a
  3219. }
  3220. this.backgroundColorSplit = [c.r / 255, c.g / 255, c.b / 255], this.backgroundColorString = b.Color.RGBtoString(c.r, c.g, c.b, 255, "#")
  3221. }, Object.defineProperty(b.Stage.prototype, "backgroundColor", {
  3222. get: function() {
  3223. return this._backgroundColor
  3224. },
  3225. set: function(a) {
  3226. this.game.transparent || this.setBackgroundColor(a)
  3227. }
  3228. }), Object.defineProperty(b.Stage.prototype, "smoothed", {
  3229. get: function() {
  3230. return !PIXI.scaleModes.LINEAR
  3231. },
  3232. set: function(a) {
  3233. PIXI.scaleModes.LINEAR = a ? 0 : 1
  3234. }
  3235. }), b.Group = function(a, c, d, e, f, g) {
  3236. "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]
  3237. }, 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) {
  3238. 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
  3239. }, b.Group.prototype.addAt = function(a, b, c) {
  3240. 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
  3241. }, b.Group.prototype.getAt = function(a) {
  3242. return 0 > a || a >= this.children.length ? -1 : this.getChildAt(a)
  3243. }, b.Group.prototype.create = function(a, b, c, d, e) {
  3244. "undefined" == typeof e && (e = !0);
  3245. var f = new this.classType(this.game, a, b, c, d);
  3246. 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
  3247. }, b.Group.prototype.createMultiple = function(a, b, c, d) {
  3248. "undefined" == typeof d && (d = !1);
  3249. for (var e = 0; a > e; e++) this.create(0, 0, b, c, d)
  3250. }, b.Group.prototype.updateZ = function() {
  3251. for (var a = this.children.length; a--;) this.children[a].z = a
  3252. }, b.Group.prototype.resetCursor = function(a) {
  3253. 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
  3254. }, b.Group.prototype.next = function() {
  3255. 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
  3256. }, b.Group.prototype.previous = function() {
  3257. 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
  3258. }, b.Group.prototype.swap = function(a, b) {
  3259. var c = this.swapChildren(a, b);
  3260. return c && this.updateZ(), c
  3261. }, b.Group.prototype.bringToTop = function(a) {
  3262. return a.parent === this && this.getIndex(a) < this.children.length && (this.remove(a, !1, !0), this.add(a, !0)), a
  3263. }, b.Group.prototype.sendToBack = function(a) {
  3264. return a.parent === this && this.getIndex(a) > 0 && (this.remove(a, !1, !0), this.addAt(a, 0, !0)), a
  3265. }, b.Group.prototype.moveUp = function(a) {
  3266. if (a.parent === this && this.getIndex(a) < this.children.length - 1) {
  3267. var b = this.getIndex(a),
  3268. c = this.getAt(b + 1);
  3269. c && this.swap(a, c)
  3270. }
  3271. return a
  3272. }, b.Group.prototype.moveDown = function(a) {
  3273. if (a.parent === this && this.getIndex(a) > 0) {
  3274. var b = this.getIndex(a),
  3275. c = this.getAt(b - 1);
  3276. c && this.swap(a, c)
  3277. }
  3278. return a
  3279. }, b.Group.prototype.xy = function(a, b, c) {
  3280. return 0 > a || a > this.children.length ? -1 : (this.getChildAt(a).x = b, void(this.getChildAt(a).y = c))
  3281. }, b.Group.prototype.reverse = function() {
  3282. this.children.reverse(), this.updateZ()
  3283. }, b.Group.prototype.getIndex = function(a) {
  3284. return this.children.indexOf(a)
  3285. }, b.Group.prototype.replace = function(a, c) {
  3286. var d = this.getIndex(a);
  3287. if (-1 !== d) {
  3288. void 0 !== c.parent && (c.events.onRemovedFromGroup.dispatch(c, this), c.parent.removeChild(c), c.parent instanceof b.Group && c.parent.updateZ());
  3289. var e = a;
  3290. return this.remove(e), this.addAt(c, d), e
  3291. }
  3292. }, b.Group.prototype.hasProperty = function(a, b) {
  3293. var c = b.length;
  3294. 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
  3295. }, b.Group.prototype.setProperty = function(a, b, c, d, e) {
  3296. if ("undefined" == typeof e && (e = !1), d = d || 0, !this.hasProperty(a, b) && (!e || d > 0)) return !1;
  3297. var f = b.length;
  3298. 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
  3299. }, b.Group.prototype.checkProperty = function(a, c, d, e) {
  3300. return "undefined" == typeof e && (e = !1), !b.Utils.getProperty(a, c) && e ? !1 : b.Utils.getProperty(a, c) !== d ? !1 : !0
  3301. }, b.Group.prototype.set = function(a, b, c, d, e, f, g) {
  3302. 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
  3303. }, b.Group.prototype.setAll = function(a, b, c, d, e, f) {
  3304. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof f && (f = !1), a = a.split("."), e = e || 0;
  3305. 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)
  3306. }, b.Group.prototype.setAllChildren = function(a, c, d, e, f, g) {
  3307. "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), "undefined" == typeof g && (g = !1), f = f || 0;
  3308. 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))
  3309. }, b.Group.prototype.checkAll = function(a, b, c, d, e) {
  3310. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  3311. for (var f = 0, g = this.children.length; g > f; f++)
  3312. if ((!c || c && this.children[f].alive) && (!d || d && this.children[f].visible) && !this.checkProperty(this.children[f], a, b, e)) return !1;
  3313. return !0
  3314. }, b.Group.prototype.addAll = function(a, b, c, d) {
  3315. this.setAll(a, b, c, d, 1)
  3316. }, b.Group.prototype.subAll = function(a, b, c, d) {
  3317. this.setAll(a, b, c, d, 2)
  3318. }, b.Group.prototype.multiplyAll = function(a, b, c, d) {
  3319. this.setAll(a, b, c, d, 3)
  3320. }, b.Group.prototype.divideAll = function(a, b, c, d) {
  3321. this.setAll(a, b, c, d, 4)
  3322. }, b.Group.prototype.callAllExists = function(a, b) {
  3323. for (var c = Array.prototype.splice.call(arguments, 2), 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)
  3324. }, b.Group.prototype.callbackFromArray = function(a, b, c) {
  3325. if (1 == c) {
  3326. if (a[b[0]]) return a[b[0]]
  3327. } else if (2 == c) {
  3328. if (a[b[0]][b[1]]) return a[b[0]][b[1]]
  3329. } else if (3 == c) {
  3330. if (a[b[0]][b[1]][b[2]]) return a[b[0]][b[1]][b[2]]
  3331. } else if (4 == c) {
  3332. if (a[b[0]][b[1]][b[2]][b[3]]) return a[b[0]][b[1]][b[2]][b[3]]
  3333. } else if (a[b]) return a[b];
  3334. return !1
  3335. }, b.Group.prototype.callAll = function(a, b) {
  3336. if ("undefined" != typeof a) {
  3337. a = a.split(".");
  3338. var c = a.length;
  3339. if ("undefined" == typeof b || null === b || "" === b) b = null;
  3340. else if ("string" == typeof b) {
  3341. b = b.split(".");
  3342. var d = b.length
  3343. }
  3344. for (var 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)
  3345. }
  3346. }, b.Group.prototype.preUpdate = function() {
  3347. if (!this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  3348. for (var a = this.children.length; a--;) this.children[a].preUpdate();
  3349. return !0
  3350. }, b.Group.prototype.update = function() {
  3351. for (var a = this.children.length; a--;) this.children[a].update()
  3352. }, b.Group.prototype.postUpdate = function() {
  3353. 1 === this._cache[7] && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y);
  3354. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3355. }, b.Group.prototype.forEach = function(a, b, c) {
  3356. "undefined" == typeof c && (c = !1);
  3357. var d = Array.prototype.splice.call(arguments, 3);
  3358. d.unshift(null);
  3359. for (var e = 0, f = this.children.length; f > e; e++)(!c || c && this.children[e].exists) && (d[0] = this.children[e], a.apply(b, d))
  3360. }, b.Group.prototype.forEachExists = function(a, c) {
  3361. var d = Array.prototype.splice.call(arguments, 2);
  3362. d.unshift(null), this.iterate("exists", !0, b.Group.RETURN_TOTAL, a, c, d)
  3363. }, b.Group.prototype.forEachAlive = function(a, c) {
  3364. var d = Array.prototype.splice.call(arguments, 2);
  3365. d.unshift(null), this.iterate("alive", !0, b.Group.RETURN_TOTAL, a, c, d)
  3366. }, b.Group.prototype.forEachDead = function(a, c) {
  3367. var d = Array.prototype.splice.call(arguments, 2);
  3368. d.unshift(null), this.iterate("alive", !1, b.Group.RETURN_TOTAL, a, c, d)
  3369. }, b.Group.prototype.sort = function(a, c) {
  3370. this.children.length < 2 || ("undefined" == typeof a && (a = "z"), "undefined" == typeof c && (c = b.Group.SORT_ASCENDING), this._sortProperty = a, this.children.sort(c === b.Group.SORT_ASCENDING ? this.ascendingSortHandler.bind(this) : this.descendingSortHandler.bind(this)), this.updateZ())
  3371. }, b.Group.prototype.customSort = function(a, b) {
  3372. this.children.length < 2 || (this.children.sort(a.bind(b)), this.updateZ())
  3373. }, b.Group.prototype.ascendingSortHandler = function(a, b) {
  3374. return a[this._sortProperty] < b[this._sortProperty] ? -1 : a[this._sortProperty] > b[this._sortProperty] ? 1 : a.z < b.z ? -1 : 1
  3375. }, b.Group.prototype.descendingSortHandler = function(a, b) {
  3376. return a[this._sortProperty] < b[this._sortProperty] ? 1 : a[this._sortProperty] > b[this._sortProperty] ? -1 : 0
  3377. }, b.Group.prototype.iterate = function(a, c, d, e, f, g) {
  3378. if (d === b.Group.RETURN_TOTAL && 0 === this.children.length) return 0;
  3379. "undefined" == typeof e && (e = !1);
  3380. for (var h = 0, i = 0, j = this.children.length; j > i; i++)
  3381. 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];
  3382. return d === b.Group.RETURN_TOTAL ? h : d === b.Group.RETURN_CHILD ? null : void 0
  3383. }, b.Group.prototype.getFirstExists = function(a) {
  3384. return "boolean" != typeof a && (a = !0), this.iterate("exists", a, b.Group.RETURN_CHILD)
  3385. }, b.Group.prototype.getFirstAlive = function() {
  3386. return this.iterate("alive", !0, b.Group.RETURN_CHILD)
  3387. }, b.Group.prototype.getFirstDead = function() {
  3388. return this.iterate("alive", !1, b.Group.RETURN_CHILD)
  3389. }, b.Group.prototype.getTop = function() {
  3390. return this.children.length > 0 ? this.children[this.children.length - 1] : void 0
  3391. }, b.Group.prototype.getBottom = function() {
  3392. return this.children.length > 0 ? this.children[0] : void 0
  3393. }, b.Group.prototype.countLiving = function() {
  3394. return this.iterate("alive", !0, b.Group.RETURN_TOTAL)
  3395. }, b.Group.prototype.countDead = function() {
  3396. return this.iterate("alive", !1, b.Group.RETURN_TOTAL)
  3397. }, b.Group.prototype.getRandom = function(a, b) {
  3398. return 0 === this.children.length ? null : (a = a || 0, b = b || this.children.length, this.game.math.getRandom(this.children, a, b))
  3399. }, b.Group.prototype.remove = function(a, b, c) {
  3400. if ("undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !1), 0 === this.children.length || -1 === this.children.indexOf(a)) return !1;
  3401. c || !a.events || a.destroyPhase || a.events.onRemovedFromGroup.dispatch(a, this);
  3402. var d = this.removeChild(a);
  3403. return this.updateZ(), this.cursor === a && this.next(), b && d && d.destroy(!0), !0
  3404. }, b.Group.prototype.removeAll = function(a, b) {
  3405. if ("undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), 0 !== this.children.length) {
  3406. do {
  3407. !b && this.children[0].events && this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
  3408. var c = this.removeChild(this.children[0]);
  3409. a && c && c.destroy(!0)
  3410. } while (this.children.length > 0);
  3411. this.cursor = null
  3412. }
  3413. }, b.Group.prototype.removeBetween = function(a, b, c, d) {
  3414. if ("undefined" == typeof b && (b = this.children.length), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), 0 !== this.children.length) {
  3415. if (a > b || 0 > a || b > this.children.length) return !1;
  3416. for (var e = b; e >= a;) {
  3417. !d && this.children[e].events && this.children[e].events.onRemovedFromGroup.dispatch(this.children[e], this);
  3418. var f = this.removeChild(this.children[e]);
  3419. c && f && f.destroy(!0), this.cursor === this.children[e] && (this.cursor = null), e--
  3420. }
  3421. this.updateZ()
  3422. }
  3423. }, b.Group.prototype.destroy = function(a, b) {
  3424. 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))
  3425. }, Object.defineProperty(b.Group.prototype, "total", {
  3426. get: function() {
  3427. return this.iterate("exists", !0, b.Group.RETURN_TOTAL)
  3428. }
  3429. }), Object.defineProperty(b.Group.prototype, "length", {
  3430. get: function() {
  3431. return this.children.length
  3432. }
  3433. }), Object.defineProperty(b.Group.prototype, "angle", {
  3434. get: function() {
  3435. return b.Math.radToDeg(this.rotation)
  3436. },
  3437. set: function(a) {
  3438. this.rotation = b.Math.degToRad(a)
  3439. }
  3440. }), Object.defineProperty(b.Group.prototype, "fixedToCamera", {
  3441. get: function() {
  3442. return !!this._cache[7]
  3443. },
  3444. set: function(a) {
  3445. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  3446. }
  3447. }), b.World = function(a) {
  3448. b.Group.call(this, a, null, "__world", !1), this.bounds = new b.Rectangle(0, 0, a.width, a.height), this.camera = null
  3449. }, b.World.prototype = Object.create(b.Group.prototype), b.World.prototype.constructor = b.World, b.World.prototype.boot = function() {
  3450. 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)
  3451. }, b.World.prototype.setBounds = function(a, b, c, d) {
  3452. 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()
  3453. }, b.World.prototype.shutdown = function() {
  3454. this.destroy(!0, !0)
  3455. }, b.World.prototype.wrap = function(a, b, c, d, e) {
  3456. "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))
  3457. }, Object.defineProperty(b.World.prototype, "width", {
  3458. get: function() {
  3459. return this.bounds.width
  3460. },
  3461. set: function(a) {
  3462. this.bounds.width = a
  3463. }
  3464. }), Object.defineProperty(b.World.prototype, "height", {
  3465. get: function() {
  3466. return this.bounds.height
  3467. },
  3468. set: function(a) {
  3469. this.bounds.height = a
  3470. }
  3471. }), Object.defineProperty(b.World.prototype, "centerX", {
  3472. get: function() {
  3473. return this.bounds.halfWidth
  3474. }
  3475. }), Object.defineProperty(b.World.prototype, "centerY", {
  3476. get: function() {
  3477. return this.bounds.halfHeight
  3478. }
  3479. }), Object.defineProperty(b.World.prototype, "randomX", {
  3480. get: function() {
  3481. 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)
  3482. }
  3483. }), Object.defineProperty(b.World.prototype, "randomY", {
  3484. get: function() {
  3485. 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)
  3486. }
  3487. }), b.ScaleManager = function(a, c, d) {
  3488. 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;
  3489. var e = this;
  3490. window.addEventListener("orientationchange", function(a) {
  3491. return e.checkOrientation(a)
  3492. }, !1), window.addEventListener("resize", function(a) {
  3493. return e.checkResize(a)
  3494. }, !1), this.game.device.cocoonJS || (document.addEventListener("webkitfullscreenchange", function(a) {
  3495. return e.fullScreenChange(a)
  3496. }, !1), document.addEventListener("mozfullscreenchange", function(a) {
  3497. return e.fullScreenChange(a)
  3498. }, !1), document.addEventListener("fullscreenchange", function(a) {
  3499. return e.fullScreenChange(a)
  3500. }, !1))
  3501. }, b.ScaleManager.EXACT_FIT = 0, b.ScaleManager.NO_SCALE = 1, b.ScaleManager.SHOW_ALL = 2, b.ScaleManager.prototype = {
  3502. startFullScreen: function(a) {
  3503. !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]())
  3504. },
  3505. stopFullScreen: function() {
  3506. document[this.game.device.cancelFullscreen]()
  3507. },
  3508. fullScreenChange: function(a) {
  3509. 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))
  3510. },
  3511. forceOrientation: function(a, c, d) {
  3512. "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))
  3513. },
  3514. checkOrientationState: function() {
  3515. 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())
  3516. },
  3517. checkOrientation: function(a) {
  3518. 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()
  3519. },
  3520. checkResize: function(a) {
  3521. 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()
  3522. },
  3523. refresh: function() {
  3524. 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) {
  3525. this._iterations = this.maxIterations;
  3526. var a = this;
  3527. this._check = window.setInterval(function() {
  3528. return a.setScreenSize()
  3529. }, 10), this.setScreenSize()
  3530. }
  3531. },
  3532. setScreenSize: function(a) {
  3533. "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)
  3534. },
  3535. setSize: function() {
  3536. 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()
  3537. },
  3538. setMaximum: function() {
  3539. this.width = window.innerWidth, this.height = window.innerHeight
  3540. },
  3541. setShowAll: function() {
  3542. var a = Math.min(window.innerHeight / this.game.height, window.innerWidth / this.game.width);
  3543. this.width = Math.round(this.game.width * a), this.height = Math.round(this.game.height * a)
  3544. },
  3545. setExactFit: function() {
  3546. var a = window.innerWidth,
  3547. b = window.innerHeight;
  3548. this.width = this.maxWidth && a > this.maxWidth ? this.maxWidth : a, this.height = this.maxHeight && b > this.maxHeight ? this.maxHeight : b
  3549. }
  3550. }, b.ScaleManager.prototype.constructor = b.ScaleManager, Object.defineProperty(b.ScaleManager.prototype, "isFullScreen", {
  3551. get: function() {
  3552. return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement
  3553. }
  3554. }), Object.defineProperty(b.ScaleManager.prototype, "isPortrait", {
  3555. get: function() {
  3556. return 0 === this.orientation || 180 === this.orientation
  3557. }
  3558. }), Object.defineProperty(b.ScaleManager.prototype, "isLandscape", {
  3559. get: function() {
  3560. return 90 === this.orientation || -90 === this.orientation
  3561. }
  3562. }), b.Game = function(a, c, d, e, f, g, h, i) {
  3563. 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 = {
  3564. enableDebug: !0
  3565. }, "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));
  3566. var j = this;
  3567. return this._onBoot = function() {
  3568. return j.boot()
  3569. }, "complete" === document.readyState || "interactive" === document.readyState ? window.setTimeout(this._onBoot, 0) : (document.addEventListener("DOMContentLoaded", this._onBoot, !1), window.addEventListener("load", this._onBoot, !1)), this
  3570. }, b.Game.prototype = {
  3571. parseConfig: function(a) {
  3572. 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);
  3573. var c = [(Date.now() * Math.random()).toString()];
  3574. a.seed && (c = a.seed), this.rnd = new b.RandomDataGenerator(c);
  3575. var d = null;
  3576. a.state && (d = a.state), this.state = new b.StateManager(this, d)
  3577. },
  3578. boot: function() {
  3579. 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))
  3580. },
  3581. showDebugHeader: function() {
  3582. var a = b.VERSION,
  3583. c = "Canvas",
  3584. d = "HTML Audio",
  3585. e = 1;
  3586. if (this.renderType === b.WEBGL ? (c = "WebGL", e++) : this.renderType == b.HEADLESS && (c = "Headless"), this.device.webAudio && (d = "WebAudio", e++), this.device.chrome) {
  3587. for (var 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++) f.push(e > g ? "color: #ff2424; background: #fff" : "color: #959595; background: #fff");
  3588. console.log.apply(console, f)
  3589. } else window.console && console.log("Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " | http://phaser.io")
  3590. },
  3591. setUpRenderer: function() {
  3592. 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) {
  3593. if (!this.device.canvas) throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");
  3594. 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
  3595. } 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;
  3596. this.renderType !== b.HEADLESS && (this.stage.smoothed = this.antialias, b.Canvas.addToDOM(this.canvas, this.parent, !1), b.Canvas.setTouchAction(this.canvas))
  3597. },
  3598. update: function(a) {
  3599. 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))
  3600. },
  3601. enableStep: function() {
  3602. this.stepping = !0, this.pendingStep = !1, this.stepCount = 0
  3603. },
  3604. disableStep: function() {
  3605. this.stepping = !1, this.pendingStep = !1
  3606. },
  3607. step: function() {
  3608. this.pendingStep = !1, this.stepCount++
  3609. },
  3610. destroy: function() {
  3611. 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
  3612. },
  3613. gamePaused: function(a) {
  3614. this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.setMute(), this.onPause.dispatch(a))
  3615. },
  3616. gameResumed: function(a) {
  3617. this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.unsetMute(), this.onResume.dispatch(a))
  3618. },
  3619. focusLoss: function(a) {
  3620. this.onBlur.dispatch(a), this.stage.disableVisibilityChange || this.gamePaused(a)
  3621. },
  3622. focusGain: function(a) {
  3623. this.onFocus.dispatch(a), this.stage.disableVisibilityChange || this.gameResumed(a)
  3624. }
  3625. }, b.Game.prototype.constructor = b.Game, Object.defineProperty(b.Game.prototype, "paused", {
  3626. get: function() {
  3627. return this._paused
  3628. },
  3629. set: function(a) {
  3630. 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)
  3631. }
  3632. }), b.Input = function(a) {
  3633. 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
  3634. }, b.Input.MOUSE_OVERRIDES_TOUCH = 0, b.Input.TOUCH_OVERRIDES_MOUSE = 1, b.Input.MOUSE_TOUCH_COMBINE = 2, b.Input.prototype = {
  3635. boot: function() {
  3636. 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
  3637. },
  3638. destroy: function() {
  3639. this.mouse.stop(), this.keyboard.stop(), this.touch.stop(), this.mspointer.stop(), this.gamepad.stop(), this.moveCallbacks = [], this.moveCallback = null
  3640. },
  3641. setMoveCallback: function(a, b) {
  3642. this.moveCallback = a, this.moveCallbackContext = b
  3643. },
  3644. addMoveCallback: function(a, b) {
  3645. return this.moveCallbacks.push({
  3646. callback: a,
  3647. context: b
  3648. }) - 1
  3649. },
  3650. deleteMoveCallback: function(a) {
  3651. this.moveCallbacks[a] && this.moveCallbacks.splice(a, 1)
  3652. },
  3653. addPointer: function() {
  3654. for (var a = 0, c = 10; c > 0; c--) null === this["pointer" + c] && (a = c);
  3655. 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])
  3656. },
  3657. update: function() {
  3658. return this.keyboard.update(), this.pollRate > 0 && this._pollCounter < this.pollRate ? void this._pollCounter++ : (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(), void(this._pollCounter = 0))
  3659. },
  3660. reset: function(a) {
  3661. if (this.game.isBooted && !this.resetLocked) {
  3662. "undefined" == typeof a && (a = !1), this.keyboard.reset(a), this.mousePointer.reset(), this.gamepad.reset();
  3663. for (var c = 1; 10 >= c; c++) this["pointer" + c] && this["pointer" + c].reset();
  3664. 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
  3665. }
  3666. },
  3667. resetSpeed: function(a, b) {
  3668. this._oldPosition.setTo(a, b), this.speed.setTo(0, 0)
  3669. },
  3670. startPointer: function(a) {
  3671. if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) return null;
  3672. if (this.pointer1.active === !1) return this.pointer1.start(a);
  3673. if (this.pointer2.active === !1) return this.pointer2.start(a);
  3674. for (var b = 3; 10 >= b; b++)
  3675. if (this["pointer" + b] && this["pointer" + b].active === !1) return this["pointer" + b].start(a);
  3676. return null
  3677. },
  3678. updatePointer: function(a) {
  3679. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.move(a);
  3680. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.move(a);
  3681. for (var b = 3; 10 >= b; b++)
  3682. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].move(a);
  3683. return null
  3684. },
  3685. stopPointer: function(a) {
  3686. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.stop(a);
  3687. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.stop(a);
  3688. for (var b = 3; 10 >= b; b++)
  3689. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].stop(a);
  3690. return null
  3691. },
  3692. getPointer: function(a) {
  3693. if (a = a || !1, this.pointer1.active == a) return this.pointer1;
  3694. if (this.pointer2.active == a) return this.pointer2;
  3695. for (var b = 3; 10 >= b; b++)
  3696. if (this["pointer" + b] && this["pointer" + b].active == a) return this["pointer" + b];
  3697. return null
  3698. },
  3699. getPointerFromIdentifier: function(a) {
  3700. if (this.pointer1.identifier === a) return this.pointer1;
  3701. if (this.pointer2.identifier === a) return this.pointer2;
  3702. for (var b = 3; 10 >= b; b++)
  3703. if (this["pointer" + b] && this["pointer" + b].identifier === a) return this["pointer" + b];
  3704. return null
  3705. },
  3706. getPointerFromId: function(a) {
  3707. if (this.pointer1.pointerId === a) return this.pointer1;
  3708. if (this.pointer2.pointerId === a) return this.pointer2;
  3709. for (var b = 3; 10 >= b; b++)
  3710. if (this["pointer" + b] && this["pointer" + b].pointerId === a) return this["pointer" + b];
  3711. return null
  3712. },
  3713. getLocalPosition: function(a, c, d) {
  3714. "undefined" == typeof d && (d = new b.Point);
  3715. var e = a.worldTransform,
  3716. f = 1 / (e.a * e.d + e.b * -e.c);
  3717. return 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)
  3718. },
  3719. hitTest: function(a, c, d) {
  3720. if (!a.worldVisible) return !1;
  3721. 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;
  3722. if (a instanceof b.TileSprite) {
  3723. var e = a.width,
  3724. f = a.height,
  3725. g = -e * a.anchor.x;
  3726. if (this._localPoint.x > g && this._localPoint.x < g + e) {
  3727. var h = -f * a.anchor.y;
  3728. if (this._localPoint.y > h && this._localPoint.y < h + f) return !0
  3729. }
  3730. } else if (a instanceof PIXI.Sprite) {
  3731. var e = a.texture.frame.width,
  3732. f = a.texture.frame.height,
  3733. g = -e * a.anchor.x;
  3734. if (this._localPoint.x > g && this._localPoint.x < g + e) {
  3735. var h = -f * a.anchor.y;
  3736. if (this._localPoint.y > h && this._localPoint.y < h + f) return !0
  3737. }
  3738. }
  3739. for (var i = 0, j = a.children.length; j > i; i++)
  3740. if (this.hitTest(a.children[i], c, d)) return !0;
  3741. return !1
  3742. }
  3743. }, b.Input.prototype.constructor = b.Input, Object.defineProperty(b.Input.prototype, "x", {
  3744. get: function() {
  3745. return this._x
  3746. },
  3747. set: function(a) {
  3748. this._x = Math.floor(a)
  3749. }
  3750. }), Object.defineProperty(b.Input.prototype, "y", {
  3751. get: function() {
  3752. return this._y
  3753. },
  3754. set: function(a) {
  3755. this._y = Math.floor(a)
  3756. }
  3757. }), Object.defineProperty(b.Input.prototype, "pollLocked", {
  3758. get: function() {
  3759. return this.pollRate > 0 && this._pollCounter < this.pollRate
  3760. }
  3761. }), Object.defineProperty(b.Input.prototype, "totalInactivePointers", {
  3762. get: function() {
  3763. return 10 - this.currentPointers
  3764. }
  3765. }), Object.defineProperty(b.Input.prototype, "totalActivePointers", {
  3766. get: function() {
  3767. this.currentPointers = 0;
  3768. for (var a = 1; 10 >= a; a++) this["pointer" + a] && this["pointer" + a].active && this.currentPointers++;
  3769. return this.currentPointers
  3770. }
  3771. }), Object.defineProperty(b.Input.prototype, "worldX", {
  3772. get: function() {
  3773. return this.game.camera.view.x + this.x
  3774. }
  3775. }), Object.defineProperty(b.Input.prototype, "worldY", {
  3776. get: function() {
  3777. return this.game.camera.view.y + this.y
  3778. }
  3779. }), b.Key = function(a, c) {
  3780. 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
  3781. }, b.Key.prototype = {
  3782. update: function() {
  3783. this.enabled && this.isDown && (this.duration = this.game.time.now - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this))
  3784. },
  3785. processKeyDown: function(a) {
  3786. 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)))
  3787. },
  3788. processKeyUp: function(a) {
  3789. 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)))
  3790. },
  3791. reset: function(a) {
  3792. "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)
  3793. },
  3794. justPressed: function(a) {
  3795. return "undefined" == typeof a && (a = 50), this.isDown && this.duration < a
  3796. },
  3797. justReleased: function(a) {
  3798. return "undefined" == typeof a && (a = 50), !this.isDown && this.game.time.now - this.timeUp < a
  3799. }
  3800. }, b.Key.prototype.constructor = b.Key, b.Keyboard = function(a) {
  3801. 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
  3802. }, b.Keyboard.prototype = {
  3803. addCallbacks: function(a, b, c, d) {
  3804. this.callbackContext = a, "undefined" != typeof b && (this.onDownCallback = b), "undefined" != typeof c && (this.onUpCallback = c), "undefined" != typeof d && (this.onPressCallback = d)
  3805. },
  3806. addKey: function(a) {
  3807. return this._keys[a] || (this._keys[a] = new b.Key(this.game, a), this.addKeyCapture(a)), this._keys[a]
  3808. },
  3809. removeKey: function(a) {
  3810. this._keys[a] && (this._keys[a] = null, this.removeKeyCapture(a))
  3811. },
  3812. createCursorKeys: function() {
  3813. return {
  3814. up: this.addKey(b.Keyboard.UP),
  3815. down: this.addKey(b.Keyboard.DOWN),
  3816. left: this.addKey(b.Keyboard.LEFT),
  3817. right: this.addKey(b.Keyboard.RIGHT)
  3818. }
  3819. },
  3820. start: function() {
  3821. if (!this.game.device.cocoonJS && null === this._onKeyDown) {
  3822. var a = this;
  3823. this._onKeyDown = function(b) {
  3824. return a.processKeyDown(b)
  3825. }, this._onKeyUp = function(b) {
  3826. return a.processKeyUp(b)
  3827. }, this._onKeyPress = function(b) {
  3828. return a.processKeyPress(b)
  3829. }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
  3830. }
  3831. },
  3832. stop: function() {
  3833. window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null
  3834. },
  3835. destroy: function() {
  3836. this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0
  3837. },
  3838. addKeyCapture: function(a) {
  3839. if ("object" == typeof a)
  3840. for (var b in a) this._capture[a[b]] = !0;
  3841. else this._capture[a] = !0
  3842. },
  3843. removeKeyCapture: function(a) {
  3844. delete this._capture[a]
  3845. },
  3846. clearCaptures: function() {
  3847. this._capture = {}
  3848. },
  3849. update: function() {
  3850. for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update()
  3851. },
  3852. processKeyDown: function(a) {
  3853. 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))
  3854. },
  3855. processKeyPress: function(a) {
  3856. this.pressEvent = a, this.game.input.disabled || this.disabled || this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(a.charCode), a)
  3857. },
  3858. processKeyUp: function(a) {
  3859. 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))
  3860. },
  3861. reset: function(a) {
  3862. "undefined" == typeof a && (a = !0), this.event = null;
  3863. for (var b = this._keys.length; b--;) this._keys[b] && this._keys[b].reset(a)
  3864. },
  3865. justPressed: function(a, b) {
  3866. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justPressed(b) : !1
  3867. },
  3868. justReleased: function(a, b) {
  3869. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justReleased(b) : !1
  3870. },
  3871. isDown: function(a) {
  3872. return this._keys[a] ? this._keys[a].isDown : !1
  3873. }
  3874. }, Object.defineProperty(b.Keyboard.prototype, "lastChar", {
  3875. get: function() {
  3876. return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode)
  3877. }
  3878. }), Object.defineProperty(b.Keyboard.prototype, "lastKey", {
  3879. get: function() {
  3880. return this._keys[this._k]
  3881. }
  3882. }), 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) {
  3883. 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
  3884. }, 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 = {
  3885. start: function() {
  3886. if ((!this.game.device.android || this.game.device.chrome !== !1) && null === this._onMouseDown) {
  3887. var a = this;
  3888. this._onMouseDown = function(b) {
  3889. return a.onMouseDown(b)
  3890. }, this._onMouseMove = function(b) {
  3891. return a.onMouseMove(b)
  3892. }, this._onMouseUp = function(b) {
  3893. return a.onMouseUp(b)
  3894. }, this._onMouseOut = function(b) {
  3895. return a.onMouseOut(b)
  3896. }, this._onMouseOver = function(b) {
  3897. return a.onMouseOver(b)
  3898. }, this._onMouseWheel = function(b) {
  3899. return a.onMouseWheel(b)
  3900. }, 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))
  3901. }
  3902. },
  3903. onMouseDown: function(a) {
  3904. 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))
  3905. },
  3906. onMouseMove: function(a) {
  3907. 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))
  3908. },
  3909. onMouseUp: function(a) {
  3910. 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))
  3911. },
  3912. onMouseOut: function(a) {
  3913. 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)))
  3914. },
  3915. onMouseWheel: function(a) {
  3916. 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)
  3917. },
  3918. onMouseOver: function(a) {
  3919. 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)
  3920. },
  3921. requestPointerLock: function() {
  3922. if (this.game.device.pointerLock) {
  3923. var a = this.game.canvas;
  3924. a.requestPointerLock = a.requestPointerLock || a.mozRequestPointerLock || a.webkitRequestPointerLock, a.requestPointerLock();
  3925. var b = this;
  3926. this._pointerLockChange = function(a) {
  3927. return b.pointerLockChange(a)
  3928. }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  3929. }
  3930. },
  3931. pointerLockChange: function(a) {
  3932. var b = this.game.canvas;
  3933. 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))
  3934. },
  3935. releasePointerLock: function() {
  3936. 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)
  3937. },
  3938. stop: function() {
  3939. 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)
  3940. }
  3941. }, b.Mouse.prototype.constructor = b.Mouse, b.MSPointer = function(a) {
  3942. this.game = a, this.callbackContext = this.game, this.disabled = !1, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null
  3943. }, b.MSPointer.prototype = {
  3944. start: function() {
  3945. if (null === this._onMSPointerDown) {
  3946. var a = this;
  3947. this.game.device.mspointer === !0 && (this._onMSPointerDown = function(b) {
  3948. return a.onPointerDown(b)
  3949. }, this._onMSPointerMove = function(b) {
  3950. return a.onPointerMove(b)
  3951. }, this._onMSPointerUp = function(b) {
  3952. return a.onPointerUp(b)
  3953. }, 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")
  3954. }
  3955. },
  3956. onPointerDown: function(a) {
  3957. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.startPointer(a))
  3958. },
  3959. onPointerMove: function(a) {
  3960. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.updatePointer(a))
  3961. },
  3962. onPointerUp: function(a) {
  3963. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.stopPointer(a))
  3964. },
  3965. stop: function() {
  3966. 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)
  3967. }
  3968. }, b.MSPointer.prototype.constructor = b.MSPointer, b.Pointer = function(a, c) {
  3969. 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)
  3970. }, b.Pointer.prototype = {
  3971. start: function(a) {
  3972. 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
  3973. },
  3974. update: function() {
  3975. 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({
  3976. x: this.position.x,
  3977. y: this.position.y
  3978. }), this._history.length > this.game.input.recordLimit && this._history.shift()))
  3979. },
  3980. move: function(a, c) {
  3981. if (!this.game.input.pollLocked) {
  3982. 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;
  3983. this.game.input.moveCallback && this.game.input.moveCallback.call(this.game.input.moveCallbackContext, this, this.x, this.y);
  3984. 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);
  3985. 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)
  3986. }
  3987. },
  3988. processInteractiveObjects: function(a) {
  3989. this.game.input.interactiveItems.setAll("checked", !1), this._highestRenderOrderID = Number.MAX_SAFE_INTEGER, this._highestRenderObject = null, this._highestInputPriorityID = -1;
  3990. var b = this.game.input.interactiveItems.first;
  3991. 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);
  3992. var b = this.game.input.interactiveItems.first;
  3993. 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);
  3994. 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))
  3995. },
  3996. leave: function(a) {
  3997. this.withinGame = !1, this.move(a, !1)
  3998. },
  3999. stop: function(a) {
  4000. return this._stateReset ? void a.preventDefault() : (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)
  4001. },
  4002. justPressed: function(a) {
  4003. return a = a || this.game.input.justPressedRate, this.isDown === !0 && this.timeDown + a > this.game.time.now
  4004. },
  4005. justReleased: function(a) {
  4006. return a = a || this.game.input.justReleasedRate, this.isUp === !0 && this.timeUp + a > this.game.time.now
  4007. },
  4008. reset: function() {
  4009. 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
  4010. },
  4011. resetMovement: function() {
  4012. this.movementX = 0, this.movementY = 0
  4013. }
  4014. }, b.Pointer.prototype.constructor = b.Pointer, Object.defineProperty(b.Pointer.prototype, "duration", {
  4015. get: function() {
  4016. return this.isUp ? -1 : this.game.time.now - this.timeDown
  4017. }
  4018. }), Object.defineProperty(b.Pointer.prototype, "worldX", {
  4019. get: function() {
  4020. return this.game.world.camera.x + this.x
  4021. }
  4022. }), Object.defineProperty(b.Pointer.prototype, "worldY", {
  4023. get: function() {
  4024. return this.game.world.camera.y + this.y
  4025. }
  4026. }), b.Touch = function(a) {
  4027. 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
  4028. }, b.Touch.prototype = {
  4029. start: function() {
  4030. if (null === this._onTouchStart) {
  4031. var a = this;
  4032. this.game.device.touch && (this._onTouchStart = function(b) {
  4033. return a.onTouchStart(b)
  4034. }, this._onTouchMove = function(b) {
  4035. return a.onTouchMove(b)
  4036. }, this._onTouchEnd = function(b) {
  4037. return a.onTouchEnd(b)
  4038. }, this._onTouchEnter = function(b) {
  4039. return a.onTouchEnter(b)
  4040. }, this._onTouchLeave = function(b) {
  4041. return a.onTouchLeave(b)
  4042. }, this._onTouchCancel = function(b) {
  4043. return a.onTouchCancel(b)
  4044. }, 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)))
  4045. }
  4046. },
  4047. consumeDocumentTouches: function() {
  4048. this._documentTouchMove = function(a) {
  4049. a.preventDefault()
  4050. }, document.addEventListener("touchmove", this._documentTouchMove, !1)
  4051. },
  4052. onTouchStart: function(a) {
  4053. if (this.event = a, this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  4054. this.preventDefault && a.preventDefault();
  4055. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.startPointer(a.changedTouches[b])
  4056. }
  4057. },
  4058. onTouchCancel: function(a) {
  4059. if (this.event = a, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  4060. this.preventDefault && a.preventDefault();
  4061. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4062. }
  4063. },
  4064. onTouchEnter: function(a) {
  4065. this.event = a, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || this.preventDefault && a.preventDefault()
  4066. },
  4067. onTouchLeave: function(a) {
  4068. this.event = a, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault()
  4069. },
  4070. onTouchMove: function(a) {
  4071. this.event = a, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4072. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.updatePointer(a.changedTouches[b])
  4073. },
  4074. onTouchEnd: function(a) {
  4075. this.event = a, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4076. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4077. },
  4078. stop: function() {
  4079. 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))
  4080. }
  4081. }, b.Touch.prototype.constructor = b.Touch, b.Gamepad = function(a) {
  4082. 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
  4083. }, b.Gamepad.prototype = {
  4084. addCallbacks: function(a, b) {
  4085. "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)
  4086. },
  4087. start: function() {
  4088. if (!this._active) {
  4089. this._active = !0;
  4090. var a = this;
  4091. this._ongamepadconnected = function(b) {
  4092. var c = b.gamepad;
  4093. a._rawPads.push(c), a._gamepads[c.index].connect(c)
  4094. }, window.addEventListener("gamepadconnected", this._ongamepadconnected, !1), this._ongamepaddisconnected = function(b) {
  4095. var c = b.gamepad;
  4096. for (var d in a._rawPads) a._rawPads[d].index === c.index && a._rawPads.splice(d, 1);
  4097. a._gamepads[c.index].disconnect()
  4098. }, window.addEventListener("gamepaddisconnected", this._ongamepaddisconnected, !1)
  4099. }
  4100. },
  4101. update: function() {
  4102. this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus()
  4103. },
  4104. _pollGamepads: function() {
  4105. if (navigator.getGamepads) var a = navigator.getGamepads();
  4106. else if (navigator.webkitGetGamepads) var a = navigator.webkitGetGamepads();
  4107. else if (navigator.webkitGamepads) var a = navigator.webkitGamepads();
  4108. if (a) {
  4109. this._rawPads = [];
  4110. for (var 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++);
  4111. if (b) {
  4112. for (var d, e = {
  4113. rawIndices: {},
  4114. padIndices: {}
  4115. }, f = 0; f < this._gamepads.length; f++)
  4116. if (d = this._gamepads[f], d.connected)
  4117. for (var g = 0; g < this._rawPads.length; g++) this._rawPads[g].index === d.index && (e.rawIndices[d.index] = !0, e.padIndices[f] = !0);
  4118. for (var h = 0; h < this._gamepads.length; h++)
  4119. if (d = this._gamepads[h], !e.padIndices[h]) {
  4120. this._rawPads.length < 1 && d.disconnect();
  4121. for (var i = 0; i < this._rawPads.length && !e.padIndices[h]; i++) {
  4122. var j = this._rawPads[i];
  4123. if (j) {
  4124. if (e.rawIndices[j.index]) {
  4125. d.disconnect();
  4126. continue
  4127. }
  4128. d.connect(j), e.rawIndices[j.index] = !0, e.padIndices[h] = !0
  4129. } else d.disconnect()
  4130. }
  4131. }
  4132. }
  4133. }
  4134. },
  4135. setDeadZones: function(a) {
  4136. for (var b = 0; b < this._gamepads.length; b++) this._gamepads[b].deadZone = a
  4137. },
  4138. stop: function() {
  4139. this._active = !1, window.removeEventListener("gamepadconnected", this._ongamepadconnected), window.removeEventListener("gamepaddisconnected", this._ongamepaddisconnected)
  4140. },
  4141. reset: function() {
  4142. this.update();
  4143. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].reset()
  4144. },
  4145. justPressed: function(a, b) {
  4146. for (var c = 0; c < this._gamepads.length; c++)
  4147. if (this._gamepads[c].justPressed(a, b) === !0) return !0;
  4148. return !1
  4149. },
  4150. justReleased: function(a, b) {
  4151. for (var c = 0; c < this._gamepads.length; c++)
  4152. if (this._gamepads[c].justReleased(a, b) === !0) return !0;
  4153. return !1
  4154. },
  4155. isDown: function(a) {
  4156. for (var b = 0; b < this._gamepads.length; b++)
  4157. if (this._gamepads[b].isDown(a) === !0) return !0;
  4158. return !1
  4159. }
  4160. }, b.Gamepad.prototype.constructor = b.Gamepad, Object.defineProperty(b.Gamepad.prototype, "active", {
  4161. get: function() {
  4162. return this._active
  4163. }
  4164. }), Object.defineProperty(b.Gamepad.prototype, "supported", {
  4165. get: function() {
  4166. return this._gamepadSupportAvailable
  4167. }
  4168. }), Object.defineProperty(b.Gamepad.prototype, "padsConnected", {
  4169. get: function() {
  4170. return this._rawPads.length
  4171. }
  4172. }), Object.defineProperty(b.Gamepad.prototype, "pad1", {
  4173. get: function() {
  4174. return this._gamepads[0]
  4175. }
  4176. }), Object.defineProperty(b.Gamepad.prototype, "pad2", {
  4177. get: function() {
  4178. return this._gamepads[1]
  4179. }
  4180. }), Object.defineProperty(b.Gamepad.prototype, "pad3", {
  4181. get: function() {
  4182. return this._gamepads[2]
  4183. }
  4184. }), Object.defineProperty(b.Gamepad.prototype, "pad4", {
  4185. get: function() {
  4186. return this._gamepads[3]
  4187. }
  4188. }), 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) {
  4189. 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
  4190. }, b.SinglePad.prototype = {
  4191. addCallbacks: function(a, b) {
  4192. "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)
  4193. },
  4194. addButton: function(a) {
  4195. return this.getButton(a)
  4196. },
  4197. getButton: function(a) {
  4198. return this._buttons[a] ? this._buttons[a] : null
  4199. },
  4200. pollStatus: function() {
  4201. if (!(!this.connected || this.game.input.disabled || this.game.input.gamepad.disabled || this._rawPad.timestamp && this._rawPad.timestamp === this._prevTimestamp)) {
  4202. for (var a = 0; a < this._buttonsLen; a++) {
  4203. var b = isNaN(this._rawPad.buttons[a]) ? this._rawPad.buttons[a].value : this._rawPad.buttons[a];
  4204. b !== this._buttons[a].value && (1 === b ? this.processButtonDown(a, b) : 0 === b ? this.processButtonUp(a, b) : this.processButtonFloat(a, b))
  4205. }
  4206. for (var c = 0; c < this._axesLen; c++) {
  4207. var d = this._rawPad.axes[c];
  4208. this.processAxisChange(d > 0 && d > this.deadZone || 0 > d && d < -this.deadZone ? {
  4209. axis: c,
  4210. value: d
  4211. } : {
  4212. axis: c,
  4213. value: 0
  4214. })
  4215. }
  4216. this._prevTimestamp = this._rawPad.timestamp
  4217. }
  4218. },
  4219. connect: function(a) {
  4220. var c = !this.connected;
  4221. 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;
  4222. for (var d in a.buttons) d = parseInt(d, 10), this._buttons[d] = new b.GamepadButton(this, d);
  4223. c && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), c && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
  4224. },
  4225. disconnect: function() {
  4226. var a = this.connected,
  4227. b = this.index;
  4228. this.connected = !1, this.index = null, this._rawPad = void 0;
  4229. for (var c = 0; c < this._buttonsLen; c++) this._buttons[c].destroy();
  4230. 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)
  4231. },
  4232. processAxisChange: function(a) {
  4233. 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))
  4234. },
  4235. processButtonDown: function(a, b) {
  4236. 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)
  4237. },
  4238. processButtonUp: function(a, b) {
  4239. 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)
  4240. },
  4241. processButtonFloat: function(a, b) {
  4242. 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)
  4243. },
  4244. axis: function(a) {
  4245. return this._axes[a] ? this._axes[a] : !1
  4246. },
  4247. isDown: function(a) {
  4248. return this._buttons[a] ? this._buttons[a].isDown : !1
  4249. },
  4250. isUp: function(a) {
  4251. return this._buttons[a] ? this._buttons[a].isUp : !1
  4252. },
  4253. justReleased: function(a, b) {
  4254. return this._buttons[a] ? this._buttons[a].justReleased(b) : void 0
  4255. },
  4256. justPressed: function(a, b) {
  4257. return this._buttons[a] ? this._buttons[a].justPressed(b) : void 0
  4258. },
  4259. buttonValue: function(a) {
  4260. return this._buttons[a] ? this._buttons[a].value : null
  4261. },
  4262. reset: function() {
  4263. for (var a = 0; a < this._axes.length; a++) this._axes[a] = 0
  4264. }
  4265. }, b.SinglePad.prototype.constructor = b.SinglePad, b.GamepadButton = function(a, c) {
  4266. 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
  4267. }, b.GamepadButton.prototype = {
  4268. processButtonDown: function(a) {
  4269. 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))
  4270. },
  4271. processButtonUp: function(a) {
  4272. this.isDown && (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.value = a, this.onUp.dispatch(this, a))
  4273. },
  4274. processButtonFloat: function(a) {
  4275. this.value = a, this.onFloat.dispatch(this, a)
  4276. },
  4277. justPressed: function(a) {
  4278. return "undefined" == typeof a && (a = 250), this.isDown && this.duration < a
  4279. },
  4280. justReleased: function(a) {
  4281. return "undefined" == typeof a && (a = 250), this.isDown === !1 && this.game.time.now - this.timeUp < a
  4282. },
  4283. reset: function() {
  4284. this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0
  4285. },
  4286. destroy: function() {
  4287. this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.pad = null, this.game = null
  4288. }
  4289. }, b.GamepadButton.prototype.constructor = b.GamepadButton, b.InputHandler = function(a) {
  4290. 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({
  4291. id: 0,
  4292. x: 0,
  4293. y: 0,
  4294. isDown: !1,
  4295. isUp: !1,
  4296. isOver: !1,
  4297. isOut: !1,
  4298. timeOver: 0,
  4299. timeOut: 0,
  4300. timeDown: 0,
  4301. timeUp: 0,
  4302. downDuration: 0,
  4303. isDragged: !1
  4304. })
  4305. }, b.InputHandler.prototype = {
  4306. start: function(a, c) {
  4307. if (a = a || 0, "undefined" == typeof c && (c = !1), this.enabled === !1) {
  4308. this.game.input.interactiveItems.add(this), this.useHandCursor = c, this.priorityID = a;
  4309. for (var d = 0; 10 > d; d++) this._pointerData[d] = {
  4310. id: d,
  4311. x: 0,
  4312. y: 0,
  4313. isDown: !1,
  4314. isUp: !1,
  4315. isOver: !1,
  4316. isOut: !1,
  4317. timeOver: 0,
  4318. timeOut: 0,
  4319. timeDown: 0,
  4320. timeUp: 0,
  4321. downDuration: 0,
  4322. isDragged: !1
  4323. };
  4324. 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)
  4325. }
  4326. return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.flagged = !1, this.sprite
  4327. },
  4328. addedToGroup: function() {
  4329. this._dragPhase || this._wasEnabled && !this.enabled && this.start()
  4330. },
  4331. removedFromGroup: function() {
  4332. this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1)
  4333. },
  4334. reset: function() {
  4335. this.enabled = !1, this.flagged = !1;
  4336. for (var a = 0; 10 > a; a++) this._pointerData[a] = {
  4337. id: a,
  4338. x: 0,
  4339. y: 0,
  4340. isDown: !1,
  4341. isUp: !1,
  4342. isOver: !1,
  4343. isOut: !1,
  4344. timeOver: 0,
  4345. timeOut: 0,
  4346. timeDown: 0,
  4347. timeUp: 0,
  4348. downDuration: 0,
  4349. isDragged: !1
  4350. }
  4351. },
  4352. stop: function() {
  4353. this.enabled !== !1 && (this.enabled = !1, this.game.input.interactiveItems.remove(this))
  4354. },
  4355. destroy: function() {
  4356. 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)
  4357. },
  4358. validForInput: function(a, b, c) {
  4359. 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
  4360. },
  4361. isPixelPerfect: function() {
  4362. return this.pixelPerfectClick || this.pixelPerfectOver
  4363. },
  4364. pointerX: function(a) {
  4365. return a = a || 0, this._pointerData[a].x
  4366. },
  4367. pointerY: function(a) {
  4368. return a = a || 0, this._pointerData[a].y
  4369. },
  4370. pointerDown: function(a) {
  4371. return a = a || 0, this._pointerData[a].isDown
  4372. },
  4373. pointerUp: function(a) {
  4374. return a = a || 0, this._pointerData[a].isUp
  4375. },
  4376. pointerTimeDown: function(a) {
  4377. return a = a || 0, this._pointerData[a].timeDown
  4378. },
  4379. pointerTimeUp: function(a) {
  4380. return a = a || 0, this._pointerData[a].timeUp
  4381. },
  4382. pointerOver: function(a) {
  4383. if (this.enabled) {
  4384. if ("undefined" != typeof a) return this._pointerData[a].isOver;
  4385. for (var b = 0; 10 > b; b++)
  4386. if (this._pointerData[b].isOver) return !0
  4387. }
  4388. return !1
  4389. },
  4390. pointerOut: function(a) {
  4391. if (this.enabled) {
  4392. if ("undefined" != typeof a) return this._pointerData[a].isOut;
  4393. for (var b = 0; 10 > b; b++)
  4394. if (this._pointerData[b].isOut) return !0
  4395. }
  4396. return !1
  4397. },
  4398. pointerTimeOver: function(a) {
  4399. return a = a || 0, this._pointerData[a].timeOver
  4400. },
  4401. pointerTimeOut: function(a) {
  4402. return a = a || 0, this._pointerData[a].timeOut
  4403. },
  4404. pointerDragged: function(a) {
  4405. return a = a || 0, this._pointerData[a].isDragged
  4406. },
  4407. checkPointerDown: function(a, b) {
  4408. 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
  4409. },
  4410. checkPointerOver: function(a, b) {
  4411. 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
  4412. },
  4413. checkPixel: function(a, b, c) {
  4414. if (this.sprite.texture.baseTexture.source) {
  4415. if (this.game.input.hitContext.clearRect(0, 0, 1, 1), null === a && null === b) {
  4416. this.game.input.getLocalPosition(this.sprite, c, this._tempPoint);
  4417. var a = this._tempPoint.x,
  4418. b = this._tempPoint.y
  4419. }
  4420. 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);
  4421. var d = this.game.input.hitContext.getImageData(0, 0, 1, 1);
  4422. if (d.data[3] >= this.pixelPerfectAlpha) return !0
  4423. }
  4424. return !1
  4425. },
  4426. update: function(a) {
  4427. 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
  4428. },
  4429. _pointerOverHandler: function(a) {
  4430. 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))
  4431. },
  4432. _pointerOutHandler: function(a) {
  4433. 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))
  4434. },
  4435. _touchedHandler: function(a) {
  4436. if (null !== this.sprite) {
  4437. if (this._pointerData[a.id].isDown === !1 && this._pointerData[a.id].isOver === !0) {
  4438. if (this.pixelPerfectClick && !this.checkPixel(null, null, a)) return;
  4439. 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()
  4440. }
  4441. return this.consumePointerEvent
  4442. }
  4443. },
  4444. _releasedHandler: function(a) {
  4445. 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))
  4446. },
  4447. updateDrag: function(a) {
  4448. 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)
  4449. },
  4450. justOver: function(a, b) {
  4451. return a = a || 0, b = b || 500, this._pointerData[a].isOver && this.overDuration(a) < b
  4452. },
  4453. justOut: function(a, b) {
  4454. return a = a || 0, b = b || 500, this._pointerData[a].isOut && this.game.time.now - this._pointerData[a].timeOut < b
  4455. },
  4456. justPressed: function(a, b) {
  4457. return a = a || 0, b = b || 500, this._pointerData[a].isDown && this.downDuration(a) < b
  4458. },
  4459. justReleased: function(a, b) {
  4460. return a = a || 0, b = b || 500, this._pointerData[a].isUp && this.game.time.now - this._pointerData[a].timeUp < b
  4461. },
  4462. overDuration: function(a) {
  4463. return a = a || 0, this._pointerData[a].isOver ? this.game.time.now - this._pointerData[a].timeOver : -1
  4464. },
  4465. downDuration: function(a) {
  4466. return a = a || 0, this._pointerData[a].isDown ? this.game.time.now - this._pointerData[a].timeDown : -1
  4467. },
  4468. enableDrag: function(a, c, d, e, f, g) {
  4469. "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)
  4470. },
  4471. disableDrag: function() {
  4472. if (this._pointerData)
  4473. for (var a = 0; 10 > a; a++) this._pointerData[a].isDragged = !1;
  4474. this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1
  4475. },
  4476. startDrag: function(a) {
  4477. 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);
  4478. else if (this.dragFromCenter) {
  4479. var b = this.sprite.getBounds();
  4480. 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)
  4481. } else this._dragPoint.setTo(this.sprite.x - a.x, this.sprite.y - a.y);
  4482. this.updateDrag(a), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.sprite.events.onDragStart.dispatch(this.sprite, a)
  4483. },
  4484. stopDrag: function(a) {
  4485. 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)
  4486. },
  4487. setDragLock: function(a, b) {
  4488. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), this.allowHorizontalDrag = a, this.allowVerticalDrag = b
  4489. },
  4490. enableSnap: function(a, b, c, d, e, f) {
  4491. "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
  4492. },
  4493. disableSnap: function() {
  4494. this.snapOnDrag = !1, this.snapOnRelease = !1
  4495. },
  4496. checkBoundsRect: function() {
  4497. 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))
  4498. },
  4499. checkBoundsSprite: function() {
  4500. 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))
  4501. }
  4502. }, b.InputHandler.prototype.constructor = b.InputHandler, b.Events = function(a) {
  4503. 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
  4504. }, b.Events.prototype = {
  4505. destroy: function() {
  4506. 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())
  4507. }
  4508. }, b.Events.prototype.constructor = b.Events, b.GameObjectFactory = function(a) {
  4509. this.game = a, this.world = this.game.world
  4510. }, b.GameObjectFactory.prototype = {
  4511. existing: function(a) {
  4512. return this.world.add(a)
  4513. },
  4514. image: function(a, c, d, e, f) {
  4515. return "undefined" == typeof f && (f = this.world), f.add(new b.Image(this.game, a, c, d, e))
  4516. },
  4517. sprite: function(a, b, c, d, e) {
  4518. return "undefined" == typeof e && (e = this.world), e.create(a, b, c, d)
  4519. },
  4520. tween: function(a) {
  4521. return this.game.tweens.create(a)
  4522. },
  4523. group: function(a, c, d, e, f) {
  4524. return new b.Group(this.game, a, c, d, e, f)
  4525. },
  4526. physicsGroup: function(a, c, d, e) {
  4527. return new b.Group(this.game, c, d, e, !0, a)
  4528. },
  4529. spriteBatch: function(a, c, d) {
  4530. return "undefined" == typeof a && (a = null), "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  4531. },
  4532. audio: function(a, b, c, d) {
  4533. return this.game.sound.add(a, b, c, d)
  4534. },
  4535. sound: function(a, b, c, d) {
  4536. return this.game.sound.add(a, b, c, d)
  4537. },
  4538. tileSprite: function(a, c, d, e, f, g, h) {
  4539. return "undefined" == typeof h && (h = this.world), h.add(new b.TileSprite(this.game, a, c, d, e, f, g))
  4540. },
  4541. text: function(a, c, d, e, f) {
  4542. return "undefined" == typeof f && (f = this.world), f.add(new b.Text(this.game, a, c, d, e))
  4543. },
  4544. button: function(a, c, d, e, f, g, h, i, j, k) {
  4545. return "undefined" == typeof k && (k = this.world), k.add(new b.Button(this.game, a, c, d, e, f, g, h, i, j))
  4546. },
  4547. graphics: function(a, c, d) {
  4548. return "undefined" == typeof d && (d = this.world), d.add(new b.Graphics(this.game, a, c))
  4549. },
  4550. emitter: function(a, c, d) {
  4551. return this.game.particles.add(new b.Particles.Arcade.Emitter(this.game, a, c, d))
  4552. },
  4553. retroFont: function(a, c, d, e, f, g, h, i, j) {
  4554. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  4555. },
  4556. bitmapText: function(a, c, d, e, f, g) {
  4557. return "undefined" == typeof g && (g = this.world), g.add(new b.BitmapText(this.game, a, c, d, e, f))
  4558. },
  4559. tilemap: function(a, c, d, e, f) {
  4560. return new b.Tilemap(this.game, a, c, d, e, f)
  4561. },
  4562. renderTexture: function(a, c, d, e) {
  4563. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  4564. var f = new b.RenderTexture(this.game, a, c, d);
  4565. return e && this.game.cache.addRenderTexture(d, f), f
  4566. },
  4567. bitmapData: function(a, c, d, e) {
  4568. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  4569. var f = new b.BitmapData(this.game, d, a, c);
  4570. return e && this.game.cache.addBitmapData(d, f), f
  4571. },
  4572. filter: function(a) {
  4573. var c = Array.prototype.splice.call(arguments, 1),
  4574. a = new b.Filter[a](this.game);
  4575. return a.init.apply(a, c), a
  4576. },
  4577. plugin: function(a) {
  4578. return this.game.plugins.add(a)
  4579. }
  4580. }, b.GameObjectFactory.prototype.constructor = b.GameObjectFactory, b.GameObjectCreator = function(a) {
  4581. this.game = a, this.world = this.game.world
  4582. }, b.GameObjectCreator.prototype = {
  4583. image: function(a, c, d, e) {
  4584. return new b.Image(this.game, a, c, d, e)
  4585. },
  4586. sprite: function(a, c, d, e) {
  4587. return new b.Sprite(this.game, a, c, d, e)
  4588. },
  4589. tween: function(a) {
  4590. return new b.Tween(a, this.game)
  4591. },
  4592. group: function(a, c, d, e, f) {
  4593. return new b.Group(this.game, null, c, d, e, f)
  4594. },
  4595. spriteBatch: function(a, c, d) {
  4596. return "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  4597. },
  4598. audio: function(a, b, c, d) {
  4599. return this.game.sound.add(a, b, c, d)
  4600. },
  4601. sound: function(a, b, c, d) {
  4602. return this.game.sound.add(a, b, c, d)
  4603. },
  4604. tileSprite: function(a, c, d, e, f, g) {
  4605. return new b.TileSprite(this.game, a, c, d, e, f, g)
  4606. },
  4607. text: function(a, c, d, e) {
  4608. return new b.Text(this.game, a, c, d, e)
  4609. },
  4610. button: function(a, c, d, e, f, g, h, i, j) {
  4611. return new b.Button(this.game, a, c, d, e, f, g, h, i, j)
  4612. },
  4613. graphics: function(a, c) {
  4614. return new b.Graphics(this.game, a, c)
  4615. },
  4616. emitter: function(a, c, d) {
  4617. return new b.Particles.Arcade.Emitter(this.game, a, c, d)
  4618. },
  4619. retroFont: function(a, c, d, e, f, g, h, i, j) {
  4620. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  4621. },
  4622. bitmapText: function(a, c, d, e, f) {
  4623. return new b.BitmapText(this.game, a, c, d, e, f)
  4624. },
  4625. tilemap: function(a, c, d, e, f) {
  4626. return new b.Tilemap(this.game, a, c, d, e, f)
  4627. },
  4628. renderTexture: function(a, c, d, e) {
  4629. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  4630. var f = new b.RenderTexture(this.game, a, c, d);
  4631. return e && this.game.cache.addRenderTexture(d, f), f
  4632. },
  4633. bitmapData: function(a, c, d, e) {
  4634. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  4635. var f = new b.BitmapData(this.game, d, a, c);
  4636. return e && this.game.cache.addBitmapData(d, f), f
  4637. },
  4638. filter: function(a) {
  4639. var c = Array.prototype.splice.call(arguments, 1),
  4640. a = new b.Filter[a](this.game);
  4641. return a.init.apply(a, c), a
  4642. }
  4643. }, b.GameObjectCreator.prototype.constructor = b.GameObjectCreator, b.BitmapData = function(a, c, d, e) {
  4644. "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
  4645. }, b.BitmapData.prototype = {
  4646. add: function(a) {
  4647. if (Array.isArray(a))
  4648. for (var b = 0; b < a.length; b++) a[b].loadTexture && a[b].loadTexture(this);
  4649. else a.loadTexture(this)
  4650. },
  4651. load: function(a) {
  4652. "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()
  4653. },
  4654. clear: function() {
  4655. this.context.clearRect(0, 0, this.width, this.height), this.dirty = !0
  4656. },
  4657. fill: function(a, b, c, d) {
  4658. "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
  4659. },
  4660. resize: function(a, b) {
  4661. (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)
  4662. },
  4663. refreshBuffer: function(a, b, c, d) {
  4664. "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
  4665. },
  4666. processPixelRGB: function(a, c, d, e, f, g) {
  4667. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = this.width), "undefined" == typeof g && (g = this.height);
  4668. for (var h = d + f, i = e + g, j = b.Color.createColor(), k = {
  4669. r: 0,
  4670. g: 0,
  4671. b: 0,
  4672. a: 0
  4673. }, l = !1, m = e; i > m; m++)
  4674. for (var 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);
  4675. l && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)
  4676. },
  4677. processPixel: function(a, b, c, d, e, f) {
  4678. "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = this.width), "undefined" == typeof f && (f = this.height);
  4679. for (var g = c + e, h = d + f, i = 0, j = 0, k = !1, l = d; h > l; l++)
  4680. for (var 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);
  4681. k && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)
  4682. },
  4683. replaceRGB: function(a, c, d, e, f, g, h, i, j) {
  4684. var k = 0,
  4685. l = 0,
  4686. m = this.width,
  4687. n = this.height,
  4688. o = b.Color.packPixel(a, c, d, e);
  4689. void 0 !== j && j instanceof b.Rectangle && (k = j.x, l = j.y, m = j.width, n = j.height);
  4690. for (var p = 0; n > p; p++)
  4691. for (var q = 0; m > q; q++) this.getPixel32(k + q, l + p) === o && this.setPixel32(k + q, l + p, f, g, h, i, !1);
  4692. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  4693. },
  4694. setHSL: function(a, c, d, e) {
  4695. 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) {
  4696. "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
  4697. for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  4698. for (var 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);
  4699. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  4700. }
  4701. },
  4702. shiftHSL: function(a, c, d, e) {
  4703. 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) {
  4704. "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
  4705. for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  4706. for (var 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);
  4707. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  4708. }
  4709. },
  4710. setPixel32: function(a, c, d, e, f, g, h) {
  4711. "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))
  4712. },
  4713. setPixel: function(a, b, c, d, e, f) {
  4714. this.setPixel32(a, b, c, d, e, 255, f)
  4715. },
  4716. getPixel: function(a, c, d) {
  4717. d || (d = b.Color.createColor());
  4718. var e = ~~(a + c * this.width);
  4719. return e *= 4, d.r = this.data[e], d.g = this.data[++e], d.b = this.data[++e], d.a = this.data[++e], d
  4720. },
  4721. getPixel32: function(a, b) {
  4722. return a >= 0 && a <= this.width && b >= 0 && b <= this.height ? this.pixels[b * this.width + a] : void 0
  4723. },
  4724. getPixelRGB: function(a, c, d, e, f) {
  4725. return b.Color.unpackPixel(this.getPixel32(a, c), d, e, f)
  4726. },
  4727. getPixels: function(a) {
  4728. return this.context.getImageData(a.x, a.y, a.width, a.height)
  4729. },
  4730. addToWorld: function(a, b) {
  4731. return this.game.add.image(a, b, this)
  4732. },
  4733. copyPixels: function(a, c, d, e) {
  4734. "string" == typeof a && (a = this.game.cache.getImage(a));
  4735. var f = a,
  4736. g = 0,
  4737. h = 0;
  4738. if (a instanceof b.Image || a instanceof b.Sprite) {
  4739. f = a.texture.baseTexture.source;
  4740. var i = a.texture.frame;
  4741. g = i.x, h = i.y
  4742. } else a instanceof b.BitmapData && (f = a.canvas);
  4743. this.context.drawImage(f, g + c.x, h + c.y, c.width, c.height, d, e, c.width, c.height), this.dirty = !0
  4744. },
  4745. draw: function(a, c, d, e, f) {
  4746. "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "string" == typeof a && (a = this.game.cache.getImage(a));
  4747. var g = a,
  4748. h = 0,
  4749. i = 0,
  4750. j = 0,
  4751. k = 0;
  4752. if (a instanceof b.Image || a instanceof b.Sprite) {
  4753. g = a.texture.baseTexture.source;
  4754. var l = a.texture.frame;
  4755. h = l.x, i = l.y, j = l.width, k = l.height
  4756. } else a instanceof b.BitmapData && (g = a.canvas), j = a.width, k = a.height;
  4757. "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
  4758. },
  4759. drawSprite: function(a, b, c) {
  4760. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), this.draw(a, b, c)
  4761. },
  4762. alphaMask: function(a, b, c, d) {
  4763. ("undefined" == typeof b || null === b) && (b = this);
  4764. var e = this.context.globalCompositeOperation;
  4765. "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
  4766. },
  4767. extract: function(a, b, c, d, e, f, g, h, i) {
  4768. 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) {
  4769. return f.r === b && f.g === c && f.b === d && a.setPixel32(j, k, g, h, i, e, !1), !1
  4770. }, this), a.context.putImageData(a.imageData, 0, 0), a.dirty = !0, a
  4771. },
  4772. rect: function(a, b, c, d, e) {
  4773. "undefined" != typeof e && (this.context.fillStyle = e), this.context.fillRect(a, b, c, d)
  4774. },
  4775. circle: function(a, b, c, d) {
  4776. "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()
  4777. },
  4778. render: function() {
  4779. !this.disableTextureUpload && this.game.renderType === b.WEBGL && this.dirty && (PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl), this.dirty = !1)
  4780. }
  4781. }, b.BitmapData.prototype.constructor = b.BitmapData, b.Sprite = function(a, c, d, e, f) {
  4782. 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)
  4783. }, b.Sprite.prototype = Object.create(PIXI.Sprite.prototype), b.Sprite.prototype.constructor = b.Sprite, b.Sprite.prototype.preUpdate = function() {
  4784. 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;
  4785. 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;
  4786. if (this.lifespan > 0 && (this.lifespan -= this.game.time.elapsed, this.lifespan <= 0)) return this.kill(), !1;
  4787. if ((this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds)
  4788. if (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds)) this._cache[5] = 0, this.events.onEnterBounds.dispatch(this);
  4789. 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;
  4790. 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();
  4791. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4792. return !0
  4793. }, b.Sprite.prototype.update = function() {}, b.Sprite.prototype.postUpdate = function() {
  4794. 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);
  4795. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  4796. }, b.Sprite.prototype.loadTexture = function(a, c, d) {
  4797. c = c || 0, (d || "undefined" == typeof d) && this.animations.stop(), this.key = a;
  4798. var e = !0,
  4799. f = this.smoothed;
  4800. 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)
  4801. }, b.Sprite.prototype.setFrame = function(a) {
  4802. 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 = {
  4803. x: a.spriteSourceSizeX,
  4804. y: a.spriteSourceSizeY,
  4805. width: a.sourceSizeW,
  4806. height: a.sourceSizeH
  4807. }, 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)
  4808. }, b.Sprite.prototype.resetFrame = function() {
  4809. this._frame && this.setFrame(this._frame)
  4810. }, b.Sprite.prototype.crop = function(a, c) {
  4811. "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())
  4812. }, b.Sprite.prototype.updateCrop = function() {
  4813. if (this.cropRect) {
  4814. this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
  4815. var a = Math.max(this._frame.x, this._crop.x),
  4816. c = Math.max(this._frame.y, this._crop.y),
  4817. d = Math.min(this._frame.right, this._crop.right) - a,
  4818. e = Math.min(this._frame.bottom, this._crop.bottom) - c;
  4819. 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)
  4820. }
  4821. }, b.Sprite.prototype.revive = function(a) {
  4822. 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
  4823. }, b.Sprite.prototype.kill = function() {
  4824. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  4825. }, b.Sprite.prototype.destroy = function(a) {
  4826. if (null !== this.game && 1 !== this._cache[8]) {
  4827. "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();
  4828. var c = this.children.length;
  4829. if (a)
  4830. for (; c--;) this.children[c].destroy(a);
  4831. else
  4832. for (; c--;) this.removeChild(this.children[c]);
  4833. 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
  4834. }
  4835. }, b.Sprite.prototype.damage = function(a) {
  4836. return this.alive && (this.health -= a, this.health <= 0 && this.kill()), this
  4837. }, b.Sprite.prototype.reset = function(a, b, c) {
  4838. 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
  4839. }, b.Sprite.prototype.bringToTop = function() {
  4840. return this.parent && this.parent.bringToTop(this), this
  4841. }, b.Sprite.prototype.play = function(a, b, c, d) {
  4842. return this.animations ? this.animations.play(a, b, c, d) : void 0
  4843. }, b.Sprite.prototype.overlap = function(a) {
  4844. return b.Rectangle.intersects(this.getBounds(), a.getBounds())
  4845. }, Object.defineProperty(b.Sprite.prototype, "angle", {
  4846. get: function() {
  4847. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  4848. },
  4849. set: function(a) {
  4850. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  4851. }
  4852. }), Object.defineProperty(b.Sprite.prototype, "deltaX", {
  4853. get: function() {
  4854. return this.world.x - this._cache[0]
  4855. }
  4856. }), Object.defineProperty(b.Sprite.prototype, "deltaY", {
  4857. get: function() {
  4858. return this.world.y - this._cache[1]
  4859. }
  4860. }), Object.defineProperty(b.Sprite.prototype, "deltaZ", {
  4861. get: function() {
  4862. return this.rotation - this._cache[2]
  4863. }
  4864. }), Object.defineProperty(b.Sprite.prototype, "inWorld", {
  4865. get: function() {
  4866. return this.game.world.bounds.intersects(this.getBounds())
  4867. }
  4868. }), Object.defineProperty(b.Sprite.prototype, "inCamera", {
  4869. get: function() {
  4870. return this.game.world.camera.screenView.intersects(this.getBounds())
  4871. }
  4872. }), Object.defineProperty(b.Sprite.prototype, "frame", {
  4873. get: function() {
  4874. return this.animations.frame
  4875. },
  4876. set: function(a) {
  4877. this.animations.frame = a
  4878. }
  4879. }), Object.defineProperty(b.Sprite.prototype, "frameName", {
  4880. get: function() {
  4881. return this.animations.frameName
  4882. },
  4883. set: function(a) {
  4884. this.animations.frameName = a
  4885. }
  4886. }), Object.defineProperty(b.Sprite.prototype, "renderOrderID", {
  4887. get: function() {
  4888. return this._cache[3]
  4889. }
  4890. }), Object.defineProperty(b.Sprite.prototype, "inputEnabled", {
  4891. get: function() {
  4892. return this.input && this.input.enabled
  4893. },
  4894. set: function(a) {
  4895. 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()
  4896. }
  4897. }), Object.defineProperty(b.Sprite.prototype, "exists", {
  4898. get: function() {
  4899. return !!this._cache[6]
  4900. },
  4901. set: function(a) {
  4902. 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)
  4903. }
  4904. }), Object.defineProperty(b.Sprite.prototype, "fixedToCamera", {
  4905. get: function() {
  4906. return !!this._cache[7]
  4907. },
  4908. set: function(a) {
  4909. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4910. }
  4911. }), Object.defineProperty(b.Sprite.prototype, "smoothed", {
  4912. get: function() {
  4913. return !this.texture.baseTexture.scaleMode
  4914. },
  4915. set: function(a) {
  4916. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  4917. }
  4918. }), Object.defineProperty(b.Sprite.prototype, "x", {
  4919. get: function() {
  4920. return this.position.x
  4921. },
  4922. set: function(a) {
  4923. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4924. }
  4925. }), Object.defineProperty(b.Sprite.prototype, "y", {
  4926. get: function() {
  4927. return this.position.y
  4928. },
  4929. set: function(a) {
  4930. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4931. }
  4932. }), Object.defineProperty(b.Sprite.prototype, "destroyPhase", {
  4933. get: function() {
  4934. return !!this._cache[8]
  4935. }
  4936. }), b.Image = function(a, c, d, e, f) {
  4937. 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]
  4938. }, b.Image.prototype = Object.create(PIXI.Sprite.prototype), b.Image.prototype.constructor = b.Image, b.Image.prototype.preUpdate = function() {
  4939. 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;
  4940. 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++);
  4941. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4942. return !0
  4943. }, b.Image.prototype.update = function() {}, b.Image.prototype.postUpdate = function() {
  4944. 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);
  4945. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  4946. }, b.Image.prototype.loadTexture = function(a, c) {
  4947. if (c = c || 0, a instanceof b.RenderTexture) return this.key = a.key, void this.setTexture(a);
  4948. if (a instanceof b.BitmapData) return this.key = a, void this.setTexture(a.texture);
  4949. if (a instanceof PIXI.Texture) return this.key = a, void this.setTexture(a);
  4950. if (null === a || "undefined" == typeof a) return this.key = "__default", void this.setTexture(PIXI.TextureCache[this.key]);
  4951. if ("string" == typeof a && !this.game.cache.checkImageKey(a)) return this.key = "__missing", void this.setTexture(PIXI.TextureCache[this.key]);
  4952. if (this.game.cache.isSpriteSheet(a)) {
  4953. this.key = a;
  4954. var d = this.game.cache.getFrameData(a);
  4955. return "string" == typeof c ? (this._frame = 0, this._frameName = c, void this.setTexture(PIXI.TextureCache[d.getFrameByName(c).uuid])) : (this._frame = c, this._frameName = "", void this.setTexture(PIXI.TextureCache[d.getFrame(c).uuid]))
  4956. }
  4957. return this.key = a, void this.setTexture(PIXI.TextureCache[a])
  4958. }, b.Image.prototype.crop = function(a) {
  4959. if ("undefined" == typeof a || null === a) this.texture.hasOwnProperty("sourceWidth") && this.texture.setFrame(new b.Rectangle(0, 0, this.texture.sourceWidth, this.texture.sourceHeight));
  4960. else if (this.texture instanceof PIXI.Texture) {
  4961. var c = {};
  4962. 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)
  4963. } else this.texture.setFrame(a)
  4964. }, b.Image.prototype.revive = function() {
  4965. return this.alive = !0, this.exists = !0, this.visible = !0, this.events && this.events.onRevived.dispatch(this), this
  4966. }, b.Image.prototype.kill = function() {
  4967. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  4968. }, b.Image.prototype.destroy = function(a) {
  4969. if (null !== this.game && !this.destroyPhase) {
  4970. "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();
  4971. var c = this.children.length;
  4972. if (a)
  4973. for (; c--;) this.children[c].destroy(a);
  4974. else
  4975. for (; c--;) this.removeChild(this.children[c]);
  4976. this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4977. }
  4978. }, b.Image.prototype.reset = function(a, b) {
  4979. 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
  4980. }, b.Image.prototype.bringToTop = function() {
  4981. return this.parent && this.parent.bringToTop(this), this
  4982. }, Object.defineProperty(b.Image.prototype, "angle", {
  4983. get: function() {
  4984. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  4985. },
  4986. set: function(a) {
  4987. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  4988. }
  4989. }), Object.defineProperty(b.Image.prototype, "deltaX", {
  4990. get: function() {
  4991. return this.world.x - this._cache[0]
  4992. }
  4993. }), Object.defineProperty(b.Image.prototype, "deltaY", {
  4994. get: function() {
  4995. return this.world.y - this._cache[1]
  4996. }
  4997. }), Object.defineProperty(b.Image.prototype, "deltaZ", {
  4998. get: function() {
  4999. return this.rotation - this._cache[2]
  5000. }
  5001. }), Object.defineProperty(b.Image.prototype, "inWorld", {
  5002. get: function() {
  5003. return this.game.world.bounds.intersects(this.getBounds())
  5004. }
  5005. }), Object.defineProperty(b.Image.prototype, "inCamera", {
  5006. get: function() {
  5007. return this.game.world.camera.screenView.intersects(this.getBounds())
  5008. }
  5009. }), Object.defineProperty(b.Image.prototype, "frame", {
  5010. get: function() {
  5011. return this._frame
  5012. },
  5013. set: function(a) {
  5014. if (a !== this.frame && this.game.cache.isSpriteSheet(this.key)) {
  5015. var b = this.game.cache.getFrameData(this.key);
  5016. b && a < b.total && b.getFrame(a) && (this.setTexture(PIXI.TextureCache[b.getFrame(a).uuid]), this._frame = a)
  5017. }
  5018. }
  5019. }), Object.defineProperty(b.Image.prototype, "frameName", {
  5020. get: function() {
  5021. return this._frameName
  5022. },
  5023. set: function(a) {
  5024. if (a !== this.frameName && this.game.cache.isSpriteSheet(this.key)) {
  5025. var b = this.game.cache.getFrameData(this.key);
  5026. b && b.getFrameByName(a) && (this.setTexture(PIXI.TextureCache[b.getFrameByName(a).uuid]), this._frameName = a)
  5027. }
  5028. }
  5029. }), Object.defineProperty(b.Image.prototype, "renderOrderID", {
  5030. get: function() {
  5031. return this._cache[3]
  5032. }
  5033. }), Object.defineProperty(b.Image.prototype, "inputEnabled", {
  5034. get: function() {
  5035. return this.input && this.input.enabled
  5036. },
  5037. set: function(a) {
  5038. 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()
  5039. }
  5040. }), Object.defineProperty(b.Image.prototype, "fixedToCamera", {
  5041. get: function() {
  5042. return !!this._cache[7]
  5043. },
  5044. set: function(a) {
  5045. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5046. }
  5047. }), Object.defineProperty(b.Image.prototype, "smoothed", {
  5048. get: function() {
  5049. return !this.texture.baseTexture.scaleMode
  5050. },
  5051. set: function(a) {
  5052. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  5053. }
  5054. }), Object.defineProperty(b.Image.prototype, "destroyPhase", {
  5055. get: function() {
  5056. return !!this._cache[8]
  5057. }
  5058. }), b.TileSprite = function(a, c, d, e, f, g, h) {
  5059. 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)
  5060. }, b.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), b.TileSprite.prototype.constructor = b.TileSprite, b.TileSprite.prototype.preUpdate = function() {
  5061. 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;
  5062. 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;
  5063. (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();
  5064. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5065. return !0
  5066. }, b.TileSprite.prototype.update = function() {}, b.TileSprite.prototype.postUpdate = function() {
  5067. 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);
  5068. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  5069. }, b.TileSprite.prototype.autoScroll = function(a, b) {
  5070. this._scroll.set(a, b)
  5071. }, b.TileSprite.prototype.stopScroll = function() {
  5072. this._scroll.set(0, 0)
  5073. }, b.TileSprite.prototype.loadTexture = function(a, c) {
  5074. 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]))
  5075. }, b.TileSprite.prototype.setFrame = function(a) {
  5076. 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 = {
  5077. x: a.spriteSourceSizeX,
  5078. y: a.spriteSourceSizeY,
  5079. width: a.sourceSizeW,
  5080. height: a.sourceSizeH
  5081. }, 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)
  5082. }, b.TileSprite.prototype.destroy = function(a) {
  5083. if (null !== this.game && !this.destroyPhase) {
  5084. "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();
  5085. var c = this.children.length;
  5086. if (a)
  5087. for (; c--;) this.children[c].destroy(a);
  5088. else
  5089. for (; c--;) this.removeChild(this.children[c]);
  5090. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5091. }
  5092. }, b.TileSprite.prototype.play = function(a, b, c, d) {
  5093. return this.animations.play(a, b, c, d)
  5094. }, b.TileSprite.prototype.reset = function(a, b) {
  5095. 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
  5096. }, Object.defineProperty(b.TileSprite.prototype, "angle", {
  5097. get: function() {
  5098. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  5099. },
  5100. set: function(a) {
  5101. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  5102. }
  5103. }), Object.defineProperty(b.TileSprite.prototype, "frame", {
  5104. get: function() {
  5105. return this.animations.frame
  5106. },
  5107. set: function(a) {
  5108. a !== this.animations.frame && (this.animations.frame = a)
  5109. }
  5110. }), Object.defineProperty(b.TileSprite.prototype, "frameName", {
  5111. get: function() {
  5112. return this.animations.frameName
  5113. },
  5114. set: function(a) {
  5115. a !== this.animations.frameName && (this.animations.frameName = a)
  5116. }
  5117. }), Object.defineProperty(b.TileSprite.prototype, "fixedToCamera", {
  5118. get: function() {
  5119. return !!this._cache[7]
  5120. },
  5121. set: function(a) {
  5122. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5123. }
  5124. }), Object.defineProperty(b.TileSprite.prototype, "exists", {
  5125. get: function() {
  5126. return !!this._cache[6]
  5127. },
  5128. set: function(a) {
  5129. 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)
  5130. }
  5131. }), Object.defineProperty(b.TileSprite.prototype, "inputEnabled", {
  5132. get: function() {
  5133. return this.input && this.input.enabled
  5134. },
  5135. set: function(a) {
  5136. 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()
  5137. }
  5138. }), Object.defineProperty(b.TileSprite.prototype, "x", {
  5139. get: function() {
  5140. return this.position.x
  5141. },
  5142. set: function(a) {
  5143. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5144. }
  5145. }), Object.defineProperty(b.TileSprite.prototype, "y", {
  5146. get: function() {
  5147. return this.position.y
  5148. },
  5149. set: function(a) {
  5150. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5151. }
  5152. }), Object.defineProperty(b.TileSprite.prototype, "destroyPhase", {
  5153. get: function() {
  5154. return !!this._cache[8]
  5155. }
  5156. }), b.Text = function(a, c, d, e, f) {
  5157. 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]
  5158. }, b.Text.prototype = Object.create(PIXI.Text.prototype), b.Text.prototype.constructor = b.Text, b.Text.prototype.preUpdate = function() {
  5159. 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;
  5160. 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++);
  5161. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5162. return !0
  5163. }, b.Text.prototype.update = function() {}, b.Text.prototype.postUpdate = function() {
  5164. 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);
  5165. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  5166. }, b.Text.prototype.destroy = function(a) {
  5167. if (null !== this.game && !this.destroyPhase) {
  5168. "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);
  5169. var c = this.children.length;
  5170. if (a)
  5171. for (; c--;) this.children[c].destroy(a);
  5172. else
  5173. for (; c--;) this.removeChild(this.children[c]);
  5174. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5175. }
  5176. }, b.Text.prototype.setShadow = function(a, b, c, d) {
  5177. 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
  5178. }, b.Text.prototype.setStyle = function(a) {
  5179. 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
  5180. }, b.Text.prototype.updateText = function() {
  5181. this.context.font = this.style.font;
  5182. var a = this.text;
  5183. this.style.wordWrap && (a = this.runWordWrap(this.text));
  5184. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = 0; e < b.length; e++) {
  5185. var f = this.context.measureText(b[e]).width;
  5186. c[e] = f, d = Math.max(d, f)
  5187. }
  5188. this.canvas.width = d + this.style.strokeThickness;
  5189. var g = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness + this._lineSpacing + this.style.shadowOffsetY;
  5190. for (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++) {
  5191. var h = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + e * g);
  5192. "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)
  5193. }
  5194. this.updateTexture()
  5195. }, b.Text.prototype.runWordWrap = function(a) {
  5196. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  5197. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  5198. var h = this.context.measureText(f[g]).width,
  5199. i = h + this.context.measureText(" ").width;
  5200. i > e ? (g > 0 && (b += "\n"), b += f[g] + " ", e = this.style.wordWrapWidth - h) : (e -= i, b += f[g] + " ")
  5201. }
  5202. d < c.length - 1 && (b += "\n")
  5203. }
  5204. return b
  5205. }, Object.defineProperty(b.Text.prototype, "angle", {
  5206. get: function() {
  5207. return b.Math.radToDeg(this.rotation)
  5208. },
  5209. set: function(a) {
  5210. this.rotation = b.Math.degToRad(a)
  5211. }
  5212. }), Object.defineProperty(b.Text.prototype, "text", {
  5213. get: function() {
  5214. return this._text
  5215. },
  5216. set: function(a) {
  5217. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0, this.updateTransform())
  5218. }
  5219. }), Object.defineProperty(b.Text.prototype, "font", {
  5220. get: function() {
  5221. return this._font
  5222. },
  5223. set: function(a) {
  5224. a !== this._font && (this._font = a.trim(), this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.updateTransform())
  5225. }
  5226. }), Object.defineProperty(b.Text.prototype, "fontSize", {
  5227. get: function() {
  5228. return this._fontSize
  5229. },
  5230. set: function(a) {
  5231. 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())
  5232. }
  5233. }), Object.defineProperty(b.Text.prototype, "fontWeight", {
  5234. get: function() {
  5235. return this._fontWeight
  5236. },
  5237. set: function(a) {
  5238. a !== this._fontWeight && (this._fontWeight = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.updateTransform())
  5239. }
  5240. }), Object.defineProperty(b.Text.prototype, "fill", {
  5241. get: function() {
  5242. return this.style.fill
  5243. },
  5244. set: function(a) {
  5245. a !== this.style.fill && (this.style.fill = a, this.dirty = !0)
  5246. }
  5247. }), Object.defineProperty(b.Text.prototype, "align", {
  5248. get: function() {
  5249. return this.style.align
  5250. },
  5251. set: function(a) {
  5252. a !== this.style.align && (this.style.align = a, this.dirty = !0)
  5253. }
  5254. }), Object.defineProperty(b.Text.prototype, "stroke", {
  5255. get: function() {
  5256. return this.style.stroke
  5257. },
  5258. set: function(a) {
  5259. a !== this.style.stroke && (this.style.stroke = a, this.dirty = !0)
  5260. }
  5261. }), Object.defineProperty(b.Text.prototype, "strokeThickness", {
  5262. get: function() {
  5263. return this.style.strokeThickness
  5264. },
  5265. set: function(a) {
  5266. a !== this.style.strokeThickness && (this.style.strokeThickness = a, this.dirty = !0)
  5267. }
  5268. }), Object.defineProperty(b.Text.prototype, "wordWrap", {
  5269. get: function() {
  5270. return this.style.wordWrap
  5271. },
  5272. set: function(a) {
  5273. a !== this.style.wordWrap && (this.style.wordWrap = a, this.dirty = !0)
  5274. }
  5275. }), Object.defineProperty(b.Text.prototype, "wordWrapWidth", {
  5276. get: function() {
  5277. return this.style.wordWrapWidth
  5278. },
  5279. set: function(a) {
  5280. a !== this.style.wordWrapWidth && (this.style.wordWrapWidth = a, this.dirty = !0)
  5281. }
  5282. }), Object.defineProperty(b.Text.prototype, "lineSpacing", {
  5283. get: function() {
  5284. return this._lineSpacing
  5285. },
  5286. set: function(a) {
  5287. a !== this._lineSpacing && (this._lineSpacing = parseFloat(a), this.dirty = !0, this.updateTransform())
  5288. }
  5289. }), Object.defineProperty(b.Text.prototype, "shadowOffsetX", {
  5290. get: function() {
  5291. return this.style.shadowOffsetX
  5292. },
  5293. set: function(a) {
  5294. a !== this.style.shadowOffsetX && (this.style.shadowOffsetX = a, this.dirty = !0)
  5295. }
  5296. }), Object.defineProperty(b.Text.prototype, "shadowOffsetY", {
  5297. get: function() {
  5298. return this.style.shadowOffsetY
  5299. },
  5300. set: function(a) {
  5301. a !== this.style.shadowOffsetY && (this.style.shadowOffsetY = a, this.dirty = !0)
  5302. }
  5303. }), Object.defineProperty(b.Text.prototype, "shadowColor", {
  5304. get: function() {
  5305. return this.style.shadowColor
  5306. },
  5307. set: function(a) {
  5308. a !== this.style.shadowColor && (this.style.shadowColor = a, this.dirty = !0)
  5309. }
  5310. }), Object.defineProperty(b.Text.prototype, "shadowBlur", {
  5311. get: function() {
  5312. return this.style.shadowBlur
  5313. },
  5314. set: function(a) {
  5315. a !== this.style.shadowBlur && (this.style.shadowBlur = a, this.dirty = !0)
  5316. }
  5317. }), Object.defineProperty(b.Text.prototype, "inputEnabled", {
  5318. get: function() {
  5319. return this.input && this.input.enabled
  5320. },
  5321. set: function(a) {
  5322. 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()
  5323. }
  5324. }), Object.defineProperty(b.Text.prototype, "fixedToCamera", {
  5325. get: function() {
  5326. return !!this._cache[7]
  5327. },
  5328. set: function(a) {
  5329. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5330. }
  5331. }), Object.defineProperty(b.Text.prototype, "destroyPhase", {
  5332. get: function() {
  5333. return !!this._cache[8]
  5334. }
  5335. }), b.BitmapText = function(a, c, d, e, f, g) {
  5336. 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]
  5337. }, b.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setStyle = function() {
  5338. this.style = {
  5339. align: this._align
  5340. }, this.fontName = this._font, this.fontSize = this._fontSize, this.dirty = !0
  5341. }, b.BitmapText.prototype.preUpdate = function() {
  5342. 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)
  5343. }, b.BitmapText.prototype.update = function() {}, b.BitmapText.prototype.postUpdate = function() {
  5344. 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)
  5345. }, b.BitmapText.prototype.destroy = function(a) {
  5346. if (null !== this.game && !this.destroyPhase) {
  5347. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
  5348. var c = this.children.length;
  5349. if (a)
  5350. for (; c--;) this.children[c].destroy ? this.children[c].destroy(a) : this.removeChild(this.children[c]);
  5351. else
  5352. for (; c--;) this.removeChild(this.children[c]);
  5353. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5354. }
  5355. }, Object.defineProperty(b.BitmapText.prototype, "align", {
  5356. get: function() {
  5357. return this._align
  5358. },
  5359. set: function(a) {
  5360. a !== this._align && (this._align = a, this.setStyle())
  5361. }
  5362. }), Object.defineProperty(b.BitmapText.prototype, "tint", {
  5363. get: function() {
  5364. return this._tint
  5365. },
  5366. set: function(a) {
  5367. a !== this._tint && (this._tint = a, this.dirty = !0)
  5368. }
  5369. }), Object.defineProperty(b.BitmapText.prototype, "angle", {
  5370. get: function() {
  5371. return b.Math.radToDeg(this.rotation)
  5372. },
  5373. set: function(a) {
  5374. this.rotation = b.Math.degToRad(a)
  5375. }
  5376. }), Object.defineProperty(b.BitmapText.prototype, "font", {
  5377. get: function() {
  5378. return this._font
  5379. },
  5380. set: function(a) {
  5381. a !== this._font && (this._font = a.trim(), this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  5382. }
  5383. }), Object.defineProperty(b.BitmapText.prototype, "fontSize", {
  5384. get: function() {
  5385. return this._fontSize
  5386. },
  5387. set: function(a) {
  5388. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  5389. }
  5390. }), Object.defineProperty(b.BitmapText.prototype, "text", {
  5391. get: function() {
  5392. return this._text
  5393. },
  5394. set: function(a) {
  5395. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0)
  5396. }
  5397. }), Object.defineProperty(b.BitmapText.prototype, "inputEnabled", {
  5398. get: function() {
  5399. return this.input && this.input.enabled
  5400. },
  5401. set: function(a) {
  5402. 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()
  5403. }
  5404. }), Object.defineProperty(b.BitmapText.prototype, "fixedToCamera", {
  5405. get: function() {
  5406. return !!this._cache[7]
  5407. },
  5408. set: function(a) {
  5409. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5410. }
  5411. }), Object.defineProperty(b.BitmapText.prototype, "destroyPhase", {
  5412. get: function() {
  5413. return !!this._cache[8]
  5414. }
  5415. }), b.Button = function(a, c, d, e, f, g, h, i, j, k) {
  5416. 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)
  5417. }, b.Button.prototype = Object.create(b.Image.prototype), b.Button.prototype.constructor = b.Button, b.Button.prototype.clearFrames = function() {
  5418. this._onOverFrameName = null, this._onOverFrameID = null, this._onOutFrameName = null, this._onOutFrameID = null, this._onDownFrameName = null, this._onDownFrameID = null, this._onUpFrameName = null, this._onUpFrameID = null
  5419. }, b.Button.prototype.setFrames = function(a, b, c, d) {
  5420. 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)))
  5421. }, b.Button.prototype.setSounds = function(a, b, c, d, e, f, g, h) {
  5422. this.setOverSound(a, b), this.setOutSound(e, f), this.setDownSound(c, d), this.setUpSound(g, h)
  5423. }, b.Button.prototype.setOverSound = function(a, c) {
  5424. this.onOverSound = null, this.onOverSoundMarker = "", a instanceof b.Sound && (this.onOverSound = a), "string" == typeof c && (this.onOverSoundMarker = c)
  5425. }, b.Button.prototype.setOutSound = function(a, c) {
  5426. this.onOutSound = null, this.onOutSoundMarker = "", a instanceof b.Sound && (this.onOutSound = a), "string" == typeof c && (this.onOutSoundMarker = c)
  5427. }, b.Button.prototype.setDownSound = function(a, c) {
  5428. this.onDownSound = null, this.onDownSoundMarker = "", a instanceof b.Sound && (this.onDownSound = a), "string" == typeof c && (this.onDownSoundMarker = c)
  5429. }, b.Button.prototype.setUpSound = function(a, c) {
  5430. this.onUpSound = null, this.onUpSoundMarker = "", a instanceof b.Sound && (this.onUpSound = a), "string" == typeof c && (this.onUpSoundMarker = c)
  5431. }, b.Button.prototype.onInputOverHandler = function(a, b) {
  5432. this.freezeFrames === !1 && this.setState(1), (!this.onOverMouseOnly || b.isMouse) && (this.onOverSound && this.onOverSound.play(this.onOverSoundMarker), this.onInputOver && this.onInputOver.dispatch(this, b))
  5433. }, b.Button.prototype.onInputOutHandler = function(a, b) {
  5434. this.freezeFrames === !1 && this.setState(2), this.onOutSound && this.onOutSound.play(this.onOutSoundMarker), this.onInputOut && this.onInputOut.dispatch(this, b)
  5435. }, b.Button.prototype.onInputDownHandler = function(a, b) {
  5436. this.freezeFrames === !1 && this.setState(3), this.onDownSound && this.onDownSound.play(this.onDownSoundMarker), this.onInputDown && this.onInputDown.dispatch(this, b)
  5437. }, b.Button.prototype.onInputUpHandler = function(a, b, c) {
  5438. this.onUpSound && this.onUpSound.play(this.onUpSoundMarker), this.onInputUp && this.onInputUp.dispatch(this, b, c), this.freezeFrames || this.setState(this.forceOut ? 2 : null !== this._onUpFrameName || null !== this._onUpFrameID ? 4 : c ? 1 : 2)
  5439. }, b.Button.prototype.setState = function(a) {
  5440. 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))
  5441. }, b.Graphics = function(a, c, d) {
  5442. 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]
  5443. }, b.Graphics.prototype = Object.create(PIXI.Graphics.prototype), b.Graphics.prototype.constructor = b.Graphics, b.Graphics.prototype.preUpdate = function() {
  5444. 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)
  5445. }, b.Graphics.prototype.update = function() {}, b.Graphics.prototype.postUpdate = function() {
  5446. 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)
  5447. }, b.Graphics.prototype.destroy = function(a) {
  5448. if (null !== this.game && !this.destroyPhase) {
  5449. "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));
  5450. var c = this.children.length;
  5451. if (a)
  5452. for (; c--;) this.children[c].destroy(a);
  5453. else
  5454. for (; c--;) this.removeChild(this.children[c]);
  5455. this.exists = !1, this.visible = !1, this.game = null, this._cache[8] = 0
  5456. }
  5457. }, b.Graphics.prototype.drawPolygon = function(a) {
  5458. this.moveTo(a.points[0].x, a.points[0].y);
  5459. for (var b = 1; b < a.points.length; b += 1) this.lineTo(a.points[b].x, a.points[b].y);
  5460. this.lineTo(a.points[0].x, a.points[0].y)
  5461. }, b.Graphics.prototype.drawTriangle = function(a, c) {
  5462. "undefined" == typeof c && (c = !1);
  5463. var d = new b.Polygon(a);
  5464. if (c) {
  5465. var e = new b.Point(this.game.camera.x - a[0].x, this.game.camera.y - a[0].y),
  5466. f = new b.Point(a[1].x - a[0].x, a[1].y - a[0].y),
  5467. g = new b.Point(a[1].x - a[2].x, a[1].y - a[2].y),
  5468. h = g.cross(f);
  5469. e.dot(h) > 0 && this.drawPolygon(d)
  5470. } else this.drawPolygon(d)
  5471. }, b.Graphics.prototype.drawTriangles = function(a, c, d) {
  5472. "undefined" == typeof d && (d = !1);
  5473. var e, f = new b.Point,
  5474. g = new b.Point,
  5475. h = new b.Point,
  5476. i = [];
  5477. if (c)
  5478. if (a[0] instanceof b.Point)
  5479. for (e = 0; e < c.length / 3; e++) i.push(a[c[3 * e]]), i.push(a[c[3 * e + 1]]), i.push(a[c[3 * e + 2]]), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5480. else
  5481. for (e = 0; e < c.length; e++) f.x = a[2 * c[e]], f.y = a[2 * c[e] + 1], i.push(f.copyTo({})), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5482. else if (a[0] instanceof b.Point)
  5483. for (e = 0; e < a.length / 3; e++) this.drawTriangle([a[3 * e], a[3 * e + 1], a[3 * e + 2]], d);
  5484. else
  5485. for (e = 0; e < a.length / 6; e++) f.x = a[6 * e + 0], f.y = a[6 * e + 1], g.x = a[6 * e + 2], g.y = a[6 * e + 3], h.x = a[6 * e + 4], h.y = a[6 * e + 5], this.drawTriangle([f, g, h], d)
  5486. }, Object.defineProperty(b.Graphics.prototype, "angle", {
  5487. get: function() {
  5488. return b.Math.radToDeg(this.rotation)
  5489. },
  5490. set: function(a) {
  5491. this.rotation = b.Math.degToRad(a)
  5492. }
  5493. }), Object.defineProperty(b.Graphics.prototype, "fixedToCamera", {
  5494. get: function() {
  5495. return !!this._cache[7]
  5496. },
  5497. set: function(a) {
  5498. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5499. }
  5500. }), Object.defineProperty(b.Graphics.prototype, "destroyPhase", {
  5501. get: function() {
  5502. return !!this._cache[8]
  5503. }
  5504. }), b.RenderTexture = function(a, c, d, e, f) {
  5505. "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)
  5506. }, b.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.renderXY = function(a, b, c, d) {
  5507. this._temp.set(b, c), this.render(a, this._temp, d)
  5508. }, b.SpriteBatch = function(a, c, d, e) {
  5509. ("undefined" == typeof c || null === c) && (c = a.world), PIXI.SpriteBatch.call(this), b.Group.call(this, a, c, d, e), this.type = b.SPRITEBATCH
  5510. }, 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) {
  5511. if (!a.cache.checkImageKey(c)) return !1;
  5512. ("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 = [];
  5513. for (var l = this.offsetX, m = this.offsetY, n = 0, o = new b.FrameData, p = 0; p < f.length; p++) {
  5514. var q = a.rnd.uuid(),
  5515. r = o.addFrame(new b.Frame(p, l, m, this.characterWidth, this.characterHeight, "", q));
  5516. this.grabData[f.charCodeAt(p)] = r.index, PIXI.TextureCache[q] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  5517. x: l,
  5518. y: m,
  5519. width: this.characterWidth,
  5520. height: this.characterHeight
  5521. }), n++, n == this.characterPerRow ? (n = 0, l = this.offsetX, m += this.characterHeight + this.characterSpacingY) : l += this.characterWidth + this.characterSpacingX
  5522. }
  5523. 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
  5524. }, 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) {
  5525. "undefined" == typeof b && (b = "left"), this.fixedWidth = a, this.align = b
  5526. }, b.RetroFont.prototype.setText = function(a, b, c, d, e, f) {
  5527. 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)
  5528. }, b.RetroFont.prototype.buildRetroFontText = function() {
  5529. var a = 0,
  5530. c = 0;
  5531. if (this.clear(), this.multiLine) {
  5532. var d = this._text.split("\n");
  5533. 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);
  5534. for (var e = 0; e < d.length; e++) {
  5535. switch (this.align) {
  5536. case b.RetroFont.ALIGN_LEFT:
  5537. a = 0;
  5538. break;
  5539. case b.RetroFont.ALIGN_RIGHT:
  5540. a = this.width - d[e].length * (this.characterWidth + this.customSpacingX);
  5541. break;
  5542. case b.RetroFont.ALIGN_CENTER:
  5543. a = this.width / 2 - d[e].length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  5544. }
  5545. 0 > a && (a = 0), this.pasteLine(d[e], a, c, this.customSpacingX), c += this.characterHeight + this.customSpacingY
  5546. }
  5547. } else {
  5548. 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) {
  5549. case b.RetroFont.ALIGN_LEFT:
  5550. a = 0;
  5551. break;
  5552. case b.RetroFont.ALIGN_RIGHT:
  5553. a = this.width - this._text.length * (this.characterWidth + this.customSpacingX);
  5554. break;
  5555. case b.RetroFont.ALIGN_CENTER:
  5556. a = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  5557. }
  5558. this.textureBuffer.clear(), this.pasteLine(this._text, a, 0, this.customSpacingX)
  5559. }
  5560. }, b.RetroFont.prototype.pasteLine = function(a, c, d, e) {
  5561. for (var f = new b.Point, g = 0; g < a.length; g++)
  5562. if (" " == a.charAt(g)) c += this.characterWidth + e;
  5563. 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
  5564. }, b.RetroFont.prototype.getLongestLine = function() {
  5565. var a = 0;
  5566. if (this._text.length > 0)
  5567. for (var b = this._text.split("\n"), c = 0; c < b.length; c++) b[c].length > a && (a = b[c].length);
  5568. return a
  5569. }, b.RetroFont.prototype.removeUnsupportedCharacters = function(a) {
  5570. for (var b = "", c = 0; c < this._text.length; c++) {
  5571. var d = this._text[c],
  5572. e = d.charCodeAt(0);
  5573. (this.grabData[e] >= 0 || !a && "\n" === d) && (b = b.concat(d))
  5574. }
  5575. return b
  5576. }, b.RetroFont.prototype.updateOffset = function(a, b) {
  5577. if (this.offsetX !== a || this.offsetY !== b) {
  5578. for (var 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;
  5579. this.buildRetroFontText()
  5580. }
  5581. }, Object.defineProperty(b.RetroFont.prototype, "text", {
  5582. get: function() {
  5583. return this._text
  5584. },
  5585. set: function(a) {
  5586. var b;
  5587. b = this.autoUpperCase ? a.toUpperCase() : a, b !== this._text && (this._text = b, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
  5588. }
  5589. }), Object.defineProperty(b.RetroFont.prototype, "smoothed", {
  5590. get: function() {
  5591. return this.stamp.smoothed
  5592. },
  5593. set: function(a) {
  5594. this.stamp.smoothed = a, this.buildRetroFontText()
  5595. }
  5596. }), b.Particle = function(a, c, d, e, f) {
  5597. 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
  5598. }, b.Particle.prototype = Object.create(b.Sprite.prototype), b.Particle.prototype.constructor = b.Particle, b.Particle.prototype.update = function() {
  5599. 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)
  5600. }, b.Particle.prototype.onEmit = function() {}, b.Particle.prototype.setAlphaData = function(a) {
  5601. this.alphaData = a, this._a = a.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0
  5602. }, b.Particle.prototype.setScaleData = function(a) {
  5603. this.scaleData = a, this._s = a.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0
  5604. }, b.Particle.prototype.reset = function(a, b, c) {
  5605. 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
  5606. }, b.Canvas = {
  5607. create: function(a, b, c, d) {
  5608. "undefined" == typeof d && (d = !1), a = a || 256, b = b || 256;
  5609. var e = document.createElement("canvas");
  5610. return "string" == typeof c && "" !== c && (e.id = c), e.width = a, e.height = b, e.style.display = "block", e
  5611. },
  5612. getOffset: function(a, c) {
  5613. c = c || new b.Point;
  5614. var d = a.getBoundingClientRect(),
  5615. e = a.clientTop || document.body.clientTop || 0,
  5616. f = a.clientLeft || document.body.clientLeft || 0,
  5617. g = 0,
  5618. h = 0;
  5619. return "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
  5620. },
  5621. getAspectRatio: function(a) {
  5622. return a.width / a.height
  5623. },
  5624. setBackgroundColor: function(a, b) {
  5625. return b = b || "rgb(0,0,0)", a.style.backgroundColor = b, a
  5626. },
  5627. setTouchAction: function(a, b) {
  5628. return b = b || "none", a.style.msTouchAction = b, a.style["ms-touch-action"] = b, a.style["touch-action"] = b, a
  5629. },
  5630. setUserSelect: function(a, b) {
  5631. 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
  5632. },
  5633. addToDOM: function(a, b, c) {
  5634. var d;
  5635. 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
  5636. },
  5637. setTransform: function(a, b, c, d, e, f, g) {
  5638. return a.setTransform(d, f, g, e, b, c), a
  5639. },
  5640. setSmoothingEnabled: function(a, b) {
  5641. return a.imageSmoothingEnabled = b, a.mozImageSmoothingEnabled = b, a.oImageSmoothingEnabled = b, a.webkitImageSmoothingEnabled = b, a.msImageSmoothingEnabled = b, a
  5642. },
  5643. setImageRenderingCrisp: function(a) {
  5644. 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
  5645. },
  5646. setImageRenderingBicubic: function(a) {
  5647. return a.style["image-rendering"] = "auto", a.style.msInterpolationMode = "bicubic", a
  5648. }
  5649. }, b.Device = function(a) {
  5650. 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()
  5651. }, b.Device.LITTLE_ENDIAN = !1, b.Device.prototype = {
  5652. _checkOS: function() {
  5653. var a = navigator.userAgent;
  5654. /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)
  5655. },
  5656. _checkFeatures: function() {
  5657. this.canvas = !!window.CanvasRenderingContext2D || this.cocoonJS;
  5658. try {
  5659. this.localStorage = !!localStorage.getItem
  5660. } catch (a) {
  5661. this.localStorage = !1
  5662. }
  5663. this.file = !!(window.File && window.FileReader && window.FileList && window.Blob), this.fileSystem = !!window.requestFileSystem, this.webGL = function() {
  5664. try {
  5665. var a = document.createElement("canvas");
  5666. return !!window.WebGLRenderingContext && (a.getContext("webgl") || a.getContext("experimental-webgl"))
  5667. } catch (b) {
  5668. return !1
  5669. }
  5670. }(), 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)
  5671. },
  5672. checkFullScreenSupport: function() {
  5673. for (var a = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"], b = 0; b < a.length; b++)
  5674. if (this.game.canvas[a[b]]) {
  5675. this.fullscreen = !0, this.requestFullscreen = a[b];
  5676. break
  5677. }
  5678. var c = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
  5679. if (this.fullscreen)
  5680. for (var b = 0; b < c.length; b++)
  5681. if (document[c[b]]) {
  5682. this.cancelFullscreen = c[b];
  5683. break
  5684. }
  5685. window.Element && Element.ALLOW_KEYBOARD_INPUT && (this.fullscreenKeyboard = !0)
  5686. },
  5687. _checkBrowser: function() {
  5688. var a = navigator.userAgent;
  5689. /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)
  5690. },
  5691. _checkAudio: function() {
  5692. this.audioData = !!window.Audio, this.webAudio = !(!window.webkitAudioContext && !window.AudioContext);
  5693. var a = document.createElement("audio"),
  5694. b = !1;
  5695. try {
  5696. (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))
  5697. } catch (c) {}
  5698. },
  5699. _checkDevice: function() {
  5700. 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)
  5701. },
  5702. _checkIsLittleEndian: function() {
  5703. var a = new ArrayBuffer(4),
  5704. b = new Uint8Array(a),
  5705. c = new Uint32Array(a);
  5706. return b[0] = 161, b[1] = 178, b[2] = 195, b[3] = 212, 3569595041 == c[0] ? !0 : 2712847316 == c[0] ? !1 : null
  5707. },
  5708. _checkIsUint8ClampedImageData: function() {
  5709. if ("undefined" == typeof Uint8ClampedArray) return !1;
  5710. var a = document.createElement("canvas"),
  5711. b = a.getContext("2d");
  5712. if (!b) return !1;
  5713. var c = b.createImageData(1, 1);
  5714. return c.data instanceof Uint8ClampedArray
  5715. },
  5716. _checkCSS3D: function() {
  5717. var a, b = document.createElement("p"),
  5718. c = {
  5719. webkitTransform: "-webkit-transform",
  5720. OTransform: "-o-transform",
  5721. msTransform: "-ms-transform",
  5722. MozTransform: "-moz-transform",
  5723. transform: "transform"
  5724. };
  5725. document.body.insertBefore(b, null);
  5726. for (var d in c) void 0 !== b.style[d] && (b.style[d] = "translate3d(1px,1px,1px)", a = window.getComputedStyle(b).getPropertyValue(c[d]));
  5727. document.body.removeChild(b), this.css3D = void 0 !== a && a.length > 0 && "none" !== a
  5728. },
  5729. canPlayAudio: function(a) {
  5730. 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
  5731. },
  5732. isConsoleOpen: function() {
  5733. return window.console && window.console.firebug ? !0 : window.console && (console.profile(), console.profileEnd(), console.clear && console.clear(), console.profiles) ? console.profiles.length > 0 : !1
  5734. }
  5735. }, b.Device.prototype.constructor = b.Device, b.RequestAnimationFrame = function(a, b) {
  5736. "undefined" == typeof b && (b = !1), this.game = a, this.isRunning = !1, this.forceSetTimeOut = b;
  5737. for (var 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"];
  5738. this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
  5739. }, b.RequestAnimationFrame.prototype = {
  5740. start: function() {
  5741. this.isRunning = !0;
  5742. var a = this;
  5743. !window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() {
  5744. return a.updateSetTimeout()
  5745. }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(b) {
  5746. return a.updateRAF(b)
  5747. }, this._timeOutID = window.requestAnimationFrame(this._onLoop))
  5748. },
  5749. updateRAF: function() {
  5750. this.game.update(Date.now()), this._timeOutID = window.requestAnimationFrame(this._onLoop)
  5751. },
  5752. updateSetTimeout: function() {
  5753. this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)
  5754. },
  5755. stop: function() {
  5756. this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1
  5757. },
  5758. isSetTimeOut: function() {
  5759. return this._isSetTimeOut
  5760. },
  5761. isRAF: function() {
  5762. return this._isSetTimeOut === !1
  5763. }
  5764. }, b.RequestAnimationFrame.prototype.constructor = b.RequestAnimationFrame, b.Math = {
  5765. PI2: 2 * Math.PI,
  5766. fuzzyEqual: function(a, b, c) {
  5767. return "undefined" == typeof c && (c = 1e-4), Math.abs(a - b) < c
  5768. },
  5769. fuzzyLessThan: function(a, b, c) {
  5770. return "undefined" == typeof c && (c = 1e-4), b + c > a
  5771. },
  5772. fuzzyGreaterThan: function(a, b, c) {
  5773. return "undefined" == typeof c && (c = 1e-4), a > b - c
  5774. },
  5775. fuzzyCeil: function(a, b) {
  5776. return "undefined" == typeof b && (b = 1e-4), Math.ceil(a - b)
  5777. },
  5778. fuzzyFloor: function(a, b) {
  5779. return "undefined" == typeof b && (b = 1e-4), Math.floor(a + b)
  5780. },
  5781. average: function() {
  5782. for (var a = [], b = 0; b < arguments.length - 0; b++) a[b] = arguments[b + 0];
  5783. for (var c = 0, d = 0; d < a.length; d++) c += a[d];
  5784. return c / a.length
  5785. },
  5786. truncate: function(a) {
  5787. return a > 0 ? Math.floor(a) : Math.ceil(a)
  5788. },
  5789. shear: function(a) {
  5790. return a % 1
  5791. },
  5792. snapTo: function(a, b, c) {
  5793. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.round(a / b), c + a)
  5794. },
  5795. snapToFloor: function(a, b, c) {
  5796. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.floor(a / b), c + a)
  5797. },
  5798. snapToCeil: function(a, b, c) {
  5799. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.ceil(a / b), c + a)
  5800. },
  5801. snapToInArray: function(a, b, c) {
  5802. if ("undefined" == typeof c && (c = !0), c && b.sort(), a < b[0]) return b[0];
  5803. for (var d = 1; b[d] < a;) d++;
  5804. var e = b[d - 1],
  5805. f = d < b.length ? b[d] : Number.POSITIVE_INFINITY;
  5806. return a - e >= f - a ? f : e
  5807. },
  5808. roundTo: function(a, b, c) {
  5809. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  5810. var d = Math.pow(c, -b);
  5811. return Math.round(a * d) / d
  5812. },
  5813. floorTo: function(a, b, c) {
  5814. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  5815. var d = Math.pow(c, -b);
  5816. return Math.floor(a * d) / d
  5817. },
  5818. ceilTo: function(a, b, c) {
  5819. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  5820. var d = Math.pow(c, -b);
  5821. return Math.ceil(a * d) / d
  5822. },
  5823. interpolateFloat: function(a, b, c) {
  5824. return (b - a) * c + a
  5825. },
  5826. angleBetween: function(a, b, c, d) {
  5827. return Math.atan2(d - b, c - a)
  5828. },
  5829. angleBetweenPoints: function(a, b) {
  5830. return Math.atan2(b.y - a.y, b.x - a.x)
  5831. },
  5832. reverseAngle: function(a) {
  5833. return this.normalizeAngle(a + Math.PI, !0)
  5834. },
  5835. normalizeAngle: function(a) {
  5836. return a %= 2 * Math.PI, a >= 0 ? a : a + 2 * Math.PI
  5837. },
  5838. normalizeLatitude: function(a) {
  5839. return Math.max(-90, Math.min(90, a))
  5840. },
  5841. normalizeLongitude: function(a) {
  5842. return a % 360 == 180 ? 180 : (a %= 360, -180 > a ? a + 360 : a > 180 ? a - 360 : a)
  5843. },
  5844. chanceRoll: function(a) {
  5845. return "undefined" == typeof a && (a = 50), 0 >= a ? !1 : a >= 100 ? !0 : 100 * Math.random() >= a ? !1 : !0
  5846. },
  5847. numberArray: function(a, b) {
  5848. for (var c = [], d = a; b >= d; d++) c.push(d);
  5849. return c
  5850. },
  5851. maxAdd: function(a, b, c) {
  5852. return a += b, a > c && (a = c), a
  5853. },
  5854. minSub: function(a, b, c) {
  5855. return a -= b, c > a && (a = c), a
  5856. },
  5857. wrap: function(a, b, c) {
  5858. var d = c - b;
  5859. if (0 >= d) return 0;
  5860. var e = (a - b) % d;
  5861. return 0 > e && (e += d), e + b
  5862. },
  5863. wrapValue: function(a, b, c) {
  5864. var d;
  5865. return a = Math.abs(a), b = Math.abs(b), c = Math.abs(c), d = (a + b) % c
  5866. },
  5867. limitValue: function(a, b, c) {
  5868. return b > a ? b : a > c ? c : a
  5869. },
  5870. randomSign: function() {
  5871. return Math.random() > .5 ? 1 : -1
  5872. },
  5873. isOdd: function(a) {
  5874. return 1 & a
  5875. },
  5876. isEven: function(a) {
  5877. return 1 & a ? !1 : !0
  5878. },
  5879. min: function() {
  5880. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  5881. else var a = arguments;
  5882. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] < a[c] && (c = b);
  5883. return a[c]
  5884. },
  5885. max: function() {
  5886. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  5887. else var a = arguments;
  5888. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] > a[c] && (c = b);
  5889. return a[c]
  5890. },
  5891. minProperty: function(a) {
  5892. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  5893. else var b = arguments.slice(1);
  5894. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] < b[d][a] && (d = c);
  5895. return b[d][a]
  5896. },
  5897. maxProperty: function(a) {
  5898. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  5899. else var b = arguments.slice(1);
  5900. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] > b[d][a] && (d = c);
  5901. return b[d][a]
  5902. },
  5903. wrapAngle: function(a, b) {
  5904. var c = b ? Math.PI / 180 : 1;
  5905. return this.wrap(a, -180 * c, 180 * c)
  5906. },
  5907. angleLimit: function(a, b, c) {
  5908. var d = a;
  5909. return a > c ? d = c : b > a && (d = b), d
  5910. },
  5911. linearInterpolation: function(a, b) {
  5912. var c = a.length - 1,
  5913. d = c * b,
  5914. e = Math.floor(d);
  5915. 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)
  5916. },
  5917. bezierInterpolation: function(a, b) {
  5918. for (var c = 0, d = a.length - 1, e = 0; d >= e; e++) c += Math.pow(1 - b, d - e) * Math.pow(b, e) * a[e] * this.bernstein(d, e);
  5919. return c
  5920. },
  5921. catmullRomInterpolation: function(a, b) {
  5922. var c = a.length - 1,
  5923. d = c * b,
  5924. e = Math.floor(d);
  5925. 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)
  5926. },
  5927. linear: function(a, b, c) {
  5928. return (b - a) * c + a
  5929. },
  5930. bernstein: function(a, b) {
  5931. return this.factorial(a) / this.factorial(b) / this.factorial(a - b)
  5932. },
  5933. factorial: function(a) {
  5934. if (0 === a) return 1;
  5935. for (var b = a; --a;) b *= a;
  5936. return b
  5937. },
  5938. catmullRom: function(a, b, c, d, e) {
  5939. var f = .5 * (c - a),
  5940. g = .5 * (d - b),
  5941. h = e * e,
  5942. i = e * h;
  5943. return (2 * b - 2 * c + f + g) * i + (-3 * b + 3 * c - 2 * f - g) * h + f * e + b
  5944. },
  5945. difference: function(a, b) {
  5946. return Math.abs(a - b)
  5947. },
  5948. getRandom: function(a, b, c) {
  5949. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
  5950. var d = c;
  5951. if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) return a[b + Math.floor(Math.random() * d)]
  5952. }
  5953. return null
  5954. },
  5955. removeRandom: function(a, b, c) {
  5956. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
  5957. var d = c;
  5958. if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) {
  5959. var e = b + Math.floor(Math.random() * d),
  5960. f = a.splice(e, 1);
  5961. return f[0]
  5962. }
  5963. }
  5964. return null
  5965. },
  5966. floor: function(a) {
  5967. var b = 0 | a;
  5968. return a > 0 ? b : b != a ? b - 1 : b
  5969. },
  5970. ceil: function(a) {
  5971. var b = 0 | a;
  5972. return a > 0 && b != a ? b + 1 : b
  5973. },
  5974. sinCosGenerator: function(a, b, c, d) {
  5975. "undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1);
  5976. for (var 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;
  5977. return {
  5978. sin: i,
  5979. cos: h,
  5980. length: a
  5981. }
  5982. },
  5983. shift: function(a) {
  5984. var b = a.shift();
  5985. return a.push(b), b
  5986. },
  5987. shuffleArray: function(a) {
  5988. for (var b = a.length - 1; b > 0; b--) {
  5989. var c = Math.floor(Math.random() * (b + 1)),
  5990. d = a[b];
  5991. a[b] = a[c], a[c] = d
  5992. }
  5993. return a
  5994. },
  5995. distance: function(a, b, c, d) {
  5996. var e = a - c,
  5997. f = b - d;
  5998. return Math.sqrt(e * e + f * f)
  5999. },
  6000. distancePow: function(a, b, c, d, e) {
  6001. return "undefined" == typeof e && (e = 2), Math.sqrt(Math.pow(c - a, e) + Math.pow(d - b, e))
  6002. },
  6003. distanceRounded: function(a, c, d, e) {
  6004. return Math.round(b.Math.distance(a, c, d, e))
  6005. },
  6006. clamp: function(a, b, c) {
  6007. return b > a ? b : a > c ? c : a
  6008. },
  6009. clampBottom: function(a, b) {
  6010. return b > a ? b : a
  6011. },
  6012. within: function(a, b, c) {
  6013. return Math.abs(a - b) <= c
  6014. },
  6015. mapLinear: function(a, b, c, d, e) {
  6016. return d + (a - b) * (e - d) / (c - b)
  6017. },
  6018. smoothstep: function(a, b, c) {
  6019. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * (3 - 2 * a)
  6020. },
  6021. smootherstep: function(a, b, c) {
  6022. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * a * (a * (6 * a - 15) + 10)
  6023. },
  6024. sign: function(a) {
  6025. return 0 > a ? -1 : a > 0 ? 1 : 0
  6026. },
  6027. percent: function(a, b, c) {
  6028. return "undefined" == typeof c && (c = 0), a > b || c > b ? 1 : c > a || c > a ? 0 : (a - c) / b
  6029. },
  6030. degToRad: function() {
  6031. var a = Math.PI / 180;
  6032. return function(b) {
  6033. return b * a
  6034. }
  6035. }(),
  6036. radToDeg: function() {
  6037. var a = 180 / Math.PI;
  6038. return function(b) {
  6039. return b * a
  6040. }
  6041. }()
  6042. }, b.RandomDataGenerator = function(a) {
  6043. "undefined" == typeof a && (a = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.sow(a)
  6044. }, b.RandomDataGenerator.prototype = {
  6045. rnd: function() {
  6046. var a = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c;
  6047. return this.c = 0 | a, this.s0 = this.s1, this.s1 = this.s2, this.s2 = a - this.c, this.s2
  6048. },
  6049. sow: function(a) {
  6050. "undefined" == typeof a && (a = []), this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1;
  6051. for (var b, 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)
  6052. },
  6053. hash: function(a) {
  6054. var b, c, d;
  6055. 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;
  6056. return 2.3283064365386963e-10 * (d >>> 0)
  6057. },
  6058. integer: function() {
  6059. return 4294967296 * this.rnd.apply(this)
  6060. },
  6061. frac: function() {
  6062. return this.rnd.apply(this) + 1.1102230246251565e-16 * (2097152 * this.rnd.apply(this) | 0)
  6063. },
  6064. real: function() {
  6065. return this.integer() + this.frac()
  6066. },
  6067. integerInRange: function(a, b) {
  6068. return Math.floor(this.realInRange(0, b - a + 1) + a)
  6069. },
  6070. between: function(a, b) {
  6071. return this.integerInRange(a, b)
  6072. },
  6073. realInRange: function(a, b) {
  6074. return this.frac() * (b - a) + a
  6075. },
  6076. normal: function() {
  6077. return 1 - 2 * this.frac()
  6078. },
  6079. uuid: function() {
  6080. var a = "",
  6081. b = "";
  6082. for (b = a = ""; a++ < 36; b += ~a % 5 | 3 * a & 4 ? (15 ^ a ? 8 ^ this.frac() * (20 ^ a ? 16 : 4) : 4).toString(16) : "-");
  6083. return b
  6084. },
  6085. pick: function(a) {
  6086. return a[this.integerInRange(0, a.length - 1)]
  6087. },
  6088. weightedPick: function(a) {
  6089. return a[~~(Math.pow(this.frac(), 2) * (a.length - 1))]
  6090. },
  6091. timestamp: function(a, b) {
  6092. return this.realInRange(a || 9466848e5, b || 1577862e6)
  6093. },
  6094. angle: function() {
  6095. return this.integerInRange(-180, 180)
  6096. }
  6097. }, b.RandomDataGenerator.prototype.constructor = b.RandomDataGenerator, b.QuadTree = function(a, b, c, d, e, f, g) {
  6098. 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)
  6099. }, b.QuadTree.prototype = {
  6100. reset: function(a, b, c, d, e, f, g) {
  6101. this.maxObjects = e || 10, this.maxLevels = f || 4, this.level = g || 0, this.bounds = {
  6102. x: Math.round(a),
  6103. y: Math.round(b),
  6104. width: c,
  6105. height: d,
  6106. subWidth: Math.floor(c / 2),
  6107. subHeight: Math.floor(d / 2),
  6108. right: Math.round(a) + Math.floor(c / 2),
  6109. bottom: Math.round(b) + Math.floor(d / 2)
  6110. }, this.objects.length = 0, this.nodes.length = 0
  6111. },
  6112. populate: function(a) {
  6113. a.forEach(this.populateHandler, this, !0)
  6114. },
  6115. populateHandler: function(a) {
  6116. a.body && a.exists && this.insert(a.body)
  6117. },
  6118. split: function() {
  6119. 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)
  6120. },
  6121. insert: function(a) {
  6122. var b, c = 0;
  6123. if (null != this.nodes[0] && (b = this.getIndex(a), -1 !== b)) return void this.nodes[b].insert(a);
  6124. if (this.objects.push(a), this.objects.length > this.maxObjects && this.level < this.maxLevels)
  6125. for (null == this.nodes[0] && this.split(); c < this.objects.length;) b = this.getIndex(this.objects[c]), -1 !== b ? this.nodes[b].insert(this.objects.splice(c, 1)[0]) : c++
  6126. },
  6127. getIndex: function(a) {
  6128. var b = -1;
  6129. 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
  6130. },
  6131. retrieve: function(a) {
  6132. if (a instanceof b.Rectangle) var c = this.objects,
  6133. d = this.getIndex(a);
  6134. else {
  6135. if (!a.body) return this._empty;
  6136. var c = this.objects,
  6137. d = this.getIndex(a.body)
  6138. }
  6139. 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
  6140. },
  6141. clear: function() {
  6142. this.objects.length = 0;
  6143. for (var a = this.nodes.length; a--;) this.nodes[a].clear(), this.nodes.splice(a, 1);
  6144. this.nodes.length = 0
  6145. }
  6146. }, b.QuadTree.prototype.constructor = b.QuadTree, b.Net = function(a) {
  6147. this.game = a
  6148. }, b.Net.prototype = {
  6149. getHostName: function() {
  6150. return window.location && window.location.hostname ? window.location.hostname : null
  6151. },
  6152. checkDomainName: function(a) {
  6153. return -1 !== window.location.hostname.indexOf(a)
  6154. },
  6155. updateQueryString: function(a, b, c, d) {
  6156. "undefined" == typeof c && (c = !1), ("undefined" == typeof d || "" === d) && (d = window.location.href);
  6157. var e = "",
  6158. f = new RegExp("([?|&])" + a + "=.*?(&|#|$)(.*)", "gi");
  6159. if (f.test(d)) e = "undefined" != typeof b && null !== b ? d.replace(f, "$1" + a + "=" + b + "$2$3") : d.replace(f, "$1$3").replace(/(&|\?)$/, "");
  6160. else if ("undefined" != typeof b && null !== b) {
  6161. var g = -1 !== d.indexOf("?") ? "&" : "?",
  6162. h = d.split("#");
  6163. d = h[0] + g + a + "=" + b, h[1] && (d += "#" + h[1]), e = d
  6164. } else e = d;
  6165. return c ? void(window.location.href = e) : e
  6166. },
  6167. getQueryString: function(a) {
  6168. "undefined" == typeof a && (a = "");
  6169. var b = {},
  6170. c = location.search.substring(1).split("&");
  6171. for (var d in c) {
  6172. var e = c[d].split("=");
  6173. if (e.length > 1) {
  6174. if (a && a == this.decodeURI(e[0])) return this.decodeURI(e[1]);
  6175. b[this.decodeURI(e[0])] = this.decodeURI(e[1])
  6176. }
  6177. }
  6178. return b
  6179. },
  6180. decodeURI: function(a) {
  6181. return decodeURIComponent(a.replace(/\+/g, " "))
  6182. }
  6183. }, b.Net.prototype.constructor = b.Net, b.TweenManager = function(a) {
  6184. this.game = a, this._tweens = [], this._add = [], this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this)
  6185. }, b.TweenManager.prototype = {
  6186. getAll: function() {
  6187. return this._tweens
  6188. },
  6189. removeAll: function() {
  6190. for (var a = 0; a < this._tweens.length; a++) this._tweens[a].pendingDelete = !0;
  6191. this._add = []
  6192. },
  6193. add: function(a) {
  6194. a._manager = this, this._add.push(a)
  6195. },
  6196. create: function(a) {
  6197. return new b.Tween(a, this.game, this)
  6198. },
  6199. remove: function(a) {
  6200. 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))
  6201. },
  6202. update: function() {
  6203. var a = this._add.length,
  6204. b = this._tweens.length;
  6205. if (0 === b && 0 === a) return !1;
  6206. for (var c = 0; b > c;) this._tweens[c].update(this.game.time.now) ? c++ : (this._tweens.splice(c, 1), b--);
  6207. return a > 0 && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
  6208. },
  6209. isTweening: function(a) {
  6210. return this._tweens.some(function(b) {
  6211. return b._object === a
  6212. })
  6213. },
  6214. _pauseAll: function() {
  6215. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._pause()
  6216. },
  6217. _resumeAll: function() {
  6218. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._resume()
  6219. },
  6220. pauseAll: function() {
  6221. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].pause()
  6222. },
  6223. resumeAll: function() {
  6224. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].resume(!0)
  6225. }
  6226. }, b.TweenManager.prototype.constructor = b.TweenManager, b.Tween = function(a, c, d) {
  6227. 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
  6228. }, b.Tween.prototype = {
  6229. to: function(a, b, c, d, e, f, g) {
  6230. b = b || 1e3, c = c || null, d = d || !1, e = e || 0, f = f || 0, g = g || !1, g && 0 === f && (f = 1);
  6231. var h;
  6232. 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
  6233. },
  6234. from: function(a, b, c, d, e, f, g) {
  6235. var h = {};
  6236. for (var i in a) h[i] = this._object[i], this._object[i] = a[i];
  6237. return this.to(h, b, c, d, e, f, g)
  6238. },
  6239. start: function() {
  6240. if (null !== this.game && null !== this._object) {
  6241. this._manager.add(this), this.isRunning = !0, this._onStartCallbackFired = !1, this._startTime = this.game.time.now + this._delayTime;
  6242. for (var a in this._valuesEnd) {
  6243. if (Array.isArray(this._valuesEnd[a])) {
  6244. if (0 === this._valuesEnd[a].length) continue;
  6245. this._valuesEnd[a] = [this._object[a]].concat(this._valuesEnd[a])
  6246. }
  6247. this._valuesStart[a] = this._object[a], Array.isArray(this._valuesStart[a]) || (this._valuesStart[a] *= 1), this._valuesStartRepeat[a] = this._valuesStart[a] || 0
  6248. }
  6249. return this
  6250. }
  6251. },
  6252. generateData: function(a, b) {
  6253. if (null === this.game || null === this._object) return null;
  6254. this._startTime = 0;
  6255. for (var c in this._valuesEnd) {
  6256. if (Array.isArray(this._valuesEnd[c])) {
  6257. if (0 === this._valuesEnd[c].length) continue;
  6258. this._valuesEnd[c] = [this._object[c]].concat(this._valuesEnd[c])
  6259. }
  6260. this._valuesStart[c] = this._object[c], Array.isArray(this._valuesStart[c]) || (this._valuesStart[c] *= 1), this._valuesStartRepeat[c] = this._valuesStart[c] || 0
  6261. }
  6262. for (var d = 0, e = Math.floor(a * (this._duration / 1e3)), f = this._duration / e, g = []; e--;) {
  6263. var c, h = (d - this._startTime) / this._duration;
  6264. h = h > 1 ? 1 : h;
  6265. var i = this._easingFunction(h),
  6266. j = {};
  6267. for (c in this._valuesEnd) {
  6268. var k = this._valuesStart[c] || 0,
  6269. l = this._valuesEnd[c];
  6270. 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))
  6271. }
  6272. g.push(j), d += f
  6273. }
  6274. if (this._yoyo) {
  6275. var m = g.slice();
  6276. m.reverse(), g = g.concat(m)
  6277. }
  6278. return "undefined" != typeof b ? b = b.concat(g) : g
  6279. },
  6280. stop: function() {
  6281. return this.isRunning = !1, this._onUpdateCallback = null, this._manager.remove(this), this
  6282. },
  6283. delay: function(a) {
  6284. return this._delayTime = a, this
  6285. },
  6286. repeat: function(a) {
  6287. return this._repeat = a, this
  6288. },
  6289. yoyo: function(a) {
  6290. return this._yoyo = a, a && 0 === this._repeat && (this._repeat = 1), this
  6291. },
  6292. easing: function(a) {
  6293. return this._easingFunction = a, this
  6294. },
  6295. interpolation: function(a) {
  6296. return this._interpolationFunction = a, this
  6297. },
  6298. chain: function() {
  6299. return this._chainedTweens = arguments, this
  6300. },
  6301. loop: function() {
  6302. return this._lastChild.chain(this), this
  6303. },
  6304. onUpdateCallback: function(a, b) {
  6305. return this._onUpdateCallback = a, this._onUpdateCallbackContext = b, this
  6306. },
  6307. pause: function() {
  6308. this._codePaused = !0, this._paused = !0, this._pausedTime = this.game.time.now
  6309. },
  6310. _pause: function() {
  6311. this._codePaused || (this._paused = !0, this._pausedTime = this.game.time.now)
  6312. },
  6313. resume: function() {
  6314. this._paused && (this._paused = !1, this._codePaused = !1, this._startTime += this.game.time.now - this._pausedTime)
  6315. },
  6316. _resume: function() {
  6317. this._codePaused || (this._startTime += this.game.time.pauseDuration, this._paused = !1)
  6318. },
  6319. update: function(a) {
  6320. if (this.pendingDelete) return !1;
  6321. if (this._paused || a < this._startTime) return !0;
  6322. var b;
  6323. if (a < this._startTime) return !0;
  6324. this._onStartCallbackFired === !1 && (this.onStart.dispatch(this._object), this._onStartCallbackFired = !0);
  6325. var c = (a - this._startTime) / this._duration;
  6326. c = c > 1 ? 1 : c;
  6327. var d = this._easingFunction(c);
  6328. for (b in this._valuesEnd) {
  6329. var e = this._valuesStart[b] || 0,
  6330. f = this._valuesEnd[b];
  6331. 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))
  6332. }
  6333. if (null !== this._onUpdateCallback && (this._onUpdateCallback.call(this._onUpdateCallbackContext, this, d), !this.isRunning)) return !1;
  6334. if (1 == c) {
  6335. if (this._repeat > 0) {
  6336. isFinite(this._repeat) && this._repeat--;
  6337. for (b in this._valuesStartRepeat) {
  6338. if ("string" == typeof this._valuesEnd[b] && (this._valuesStartRepeat[b] = this._valuesStartRepeat[b] + parseFloat(this._valuesEnd[b], 10)), this._yoyo) {
  6339. var g = this._valuesStartRepeat[b];
  6340. this._valuesStartRepeat[b] = this._valuesEnd[b], this._valuesEnd[b] = g
  6341. }
  6342. this._valuesStart[b] = this._valuesStartRepeat[b]
  6343. }
  6344. return this._yoyo && (this._reversed = !this._reversed), this._startTime = a + this._delayTime, this.onLoop.dispatch(this._object), !0
  6345. }
  6346. this.isRunning = !1, this.onComplete.dispatch(this._object);
  6347. for (var h = 0, i = this._chainedTweens.length; i > h; h++) this._chainedTweens[h].start(a);
  6348. return !1
  6349. }
  6350. return !0
  6351. }
  6352. }, b.Tween.prototype.constructor = b.Tween, b.Easing = {
  6353. Linear: {
  6354. None: function(a) {
  6355. return a
  6356. }
  6357. },
  6358. Quadratic: {
  6359. In: function(a) {
  6360. return a * a
  6361. },
  6362. Out: function(a) {
  6363. return a * (2 - a)
  6364. },
  6365. InOut: function(a) {
  6366. return (a *= 2) < 1 ? .5 * a * a : -.5 * (--a * (a - 2) - 1)
  6367. }
  6368. },
  6369. Cubic: {
  6370. In: function(a) {
  6371. return a * a * a
  6372. },
  6373. Out: function(a) {
  6374. return --a * a * a + 1
  6375. },
  6376. InOut: function(a) {
  6377. return (a *= 2) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2)
  6378. }
  6379. },
  6380. Quartic: {
  6381. In: function(a) {
  6382. return a * a * a * a
  6383. },
  6384. Out: function(a) {
  6385. return 1 - --a * a * a * a
  6386. },
  6387. InOut: function(a) {
  6388. return (a *= 2) < 1 ? .5 * a * a * a * a : -.5 * ((a -= 2) * a * a * a - 2)
  6389. }
  6390. },
  6391. Quintic: {
  6392. In: function(a) {
  6393. return a * a * a * a * a
  6394. },
  6395. Out: function(a) {
  6396. return --a * a * a * a * a + 1
  6397. },
  6398. InOut: function(a) {
  6399. return (a *= 2) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2)
  6400. }
  6401. },
  6402. Sinusoidal: {
  6403. In: function(a) {
  6404. return 1 - Math.cos(a * Math.PI / 2)
  6405. },
  6406. Out: function(a) {
  6407. return Math.sin(a * Math.PI / 2)
  6408. },
  6409. InOut: function(a) {
  6410. return .5 * (1 - Math.cos(Math.PI * a))
  6411. }
  6412. },
  6413. Exponential: {
  6414. In: function(a) {
  6415. return 0 === a ? 0 : Math.pow(1024, a - 1)
  6416. },
  6417. Out: function(a) {
  6418. return 1 === a ? 1 : 1 - Math.pow(2, -10 * a)
  6419. },
  6420. InOut: function(a) {
  6421. return 0 === a ? 0 : 1 === a ? 1 : (a *= 2) < 1 ? .5 * Math.pow(1024, a - 1) : .5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  6422. }
  6423. },
  6424. Circular: {
  6425. In: function(a) {
  6426. return 1 - Math.sqrt(1 - a * a)
  6427. },
  6428. Out: function(a) {
  6429. return Math.sqrt(1 - --a * a)
  6430. },
  6431. InOut: function(a) {
  6432. return (a *= 2) < 1 ? -.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  6433. }
  6434. },
  6435. Elastic: {
  6436. In: function(a) {
  6437. var b, c = .1,
  6438. d = .4;
  6439. 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(2 * (a - b) * Math.PI / d)))
  6440. },
  6441. Out: function(a) {
  6442. var b, c = .1,
  6443. d = .4;
  6444. 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(2 * (a - b) * Math.PI / d) + 1)
  6445. },
  6446. InOut: function(a) {
  6447. var b, c = .1,
  6448. d = .4;
  6449. 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(2 * (a - b) * Math.PI / d) : c * Math.pow(2, -10 * (a -= 1)) * Math.sin(2 * (a - b) * Math.PI / d) * .5 + 1)
  6450. }
  6451. },
  6452. Back: {
  6453. In: function(a) {
  6454. var b = 1.70158;
  6455. return a * a * ((b + 1) * a - b)
  6456. },
  6457. Out: function(a) {
  6458. var b = 1.70158;
  6459. return --a * a * ((b + 1) * a + b) + 1
  6460. },
  6461. InOut: function(a) {
  6462. var b = 2.5949095;
  6463. return (a *= 2) < 1 ? .5 * a * a * ((b + 1) * a - b) : .5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
  6464. }
  6465. },
  6466. Bounce: {
  6467. In: function(a) {
  6468. return 1 - b.Easing.Bounce.Out(1 - a)
  6469. },
  6470. Out: function(a) {
  6471. 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
  6472. },
  6473. InOut: function(a) {
  6474. return .5 > a ? .5 * b.Easing.Bounce.In(2 * a) : .5 * b.Easing.Bounce.Out(2 * a - 1) + .5
  6475. }
  6476. }
  6477. }, b.Time = function(a) {
  6478. 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
  6479. }, b.Time.prototype = {
  6480. boot: function() {
  6481. this._started = Date.now(), this.events.start()
  6482. },
  6483. add: function(a) {
  6484. return this._timers.push(a), a
  6485. },
  6486. create: function(a) {
  6487. "undefined" == typeof a && (a = !0);
  6488. var c = new b.Timer(this.game, a);
  6489. return this._timers.push(c), c
  6490. },
  6491. removeAll: function() {
  6492. for (var a = 0; a < this._timers.length; a++) this._timers[a].destroy();
  6493. this._timers = [], this.events.removeAll()
  6494. },
  6495. update: function(a) {
  6496. 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)
  6497. 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--)
  6498. },
  6499. gamePaused: function() {
  6500. this._pauseStarted = this.now, this.events.pause();
  6501. for (var a = this._timers.length; a--;) this._timers[a]._pause()
  6502. },
  6503. gameResumed: function() {
  6504. this.time = this.now = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume();
  6505. for (var a = this._timers.length; a--;) this._timers[a]._resume()
  6506. },
  6507. totalElapsedSeconds: function() {
  6508. return .001 * (this.now - this._started)
  6509. },
  6510. elapsedSince: function(a) {
  6511. return this.now - a
  6512. },
  6513. elapsedSecondsSince: function(a) {
  6514. return .001 * (this.now - a)
  6515. },
  6516. reset: function() {
  6517. this._started = this.now, this.removeAll()
  6518. }
  6519. }, b.Time.prototype.constructor = b.Time, b.Timer = function(a, c) {
  6520. "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
  6521. }, b.Timer.MINUTE = 6e4, b.Timer.SECOND = 1e3, b.Timer.HALF = 500, b.Timer.QUARTER = 250, b.Timer.prototype = {
  6522. create: function(a, c, d, e, f, g) {
  6523. var h = a;
  6524. h += 0 === this._now ? this.game.time.now : this._now;
  6525. var i = new b.TimerEvent(this, a, h, d, c, e, f, g);
  6526. return this.events.push(i), this.order(), this.expired = !1, i
  6527. },
  6528. add: function(a, b, c) {
  6529. return this.create(a, !1, 0, b, c, Array.prototype.splice.call(arguments, 3))
  6530. },
  6531. repeat: function(a, b, c, d) {
  6532. return this.create(a, !1, b, c, d, Array.prototype.splice.call(arguments, 4))
  6533. },
  6534. loop: function(a, b, c) {
  6535. return this.create(a, !0, 0, b, c, Array.prototype.splice.call(arguments, 3))
  6536. },
  6537. start: function(a) {
  6538. if (!this.running) {
  6539. this._started = this.game.time.now + (a || 0), this.running = !0;
  6540. for (var b = 0; b < this.events.length; b++) this.events[b].tick = this.events[b].delay + this._started
  6541. }
  6542. },
  6543. stop: function(a) {
  6544. this.running = !1, "undefined" == typeof a && (a = !0), a && (this.events.length = 0)
  6545. },
  6546. remove: function(a) {
  6547. for (var b = 0; b < this.events.length; b++)
  6548. if (this.events[b] === a) return this.events[b].pendingDelete = !0, !0;
  6549. return !1
  6550. },
  6551. order: function() {
  6552. this.events.length > 0 && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick)
  6553. },
  6554. sortHandler: function(a, b) {
  6555. return a.tick < b.tick ? -1 : a.tick > b.tick ? 1 : 0
  6556. },
  6557. clearPendingEvents: function() {
  6558. for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
  6559. this._len = this.events.length, this._i = 0
  6560. },
  6561. update: function(a) {
  6562. if (this.paused) return !0;
  6563. 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) {
  6564. 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++;
  6565. this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
  6566. }
  6567. return this.expired && this.autoDestroy ? !1 : !0
  6568. },
  6569. pause: function() {
  6570. this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.now, this.paused = !0))
  6571. },
  6572. _pause: function() {
  6573. !this.paused && this.running && (this._pauseStarted = this.game.time.now, this.paused = !0)
  6574. },
  6575. adjustEvents: function(a) {
  6576. for (var b = 0; b < this.events.length; b++)
  6577. if (!this.events[b].pendingDelete) {
  6578. var c = this.events[b].tick - a;
  6579. 0 > c && (c = 0), this.events[b].tick = this._now + c
  6580. }
  6581. var d = this.nextTick - a;
  6582. this.nextTick = 0 > d ? this._now : this._now + d
  6583. },
  6584. resume: function() {
  6585. if (this.paused) {
  6586. var a = this.game.time.now;
  6587. this._pauseTotal += a - this._now, this._now = a, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
  6588. }
  6589. },
  6590. _resume: function() {
  6591. this._codePaused || this.resume()
  6592. },
  6593. removeAll: function() {
  6594. this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0
  6595. },
  6596. destroy: function() {
  6597. this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0
  6598. }
  6599. }, Object.defineProperty(b.Timer.prototype, "next", {
  6600. get: function() {
  6601. return this.nextTick
  6602. }
  6603. }), Object.defineProperty(b.Timer.prototype, "duration", {
  6604. get: function() {
  6605. return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0
  6606. }
  6607. }), Object.defineProperty(b.Timer.prototype, "length", {
  6608. get: function() {
  6609. return this.events.length
  6610. }
  6611. }), Object.defineProperty(b.Timer.prototype, "ms", {
  6612. get: function() {
  6613. return this.running ? this._now - this._started - this._pauseTotal : 0
  6614. }
  6615. }), Object.defineProperty(b.Timer.prototype, "seconds", {
  6616. get: function() {
  6617. return this.running ? .001 * this.ms : 0
  6618. }
  6619. }), b.Timer.prototype.constructor = b.Timer, b.TimerEvent = function(a, b, c, d, e, f, g, h) {
  6620. 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
  6621. }, b.TimerEvent.prototype.constructor = b.TimerEvent, b.AnimationManager = function(a) {
  6622. 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 = []
  6623. }, b.AnimationManager.prototype = {
  6624. loadFrameData: function(a, b) {
  6625. if (this.isLoaded)
  6626. for (var c in this._anims) this._anims[c].updateFrameData(a);
  6627. 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
  6628. },
  6629. add: function(a, c, d, e, f) {
  6630. return null === this._frameData ? void console.warn("No FrameData available for Phaser.Animation " + a) : (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])
  6631. },
  6632. validateFrames: function(a, b) {
  6633. "undefined" == typeof b && (b = !0);
  6634. for (var c = 0; c < a.length; c++)
  6635. if (b === !0) {
  6636. if (a[c] > this._frameData.total) return !1
  6637. } else if (this._frameData.checkFrameName(a[c]) === !1) return !1;
  6638. return !0
  6639. },
  6640. play: function(a, b, c, d) {
  6641. 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
  6642. },
  6643. stop: function(a, b) {
  6644. "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)
  6645. },
  6646. update: function() {
  6647. return this.updateIfVisible && !this.sprite.visible ? !1 : this.currentAnim && this.currentAnim.update() === !0 ? (this.currentFrame = this.currentAnim.currentFrame, !0) : !1
  6648. },
  6649. next: function(a) {
  6650. this.currentAnim && (this.currentAnim.next(a), this.currentFrame = this.currentAnim.currentFrame)
  6651. },
  6652. previous: function(a) {
  6653. this.currentAnim && (this.currentAnim.previous(a), this.currentFrame = this.currentAnim.currentFrame)
  6654. },
  6655. getAnimation: function(a) {
  6656. return "string" == typeof a && this._anims[a] ? this._anims[a] : null
  6657. },
  6658. refreshFrame: function() {
  6659. this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)
  6660. },
  6661. destroy: function() {
  6662. var a = null;
  6663. for (var a in this._anims) this._anims.hasOwnProperty(a) && this._anims[a].destroy();
  6664. this._anims = {}, this._frameData = null, this._frameIndex = 0, this.currentAnim = null, this.currentFrame = null
  6665. }
  6666. }, b.AnimationManager.prototype.constructor = b.AnimationManager, Object.defineProperty(b.AnimationManager.prototype, "frameData", {
  6667. get: function() {
  6668. return this._frameData
  6669. }
  6670. }), Object.defineProperty(b.AnimationManager.prototype, "frameTotal", {
  6671. get: function() {
  6672. return this._frameData ? this._frameData.total : -1
  6673. }
  6674. }), Object.defineProperty(b.AnimationManager.prototype, "paused", {
  6675. get: function() {
  6676. return this.currentAnim.isPaused
  6677. },
  6678. set: function(a) {
  6679. this.currentAnim.paused = a
  6680. }
  6681. }), Object.defineProperty(b.AnimationManager.prototype, "frame", {
  6682. get: function() {
  6683. return this.currentFrame ? this._frameIndex : void 0
  6684. },
  6685. set: function(a) {
  6686. "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)))
  6687. }
  6688. }), Object.defineProperty(b.AnimationManager.prototype, "frameName", {
  6689. get: function() {
  6690. return this.currentFrame ? this.currentFrame.name : void 0
  6691. },
  6692. set: function(a) {
  6693. "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)
  6694. }
  6695. }), b.Animation = function(a, c, d, e, f, g, h) {
  6696. 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)
  6697. }, b.Animation.prototype = {
  6698. play: function(a, b, c) {
  6699. 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
  6700. },
  6701. restart: function() {
  6702. 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)
  6703. },
  6704. setFrame: function(a, b) {
  6705. var c;
  6706. if ("undefined" == typeof b && (b = !1), "string" == typeof a)
  6707. for (var d = 0; d < this._frames.length; d++) this._frameData.getFrame(this._frames[d]).name === a && (c = d);
  6708. else if ("number" == typeof a)
  6709. if (b) c = a;
  6710. else
  6711. for (var d = 0; d < this._frames.length; d++) this.frames[d] === c && (c = d);
  6712. c && (this._frameIndex = c - 1, this._timeNextFrame = this.game.time.now, this.update())
  6713. },
  6714. stop: function(a, b) {
  6715. "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))
  6716. },
  6717. onPause: function() {
  6718. this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.now)
  6719. },
  6720. onResume: function() {
  6721. this.isPlaying && (this._timeNextFrame = this.game.time.now + this._frameDiff)
  6722. },
  6723. update: function() {
  6724. 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
  6725. },
  6726. next: function(a) {
  6727. "undefined" == typeof a && (a = 1);
  6728. var b = this._frameIndex + a;
  6729. 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)))
  6730. },
  6731. previous: function(a) {
  6732. "undefined" == typeof a && (a = 1);
  6733. var b = this._frameIndex - a;
  6734. 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)))
  6735. },
  6736. updateFrameData: function(a) {
  6737. this._frameData = a, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null
  6738. },
  6739. destroy: function() {
  6740. 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()
  6741. },
  6742. complete: function() {
  6743. 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()
  6744. }
  6745. }, b.Animation.prototype.constructor = b.Animation, Object.defineProperty(b.Animation.prototype, "paused", {
  6746. get: function() {
  6747. return this.isPaused
  6748. },
  6749. set: function(a) {
  6750. this.isPaused = a, a ? this._pauseStartTime = this.game.time.now : this.isPlaying && (this._timeNextFrame = this.game.time.now + this.delay)
  6751. }
  6752. }), Object.defineProperty(b.Animation.prototype, "frameTotal", {
  6753. get: function() {
  6754. return this._frames.length
  6755. }
  6756. }), Object.defineProperty(b.Animation.prototype, "frame", {
  6757. get: function() {
  6758. return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex
  6759. },
  6760. set: function(a) {
  6761. this.currentFrame = this._frameData.getFrame(this._frames[a]), null !== this.currentFrame && (this._frameIndex = a, this._parent.setFrame(this.currentFrame))
  6762. }
  6763. }), Object.defineProperty(b.Animation.prototype, "speed", {
  6764. get: function() {
  6765. return Math.round(1e3 / this.delay)
  6766. },
  6767. set: function(a) {
  6768. a >= 1 && (this.delay = 1e3 / a)
  6769. }
  6770. }), b.Animation.generateFrameNames = function(a, c, d, e, f) {
  6771. "undefined" == typeof e && (e = "");
  6772. var g = [],
  6773. h = "";
  6774. if (d > c)
  6775. for (var 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);
  6776. else
  6777. for (var 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);
  6778. return g
  6779. }, b.Frame = function(a, c, d, e, f, g, h) {
  6780. 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
  6781. }, b.Frame.prototype = {
  6782. setTrim: function(a, b, c, d, e, f, g) {
  6783. 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)
  6784. },
  6785. getRect: function(a) {
  6786. 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
  6787. }
  6788. }, b.Frame.prototype.constructor = b.Frame, b.FrameData = function() {
  6789. this._frames = [], this._frameNames = []
  6790. }, b.FrameData.prototype = {
  6791. addFrame: function(a) {
  6792. return a.index = this._frames.length, this._frames.push(a), "" !== a.name && (this._frameNames[a.name] = a.index), a
  6793. },
  6794. getFrame: function(a) {
  6795. return a > this._frames.length && (a = 0), this._frames[a]
  6796. },
  6797. getFrameByName: function(a) {
  6798. return "number" == typeof this._frameNames[a] ? this._frames[this._frameNames[a]] : null
  6799. },
  6800. checkFrameName: function(a) {
  6801. return null == this._frameNames[a] ? !1 : !0
  6802. },
  6803. getFrameRange: function(a, b, c) {
  6804. "undefined" == typeof c && (c = []);
  6805. for (var d = a; b >= d; d++) c.push(this._frames[d]);
  6806. return c
  6807. },
  6808. getFrames: function(a, b, c) {
  6809. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  6810. for (var d = 0; d < this._frames.length; d++) c.push(this._frames[d]);
  6811. else
  6812. for (var d = 0, e = a.length; e > d; d++) c.push(b ? this.getFrame(a[d]) : this.getFrameByName(a[d]));
  6813. return c
  6814. },
  6815. getFrameIndexes: function(a, b, c) {
  6816. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  6817. for (var d = 0, e = this._frames.length; e > d; d++) c.push(this._frames[d].index);
  6818. else
  6819. for (var d = 0, e = a.length; e > d; d++) b ? c.push(a[d]) : this.getFrameByName(a[d]) && c.push(this.getFrameByName(a[d]).index);
  6820. return c
  6821. }
  6822. }, b.FrameData.prototype.constructor = b.FrameData, Object.defineProperty(b.FrameData.prototype, "total", {
  6823. get: function() {
  6824. return this._frames.length
  6825. }
  6826. }), b.AnimationParser = {
  6827. spriteSheet: function(a, c, d, e, f, g, h) {
  6828. var i = a.cache.getImage(c);
  6829. if (null == i) return null;
  6830. var j = i.width,
  6831. k = i.height;
  6832. 0 >= d && (d = Math.floor(-j / Math.min(-1, d))), 0 >= e && (e = Math.floor(-k / Math.min(-1, e)));
  6833. var l = Math.floor((j - g) / (d + h)),
  6834. m = Math.floor((k - g) / (e + h)),
  6835. n = l * m;
  6836. if (-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;
  6837. for (var o = new b.FrameData, p = g, q = g, r = 0; n > r; r++) {
  6838. var s = a.rnd.uuid();
  6839. o.addFrame(new b.Frame(r, p, q, d, e, "", s)), PIXI.TextureCache[s] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  6840. x: p,
  6841. y: q,
  6842. width: d,
  6843. height: e
  6844. }), p += d + h, p + d > j && (p = g, q += e + h)
  6845. }
  6846. return o
  6847. },
  6848. JSONData: function(a, c, d) {
  6849. if (!c.frames) return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"), void console.log(c);
  6850. for (var e, f = new b.FrameData, g = c.frames, h = 0; h < g.length; h++) {
  6851. var i = a.rnd.uuid();
  6852. e = f.addFrame(new b.Frame(h, g[h].frame.x, g[h].frame.y, g[h].frame.w, g[h].frame.h, g[h].filename, i)), PIXI.TextureCache[i] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  6853. x: g[h].frame.x,
  6854. y: g[h].frame.y,
  6855. width: g[h].frame.w,
  6856. height: g[h].frame.h
  6857. }), g[h].trimmed && e.setTrim(g[h].trimmed, g[h].sourceSize.w, g[h].sourceSize.h, g[h].spriteSourceSize.x, g[h].spriteSourceSize.y, g[h].spriteSourceSize.w, g[h].spriteSourceSize.h)
  6858. }
  6859. return f
  6860. },
  6861. JSONDataHash: function(a, c, d) {
  6862. if (!c.frames) return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"), void console.log(c);
  6863. var e, f = new b.FrameData,
  6864. g = c.frames,
  6865. h = 0;
  6866. for (var i in g) {
  6867. var j = a.rnd.uuid();
  6868. e = f.addFrame(new b.Frame(h, g[i].frame.x, g[i].frame.y, g[i].frame.w, g[i].frame.h, i, j)), PIXI.TextureCache[j] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  6869. x: g[i].frame.x,
  6870. y: g[i].frame.y,
  6871. width: g[i].frame.w,
  6872. height: g[i].frame.h
  6873. }), g[i].trimmed && e.setTrim(g[i].trimmed, g[i].sourceSize.w, g[i].sourceSize.h, g[i].spriteSourceSize.x, g[i].spriteSourceSize.y, g[i].spriteSourceSize.w, g[i].spriteSourceSize.h), h++
  6874. }
  6875. return f
  6876. },
  6877. XMLData: function(a, c, d) {
  6878. if (!c.getElementsByTagName("TextureAtlas")) return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
  6879. for (var e, f, g, h, i, j, k, l, m, n, o, p, q = new b.FrameData, r = c.getElementsByTagName("SubTexture"), s = 0; s < r.length; s++) f = a.rnd.uuid(), h = r[s].attributes, g = h.name.nodeValue, i = parseInt(h.x.nodeValue, 10), j = parseInt(h.y.nodeValue, 10), k = parseInt(h.width.nodeValue, 10), l = parseInt(h.height.nodeValue, 10), m = null, n = null, h.frameX && (m = Math.abs(parseInt(h.frameX.nodeValue, 10)), n = Math.abs(parseInt(h.frameY.nodeValue, 10)), o = parseInt(h.frameWidth.nodeValue, 10), p = parseInt(h.frameHeight.nodeValue, 10)), e = q.addFrame(new b.Frame(s, i, j, k, l, g, f)), PIXI.TextureCache[f] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  6880. x: i,
  6881. y: j,
  6882. width: k,
  6883. height: l
  6884. }), (null !== m || null !== n) && e.setTrim(!0, k, l, m, n, o, p);
  6885. return q
  6886. }
  6887. }, b.Cache = function(a) {
  6888. 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
  6889. }, 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 = {
  6890. addCanvas: function(a, b, c) {
  6891. this._canvases[a] = {
  6892. canvas: b,
  6893. context: c
  6894. }
  6895. },
  6896. addBinary: function(a, b) {
  6897. this._binary[a] = b
  6898. },
  6899. addBitmapData: function(a, b) {
  6900. return this._bitmapDatas[a] = b, b
  6901. },
  6902. addRenderTexture: function(a, c) {
  6903. var d = new b.Frame(0, 0, 0, c.width, c.height, "", "");
  6904. this._textures[a] = {
  6905. texture: c,
  6906. frame: d
  6907. }
  6908. },
  6909. addSpriteSheet: function(a, c, d, e, f, g, h, i) {
  6910. this._images[a] = {
  6911. url: c,
  6912. data: d,
  6913. spriteSheet: !0,
  6914. frameWidth: e,
  6915. frameHeight: f,
  6916. margin: h,
  6917. spacing: i
  6918. }, 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)
  6919. },
  6920. addTilemap: function(a, b, c, d) {
  6921. this._tilemaps[a] = {
  6922. url: b,
  6923. data: c,
  6924. format: d
  6925. }
  6926. },
  6927. addTextureAtlas: function(a, c, d, e, f) {
  6928. this._images[a] = {
  6929. url: c,
  6930. data: d,
  6931. spriteSheet: !0
  6932. }, 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))
  6933. },
  6934. addBitmapFont: function(a, c, d, e, f, g) {
  6935. this._images[a] = {
  6936. url: c,
  6937. data: d,
  6938. spriteSheet: !0
  6939. }, 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)
  6940. },
  6941. addPhysicsData: function(a, b, c, d) {
  6942. this._physics[a] = {
  6943. url: b,
  6944. data: c,
  6945. format: d
  6946. }
  6947. },
  6948. addDefaultImage: function() {
  6949. var a = new Image;
  6950. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==", this._images.__default = {
  6951. url: null,
  6952. data: a,
  6953. spriteSheet: !1
  6954. }, 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)
  6955. },
  6956. addMissingImage: function() {
  6957. var a = new Image;
  6958. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==", this._images.__missing = {
  6959. url: null,
  6960. data: a,
  6961. spriteSheet: !1
  6962. }, 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)
  6963. },
  6964. addText: function(a, b, c) {
  6965. this._text[a] = {
  6966. url: b,
  6967. data: c
  6968. }
  6969. },
  6970. addJSON: function(a, b, c) {
  6971. this._json[a] = {
  6972. url: b,
  6973. data: c
  6974. }
  6975. },
  6976. addImage: function(a, c, d) {
  6977. this._images[a] = {
  6978. url: c,
  6979. data: d,
  6980. spriteSheet: !1
  6981. }, 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])
  6982. },
  6983. addSound: function(a, b, c, d, e) {
  6984. d = d || !0, e = e || !1;
  6985. var f = !1;
  6986. e && (f = !0), this._sounds[a] = {
  6987. url: b,
  6988. data: c,
  6989. isDecoding: !1,
  6990. decoded: f,
  6991. webAudio: d,
  6992. audioTag: e,
  6993. locked: this.game.sound.touchLocked
  6994. }
  6995. },
  6996. reloadSound: function(a) {
  6997. var b = this;
  6998. this._sounds[a] && (this._sounds[a].data.src = this._sounds[a].url, this._sounds[a].data.addEventListener("canplaythrough", function() {
  6999. return b.reloadSoundComplete(a)
  7000. }, !1), this._sounds[a].data.load())
  7001. },
  7002. reloadSoundComplete: function(a) {
  7003. this._sounds[a] && (this._sounds[a].locked = !1, this.onSoundUnlock.dispatch(a))
  7004. },
  7005. updateSound: function(a, b, c) {
  7006. this._sounds[a] && (this._sounds[a][b] = c)
  7007. },
  7008. decodedSound: function(a, b) {
  7009. this._sounds[a].data = b, this._sounds[a].decoded = !0, this._sounds[a].isDecoding = !1
  7010. },
  7011. getCanvas: function(a) {
  7012. return this._canvases[a] ? this._canvases[a].canvas : void console.warn('Phaser.Cache.getCanvas: Invalid key: "' + a + '"')
  7013. },
  7014. getBitmapData: function(a) {
  7015. return this._bitmapDatas[a] ? this._bitmapDatas[a] : void console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + a + '"')
  7016. },
  7017. getBitmapFont: function(a) {
  7018. return this._bitmapFont[a] ? this._bitmapFont[a] : void console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + a + '"')
  7019. },
  7020. getPhysicsData: function(a, b, c) {
  7021. if ("undefined" == typeof b || null === b) {
  7022. if (this._physics[a]) return this._physics[a].data;
  7023. console.warn('Phaser.Cache.getPhysicsData: Invalid key: "' + a + '"')
  7024. } else if (this._physics[a] && this._physics[a].data[b]) {
  7025. var d = this._physics[a].data[b];
  7026. if (!d || !c) return d;
  7027. for (var e in d)
  7028. if (e = d[e], e.fixtureKey === c) return e;
  7029. console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "' + c + " in " + a + '"')
  7030. } else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + a + " / " + b + '"');
  7031. return null
  7032. },
  7033. checkKey: function(a, b) {
  7034. return this._cacheMap[a][b] ? !0 : !1
  7035. },
  7036. checkCanvasKey: function(a) {
  7037. return this.checkKey(b.Cache.CANVAS, a)
  7038. },
  7039. checkImageKey: function(a) {
  7040. return this.checkKey(b.Cache.IMAGE, a)
  7041. },
  7042. checkTextureKey: function(a) {
  7043. return this.checkKey(b.Cache.TEXTURE, a)
  7044. },
  7045. checkSoundKey: function(a) {
  7046. return this.checkKey(b.Cache.SOUND, a)
  7047. },
  7048. checkTextKey: function(a) {
  7049. return this.checkKey(b.Cache.TEXT, a)
  7050. },
  7051. checkPhysicsKey: function(a) {
  7052. return this.checkKey(b.Cache.PHYSICS, a)
  7053. },
  7054. checkTilemapKey: function(a) {
  7055. return this.checkKey(b.Cache.TILEMAP, a)
  7056. },
  7057. checkBinaryKey: function(a) {
  7058. return this.checkKey(b.Cache.BINARY, a)
  7059. },
  7060. checkBitmapDataKey: function(a) {
  7061. return this.checkKey(b.Cache.BITMAPDATA, a)
  7062. },
  7063. checkBitmapFontKey: function(a) {
  7064. return this.checkKey(b.Cache.BITMAPFONT, a)
  7065. },
  7066. checkJSONKey: function(a) {
  7067. return this.checkKey(b.Cache.JSON, a)
  7068. },
  7069. getImage: function(a) {
  7070. return this._images[a] ? this._images[a].data : void console.warn('Phaser.Cache.getImage: Invalid key: "' + a + '"')
  7071. },
  7072. getTilemapData: function(a) {
  7073. return this._tilemaps[a] ? this._tilemaps[a] : void console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + a + '"')
  7074. },
  7075. getFrameData: function(a) {
  7076. return this._images[a] && this._images[a].frameData ? this._images[a].frameData : null
  7077. },
  7078. updateFrameData: function(a, b) {
  7079. this._images[a] && (this._images[a].spriteSheet = !0, this._images[a].frameData = b)
  7080. },
  7081. getFrameByIndex: function(a, b) {
  7082. return this._images[a] && this._images[a].frameData ? this._images[a].frameData.getFrame(b) : null
  7083. },
  7084. getFrameByName: function(a, b) {
  7085. return this._images[a] && this._images[a].frameData ? this._images[a].frameData.getFrameByName(b) : null
  7086. },
  7087. getFrame: function(a) {
  7088. return this._images[a] && this._images[a].spriteSheet === !1 ? this._images[a].frame : null
  7089. },
  7090. getTextureFrame: function(a) {
  7091. return this._textures[a] ? this._textures[a].frame : null
  7092. },
  7093. getTexture: function(a) {
  7094. return this._textures[a] ? this._textures[a] : void console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"')
  7095. },
  7096. getSound: function(a) {
  7097. return this._sounds[a] ? this._sounds[a] : void console.warn('Phaser.Cache.getSound: Invalid key: "' + a + '"')
  7098. },
  7099. getSoundData: function(a) {
  7100. return this._sounds[a] ? this._sounds[a].data : void console.warn('Phaser.Cache.getSoundData: Invalid key: "' + a + '"')
  7101. },
  7102. isSoundDecoded: function(a) {
  7103. return this._sounds[a] ? this._sounds[a].decoded : void 0
  7104. },
  7105. isSoundReady: function(a) {
  7106. return this._sounds[a] && this._sounds[a].decoded && this.game.sound.touchLocked === !1
  7107. },
  7108. isSpriteSheet: function(a) {
  7109. return this._images[a] ? this._images[a].spriteSheet : !1
  7110. },
  7111. getText: function(a) {
  7112. return this._text[a] ? this._text[a].data : void console.warn('Phaser.Cache.getText: Invalid key: "' + a + '"')
  7113. },
  7114. getJSON: function(a) {
  7115. return this._json[a] ? this._json[a].data : void console.warn('Phaser.Cache.getJSON: Invalid key: "' + a + '"')
  7116. },
  7117. getBinary: function(a) {
  7118. return this._binary[a] ? this._binary[a] : void console.warn('Phaser.Cache.getBinary: Invalid key: "' + a + '"')
  7119. },
  7120. getKeys: function(a) {
  7121. var c = null;
  7122. switch (a) {
  7123. case b.Cache.CANVAS:
  7124. c = this._canvases;
  7125. break;
  7126. case b.Cache.IMAGE:
  7127. c = this._images;
  7128. break;
  7129. case b.Cache.TEXTURE:
  7130. c = this._textures;
  7131. break;
  7132. case b.Cache.SOUND:
  7133. c = this._sounds;
  7134. break;
  7135. case b.Cache.TEXT:
  7136. c = this._text;
  7137. break;
  7138. case b.Cache.PHYSICS:
  7139. c = this._physics;
  7140. break;
  7141. case b.Cache.TILEMAP:
  7142. c = this._tilemaps;
  7143. break;
  7144. case b.Cache.BINARY:
  7145. c = this._binary;
  7146. break;
  7147. case b.Cache.BITMAPDATA:
  7148. c = this._bitmapDatas;
  7149. break;
  7150. case b.Cache.BITMAPFONT:
  7151. c = this._bitmapFont;
  7152. break;
  7153. case b.Cache.JSON:
  7154. c = this._json
  7155. }
  7156. if (c) {
  7157. var d = [];
  7158. for (var e in c) "__default" !== e && "__missing" !== e && d.push(e);
  7159. return d
  7160. }
  7161. },
  7162. removeCanvas: function(a) {
  7163. delete this._canvases[a]
  7164. },
  7165. removeImage: function(a) {
  7166. delete this._images[a]
  7167. },
  7168. removeSound: function(a) {
  7169. delete this._sounds[a]
  7170. },
  7171. removeText: function(a) {
  7172. delete this._text[a]
  7173. },
  7174. removeJSON: function(a) {
  7175. delete this._json[a]
  7176. },
  7177. removePhysics: function(a) {
  7178. delete this._physics[a]
  7179. },
  7180. removeTilemap: function(a) {
  7181. delete this._tilemaps[a]
  7182. },
  7183. removeBinary: function(a) {
  7184. delete this._binary[a]
  7185. },
  7186. removeBitmapData: function(a) {
  7187. delete this._bitmapDatas[a]
  7188. },
  7189. removeBitmapFont: function(a) {
  7190. delete this._bitmapFont[a]
  7191. },
  7192. destroy: function() {
  7193. for (var a in this._canvases) delete this._canvases[a];
  7194. for (var a in this._images) "__default" !== a && "__missing" !== a && delete this._images[a];
  7195. for (var a in this._sounds) delete this._sounds[a];
  7196. for (var a in this._text) delete this._text[a];
  7197. for (var a in this._json) delete this._json[a];
  7198. for (var a in this._textures) delete this._textures[a];
  7199. for (var a in this._physics) delete this._physics[a];
  7200. for (var a in this._tilemaps) delete this._tilemaps[a];
  7201. for (var a in this._binary) delete this._binary[a];
  7202. for (var a in this._bitmapDatas) delete this._bitmapDatas[a];
  7203. for (var a in this._bitmapFont) delete this._bitmapFont[a]
  7204. }
  7205. }, b.Cache.prototype.constructor = b.Cache, b.Loader = function(a) {
  7206. 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
  7207. }, 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 = {
  7208. setPreloadSprite: function(a, c) {
  7209. c = c || 0, this.preloadSprite = {
  7210. sprite: a,
  7211. direction: c,
  7212. width: a.width,
  7213. height: a.height,
  7214. rect: null
  7215. }, 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
  7216. },
  7217. checkKeyExists: function(a, b) {
  7218. if (this._fileList.length > 0)
  7219. for (var c = 0; c < this._fileList.length; c++)
  7220. if (this._fileList[c].type === a && this._fileList[c].key === b) return !0;
  7221. return !1
  7222. },
  7223. getAssetIndex: function(a, b) {
  7224. if (this._fileList.length > 0)
  7225. for (var c = 0; c < this._fileList.length; c++)
  7226. if (this._fileList[c].type === a && this._fileList[c].key === b) return c;
  7227. return -1
  7228. },
  7229. getAsset: function(a, b) {
  7230. if (this._fileList.length > 0)
  7231. for (var c = 0; c < this._fileList.length; c++)
  7232. if (this._fileList[c].type === a && this._fileList[c].key === b) return {
  7233. index: c,
  7234. file: this._fileList[c]
  7235. };
  7236. return !1
  7237. },
  7238. reset: function() {
  7239. this.preloadSprite = null, this.isLoading = !1, this._packList.length = 0, this._packIndex = 0, this._fileList.length = 0, this._fileIndex = 0
  7240. },
  7241. addToFileList: function(a, b, c, d) {
  7242. var e = {
  7243. type: a,
  7244. key: b,
  7245. url: c,
  7246. data: null,
  7247. error: !1,
  7248. loaded: !1
  7249. };
  7250. if ("undefined" != typeof d)
  7251. for (var f in d) e[f] = d[f];
  7252. this.checkKeyExists(a, b) === !1 && this._fileList.push(e)
  7253. },
  7254. replaceInFileList: function(a, b, c, d) {
  7255. var e = {
  7256. type: a,
  7257. key: b,
  7258. url: c,
  7259. data: null,
  7260. error: !1,
  7261. loaded: !1
  7262. };
  7263. if ("undefined" != typeof d)
  7264. for (var f in d) e[f] = d[f];
  7265. var g = this.getAssetIndex(a, b); - 1 === g ? this._fileList.push(e) : this._fileList[g] = e
  7266. },
  7267. pack: function(a, b, c, d) {
  7268. 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({
  7269. key: a,
  7270. url: b,
  7271. data: c,
  7272. loaded: !1,
  7273. error: !1,
  7274. callbackContext: d
  7275. }), this)
  7276. },
  7277. image: function(a, b, c) {
  7278. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("image", a, b) : this.addToFileList("image", a, b), this
  7279. },
  7280. text: function(a, b, c) {
  7281. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("text", a, b) : this.addToFileList("text", a, b), this
  7282. },
  7283. json: function(a, b, c) {
  7284. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("json", a, b) : this.addToFileList("json", a, b), this
  7285. },
  7286. script: function(a, b, c, d) {
  7287. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("script", a, b, {
  7288. callback: c,
  7289. callbackContext: d
  7290. }), this
  7291. },
  7292. binary: function(a, b, c, d) {
  7293. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("binary", a, b, {
  7294. callback: c,
  7295. callbackContext: d
  7296. }), this
  7297. },
  7298. spritesheet: function(a, b, c, d, e, f, g) {
  7299. return "undefined" == typeof e && (e = -1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), this.addToFileList("spritesheet", a, b, {
  7300. frameWidth: c,
  7301. frameHeight: d,
  7302. frameMax: e,
  7303. margin: f,
  7304. spacing: g
  7305. }), this
  7306. },
  7307. audio: function(a, b, c) {
  7308. return "undefined" == typeof c && (c = !0), this.addToFileList("audio", a, b, {
  7309. buffer: null,
  7310. autoDecode: c
  7311. }), this
  7312. },
  7313. tilemap: function(a, c, d, e) {
  7314. 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;
  7315. if (d) {
  7316. switch (e) {
  7317. case b.Tilemap.CSV:
  7318. break;
  7319. case b.Tilemap.TILED_JSON:
  7320. "string" == typeof d && (d = JSON.parse(d))
  7321. }
  7322. this.game.cache.addTilemap(a, null, d, e)
  7323. } else this.addToFileList("tilemap", a, c, {
  7324. format: e
  7325. });
  7326. return this
  7327. },
  7328. physics: function(a, c, d, e) {
  7329. 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, {
  7330. format: e
  7331. }), this)
  7332. },
  7333. bitmapFont: function(a, b, c, d, e, f) {
  7334. 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, {
  7335. xmlURL: c,
  7336. xSpacing: e,
  7337. ySpacing: f
  7338. });
  7339. else if ("string" == typeof d) {
  7340. var g;
  7341. try {
  7342. if (window.DOMParser) {
  7343. var h = new DOMParser;
  7344. g = h.parseFromString(d, "text/xml")
  7345. } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(d)
  7346. } catch (i) {
  7347. g = void 0
  7348. }
  7349. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
  7350. this.addToFileList("bitmapfont", a, b, {
  7351. xmlURL: null,
  7352. xmlData: g,
  7353. xSpacing: e,
  7354. ySpacing: f
  7355. })
  7356. }
  7357. return this
  7358. },
  7359. atlasJSONArray: function(a, c, d, e) {
  7360. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_ARRAY)
  7361. },
  7362. atlasJSONHash: function(a, c, d, e) {
  7363. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_HASH)
  7364. },
  7365. atlasXML: function(a, c, d, e) {
  7366. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_XML_STARLING)
  7367. },
  7368. atlas: function(a, c, d, e, f) {
  7369. 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, {
  7370. atlasURL: d,
  7371. format: f
  7372. });
  7373. else {
  7374. switch (f) {
  7375. case b.Loader.TEXTURE_ATLAS_JSON_ARRAY:
  7376. "string" == typeof e && (e = JSON.parse(e));
  7377. break;
  7378. case b.Loader.TEXTURE_ATLAS_XML_STARLING:
  7379. if ("string" == typeof e) {
  7380. var g;
  7381. try {
  7382. if (window.DOMParser) {
  7383. var h = new DOMParser;
  7384. g = h.parseFromString(e, "text/xml")
  7385. } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(e)
  7386. } catch (i) {
  7387. g = void 0
  7388. }
  7389. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
  7390. e = g
  7391. }
  7392. }
  7393. this.addToFileList("textureatlas", a, c, {
  7394. atlasURL: null,
  7395. atlasData: e,
  7396. format: f
  7397. })
  7398. }
  7399. return this
  7400. },
  7401. removeFile: function(a, b) {
  7402. var c = this.getAsset(a, b);
  7403. c !== !1 && this._fileList.splice(c.index, 1)
  7404. },
  7405. removeAll: function() {
  7406. this._fileList.length = 0
  7407. },
  7408. start: function() {
  7409. this.isLoading || (this._packList.length > 0 ? (this._packIndex = 0, this.loadPack()) : this.beginLoad())
  7410. },
  7411. beginLoad: function() {
  7412. 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())
  7413. },
  7414. loadPack: function() {
  7415. if (!this._packList[this._packIndex]) return void console.warn("Phaser.Loader loadPackList invalid index " + this._packIndex);
  7416. var a = this._packList[this._packIndex];
  7417. null !== a.data ? this.packLoadComplete(this._packIndex, !1) : this.xhrLoad(this._packIndex, this.baseURL + a.url, "text", "packLoadComplete", "packLoadError")
  7418. },
  7419. packLoadComplete: function(a, c) {
  7420. if ("undefined" == typeof c && (c = !0), !this._packList[a]) return void console.warn("Phaser.Loader packLoadComplete invalid index " + a);
  7421. var d = this._packList[a];
  7422. if (d.loaded = !0, c) var e = JSON.parse(this._xhr.responseText);
  7423. else var e = this._packList[a].data; if (e[d.key])
  7424. for (var f, g = 0; g < e[d.key].length; g++) switch (f = e[d.key][g], f.type) {
  7425. case "image":
  7426. this.image(f.key, f.url, f.overwrite);
  7427. break;
  7428. case "text":
  7429. this.text(f.key, f.url, f.overwrite);
  7430. break;
  7431. case "json":
  7432. this.json(f.key, f.url, f.overwrite);
  7433. break;
  7434. case "script":
  7435. this.script(f.key, f.url, f.callback, d.callbackContext);
  7436. break;
  7437. case "binary":
  7438. this.binary(f.key, f.url, f.callback, d.callbackContext);
  7439. break;
  7440. case "spritesheet":
  7441. this.spritesheet(f.key, f.url, f.frameWidth, f.frameHeight, f.frameMax, f.margin, f.spacing);
  7442. break;
  7443. case "audio":
  7444. this.audio(f.key, f.urls, f.autoDecode);
  7445. break;
  7446. case "tilemap":
  7447. this.tilemap(f.key, f.url, f.data, b.Tilemap[f.format]);
  7448. break;
  7449. case "physics":
  7450. this.physics(f.key, f.url, f.data, b.Loader[f.format]);
  7451. break;
  7452. case "bitmapFont":
  7453. this.bitmapFont(f.key, f.textureURL, f.xmlURL, f.xmlData, f.xSpacing, f.ySpacing);
  7454. break;
  7455. case "atlasJSONArray":
  7456. this.atlasJSONArray(f.key, f.textureURL, f.atlasURL, f.atlasData);
  7457. break;
  7458. case "atlasJSONHash":
  7459. this.atlasJSONHash(f.key, f.textureURL, f.atlasURL, f.atlasData);
  7460. break;
  7461. case "atlasXML":
  7462. this.atlasXML(f.key, f.textureURL, f.atlasURL, f.atlasData);
  7463. break;
  7464. case "atlas":
  7465. this.atlas(f.key, f.textureURL, f.atlasURL, f.atlasData, b.Loader[f.format])
  7466. }
  7467. this.nextPack(a, !0)
  7468. },
  7469. packError: function(a) {
  7470. 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)
  7471. },
  7472. nextPack: function(a, b) {
  7473. this.onPackComplete.dispatch(this._packList[a].key, b, this.totalLoadedPacks(), this._packList.length), this._packIndex++, this._packIndex < this._packList.length ? this.loadPack() : this.beginLoad()
  7474. },
  7475. loadFile: function() {
  7476. if (!this._fileList[this._fileIndex]) return void console.warn("Phaser.Loader loadFile invalid index " + this._fileIndex);
  7477. var a = this._fileList[this._fileIndex],
  7478. c = this;
  7479. switch (this.onFileStart.dispatch(this.progress, a.key), a.type) {
  7480. case "image":
  7481. case "spritesheet":
  7482. case "textureatlas":
  7483. case "bitmapfont":
  7484. a.data = new Image, a.data.name = a.key, a.data.onload = function() {
  7485. return c.fileComplete(c._fileIndex)
  7486. }, a.data.onerror = function() {
  7487. return c.fileError(c._fileIndex)
  7488. }, this.crossOrigin && (a.data.crossOrigin = this.crossOrigin), a.data.src = this.baseURL + a.url;
  7489. break;
  7490. case "audio":
  7491. 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() {
  7492. return c.fileError(c._fileIndex)
  7493. }, 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);
  7494. break;
  7495. case "json":
  7496. window.XDomainRequest ? (this._ajax = new window.XDomainRequest, this._ajax.timeout = 3e3, this._ajax.onerror = function() {
  7497. return c.dataLoadError(c._fileIndex)
  7498. }, this._ajax.ontimeout = function() {
  7499. return c.dataLoadError(c._fileIndex)
  7500. }, this._ajax.onprogress = function() {}, this._ajax.onload = function() {
  7501. return c.jsonLoadComplete(c._fileIndex)
  7502. }, this._ajax.open("GET", this.baseURL + a.url, !0), this._ajax.send()) : this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  7503. break;
  7504. case "tilemap":
  7505. if (a.format === b.Tilemap.TILED_JSON) this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  7506. else {
  7507. if (a.format !== b.Tilemap.CSV) throw new Error("Phaser.Loader. Invalid Tilemap format: " + a.format);
  7508. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "csvLoadComplete", "dataLoadError")
  7509. }
  7510. break;
  7511. case "text":
  7512. case "script":
  7513. case "physics":
  7514. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "fileComplete", "fileError");
  7515. break;
  7516. case "binary":
  7517. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError")
  7518. }
  7519. },
  7520. xhrLoad: function(a, b, c, d, e) {
  7521. this._xhr.open("GET", b, !0), this._xhr.responseType = c;
  7522. var f = this;
  7523. this._xhr.onload = function() {
  7524. return f[d](a)
  7525. }, this._xhr.onerror = function() {
  7526. return f[e](a)
  7527. }, this._xhr.send()
  7528. },
  7529. getAudioURL: function(a) {
  7530. var b;
  7531. "string" == typeof a && (a = [a]);
  7532. for (var c = 0; c < a.length; c++)
  7533. if (b = a[c].toLowerCase(), b = b.substr((Math.max(0, b.lastIndexOf(".")) || 1 / 0) + 1), this.game.device.canPlayAudio(b)) return a[c];
  7534. return null
  7535. },
  7536. fileError: function(a) {
  7537. 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)
  7538. },
  7539. fileComplete: function(a) {
  7540. if (!this._fileList[a]) return void console.warn("Phaser.Loader fileComplete invalid index " + a);
  7541. var c = this._fileList[a];
  7542. c.loaded = !0;
  7543. var d = !0;
  7544. switch (c.type) {
  7545. case "image":
  7546. this.game.cache.addImage(c.key, c.url, c.data);
  7547. break;
  7548. case "spritesheet":
  7549. this.game.cache.addSpriteSheet(c.key, c.url, c.data, c.frameWidth, c.frameHeight, c.frameMax, c.margin, c.spacing);
  7550. break;
  7551. case "textureatlas":
  7552. if (null == c.atlasURL) this.game.cache.addTextureAtlas(c.key, c.url, c.data, c.atlasData, c.format);
  7553. 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");
  7554. else {
  7555. if (c.format != b.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + c.format);
  7556. this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "xmlLoadComplete", "dataLoadError")
  7557. }
  7558. break;
  7559. case "bitmapfont":
  7560. 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"));
  7561. break;
  7562. case "audio":
  7563. if (this.game.sound.usingWebAudio) {
  7564. if (c.data = this._xhr.response, this.game.cache.addSound(c.key, c.url, c.data, !0, !1), c.autoDecode) {
  7565. var e = this,
  7566. f = c.key;
  7567. this.game.cache.updateSound(f, "isDecoding", !0), this.game.sound.context.decodeAudioData(c.data, function(a) {
  7568. a && (e.game.cache.decodedSound(f, a), e.game.sound.onSoundDecode.dispatch(f, e.game.cache.getSound(f)))
  7569. })
  7570. }
  7571. } else c.data.removeEventListener("canplaythrough", b.GAMES[this.game.id].load.fileComplete), this.game.cache.addSound(c.key, c.url, c.data, !1, !0);
  7572. break;
  7573. case "text":
  7574. c.data = this._xhr.responseText, this.game.cache.addText(c.key, c.url, c.data);
  7575. break;
  7576. case "physics":
  7577. var g = JSON.parse(this._xhr.responseText);
  7578. this.game.cache.addPhysicsData(c.key, c.url, g, c.format);
  7579. break;
  7580. case "script":
  7581. 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));
  7582. break;
  7583. case "binary":
  7584. 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)
  7585. }
  7586. d && this.nextFile(a, !0)
  7587. },
  7588. jsonLoadComplete: function(a) {
  7589. if (!this._fileList[a]) return void console.warn("Phaser.Loader jsonLoadComplete invalid index " + a);
  7590. var b = this._fileList[a],
  7591. c = JSON.parse(this._xhr.responseText);
  7592. 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)
  7593. },
  7594. csvLoadComplete: function(a) {
  7595. if (!this._fileList[a]) return void console.warn("Phaser.Loader csvLoadComplete invalid index " + a);
  7596. var b = this._fileList[a],
  7597. c = this._xhr.responseText;
  7598. b.loaded = !0, this.game.cache.addTilemap(b.key, b.url, c, b.format), this.nextFile(a, !0)
  7599. },
  7600. dataLoadError: function(a) {
  7601. var b = this._fileList[a];
  7602. b.loaded = !0, b.error = !0, console.warn("Phaser.Loader dataLoadError: " + b.key), this.nextFile(a, !0)
  7603. },
  7604. xmlLoadComplete: function(a) {
  7605. var b, c = this._xhr.responseText;
  7606. try {
  7607. if (window.DOMParser) {
  7608. var d = new DOMParser;
  7609. b = d.parseFromString(c, "text/xml")
  7610. } else b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(c)
  7611. } catch (e) {
  7612. b = void 0
  7613. }
  7614. if (!b || !b.documentElement || b.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid XML given");
  7615. var f = this._fileList[a];
  7616. f.loaded = !0, "bitmapfont" == f.type ? this.game.cache.addBitmapFont(f.key, f.url, f.data, b, f.xSpacing, f.ySpacing) : "textureatlas" == f.type && this.game.cache.addTextureAtlas(f.key, f.url, f.data, b, f.format), this.nextFile(a, !0)
  7617. },
  7618. nextFile: function(a, b) {
  7619. 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())
  7620. },
  7621. totalLoadedFiles: function() {
  7622. for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded && a++;
  7623. return a
  7624. },
  7625. totalQueuedFiles: function() {
  7626. for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded === !1 && a++;
  7627. return a
  7628. },
  7629. totalLoadedPacks: function() {
  7630. for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded && a++;
  7631. return a
  7632. },
  7633. totalQueuedPacks: function() {
  7634. for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded === !1 && a++;
  7635. return a
  7636. }
  7637. }, b.Loader.prototype.constructor = b.Loader, b.LoaderParser = {
  7638. bitmapFont: function(a, b, c, d, e) {
  7639. var f = {},
  7640. g = b.getElementsByTagName("info")[0],
  7641. h = b.getElementsByTagName("common")[0];
  7642. f.font = g.getAttribute("face"), f.size = parseInt(g.getAttribute("size"), 10), f.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + e, f.chars = {};
  7643. for (var i = b.getElementsByTagName("char"), j = 0; j < i.length; j++) {
  7644. var k = parseInt(i[j].getAttribute("id"), 10),
  7645. 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));
  7646. f.chars[k] = {
  7647. xOffset: parseInt(i[j].getAttribute("xoffset"), 10),
  7648. yOffset: parseInt(i[j].getAttribute("yoffset"), 10),
  7649. xAdvance: parseInt(i[j].getAttribute("xadvance"), 10) + d,
  7650. kerning: {},
  7651. texture: PIXI.TextureCache[c] = new PIXI.Texture(PIXI.BaseTextureCache[c], l)
  7652. }
  7653. }
  7654. var m = b.getElementsByTagName("kerning");
  7655. for (j = 0; j < m.length; j++) {
  7656. var n = parseInt(m[j].getAttribute("first"), 10),
  7657. o = parseInt(m[j].getAttribute("second"), 10),
  7658. p = parseInt(m[j].getAttribute("amount"), 10);
  7659. f.chars[o].kerning[n] = p
  7660. }
  7661. PIXI.BitmapText.fonts[c] = f
  7662. }
  7663. }, b.Sound = function(a, c, d, e, f) {
  7664. "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
  7665. }, b.Sound.prototype = {
  7666. soundHasUnlocked: function(a) {
  7667. a == this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration)
  7668. },
  7669. addMarker: function(a, b, c, d, e) {
  7670. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), this.markers[a] = {
  7671. name: a,
  7672. start: b,
  7673. stop: b + c,
  7674. volume: d,
  7675. duration: c,
  7676. durationMS: 1e3 * c,
  7677. loop: e
  7678. }
  7679. },
  7680. removeMarker: function(a) {
  7681. delete this.markers[a]
  7682. },
  7683. update: function() {
  7684. 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()))
  7685. },
  7686. play: function(a, b, c, d, e) {
  7687. if ("undefined" == typeof a && (a = ""), "undefined" == typeof e && (e = !0), this.isPlaying === !0 && e === !1 && this.override === !1) return this;
  7688. 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) {
  7689. if (!this.markers[a]) return console.warn("Phaser.Sound.play: audio marker " + a + " doesn't exist"), this;
  7690. 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
  7691. } 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;
  7692. 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._sound.connect(this.externalNode ? this.externalNode : 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
  7693. },
  7694. restart: function(a, b, c, d) {
  7695. a = a || "", b = b || 0, c = c || 1, "undefined" == typeof d && (d = !1), this.play(a, b, c, d, !0)
  7696. },
  7697. pause: function() {
  7698. this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.now, this.onPause.dispatch(this), this.stop())
  7699. },
  7700. resume: function() {
  7701. if (this.paused && this._sound) {
  7702. if (this.usingWebAudio) {
  7703. var a = this.position + this.pausedPosition / 1e3;
  7704. this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this._sound.connect(this.externalNode ? this.externalNode : 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)
  7705. } else this._sound.play();
  7706. this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.now - this.pausedTime, this.onResume.dispatch(this)
  7707. }
  7708. },
  7709. stop: function() {
  7710. if (this.isPlaying && this._sound)
  7711. if (this.usingWebAudio)
  7712. if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
  7713. else try {
  7714. this._sound.stop(0)
  7715. } catch (a) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
  7716. this.isPlaying = !1;
  7717. var b = this.currentMarker;
  7718. "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", this.paused || this.onStop.dispatch(this, b)
  7719. },
  7720. destroy: function(a) {
  7721. "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())
  7722. }
  7723. }, b.Sound.prototype.constructor = b.Sound, Object.defineProperty(b.Sound.prototype, "isDecoding", {
  7724. get: function() {
  7725. return this.game.cache.getSound(this.key).isDecoding
  7726. }
  7727. }), Object.defineProperty(b.Sound.prototype, "isDecoded", {
  7728. get: function() {
  7729. return this.game.cache.isSoundDecoded(this.key)
  7730. }
  7731. }), Object.defineProperty(b.Sound.prototype, "mute", {
  7732. get: function() {
  7733. return this._muted || this.game.sound.mute
  7734. },
  7735. set: function(a) {
  7736. 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)
  7737. }
  7738. }), Object.defineProperty(b.Sound.prototype, "volume", {
  7739. get: function() {
  7740. return this._volume
  7741. },
  7742. set: function(a) {
  7743. 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)
  7744. }
  7745. }), b.SoundManager = function(a) {
  7746. 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
  7747. }, b.SoundManager.prototype = {
  7748. boot: function() {
  7749. 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) {
  7750. if (window.PhaserGlobal.disableAudio === !0) return this.usingWebAudio = !1, void(this.noAudio = !0);
  7751. if (window.PhaserGlobal.disableWebAudio === !0) return this.usingWebAudio = !1, this.usingAudioTag = !0, void(this.noAudio = !1)
  7752. }
  7753. if (window.AudioContext) try {
  7754. this.context = new window.AudioContext
  7755. } catch (a) {
  7756. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  7757. } else if (window.webkitAudioContext) try {
  7758. this.context = new window.webkitAudioContext
  7759. } catch (a) {
  7760. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  7761. }
  7762. 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))
  7763. },
  7764. unlock: function() {
  7765. if (this.touchLocked !== !1)
  7766. 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;
  7767. else {
  7768. var a = this.context.createBuffer(1, 1, 22050);
  7769. this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = a, this._unlockSource.connect(this.context.destination), this._unlockSource.noteOn(0)
  7770. }
  7771. },
  7772. stopAll: function() {
  7773. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].stop()
  7774. },
  7775. pauseAll: function() {
  7776. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].pause()
  7777. },
  7778. resumeAll: function() {
  7779. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].resume()
  7780. },
  7781. decode: function(a, b) {
  7782. b = b || null;
  7783. var c = this.game.cache.getSoundData(a);
  7784. if (c && this.game.cache.isSoundDecoded(a) === !1) {
  7785. this.game.cache.updateSound(a, "isDecoding", !0);
  7786. var d = this;
  7787. this.context.decodeAudioData(c, function(c) {
  7788. d.game.cache.decodedSound(a, c), b && d.onSoundDecode.dispatch(a, b)
  7789. })
  7790. }
  7791. },
  7792. update: function() {
  7793. 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);
  7794. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].update()
  7795. },
  7796. add: function(a, c, d, e) {
  7797. "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = this.connectToMaster);
  7798. var f = new b.Sound(this.game, a, c, d, e);
  7799. return this._sounds.push(f), f
  7800. },
  7801. remove: function(a) {
  7802. for (var b = this._sounds.length; b--;)
  7803. if (this._sounds[b] === a) return this._sounds[b].destroy(!1), this._sounds.splice(b, 1), !0;
  7804. return !1
  7805. },
  7806. removeByKey: function(a) {
  7807. 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++);
  7808. return c
  7809. },
  7810. play: function(a, b, c) {
  7811. var d = this.add(a, b, c);
  7812. return d.play(), d
  7813. },
  7814. setMute: function() {
  7815. if (!this._muted) {
  7816. this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
  7817. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !0)
  7818. }
  7819. },
  7820. unsetMute: function() {
  7821. if (this._muted && !this._codeMuted) {
  7822. this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
  7823. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !1)
  7824. }
  7825. }
  7826. }, b.SoundManager.prototype.constructor = b.SoundManager, Object.defineProperty(b.SoundManager.prototype, "mute", {
  7827. get: function() {
  7828. return this._muted
  7829. },
  7830. set: function(a) {
  7831. if (a = a || null) {
  7832. if (this._muted) return;
  7833. this._codeMuted = !0, this.setMute()
  7834. } else {
  7835. if (!this._muted) return;
  7836. this._codeMuted = !1, this.unsetMute()
  7837. }
  7838. }
  7839. }), Object.defineProperty(b.SoundManager.prototype, "volume", {
  7840. get: function() {
  7841. return this.usingWebAudio ? this.masterGain.gain.value : this._volume
  7842. },
  7843. set: function(a) {
  7844. if (this._volume = a, this.usingWebAudio) this.masterGain.gain.value = a;
  7845. else
  7846. for (var b = 0; b < this._sounds.length; b++) this._sounds[b].usingAudioTag && (this._sounds[b].volume = this._sounds[b].volume * a)
  7847. }
  7848. }), b.Utils.Debug = function(a) {
  7849. 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
  7850. }, b.Utils.Debug.prototype = {
  7851. boot: function() {
  7852. 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))
  7853. },
  7854. preUpdate: function() {
  7855. this.dirty && this.sprite && (this.context.clearRect(0, 0, this.game.width, this.game.height), this.dirty = !1)
  7856. },
  7857. start: function(a, b, c, d) {
  7858. "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
  7859. },
  7860. stop: function() {
  7861. this.context.restore(), this.context.globalAlpha = this.currentAlpha, this.sprite && PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl)
  7862. },
  7863. line: function() {
  7864. for (var a = this.currentX, 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;
  7865. this.currentY += this.lineHeight
  7866. },
  7867. soundInfo: function(a, b, c, d) {
  7868. 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()
  7869. },
  7870. cameraInfo: function(a, b, c, d) {
  7871. 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()
  7872. },
  7873. timer: function(a, b, c, d) {
  7874. 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()
  7875. },
  7876. pointer: function(a, b, c, d, e) {
  7877. 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()))
  7878. },
  7879. spriteInputInfo: function(a, b, c, d) {
  7880. 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()
  7881. },
  7882. key: function(a, b, c, d) {
  7883. 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()
  7884. },
  7885. inputInfo: function(a, b, c) {
  7886. 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()
  7887. },
  7888. spriteBounds: function(a, b, c) {
  7889. var d = a.getBounds();
  7890. d.x += this.game.camera.x, d.y += this.game.camera.y, this.rectangle(d, b, c)
  7891. },
  7892. spriteInfo: function(a, b, c, d) {
  7893. 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()
  7894. },
  7895. spriteCoords: function(a, b, c, d) {
  7896. 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()
  7897. },
  7898. lineInfo: function(a, b, c, d) {
  7899. 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()
  7900. },
  7901. pixel: function(a, b, c, d) {
  7902. d = d || 2, this.start(), this.context.fillStyle = c, this.context.fillRect(a, b, d, d), this.stop()
  7903. },
  7904. geom: function(a, c, d, e) {
  7905. "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()
  7906. },
  7907. rectangle: function(a, b, c) {
  7908. "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()
  7909. },
  7910. text: function(a, b, c, d, e) {
  7911. 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()
  7912. },
  7913. quadTree: function(a, b) {
  7914. b = b || "rgba(255,0,0,0.3)", this.start();
  7915. var c = a.bounds;
  7916. if (0 === a.nodes.length) {
  7917. 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)";
  7918. for (var 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)
  7919. } else
  7920. for (var d = 0; d < a.nodes.length; d++) this.quadTree(a.nodes[d]);
  7921. this.stop()
  7922. },
  7923. body: function(a, c, d) {
  7924. 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()))
  7925. },
  7926. bodyInfo: function(a, c, d, e) {
  7927. a.body && a.body.type === b.Physics.ARCADE && (this.start(c, d, e, 210), b.Physics.Arcade.Body.renderBodyInfo(this, a.body), this.stop())
  7928. }
  7929. }, b.Utils.Debug.prototype.constructor = b.Utils.Debug, b.Color = {
  7930. packPixel: function(a, c, d, e) {
  7931. return b.Device.LITTLE_ENDIAN ? (e << 24 | d << 16 | c << 8 | a) >>> 0 : (a << 24 | c << 16 | d << 8 | e) >>> 0
  7932. },
  7933. unpackPixel: function(a, c, d, e) {
  7934. 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
  7935. },
  7936. fromRGBA: function(a, c) {
  7937. 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
  7938. },
  7939. toRGBA: function(a, b, c, d) {
  7940. return a << 24 | b << 16 | c << 8 | d
  7941. },
  7942. RGBtoHSL: function(a, c, d, e) {
  7943. e || (e = b.Color.createColor(a, c, d, 1)), a /= 255, c /= 255, d /= 255;
  7944. var f = Math.min(a, c, d),
  7945. g = Math.max(a, c, d);
  7946. if (e.h = 0, e.s = 0, e.l = (g + f) / 2, g !== f) {
  7947. var h = g - f;
  7948. 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
  7949. }
  7950. return e
  7951. },
  7952. HSLtoRGB: function(a, c, d, e) {
  7953. if (e ? (e.r = d, e.g = d, e.b = d) : e = b.Color.createColor(d, d, d), 0 !== c) {
  7954. var f = .5 > d ? d * (1 + c) : d + c - d * c,
  7955. g = 2 * d - f;
  7956. 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)
  7957. }
  7958. return e.r = Math.floor(255 * e.r | 0), e.g = Math.floor(255 * e.g | 0), e.b = Math.floor(255 * e.b | 0), b.Color.updateColor(e), e
  7959. },
  7960. RGBtoHSV: function(a, c, d, e) {
  7961. e || (e = b.Color.createColor(a, c, d, 255)), a /= 255, c /= 255, d /= 255;
  7962. var f = Math.min(a, c, d),
  7963. g = Math.max(a, c, d),
  7964. h = g - f;
  7965. return 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
  7966. },
  7967. HSVtoRGB: function(a, c, d, e) {
  7968. "undefined" == typeof e && (e = b.Color.createColor(0, 0, 0, 1, a, c, 0, d));
  7969. var f, g, h, i = Math.floor(6 * a),
  7970. j = 6 * a - i,
  7971. k = d * (1 - c),
  7972. l = d * (1 - j * c),
  7973. m = d * (1 - (1 - j) * c);
  7974. switch (i % 6) {
  7975. case 0:
  7976. f = d, g = m, h = k;
  7977. break;
  7978. case 1:
  7979. f = l, g = d, h = k;
  7980. break;
  7981. case 2:
  7982. f = k, g = d, h = m;
  7983. break;
  7984. case 3:
  7985. f = k, g = l, h = d;
  7986. break;
  7987. case 4:
  7988. f = m, g = k, h = d;
  7989. break;
  7990. case 5:
  7991. f = d, g = k, h = l
  7992. }
  7993. return e.r = Math.floor(255 * f), e.g = Math.floor(255 * g), e.b = Math.floor(255 * h), b.Color.updateColor(e), e
  7994. },
  7995. hueToColor: function(a, b, c) {
  7996. return 0 > c && (c += 1), c > 1 && (c -= 1), 1 / 6 > c ? a + 6 * (b - a) * c : .5 > c ? b : 2 / 3 > c ? a + (b - a) * (2 / 3 - c) * 6 : a
  7997. },
  7998. createColor: function(a, b, c, d, e, f, g, h) {
  7999. var i = {
  8000. r: a || 0,
  8001. g: b || 0,
  8002. b: c || 0,
  8003. a: d || 1,
  8004. h: e || 0,
  8005. s: f || 0,
  8006. l: g || 0,
  8007. v: h || 0,
  8008. color: 0
  8009. };
  8010. return i.rgba = "rgba(" + i.r + "," + i.g + "," + i.b + "," + i.a + ")", i
  8011. },
  8012. updateColor: function(a) {
  8013. return a.rgba = "rgba(" + a.r + "," + a.g + "," + a.b + "," + a.a + ")", a
  8014. },
  8015. getColor32: function(a, b, c, d) {
  8016. return a << 24 | b << 16 | c << 8 | d
  8017. },
  8018. getColor: function(a, b, c) {
  8019. return a << 16 | b << 8 | c
  8020. },
  8021. RGBtoString: function(a, c, d, e, f) {
  8022. 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)
  8023. },
  8024. hexToRGB: function(a) {
  8025. var c = b.Color.hexToColor(a);
  8026. return c ? b.Color.getColor32(c.a, c.r, c.g, c.b) : void 0
  8027. },
  8028. hexToColor: function(a, c) {
  8029. c || (c = b.Color.createColor());
  8030. var d = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  8031. a = a.replace(d, function(a, b, c, d) {
  8032. return b + b + c + c + d + d
  8033. });
  8034. var e = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
  8035. return e && (c.r = parseInt(e[1], 16), c.g = parseInt(e[2], 16), c.b = parseInt(e[3], 16)), c
  8036. },
  8037. componentToHex: function(a) {
  8038. var b = a.toString(16);
  8039. return 1 == b.length ? "0" + b : b
  8040. },
  8041. HSVColorWheel: function(a, c) {
  8042. "undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1);
  8043. for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSVtoRGB(e / 359, a, c));
  8044. return d
  8045. },
  8046. HSLColorWheel: function(a, c) {
  8047. "undefined" == typeof a && (a = .5), "undefined" == typeof c && (c = .5);
  8048. for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSLtoRGB(e / 359, a, c));
  8049. return d
  8050. },
  8051. interpolateColor: function(a, c, d, e, f) {
  8052. "undefined" == typeof f && (f = 255);
  8053. var g = b.Color.getRGB(a),
  8054. h = b.Color.getRGB(c),
  8055. i = (h.red - g.red) * e / d + g.red,
  8056. j = (h.green - g.green) * e / d + g.green,
  8057. k = (h.blue - g.blue) * e / d + g.blue;
  8058. return b.Color.getColor32(f, i, j, k)
  8059. },
  8060. interpolateColorWithRGB: function(a, c, d, e, f, g) {
  8061. var h = b.Color.getRGB(a),
  8062. i = (c - h.red) * g / f + h.red,
  8063. j = (d - h.green) * g / f + h.green,
  8064. k = (e - h.blue) * g / f + h.blue;
  8065. return b.Color.getColor(i, j, k)
  8066. },
  8067. interpolateRGB: function(a, c, d, e, f, g, h, i) {
  8068. var j = (e - a) * i / h + a,
  8069. k = (f - c) * i / h + c,
  8070. l = (g - d) * i / h + d;
  8071. return b.Color.getColor(j, k, l)
  8072. },
  8073. getRandomColor: function(a, c, d) {
  8074. if ("undefined" == typeof a && (a = 0), "undefined" == typeof c && (c = 255), "undefined" == typeof d && (d = 255), c > 255 || a > c) return b.Color.getColor(255, 255, 255);
  8075. var e = a + Math.round(Math.random() * (c - a)),
  8076. f = a + Math.round(Math.random() * (c - a)),
  8077. g = a + Math.round(Math.random() * (c - a));
  8078. return b.Color.getColor32(d, e, f, g)
  8079. },
  8080. getRGB: function(a) {
  8081. return a > 16777215 ? {
  8082. alpha: a >>> 24,
  8083. red: a >> 16 & 255,
  8084. green: a >> 8 & 255,
  8085. blue: 255 & a,
  8086. a: a >>> 24,
  8087. r: a >> 16 & 255,
  8088. g: a >> 8 & 255,
  8089. b: 255 & a
  8090. } : {
  8091. alpha: 255,
  8092. red: a >> 16 & 255,
  8093. green: a >> 8 & 255,
  8094. blue: 255 & a,
  8095. a: 255,
  8096. r: a >> 16 & 255,
  8097. g: a >> 8 & 255,
  8098. b: 255 & a
  8099. }
  8100. },
  8101. getWebRGB: function(a) {
  8102. if ("object" == typeof a) return "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + (a.a / 255).toString() + ")";
  8103. var c = b.Color.getRGB(a);
  8104. return "rgba(" + c.r.toString() + "," + c.g.toString() + "," + c.b.toString() + "," + (c.a / 255).toString() + ")"
  8105. },
  8106. getAlpha: function(a) {
  8107. return a >>> 24
  8108. },
  8109. getAlphaFloat: function(a) {
  8110. return (a >>> 24) / 255
  8111. },
  8112. getRed: function(a) {
  8113. return a >> 16 & 255
  8114. },
  8115. getGreen: function(a) {
  8116. return a >> 8 & 255
  8117. },
  8118. getBlue: function(a) {
  8119. return 255 & a
  8120. },
  8121. getColorInfo: function(a) {
  8122. var c = b.Color.getRGB(a),
  8123. d = b.Color.RGBtoHexstring(a) + "\n";
  8124. return d = d.concat("Alpha: " + c.alpha + " Red: " + c.red + " Green: " + c.green + " Blue: " + c.blue) + "\n"
  8125. },
  8126. RGBtoHexstring: function(a) {
  8127. var c = b.Color.getRGB(a);
  8128. return "0x" + b.Color.colorToHexstring(c.alpha) + b.Color.colorToHexstring(c.red) + b.Color.colorToHexstring(c.green) + b.Color.colorToHexstring(c.blue)
  8129. },
  8130. RGBtoWebstring: function(a) {
  8131. var c = b.Color.getRGB(a);
  8132. return "#" + b.Color.colorToHexstring(c.red) + b.Color.colorToHexstring(c.green) + b.Color.colorToHexstring(c.blue)
  8133. },
  8134. colorToHexstring: function(a) {
  8135. var b = "0123456789ABCDEF",
  8136. c = a % 16,
  8137. d = (a - c) / 16,
  8138. e = b.charAt(d) + b.charAt(c);
  8139. return e
  8140. }
  8141. }, b.Physics = function(a, b) {
  8142. 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()
  8143. }, b.Physics.ARCADE = 0, b.Physics.P2JS = 1, b.Physics.NINJA = 2, b.Physics.BOX2D = 3, b.Physics.CHIPMUNK = 5, b.Physics.prototype = {
  8144. parseConfig: function() {
  8145. 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))
  8146. },
  8147. startSystem: function(a) {
  8148. 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);
  8149. else {
  8150. if (a === b.Physics.BOX2D && null === this.box2d) throw new Error("The Box2D physics system has not been implemented yet.");
  8151. if (a === b.Physics.CHIPMUNK && null === this.chipmunk) throw new Error("The Chipmunk physics system has not been implemented yet.")
  8152. }
  8153. this.setBoundsToWorld()
  8154. },
  8155. enable: function(a, c, d) {
  8156. "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)
  8157. },
  8158. preUpdate: function() {
  8159. this.p2 && this.p2.preUpdate()
  8160. },
  8161. update: function() {
  8162. this.p2 && this.p2.update()
  8163. },
  8164. setBoundsToWorld: function() {
  8165. this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld()
  8166. },
  8167. clear: function() {
  8168. this.p2 && this.p2.clear()
  8169. },
  8170. destroy: function() {
  8171. this.p2 && this.p2.destroy(), this.arcade = null, this.ninja = null, this.p2 = null
  8172. }
  8173. }, b.Physics.prototype.constructor = b.Physics, b.Physics.Arcade = function(a) {
  8174. this.game = a, this.gravity = new b.Point, this.bounds = new b.Rectangle(0, 0, a.world.width, a.world.height), this.checkCollision = {
  8175. up: !0,
  8176. down: !0,
  8177. left: !0,
  8178. right: !0
  8179. }, 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
  8180. }, b.Physics.Arcade.prototype.constructor = b.Physics.Arcade, b.Physics.Arcade.prototype = {
  8181. setBounds: function(a, b, c, d) {
  8182. this.bounds.setTo(a, b, c, d)
  8183. },
  8184. setBoundsToWorld: function() {
  8185. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  8186. },
  8187. enable: function(a, c) {
  8188. "undefined" == typeof c && (c = !0);
  8189. var d = 1;
  8190. if (Array.isArray(a))
  8191. 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));
  8192. 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))
  8193. },
  8194. enableBody: function(a) {
  8195. a.hasOwnProperty("body") && null === a.body && (a.body = new b.Physics.Arcade.Body(a))
  8196. },
  8197. updateMotion: function(a) {
  8198. 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)
  8199. },
  8200. computeVelocity: function(a, b, c, d, e, f) {
  8201. 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
  8202. },
  8203. overlap: function(a, b, c, d, e) {
  8204. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  8205. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !0);
  8206. else this.collideHandler(a, b, c, d, e, !0);
  8207. return this._total > 0
  8208. },
  8209. collide: function(a, b, c, d, e) {
  8210. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  8211. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !1);
  8212. else this.collideHandler(a, b, c, d, e, !1);
  8213. return this._total > 0
  8214. },
  8215. collideHandler: function(a, c, d, e, f, g) {
  8216. return "undefined" != typeof c || a.type !== b.GROUP && a.type !== b.EMITTER ? void(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 this.collideGroupVsSelf(a, d, e, f, g)
  8217. },
  8218. collideSpriteVsSprite: function(a, b, c, d, e, f) {
  8219. return a.body && b.body ? (this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++), !0) : !1
  8220. },
  8221. collideSpriteVsGroup: function(a, b, c, d, e, f) {
  8222. if (0 !== b.length && a.body) {
  8223. 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);
  8224. 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++)
  8225. }
  8226. },
  8227. collideGroupVsSelf: function(a, b, c, d, e) {
  8228. if (0 !== a.length)
  8229. for (var f = a.children.length, g = 0; f > g; g++)
  8230. for (var 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)
  8231. },
  8232. collideGroupVsGroup: function(a, b, c, d, e, f) {
  8233. if (0 !== a.length && 0 !== b.length)
  8234. 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)
  8235. },
  8236. collideSpriteVsTilemapLayer: function(a, b, c, d, e) {
  8237. 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))
  8238. 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]))
  8239. },
  8240. collideGroupVsTilemapLayer: function(a, b, c, d, e) {
  8241. if (0 !== a.length)
  8242. for (var f = 0, g = a.children.length; g > f; f++) a.children[f].exists && this.collideSpriteVsTilemapLayer(a.children[f], b, c, d, e)
  8243. },
  8244. separate: function(a, b, c, d, e) {
  8245. 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
  8246. },
  8247. intersects: function(a, b) {
  8248. 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
  8249. },
  8250. separateX: function(a, b, c) {
  8251. 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)
  8252. },
  8253. separateY: function(a, b, c) {
  8254. 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)
  8255. },
  8256. separateTile: function(a, b, c) {
  8257. if (!b.enable || !c.intersects(b.position.x, b.position.y, b.right, b.bottom)) return !1;
  8258. if (c.collisionCallback && !c.collisionCallback.call(c.collisionCallbackContext, b.sprite, c)) return !1;
  8259. if (c.layer.callbacks[c.index] && !c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext, b.sprite, c)) return !1;
  8260. if (!(c.faceLeft || c.faceRight || c.faceTop || c.faceBottom)) return !1;
  8261. var d = 0,
  8262. e = 0,
  8263. f = 0,
  8264. g = 1;
  8265. if (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) {
  8266. 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;
  8267. (c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c))
  8268. } else {
  8269. 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;
  8270. (c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c))
  8271. }
  8272. return 0 !== d || 0 !== e
  8273. },
  8274. tileCheckX: function(a, b) {
  8275. var c = 0;
  8276. 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
  8277. },
  8278. tileCheckY: function(a, b) {
  8279. var c = 0;
  8280. 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
  8281. },
  8282. processTileSeparationX: function(a, b) {
  8283. 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
  8284. },
  8285. processTileSeparationY: function(a, b) {
  8286. 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
  8287. },
  8288. getObjectsUnderPointer: function(a, c, d, e) {
  8289. if (0 !== c.length && a.exists) {
  8290. 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);
  8291. var f = new b.Rectangle(a.x, a.y, 1, 1),
  8292. g = [];
  8293. this._potentials = this.quadTree.retrieve(f);
  8294. for (var 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));
  8295. return g
  8296. }
  8297. },
  8298. moveToObject: function(a, b, c, d) {
  8299. 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
  8300. },
  8301. moveToPointer: function(a, b, c, d) {
  8302. 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
  8303. },
  8304. moveToXY: function(a, b, c, d, e) {
  8305. 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
  8306. },
  8307. velocityFromAngle: function(a, c, d) {
  8308. 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)
  8309. },
  8310. velocityFromRotation: function(a, c, d) {
  8311. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  8312. },
  8313. accelerationFromRotation: function(a, c, d) {
  8314. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  8315. },
  8316. accelerateToObject: function(a, b, c, d, e) {
  8317. 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
  8318. },
  8319. accelerateToPointer: function(a, b, c, d, e) {
  8320. 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
  8321. },
  8322. accelerateToXY: function(a, b, c, d, e, f) {
  8323. 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
  8324. },
  8325. distanceBetween: function(a, b) {
  8326. return this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  8327. },
  8328. distanceToXY: function(a, b, c) {
  8329. return this._dx = a.x - b, this._dy = a.y - c, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  8330. },
  8331. distanceToPointer: function(a, b) {
  8332. 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)
  8333. },
  8334. angleBetween: function(a, b) {
  8335. return this._dx = b.x - a.x, this._dy = b.y - a.y, Math.atan2(this._dy, this._dx)
  8336. },
  8337. angleToXY: function(a, b, c) {
  8338. return this._dx = b - a.x, this._dy = c - a.y, Math.atan2(this._dy, this._dx)
  8339. },
  8340. angleToPointer: function(a, b) {
  8341. 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)
  8342. }
  8343. }, b.Physics.Arcade.Body = function(a) {
  8344. 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 = {
  8345. none: !1,
  8346. any: !0,
  8347. up: !0,
  8348. down: !0,
  8349. left: !0,
  8350. right: !0
  8351. }, this.touching = {
  8352. none: !0,
  8353. up: !1,
  8354. down: !1,
  8355. left: !1,
  8356. right: !1
  8357. }, this.wasTouching = {
  8358. none: !0,
  8359. up: !1,
  8360. down: !1,
  8361. left: !1,
  8362. right: !1
  8363. }, this.blocked = {
  8364. up: !1,
  8365. down: !1,
  8366. left: !1,
  8367. right: !1
  8368. }, 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
  8369. }, b.Physics.Arcade.Body.prototype = {
  8370. updateBounds: function() {
  8371. var a = Math.abs(this.sprite.scale.x),
  8372. b = Math.abs(this.sprite.scale.y);
  8373. (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)
  8374. },
  8375. preUpdate: function() {
  8376. 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)
  8377. },
  8378. postUpdate: function() {
  8379. 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)
  8380. },
  8381. destroy: function() {
  8382. this.sprite = null
  8383. },
  8384. checkWorldBounds: function() {
  8385. 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)
  8386. },
  8387. setSize: function(a, b, c, d) {
  8388. "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)
  8389. },
  8390. reset: function(a, b) {
  8391. 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)
  8392. },
  8393. hitTest: function(a, c) {
  8394. return b.Rectangle.contains(this, a, c)
  8395. },
  8396. onFloor: function() {
  8397. return this.blocked.down
  8398. },
  8399. onWall: function() {
  8400. return this.blocked.left || this.blocked.right
  8401. },
  8402. deltaAbsX: function() {
  8403. return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
  8404. },
  8405. deltaAbsY: function() {
  8406. return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
  8407. },
  8408. deltaX: function() {
  8409. return this.position.x - this.prev.x
  8410. },
  8411. deltaY: function() {
  8412. return this.position.y - this.prev.y
  8413. },
  8414. deltaZ: function() {
  8415. return this.rotation - this.preRotation
  8416. }
  8417. }, Object.defineProperty(b.Physics.Arcade.Body.prototype, "bottom", {
  8418. get: function() {
  8419. return this.position.y + this.height
  8420. }
  8421. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "right", {
  8422. get: function() {
  8423. return this.position.x + this.width
  8424. }
  8425. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "x", {
  8426. get: function() {
  8427. return this.position.x
  8428. },
  8429. set: function(a) {
  8430. this.position.x = a
  8431. }
  8432. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "y", {
  8433. get: function() {
  8434. return this.position.y
  8435. },
  8436. set: function(a) {
  8437. this.position.y = a
  8438. }
  8439. }), b.Physics.Arcade.Body.render = function(a, b, c, d) {
  8440. "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))
  8441. }, b.Physics.Arcade.Body.renderBodyInfo = function(a, b) {
  8442. 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)
  8443. }, b.Physics.Arcade.Body.prototype.constructor = b.Physics.Arcade.Body, b.Particles = function(a) {
  8444. this.game = a, this.emitters = {}, this.ID = 0
  8445. }, b.Particles.prototype = {
  8446. add: function(a) {
  8447. return this.emitters[a.name] = a, a
  8448. },
  8449. remove: function(a) {
  8450. delete this.emitters[a.name]
  8451. },
  8452. update: function() {
  8453. for (var a in this.emitters) this.emitters[a].exists && this.emitters[a].update()
  8454. }
  8455. }, b.Particles.prototype.constructor = b.Particles, b.Particles.Arcade = {}, b.Particles.Arcade.Emitter = function(a, c, d, e) {
  8456. 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
  8457. }, 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() {
  8458. if (this.on)
  8459. if (this._explode) {
  8460. this._counter = 0;
  8461. do this.emitParticle(), this._counter++; while (this._counter < this._quantity);
  8462. this.on = !1
  8463. } 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);
  8464. for (var a = this.children.length; a--;) this.children[a].exists && this.children[a].update()
  8465. }, b.Particles.Arcade.Emitter.prototype.makeParticles = function(a, b, c, d, e) {
  8466. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.maxParticles), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  8467. var f, g = 0,
  8468. h = a,
  8469. i = b;
  8470. for (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++;
  8471. return this
  8472. }, b.Particles.Arcade.Emitter.prototype.kill = function() {
  8473. this.on = !1, this.alive = !1, this.exists = !1
  8474. }, b.Particles.Arcade.Emitter.prototype.revive = function() {
  8475. this.alive = !0, this.exists = !0
  8476. }, b.Particles.Arcade.Emitter.prototype.explode = function(a, b) {
  8477. this.start(!0, a, 0, b, !1)
  8478. }, b.Particles.Arcade.Emitter.prototype.flow = function(a, b, c) {
  8479. this.start(!1, a, b, c, !0)
  8480. }, b.Particles.Arcade.Emitter.prototype.start = function(a, b, c, d, e) {
  8481. "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
  8482. }, b.Particles.Arcade.Emitter.prototype.emitParticle = function() {
  8483. var a = this.getFirstExists(!1);
  8484. 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())
  8485. }, b.Particles.Arcade.Emitter.prototype.setSize = function(a, b) {
  8486. this.area.width = a, this.area.height = b
  8487. }, b.Particles.Arcade.Emitter.prototype.setXSpeed = function(a, b) {
  8488. a = a || 0, b = b || 0, this.minParticleSpeed.x = a, this.maxParticleSpeed.x = b
  8489. }, b.Particles.Arcade.Emitter.prototype.setYSpeed = function(a, b) {
  8490. a = a || 0, b = b || 0, this.minParticleSpeed.y = a, this.maxParticleSpeed.y = b
  8491. }, b.Particles.Arcade.Emitter.prototype.setRotation = function(a, b) {
  8492. a = a || 0, b = b || 0, this.minRotation = a, this.maxRotation = b
  8493. }, b.Particles.Arcade.Emitter.prototype.setAlpha = function(a, c, d, e, f) {
  8494. if ("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) {
  8495. var g = {
  8496. v: a
  8497. },
  8498. h = this.game.make.tween(g).to({
  8499. v: c
  8500. }, d, e);
  8501. h.yoyo(f), this.alphaData = h.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0
  8502. }
  8503. }, b.Particles.Arcade.Emitter.prototype.setScale = function(a, c, d, e, f, g, h) {
  8504. if ("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) {
  8505. var i = {
  8506. x: a,
  8507. y: d
  8508. },
  8509. j = this.game.make.tween(i).to({
  8510. x: c,
  8511. y: e
  8512. }, f, g);
  8513. j.yoyo(h), this.scaleData = j.generateData(60), this.scaleData.reverse(), this.autoScale = !0
  8514. }
  8515. }, b.Particles.Arcade.Emitter.prototype.at = function(a) {
  8516. 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)
  8517. }, Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "width", {
  8518. get: function() {
  8519. return this.area.width
  8520. },
  8521. set: function(a) {
  8522. this.area.width = a
  8523. }
  8524. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "height", {
  8525. get: function() {
  8526. return this.area.height
  8527. },
  8528. set: function(a) {
  8529. this.area.height = a
  8530. }
  8531. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "x", {
  8532. get: function() {
  8533. return this.emitX
  8534. },
  8535. set: function(a) {
  8536. this.emitX = a
  8537. }
  8538. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "y", {
  8539. get: function() {
  8540. return this.emitY
  8541. },
  8542. set: function(a) {
  8543. this.emitY = a
  8544. }
  8545. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "left", {
  8546. get: function() {
  8547. return Math.floor(this.x - this.area.width / 2)
  8548. }
  8549. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "right", {
  8550. get: function() {
  8551. return Math.floor(this.x + this.area.width / 2)
  8552. }
  8553. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "top", {
  8554. get: function() {
  8555. return Math.floor(this.y - this.area.height / 2)
  8556. }
  8557. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "bottom", {
  8558. get: function() {
  8559. return Math.floor(this.y + this.area.height / 2)
  8560. }
  8561. }), b.Tile = function(a, b, c, d, e, f) {
  8562. 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
  8563. }, b.Tile.prototype = {
  8564. containsPoint: function(a, b) {
  8565. return !(a < this.worldX || b < this.worldY || a > this.right || b > this.bottom)
  8566. },
  8567. intersects: function(a, b, c, d) {
  8568. return c <= this.worldX ? !1 : d <= this.worldY ? !1 : a >= this.worldX + this.width ? !1 : b >= this.worldY + this.height ? !1 : !0
  8569. },
  8570. setCollisionCallback: function(a, b) {
  8571. this.collisionCallback = a, this.collisionCallbackContext = b
  8572. },
  8573. destroy: function() {
  8574. this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null
  8575. },
  8576. setCollision: function(a, b, c, d) {
  8577. this.collideLeft = a, this.collideRight = b, this.collideUp = c, this.collideDown = d
  8578. },
  8579. resetCollision: function() {
  8580. this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1
  8581. },
  8582. isInteresting: function(a, b) {
  8583. 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
  8584. },
  8585. copy: function(a) {
  8586. 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
  8587. }
  8588. }, b.Tile.prototype.constructor = b.Tile, Object.defineProperty(b.Tile.prototype, "collides", {
  8589. get: function() {
  8590. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown
  8591. }
  8592. }), Object.defineProperty(b.Tile.prototype, "canCollide", {
  8593. get: function() {
  8594. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback
  8595. }
  8596. }), Object.defineProperty(b.Tile.prototype, "left", {
  8597. get: function() {
  8598. return this.worldX
  8599. }
  8600. }), Object.defineProperty(b.Tile.prototype, "right", {
  8601. get: function() {
  8602. return this.worldX + this.width
  8603. }
  8604. }), Object.defineProperty(b.Tile.prototype, "top", {
  8605. get: function() {
  8606. return this.worldY
  8607. }
  8608. }), Object.defineProperty(b.Tile.prototype, "bottom", {
  8609. get: function() {
  8610. return this.worldY + this.height
  8611. }
  8612. }), b.Tilemap = function(a, c, d, e, f, g) {
  8613. this.game = a, this.key = c;
  8614. var h = b.TilemapParser.parse(this.game, c, d, e, f, g);
  8615. 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)
  8616. }, 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 = {
  8617. create: function(a, b, c, d, e, f) {
  8618. 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)
  8619. },
  8620. setTileSize: function(a, b) {
  8621. this.tileWidth = a, this.tileHeight = b, this.widthInPixels = this.width * a, this.heightInPixels = this.height * b
  8622. },
  8623. addTilesetImage: function(a, c, d, e, f, g, h) {
  8624. 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) {
  8625. if ("string" != typeof a) return null;
  8626. if (c = a, !this.game.cache.checkImageKey(c)) return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + c + '"'), null
  8627. }
  8628. 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;
  8629. if (this.tilesets[a]) return this.tilesets[a].setImage(this.game.cache.getImage(c)), this.tilesets[a];
  8630. var i = new b.Tileset(c, h, d, e, f, g, {});
  8631. i.setImage(this.game.cache.getImage(c)), this.tilesets.push(i);
  8632. for (var 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++);
  8633. return i
  8634. },
  8635. createFromObjects: function(a, c, d, e, f, g, h, i, j) {
  8636. 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 void console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: " + a);
  8637. for (var k, l = 0, m = this.objects[a].length; m > l; l++)
  8638. if (this.objects[a][l].gid === c) {
  8639. 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);
  8640. for (var n in this.objects[a][l].properties) h.set(k, n, this.objects[a][l].properties[n], !1, !1, 0, !0)
  8641. }
  8642. },
  8643. createLayer: function(a, c, d, e) {
  8644. "undefined" == typeof c && (c = this.game.width), "undefined" == typeof d && (d = this.game.height), "undefined" == typeof e && (e = this.game.world);
  8645. var f = a;
  8646. return "string" == typeof a && (f = this.getLayerIndex(a)), null === f || f > this.layers.length ? void console.warn("Tilemap.createLayer: Invalid layer ID given: " + f) : e.add(new b.TilemapLayer(this.game, this, f, c, d))
  8647. },
  8648. createBlankLayer: function(a, c, d, e, f, g) {
  8649. if ("undefined" == typeof g && (g = this.game.world), null !== this.getLayerIndex(a)) return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists");
  8650. for (var h, i = {
  8651. name: a,
  8652. x: 0,
  8653. y: 0,
  8654. width: c,
  8655. height: d,
  8656. widthInPixels: c * e,
  8657. heightInPixels: d * f,
  8658. alpha: 1,
  8659. visible: !0,
  8660. properties: {},
  8661. indexes: [],
  8662. callbacks: [],
  8663. bodies: [],
  8664. data: null
  8665. }, j = [], k = 0; d > k; k++) {
  8666. h = [];
  8667. for (var l = 0; c > l; l++) h.push(new b.Tile(i, -1, l, k, e, f));
  8668. j.push(h)
  8669. }
  8670. i.data = j, this.layers.push(i), this.currentLayer = this.layers.length - 1;
  8671. var m = i.widthInPixels,
  8672. n = i.heightInPixels;
  8673. m > this.game.width && (m = this.game.width), n > this.game.height && (n = this.game.height);
  8674. var j = new b.TilemapLayer(this.game, this, this.layers.length - 1, m, n);
  8675. return j.name = a, g.add(j)
  8676. },
  8677. getIndex: function(a, b) {
  8678. for (var c = 0; c < a.length; c++)
  8679. if (a[c].name === b) return c;
  8680. return null
  8681. },
  8682. getLayerIndex: function(a) {
  8683. return this.getIndex(this.layers, a)
  8684. },
  8685. getTilesetIndex: function(a) {
  8686. return this.getIndex(this.tilesets, a)
  8687. },
  8688. getImageIndex: function(a) {
  8689. return this.getIndex(this.images, a)
  8690. },
  8691. getObjectIndex: function(a) {
  8692. return this.getIndex(this.objects, a)
  8693. },
  8694. setTileIndexCallback: function(a, b, c, d) {
  8695. if (d = this.getLayer(d), "number" == typeof a) this.layers[d].callbacks[a] = {
  8696. callback: b,
  8697. callbackContext: c
  8698. };
  8699. else
  8700. for (var e = 0, f = a.length; f > e; e++) this.layers[d].callbacks[a[e]] = {
  8701. callback: b,
  8702. callbackContext: c
  8703. }
  8704. },
  8705. setTileLocationCallback: function(a, b, c, d, e, f, g) {
  8706. if (g = this.getLayer(g), this.copy(a, b, c, d, g), !(this._results.length < 2))
  8707. for (var h = 1; h < this._results.length; h++) this._results[h].setCollisionCallback(e, f)
  8708. },
  8709. setCollision: function(a, b, c, d) {
  8710. 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);
  8711. for (var e = 0, f = a.length; f > e; e++) this.setCollisionByIndex(a[e], b, c, !1);
  8712. d && this.calculateFaces(c)
  8713. },
  8714. setCollisionBetween: function(a, b, c, d, e) {
  8715. if ("undefined" == typeof c && (c = !0), "undefined" == typeof e && (e = !0), d = this.getLayer(d), !(a > b)) {
  8716. for (var f = a; b >= f; f++) this.setCollisionByIndex(f, c, d, !1);
  8717. e && this.calculateFaces(d)
  8718. }
  8719. },
  8720. setCollisionByExclusion: function(a, b, c, d) {
  8721. "undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c);
  8722. for (var e = 0, f = this.tiles.length; f > e; e++) - 1 === a.indexOf(e) && this.setCollisionByIndex(e, b, c, !1);
  8723. d && this.calculateFaces(c)
  8724. },
  8725. setCollisionByIndex: function(a, b, c, d) {
  8726. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = this.currentLayer), "undefined" == typeof d && (d = !0), b) this.collideIndexes.push(a);
  8727. else {
  8728. var e = this.collideIndexes.indexOf(a);
  8729. e > -1 && this.collideIndexes.splice(e, 1)
  8730. }
  8731. for (var f = 0; f < this.layers[c].height; f++)
  8732. for (var g = 0; g < this.layers[c].width; g++) {
  8733. var h = this.layers[c].data[f][g];
  8734. 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)
  8735. }
  8736. return d && this.calculateFaces(c), c
  8737. },
  8738. getLayer: function(a) {
  8739. return "undefined" == typeof a ? a = this.currentLayer : "string" == typeof a ? a = this.getLayerIndex(a) : a instanceof b.TilemapLayer && (a = a.index), a
  8740. },
  8741. setPreventRecalculate: function(a) {
  8742. if (a === !0 && this.preventingRecalculate !== !0 && (this.preventingRecalculate = !0, this.needToRecalculate = {}), a === !1 && this.preventingRecalculate === !0) {
  8743. this.preventingRecalculate = !1;
  8744. for (var b in this.needToRecalculate) this.calculateFaces(b);
  8745. this.needToRecalculate = !1
  8746. }
  8747. },
  8748. calculateFaces: function(a) {
  8749. if (this.preventingRecalculate === !0) return void(this.needToRecalculate[a] = !0);
  8750. for (var b = null, c = null, d = null, e = null, f = 0, g = this.layers[a].height; g > f; f++)
  8751. for (var h = 0, i = this.layers[a].width; i > h; h++) {
  8752. var j = this.layers[a].data[f][h];
  8753. 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))
  8754. }
  8755. },
  8756. getTileAbove: function(a, b, c) {
  8757. return c > 0 ? this.layers[a].data[c - 1][b] : null
  8758. },
  8759. getTileBelow: function(a, b, c) {
  8760. return c < this.layers[a].height - 1 ? this.layers[a].data[c + 1][b] : null
  8761. },
  8762. getTileLeft: function(a, b, c) {
  8763. return b > 0 ? this.layers[a].data[c][b - 1] : null
  8764. },
  8765. getTileRight: function(a, b, c) {
  8766. return b < this.layers[a].width - 1 ? this.layers[a].data[c][b + 1] : null
  8767. },
  8768. setLayer: function(a) {
  8769. a = this.getLayer(a), this.layers[a] && (this.currentLayer = a)
  8770. },
  8771. hasTile: function(a, b, c) {
  8772. return c = this.getLayer(c), null !== this.layers[c].data[b] && null !== this.layers[c].data[b][a]
  8773. },
  8774. removeTile: function(a, c, d) {
  8775. if (d = this.getLayer(d), a >= 0 && a < this.layers[d].width && c >= 0 && c < this.layers[d].height && this.hasTile(a, c, d)) {
  8776. var e = this.layers[d].data[c][a];
  8777. 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
  8778. }
  8779. },
  8780. removeTileWorldXY: function(a, b, c, d, e) {
  8781. 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)
  8782. },
  8783. putTile: function(a, c, d, e) {
  8784. if (null === a) return this.removeTile(c, d, e);
  8785. if (e = this.getLayer(e), c >= 0 && c < this.layers[e].width && d >= 0 && d < this.layers[e].height) {
  8786. var f;
  8787. 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]
  8788. }
  8789. return null
  8790. },
  8791. putTileWorldXY: function(a, b, c, d, e, f) {
  8792. 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)
  8793. },
  8794. searchTileIndex: function(a, b, c, d) {
  8795. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), d = this.getLayer(d);
  8796. var e = 0;
  8797. if (c) {
  8798. for (var f = this.layers[d].height - 1; f >= 0; f--)
  8799. for (var g = this.layers[d].width - 1; g >= 0; g--)
  8800. if (this.layers[d].data[f][g].index === a) {
  8801. if (e === b) return this.layers[d].data[f][g];
  8802. e++
  8803. }
  8804. } else
  8805. for (var f = 0; f < this.layers[d].height; f++)
  8806. for (var g = 0; g < this.layers[d].width; g++)
  8807. if (this.layers[d].data[f][g].index === a) {
  8808. if (e === b) return this.layers[d].data[f][g];
  8809. e++
  8810. } return null
  8811. },
  8812. getTile: function(a, b, c, d) {
  8813. 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
  8814. },
  8815. getTileWorldXY: function(a, b, c, d, e) {
  8816. 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)
  8817. },
  8818. copy: function(a, b, c, d, e) {
  8819. if (e = this.getLayer(e), !this.layers[e]) return void(this._results.length = 0);
  8820. "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({
  8821. x: a,
  8822. y: b,
  8823. width: c,
  8824. height: d,
  8825. layer: e
  8826. });
  8827. for (var f = b; b + d > f; f++)
  8828. for (var g = a; a + c > g; g++) this._results.push(this.layers[e].data[f][g]);
  8829. return this._results
  8830. },
  8831. paste: function(a, b, c, d) {
  8832. if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), d = this.getLayer(d), c && !(c.length < 2)) {
  8833. for (var 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]);
  8834. this.layers[d].dirty = !0, this.calculateFaces(d)
  8835. }
  8836. },
  8837. swap: function(a, b, c, d, e, f, g) {
  8838. 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))
  8839. },
  8840. swapHandler: function(a) {
  8841. a.index === this._tempA ? a.index = this._tempB : a.index === this._tempB && (a.index = this._tempA)
  8842. },
  8843. forEach: function(a, b, c, d, e, f, g) {
  8844. 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))
  8845. },
  8846. replace: function(a, b, c, d, e, f, g) {
  8847. if (g = this.getLayer(g), this.copy(c, d, e, f, g), !(this._results.length < 2)) {
  8848. for (var h = 1; h < this._results.length; h++) this._results[h].index === a && (this._results[h].index = b);
  8849. this.paste(c, d, this._results, g)
  8850. }
  8851. },
  8852. random: function(a, b, c, d, e) {
  8853. if (e = this.getLayer(e), this.copy(a, b, c, d, e), !(this._results.length < 2)) {
  8854. for (var f = [], g = 1; g < this._results.length; g++)
  8855. if (this._results[g].index) {
  8856. var h = this._results[g].index; - 1 === f.indexOf(h) && f.push(h)
  8857. }
  8858. for (var i = 1; i < this._results.length; i++) this._results[i].index = this.game.rnd.pick(f);
  8859. this.paste(a, b, this._results, e)
  8860. }
  8861. },
  8862. shuffle: function(a, c, d, e, f) {
  8863. if (f = this.getLayer(f), this.copy(a, c, d, e, f), !(this._results.length < 2)) {
  8864. for (var g = [], h = 1; h < this._results.length; h++) this._results[h].index && g.push(this._results[h].index);
  8865. b.Utils.shuffle(g);
  8866. for (var i = 1; i < this._results.length; i++) this._results[i].index = g[i - 1];
  8867. this.paste(a, c, this._results, f)
  8868. }
  8869. },
  8870. fill: function(a, b, c, d, e, f) {
  8871. if (f = this.getLayer(f), this.copy(b, c, d, e, f), !(this._results.length < 2)) {
  8872. for (var g = 1; g < this._results.length; g++) this._results[g].index = a;
  8873. this.paste(b, c, this._results, f)
  8874. }
  8875. },
  8876. removeAllLayers: function() {
  8877. this.layers.length = 0, this.currentLayer = 0
  8878. },
  8879. dump: function() {
  8880. for (var a = "", b = [""], c = 0; c < this.layers[this.currentLayer].height; c++) {
  8881. for (var d = 0; d < this.layers[this.currentLayer].width; d++) a += "%c ", b.push(this.layers[this.currentLayer].data[c][d] > 1 ? this.debugMap[this.layers[this.currentLayer].data[c][d]] ? "background: " + this.debugMap[this.layers[this.currentLayer].data[c][d]] : "background: #ffffff" : "background: rgb(0, 0, 0)");
  8882. a += "\n"
  8883. }
  8884. b[0] = a, console.log.apply(console, b)
  8885. },
  8886. destroy: function() {
  8887. this.removeAllLayers(), this.data = [], this.game = null
  8888. }
  8889. }, b.Tilemap.prototype.constructor = b.Tilemap, Object.defineProperty(b.Tilemap.prototype, "layer", {
  8890. get: function() {
  8891. return this.layers[this.currentLayer]
  8892. },
  8893. set: function(a) {
  8894. a !== this.currentLayer && this.setLayer(a)
  8895. }
  8896. }), b.TilemapLayer = function(a, c, d, e, f) {
  8897. 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 = {
  8898. cw: c.tileWidth,
  8899. ch: c.tileHeight,
  8900. ga: 1,
  8901. dx: 0,
  8902. dy: 0,
  8903. dw: 0,
  8904. dh: 0,
  8905. tx: 0,
  8906. ty: 0,
  8907. tw: 0,
  8908. th: 0,
  8909. tl: 0,
  8910. maxX: 0,
  8911. maxY: 0,
  8912. startX: 0,
  8913. startY: 0,
  8914. x: 0,
  8915. y: 0,
  8916. prevX: 0,
  8917. prevY: 0
  8918. }, this._results = [], this.updateMax()
  8919. }, b.TilemapLayer.prototype = Object.create(b.Image.prototype), b.TilemapLayer.prototype.constructor = b.TilemapLayer, b.TilemapLayer.prototype.postUpdate = function() {
  8920. 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)
  8921. }, b.TilemapLayer.prototype.resizeWorld = function() {
  8922. this.game.world.setBounds(0, 0, this.layer.widthInPixels, this.layer.heightInPixels)
  8923. }, b.TilemapLayer.prototype._fixX = function(a) {
  8924. return 0 > a && (a = 0), 1 === this.scrollFactorX ? a : this._mc.x + (a - this._mc.x / this.scrollFactorX)
  8925. }, b.TilemapLayer.prototype._unfixX = function(a) {
  8926. return 1 === this.scrollFactorX ? a : this._mc.x / this.scrollFactorX + (a - this._mc.x)
  8927. }, b.TilemapLayer.prototype._fixY = function(a) {
  8928. return 0 > a && (a = 0), 1 === this.scrollFactorY ? a : this._mc.y + (a - this._mc.y / this.scrollFactorY)
  8929. }, b.TilemapLayer.prototype._unfixY = function(a) {
  8930. return 1 === this.scrollFactorY ? a : this._mc.y / this.scrollFactorY + (a - this._mc.y)
  8931. }, b.TilemapLayer.prototype.getTileX = function(a) {
  8932. return this.game.math.snapToFloor(this._fixX(a), this.map.tileWidth) / this.map.tileWidth
  8933. }, b.TilemapLayer.prototype.getTileY = function(a) {
  8934. return this.game.math.snapToFloor(this._fixY(a), this.map.tileHeight) / this.map.tileHeight
  8935. }, b.TilemapLayer.prototype.getTileXY = function(a, b, c) {
  8936. return c.x = this.getTileX(a), c.y = this.getTileY(b), c
  8937. }, b.TilemapLayer.prototype.getRayCastTiles = function(a, b, c, d) {
  8938. ("undefined" == typeof b || null === b) && (b = this.rayStepRate), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1);
  8939. var e = this.getTiles(a.x, a.y, a.width, a.height, c, d);
  8940. if (0 === e.length) return [];
  8941. for (var f = a.coordinatesOnLine(b), g = f.length, h = [], i = 0; i < e.length; i++)
  8942. for (var j = 0; g > j; j++)
  8943. if (e[i].containsPoint(f[j][0], f[j][1])) {
  8944. h.push(e[i]);
  8945. break
  8946. }
  8947. return h
  8948. }, b.TilemapLayer.prototype.getTiles = function(a, b, c, d, e, f) {
  8949. "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;
  8950. for (var g = this._mc.ty; g < this._mc.ty + this._mc.th; g++)
  8951. for (var 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]);
  8952. return this._results
  8953. }, b.TilemapLayer.prototype.updateMax = function() {
  8954. 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
  8955. }, b.TilemapLayer.prototype.render = function() {
  8956. if (this.layer.dirty && (this.dirty = !0), this.dirty && this.visible) {
  8957. 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;
  8958. var a, c;
  8959. this.debug && (this.context.globalAlpha = this.debugAlpha);
  8960. for (var d = this._mc.startY, e = this._mc.startY + this._mc.maxY; e > d; d++) {
  8961. 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)
  8962. for (var f = this._mc.startX, g = this._mc.startX + this._mc.maxX; g > f; f++) {
  8963. var a = null;
  8964. 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
  8965. }
  8966. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  8967. }
  8968. 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
  8969. }
  8970. }, b.TilemapLayer.prototype.renderDebug = function() {
  8971. this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.strokeStyle = this.debugColor, this.context.fillStyle = this.debugFillColor;
  8972. for (var a = this._mc.startY, b = this._mc.startY + this._mc.maxY; b > a; a++) {
  8973. 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)
  8974. for (var c = this._mc.startX, d = this._mc.startX + this._mc.maxX; d > c; c++) {
  8975. var e = null;
  8976. 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
  8977. }
  8978. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  8979. }
  8980. }, Object.defineProperty(b.TilemapLayer.prototype, "scrollX", {
  8981. get: function() {
  8982. return this._mc.x
  8983. },
  8984. set: function(a) {
  8985. a !== this._mc.x && (this._mc.x = a, this._mc.startX = this.game.math.floor(this._mc.x / this.map.tileWidth), this.dirty = !0)
  8986. }
  8987. }), Object.defineProperty(b.TilemapLayer.prototype, "scrollY", {
  8988. get: function() {
  8989. return this._mc.y
  8990. },
  8991. set: function(a) {
  8992. a !== this._mc.y && (this._mc.y = a, this._mc.startY = this.game.math.floor(this._mc.y / this.map.tileHeight), this.dirty = !0)
  8993. }
  8994. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionWidth", {
  8995. get: function() {
  8996. return this._mc.cw
  8997. },
  8998. set: function(a) {
  8999. this._mc.cw = a, this.dirty = !0
  9000. }
  9001. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionHeight", {
  9002. get: function() {
  9003. return this._mc.ch
  9004. },
  9005. set: function(a) {
  9006. this._mc.ch = a, this.dirty = !0
  9007. }
  9008. }), b.TilemapParser = {
  9009. parse: function(a, c, d, e, f, g) {
  9010. 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();
  9011. if (null === c) return this.getEmptyData(d, e, f, g);
  9012. var h = a.cache.getTilemapData(c);
  9013. if (h) {
  9014. if (h.format === b.Tilemap.CSV) return this.parseCSV(c, h.data, d, e);
  9015. if (!h.format || h.format === b.Tilemap.TILED_JSON) return this.parseTiledJSON(h.data)
  9016. } else console.warn("Phaser.TilemapParser.parse - No map data found for key " + c)
  9017. },
  9018. parseCSV: function(a, c, d, e) {
  9019. var f = this.getEmptyData();
  9020. c = c.trim();
  9021. for (var g = [], h = c.split("\n"), i = h.length, j = 0, k = 0; k < h.length; k++) {
  9022. g[k] = [];
  9023. for (var 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);
  9024. 0 === j && (j = l.length)
  9025. }
  9026. 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
  9027. },
  9028. getEmptyData: function(a, b, c, d) {
  9029. var e = {};
  9030. 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;
  9031. var f = [],
  9032. g = {
  9033. name: "layer",
  9034. x: 0,
  9035. y: 0,
  9036. width: 0,
  9037. height: 0,
  9038. widthInPixels: 0,
  9039. heightInPixels: 0,
  9040. alpha: 1,
  9041. visible: !0,
  9042. properties: {},
  9043. indexes: [],
  9044. callbacks: [],
  9045. data: []
  9046. };
  9047. return f.push(g), e.layers = f, e.images = [], e.objects = {}, e.collision = {}, e.tilesets = [], e.tiles = [], e
  9048. },
  9049. parseTiledJSON: function(a) {
  9050. function c(a, b) {
  9051. var c = {};
  9052. for (var d in b) {
  9053. var e = b[d];
  9054. c[e] = a[e]
  9055. }
  9056. return c
  9057. }
  9058. if ("orthogonal" !== a.orientation) return console.warn("TilemapParser.parseTiledJSON: Only orthogonal map types are supported in this version of Phaser"), null;
  9059. var d = {};
  9060. d.width = a.width, d.height = a.height, d.tileWidth = a.tilewidth, d.tileHeight = a.tileheight, d.orientation = a.orientation, d.format = b.Tilemap.TILED_JSON, d.version = a.version, d.properties = a.properties, d.widthInPixels = d.width * d.tileWidth, d.heightInPixels = d.height * d.tileHeight;
  9061. for (var e = [], f = 0; f < a.layers.length; f++)
  9062. if ("tilelayer" === a.layers[f].type) {
  9063. var g = {
  9064. name: a.layers[f].name,
  9065. x: a.layers[f].x,
  9066. y: a.layers[f].y,
  9067. width: a.layers[f].width,
  9068. height: a.layers[f].height,
  9069. widthInPixels: a.layers[f].width * a.tilewidth,
  9070. heightInPixels: a.layers[f].height * a.tileheight,
  9071. alpha: a.layers[f].opacity,
  9072. visible: a.layers[f].visible,
  9073. properties: {},
  9074. indexes: [],
  9075. callbacks: [],
  9076. bodies: []
  9077. };
  9078. a.layers[f].properties && (g.properties = a.layers[f].properties);
  9079. for (var h = 0, i = [], j = [], k = 0, l = a.layers[f].data.length; l > k; k++) i.push(a.layers[f].data[k] > 0 ? new b.Tile(g, a.layers[f].data[k], h, j.length, a.tilewidth, a.tileheight) : new b.Tile(g, -1, h, j.length, a.tilewidth, a.tileheight)), h++, h === a.layers[f].width && (j.push(i), h = 0, i = []);
  9080. g.data = j, e.push(g)
  9081. }
  9082. d.layers = e;
  9083. for (var m = [], f = 0; f < a.layers.length; f++)
  9084. if ("imagelayer" === a.layers[f].type) {
  9085. var n = {
  9086. name: a.layers[f].name,
  9087. image: a.layers[f].image,
  9088. x: a.layers[f].x,
  9089. y: a.layers[f].y,
  9090. alpha: a.layers[f].opacity,
  9091. visible: a.layers[f].visible,
  9092. properties: {}
  9093. };
  9094. a.layers[f].properties && (n.properties = a.layers[f].properties), m.push(n)
  9095. }
  9096. d.images = m;
  9097. for (var o = [], f = 0; f < a.tilesets.length; f++) {
  9098. var p = a.tilesets[f],
  9099. q = new b.Tileset(p.name, p.firstgid, p.tilewidth, p.tileheight, p.margin, p.spacing, p.properties);
  9100. p.tileproperties && (q.tileProperties = p.tileproperties), q.rows = Math.round((p.imageheight - p.margin) / (p.tileheight + p.spacing)), q.columns = Math.round((p.imagewidth - p.margin) / (p.tilewidth + p.spacing)), q.total = q.rows * q.columns, q.rows % 1 !== 0 || q.columns % 1 !== 0 ? console.warn("TileSet image dimensions do not match expected dimensions. Tileset width/height must be evenly divisible by Tilemap tile width/height.") : o.push(q)
  9101. }
  9102. d.tilesets = o;
  9103. for (var r = {}, s = {}, f = 0; f < a.layers.length; f++)
  9104. if ("objectgroup" === a.layers[f].type) {
  9105. r[a.layers[f].name] = [], s[a.layers[f].name] = [];
  9106. for (var t = 0, l = a.layers[f].objects.length; l > t; t++)
  9107. if (a.layers[f].objects[t].gid) {
  9108. var u = {
  9109. gid: a.layers[f].objects[t].gid,
  9110. name: a.layers[f].objects[t].name,
  9111. x: a.layers[f].objects[t].x,
  9112. y: a.layers[f].objects[t].y,
  9113. visible: a.layers[f].objects[t].visible,
  9114. properties: a.layers[f].objects[t].properties
  9115. };
  9116. r[a.layers[f].name].push(u)
  9117. } else if (a.layers[f].objects[t].polyline) {
  9118. var u = {
  9119. name: a.layers[f].objects[t].name,
  9120. x: a.layers[f].objects[t].x,
  9121. y: a.layers[f].objects[t].y,
  9122. width: a.layers[f].objects[t].width,
  9123. height: a.layers[f].objects[t].height,
  9124. visible: a.layers[f].objects[t].visible,
  9125. properties: a.layers[f].objects[t].properties
  9126. };
  9127. u.polyline = [];
  9128. for (var v = 0; v < a.layers[f].objects[t].polyline.length; v++) u.polyline.push([a.layers[f].objects[t].polyline[v].x, a.layers[f].objects[t].polyline[v].y]);
  9129. s[a.layers[f].name].push(u)
  9130. } else if (a.layers[f].objects[t].polygon) {
  9131. var u = c(a.layers[f].objects[t], ["name", "x", "y", "visible", "properties"]);
  9132. u.polygon = [];
  9133. for (var v = 0; v < a.layers[f].objects[t].polygon.length; v++) u.polygon.push([a.layers[f].objects[t].polygon[v].x, a.layers[f].objects[t].polygon[v].y]);
  9134. r[a.layers[f].name].push(u)
  9135. } else if (a.layers[f].objects[t].ellipse) {
  9136. var u = c(a.layers[f].objects[t], ["name", "ellipse", "x", "y", "width", "height", "visible", "properties"]);
  9137. r[a.layers[f].name].push(u)
  9138. } else {
  9139. var u = c(a.layers[f].objects[t], ["name", "x", "y", "width", "height", "visible", "properties"]);
  9140. u.rectangle = !0, r[a.layers[f].name].push(u)
  9141. }
  9142. }
  9143. d.objects = r, d.collision = s, d.tiles = [];
  9144. for (var f = 0; f < d.tilesets.length; f++)
  9145. for (var p = d.tilesets[f], h = p.tileMargin, w = p.tileMargin, x = 0, y = 0, z = 0, k = p.firstgid; k < p.firstgid + p.total && (d.tiles[k] = [h, w, f], h += p.tileWidth + p.tileSpacing, x++, x !== p.total) && (y++, y !== p.columns || (h = p.tileMargin, w += p.tileHeight + p.tileSpacing, y = 0, z++, z !== p.rows)); k++);
  9146. return d
  9147. }
  9148. }, b.Tileset = function(a, b, c, d, e, f, g) {
  9149. ("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 = []
  9150. }, b.Tileset.prototype = {
  9151. draw: function(a, b, c, d) {
  9152. 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)
  9153. },
  9154. setImage: function(a) {
  9155. 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;
  9156. for (var b = this.tileMargin, c = this.tileMargin, d = this.firstgid, e = 0; e < this.rows; e++) {
  9157. for (var f = 0; f < this.columns; f++) this.drawCoords[d] = [b, c], b += this.tileWidth + this.tileSpacing, d++;
  9158. b = this.tileMargin, c += this.tileHeight + this.tileSpacing
  9159. }
  9160. },
  9161. setSpacing: function(a, b) {
  9162. this.tileMargin = a, this.tileSpacing = b, this.setImage(this.image)
  9163. }
  9164. }, 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() {
  9165. return a.Phaser = b
  9166. }()) : a.Phaser = b
  9167. }.call(this), Phaser.Physics.Ninja = function(a) {
  9168. this.game = a, this.time = this.game.time, this.gravity = .2, this.bounds = new Phaser.Rectangle(0, 0, a.world.width, a.world.height), this.maxObjects = 10, this.maxLevels = 4, this.quadTree = new Phaser.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)
  9169. }, Phaser.Physics.Ninja.prototype.constructor = Phaser.Physics.Ninja, Phaser.Physics.Ninja.prototype = {
  9170. enableAABB: function(a, b) {
  9171. this.enable(a, 1, 0, 0, b)
  9172. },
  9173. enableCircle: function(a, b, c) {
  9174. this.enable(a, 2, 0, b, c)
  9175. },
  9176. enableTile: function(a, b, c) {
  9177. this.enable(a, 3, b, 0, c)
  9178. },
  9179. enable: function(a, b, c, d, e) {
  9180. if ("undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = !0), Array.isArray(a))
  9181. for (var f = a.length; f--;) a[f] instanceof Phaser.Group ? this.enable(a[f].children, b, c, d, e) : (this.enableBody(a[f], b, c, d), e && a[f].hasOwnProperty("children") && a[f].children.length > 0 && this.enable(a[f], b, c, d, !0));
  9182. else a instanceof Phaser.Group ? this.enable(a.children, b, c, d, e) : (this.enableBody(a, b, c, d), e && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, b, c, d, !0))
  9183. },
  9184. enableBody: function(a, b, c, d) {
  9185. a.hasOwnProperty("body") && null === a.body && (a.body = new Phaser.Physics.Ninja.Body(this, a, b, c, d), a.anchor.set(.5))
  9186. },
  9187. setBounds: function(a, b, c, d) {
  9188. this.bounds.setTo(a, b, c, d)
  9189. },
  9190. setBoundsToWorld: function() {
  9191. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  9192. },
  9193. clearTilemapLayerBodies: function(a, b) {
  9194. b = a.getLayer(b);
  9195. for (var c = a.layers[b].bodies.length; c--;) a.layers[b].bodies[c].destroy();
  9196. a.layers[b].bodies.length = []
  9197. },
  9198. convertTilemap: function(a, b, c) {
  9199. b = a.getLayer(b), this.clearTilemapLayerBodies(a, b);
  9200. for (var d = 0, e = a.layers[b].height; e > d; d++)
  9201. for (var f = 0, g = a.layers[b].width; g > f; f++) {
  9202. var h = a.layers[b].data[d][f];
  9203. if (h && c.hasOwnProperty(h.index)) {
  9204. var i = new Phaser.Physics.Ninja.Body(this, null, 3, c[h.index], 0, h.worldX + h.centerX, h.worldY + h.centerY, h.width, h.height);
  9205. a.layers[b].bodies.push(i)
  9206. }
  9207. }
  9208. return a.layers[b].bodies
  9209. },
  9210. overlap: function(a, b, c, d, e) {
  9211. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  9212. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !0);
  9213. else this.collideHandler(a, b, c, d, e, !0);
  9214. return this._total > 0
  9215. },
  9216. collide: function(a, b, c, d, e) {
  9217. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  9218. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !1);
  9219. else this.collideHandler(a, b, c, d, e, !1);
  9220. return this._total > 0
  9221. },
  9222. collideHandler: function(a, b, c, d, e, f) {
  9223. return "undefined" != typeof b || a.type !== Phaser.GROUP && a.type !== Phaser.EMITTER ? void(a && b && a.exists && b.exists && (a.type == Phaser.SPRITE || a.type == Phaser.TILESPRITE ? b.type == Phaser.SPRITE || b.type == Phaser.TILESPRITE ? this.collideSpriteVsSprite(a, b, c, d, e, f) : b.type == Phaser.GROUP || b.type == Phaser.EMITTER ? this.collideSpriteVsGroup(a, b, c, d, e, f) : b.type == Phaser.TILEMAPLAYER && this.collideSpriteVsTilemapLayer(a, b, c, d, e) : a.type == Phaser.GROUP ? b.type == Phaser.SPRITE || b.type == Phaser.TILESPRITE ? this.collideSpriteVsGroup(b, a, c, d, e, f) : b.type == Phaser.GROUP || b.type == Phaser.EMITTER ? this.collideGroupVsGroup(a, b, c, d, e, f) : b.type == Phaser.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, b, c, d, e) : a.type == Phaser.TILEMAPLAYER ? b.type == Phaser.SPRITE || b.type == Phaser.TILESPRITE ? this.collideSpriteVsTilemapLayer(b, a, c, d, e) : (b.type == Phaser.GROUP || b.type == Phaser.EMITTER) && this.collideGroupVsTilemapLayer(b, a, c, d, e) : a.type == Phaser.EMITTER && (b.type == Phaser.SPRITE || b.type == Phaser.TILESPRITE ? this.collideSpriteVsGroup(b, a, c, d, e, f) : b.type == Phaser.GROUP || b.type == Phaser.EMITTER ? this.collideGroupVsGroup(a, b, c, d, e, f) : b.type == Phaser.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, b, c, d, e)))) : void this.collideGroupVsSelf(a, c, d, e, f)
  9224. },
  9225. collideSpriteVsSprite: function(a, b, c, d, e, f) {
  9226. this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++)
  9227. },
  9228. collideSpriteVsGroup: function(a, b, c, d, e, f) {
  9229. if (0 !== b.length)
  9230. for (var g = 0, h = b.children.length; h > g; g++) b.children[g].exists && b.children[g].body && this.separate(a.body, b.children[g].body, d, e, f) && (c && c.call(e, a, b.children[g]), this._total++)
  9231. },
  9232. collideGroupVsSelf: function(a, b, c, d, e) {
  9233. if (0 !== a.length)
  9234. for (var f = a.children.length, g = 0; f > g; g++)
  9235. for (var 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)
  9236. },
  9237. collideGroupVsGroup: function(a, b, c, d, e, f) {
  9238. if (0 !== a.length && 0 !== b.length)
  9239. 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)
  9240. },
  9241. separate: function(a, b) {
  9242. return a.type !== Phaser.Physics.NINJA || b.type !== Phaser.Physics.NINJA ? !1 : a.aabb && b.aabb ? a.aabb.collideAABBVsAABB(b.aabb) : a.aabb && b.tile ? a.aabb.collideAABBVsTile(b.tile) : a.tile && b.aabb ? b.aabb.collideAABBVsTile(a.tile) : a.circle && b.tile ? a.circle.collideCircleVsTile(b.tile) : a.tile && b.circle ? b.circle.collideCircleVsTile(a.tile) : void 0
  9243. }
  9244. }, Phaser.Physics.Ninja.Body = function(a, b, c, d, e, f, g, h, i) {
  9245. b = b || null, "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = 16), this.sprite = b, this.game = a.game, this.type = Phaser.Physics.NINJA, this.system = a, this.aabb = null, this.tile = null, this.circle = null, this.shape = null, this.drag = 1, this.friction = .05, this.gravityScale = 1, this.bounce = .3, this.velocity = new Phaser.Point, this.facing = Phaser.NONE, this.immovable = !1, this.collideWorldBounds = !0, this.checkCollision = {
  9246. none: !1,
  9247. any: !0,
  9248. up: !0,
  9249. down: !0,
  9250. left: !0,
  9251. right: !0
  9252. }, this.touching = {
  9253. none: !0,
  9254. up: !1,
  9255. down: !1,
  9256. left: !1,
  9257. right: !1
  9258. }, this.wasTouching = {
  9259. none: !0,
  9260. up: !1,
  9261. down: !1,
  9262. left: !1,
  9263. right: !1
  9264. }, this.maxSpeed = 8, b && (f = b.x, g = b.y, h = b.width, i = b.height, 0 === b.anchor.x && (f += .5 * b.width), 0 === b.anchor.y && (g += .5 * b.height)), 1 === c ? (this.aabb = new Phaser.Physics.Ninja.AABB(this, f, g, h, i), this.shape = this.aabb) : 2 === c ? (this.circle = new Phaser.Physics.Ninja.Circle(this, f, g, e), this.shape = this.circle) : 3 === c && (this.tile = new Phaser.Physics.Ninja.Tile(this, f, g, h, i, d), this.shape = this.tile)
  9265. }, Phaser.Physics.Ninja.Body.prototype = {
  9266. preUpdate: function() {
  9267. 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.shape.integrate(), this.collideWorldBounds && this.shape.collideWorldBounds()
  9268. },
  9269. postUpdate: function() {
  9270. this.sprite && (this.sprite.type === Phaser.TILESPRITE ? (this.sprite.x = this.shape.pos.x - this.shape.xw, this.sprite.y = this.shape.pos.y - this.shape.yw) : (this.sprite.x = this.shape.pos.x, this.sprite.y = this.shape.pos.y)), this.velocity.x < 0 ? this.facing = Phaser.LEFT : this.velocity.x > 0 && (this.facing = Phaser.RIGHT), this.velocity.y < 0 ? this.facing = Phaser.UP : this.velocity.y > 0 && (this.facing = Phaser.DOWN)
  9271. },
  9272. setZeroVelocity: function() {
  9273. this.shape.oldpos.x = this.shape.pos.x, this.shape.oldpos.y = this.shape.pos.y
  9274. },
  9275. moveTo: function(a, b) {
  9276. var c = a * this.game.time.physicsElapsed,
  9277. b = this.game.math.degToRad(b);
  9278. this.shape.pos.x = this.shape.oldpos.x + c * Math.cos(b), this.shape.pos.y = this.shape.oldpos.y + c * Math.sin(b)
  9279. },
  9280. moveFrom: function(a, b) {
  9281. var c = -a * this.game.time.physicsElapsed,
  9282. b = this.game.math.degToRad(b);
  9283. this.shape.pos.x = this.shape.oldpos.x + c * Math.cos(b), this.shape.pos.y = this.shape.oldpos.y + c * Math.sin(b)
  9284. },
  9285. moveLeft: function(a) {
  9286. var b = -a * this.game.time.physicsElapsed;
  9287. this.shape.pos.x = this.shape.oldpos.x + Math.min(this.maxSpeed, Math.max(-this.maxSpeed, this.shape.pos.x - this.shape.oldpos.x + b))
  9288. },
  9289. moveRight: function(a) {
  9290. var b = a * this.game.time.physicsElapsed;
  9291. this.shape.pos.x = this.shape.oldpos.x + Math.min(this.maxSpeed, Math.max(-this.maxSpeed, this.shape.pos.x - this.shape.oldpos.x + b))
  9292. },
  9293. moveUp: function(a) {
  9294. var b = -a * this.game.time.physicsElapsed;
  9295. this.shape.pos.y = this.shape.oldpos.y + Math.min(this.maxSpeed, Math.max(-this.maxSpeed, this.shape.pos.y - this.shape.oldpos.y + b))
  9296. },
  9297. moveDown: function(a) {
  9298. var b = a * this.game.time.physicsElapsed;
  9299. this.shape.pos.y = this.shape.oldpos.y + Math.min(this.maxSpeed, Math.max(-this.maxSpeed, this.shape.pos.y - this.shape.oldpos.y + b))
  9300. },
  9301. reset: function() {
  9302. this.velocity.set(0), this.shape.pos.x = this.sprite.x, this.shape.pos.y = this.sprite.y, this.shape.oldpos.copyFrom(this.shape.pos)
  9303. },
  9304. deltaAbsX: function() {
  9305. return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
  9306. },
  9307. deltaAbsY: function() {
  9308. return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
  9309. },
  9310. deltaX: function() {
  9311. return this.shape.pos.x - this.shape.oldpos.x
  9312. },
  9313. deltaY: function() {
  9314. return this.shape.pos.y - this.shape.oldpos.y
  9315. },
  9316. destroy: function() {
  9317. this.sprite = null, this.system = null, this.aabb = null, this.tile = null, this.circle = null, this.shape.destroy(), this.shape = null
  9318. }
  9319. }, Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "x", {
  9320. get: function() {
  9321. return this.shape.pos.x
  9322. },
  9323. set: function(a) {
  9324. this.shape.pos.x = a
  9325. }
  9326. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "y", {
  9327. get: function() {
  9328. return this.shape.pos.y
  9329. },
  9330. set: function(a) {
  9331. this.shape.pos.y = a
  9332. }
  9333. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "width", {
  9334. get: function() {
  9335. return this.shape.width
  9336. }
  9337. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "height", {
  9338. get: function() {
  9339. return this.shape.height
  9340. }
  9341. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "bottom", {
  9342. get: function() {
  9343. return this.shape.pos.y + this.shape.yw
  9344. }
  9345. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "right", {
  9346. get: function() {
  9347. return this.shape.pos.x + this.shape.xw
  9348. }
  9349. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "speed", {
  9350. get: function() {
  9351. return Math.sqrt(this.shape.velocity.x * this.shape.velocity.x + this.shape.velocity.y * this.shape.velocity.y)
  9352. }
  9353. }), Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "angle", {
  9354. get: function() {
  9355. return Math.atan2(this.shape.velocity.y, this.shape.velocity.x)
  9356. }
  9357. }), Phaser.Physics.Ninja.Body.render = function(a, b, c, d) {
  9358. c = c || "rgba(0,255,0,0.4)", "undefined" == typeof d && (d = !0), (b.aabb || b.circle) && b.shape.render(a, b.game.camera.x, b.game.camera.y, c, d)
  9359. }, Phaser.Physics.Ninja.AABB = function(a, b, c, d, e) {
  9360. this.body = a, this.system = a.system, this.pos = new Phaser.Point(b, c), this.oldpos = new Phaser.Point(b, c), this.xw = Math.abs(d / 2), this.yw = Math.abs(e / 2), this.width = d, this.height = e, this.oH = 0, this.oV = 0, this.velocity = new Phaser.Point, this.aabbTileProjections = {}, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_FULL] = this.projAABB_Full, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_45DEG] = this.projAABB_45Deg, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONCAVE] = this.projAABB_Concave, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONVEX] = this.projAABB_Convex, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGs] = this.projAABB_22DegS, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGb] = this.projAABB_22DegB, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGs] = this.projAABB_67DegS, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGb] = this.projAABB_67DegB, this.aabbTileProjections[Phaser.Physics.Ninja.Tile.TYPE_HALF] = this.projAABB_Half
  9361. }, Phaser.Physics.Ninja.AABB.prototype.constructor = Phaser.Physics.Ninja.AABB, Phaser.Physics.Ninja.AABB.COL_NONE = 0, Phaser.Physics.Ninja.AABB.COL_AXIS = 1, Phaser.Physics.Ninja.AABB.COL_OTHER = 2, Phaser.Physics.Ninja.AABB.prototype = {
  9362. integrate: function() {
  9363. var a = this.pos.x,
  9364. b = this.pos.y;
  9365. this.pos.x += this.body.drag * this.pos.x - this.body.drag * this.oldpos.x, this.pos.y += this.body.drag * this.pos.y - this.body.drag * this.oldpos.y + this.system.gravity * this.body.gravityScale, this.velocity.set(this.pos.x - a, this.pos.y - b), this.oldpos.set(a, b)
  9366. },
  9367. reportCollisionVsWorld: function(a, b, c, d) {
  9368. var e, f, g, h, i, j = this.pos,
  9369. k = this.oldpos,
  9370. l = j.x - k.x,
  9371. m = j.y - k.y,
  9372. n = l * c + m * d,
  9373. o = n * c,
  9374. p = n * d,
  9375. q = l - o,
  9376. r = m - p;
  9377. 0 > n ? (h = q * this.body.friction, i = r * this.body.friction, e = 1 + this.body.bounce, f = o * e, g = p * e, 1 === c ? this.body.touching.left = !0 : -1 === c && (this.body.touching.right = !0), 1 === d ? this.body.touching.up = !0 : -1 === d && (this.body.touching.down = !0)) : f = g = h = i = 0, j.x += a, j.y += b, k.x += a + f + h, k.y += b + g + i
  9378. },
  9379. reverse: function() {
  9380. var a = this.pos.x - this.oldpos.x,
  9381. b = this.pos.y - this.oldpos.y;
  9382. this.oldpos.x < this.pos.x ? this.oldpos.x = this.pos.x + a : this.oldpos.x > this.pos.x && (this.oldpos.x = this.pos.x - a), this.oldpos.y < this.pos.y ? this.oldpos.y = this.pos.y + b : this.oldpos.y > this.pos.y && (this.oldpos.y = this.pos.y - b)
  9383. },
  9384. reportCollisionVsBody: function(a, b, c, d, e) {
  9385. var f = this.pos.x - this.oldpos.x,
  9386. g = this.pos.y - this.oldpos.y,
  9387. h = f * c + g * d;
  9388. return this.body.immovable && e.body.immovable ? (a *= .5, b *= .5, this.pos.add(a, b), this.oldpos.set(this.pos.x, this.pos.y), e.pos.subtract(a, b), void e.oldpos.set(e.pos.x, e.pos.y)) : void(this.body.immovable || e.body.immovable ? this.body.immovable ? e.body.immovable || (e.pos.subtract(a, b), 0 > h && e.reverse()) : (this.pos.subtract(a, b), 0 > h && this.reverse()) : (a *= .5, b *= .5, this.pos.add(a, b), e.pos.subtract(a, b), 0 > h && (this.reverse(), e.reverse())))
  9389. },
  9390. collideWorldBounds: function() {
  9391. var a = this.system.bounds.x - (this.pos.x - this.xw);
  9392. a > 0 ? this.reportCollisionVsWorld(a, 0, 1, 0, null) : (a = this.pos.x + this.xw - this.system.bounds.right, a > 0 && this.reportCollisionVsWorld(-a, 0, -1, 0, null));
  9393. var b = this.system.bounds.y - (this.pos.y - this.yw);
  9394. b > 0 ? this.reportCollisionVsWorld(0, b, 0, 1, null) : (b = this.pos.y + this.yw - this.system.bounds.bottom, b > 0 && this.reportCollisionVsWorld(0, -b, 0, -1, null))
  9395. },
  9396. collideAABBVsAABB: function(a) {
  9397. var b = this.pos,
  9398. c = a,
  9399. d = c.pos.x,
  9400. e = c.pos.y,
  9401. f = c.xw,
  9402. g = c.yw,
  9403. h = b.x - d,
  9404. i = f + this.xw - Math.abs(h);
  9405. if (i > 0) {
  9406. var j = b.y - e,
  9407. k = g + this.yw - Math.abs(j);
  9408. if (k > 0) {
  9409. k > i ? 0 > h ? (i *= -1, k = 0) : k = 0 : 0 > j ? (i = 0, k *= -1) : i = 0;
  9410. var l = Math.sqrt(i * i + k * k);
  9411. return this.reportCollisionVsBody(i, k, i / l, k / l, c), Phaser.Physics.Ninja.AABB.COL_AXIS
  9412. }
  9413. }
  9414. return !1
  9415. },
  9416. collideAABBVsTile: function(a) {
  9417. var b = this.pos.x - a.pos.x,
  9418. c = a.xw + this.xw - Math.abs(b);
  9419. if (c > 0) {
  9420. var d = this.pos.y - a.pos.y,
  9421. e = a.yw + this.yw - Math.abs(d);
  9422. if (e > 0) return e > c ? 0 > b ? (c *= -1, e = 0) : e = 0 : 0 > d ? (c = 0, e *= -1) : c = 0, this.resolveTile(c, e, this, a)
  9423. }
  9424. return !1
  9425. },
  9426. resolveTile: function(a, b, c, d) {
  9427. return 0 < d.id ? this.aabbTileProjections[d.type](a, b, c, d) : !1
  9428. },
  9429. projAABB_Full: function(a, b, c, d) {
  9430. var e = Math.sqrt(a * a + b * b);
  9431. return c.reportCollisionVsWorld(a, b, a / e, b / e, d), Phaser.Physics.Ninja.AABB.COL_AXIS
  9432. },
  9433. projAABB_Half: function(a, b, c, d) {
  9434. var e = d.signx,
  9435. f = d.signy,
  9436. g = c.pos.x - e * c.xw - d.pos.x,
  9437. h = c.pos.y - f * c.yw - d.pos.y,
  9438. i = g * e + h * f;
  9439. if (0 > i) {
  9440. e *= -i, f *= -i;
  9441. var j = Math.sqrt(e * e + f * f),
  9442. k = Math.sqrt(a * a + b * b);
  9443. return j > k ? (c.reportCollisionVsWorld(a, b, a / k, b / k, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : (c.reportCollisionVsWorld(e, f, d.signx, d.signy, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9444. }
  9445. return Phaser.Physics.Ninja.AABB.COL_NONE
  9446. },
  9447. projAABB_45Deg: function(a, b, c, d) {
  9448. var e = d.signx,
  9449. f = d.signy,
  9450. g = c.pos.x - e * c.xw - d.pos.x,
  9451. h = c.pos.y - f * c.yw - d.pos.y,
  9452. i = d.sx,
  9453. j = d.sy,
  9454. k = g * i + h * j;
  9455. if (0 > k) {
  9456. i *= -k, j *= -k;
  9457. var l = Math.sqrt(i * i + j * j),
  9458. m = Math.sqrt(a * a + b * b);
  9459. return l > m ? (c.reportCollisionVsWorld(a, b, a / m, b / m, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : (c.reportCollisionVsWorld(i, j, d.sx, d.sy), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9460. }
  9461. return Phaser.Physics.Ninja.AABB.COL_NONE
  9462. },
  9463. projAABB_22DegS: function(a, b, c, d) {
  9464. var e = d.signx,
  9465. f = d.signy,
  9466. g = c.pos.y - f * c.yw,
  9467. h = d.pos.y - g;
  9468. if (h * f > 0) {
  9469. var i = c.pos.x - e * c.xw - (d.pos.x + e * d.xw),
  9470. j = c.pos.y - f * c.yw - (d.pos.y - f * d.yw),
  9471. k = d.sx,
  9472. l = d.sy,
  9473. m = i * k + j * l;
  9474. if (0 > m) {
  9475. k *= -m, l *= -m;
  9476. var n = Math.sqrt(k * k + l * l),
  9477. o = Math.sqrt(a * a + b * b),
  9478. p = Math.abs(h);
  9479. return n > o ? o > p ? (c.reportCollisionVsWorld(0, h, 0, h / p, d), Phaser.Physics.Ninja.AABB.COL_OTHER) : (c.reportCollisionVsWorld(a, b, a / o, b / o, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : n > p ? (c.reportCollisionVsWorld(0, h, 0, h / p, d), Phaser.Physics.Ninja.AABB.COL_OTHER) : (c.reportCollisionVsWorld(k, l, d.sx, d.sy, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9480. }
  9481. }
  9482. return Phaser.Physics.Ninja.AABB.COL_NONE
  9483. },
  9484. projAABB_22DegB: function(a, b, c, d) {
  9485. var e = d.signx,
  9486. f = d.signy,
  9487. g = c.pos.x - e * c.xw - (d.pos.x - e * d.xw),
  9488. h = c.pos.y - f * c.yw - (d.pos.y + f * d.yw),
  9489. i = d.sx,
  9490. j = d.sy,
  9491. k = g * i + h * j;
  9492. if (0 > k) {
  9493. i *= -k, j *= -k;
  9494. var l = Math.sqrt(i * i + j * j),
  9495. m = Math.sqrt(a * a + b * b);
  9496. return l > m ? (c.reportCollisionVsWorld(a, b, a / m, b / m, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : (c.reportCollisionVsWorld(i, j, d.sx, d.sy, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9497. }
  9498. return Phaser.Physics.Ninja.AABB.COL_NONE
  9499. },
  9500. projAABB_67DegS: function(a, b, c, d) {
  9501. var e = d.signx,
  9502. f = d.signy,
  9503. g = c.pos.x - e * c.xw,
  9504. h = d.pos.x - g;
  9505. if (h * e > 0) {
  9506. var i = c.pos.x - e * c.xw - (d.pos.x - e * d.xw),
  9507. j = c.pos.y - f * c.yw - (d.pos.y + f * d.yw),
  9508. k = d.sx,
  9509. l = d.sy,
  9510. m = i * k + j * l;
  9511. if (0 > m) {
  9512. k *= -m, l *= -m;
  9513. var n = Math.sqrt(k * k + l * l),
  9514. o = Math.sqrt(a * a + b * b),
  9515. p = Math.abs(h);
  9516. return n > o ? o > p ? (c.reportCollisionVsWorld(h, 0, h / p, 0, d), Phaser.Physics.Ninja.AABB.COL_OTHER) : (c.reportCollisionVsWorld(a, b, a / o, b / o, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : n > p ? (c.reportCollisionVsWorld(h, 0, h / p, 0, d), Phaser.Physics.Ninja.AABB.COL_OTHER) : (c.reportCollisionVsWorld(k, l, d.sx, d.sy, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9517. }
  9518. }
  9519. return Phaser.Physics.Ninja.AABB.COL_NONE
  9520. },
  9521. projAABB_67DegB: function(a, b, c, d) {
  9522. var e = d.signx,
  9523. f = d.signy,
  9524. g = c.pos.x - e * c.xw - (d.pos.x + e * d.xw),
  9525. h = c.pos.y - f * c.yw - (d.pos.y - f * d.yw),
  9526. i = d.sx,
  9527. j = d.sy,
  9528. k = g * i + h * j;
  9529. if (0 > k) {
  9530. i *= -k, j *= -k;
  9531. var l = Math.sqrt(i * i + j * j),
  9532. m = Math.sqrt(a * a + b * b);
  9533. return l > m ? (c.reportCollisionVsWorld(a, b, a / m, b / m, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : (c.reportCollisionVsWorld(i, j, d.sx, d.sy, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9534. }
  9535. return Phaser.Physics.Ninja.AABB.COL_NONE
  9536. },
  9537. projAABB_Convex: function(a, b, c, d) {
  9538. var e = d.signx,
  9539. f = d.signy,
  9540. g = c.pos.x - e * c.xw - (d.pos.x - e * d.xw),
  9541. h = c.pos.y - f * c.yw - (d.pos.y - f * d.yw),
  9542. i = Math.sqrt(g * g + h * h),
  9543. j = 2 * d.xw,
  9544. k = Math.sqrt(j * j + 0),
  9545. l = k - i;
  9546. if (0 > e * g || 0 > f * h) {
  9547. var m = Math.sqrt(a * a + b * b);
  9548. return c.reportCollisionVsWorld(a, b, a / m, b / m, d), Phaser.Physics.Ninja.AABB.COL_AXIS
  9549. }
  9550. return l > 0 ? (g /= i, h /= i, c.reportCollisionVsWorld(g * l, h * l, g, h, d), Phaser.Physics.Ninja.AABB.COL_OTHER) : Phaser.Physics.Ninja.AABB.COL_NONE
  9551. },
  9552. projAABB_Concave: function(a, b, c, d) {
  9553. var e = d.signx,
  9554. f = d.signy,
  9555. g = d.pos.x + e * d.xw - (c.pos.x - e * c.xw),
  9556. h = d.pos.y + f * d.yw - (c.pos.y - f * c.yw),
  9557. i = 2 * d.xw,
  9558. j = Math.sqrt(i * i + 0),
  9559. k = Math.sqrt(g * g + h * h),
  9560. l = k - j;
  9561. if (l > 0) {
  9562. var m = Math.sqrt(a * a + b * b);
  9563. return l > m ? (c.reportCollisionVsWorld(a, b, a / m, b / m, d), Phaser.Physics.Ninja.AABB.COL_AXIS) : (g /= k, h /= k, c.reportCollisionVsWorld(g * l, h * l, g, h, d), Phaser.Physics.Ninja.AABB.COL_OTHER)
  9564. }
  9565. return Phaser.Physics.Ninja.AABB.COL_NONE
  9566. },
  9567. destroy: function() {
  9568. this.body = null, this.system = null
  9569. },
  9570. render: function(a, b, c, d, e) {
  9571. var f = this.pos.x - this.xw - b,
  9572. g = this.pos.y - this.yw - c;
  9573. e ? (a.fillStyle = d, a.fillRect(f, g, this.width, this.height)) : (a.strokeStyle = d, a.strokeRect(f, g, this.width, this.height))
  9574. }
  9575. }, Phaser.Physics.Ninja.Tile = function(a, b, c, d, e, f) {
  9576. "undefined" == typeof f && (f = Phaser.Physics.Ninja.Tile.EMPTY), this.body = a, this.system = a.system, this.id = f, this.type = Phaser.Physics.Ninja.Tile.TYPE_EMPTY, this.pos = new Phaser.Point(b, c), this.oldpos = new Phaser.Point(b, c), this.id > 1 && this.id < 30 && (e = d), this.xw = Math.abs(d / 2), this.yw = Math.abs(e / 2), this.width = d, this.height = e, this.velocity = new Phaser.Point, this.signx = 0, this.signy = 0, this.sx = 0, this.sy = 0, this.body.gravityScale = 0, this.body.collideWorldBounds = !1, this.id > 0 && this.setType(this.id)
  9577. }, Phaser.Physics.Ninja.Tile.prototype.constructor = Phaser.Physics.Ninja.Tile, Phaser.Physics.Ninja.Tile.prototype = {
  9578. integrate: function() {
  9579. var a = this.pos.x,
  9580. b = this.pos.y;
  9581. this.pos.x += this.body.drag * this.pos.x - this.body.drag * this.oldpos.x, this.pos.y += this.body.drag * this.pos.y - this.body.drag * this.oldpos.y + this.system.gravity * this.body.gravityScale, this.velocity.set(this.pos.x - a, this.pos.y - b), this.oldpos.set(a, b)
  9582. },
  9583. collideWorldBounds: function() {
  9584. var a = this.system.bounds.x - (this.pos.x - this.xw);
  9585. a > 0 ? this.reportCollisionVsWorld(a, 0, 1, 0, null) : (a = this.pos.x + this.xw - this.system.bounds.right, a > 0 && this.reportCollisionVsWorld(-a, 0, -1, 0, null));
  9586. var b = this.system.bounds.y - (this.pos.y - this.yw);
  9587. b > 0 ? this.reportCollisionVsWorld(0, b, 0, 1, null) : (b = this.pos.y + this.yw - this.system.bounds.bottom, b > 0 && this.reportCollisionVsWorld(0, -b, 0, -1, null))
  9588. },
  9589. reportCollisionVsWorld: function(a, b, c, d) {
  9590. var e, f, g, h, i, j = this.pos,
  9591. k = this.oldpos,
  9592. l = j.x - k.x,
  9593. m = j.y - k.y,
  9594. n = l * c + m * d,
  9595. o = n * c,
  9596. p = n * d,
  9597. q = l - o,
  9598. r = m - p;
  9599. 0 > n ? (h = q * this.body.friction, i = r * this.body.friction, e = 1 + this.body.bounce, f = o * e, g = p * e, 1 === c ? this.body.touching.left = !0 : -1 === c && (this.body.touching.right = !0), 1 === d ? this.body.touching.up = !0 : -1 === d && (this.body.touching.down = !0)) : f = g = h = i = 0, j.x += a, j.y += b, k.x += a + f + h, k.y += b + g + i
  9600. },
  9601. setType: function(a) {
  9602. return a === Phaser.Physics.Ninja.Tile.EMPTY ? this.clear() : (this.id = a, this.updateType()), this
  9603. },
  9604. clear: function() {
  9605. this.id = Phaser.Physics.Ninja.Tile.EMPTY, this.updateType()
  9606. },
  9607. destroy: function() {
  9608. this.body = null, this.system = null
  9609. },
  9610. updateType: function() {
  9611. if (0 === this.id) return this.type = Phaser.Physics.Ninja.Tile.TYPE_EMPTY, this.signx = 0, this.signy = 0, this.sx = 0, this.sy = 0, !0;
  9612. if (this.id < Phaser.Physics.Ninja.Tile.TYPE_45DEG) this.type = Phaser.Physics.Ninja.Tile.TYPE_FULL, this.signx = 0, this.signy = 0, this.sx = 0, this.sy = 0;
  9613. else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_CONCAVE)
  9614. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_45DEG, this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn) this.signx = 1, this.signy = -1, this.sx = this.signx / Math.SQRT2, this.sy = this.signy / Math.SQRT2;
  9615. else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGnn) this.signx = -1, this.signy = -1, this.sx = this.signx / Math.SQRT2, this.sy = this.signy / Math.SQRT2;
  9616. else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGnp) this.signx = -1, this.signy = 1, this.sx = this.signx / Math.SQRT2, this.sy = this.signy / Math.SQRT2;
  9617. else {
  9618. if (this.id != Phaser.Physics.Ninja.Tile.SLOPE_45DEGpp) return !1;
  9619. this.signx = 1, this.signy = 1, this.sx = this.signx / Math.SQRT2, this.sy = this.signy / Math.SQRT2
  9620. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_CONVEX)
  9621. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_CONCAVE, this.id == Phaser.Physics.Ninja.Tile.CONCAVEpn) this.signx = 1, this.signy = -1, this.sx = 0, this.sy = 0;
  9622. else if (this.id == Phaser.Physics.Ninja.Tile.CONCAVEnn) this.signx = -1, this.signy = -1, this.sx = 0, this.sy = 0;
  9623. else if (this.id == Phaser.Physics.Ninja.Tile.CONCAVEnp) this.signx = -1, this.signy = 1, this.sx = 0, this.sy = 0;
  9624. else {
  9625. if (this.id != Phaser.Physics.Ninja.Tile.CONCAVEpp) return !1;
  9626. this.signx = 1, this.signy = 1, this.sx = 0, this.sy = 0
  9627. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_22DEGs)
  9628. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_CONVEX, this.id == Phaser.Physics.Ninja.Tile.CONVEXpn) this.signx = 1, this.signy = -1, this.sx = 0, this.sy = 0;
  9629. else if (this.id == Phaser.Physics.Ninja.Tile.CONVEXnn) this.signx = -1, this.signy = -1, this.sx = 0, this.sy = 0;
  9630. else if (this.id == Phaser.Physics.Ninja.Tile.CONVEXnp) this.signx = -1, this.signy = 1, this.sx = 0, this.sy = 0;
  9631. else {
  9632. if (this.id != Phaser.Physics.Ninja.Tile.CONVEXpp) return !1;
  9633. this.signx = 1, this.signy = 1, this.sx = 0, this.sy = 0
  9634. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_22DEGb)
  9635. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_22DEGs, this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGpnS) {
  9636. this.signx = 1, this.signy = -1;
  9637. var a = Math.sqrt(5);
  9638. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9639. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGnnS) {
  9640. this.signx = -1, this.signy = -1;
  9641. var a = Math.sqrt(5);
  9642. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9643. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGnpS) {
  9644. this.signx = -1, this.signy = 1;
  9645. var a = Math.sqrt(5);
  9646. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9647. } else {
  9648. if (this.id != Phaser.Physics.Ninja.Tile.SLOPE_22DEGppS) return !1;
  9649. this.signx = 1, this.signy = 1;
  9650. var a = Math.sqrt(5);
  9651. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9652. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_67DEGs)
  9653. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_22DEGb, this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGpnB) {
  9654. this.signx = 1, this.signy = -1;
  9655. var a = Math.sqrt(5);
  9656. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9657. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGnnB) {
  9658. this.signx = -1, this.signy = -1;
  9659. var a = Math.sqrt(5);
  9660. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9661. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_22DEGnpB) {
  9662. this.signx = -1, this.signy = 1;
  9663. var a = Math.sqrt(5);
  9664. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9665. } else {
  9666. if (this.id != Phaser.Physics.Ninja.Tile.SLOPE_22DEGppB) return !1;
  9667. this.signx = 1, this.signy = 1;
  9668. var a = Math.sqrt(5);
  9669. this.sx = 1 * this.signx / a, this.sy = 2 * this.signy / a
  9670. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_67DEGb)
  9671. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_67DEGs, this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGpnS) {
  9672. this.signx = 1, this.signy = -1;
  9673. var a = Math.sqrt(5);
  9674. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9675. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGnnS) {
  9676. this.signx = -1, this.signy = -1;
  9677. var a = Math.sqrt(5);
  9678. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9679. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGnpS) {
  9680. this.signx = -1, this.signy = 1;
  9681. var a = Math.sqrt(5);
  9682. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9683. } else {
  9684. if (this.id != Phaser.Physics.Ninja.Tile.SLOPE_67DEGppS) return !1;
  9685. this.signx = 1, this.signy = 1;
  9686. var a = Math.sqrt(5);
  9687. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9688. } else if (this.id < Phaser.Physics.Ninja.Tile.TYPE_HALF)
  9689. if (this.type = Phaser.Physics.Ninja.Tile.TYPE_67DEGb, this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGpnB) {
  9690. this.signx = 1, this.signy = -1;
  9691. var a = Math.sqrt(5);
  9692. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9693. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGnnB) {
  9694. this.signx = -1, this.signy = -1;
  9695. var a = Math.sqrt(5);
  9696. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9697. } else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_67DEGnpB) {
  9698. this.signx = -1, this.signy = 1;
  9699. var a = Math.sqrt(5);
  9700. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9701. } else {
  9702. if (this.id != Phaser.Physics.Ninja.Tile.SLOPE_67DEGppB) return !1;
  9703. this.signx = 1, this.signy = 1;
  9704. var a = Math.sqrt(5);
  9705. this.sx = 2 * this.signx / a, this.sy = 1 * this.signy / a
  9706. } else if (this.type = Phaser.Physics.Ninja.Tile.TYPE_HALF, this.id == Phaser.Physics.Ninja.Tile.HALFd) this.signx = 0, this.signy = -1, this.sx = this.signx, this.sy = this.signy;
  9707. else if (this.id == Phaser.Physics.Ninja.Tile.HALFu) this.signx = 0, this.signy = 1, this.sx = this.signx, this.sy = this.signy;
  9708. else if (this.id == Phaser.Physics.Ninja.Tile.HALFl) this.signx = 1, this.signy = 0, this.sx = this.signx, this.sy = this.signy;
  9709. else {
  9710. if (this.id != Phaser.Physics.Ninja.Tile.HALFr) return !1;
  9711. this.signx = -1, this.signy = 0, this.sx = this.signx, this.sy = this.signy
  9712. }
  9713. }
  9714. }, Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "x", {
  9715. get: function() {
  9716. return this.pos.x - this.xw
  9717. },
  9718. set: function(a) {
  9719. this.pos.x = a
  9720. }
  9721. }), Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "y", {
  9722. get: function() {
  9723. return this.pos.y - this.yw
  9724. },
  9725. set: function(a) {
  9726. this.pos.y = a
  9727. }
  9728. }), Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "bottom", {
  9729. get: function() {
  9730. return this.pos.y + this.yw
  9731. }
  9732. }), Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "right", {
  9733. get: function() {
  9734. return this.pos.x + this.xw
  9735. }
  9736. }), Phaser.Physics.Ninja.Tile.EMPTY = 0, Phaser.Physics.Ninja.Tile.FULL = 1, Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn = 2, Phaser.Physics.Ninja.Tile.SLOPE_45DEGnn = 3, Phaser.Physics.Ninja.Tile.SLOPE_45DEGnp = 4, Phaser.Physics.Ninja.Tile.SLOPE_45DEGpp = 5, Phaser.Physics.Ninja.Tile.CONCAVEpn = 6, Phaser.Physics.Ninja.Tile.CONCAVEnn = 7, Phaser.Physics.Ninja.Tile.CONCAVEnp = 8, Phaser.Physics.Ninja.Tile.CONCAVEpp = 9, Phaser.Physics.Ninja.Tile.CONVEXpn = 10, Phaser.Physics.Ninja.Tile.CONVEXnn = 11, Phaser.Physics.Ninja.Tile.CONVEXnp = 12, Phaser.Physics.Ninja.Tile.CONVEXpp = 13, Phaser.Physics.Ninja.Tile.SLOPE_22DEGpnS = 14, Phaser.Physics.Ninja.Tile.SLOPE_22DEGnnS = 15, Phaser.Physics.Ninja.Tile.SLOPE_22DEGnpS = 16, Phaser.Physics.Ninja.Tile.SLOPE_22DEGppS = 17, Phaser.Physics.Ninja.Tile.SLOPE_22DEGpnB = 18, Phaser.Physics.Ninja.Tile.SLOPE_22DEGnnB = 19, Phaser.Physics.Ninja.Tile.SLOPE_22DEGnpB = 20, Phaser.Physics.Ninja.Tile.SLOPE_22DEGppB = 21, Phaser.Physics.Ninja.Tile.SLOPE_67DEGpnS = 22, Phaser.Physics.Ninja.Tile.SLOPE_67DEGnnS = 23, Phaser.Physics.Ninja.Tile.SLOPE_67DEGnpS = 24, Phaser.Physics.Ninja.Tile.SLOPE_67DEGppS = 25, Phaser.Physics.Ninja.Tile.SLOPE_67DEGpnB = 26, Phaser.Physics.Ninja.Tile.SLOPE_67DEGnnB = 27, Phaser.Physics.Ninja.Tile.SLOPE_67DEGnpB = 28, Phaser.Physics.Ninja.Tile.SLOPE_67DEGppB = 29, Phaser.Physics.Ninja.Tile.HALFd = 30, Phaser.Physics.Ninja.Tile.HALFr = 31, Phaser.Physics.Ninja.Tile.HALFu = 32, Phaser.Physics.Ninja.Tile.HALFl = 33, Phaser.Physics.Ninja.Tile.TYPE_EMPTY = 0, Phaser.Physics.Ninja.Tile.TYPE_FULL = 1, Phaser.Physics.Ninja.Tile.TYPE_45DEG = 2, Phaser.Physics.Ninja.Tile.TYPE_CONCAVE = 6, Phaser.Physics.Ninja.Tile.TYPE_CONVEX = 10, Phaser.Physics.Ninja.Tile.TYPE_22DEGs = 14, Phaser.Physics.Ninja.Tile.TYPE_22DEGb = 18, Phaser.Physics.Ninja.Tile.TYPE_67DEGs = 22, Phaser.Physics.Ninja.Tile.TYPE_67DEGb = 26, Phaser.Physics.Ninja.Tile.TYPE_HALF = 30, Phaser.Physics.Ninja.Circle = function(a, b, c, d) {
  9737. this.body = a, this.system = a.system, this.pos = new Phaser.Point(b, c), this.oldpos = new Phaser.Point(b, c), this.radius = d, this.xw = d, this.yw = d, this.width = 2 * d, this.height = 2 * d, this.oH = 0, this.oV = 0, this.velocity = new Phaser.Point, this.circleTileProjections = {}, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_FULL] = this.projCircle_Full, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_45DEG] = this.projCircle_45Deg, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONCAVE] = this.projCircle_Concave, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_CONVEX] = this.projCircle_Convex, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGs] = this.projCircle_22DegS, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_22DEGb] = this.projCircle_22DegB, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGs] = this.projCircle_67DegS, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGb] = this.projCircle_67DegB, this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_HALF] = this.projCircle_Half
  9738. }, Phaser.Physics.Ninja.Circle.prototype.constructor = Phaser.Physics.Ninja.Circle, Phaser.Physics.Ninja.Circle.COL_NONE = 0, Phaser.Physics.Ninja.Circle.COL_AXIS = 1, Phaser.Physics.Ninja.Circle.COL_OTHER = 2, Phaser.Physics.Ninja.Circle.prototype = {
  9739. integrate: function() {
  9740. var a = this.pos.x,
  9741. b = this.pos.y;
  9742. this.pos.x += this.body.drag * this.pos.x - this.body.drag * this.oldpos.x, this.pos.y += this.body.drag * this.pos.y - this.body.drag * this.oldpos.y + this.system.gravity * this.body.gravityScale, this.velocity.set(this.pos.x - a, this.pos.y - b), this.oldpos.set(a, b)
  9743. },
  9744. reportCollisionVsWorld: function(a, b, c, d) {
  9745. var e, f, g, h, i, j = this.pos,
  9746. k = this.oldpos,
  9747. l = j.x - k.x,
  9748. m = j.y - k.y,
  9749. n = l * c + m * d,
  9750. o = n * c,
  9751. p = n * d,
  9752. q = l - o,
  9753. r = m - p;
  9754. 0 > n ? (h = q * this.body.friction, i = r * this.body.friction, e = 1 + this.body.bounce, f = o * e, g = p * e, 1 === c ? this.body.touching.left = !0 : -1 === c && (this.body.touching.right = !0), 1 === d ? this.body.touching.up = !0 : -1 === d && (this.body.touching.down = !0)) : f = g = h = i = 0, j.x += a, j.y += b, k.x += a + f + h, k.y += b + g + i
  9755. },
  9756. collideWorldBounds: function() {
  9757. var a = this.system.bounds.x - (this.pos.x - this.radius);
  9758. a > 0 ? this.reportCollisionVsWorld(a, 0, 1, 0, null) : (a = this.pos.x + this.radius - this.system.bounds.right, a > 0 && this.reportCollisionVsWorld(-a, 0, -1, 0, null));
  9759. var b = this.system.bounds.y - (this.pos.y - this.radius);
  9760. b > 0 ? this.reportCollisionVsWorld(0, b, 0, 1, null) : (b = this.pos.y + this.radius - this.system.bounds.bottom, b > 0 && this.reportCollisionVsWorld(0, -b, 0, -1, null))
  9761. },
  9762. collideCircleVsTile: function(a) {
  9763. var b = this.pos,
  9764. c = this.radius,
  9765. d = a,
  9766. e = d.pos.x,
  9767. f = d.pos.y,
  9768. g = d.xw,
  9769. h = d.yw,
  9770. i = b.x - e,
  9771. j = g + c - Math.abs(i);
  9772. if (j > 0) {
  9773. var k = b.y - f,
  9774. l = h + c - Math.abs(k);
  9775. if (l > 0) return this.oH = 0, this.oV = 0, -g > i ? this.oH = -1 : i > g && (this.oH = 1), -h > k ? this.oV = -1 : k > h && (this.oV = 1), this.resolveCircleTile(j, l, this.oH, this.oV, this, d)
  9776. }
  9777. },
  9778. resolveCircleTile: function(a, b, c, d, e, f) {
  9779. return 0 < f.id ? this.circleTileProjections[f.type](a, b, c, d, e, f) : !1
  9780. },
  9781. projCircle_Full: function(a, b, c, d, e, f) {
  9782. if (0 === c) {
  9783. if (0 === d) {
  9784. if (b > a) {
  9785. var g = e.pos.x - f.pos.x;
  9786. return 0 > g ? (e.reportCollisionVsWorld(-a, 0, -1, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(a, 0, 1, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS)
  9787. }
  9788. var h = e.pos.y - f.pos.y;
  9789. return 0 > h ? (e.reportCollisionVsWorld(0, -b, 0, -1, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(0, b, 0, 1, f), Phaser.Physics.Ninja.Circle.COL_AXIS)
  9790. }
  9791. return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS
  9792. }
  9793. if (0 === d) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9794. var i = f.pos.x + c * f.xw,
  9795. j = f.pos.y + d * f.yw,
  9796. g = e.pos.x - i,
  9797. h = e.pos.y - j,
  9798. k = Math.sqrt(g * g + h * h),
  9799. l = e.radius - k;
  9800. return l > 0 ? (0 === k ? (g = c / Math.SQRT2, h = d / Math.SQRT2) : (g /= k, h /= k), e.reportCollisionVsWorld(g * l, h * l, g, h, f), Phaser.Physics.Ninja.Circle.COL_OTHER) : Phaser.Physics.Ninja.Circle.COL_NONE
  9801. },
  9802. projCircle_45Deg: function(a, b, c, d, e, f) {
  9803. var g, h = f.signx,
  9804. i = f.signy;
  9805. if (0 === c)
  9806. if (0 === d) {
  9807. var j = f.sx,
  9808. k = f.sy,
  9809. l = e.pos.x - j * e.radius - f.pos.x,
  9810. m = e.pos.y - k * e.radius - f.pos.y,
  9811. n = l * j + m * k;
  9812. if (0 > n) {
  9813. j *= -n, k *= -n, b > a ? (g = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (g = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1));
  9814. var o = Math.sqrt(j * j + k * k);
  9815. return o > g ? (e.reportCollisionVsWorld(a, b, a / g, b / g, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(j, k, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  9816. }
  9817. } else {
  9818. if (0 > i * d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9819. var j = f.sx,
  9820. k = f.sy,
  9821. l = e.pos.x - (f.pos.x - h * f.xw),
  9822. m = e.pos.y - (f.pos.y + d * f.yw),
  9823. p = l * -k + m * j;
  9824. if (p * h * i > 0) {
  9825. var q = Math.sqrt(l * l + m * m),
  9826. r = e.radius - q;
  9827. if (r > 0) return l /= q, m /= q, e.reportCollisionVsWorld(l * r, m * r, l, m, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9828. } else {
  9829. var n = l * j + m * k,
  9830. r = e.radius - Math.abs(n);
  9831. if (r > 0) return e.reportCollisionVsWorld(j * r, k * r, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9832. }
  9833. } else if (0 === d) {
  9834. if (0 > h * c) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9835. var j = f.sx,
  9836. k = f.sy,
  9837. l = e.pos.x - (f.pos.x + c * f.xw),
  9838. m = e.pos.y - (f.pos.y - i * f.yw),
  9839. p = l * -k + m * j;
  9840. if (0 > p * h * i) {
  9841. var q = Math.sqrt(l * l + m * m),
  9842. r = e.radius - q;
  9843. if (r > 0) return l /= q, m /= q, e.reportCollisionVsWorld(l * r, m * r, l, m, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9844. } else {
  9845. var n = l * j + m * k,
  9846. r = e.radius - Math.abs(n);
  9847. if (r > 0) return e.reportCollisionVsWorld(j * r, k * r, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9848. }
  9849. } else {
  9850. if (h * c + i * d > 0) return Phaser.Physics.Ninja.Circle.COL_NONE;
  9851. var s = f.pos.x + c * f.xw,
  9852. t = f.pos.y + d * f.yw,
  9853. u = e.pos.x - s,
  9854. v = e.pos.y - t,
  9855. q = Math.sqrt(u * u + v * v),
  9856. r = e.radius - q;
  9857. if (r > 0) return 0 === q ? (u = c / Math.SQRT2, v = d / Math.SQRT2) : (u /= q, v /= q), e.reportCollisionVsWorld(u * r, v * r, u, v, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9858. }
  9859. return Phaser.Physics.Ninja.Circle.COL_NONE
  9860. },
  9861. projCircle_Concave: function(a, b, c, d, e, f) {
  9862. var g, h = f.signx,
  9863. i = f.signy;
  9864. if (0 === c) {
  9865. if (0 === d) {
  9866. var j = f.pos.x + h * f.xw - e.pos.x,
  9867. k = f.pos.y + i * f.yw - e.pos.y,
  9868. l = 2 * f.xw,
  9869. m = Math.sqrt(l * l + 0),
  9870. n = Math.sqrt(j * j + k * k),
  9871. o = n + e.radius - m;
  9872. return o > 0 ? (b > a ? (g = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (g = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), o > g ? (e.reportCollisionVsWorld(a, b, a / g, b / g, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (j /= n, k /= n, e.reportCollisionVsWorld(j * o, k * o, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER)) : Phaser.Physics.Ninja.Circle.COL_NONE
  9873. }
  9874. if (0 > i * d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9875. var p = f.pos.x - h * f.xw,
  9876. q = f.pos.y + d * f.yw,
  9877. r = e.pos.x - p,
  9878. s = e.pos.y - q,
  9879. n = Math.sqrt(r * r + s * s),
  9880. o = e.radius - n;
  9881. if (o > 0) return 0 === n ? (r = 0, s = d) : (r /= n, s /= n), e.reportCollisionVsWorld(r * o, s * o, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9882. } else if (0 === d) {
  9883. if (0 > h * c) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9884. var p = f.pos.x + c * f.xw,
  9885. q = f.pos.y - i * f.yw,
  9886. r = e.pos.x - p,
  9887. s = e.pos.y - q,
  9888. n = Math.sqrt(r * r + s * s),
  9889. o = e.radius - n;
  9890. if (o > 0) return 0 === n ? (r = c, s = 0) : (r /= n, s /= n), e.reportCollisionVsWorld(r * o, s * o, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9891. } else {
  9892. if (h * c + i * d > 0) return Phaser.Physics.Ninja.Circle.COL_NONE;
  9893. var p = f.pos.x + c * f.xw,
  9894. q = f.pos.y + d * f.yw,
  9895. r = e.pos.x - p,
  9896. s = e.pos.y - q,
  9897. n = Math.sqrt(r * r + s * s),
  9898. o = e.radius - n;
  9899. if (o > 0) return 0 === n ? (r = c / Math.SQRT2, s = d / Math.SQRT2) : (r /= n, s /= n), e.reportCollisionVsWorld(r * o, s * o, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9900. }
  9901. return Phaser.Physics.Ninja.Circle.COL_NONE
  9902. },
  9903. projCircle_Convex: function(a, b, c, d, e, f) {
  9904. var g, h = f.signx,
  9905. i = f.signy;
  9906. if (0 === c)
  9907. if (0 === d) {
  9908. var j = e.pos.x - (f.pos.x - h * f.xw),
  9909. k = e.pos.y - (f.pos.y - i * f.yw),
  9910. l = 2 * f.xw,
  9911. m = Math.sqrt(l * l + 0),
  9912. n = Math.sqrt(j * j + k * k),
  9913. o = m + e.radius - n;
  9914. if (o > 0) return b > a ? (g = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (g = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), o > g ? (e.reportCollisionVsWorld(a, b, a / g, b / g, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (j /= n, k /= n, e.reportCollisionVsWorld(j * o, k * o, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  9915. } else {
  9916. if (0 > i * d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9917. var j = e.pos.x - (f.pos.x - h * f.xw),
  9918. k = e.pos.y - (f.pos.y - i * f.yw),
  9919. l = 2 * f.xw,
  9920. m = Math.sqrt(l * l + 0),
  9921. n = Math.sqrt(j * j + k * k),
  9922. o = m + e.radius - n;
  9923. if (o > 0) return j /= n, k /= n, e.reportCollisionVsWorld(j * o, k * o, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9924. } else if (0 === d) {
  9925. if (0 > h * c) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9926. var j = e.pos.x - (f.pos.x - h * f.xw),
  9927. k = e.pos.y - (f.pos.y - i * f.yw),
  9928. l = 2 * f.xw,
  9929. m = Math.sqrt(l * l + 0),
  9930. n = Math.sqrt(j * j + k * k),
  9931. o = m + e.radius - n;
  9932. if (o > 0) return j /= n, k /= n, e.reportCollisionVsWorld(j * o, k * o, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9933. } else if (h * c + i * d > 0) {
  9934. var j = e.pos.x - (f.pos.x - h * f.xw),
  9935. k = e.pos.y - (f.pos.y - i * f.yw),
  9936. l = 2 * f.xw,
  9937. m = Math.sqrt(l * l + 0),
  9938. n = Math.sqrt(j * j + k * k),
  9939. o = m + e.radius - n;
  9940. if (o > 0) return j /= n, k /= n, e.reportCollisionVsWorld(j * o, k * o, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9941. } else {
  9942. var p = f.pos.x + c * f.xw,
  9943. q = f.pos.y + d * f.yw,
  9944. r = e.pos.x - p,
  9945. s = e.pos.y - q,
  9946. n = Math.sqrt(r * r + s * s),
  9947. o = e.radius - n;
  9948. if (o > 0) return 0 === n ? (r = c / Math.SQRT2, s = d / Math.SQRT2) : (r /= n, s /= n), e.reportCollisionVsWorld(r * o, s * o, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9949. }
  9950. return Phaser.Physics.Ninja.Circle.COL_NONE
  9951. },
  9952. projCircle_Half: function(a, b, c, d, e, f) {
  9953. var g = f.signx,
  9954. h = f.signy,
  9955. i = c * g + d * h;
  9956. if (i > 0) return Phaser.Physics.Ninja.Circle.COL_NONE;
  9957. if (0 === c)
  9958. if (0 === d) {
  9959. var j = e.radius,
  9960. k = e.pos.x - g * j - f.pos.x,
  9961. l = e.pos.y - h * j - f.pos.y,
  9962. m = g,
  9963. n = h,
  9964. o = k * m + l * n;
  9965. if (0 > o) {
  9966. m *= -o, n *= -o;
  9967. var p = Math.sqrt(m * m + n * n),
  9968. q = Math.sqrt(a * a + b * b);
  9969. return p > q ? (e.reportCollisionVsWorld(a, b, a / q, b / q, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(m, n, f.signx, f.signy), Phaser.Physics.Ninja.Circle.COL_OTHER)
  9970. }
  9971. } else {
  9972. if (0 !== i) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9973. var r = e.pos.x - f.pos.x;
  9974. if (0 > r * g) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9975. var s = e.pos.y - (f.pos.y + d * f.yw),
  9976. t = Math.sqrt(r * r + s * s),
  9977. u = e.radius - t;
  9978. if (u > 0) return 0 === t ? (r = g / Math.SQRT2, s = d / Math.SQRT2) : (r /= t, s /= t), e.reportCollisionVsWorld(r * u, s * u, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9979. } else if (0 === d) {
  9980. if (0 !== i) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9981. var s = e.pos.y - f.pos.y;
  9982. if (0 > s * h) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  9983. var r = e.pos.x - (f.pos.x + c * f.xw),
  9984. t = Math.sqrt(r * r + s * s),
  9985. u = e.radius - t;
  9986. if (u > 0) return 0 === t ? (r = g / Math.SQRT2, s = d / Math.SQRT2) : (r /= t, s /= t), e.reportCollisionVsWorld(r * u, s * u, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9987. } else {
  9988. var v = f.pos.x + c * f.xw,
  9989. w = f.pos.y + d * f.yw,
  9990. r = e.pos.x - v,
  9991. s = e.pos.y - w,
  9992. t = Math.sqrt(r * r + s * s),
  9993. u = e.radius - t;
  9994. if (u > 0) return 0 === t ? (r = c / Math.SQRT2, s = d / Math.SQRT2) : (r /= t, s /= t), e.reportCollisionVsWorld(r * u, s * u, r, s, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  9995. }
  9996. return Phaser.Physics.Ninja.Circle.COL_NONE
  9997. },
  9998. projCircle_22DegS: function(a, b, c, d, e, f) {
  9999. var g, h = f.signx,
  10000. i = f.signy;
  10001. if (i * d > 0) return Phaser.Physics.Ninja.Circle.COL_NONE;
  10002. if (0 === c) {
  10003. if (0 !== d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10004. var j = f.sx,
  10005. k = f.sy,
  10006. l = e.radius,
  10007. m = e.pos.x - (f.pos.x - h * f.xw),
  10008. n = e.pos.y - f.pos.y,
  10009. o = m * -k + n * j;
  10010. if (o * h * i > 0) {
  10011. var p = Math.sqrt(m * m + n * n),
  10012. q = l - p;
  10013. if (q > 0) return m /= p, n /= p, e.reportCollisionVsWorld(m * q, n * q, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10014. } else {
  10015. m -= l * j, n -= l * k;
  10016. var r = m * j + n * k;
  10017. if (0 > r) {
  10018. j *= -r, k *= -r;
  10019. var s = Math.sqrt(j * j + k * k);
  10020. return b > a ? (g = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (g = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), s > g ? (e.reportCollisionVsWorld(a, b, a / g, b / g, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(j, k, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  10021. }
  10022. }
  10023. } else if (0 === d)
  10024. if (0 > h * c) {
  10025. var t = f.pos.x - h * f.xw,
  10026. u = f.pos.y,
  10027. v = e.pos.x - t,
  10028. w = e.pos.y - u;
  10029. if (0 > w * i) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10030. var p = Math.sqrt(v * v + w * w),
  10031. q = e.radius - p;
  10032. if (q > 0) return 0 === p ? (v = c / Math.SQRT2, w = d / Math.SQRT2) : (v /= p, w /= p), e.reportCollisionVsWorld(v * q, w * q, v, w, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10033. } else {
  10034. var j = f.sx,
  10035. k = f.sy,
  10036. m = e.pos.x - (f.pos.x + c * f.xw),
  10037. n = e.pos.y - (f.pos.y - i * f.yw),
  10038. o = m * -k + n * j;
  10039. if (0 > o * h * i) {
  10040. var p = Math.sqrt(m * m + n * n),
  10041. q = e.radius - p;
  10042. if (q > 0) return m /= p, n /= p, e.reportCollisionVsWorld(m * q, n * q, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10043. } else {
  10044. var r = m * j + n * k,
  10045. q = e.radius - Math.abs(r);
  10046. if (q > 0) return e.reportCollisionVsWorld(j * q, k * q, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10047. }
  10048. } else {
  10049. var t = f.pos.x + c * f.xw,
  10050. u = f.pos.y + d * f.yw,
  10051. v = e.pos.x - t,
  10052. w = e.pos.y - u,
  10053. p = Math.sqrt(v * v + w * w),
  10054. q = e.radius - p;
  10055. if (q > 0) return 0 === p ? (v = c / Math.SQRT2, w = d / Math.SQRT2) : (v /= p, w /= p), e.reportCollisionVsWorld(v * q, w * q, v, w, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10056. }
  10057. return Phaser.Physics.Ninja.Circle.COL_NONE
  10058. },
  10059. projCircle_22DegB: function(a, b, c, d, e, f) {
  10060. var g, h = f.signx,
  10061. i = f.signy;
  10062. if (0 === c)
  10063. if (0 === d) {
  10064. var j = f.sx,
  10065. k = f.sy,
  10066. l = e.radius,
  10067. m = e.pos.x - j * l - (f.pos.x - h * f.xw),
  10068. n = e.pos.y - k * l - (f.pos.y + i * f.yw),
  10069. o = m * j + n * k;
  10070. if (0 > o) {
  10071. j *= -o, k *= -o;
  10072. var p = Math.sqrt(j * j + k * k);
  10073. return b > a ? (g = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (g = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), p > g ? (e.reportCollisionVsWorld(a, b, a / g, b / g, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(j, k, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  10074. }
  10075. } else {
  10076. if (0 > i * d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10077. var j = f.sx,
  10078. k = f.sy,
  10079. m = e.pos.x - (f.pos.x - h * f.xw),
  10080. n = e.pos.y - (f.pos.y + i * f.yw),
  10081. q = m * -k + n * j;
  10082. if (q * h * i > 0) {
  10083. var r = Math.sqrt(m * m + n * n),
  10084. s = e.radius - r;
  10085. if (s > 0) return m /= r, n /= r, e.reportCollisionVsWorld(m * s, n * s, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10086. } else {
  10087. var o = m * j + n * k,
  10088. s = e.radius - Math.abs(o);
  10089. if (s > 0) return e.reportCollisionVsWorld(j * s, k * s, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10090. }
  10091. } else if (0 === d) {
  10092. if (0 > h * c) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10093. var m = e.pos.x - (f.pos.x + h * f.xw),
  10094. n = e.pos.y - f.pos.y;
  10095. if (0 > n * i) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10096. var j = f.sx,
  10097. k = f.sy,
  10098. q = m * -k + n * j;
  10099. if (0 > q * h * i) {
  10100. var r = Math.sqrt(m * m + n * n),
  10101. s = e.radius - r;
  10102. if (s > 0) return m /= r, n /= r, e.reportCollisionVsWorld(m * s, n * s, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10103. } else {
  10104. var o = m * j + n * k,
  10105. s = e.radius - Math.abs(o);
  10106. if (s > 0) return e.reportCollisionVsWorld(j * s, k * s, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10107. }
  10108. } else {
  10109. if (h * c + i * d > 0) {
  10110. var t = Math.sqrt(5),
  10111. j = 1 * h / t,
  10112. k = 2 * i / t,
  10113. l = e.radius,
  10114. m = e.pos.x - j * l - (f.pos.x - h * f.xw),
  10115. n = e.pos.y - k * l - (f.pos.y + i * f.yw),
  10116. o = m * j + n * k;
  10117. return 0 > o ? (e.reportCollisionVsWorld(-j * o, -k * o, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER) : Phaser.Physics.Ninja.Circle.COL_NONE
  10118. }
  10119. var u = f.pos.x + c * f.xw,
  10120. v = f.pos.y + d * f.yw,
  10121. w = e.pos.x - u,
  10122. x = e.pos.y - v,
  10123. r = Math.sqrt(w * w + x * x),
  10124. s = e.radius - r;
  10125. if (s > 0) return 0 === r ? (w = c / Math.SQRT2, x = d / Math.SQRT2) : (w /= r, x /= r), e.reportCollisionVsWorld(w * s, x * s, w, x, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10126. }
  10127. return Phaser.Physics.Ninja.Circle.COL_NONE
  10128. },
  10129. projCircle_67DegS: function(a, b, c, d, e, f) {
  10130. var g = f.signx,
  10131. h = f.signy;
  10132. if (g * c > 0) return Phaser.Physics.Ninja.Circle.COL_NONE;
  10133. if (0 === c)
  10134. if (0 === d) {
  10135. var i, j = f.sx,
  10136. k = f.sy,
  10137. l = e.radius,
  10138. m = e.pos.x - f.pos.x,
  10139. n = e.pos.y - (f.pos.y - h * f.yw),
  10140. o = m * -k + n * j;
  10141. if (0 > o * g * h) {
  10142. var p = Math.sqrt(m * m + n * n),
  10143. q = l - p;
  10144. if (q > 0) return m /= p, n /= p, e.reportCollisionVsWorld(m * q, n * q, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10145. } else {
  10146. m -= l * j, n -= l * k;
  10147. var r = m * j + n * k;
  10148. if (0 > r) {
  10149. j *= -r, k *= -r;
  10150. var s = Math.sqrt(j * j + k * k);
  10151. return b > a ? (i = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (i = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), s > i ? (e.reportCollisionVsWorld(a, b, a / i, b / i, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(j, k, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  10152. }
  10153. }
  10154. } else if (0 > h * d) {
  10155. var t = f.pos.x,
  10156. u = f.pos.y - h * f.yw,
  10157. v = e.pos.x - t,
  10158. w = e.pos.y - u;
  10159. if (0 > v * g) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10160. var p = Math.sqrt(v * v + w * w),
  10161. q = e.radius - p;
  10162. if (q > 0) return 0 === p ? (v = c / Math.SQRT2, w = d / Math.SQRT2) : (v /= p, w /= p), e.reportCollisionVsWorld(v * q, w * q, v, w, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10163. } else {
  10164. var j = f.sx,
  10165. k = f.sy,
  10166. m = e.pos.x - (f.pos.x - g * f.xw),
  10167. n = e.pos.y - (f.pos.y + d * f.yw),
  10168. o = m * -k + n * j;
  10169. if (o * g * h > 0) {
  10170. var p = Math.sqrt(m * m + n * n),
  10171. q = e.radius - p;
  10172. if (q > 0) return m /= p, n /= p, e.reportCollisionVsWorld(m * q, n * q, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10173. } else {
  10174. var r = m * j + n * k,
  10175. q = e.radius - Math.abs(r);
  10176. if (q > 0) return e.reportCollisionVsWorld(j * q, k * q, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10177. }
  10178. } else {
  10179. if (0 === d) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10180. var t = f.pos.x + c * f.xw,
  10181. u = f.pos.y + d * f.yw,
  10182. v = e.pos.x - t,
  10183. w = e.pos.y - u,
  10184. p = Math.sqrt(v * v + w * w),
  10185. q = e.radius - p;
  10186. if (q > 0) return 0 === p ? (v = c / Math.SQRT2, w = d / Math.SQRT2) : (v /= p, w /= p), e.reportCollisionVsWorld(v * q, w * q, v, w, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10187. }
  10188. return Phaser.Physics.Ninja.Circle.COL_NONE
  10189. },
  10190. projCircle_67DegB: function(a, b, c, d, e, f) {
  10191. var g = f.signx,
  10192. h = f.signy;
  10193. if (0 === c)
  10194. if (0 === d) {
  10195. var i, j = f.sx,
  10196. k = f.sy,
  10197. l = e.radius,
  10198. m = e.pos.x - j * l - (f.pos.x + g * f.xw),
  10199. n = e.pos.y - k * l - (f.pos.y - h * f.yw),
  10200. o = m * j + n * k;
  10201. if (0 > o) {
  10202. j *= -o, k *= -o;
  10203. var p = Math.sqrt(j * j + k * k);
  10204. return b > a ? (i = a, b = 0, e.pos.x - f.pos.x < 0 && (a *= -1)) : (i = b, a = 0, e.pos.y - f.pos.y < 0 && (b *= -1)), p > i ? (e.reportCollisionVsWorld(a, b, a / i, b / i, f), Phaser.Physics.Ninja.Circle.COL_AXIS) : (e.reportCollisionVsWorld(j, k, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER)
  10205. }
  10206. } else {
  10207. if (0 > h * d) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10208. var m = e.pos.x - f.pos.x,
  10209. n = e.pos.y - (f.pos.y + h * f.yw);
  10210. if (0 > m * g) return e.reportCollisionVsWorld(0, b * d, 0, d, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10211. var j = f.sx,
  10212. k = f.sy,
  10213. q = m * -k + n * j;
  10214. if (q * g * h > 0) {
  10215. var r = Math.sqrt(m * m + n * n),
  10216. s = e.radius - r;
  10217. if (s > 0) return m /= r, n /= r, e.reportCollisionVsWorld(m * s, n * s, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10218. } else {
  10219. var o = m * j + n * k,
  10220. s = e.radius - Math.abs(o);
  10221. if (s > 0) return e.reportCollisionVsWorld(j * s, k * s, j, k, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10222. }
  10223. } else if (0 === d) {
  10224. if (0 > g * c) return e.reportCollisionVsWorld(a * c, 0, c, 0, f), Phaser.Physics.Ninja.Circle.COL_AXIS;
  10225. var t = Math.sqrt(5),
  10226. j = 2 * g / t,
  10227. k = 1 * h / t,
  10228. m = e.pos.x - (f.pos.x + g * f.xw),
  10229. n = e.pos.y - (f.pos.y - h * f.yw),
  10230. q = m * -k + n * j;
  10231. if (0 > q * g * h) {
  10232. var r = Math.sqrt(m * m + n * n),
  10233. s = e.radius - r;
  10234. if (s > 0) return m /= r, n /= r, e.reportCollisionVsWorld(m * s, n * s, m, n, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10235. } else {
  10236. var o = m * j + n * k,
  10237. s = e.radius - Math.abs(o);
  10238. if (s > 0) return e.reportCollisionVsWorld(j * s, k * s, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10239. }
  10240. } else {
  10241. if (g * c + h * d > 0) {
  10242. var j = f.sx,
  10243. k = f.sy,
  10244. l = e.radius,
  10245. m = e.pos.x - j * l - (f.pos.x + g * f.xw),
  10246. n = e.pos.y - k * l - (f.pos.y - h * f.yw),
  10247. o = m * j + n * k;
  10248. return 0 > o ? (e.reportCollisionVsWorld(-j * o, -k * o, f.sx, f.sy, f), Phaser.Physics.Ninja.Circle.COL_OTHER) : Phaser.Physics.Ninja.Circle.COL_NONE
  10249. }
  10250. var u = f.pos.x + c * f.xw,
  10251. v = f.pos.y + d * f.yw,
  10252. w = e.pos.x - u,
  10253. x = e.pos.y - v,
  10254. r = Math.sqrt(w * w + x * x),
  10255. s = e.radius - r;
  10256. if (s > 0) return 0 === r ? (w = c / Math.SQRT2, x = d / Math.SQRT2) : (w /= r, x /= r), e.reportCollisionVsWorld(w * s, x * s, w, x, f), Phaser.Physics.Ninja.Circle.COL_OTHER
  10257. }
  10258. return Phaser.Physics.Ninja.Circle.COL_NONE
  10259. },
  10260. destroy: function() {
  10261. this.body = null, this.system = null
  10262. },
  10263. render: function(a, b, c, d, e) {
  10264. var f = this.pos.x - b,
  10265. g = this.pos.y - c;
  10266. a.beginPath(), a.arc(f, g, this.radius, 0, 2 * Math.PI, !1), e ? (a.fillStyle = d, a.fill()) : (a.strokeStyle = d, a.stroke())
  10267. }
  10268. }, ! function(a) {
  10269. "object" == typeof exports ? module.exports = a() : "function" == typeof define && define.amd ? define("p2", function() {
  10270. return this.p2 = a()
  10271. }()) : "undefined" != typeof window ? window.p2 = a() : "undefined" != typeof global ? self.p2 = a() : "undefined" != typeof self && (self.p2 = a())
  10272. }(function() {
  10273. return function a(b, c, d) {
  10274. function e(g, h) {
  10275. if (!c[g]) {
  10276. if (!b[g]) {
  10277. var i = "function" == typeof require && require;
  10278. if (!h && i) return i(g, !0);
  10279. if (f) return f(g, !0);
  10280. throw new Error("Cannot find module '" + g + "'")
  10281. }
  10282. var j = c[g] = {
  10283. exports: {}
  10284. };
  10285. b[g][0].call(j.exports, function(a) {
  10286. var c = b[g][1][a];
  10287. return e(c ? c : a)
  10288. }, j, j.exports, a, b, c, d)
  10289. }
  10290. return c[g].exports
  10291. }
  10292. for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
  10293. return e
  10294. }({
  10295. 1: [
  10296. function(a, b, c) {
  10297. if (!d) var d = 1e-6;
  10298. if (!e) var e = "undefined" != typeof Float32Array ? Float32Array : Array;
  10299. var f = {};
  10300. f.setMatrixArrayType = function(a) {
  10301. e = a
  10302. }, "undefined" != typeof c && (c.glMatrix = f);
  10303. var g = {};
  10304. g.create = function() {
  10305. var a = new e(2);
  10306. return a[0] = 0, a[1] = 0, a
  10307. }, g.clone = function(a) {
  10308. var b = new e(2);
  10309. return b[0] = a[0], b[1] = a[1], b
  10310. }, g.fromValues = function(a, b) {
  10311. var c = new e(2);
  10312. return c[0] = a, c[1] = b, c
  10313. }, g.copy = function(a, b) {
  10314. return a[0] = b[0], a[1] = b[1], a
  10315. }, g.set = function(a, b, c) {
  10316. return a[0] = b, a[1] = c, a
  10317. }, g.add = function(a, b, c) {
  10318. return a[0] = b[0] + c[0], a[1] = b[1] + c[1], a
  10319. }, g.subtract = function(a, b, c) {
  10320. return a[0] = b[0] - c[0], a[1] = b[1] - c[1], a
  10321. }, g.sub = g.subtract, g.multiply = function(a, b, c) {
  10322. return a[0] = b[0] * c[0], a[1] = b[1] * c[1], a
  10323. }, g.mul = g.multiply, g.divide = function(a, b, c) {
  10324. return a[0] = b[0] / c[0], a[1] = b[1] / c[1], a
  10325. }, g.div = g.divide, g.min = function(a, b, c) {
  10326. return a[0] = Math.min(b[0], c[0]), a[1] = Math.min(b[1], c[1]), a
  10327. }, g.max = function(a, b, c) {
  10328. return a[0] = Math.max(b[0], c[0]), a[1] = Math.max(b[1], c[1]), a
  10329. }, g.scale = function(a, b, c) {
  10330. return a[0] = b[0] * c, a[1] = b[1] * c, a
  10331. }, g.distance = function(a, b) {
  10332. var c = b[0] - a[0],
  10333. d = b[1] - a[1];
  10334. return Math.sqrt(c * c + d * d)
  10335. }, g.dist = g.distance, g.squaredDistance = function(a, b) {
  10336. var c = b[0] - a[0],
  10337. d = b[1] - a[1];
  10338. return c * c + d * d
  10339. }, g.sqrDist = g.squaredDistance, g.length = function(a) {
  10340. var b = a[0],
  10341. c = a[1];
  10342. return Math.sqrt(b * b + c * c)
  10343. }, g.len = g.length, g.squaredLength = function(a) {
  10344. var b = a[0],
  10345. c = a[1];
  10346. return b * b + c * c
  10347. }, g.sqrLen = g.squaredLength, g.negate = function(a, b) {
  10348. return a[0] = -b[0], a[1] = -b[1], a
  10349. }, g.normalize = function(a, b) {
  10350. var c = b[0],
  10351. d = b[1],
  10352. e = c * c + d * d;
  10353. return e > 0 && (e = 1 / Math.sqrt(e), a[0] = b[0] * e, a[1] = b[1] * e), a
  10354. }, g.dot = function(a, b) {
  10355. return a[0] * b[0] + a[1] * b[1]
  10356. }, g.cross = function(a, b, c) {
  10357. var d = b[0] * c[1] - b[1] * c[0];
  10358. return a[0] = a[1] = 0, a[2] = d, a
  10359. }, g.lerp = function(a, b, c, d) {
  10360. var e = b[0],
  10361. f = b[1];
  10362. return a[0] = e + d * (c[0] - e), a[1] = f + d * (c[1] - f), a
  10363. }, g.transformMat2 = function(a, b, c) {
  10364. var d = b[0],
  10365. e = b[1];
  10366. return a[0] = c[0] * d + c[2] * e, a[1] = c[1] * d + c[3] * e, a
  10367. }, g.transformMat2d = function(a, b, c) {
  10368. var d = b[0],
  10369. e = b[1];
  10370. return a[0] = c[0] * d + c[2] * e + c[4], a[1] = c[1] * d + c[3] * e + c[5], a
  10371. }, g.transformMat3 = function(a, b, c) {
  10372. var d = b[0],
  10373. e = b[1];
  10374. return a[0] = c[0] * d + c[3] * e + c[6], a[1] = c[1] * d + c[4] * e + c[7], a
  10375. }, g.transformMat4 = function(a, b, c) {
  10376. var d = b[0],
  10377. e = b[1];
  10378. return a[0] = c[0] * d + c[4] * e + c[12], a[1] = c[1] * d + c[5] * e + c[13], a
  10379. }, g.forEach = function() {
  10380. var a = g.create();
  10381. return function(b, c, d, e, f, g) {
  10382. var h, i;
  10383. for (c || (c = 2), d || (d = 0), i = e ? Math.min(e * c + d, b.length) : b.length, h = d; i > h; h += c) a[0] = b[h], a[1] = b[h + 1], f(a, a, g), b[h] = a[0], b[h + 1] = a[1];
  10384. return b
  10385. }
  10386. }(), g.str = function(a) {
  10387. return "vec2(" + a[0] + ", " + a[1] + ")"
  10388. }, "undefined" != typeof c && (c.vec2 = g)
  10389. }, {}
  10390. ],
  10391. 2: [
  10392. function(a, b) {
  10393. function c() {}
  10394. var d = a("./Scalar");
  10395. b.exports = c, c.lineInt = function(a, b, c) {
  10396. c = c || 0;
  10397. var e, f, g, h, i, j, k, l = [0, 0];
  10398. return e = a[1][1] - a[0][1], f = a[0][0] - a[1][0], g = e * a[0][0] + f * a[0][1], h = b[1][1] - b[0][1], i = b[0][0] - b[1][0], j = h * b[0][0] + i * b[0][1], k = e * i - h * f, d.eq(k, 0, c) || (l[0] = (i * g - f * j) / k, l[1] = (e * j - h * g) / k), l
  10399. }, c.segmentsIntersect = function(a, b, c, d) {
  10400. var e = b[0] - a[0],
  10401. f = b[1] - a[1],
  10402. g = d[0] - c[0],
  10403. h = d[1] - c[1];
  10404. if (g * f - h * e == 0) return !1;
  10405. var i = (e * (c[1] - a[1]) + f * (a[0] - c[0])) / (g * f - h * e),
  10406. j = (g * (a[1] - c[1]) + h * (c[0] - a[0])) / (h * e - g * f);
  10407. return i >= 0 && 1 >= i && j >= 0 && 1 >= j
  10408. }
  10409. }, {
  10410. "./Scalar": 5
  10411. }
  10412. ],
  10413. 3: [
  10414. function(a, b) {
  10415. function c() {}
  10416. b.exports = c, c.area = function(a, b, c) {
  10417. return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])
  10418. }, c.left = function(a, b, d) {
  10419. return c.area(a, b, d) > 0
  10420. }, c.leftOn = function(a, b, d) {
  10421. return c.area(a, b, d) >= 0
  10422. }, c.right = function(a, b, d) {
  10423. return c.area(a, b, d) < 0
  10424. }, c.rightOn = function(a, b, d) {
  10425. return c.area(a, b, d) <= 0
  10426. };
  10427. var d = [],
  10428. e = [];
  10429. c.collinear = function(a, b, f, g) {
  10430. if (g) {
  10431. var h = d,
  10432. i = e;
  10433. h[0] = b[0] - a[0], h[1] = b[1] - a[1], i[0] = f[0] - b[0], i[1] = f[1] - b[1];
  10434. var j = h[0] * i[0] + h[1] * i[1],
  10435. k = Math.sqrt(h[0] * h[0] + h[1] * h[1]),
  10436. l = Math.sqrt(i[0] * i[0] + i[1] * i[1]),
  10437. m = Math.acos(j / (k * l));
  10438. return g > m
  10439. }
  10440. return 0 == c.area(a, b, f)
  10441. }, c.sqdist = function(a, b) {
  10442. var c = b[0] - a[0],
  10443. d = b[1] - a[1];
  10444. return c * c + d * d
  10445. }
  10446. }, {}
  10447. ],
  10448. 4: [
  10449. function(a, b) {
  10450. function c() {
  10451. this.vertices = []
  10452. }
  10453. function d(a, b, c, d, e) {
  10454. e = e || 0;
  10455. var f = b[1] - a[1],
  10456. h = a[0] - b[0],
  10457. i = f * a[0] + h * a[1],
  10458. j = d[1] - c[1],
  10459. k = c[0] - d[0],
  10460. l = j * c[0] + k * c[1],
  10461. m = f * k - j * h;
  10462. return g.eq(m, 0, e) ? [0, 0] : [(k * i - h * l) / m, (f * l - j * i) / m]
  10463. }
  10464. var e = a("./Line"),
  10465. f = a("./Point"),
  10466. g = a("./Scalar");
  10467. b.exports = c, c.prototype.at = function(a) {
  10468. var b = this.vertices,
  10469. c = b.length;
  10470. return b[0 > a ? a % c + c : a % c]
  10471. }, c.prototype.first = function() {
  10472. return this.vertices[0]
  10473. }, c.prototype.last = function() {
  10474. return this.vertices[this.vertices.length - 1]
  10475. }, c.prototype.clear = function() {
  10476. this.vertices.length = 0
  10477. }, c.prototype.append = function(a, b, c) {
  10478. if ("undefined" == typeof b) throw new Error("From is not given!");
  10479. if ("undefined" == typeof c) throw new Error("To is not given!");
  10480. if (b > c - 1) throw new Error("lol1");
  10481. if (c > a.vertices.length) throw new Error("lol2");
  10482. if (0 > b) throw new Error("lol3");
  10483. for (var d = b; c > d; d++) this.vertices.push(a.vertices[d])
  10484. }, c.prototype.makeCCW = function() {
  10485. for (var a = 0, b = this.vertices, c = 1; c < this.vertices.length; ++c)(b[c][1] < b[a][1] || b[c][1] == b[a][1] && b[c][0] > b[a][0]) && (a = c);
  10486. f.left(this.at(a - 1), this.at(a), this.at(a + 1)) || this.reverse()
  10487. }, c.prototype.reverse = function() {
  10488. for (var a = [], b = 0, c = this.vertices.length; b !== c; b++) a.push(this.vertices.pop());
  10489. this.vertices = a
  10490. }, c.prototype.isReflex = function(a) {
  10491. return f.right(this.at(a - 1), this.at(a), this.at(a + 1))
  10492. };
  10493. var h = [],
  10494. i = [];
  10495. c.prototype.canSee = function(a, b) {
  10496. var c, d, g = h,
  10497. j = i;
  10498. if (f.leftOn(this.at(a + 1), this.at(a), this.at(b)) && f.rightOn(this.at(a - 1), this.at(a), this.at(b))) return !1;
  10499. d = f.sqdist(this.at(a), this.at(b));
  10500. for (var k = 0; k !== this.vertices.length; ++k)
  10501. if ((k + 1) % this.vertices.length !== a && k !== a && f.leftOn(this.at(a), this.at(b), this.at(k + 1)) && f.rightOn(this.at(a), this.at(b), this.at(k)) && (g[0] = this.at(a), g[1] = this.at(b), j[0] = this.at(k), j[1] = this.at(k + 1), c = e.lineInt(g, j), f.sqdist(this.at(a), c) < d)) return !1;
  10502. return !0
  10503. }, c.prototype.copy = function(a, b, d) {
  10504. var e = d || new c;
  10505. if (e.clear(), b > a)
  10506. for (var f = a; b >= f; f++) e.vertices.push(this.vertices[f]);
  10507. else {
  10508. for (var f = 0; b >= f; f++) e.vertices.push(this.vertices[f]);
  10509. for (var f = a; f < this.vertices.length; f++) e.vertices.push(this.vertices[f])
  10510. }
  10511. return e
  10512. }, c.prototype.getCutEdges = function() {
  10513. for (var a = [], b = [], d = [], e = new c, f = Number.MAX_VALUE, g = 0; g < this.vertices.length; ++g)
  10514. if (this.isReflex(g))
  10515. for (var h = 0; h < this.vertices.length; ++h)
  10516. if (this.canSee(g, h)) {
  10517. b = this.copy(g, h, e).getCutEdges(), d = this.copy(h, g, e).getCutEdges();
  10518. for (var i = 0; i < d.length; i++) b.push(d[i]);
  10519. b.length < f && (a = b, f = b.length, a.push([this.at(g), this.at(h)]))
  10520. }
  10521. return a
  10522. }, c.prototype.decomp = function() {
  10523. var a = this.getCutEdges();
  10524. return a.length > 0 ? this.slice(a) : [this]
  10525. }, c.prototype.slice = function(a) {
  10526. if (0 == a.length) return [this];
  10527. if (a instanceof Array && a.length && a[0] instanceof Array && 2 == a[0].length && a[0][0] instanceof Array) {
  10528. for (var b = [this], c = 0; c < a.length; c++)
  10529. for (var d = a[c], e = 0; e < b.length; e++) {
  10530. var f = b[e],
  10531. g = f.slice(d);
  10532. if (g) {
  10533. b.splice(e, 1), b.push(g[0], g[1]);
  10534. break
  10535. }
  10536. }
  10537. return b
  10538. }
  10539. var d = a,
  10540. c = this.vertices.indexOf(d[0]),
  10541. e = this.vertices.indexOf(d[1]);
  10542. return -1 != c && -1 != e ? [this.copy(c, e), this.copy(e, c)] : !1
  10543. }, c.prototype.isSimple = function() {
  10544. for (var a = this.vertices, b = 0; b < a.length - 1; b++)
  10545. for (var c = 0; b - 1 > c; c++)
  10546. if (e.segmentsIntersect(a[b], a[b + 1], a[c], a[c + 1])) return !1;
  10547. for (var b = 1; b < a.length - 2; b++)
  10548. if (e.segmentsIntersect(a[0], a[a.length - 1], a[b], a[b + 1])) return !1;
  10549. return !0
  10550. }, c.prototype.quickDecomp = function(a, b, e, g, h, i) {
  10551. h = h || 100, i = i || 0, g = g || 25, a = "undefined" != typeof a ? a : [], b = b || [], e = e || [];
  10552. var j = [0, 0],
  10553. k = [0, 0],
  10554. l = [0, 0],
  10555. m = 0,
  10556. n = 0,
  10557. o = 0,
  10558. p = 0,
  10559. q = 0,
  10560. r = 0,
  10561. s = 0,
  10562. t = new c,
  10563. u = new c,
  10564. v = this,
  10565. w = this.vertices;
  10566. if (w.length < 3) return a;
  10567. if (i++, i > h) return console.warn("quickDecomp: max level (" + h + ") reached."), a;
  10568. for (var x = 0; x < this.vertices.length; ++x)
  10569. if (v.isReflex(x)) {
  10570. b.push(v.vertices[x]), m = n = Number.MAX_VALUE;
  10571. for (var y = 0; y < this.vertices.length; ++y) f.left(v.at(x - 1), v.at(x), v.at(y)) && f.rightOn(v.at(x - 1), v.at(x), v.at(y - 1)) && (l = d(v.at(x - 1), v.at(x), v.at(y), v.at(y - 1)), f.right(v.at(x + 1), v.at(x), l) && (o = f.sqdist(v.vertices[x], l), n > o && (n = o, k = l, r = y))), f.left(v.at(x + 1), v.at(x), v.at(y + 1)) && f.rightOn(v.at(x + 1), v.at(x), v.at(y)) && (l = d(v.at(x + 1), v.at(x), v.at(y), v.at(y + 1)), f.left(v.at(x - 1), v.at(x), l) && (o = f.sqdist(v.vertices[x], l), m > o && (m = o, j = l, q = y)));
  10572. if (r == (q + 1) % this.vertices.length) l[0] = (k[0] + j[0]) / 2, l[1] = (k[1] + j[1]) / 2, e.push(l), q > x ? (t.append(v, x, q + 1), t.vertices.push(l), u.vertices.push(l), 0 != r && u.append(v, r, v.vertices.length), u.append(v, 0, x + 1)) : (0 != x && t.append(v, x, v.vertices.length), t.append(v, 0, q + 1), t.vertices.push(l), u.vertices.push(l), u.append(v, r, x + 1));
  10573. else {
  10574. if (r > q && (q += this.vertices.length), p = Number.MAX_VALUE, r > q) return a;
  10575. for (var y = r; q >= y; ++y) f.leftOn(v.at(x - 1), v.at(x), v.at(y)) && f.rightOn(v.at(x + 1), v.at(x), v.at(y)) && (o = f.sqdist(v.at(x), v.at(y)), p > o && (p = o, s = y % this.vertices.length));
  10576. s > x ? (t.append(v, x, s + 1), 0 != s && u.append(v, s, w.length), u.append(v, 0, x + 1)) : (0 != x && t.append(v, x, w.length), t.append(v, 0, s + 1), u.append(v, s, x + 1))
  10577. }
  10578. return t.vertices.length < u.vertices.length ? (t.quickDecomp(a, b, e, g, h, i), u.quickDecomp(a, b, e, g, h, i)) : (u.quickDecomp(a, b, e, g, h, i), t.quickDecomp(a, b, e, g, h, i)), a
  10579. }
  10580. return a.push(this), a
  10581. }, c.prototype.removeCollinearPoints = function(a) {
  10582. for (var b = 0, c = this.vertices.length - 1; this.vertices.length > 3 && c >= 0; --c) f.collinear(this.at(c - 1), this.at(c), this.at(c + 1), a) && (this.vertices.splice(c % this.vertices.length, 1), c--, b++);
  10583. return b
  10584. }
  10585. }, {
  10586. "./Line": 2,
  10587. "./Point": 3,
  10588. "./Scalar": 5
  10589. }
  10590. ],
  10591. 5: [
  10592. function(a, b) {
  10593. function c() {}
  10594. b.exports = c, c.eq = function(a, b, c) {
  10595. return c = c || 0, Math.abs(a - b) < c
  10596. }
  10597. }, {}
  10598. ],
  10599. 6: [
  10600. function(a, b) {
  10601. b.exports = {
  10602. Polygon: a("./Polygon"),
  10603. Point: a("./Point")
  10604. }
  10605. }, {
  10606. "./Point": 3,
  10607. "./Polygon": 4
  10608. }
  10609. ],
  10610. 7: [
  10611. function(a, b) {
  10612. b.exports = {
  10613. name: "p2",
  10614. version: "0.5.0",
  10615. description: "A JavaScript 2D physics engine.",
  10616. author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
  10617. keywords: ["p2.js", "p2", "physics", "engine", "2d"],
  10618. main: "./src/p2.js",
  10619. engines: {
  10620. node: "*"
  10621. },
  10622. repository: {
  10623. type: "git",
  10624. url: "https://github.com/schteppe/p2.js.git"
  10625. },
  10626. bugs: {
  10627. url: "https://github.com/schteppe/p2.js/issues"
  10628. },
  10629. licenses: [{
  10630. type: "MIT"
  10631. }],
  10632. devDependencies: {
  10633. grunt: "~0.4.0",
  10634. "grunt-contrib-jshint": "~0.9.2",
  10635. "grunt-contrib-nodeunit": "~0.1.2",
  10636. "grunt-contrib-uglify": "~0.4.0",
  10637. "grunt-contrib-watch": "~0.5.0",
  10638. "grunt-browserify": "~2.0.1",
  10639. "z-schema": "~2.4.6"
  10640. },
  10641. dependencies: {
  10642. "poly-decomp": "0.1.0",
  10643. "gl-matrix": "2.1.0"
  10644. }
  10645. }
  10646. }, {}
  10647. ],
  10648. 8: [
  10649. function(a, b) {
  10650. function c(a) {
  10651. this.lowerBound = d.create(), a && a.lowerBound && d.copy(this.lowerBound, a.lowerBound), this.upperBound = d.create(), a && a.upperBound && d.copy(this.upperBound, a.upperBound)
  10652. } {
  10653. var d = a("../math/vec2");
  10654. a("../utils/Utils")
  10655. }
  10656. b.exports = c;
  10657. var e = d.create();
  10658. c.prototype.setFromPoints = function(a, b, c) {
  10659. var f = this.lowerBound,
  10660. g = this.upperBound;
  10661. d.set(f, Number.MAX_VALUE, Number.MAX_VALUE), d.set(g, -Number.MAX_VALUE, -Number.MAX_VALUE);
  10662. for (var h = 0; h < a.length; h++) {
  10663. var i = a[h];
  10664. "number" == typeof c && (d.rotate(e, i, c), i = e);
  10665. for (var j = 0; 2 > j; j++) i[j] > g[j] && (g[j] = i[j]), i[j] < f[j] && (f[j] = i[j])
  10666. }
  10667. b && (d.add(this.lowerBound, this.lowerBound, b), d.add(this.upperBound, this.upperBound, b))
  10668. }, c.prototype.copy = function(a) {
  10669. d.copy(this.lowerBound, a.lowerBound), d.copy(this.upperBound, a.upperBound)
  10670. }, c.prototype.extend = function(a) {
  10671. for (var b = 0; 2 > b; b++) a.lowerBound[b] < this.lowerBound[b] && (this.lowerBound[b] = a.lowerBound[b]), a.upperBound[b] > this.upperBound[b] && (this.upperBound[b] = a.upperBound[b])
  10672. }, c.prototype.overlaps = function(a) {
  10673. var b = this.lowerBound,
  10674. c = this.upperBound,
  10675. d = a.lowerBound,
  10676. e = a.upperBound;
  10677. return (d[0] <= c[0] && c[0] <= e[0] || b[0] <= e[0] && e[0] <= c[0]) && (d[1] <= c[1] && c[1] <= e[1] || b[1] <= e[1] && e[1] <= c[1])
  10678. }
  10679. }, {
  10680. "../math/vec2": 30,
  10681. "../utils/Utils": 47
  10682. }
  10683. ],
  10684. 9: [
  10685. function(a, b) {
  10686. function c(a) {
  10687. this.type = a, this.result = [], this.world = null, this.boundingVolumeType = c.AABB
  10688. }
  10689. var d = a("../math/vec2"),
  10690. e = a("../objects/Body");
  10691. b.exports = c, c.AABB = 1, c.BOUNDING_CIRCLE = 2, c.prototype.setWorld = function(a) {
  10692. this.world = a
  10693. }, c.prototype.getCollisionPairs = function() {
  10694. throw new Error("getCollisionPairs must be implemented in a subclass!")
  10695. };
  10696. var f = d.create();
  10697. c.boundingRadiusCheck = function(a, b) {
  10698. d.sub(f, a.position, b.position);
  10699. var c = d.squaredLength(f),
  10700. e = a.boundingRadius + b.boundingRadius;
  10701. return e * e >= c
  10702. }, c.aabbCheck = function(a, b) {
  10703. return a.aabbNeedsUpdate && a.updateAABB(), b.aabbNeedsUpdate && b.updateAABB(), a.aabb.overlaps(b.aabb)
  10704. }, c.prototype.boundingVolumeCheck = function(a, b) {
  10705. var d;
  10706. switch (this.boundingVolumeType) {
  10707. case c.BOUNDING_CIRCLE:
  10708. d = c.boundingRadiusCheck(a, b);
  10709. break;
  10710. case c.AABB:
  10711. d = c.aabbCheck(a, b);
  10712. break;
  10713. default:
  10714. throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType)
  10715. }
  10716. return d
  10717. }, c.canCollide = function(a, b) {
  10718. return a.motionState === e.STATIC && b.motionState === e.STATIC ? !1 : a.motionState === e.KINEMATIC && b.motionState === e.STATIC || a.motionState === e.STATIC && b.motionState === e.KINEMATIC ? !1 : a.motionState === e.KINEMATIC && b.motionState === e.KINEMATIC ? !1 : a.sleepState === e.SLEEPING && b.sleepState === e.SLEEPING ? !1 : a.sleepState === e.SLEEPING && b.motionState === e.STATIC || b.sleepState === e.SLEEPING && a.motionState === e.STATIC ? !1 : !0
  10719. }, c.NAIVE = 1, c.SAP = 2
  10720. }, {
  10721. "../math/vec2": 30,
  10722. "../objects/Body": 31
  10723. }
  10724. ],
  10725. 10: [
  10726. function(a, b) {
  10727. function c(a) {
  10728. d.apply(this), a = e.defaults(a, {
  10729. xmin: -100,
  10730. xmax: 100,
  10731. ymin: -100,
  10732. ymax: 100,
  10733. nx: 10,
  10734. ny: 10
  10735. }), this.xmin = a.xmin, this.ymin = a.ymin, this.xmax = a.xmax, this.ymax = a.ymax, this.nx = a.nx, this.ny = a.ny, this.binsizeX = (this.xmax - this.xmin) / this.nx, this.binsizeY = (this.ymax - this.ymin) / this.ny
  10736. }
  10737. var d = (a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Particle"), a("../collision/Broadphase")),
  10738. e = (a("../math/vec2"), a("../utils/Utils"));
  10739. b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
  10740. for (var b = [], c = a.bodies, e = c.length, f = (this.binsizeX, this.binsizeY, this.nx), g = this.ny, h = this.xmin, i = this.ymin, j = this.xmax, k = this.ymax, l = [], m = f * g, n = 0; m > n; n++) l.push([]);
  10741. for (var o = f / (j - h), p = g / (k - i), n = 0; n !== e; n++)
  10742. for (var q = c[n], r = q.aabb, s = Math.max(r.lowerBound[0], h), t = Math.max(r.lowerBound[1], i), u = Math.min(r.upperBound[0], j), v = Math.min(r.upperBound[1], k), w = Math.floor(o * (s - h)), x = Math.floor(p * (t - i)), y = Math.floor(o * (u - h)), z = Math.floor(p * (v - i)), A = w; y >= A; A++)
  10743. for (var B = x; z >= B; B++) {
  10744. var C = A,
  10745. D = B,
  10746. E = C * (g - 1) + D;
  10747. E >= 0 && m > E && l[E].push(q)
  10748. }
  10749. for (var n = 0; n !== m; n++)
  10750. for (var F = l[n], A = 0, G = F.length; A !== G; A++)
  10751. for (var q = F[A], B = 0; B !== A; B++) {
  10752. var H = F[B];
  10753. d.canCollide(q, H) && this.boundingVolumeCheck(q, H) && b.push(q, H)
  10754. }
  10755. return b
  10756. }
  10757. }, {
  10758. "../collision/Broadphase": 9,
  10759. "../math/vec2": 30,
  10760. "../shapes/Circle": 35,
  10761. "../shapes/Particle": 39,
  10762. "../shapes/Plane": 40,
  10763. "../utils/Utils": 47
  10764. }
  10765. ],
  10766. 11: [
  10767. function(a, b) {
  10768. function c() {
  10769. d.call(this, d.NAIVE)
  10770. } {
  10771. var d = (a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Shape"), a("../shapes/Particle"), a("../collision/Broadphase"));
  10772. a("../math/vec2")
  10773. }
  10774. b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
  10775. var b = a.bodies,
  10776. c = this.result;
  10777. c.length = 0;
  10778. for (var e = 0, f = b.length; e !== f; e++)
  10779. for (var g = b[e], h = 0; e > h; h++) {
  10780. var i = b[h];
  10781. d.canCollide(g, i) && this.boundingVolumeCheck(g, i) && c.push(g, i)
  10782. }
  10783. return c
  10784. }
  10785. }, {
  10786. "../collision/Broadphase": 9,
  10787. "../math/vec2": 30,
  10788. "../shapes/Circle": 35,
  10789. "../shapes/Particle": 39,
  10790. "../shapes/Plane": 40,
  10791. "../shapes/Shape": 42
  10792. }
  10793. ],
  10794. 12: [
  10795. function(a, b) {
  10796. function c() {
  10797. this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, this.slipForce = 10, this.frictionCoefficient = .3, this.surfaceVelocity = 0, this.reuseObjects = !0, this.reusableContactEquations = [], this.reusableFrictionEquations = [], this.restitution = 0, this.stiffness = l.DEFAULT_STIFFNESS, this.relaxation = l.DEFAULT_RELAXATION, this.frictionStiffness = l.DEFAULT_STIFFNESS, this.frictionRelaxation = l.DEFAULT_RELAXATION, this.collidingBodiesLastStep = new k
  10798. }
  10799. function d(a, b) {
  10800. f.set(a.vertices[0], .5 * -b.length, -b.radius), f.set(a.vertices[1], .5 * b.length, -b.radius), f.set(a.vertices[2], .5 * b.length, b.radius), f.set(a.vertices[3], .5 * -b.length, b.radius)
  10801. }
  10802. function e(a, b, c, d) {
  10803. for (var e = R, i = S, j = T, k = U, l = a, m = b.vertices, n = null, o = 0; o !== m.length + 1; o++) {
  10804. var p = m[o % m.length],
  10805. q = m[(o + 1) % m.length];
  10806. f.rotate(e, p, d), f.rotate(i, q, d), h(e, e, c), h(i, i, c), g(j, e, l), g(k, i, l);
  10807. var r = f.crossLength(j, k);
  10808. if (null === n && (n = r), 0 >= r * n) return !1;
  10809. n = r
  10810. }
  10811. return !0
  10812. }
  10813. var f = a("../math/vec2"),
  10814. g = f.sub,
  10815. h = f.add,
  10816. i = f.dot,
  10817. j = a("../utils/Utils"),
  10818. k = a("../utils/TupleDictionary"),
  10819. l = a("../equations/Equation"),
  10820. m = a("../equations/ContactEquation"),
  10821. n = a("../equations/FrictionEquation"),
  10822. o = a("../shapes/Circle"),
  10823. p = a("../shapes/Convex"),
  10824. q = a("../shapes/Shape"),
  10825. r = (a("../objects/Body"), a("../shapes/Rectangle"));
  10826. b.exports = c;
  10827. var s = f.fromValues(0, 1),
  10828. t = f.fromValues(0, 0),
  10829. u = f.fromValues(0, 0),
  10830. v = f.fromValues(0, 0),
  10831. w = f.fromValues(0, 0),
  10832. x = f.fromValues(0, 0),
  10833. y = f.fromValues(0, 0),
  10834. z = f.fromValues(0, 0),
  10835. A = f.fromValues(0, 0),
  10836. B = f.fromValues(0, 0),
  10837. C = f.fromValues(0, 0),
  10838. D = f.fromValues(0, 0),
  10839. E = f.fromValues(0, 0),
  10840. F = f.fromValues(0, 0),
  10841. G = f.fromValues(0, 0),
  10842. H = f.fromValues(0, 0),
  10843. I = f.fromValues(0, 0),
  10844. J = f.fromValues(0, 0),
  10845. K = f.fromValues(0, 0),
  10846. L = [];
  10847. c.prototype.collidedLastStep = function(a, b) {
  10848. var c = 0 | a.id,
  10849. d = 0 | b.id;
  10850. return !!this.collidingBodiesLastStep.get(c, d)
  10851. }, c.prototype.reset = function() {
  10852. this.collidingBodiesLastStep.reset();
  10853. for (var a = 0; a !== this.contactEquations.length; a++) {
  10854. var b = this.contactEquations[a],
  10855. c = 0 | b.bodyA.id,
  10856. d = 0 | b.bodyB.id;
  10857. this.collidingBodiesLastStep.set(c, d, !0)
  10858. }
  10859. if (this.reuseObjects) {
  10860. var e = this.contactEquations,
  10861. f = this.frictionEquations,
  10862. g = this.reusableFrictionEquations,
  10863. h = this.reusableContactEquations;
  10864. j.appendArray(h, e), j.appendArray(g, f)
  10865. }
  10866. this.contactEquations.length = this.frictionEquations.length = 0
  10867. }, c.prototype.createContactEquation = function(a, b, c, d) {
  10868. var e = this.reusableContactEquations.length ? this.reusableContactEquations.pop() : new m(a, b);
  10869. return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.restitution = this.restitution, e.firstImpact = !this.collidedLastStep(a, b), e.stiffness = this.stiffness, e.relaxation = this.relaxation, e.needsUpdate = !0, e.enabled = !0, e
  10870. }, c.prototype.createFrictionEquation = function(a, b, c, d) {
  10871. var e = this.reusableFrictionEquations.length ? this.reusableFrictionEquations.pop() : new n(a, b);
  10872. return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.setSlipForce(this.slipForce), e.frictionCoefficient = this.frictionCoefficient, e.relativeVelocity = this.surfaceVelocity, e.enabled = !0, e.needsUpdate = !0, e.stiffness = this.frictionStiffness, e.relaxation = this.frictionRelaxation, e
  10873. }, c.prototype.createFrictionFromContact = function(a) {
  10874. var b = this.createFrictionEquation(a.bodyA, a.bodyB, a.shapeA, a.shapeB);
  10875. return f.copy(b.contactPointA, a.contactPointA), f.copy(b.contactPointB, a.contactPointB), f.rotate90cw(b.t, a.normalA), b.contactEquation = a, b
  10876. }, c.prototype[q.LINE | q.CONVEX] = c.prototype.convexLine = function(a, b, c, d, e, f, g, h, i) {
  10877. return i ? !1 : 0
  10878. }, c.prototype[q.LINE | q.RECTANGLE] = c.prototype.lineRectangle = function(a, b, c, d, e, f, g, h, i) {
  10879. return i ? !1 : 0
  10880. };
  10881. var M = new r(1, 1),
  10882. N = f.create();
  10883. c.prototype[q.CAPSULE | q.CONVEX] = c.prototype[q.CAPSULE | q.RECTANGLE] = c.prototype.convexCapsule = function(a, b, c, e, g, h, i, j, k) {
  10884. var l = N;
  10885. f.set(l, h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  10886. var m = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  10887. f.set(l, -h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  10888. var n = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  10889. if (k && (m || n)) return !0;
  10890. var o = M;
  10891. d(o, h);
  10892. var p = this.convexConvex(a, b, c, e, g, o, i, j, k);
  10893. return p + m + n
  10894. }, c.prototype[q.CAPSULE | q.LINE] = c.prototype.lineCapsule = function(a, b, c, d, e, f, g, h, i) {
  10895. return i ? !1 : 0
  10896. };
  10897. var O = f.create(),
  10898. P = f.create(),
  10899. Q = new r(1, 1);
  10900. c.prototype[q.CAPSULE | q.CAPSULE] = c.prototype.capsuleCapsule = function(a, b, c, e, g, h, i, j, k) {
  10901. for (var l = O, m = P, n = 0, o = 0; 2 > o; o++) {
  10902. f.set(l, (0 == o ? -1 : 1) * b.length / 2, 0), f.rotate(l, l, e), f.add(l, l, c);
  10903. for (var p = 0; 2 > p; p++) {
  10904. f.set(m, (0 == p ? -1 : 1) * h.length / 2, 0), f.rotate(m, m, j), f.add(m, m, i);
  10905. var q = this.circleCircle(a, b, l, e, g, h, m, j, k, b.radius, h.radius);
  10906. if (k && q) return !0;
  10907. n += q
  10908. }
  10909. }
  10910. var r = Q;
  10911. d(r, b);
  10912. var s = this.convexCapsule(a, r, c, e, g, h, i, j, k);
  10913. if (k && s) return !0;
  10914. n += s, d(r, h);
  10915. var t = this.convexCapsule(g, r, i, j, a, b, c, e, k);
  10916. return k && t ? !0 : n += t
  10917. }, c.prototype[q.LINE | q.LINE] = c.prototype.lineLine = function(a, b, c, d, e, f, g, h, i) {
  10918. return i ? !1 : 0
  10919. }, c.prototype[q.PLANE | q.LINE] = c.prototype.planeLine = function(a, b, c, d, e, j, k, l, m) {
  10920. var n = t,
  10921. o = u,
  10922. p = v,
  10923. q = w,
  10924. r = x,
  10925. C = y,
  10926. D = z,
  10927. E = A,
  10928. F = B,
  10929. G = L;
  10930. numContacts = 0, f.set(n, -j.length / 2, 0), f.set(o, j.length / 2, 0), f.rotate(p, n, l), f.rotate(q, o, l), h(p, p, k), h(q, q, k), f.copy(n, p), f.copy(o, q), g(r, o, n), f.normalize(C, r), f.rotate90cw(F, C), f.rotate(E, s, d), G[0] = n, G[1] = o;
  10931. for (var H = 0; H < G.length; H++) {
  10932. var I = G[H];
  10933. g(D, I, c);
  10934. var J = i(D, E);
  10935. if (0 > J) {
  10936. if (m) return !0;
  10937. var K = this.createContactEquation(a, e, b, j);
  10938. numContacts++, f.copy(K.normalA, E), f.normalize(K.normalA, K.normalA), f.scale(D, E, J), g(K.contactPointA, I, D), g(K.contactPointA, K.contactPointA, a.position), g(K.contactPointB, I, k), h(K.contactPointB, K.contactPointB, k), g(K.contactPointB, K.contactPointB, e.position), this.contactEquations.push(K), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(K))
  10939. }
  10940. }
  10941. return numContacts
  10942. }, c.prototype[q.PARTICLE | q.CAPSULE] = c.prototype.particleCapsule = function(a, b, c, d, e, f, g, h, i) {
  10943. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius, 0)
  10944. }, c.prototype[q.CIRCLE | q.LINE] = c.prototype.circleLine = function(a, b, c, d, e, j, k, l, m, n, o) {
  10945. var p = j,
  10946. q = l,
  10947. r = e,
  10948. s = k,
  10949. H = c,
  10950. I = a,
  10951. J = b,
  10952. n = n || 0,
  10953. o = "undefined" != typeof o ? o : J.radius,
  10954. K = t,
  10955. M = u,
  10956. N = v,
  10957. O = w,
  10958. P = x,
  10959. Q = y,
  10960. R = z,
  10961. S = A,
  10962. T = B,
  10963. U = C,
  10964. V = D,
  10965. W = E,
  10966. X = F,
  10967. Y = G,
  10968. Z = L;
  10969. f.set(S, -p.length / 2, 0), f.set(T, p.length / 2, 0), f.rotate(U, S, q), f.rotate(V, T, q), h(U, U, s), h(V, V, s), f.copy(S, U), f.copy(T, V), g(Q, T, S), f.normalize(R, Q), f.rotate90cw(P, R), g(W, H, S);
  10970. var $ = i(W, P);
  10971. if (g(O, S, s), g(X, H, s), Math.abs($) < o + n) {
  10972. f.scale(K, P, $), g(N, H, K), f.scale(M, P, i(P, X)), f.normalize(M, M), f.scale(M, M, n), h(N, N, M);
  10973. var _ = i(R, N),
  10974. ab = i(R, S),
  10975. bb = i(R, T);
  10976. if (_ > ab && bb > _) {
  10977. if (m) return !0;
  10978. var cb = this.createContactEquation(I, r, b, j);
  10979. return f.scale(cb.normalA, K, -1), f.normalize(cb.normalA, cb.normalA), f.scale(cb.contactPointA, cb.normalA, o), h(cb.contactPointA, cb.contactPointA, H), g(cb.contactPointA, cb.contactPointA, I.position), g(cb.contactPointB, N, s), h(cb.contactPointB, cb.contactPointB, s), g(cb.contactPointB, cb.contactPointB, r.position), this.contactEquations.push(cb), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(cb)), 1
  10980. }
  10981. }
  10982. Z[0] = S, Z[1] = T;
  10983. for (var db = 0; db < Z.length; db++) {
  10984. var eb = Z[db];
  10985. if (g(W, eb, H), f.squaredLength(W) < (o + n) * (o + n)) {
  10986. if (m) return !0;
  10987. var cb = this.createContactEquation(I, r, b, j);
  10988. return f.copy(cb.normalA, W), f.normalize(cb.normalA, cb.normalA), f.scale(cb.contactPointA, cb.normalA, o), h(cb.contactPointA, cb.contactPointA, H), g(cb.contactPointA, cb.contactPointA, I.position), g(cb.contactPointB, eb, s), f.scale(Y, cb.normalA, -n), h(cb.contactPointB, cb.contactPointB, Y), h(cb.contactPointB, cb.contactPointB, s), g(cb.contactPointB, cb.contactPointB, r.position), this.contactEquations.push(cb), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(cb)), 1
  10989. }
  10990. }
  10991. return 0
  10992. }, c.prototype[q.CIRCLE | q.CAPSULE] = c.prototype.circleCapsule = function(a, b, c, d, e, f, g, h, i) {
  10993. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius)
  10994. }, c.prototype[q.CIRCLE | q.CONVEX] = c.prototype[q.CIRCLE | q.RECTANGLE] = c.prototype.circleConvex = function(a, b, c, d, i, j, k, l, m, n) {
  10995. var o = j,
  10996. p = l,
  10997. q = i,
  10998. r = k,
  10999. s = c,
  11000. y = a,
  11001. z = b,
  11002. n = "number" == typeof n ? n : z.radius,
  11003. A = t,
  11004. B = u,
  11005. E = v,
  11006. J = w,
  11007. K = x,
  11008. L = C,
  11009. M = D,
  11010. N = F,
  11011. O = G,
  11012. P = H,
  11013. Q = I,
  11014. R = !1,
  11015. S = Number.MAX_VALUE;
  11016. verts = o.vertices;
  11017. for (var T = 0; T !== verts.length + 1; T++) {
  11018. var U = verts[T % verts.length],
  11019. V = verts[(T + 1) % verts.length];
  11020. if (f.rotate(A, U, p), f.rotate(B, V, p), h(A, A, r), h(B, B, r), g(E, B, A), f.normalize(J, E), f.rotate90cw(K, J), f.scale(O, K, -z.radius), h(O, O, s), e(O, o, r, p)) {
  11021. f.sub(P, A, O);
  11022. var W = Math.abs(f.dot(P, K));
  11023. S > W && (f.copy(Q, O), S = W, f.scale(N, K, W), f.add(N, N, O), R = !0)
  11024. }
  11025. }
  11026. if (R) {
  11027. if (m) return !0;
  11028. var X = this.createContactEquation(y, q, b, j);
  11029. return f.sub(X.normalA, Q, s), f.normalize(X.normalA, X.normalA), f.scale(X.contactPointA, X.normalA, n), h(X.contactPointA, X.contactPointA, s), g(X.contactPointA, X.contactPointA, y.position), g(X.contactPointB, N, r), h(X.contactPointB, X.contactPointB, r), g(X.contactPointB, X.contactPointB, q.position), this.contactEquations.push(X), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(X)), 1
  11030. }
  11031. if (n > 0)
  11032. for (var T = 0; T < verts.length; T++) {
  11033. var Y = verts[T];
  11034. if (f.rotate(M, Y, p), h(M, M, r), g(L, M, s), f.squaredLength(L) < n * n) {
  11035. if (m) return !0;
  11036. var X = this.createContactEquation(y, q, b, j);
  11037. return f.copy(X.normalA, L), f.normalize(X.normalA, X.normalA), f.scale(X.contactPointA, X.normalA, n), h(X.contactPointA, X.contactPointA, s), g(X.contactPointA, X.contactPointA, y.position), g(X.contactPointB, M, r), h(X.contactPointB, X.contactPointB, r), g(X.contactPointB, X.contactPointB, q.position), this.contactEquations.push(X), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(X)), 1
  11038. }
  11039. }
  11040. return 0
  11041. };
  11042. var R = f.create(),
  11043. S = f.create(),
  11044. T = f.create(),
  11045. U = f.create();
  11046. c.prototype[q.PARTICLE | q.CONVEX] = c.prototype[q.PARTICLE | q.RECTANGLE] = c.prototype.particleConvex = function(a, b, c, d, j, k, l, m, n) {
  11047. var o = k,
  11048. p = m,
  11049. q = j,
  11050. r = l,
  11051. s = c,
  11052. A = a,
  11053. B = t,
  11054. D = u,
  11055. E = v,
  11056. G = w,
  11057. H = x,
  11058. I = y,
  11059. L = z,
  11060. M = C,
  11061. N = F,
  11062. O = J,
  11063. P = K,
  11064. Q = Number.MAX_VALUE,
  11065. R = !1,
  11066. S = o.vertices;
  11067. if (!e(s, o, r, p)) return 0;
  11068. if (n) return !0;
  11069. for (var T = 0; T !== S.length + 1; T++) {
  11070. var U = S[T % S.length],
  11071. V = S[(T + 1) % S.length];
  11072. f.rotate(B, U, p), f.rotate(D, V, p), h(B, B, r), h(D, D, r), g(E, D, B), f.normalize(G, E), f.rotate90cw(H, G), g(M, s, B); {
  11073. i(M, H)
  11074. }
  11075. g(I, B, r), g(L, s, r), f.sub(O, B, s);
  11076. var W = Math.abs(f.dot(O, H));
  11077. Q > W && (Q = W, f.scale(N, H, W), f.add(N, N, s), f.copy(P, H), R = !0)
  11078. }
  11079. if (R) {
  11080. var X = this.createContactEquation(A, q, b, k);
  11081. return f.scale(X.normalA, P, -1), f.normalize(X.normalA, X.normalA), f.set(X.contactPointA, 0, 0), h(X.contactPointA, X.contactPointA, s), g(X.contactPointA, X.contactPointA, A.position), g(X.contactPointB, N, r), h(X.contactPointB, X.contactPointB, r), g(X.contactPointB, X.contactPointB, q.position), this.contactEquations.push(X), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(X)), 1
  11082. }
  11083. return 0
  11084. }, c.prototype[q.CIRCLE] = c.prototype.circleCircle = function(a, b, c, d, e, i, j, k, l, m, n) {
  11085. var o = a,
  11086. p = b,
  11087. q = c,
  11088. r = e,
  11089. s = i,
  11090. u = j,
  11091. v = t,
  11092. m = m || p.radius,
  11093. n = n || s.radius;
  11094. g(v, c, j);
  11095. var w = m + n;
  11096. if (f.squaredLength(v) > w * w) return 0;
  11097. if (l) return !0;
  11098. var x = this.createContactEquation(o, r, b, i);
  11099. return g(x.normalA, u, q), f.normalize(x.normalA, x.normalA), f.scale(x.contactPointA, x.normalA, m), f.scale(x.contactPointB, x.normalA, -n), h(x.contactPointA, x.contactPointA, q), g(x.contactPointA, x.contactPointA, o.position), h(x.contactPointB, x.contactPointB, u), g(x.contactPointB, x.contactPointB, r.position), this.contactEquations.push(x), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x)), 1
  11100. }, c.prototype[q.PLANE | q.CONVEX] = c.prototype[q.PLANE | q.RECTANGLE] = c.prototype.planeConvex = function(a, b, d, e, j, k, l, m, n) {
  11101. var o = j,
  11102. p = l,
  11103. q = k,
  11104. r = m,
  11105. w = a,
  11106. x = b,
  11107. y = d,
  11108. z = e,
  11109. A = t,
  11110. B = u,
  11111. C = v,
  11112. D = 0;
  11113. f.rotate(B, s, z);
  11114. for (var E = 0; E < q.vertices.length; E++) {
  11115. var F = q.vertices[E];
  11116. if (f.rotate(A, F, r), h(A, A, p), g(C, A, y), i(C, B) <= c.convexPrecision) {
  11117. if (n) return !0;
  11118. D++;
  11119. var G = this.createContactEquation(w, o, x, q);
  11120. g(C, A, y), f.copy(G.normalA, B);
  11121. var H = i(C, G.normalA);
  11122. f.scale(C, G.normalA, H), g(G.contactPointB, A, o.position), g(G.contactPointA, A, C), g(G.contactPointA, G.contactPointA, w.position), this.contactEquations.push(G), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(G))
  11123. }
  11124. }
  11125. return D
  11126. }, c.prototype.convexPlane = function(a, b, c, d, e, f, g, h, i) {
  11127. return console.warn("Narrowphase.prototype.convexPlane is deprecated. Use planeConvex instead!"), this.planeConvex(e, f, g, h, a, b, c, d, i)
  11128. }, c.prototype[q.PARTICLE | q.PLANE] = c.prototype.particlePlane = function(a, b, c, d, e, h, j, k, l) {
  11129. var m = a,
  11130. n = c,
  11131. o = e,
  11132. p = j,
  11133. q = k,
  11134. r = t,
  11135. v = u;
  11136. q = q || 0, g(r, n, p), f.rotate(v, s, q);
  11137. var w = i(r, v);
  11138. if (w > 0) return 0;
  11139. if (l) return !0;
  11140. var x = this.createContactEquation(o, m, h, b);
  11141. return f.copy(x.normalA, v), f.scale(r, x.normalA, w), g(x.contactPointA, n, r), g(x.contactPointA, x.contactPointA, o.position), g(x.contactPointB, n, m.position), this.contactEquations.push(x), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x)), 1
  11142. }, c.prototype[q.CIRCLE | q.PARTICLE] = c.prototype.circleParticle = function(a, b, c, d, e, i, j, k, l) {
  11143. var m = a,
  11144. n = b,
  11145. o = c,
  11146. p = e,
  11147. q = j,
  11148. r = t;
  11149. if (g(r, q, o), f.squaredLength(r) > n.radius * n.radius) return 0;
  11150. if (l) return !0;
  11151. var s = this.createContactEquation(m, p, b, i);
  11152. return f.copy(s.normalA, r), f.normalize(s.normalA, s.normalA), f.scale(s.contactPointA, s.normalA, n.radius), h(s.contactPointA, s.contactPointA, o), g(s.contactPointA, s.contactPointA, m.position), g(s.contactPointB, q, p.position), this.contactEquations.push(s), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(s)), 1
  11153. }; {
  11154. var V = new o(1),
  11155. W = f.create(),
  11156. X = f.create();
  11157. f.create()
  11158. }
  11159. c.prototype[q.PLANE | q.CAPSULE] = c.prototype.planeCapsule = function(a, b, c, d, e, g, i, j, k) {
  11160. var l = W,
  11161. m = X,
  11162. n = V;
  11163. f.set(l, -g.length / 2, 0), f.rotate(l, l, j), h(l, l, i), f.set(m, g.length / 2, 0), f.rotate(m, m, j), h(m, m, i), n.radius = g.radius;
  11164. var o = this.circlePlane(e, n, l, 0, a, b, c, d, k),
  11165. p = this.circlePlane(e, n, m, 0, a, b, c, d, k);
  11166. return k ? o || p : o + p
  11167. }, c.prototype.capsulePlane = function(a, b, c, d, e, f, g, h, i) {
  11168. return console.warn("Narrowphase.prototype.capsulePlane() is deprecated. Use .planeCapsule() instead!"), this.planeCapsule(e, f, g, h, a, b, c, d, i)
  11169. }, c.prototype[q.CIRCLE | q.PLANE] = c.prototype.circlePlane = function(a, b, c, d, e, j, k, l, m) {
  11170. var n = a,
  11171. o = b,
  11172. p = c,
  11173. q = e,
  11174. r = k,
  11175. w = l;
  11176. w = w || 0;
  11177. var x = t,
  11178. y = u,
  11179. z = v;
  11180. g(x, p, r), f.rotate(y, s, w);
  11181. var A = i(y, x);
  11182. if (A > o.radius) return 0;
  11183. if (m) return !0;
  11184. var B = this.createContactEquation(q, n, j, b);
  11185. return f.copy(B.normalA, y), f.scale(B.contactPointB, B.normalA, -o.radius), h(B.contactPointB, B.contactPointB, p), g(B.contactPointB, B.contactPointB, n.position), f.scale(z, B.normalA, A), g(B.contactPointA, x, z), h(B.contactPointA, B.contactPointA, r), g(B.contactPointA, B.contactPointA, q.position), this.contactEquations.push(B), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(B)), 1
  11186. }, c.convexPrecision = 1e-7, c.prototype[q.CONVEX] = c.prototype[q.CONVEX | q.RECTANGLE] = c.prototype[q.RECTANGLE] = c.prototype.convexConvex = function(a, b, d, e, j, k, l, m, n, o) {
  11187. var p = t,
  11188. q = u,
  11189. r = v,
  11190. s = w,
  11191. y = x,
  11192. C = z,
  11193. D = A,
  11194. E = B,
  11195. F = 0,
  11196. o = o || c.convexPrecision,
  11197. G = c.findSeparatingAxis(b, d, e, k, l, m, p);
  11198. if (!G) return 0;
  11199. g(D, l, d), i(p, D) > 0 && f.scale(p, p, -1);
  11200. var H = c.getClosestEdge(b, e, p, !0),
  11201. I = c.getClosestEdge(k, m, p);
  11202. if (-1 === H || -1 === I) return 0;
  11203. for (var J = 0; 2 > J; J++) {
  11204. var K = H,
  11205. L = I,
  11206. M = b,
  11207. N = k,
  11208. O = d,
  11209. P = l,
  11210. Q = e,
  11211. R = m,
  11212. S = a,
  11213. T = j;
  11214. if (0 === J) {
  11215. var U;
  11216. U = K, K = L, L = U, U = M, M = N, N = U, U = O, O = P, P = U, U = Q, Q = R, R = U, U = S, S = T, T = U
  11217. }
  11218. for (var V = L; L + 2 > V; V++) {
  11219. var W = N.vertices[(V + N.vertices.length) % N.vertices.length];
  11220. f.rotate(q, W, R), h(q, q, P);
  11221. for (var X = 0, Y = K - 1; K + 2 > Y; Y++) {
  11222. var Z = M.vertices[(Y + M.vertices.length) % M.vertices.length],
  11223. $ = M.vertices[(Y + 1 + M.vertices.length) % M.vertices.length];
  11224. f.rotate(r, Z, Q), f.rotate(s, $, Q), h(r, r, O), h(s, s, O), g(y, s, r), f.rotate90cw(E, y), f.normalize(E, E), g(D, q, r);
  11225. var _ = i(E, D);
  11226. o >= _ && X++
  11227. }
  11228. if (X >= 3) {
  11229. if (n) return !0;
  11230. var ab = this.createContactEquation(S, T, M, N);
  11231. F++;
  11232. var Z = M.vertices[K % M.vertices.length],
  11233. $ = M.vertices[(K + 1) % M.vertices.length];
  11234. f.rotate(r, Z, Q), f.rotate(s, $, Q), h(r, r, O), h(s, s, O), g(y, s, r), f.rotate90cw(ab.normalA, y), f.normalize(ab.normalA, ab.normalA), g(D, q, r);
  11235. var _ = i(ab.normalA, D);
  11236. f.scale(C, ab.normalA, _), g(ab.contactPointA, q, O), g(ab.contactPointA, ab.contactPointA, C), h(ab.contactPointA, ab.contactPointA, O), g(ab.contactPointA, ab.contactPointA, S.position), g(ab.contactPointB, q, P), h(ab.contactPointB, ab.contactPointB, P), g(ab.contactPointB, ab.contactPointB, T.position), this.contactEquations.push(ab), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(ab))
  11237. }
  11238. }
  11239. }
  11240. return F
  11241. };
  11242. var Y = f.fromValues(0, 0);
  11243. c.projectConvexOntoAxis = function(a, b, c, d, e) {
  11244. var g, h, j = null,
  11245. k = null,
  11246. l = Y;
  11247. f.rotate(l, d, -c);
  11248. for (var m = 0; m < a.vertices.length; m++) g = a.vertices[m], h = i(g, l), (null === j || h > j) && (j = h), (null === k || k > h) && (k = h);
  11249. if (k > j) {
  11250. var n = k;
  11251. k = j, j = n
  11252. }
  11253. var o = i(b, d);
  11254. f.set(e, k + o, j + o)
  11255. };
  11256. var Z = f.fromValues(0, 0),
  11257. $ = f.fromValues(0, 0),
  11258. _ = f.fromValues(0, 0),
  11259. ab = f.fromValues(0, 0),
  11260. bb = f.fromValues(0, 0),
  11261. cb = f.fromValues(0, 0);
  11262. c.findSeparatingAxis = function(a, b, d, e, h, i, j) {
  11263. for (var k = null, l = !1, m = !1, n = Z, o = $, p = _, q = ab, r = bb, s = cb, t = 0; 2 !== t; t++) {
  11264. var u = a,
  11265. v = d;
  11266. 1 === t && (u = e, v = i);
  11267. for (var w = 0; w !== u.vertices.length; w++) {
  11268. f.rotate(o, u.vertices[w], v), f.rotate(p, u.vertices[(w + 1) % u.vertices.length], v), g(n, p, o), f.rotate90cw(q, n), f.normalize(q, q), c.projectConvexOntoAxis(a, b, d, q, r), c.projectConvexOntoAxis(e, h, i, q, s);
  11269. var x = r,
  11270. y = s,
  11271. z = !1;
  11272. r[0] > s[0] && (y = r, x = s, z = !0);
  11273. var A = y[0] - x[1];
  11274. l = A <= c.convexPrecision, (null === k || A > k) && (f.copy(j, q), k = A, m = l)
  11275. }
  11276. }
  11277. return m
  11278. };
  11279. var db = f.fromValues(0, 0),
  11280. eb = f.fromValues(0, 0),
  11281. fb = f.fromValues(0, 0);
  11282. c.getClosestEdge = function(a, b, c, d) {
  11283. var e = db,
  11284. h = eb,
  11285. j = fb;
  11286. f.rotate(e, c, -b), d && f.scale(e, e, -1);
  11287. for (var k = -1, l = a.vertices.length, m = 0; m !== l; m++) {
  11288. g(h, a.vertices[(m + 1) % l], a.vertices[m % l]), f.rotate90cw(j, h), f.normalize(j, j);
  11289. var n = i(j, e);
  11290. (-1 == k || n > maxDot) && (k = m % l, maxDot = n)
  11291. }
  11292. return k
  11293. };
  11294. var gb = f.create(),
  11295. hb = f.create(),
  11296. ib = f.create(),
  11297. jb = f.create(),
  11298. kb = f.create(),
  11299. lb = f.create(),
  11300. mb = f.create();
  11301. c.prototype[q.CIRCLE | q.HEIGHTFIELD] = c.prototype.circleHeightfield = function(a, b, c, d, e, i, j, k, l, m) {
  11302. var n = i.data,
  11303. m = m || b.radius,
  11304. o = i.elementWidth,
  11305. p = hb,
  11306. q = gb,
  11307. r = kb,
  11308. s = mb,
  11309. t = lb,
  11310. u = ib,
  11311. v = jb,
  11312. w = Math.floor((c[0] - m - j[0]) / o),
  11313. x = Math.ceil((c[0] + m - j[0]) / o);
  11314. 0 > w && (w = 0), x >= n.length && (x = n.length - 1);
  11315. for (var y = n[w], z = n[x], A = w; x > A; A++) n[A] < z && (z = n[A]), n[A] > y && (y = n[A]);
  11316. if (c[1] - m > y) return l ? !1 : 0;
  11317. c[1] + m < z;
  11318. for (var B = !1, A = w; x > A; A++) {
  11319. f.set(u, A * o, n[A]), f.set(v, (A + 1) * o, n[A + 1]), f.add(u, u, j), f.add(v, v, j), f.sub(t, v, u), f.rotate(t, t, Math.PI / 2), f.normalize(t, t), f.scale(q, t, -m), f.add(q, q, c), f.sub(p, q, u);
  11320. var C = f.dot(p, t);
  11321. if (q[0] >= u[0] && q[0] < v[0] && 0 >= C) {
  11322. if (l) return !0;
  11323. B = !0, f.scale(p, t, -C), f.add(r, q, p), f.copy(s, t);
  11324. var D = this.createContactEquation(e, a, i, b);
  11325. f.copy(D.normalA, s), f.scale(D.contactPointB, D.normalA, -m), h(D.contactPointB, D.contactPointB, c), g(D.contactPointB, D.contactPointB, a.position), f.copy(D.contactPointA, r), f.sub(D.contactPointA, D.contactPointA, e.position), this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D))
  11326. }
  11327. }
  11328. if (B = !1, m > 0)
  11329. for (var A = w; x >= A; A++)
  11330. if (f.set(u, A * o, n[A]), f.add(u, u, j), f.sub(p, c, u), f.squaredLength(p) < m * m) {
  11331. if (l) return !0;
  11332. B = !0;
  11333. var D = this.createContactEquation(e, a, i, b);
  11334. f.copy(D.normalA, p), f.normalize(D.normalA, D.normalA), f.scale(D.contactPointB, D.normalA, -m), h(D.contactPointB, D.contactPointB, c), g(D.contactPointB, D.contactPointB, a.position), g(D.contactPointA, u, j), h(D.contactPointA, D.contactPointA, j), g(D.contactPointA, D.contactPointA, e.position), this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D))
  11335. }
  11336. return B ? 1 : 0
  11337. };
  11338. var nb = f.create(),
  11339. ob = f.create(),
  11340. pb = f.create(),
  11341. qb = new p([f.create(), f.create(), f.create(), f.create()]);
  11342. c.prototype[q.RECTANGLE | q.HEIGHTFIELD] = c.prototype[q.CONVEX | q.HEIGHTFIELD] = c.prototype.convexHeightfield = function(a, b, c, d, e, g, h, i, j) {
  11343. var k = g.data,
  11344. l = g.elementWidth,
  11345. m = nb,
  11346. n = ob,
  11347. o = pb,
  11348. p = qb,
  11349. q = Math.floor((a.aabb.lowerBound[0] - h[0]) / l),
  11350. r = Math.ceil((a.aabb.upperBound[0] - h[0]) / l);
  11351. 0 > q && (q = 0), r >= k.length && (r = k.length - 1);
  11352. for (var s = k[q], t = k[r], u = q; r > u; u++) k[u] < t && (t = k[u]), k[u] > s && (s = k[u]);
  11353. if (a.aabb.lowerBound[1] > s) return j ? !1 : 0;
  11354. for (var v = 0, u = q; r > u; u++) {
  11355. f.set(m, u * l, k[u]), f.set(n, (u + 1) * l, k[u + 1]), f.add(m, m, h), f.add(n, n, h);
  11356. var w = 100;
  11357. f.set(o, .5 * (n[0] + m[0]), .5 * (n[1] + m[1] - w)), f.sub(p.vertices[0], n, o), f.sub(p.vertices[1], m, o), f.copy(p.vertices[2], p.vertices[1]), f.copy(p.vertices[3], p.vertices[0]), p.vertices[2][1] -= w, p.vertices[3][1] -= w, v += this.convexConvex(a, b, c, d, e, p, o, 0, j)
  11358. }
  11359. return v
  11360. }
  11361. }, {
  11362. "../equations/ContactEquation": 21,
  11363. "../equations/Equation": 22,
  11364. "../equations/FrictionEquation": 23,
  11365. "../math/vec2": 30,
  11366. "../objects/Body": 31,
  11367. "../shapes/Circle": 35,
  11368. "../shapes/Convex": 36,
  11369. "../shapes/Rectangle": 41,
  11370. "../shapes/Shape": 42,
  11371. "../utils/TupleDictionary": 46,
  11372. "../utils/Utils": 47
  11373. }
  11374. ],
  11375. 13: [
  11376. function(a, b) {
  11377. function c() {
  11378. e.call(this, e.SAP), this.axisList = [], this.world = null, this.axisIndex = 0;
  11379. var a = this.axisList;
  11380. this._addBodyHandler = function(b) {
  11381. a.push(b.body)
  11382. }, this._removeBodyHandler = function(b) {
  11383. var c = a.indexOf(b.body); - 1 !== c && a.splice(c, 1)
  11384. }
  11385. }
  11386. var d = a("../utils/Utils"),
  11387. e = a("../collision/Broadphase");
  11388. b.exports = c, c.prototype = new e, c.prototype.setWorld = function(a) {
  11389. this.axisList.length = 0, d.appendArray(this.axisList, a.bodies), a.off("addBody", this._addBodyHandler).off("removeBody", this._removeBodyHandler), a.on("addBody", this._addBodyHandler).on("removeBody", this._removeBodyHandler), this.world = a
  11390. }, c.sortAxisList = function(a, b) {
  11391. b = 0 | b;
  11392. for (var c = 1, d = a.length; d > c; c++) {
  11393. for (var e = a[c], f = c - 1; f >= 0 && !(a[f].aabb.lowerBound[b] <= e.aabb.lowerBound[b]); f--) a[f + 1] = a[f];
  11394. a[f + 1] = e
  11395. }
  11396. return a
  11397. }, c.prototype.getCollisionPairs = function() {
  11398. var a = this.axisList,
  11399. b = this.result,
  11400. d = this.axisIndex;
  11401. b.length = 0;
  11402. for (var f = a.length; f--;) {
  11403. var g = a[f];
  11404. g.aabbNeedsUpdate && g.updateAABB()
  11405. }
  11406. c.sortAxisList(a, d);
  11407. for (var h = 0, i = 0 | a.length; h !== i; h++)
  11408. for (var j = a[h], k = h + 1; i > k; k++) {
  11409. var l = a[k],
  11410. m = l.aabb.lowerBound[d] <= j.aabb.upperBound[d];
  11411. if (!m) break;
  11412. e.canCollide(j, l) && this.boundingVolumeCheck(j, l) && b.push(j, l)
  11413. }
  11414. return b
  11415. }
  11416. }, {
  11417. "../collision/Broadphase": 9,
  11418. "../utils/Utils": 47
  11419. }
  11420. ],
  11421. 14: [
  11422. function(a, b) {
  11423. function c(a, b, c, e) {
  11424. this.type = c, e = d.defaults(e, {
  11425. collideConnected: !0,
  11426. wakeUpBodies: !0
  11427. }), this.equations = [], this.bodyA = a, this.bodyB = b, this.collideConnected = e.collideConnected, e.wakeUpBodies && (a && a.wakeUp(), b && b.wakeUp())
  11428. }
  11429. b.exports = c;
  11430. var d = a("../utils/Utils");
  11431. c.prototype.update = function() {
  11432. throw new Error("method update() not implmemented in this Constraint subclass!")
  11433. }, c.DISTANCE = 1, c.GEAR = 2, c.LOCK = 3, c.PRISMATIC = 4, c.REVOLUTE = 5, c.prototype.setStiffness = function(a) {
  11434. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11435. var d = b[c];
  11436. d.stiffness = a, d.needsUpdate = !0
  11437. }
  11438. }, c.prototype.setRelaxation = function(a) {
  11439. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11440. var d = b[c];
  11441. d.relaxation = a, d.needsUpdate = !0
  11442. }
  11443. }
  11444. }, {
  11445. "../utils/Utils": 47
  11446. }
  11447. ],
  11448. 15: [
  11449. function(a, b) {
  11450. function c(a, b, c, g) {
  11451. g = g || {}, d.call(this, a, b, d.DISTANCE, g), this.distance = c, this.localAnchorA = f.create(), this.localAnchorB = f.create();
  11452. var h, i = this.localAnchorA,
  11453. j = this.localAnchorB;
  11454. h = "undefined" == typeof g.maxForce ? Number.MAX_VALUE : g.maxForce;
  11455. var k = new e(a, b, -h, h);
  11456. this.equations = [k];
  11457. var l = f.create(),
  11458. m = f.create(),
  11459. n = f.create(),
  11460. o = this;
  11461. k.computeGq = function() {
  11462. {
  11463. var a = this.bodyA,
  11464. b = this.bodyB,
  11465. c = a.position;
  11466. b.position
  11467. }
  11468. return f.rotate(m, i, a.angle), f.rotate(n, j, b.angle), f.add(l, c, n), f.sub(l, l, m), f.sub(l, l, c), f.sub(l, b.position, a.position), f.length(l) - o.distance
  11469. }, this.setMaxForce(h)
  11470. }
  11471. var d = a("./Constraint"),
  11472. e = a("../equations/Equation"),
  11473. f = a("../math/vec2");
  11474. b.exports = c, c.prototype = new d;
  11475. var g = f.create(),
  11476. h = f.create(),
  11477. i = f.create();
  11478. c.prototype.update = function() {
  11479. var a = this.equations[0],
  11480. b = this.bodyA,
  11481. c = this.bodyB,
  11482. d = (this.distance, b.position, c.position, a.G);
  11483. f.rotate(h, this.localAnchorA, b.angle), f.rotate(i, this.localAnchorB, c.angle);
  11484. f.crossLength(h, g), f.crossLength(i, g);
  11485. f.sub(g, c.position, b.position), f.normalize(g, g), d[0] = -g[0], d[1] = -g[1], d[3] = g[0], d[4] = g[1]
  11486. }, c.prototype.setMaxForce = function(a) {
  11487. var b = this.equations[0];
  11488. b.minForce = -a, b.maxForce = a
  11489. }, c.prototype.getMaxForce = function() {
  11490. var a = this.equations[0];
  11491. return a.maxForce
  11492. }
  11493. }, {
  11494. "../equations/Equation": 22,
  11495. "../math/vec2": 30,
  11496. "./Constraint": 14
  11497. }
  11498. ],
  11499. 16: [
  11500. function(a, b) {
  11501. function c(a, b, c) {
  11502. c = c || {}, d.call(this, a, b, d.GEAR, c), this.equations = [new e(a, b, c)], this.angle = "number" == typeof c.angle ? c.angle : 0, this.ratio = "number" == typeof c.ratio ? c.ratio : 1, "number" == typeof c.maxTorque && this.setMaxTorque(c.maxTorque)
  11503. } {
  11504. var d = a("./Constraint"),
  11505. e = (a("../equations/Equation"), a("../equations/AngleLockEquation"));
  11506. a("../math/vec2")
  11507. }
  11508. b.exports = c, c.prototype = new d, c.prototype.update = function() {
  11509. var a = this.equations[0];
  11510. a.ratio !== this.ratio && a.setRatio(this.ratio), a.angle = this.angle
  11511. }, c.prototype.setMaxTorque = function(a) {
  11512. this.equations[0].setMaxTorque(a)
  11513. }, c.prototype.getMaxTorque = function() {
  11514. return this.equations[0].maxForce
  11515. }
  11516. }, {
  11517. "../equations/AngleLockEquation": 20,
  11518. "../equations/Equation": 22,
  11519. "../math/vec2": 30,
  11520. "./Constraint": 14
  11521. }
  11522. ],
  11523. 17: [
  11524. function(a, b) {
  11525. function c(a, b, c) {
  11526. c = c || {}, d.call(this, a, b, d.LOCK, c);
  11527. var g = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce,
  11528. h = c.localOffsetB || e.fromValues(0, 0);
  11529. h = e.fromValues(h[0], h[1]);
  11530. var i = c.localAngleB || 0,
  11531. j = new f(a, b, -g, g),
  11532. k = new f(a, b, -g, g),
  11533. l = new f(a, b, -g, g),
  11534. m = e.create(),
  11535. n = e.create(),
  11536. o = this;
  11537. j.computeGq = function() {
  11538. return e.rotate(m, o.localOffsetB, a.angle), e.sub(n, b.position, a.position), e.sub(n, n, m), n[0]
  11539. }, k.computeGq = function() {
  11540. return e.rotate(m, o.localOffsetB, a.angle), e.sub(n, b.position, a.position), e.sub(n, n, m), n[1]
  11541. };
  11542. var p = e.create(),
  11543. q = e.create();
  11544. l.computeGq = function() {
  11545. return e.rotate(p, o.localOffsetB, b.angle - o.localAngleB), e.scale(p, p, -1), e.sub(n, a.position, b.position), e.add(n, n, p), e.rotate(q, p, -Math.PI / 2), e.normalize(q, q), e.dot(n, q)
  11546. }, this.localOffsetB = h, this.localAngleB = i, this.equations.push(j, k, l), this.setMaxForce(g)
  11547. }
  11548. var d = a("./Constraint"),
  11549. e = a("../math/vec2"),
  11550. f = a("../equations/Equation");
  11551. b.exports = c, c.prototype = new d, c.prototype.setMaxForce = function(a) {
  11552. for (var b = this.equations, c = 0; c < this.equations.length; c++) b[c].maxForce = a, b[c].minForce = -a
  11553. }, c.prototype.getMaxForce = function() {
  11554. return this.equations[0].maxForce
  11555. };
  11556. var g = e.create(),
  11557. h = e.create(),
  11558. i = e.create(),
  11559. j = e.fromValues(1, 0),
  11560. k = e.fromValues(0, 1);
  11561. c.prototype.update = function() {
  11562. var a = this.equations[0],
  11563. b = this.equations[1],
  11564. c = this.equations[2],
  11565. d = this.bodyA,
  11566. f = this.bodyB;
  11567. e.rotate(g, this.localOffsetB, d.angle), e.rotate(h, this.localOffsetB, f.angle - this.localAngleB), e.scale(h, h, -1), e.rotate(i, h, Math.PI / 2), e.normalize(i, i), a.G[0] = -1, a.G[1] = 0, a.G[2] = -e.crossLength(g, j), a.G[3] = 1, b.G[0] = 0, b.G[1] = -1, b.G[2] = -e.crossLength(g, k), b.G[4] = 1, c.G[0] = -i[0], c.G[1] = -i[1], c.G[3] = i[0], c.G[4] = i[1], c.G[5] = e.crossLength(h, i)
  11568. }
  11569. }, {
  11570. "../equations/Equation": 22,
  11571. "../math/vec2": 30,
  11572. "./Constraint": 14
  11573. }
  11574. ],
  11575. 18: [
  11576. function(a, b) {
  11577. function c(a, b, c) {
  11578. c = c || {}, d.call(this, a, b, d.PRISMATIC, c);
  11579. var i = g.fromValues(0, 0),
  11580. j = g.fromValues(1, 0),
  11581. k = g.fromValues(0, 0);
  11582. c.localAnchorA && g.copy(i, c.localAnchorA), c.localAxisA && g.copy(j, c.localAxisA), c.localAnchorB && g.copy(k, c.localAnchorB), this.localAnchorA = i, this.localAnchorB = k, this.localAxisA = j;
  11583. var l = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE,
  11584. m = new f(a, b, -l, l),
  11585. n = new g.create,
  11586. o = new g.create,
  11587. p = new g.create,
  11588. q = new g.create;
  11589. if (m.computeGq = function() {
  11590. return g.dot(p, q)
  11591. }, m.updateJacobian = function() {
  11592. var c = this.G,
  11593. d = a.position,
  11594. e = b.position;
  11595. g.rotate(n, i, a.angle), g.rotate(o, k, b.angle), g.add(p, e, o), g.sub(p, p, d), g.sub(p, p, n), g.rotate(q, j, a.angle + Math.PI / 2), c[0] = -q[0], c[1] = -q[1], c[2] = -g.crossLength(n, q) + g.crossLength(q, p), c[3] = q[0], c[4] = q[1], c[5] = g.crossLength(o, q)
  11596. }, this.equations.push(m), !c.disableRotationalLock) {
  11597. var r = new h(a, b, -l, l);
  11598. this.equations.push(r)
  11599. }
  11600. this.position = 0, this.velocity = 0, this.lowerLimitEnabled = "undefined" != typeof c.lowerLimit ? !0 : !1, this.upperLimitEnabled = "undefined" != typeof c.upperLimit ? !0 : !1, this.lowerLimit = "undefined" != typeof c.lowerLimit ? c.lowerLimit : 0, this.upperLimit = "undefined" != typeof c.upperLimit ? c.upperLimit : 1, this.upperLimitEquation = new e(a, b), this.lowerLimitEquation = new e(a, b), this.upperLimitEquation.minForce = this.lowerLimitEquation.minForce = 0, this.upperLimitEquation.maxForce = this.lowerLimitEquation.maxForce = l, this.motorEquation = new f(a, b), this.motorEnabled = !1, this.motorSpeed = 0; {
  11601. var s = this,
  11602. t = this.motorEquation;
  11603. t.computeGW
  11604. }
  11605. t.computeGq = function() {
  11606. return 0
  11607. }, t.computeGW = function() {
  11608. var a = this.G,
  11609. b = this.bodyA,
  11610. c = this.bodyB,
  11611. d = b.velocity,
  11612. e = c.velocity,
  11613. f = b.angularVelocity,
  11614. g = c.angularVelocity;
  11615. return this.transformedGmult(a, d, f, e, g) + s.motorSpeed
  11616. }
  11617. }
  11618. var d = a("./Constraint"),
  11619. e = a("../equations/ContactEquation"),
  11620. f = a("../equations/Equation"),
  11621. g = a("../math/vec2"),
  11622. h = a("../equations/RotationalLockEquation");
  11623. b.exports = c, c.prototype = new d;
  11624. var i = g.create(),
  11625. j = g.create(),
  11626. k = g.create(),
  11627. l = g.create(),
  11628. m = g.create(),
  11629. n = g.create();
  11630. c.prototype.update = function() {
  11631. var a = this.equations,
  11632. b = a[0],
  11633. c = this.upperLimit,
  11634. d = this.lowerLimit,
  11635. e = this.upperLimitEquation,
  11636. f = this.lowerLimitEquation,
  11637. h = this.bodyA,
  11638. o = this.bodyB,
  11639. p = this.localAxisA,
  11640. q = this.localAnchorA,
  11641. r = this.localAnchorB;
  11642. b.updateJacobian(), g.rotate(i, p, h.angle), g.rotate(l, q, h.angle), g.add(j, l, h.position), g.rotate(m, r, o.angle), g.add(k, m, o.position);
  11643. var s = this.position = g.dot(k, i) - g.dot(j, i);
  11644. if (this.motorEnabled) {
  11645. var t = this.motorEquation.G;
  11646. t[0] = i[0], t[1] = i[1], t[2] = g.crossLength(i, m), t[3] = -i[0], t[4] = -i[1], t[5] = -g.crossLength(i, l)
  11647. }
  11648. if (this.upperLimitEnabled && s > c) g.scale(e.normalA, i, -1), g.sub(e.contactPointA, j, h.position), g.sub(e.contactPointB, k, o.position), g.scale(n, i, c), g.add(e.contactPointA, e.contactPointA, n), -1 == a.indexOf(e) && a.push(e);
  11649. else {
  11650. var u = a.indexOf(e); - 1 != u && a.splice(u, 1)
  11651. } if (this.lowerLimitEnabled && d > s) g.scale(f.normalA, i, 1), g.sub(f.contactPointA, j, h.position), g.sub(f.contactPointB, k, o.position), g.scale(n, i, d), g.sub(f.contactPointB, f.contactPointB, n), -1 == a.indexOf(f) && a.push(f);
  11652. else {
  11653. var u = a.indexOf(f); - 1 != u && a.splice(u, 1)
  11654. }
  11655. }, c.prototype.enableMotor = function() {
  11656. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  11657. }, c.prototype.disableMotor = function() {
  11658. if (this.motorEnabled) {
  11659. var a = this.equations.indexOf(this.motorEquation);
  11660. this.equations.splice(a, 1), this.motorEnabled = !1
  11661. }
  11662. }
  11663. }, {
  11664. "../equations/ContactEquation": 21,
  11665. "../equations/Equation": 22,
  11666. "../equations/RotationalLockEquation": 24,
  11667. "../math/vec2": 30,
  11668. "./Constraint": 14
  11669. }
  11670. ],
  11671. 19: [
  11672. function(a, b) {
  11673. function c(a, b, c, n, o) {
  11674. o = o || {}, d.call(this, a, c, d.REVOLUTE, o);
  11675. var p = this.maxForce = "undefined" != typeof o.maxForce ? o.maxForce : Number.MAX_VALUE;
  11676. this.pivotA = h.fromValues(b[0], b[1]), this.pivotB = h.fromValues(n[0], n[1]);
  11677. var q = this.equations = [new e(a, c, -p, p), new e(a, c, -p, p)],
  11678. r = q[0],
  11679. s = q[1],
  11680. t = this;
  11681. r.computeGq = function() {
  11682. return h.rotate(i, t.pivotA, a.angle), h.rotate(j, t.pivotB, c.angle), h.add(m, c.position, j), h.sub(m, m, a.position), h.sub(m, m, i), h.dot(m, k)
  11683. }, s.computeGq = function() {
  11684. return h.rotate(i, t.pivotA, a.angle), h.rotate(j, t.pivotB, c.angle), h.add(m, c.position, j), h.sub(m, m, a.position), h.sub(m, m, i), h.dot(m, l)
  11685. }, s.minForce = r.minForce = -p, s.maxForce = r.maxForce = p, this.motorEquation = new f(a, c), this.motorEnabled = !1, this.angle = 0, this.lowerLimitEnabled = !1, this.upperLimitEnabled = !1, this.lowerLimit = 0, this.upperLimit = 0, this.upperLimitEquation = new g(a, c), this.lowerLimitEquation = new g(a, c), this.upperLimitEquation.minForce = 0, this.lowerLimitEquation.maxForce = 0
  11686. }
  11687. var d = a("./Constraint"),
  11688. e = a("../equations/Equation"),
  11689. f = a("../equations/RotationalVelocityEquation"),
  11690. g = a("../equations/RotationalLockEquation"),
  11691. h = a("../math/vec2");
  11692. b.exports = c;
  11693. var i = h.create(),
  11694. j = h.create(),
  11695. k = h.fromValues(1, 0),
  11696. l = h.fromValues(0, 1),
  11697. m = h.create();
  11698. c.prototype = new d, c.prototype.update = function() {
  11699. var a = this.bodyA,
  11700. b = this.bodyB,
  11701. c = this.pivotA,
  11702. d = this.pivotB,
  11703. e = this.equations,
  11704. f = (e[0], e[1], e[0]),
  11705. g = e[1],
  11706. m = this.upperLimit,
  11707. n = this.lowerLimit,
  11708. o = this.upperLimitEquation,
  11709. p = this.lowerLimitEquation,
  11710. q = this.angle = b.angle - a.angle;
  11711. if (this.upperLimitEnabled && q > m) o.angle = m, -1 == e.indexOf(o) && e.push(o);
  11712. else {
  11713. var r = e.indexOf(o); - 1 != r && e.splice(r, 1)
  11714. } if (this.lowerLimitEnabled && n > q) p.angle = n, -1 == e.indexOf(p) && e.push(p);
  11715. else {
  11716. var r = e.indexOf(p); - 1 != r && e.splice(r, 1)
  11717. }
  11718. h.rotate(i, c, a.angle), h.rotate(j, d, b.angle), f.G[0] = -1, f.G[1] = 0, f.G[2] = -h.crossLength(i, k), f.G[3] = 1, f.G[4] = 0, f.G[5] = h.crossLength(j, k), g.G[0] = 0, g.G[1] = -1, g.G[2] = -h.crossLength(i, l), g.G[3] = 0, g.G[4] = 1, g.G[5] = h.crossLength(j, l)
  11719. }, c.prototype.enableMotor = function() {
  11720. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  11721. }, c.prototype.disableMotor = function() {
  11722. if (this.motorEnabled) {
  11723. var a = this.equations.indexOf(this.motorEquation);
  11724. this.equations.splice(a, 1), this.motorEnabled = !1
  11725. }
  11726. }, c.prototype.motorIsEnabled = function() {
  11727. return !!this.motorEnabled
  11728. }, c.prototype.setMotorSpeed = function(a) {
  11729. if (this.motorEnabled) {
  11730. var b = this.equations.indexOf(this.motorEquation);
  11731. this.equations[b].relativeVelocity = a
  11732. }
  11733. }, c.prototype.getMotorSpeed = function() {
  11734. return this.motorEnabled ? this.motorEquation.relativeVelocity : !1
  11735. }
  11736. }, {
  11737. "../equations/Equation": 22,
  11738. "../equations/RotationalLockEquation": 24,
  11739. "../equations/RotationalVelocityEquation": 25,
  11740. "../math/vec2": 30,
  11741. "./Constraint": 14
  11742. }
  11743. ],
  11744. 20: [
  11745. function(a, b) {
  11746. function c(a, b, c) {
  11747. c = c || {}, d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0, this.ratio = "number" == typeof c.ratio ? c.ratio : 1, this.setRatio(this.ratio)
  11748. } {
  11749. var d = a("./Equation");
  11750. a("../math/vec2")
  11751. }
  11752. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeGq = function() {
  11753. return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle
  11754. }, c.prototype.setRatio = function(a) {
  11755. var b = this.G;
  11756. b[2] = a, b[5] = -1, this.ratio = a
  11757. }, c.prototype.setMaxTorque = function(a) {
  11758. this.maxForce = a, this.minForce = -a
  11759. }
  11760. }, {
  11761. "../math/vec2": 30,
  11762. "./Equation": 22
  11763. }
  11764. ],
  11765. 21: [
  11766. function(a, b) {
  11767. function c(a, b) {
  11768. d.call(this, a, b, 0, Number.MAX_VALUE), this.contactPointA = e.create(), this.penetrationVec = e.create(), this.contactPointB = e.create(), this.normalA = e.create(), this.restitution = 0, this.firstImpact = !1, this.shapeA = null, this.shapeB = null
  11769. }
  11770. var d = a("./Equation"),
  11771. e = a("../math/vec2");
  11772. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  11773. var d = this.bodyA,
  11774. f = this.bodyB,
  11775. g = this.contactPointA,
  11776. h = this.contactPointB,
  11777. i = d.position,
  11778. j = f.position,
  11779. k = this.penetrationVec,
  11780. l = this.normalA,
  11781. m = this.G,
  11782. n = e.crossLength(g, l),
  11783. o = e.crossLength(h, l);
  11784. m[0] = -l[0], m[1] = -l[1], m[2] = -n, m[3] = l[0], m[4] = l[1], m[5] = o, e.add(k, j, h), e.sub(k, k, i), e.sub(k, k, g);
  11785. var p, q;
  11786. this.firstImpact && 0 !== this.restitution ? (q = 0, p = 1 / b * (1 + this.restitution) * this.computeGW()) : (q = e.dot(l, k), p = this.computeGW());
  11787. var r = this.computeGiMf(),
  11788. s = -q * a - p * b - c * r;
  11789. return s
  11790. }
  11791. }, {
  11792. "../math/vec2": 30,
  11793. "./Equation": 22
  11794. }
  11795. ],
  11796. 22: [
  11797. function(a, b) {
  11798. function c(a, b, d, e) {
  11799. this.minForce = "undefined" == typeof d ? -Number.MAX_VALUE : d, this.maxForce = "undefined" == typeof e ? Number.MAX_VALUE : e, this.bodyA = a, this.bodyB = b, this.stiffness = c.DEFAULT_STIFFNESS, this.relaxation = c.DEFAULT_RELAXATION, this.G = new h.ARRAY_TYPE(6);
  11800. for (var f = 0; 6 > f; f++) this.G[f] = 0;
  11801. this.offset = 0, this.a = 0, this.b = 0, this.epsilon = 0, this.timeStep = 1 / 60, this.needsUpdate = !0, this.multiplier = 0, this.relativeVelocity = 0, this.enabled = !0
  11802. }
  11803. function d(a, b, c, d, e) {
  11804. return a[0] * b[0] + a[1] * b[1] + a[2] * c + a[3] * d[0] + a[4] * d[1] + a[5] * e
  11805. }
  11806. function e(a) {
  11807. return a.sleepState === i.SLEEPING ? 0 : a.invMass
  11808. }
  11809. function f(a) {
  11810. return a.sleepState === i.SLEEPING ? 0 : a.invInertia
  11811. }
  11812. b.exports = c;
  11813. var g = a("../math/vec2"),
  11814. h = a("../utils/Utils"),
  11815. i = a("../objects/Body");
  11816. c.prototype.constructor = c, c.DEFAULT_STIFFNESS = 1e6, c.DEFAULT_RELAXATION = 4, c.prototype.update = function() {
  11817. var a = this.stiffness,
  11818. b = this.relaxation,
  11819. c = this.timeStep;
  11820. this.a = 4 / (c * (1 + 4 * b)), this.b = 4 * b / (1 + 4 * b), this.epsilon = 4 / (c * c * a * (1 + 4 * b)), this.needsUpdate = !1
  11821. }, c.prototype.computeB = function(a, b, c) {
  11822. var d = this.computeGW(),
  11823. e = this.computeGq(),
  11824. f = this.computeGiMf();
  11825. return -e * a - d * b - f * c
  11826. };
  11827. var j = g.create(),
  11828. k = g.create();
  11829. c.prototype.computeGq = function() {
  11830. var a = this.G,
  11831. b = this.bodyA,
  11832. c = this.bodyB,
  11833. e = (b.position, c.position, b.angle),
  11834. f = c.angle;
  11835. return d(a, j, e, k, f) + this.offset
  11836. }, c.prototype.computeGW = function() {
  11837. var a = this.G,
  11838. b = this.bodyA,
  11839. c = this.bodyB,
  11840. e = b.velocity,
  11841. f = c.velocity,
  11842. g = b.angularVelocity,
  11843. h = c.angularVelocity;
  11844. return d(a, e, g, f, h) + this.relativeVelocity
  11845. }, c.prototype.computeGWlambda = function() {
  11846. var a = this.G,
  11847. b = this.bodyA,
  11848. c = this.bodyB,
  11849. e = b.vlambda,
  11850. f = c.vlambda,
  11851. g = b.wlambda,
  11852. h = c.wlambda;
  11853. return d(a, e, g, f, h)
  11854. };
  11855. var l = g.create(),
  11856. m = g.create();
  11857. c.prototype.computeGiMf = function() {
  11858. var a = this.bodyA,
  11859. b = this.bodyB,
  11860. c = a.force,
  11861. h = a.angularForce,
  11862. i = b.force,
  11863. j = b.angularForce,
  11864. k = e(a),
  11865. n = e(b),
  11866. o = f(a),
  11867. p = f(b),
  11868. q = this.G;
  11869. return g.scale(l, c, k), g.scale(m, i, n), d(q, l, h * o, m, j * p)
  11870. }, c.prototype.computeGiMGt = function() {
  11871. var a = this.bodyA,
  11872. b = this.bodyB,
  11873. c = e(a),
  11874. d = e(b),
  11875. g = f(a),
  11876. h = f(b),
  11877. i = this.G;
  11878. return i[0] * i[0] * c + i[1] * i[1] * c + i[2] * i[2] * g + i[3] * i[3] * d + i[4] * i[4] * d + i[5] * i[5] * h
  11879. }; {
  11880. var n = g.create(),
  11881. o = g.create(),
  11882. p = g.create();
  11883. g.create(), g.create(), g.create()
  11884. }
  11885. c.prototype.addToWlambda = function(a) {
  11886. var b = this.bodyA,
  11887. c = this.bodyB,
  11888. d = n,
  11889. h = o,
  11890. i = p,
  11891. j = e(b),
  11892. k = e(c),
  11893. l = f(b),
  11894. m = f(c),
  11895. q = this.G;
  11896. h[0] = q[0], h[1] = q[1], i[0] = q[3], i[1] = q[4], g.scale(d, h, j * a), g.add(b.vlambda, b.vlambda, d), b.wlambda += l * q[2] * a, g.scale(d, i, k * a), g.add(c.vlambda, c.vlambda, d), c.wlambda += m * q[5] * a
  11897. }, c.prototype.computeInvC = function(a) {
  11898. return 1 / (this.computeGiMGt() + a)
  11899. }
  11900. }, {
  11901. "../math/vec2": 30,
  11902. "../objects/Body": 31,
  11903. "../utils/Utils": 47
  11904. }
  11905. ],
  11906. 23: [
  11907. function(a, b) {
  11908. function c(a, b, c) {
  11909. e.call(this, a, b, -c, c), this.contactPointA = d.create(), this.contactPointB = d.create(), this.t = d.create(), this.contactEquation = null, this.shapeA = null, this.shapeB = null, this.frictionCoefficient = .3
  11910. } {
  11911. var d = a("../math/vec2"),
  11912. e = a("./Equation");
  11913. a("../utils/Utils")
  11914. }
  11915. b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setSlipForce = function(a) {
  11916. this.maxForce = a, this.minForce = -a
  11917. }, c.prototype.getSlipForce = function() {
  11918. return this.maxForce
  11919. }, c.prototype.computeB = function(a, b, c) {
  11920. var e = (this.bodyA, this.bodyB, this.contactPointA),
  11921. f = this.contactPointB,
  11922. g = this.t,
  11923. h = this.G;
  11924. h[0] = -g[0], h[1] = -g[1], h[2] = -d.crossLength(e, g), h[3] = g[0], h[4] = g[1], h[5] = d.crossLength(f, g);
  11925. var i = this.computeGW(),
  11926. j = this.computeGiMf(),
  11927. k = -i * b - c * j;
  11928. return k
  11929. }
  11930. }, {
  11931. "../math/vec2": 30,
  11932. "../utils/Utils": 47,
  11933. "./Equation": 22
  11934. }
  11935. ],
  11936. 24: [
  11937. function(a, b) {
  11938. function c(a, b, c) {
  11939. c = c || {}, d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0;
  11940. var e = this.G;
  11941. e[2] = 1, e[5] = -1
  11942. }
  11943. var d = a("./Equation"),
  11944. e = a("../math/vec2");
  11945. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  11946. var f = e.create(),
  11947. g = e.create(),
  11948. h = e.fromValues(1, 0),
  11949. i = e.fromValues(0, 1);
  11950. c.prototype.computeGq = function() {
  11951. return e.rotate(f, h, this.bodyA.angle + this.angle), e.rotate(g, i, this.bodyB.angle), e.dot(f, g)
  11952. }
  11953. }, {
  11954. "../math/vec2": 30,
  11955. "./Equation": 22
  11956. }
  11957. ],
  11958. 25: [
  11959. function(a, b) {
  11960. function c(a, b) {
  11961. d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1
  11962. } {
  11963. var d = a("./Equation");
  11964. a("../math/vec2")
  11965. }
  11966. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  11967. var d = this.G;
  11968. d[2] = -1, d[5] = this.ratio;
  11969. var e = this.computeGiMf(),
  11970. f = this.computeGW(),
  11971. g = -f * b - c * e;
  11972. return g
  11973. }
  11974. }, {
  11975. "../math/vec2": 30,
  11976. "./Equation": 22
  11977. }
  11978. ],
  11979. 26: [
  11980. function(a, b) {
  11981. var c = function() {};
  11982. b.exports = c, c.prototype = {
  11983. constructor: c,
  11984. on: function(a, b, c) {
  11985. b.context = c || this, void 0 === this._listeners && (this._listeners = {});
  11986. var d = this._listeners;
  11987. return void 0 === d[a] && (d[a] = []), -1 === d[a].indexOf(b) && d[a].push(b), this
  11988. },
  11989. has: function(a, b) {
  11990. if (void 0 === this._listeners) return !1;
  11991. var c = this._listeners;
  11992. if (b) {
  11993. if (void 0 !== c[a] && -1 !== c[a].indexOf(b)) return !0
  11994. } else if (void 0 !== c[a]) return !0;
  11995. return !1
  11996. },
  11997. off: function(a, b) {
  11998. if (void 0 === this._listeners) return this;
  11999. var c = this._listeners,
  12000. d = c[a].indexOf(b);
  12001. return -1 !== d && c[a].splice(d, 1), this
  12002. },
  12003. emit: function(a) {
  12004. if (void 0 === this._listeners) return this;
  12005. var b = this._listeners,
  12006. c = b[a.type];
  12007. if (void 0 !== c) {
  12008. a.target = this;
  12009. for (var d = 0, e = c.length; e > d; d++) {
  12010. var f = c[d];
  12011. f.call(f.context, a)
  12012. }
  12013. }
  12014. return this
  12015. }
  12016. }
  12017. }, {}
  12018. ],
  12019. 27: [
  12020. function(a, b) {
  12021. function c(a, b, f) {
  12022. if (f = f || {}, !(a instanceof d && b instanceof d)) throw new Error("First two arguments must be Material instances.");
  12023. this.id = c.idCounter++, this.materialA = a, this.materialB = b, this.friction = "undefined" != typeof f.friction ? Number(f.friction) : .3, this.restitution = "undefined" != typeof f.restitution ? Number(f.restitution) : 0, this.stiffness = "undefined" != typeof f.stiffness ? Number(f.stiffness) : e.DEFAULT_STIFFNESS, this.relaxation = "undefined" != typeof f.relaxation ? Number(f.relaxation) : e.DEFAULT_RELAXATION, this.frictionStiffness = "undefined" != typeof f.frictionStiffness ? Number(f.frictionStiffness) : e.DEFAULT_STIFFNESS, this.frictionRelaxation = "undefined" != typeof f.frictionRelaxation ? Number(f.frictionRelaxation) : e.DEFAULT_RELAXATION, this.surfaceVelocity = "undefined" != typeof f.surfaceVelocity ? Number(f.surfaceVelocity) : 0
  12024. }
  12025. var d = a("./Material"),
  12026. e = a("../equations/Equation");
  12027. b.exports = c, c.idCounter = 0
  12028. }, {
  12029. "../equations/Equation": 22,
  12030. "./Material": 28
  12031. }
  12032. ],
  12033. 28: [
  12034. function(a, b) {
  12035. function c() {
  12036. this.id = c.idCounter++
  12037. }
  12038. b.exports = c, c.idCounter = 0
  12039. }, {}
  12040. ],
  12041. 29: [
  12042. function(a, b) {
  12043. var c = {};
  12044. c.GetArea = function(a) {
  12045. if (a.length < 6) return 0;
  12046. for (var b = a.length - 2, c = 0, d = 0; b > d; d += 2) c += (a[d + 2] - a[d]) * (a[d + 1] + a[d + 3]);
  12047. return c += (a[0] - a[b]) * (a[b + 1] + a[1]), .5 * -c
  12048. }, c.Triangulate = function(a) {
  12049. var b = a.length >> 1;
  12050. if (3 > b) return [];
  12051. for (var d = [], e = [], f = 0; b > f; f++) e.push(f);
  12052. for (var f = 0, g = b; g > 3;) {
  12053. var h = e[(f + 0) % g],
  12054. i = e[(f + 1) % g],
  12055. j = e[(f + 2) % g],
  12056. k = a[2 * h],
  12057. l = a[2 * h + 1],
  12058. m = a[2 * i],
  12059. n = a[2 * i + 1],
  12060. o = a[2 * j],
  12061. p = a[2 * j + 1],
  12062. q = !1;
  12063. if (c._convex(k, l, m, n, o, p)) {
  12064. q = !0;
  12065. for (var r = 0; g > r; r++) {
  12066. var s = e[r];
  12067. if (s != h && s != i && s != j && c._PointInTriangle(a[2 * s], a[2 * s + 1], k, l, m, n, o, p)) {
  12068. q = !1;
  12069. break
  12070. }
  12071. }
  12072. }
  12073. if (q) d.push(h, i, j), e.splice((f + 1) % g, 1), g--, f = 0;
  12074. else if (f++ > 3 * g) break
  12075. }
  12076. return d.push(e[0], e[1], e[2]), d
  12077. }, c._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  12078. var i = g - c,
  12079. j = h - d,
  12080. k = e - c,
  12081. l = f - d,
  12082. m = a - c,
  12083. n = b - d,
  12084. o = i * i + j * j,
  12085. p = i * k + j * l,
  12086. q = i * m + j * n,
  12087. r = k * k + l * l,
  12088. s = k * m + l * n,
  12089. t = 1 / (o * r - p * p),
  12090. u = (r * q - p * s) * t,
  12091. v = (o * s - p * q) * t;
  12092. return u >= 0 && v >= 0 && 1 > u + v
  12093. }, c._convex = function(a, b, c, d, e, f) {
  12094. return (b - d) * (e - c) + (c - a) * (f - d) >= 0
  12095. }, b.exports = c
  12096. }, {}
  12097. ],
  12098. 30: [
  12099. function(a, b) {
  12100. var c = a("../../build/vec2").vec2;
  12101. c.crossLength = function(a, b) {
  12102. return a[0] * b[1] - a[1] * b[0]
  12103. }, c.crossVZ = function(a, b, d) {
  12104. return c.rotate(a, b, -Math.PI / 2), c.scale(a, a, d), a
  12105. }, c.crossZV = function(a, b, d) {
  12106. return c.rotate(a, d, Math.PI / 2), c.scale(a, a, b), a
  12107. }, c.rotate = function(a, b, c) {
  12108. var d = Math.cos(c),
  12109. e = Math.sin(c),
  12110. f = b[0],
  12111. g = b[1];
  12112. a[0] = d * f - e * g, a[1] = e * f + d * g
  12113. }, c.rotate90cw = function(a, b) {
  12114. a[0] = b[1], a[1] = -b[0]
  12115. }, c.toLocalFrame = function(a, b, d, e) {
  12116. c.copy(a, b), c.sub(a, a, d), c.rotate(a, a, -e)
  12117. }, c.toGlobalFrame = function(a, b, d, e) {
  12118. c.copy(a, b), c.rotate(a, a, e), c.add(a, a, d)
  12119. }, c.centroid = function(a, b, d, e) {
  12120. return c.add(a, b, d), c.add(a, a, e), c.scale(a, a, 1 / 3), a
  12121. }, b.exports = c
  12122. }, {
  12123. "../../build/vec2": 1
  12124. }
  12125. ],
  12126. 31: [
  12127. function(a, b) {
  12128. function c(a) {
  12129. a = a || {}, h.call(this), this.id = ++c._idCounter, this.world = null, this.shapes = [], this.shapeOffsets = [], this.shapeAngles = [], this.mass = a.mass || 0, this.invMass = 0, this.inertia = 0, this.invInertia = 0, this.fixedRotation = !!a.fixedRotation || !1, this.position = d.fromValues(0, 0), a.position && d.copy(this.position, a.position), this.interpolatedPosition = d.fromValues(0, 0), this.interpolatedAngle = 0, this.previousPosition = d.fromValues(0, 0), this.previousAngle = 0, this.velocity = d.fromValues(0, 0), a.velocity && d.copy(this.velocity, a.velocity), this.vlambda = d.fromValues(0, 0), this.wlambda = 0, this.angle = a.angle || 0, this.angularVelocity = a.angularVelocity || 0, this.force = d.create(), a.force && d.copy(this.force, a.force), this.angularForce = a.angularForce || 0, this.damping = "number" == typeof a.damping ? a.damping : .1, this.angularDamping = "number" == typeof a.angularDamping ? a.angularDamping : .1, this.motionState = 0 === this.mass ? c.STATIC : c.DYNAMIC, this.boundingRadius = 0, this.aabb = new g, this.aabbNeedsUpdate = !0, this.allowSleep = !0, this.wantsToSleep = !1, this.sleepState = c.AWAKE, this.sleepSpeedLimit = .2, this.sleepTimeLimit = 1, this.gravityScale = 1, this.timeLastSleepy = 0, this.concavePath = null, this.lastDampingScale = 1, this.lastAngularDampingScale = 1, this.lastDampingTimeStep = -1, this._wakeUpAfterNarrowphase = !1, this.updateMassProperties()
  12130. }
  12131. var d = a("../math/vec2"),
  12132. e = a("poly-decomp"),
  12133. f = a("../shapes/Convex"),
  12134. g = a("../collision/AABB"),
  12135. h = a("../events/EventEmitter");
  12136. b.exports = c, c.prototype = new h, c._idCounter = 0, c.prototype.setDensity = function(a) {
  12137. var b = this.getArea();
  12138. this.mass = b * a, this.updateMassProperties()
  12139. }, c.prototype.getArea = function() {
  12140. for (var a = 0, b = 0; b < this.shapes.length; b++) a += this.shapes[b].area;
  12141. return a
  12142. };
  12143. var i = new g,
  12144. j = d.create();
  12145. c.prototype.updateAABB = function() {
  12146. for (var a = this.shapes, b = this.shapeOffsets, c = this.shapeAngles, e = a.length, f = 0; f !== e; f++) {
  12147. var g = a[f],
  12148. h = j,
  12149. k = c[f] + this.angle;
  12150. d.rotate(h, b[f], this.angle), d.add(h, h, this.position), g.computeAABB(i, h, k), 0 === f ? this.aabb.copy(i) : this.aabb.extend(i)
  12151. }
  12152. this.aabbNeedsUpdate = !1
  12153. }, c.prototype.updateBoundingRadius = function() {
  12154. for (var a = this.shapes, b = this.shapeOffsets, c = a.length, e = 0, f = 0; f !== c; f++) {
  12155. var g = a[f],
  12156. h = d.length(b[f]),
  12157. i = g.boundingRadius;
  12158. h + i > e && (e = h + i)
  12159. }
  12160. this.boundingRadius = e
  12161. }, c.prototype.addShape = function(a, b, c) {
  12162. c = c || 0, b = b ? d.fromValues(b[0], b[1]) : d.fromValues(0, 0), this.shapes.push(a), this.shapeOffsets.push(b), this.shapeAngles.push(c), this.updateMassProperties(), this.updateBoundingRadius(), this.aabbNeedsUpdate = !0
  12163. }, c.prototype.removeShape = function(a) {
  12164. var b = this.shapes.indexOf(a);
  12165. return -1 !== b ? (this.shapes.splice(b, 1), this.shapeOffsets.splice(b, 1), this.shapeAngles.splice(b, 1), this.aabbNeedsUpdate = !0, !0) : !1
  12166. }, c.prototype.updateMassProperties = function() {
  12167. if (this.motionState === c.STATIC || this.motionState === c.KINEMATIC) this.mass = Number.MAX_VALUE, this.invMass = 0, this.inertia = Number.MAX_VALUE, this.invInertia = 0;
  12168. else {
  12169. var a = this.shapes,
  12170. b = a.length,
  12171. e = this.mass / b,
  12172. f = 0;
  12173. if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0;
  12174. else {
  12175. for (var g = 0; b > g; g++) {
  12176. var h = a[g],
  12177. i = d.squaredLength(this.shapeOffsets[g]),
  12178. j = h.computeMomentOfInertia(e);
  12179. f += j + e * i
  12180. }
  12181. this.inertia = f, this.invInertia = f > 0 ? 1 / f : 0
  12182. }
  12183. this.invMass = 1 / this.mass
  12184. }
  12185. };
  12186. var k = d.create();
  12187. c.prototype.applyForce = function(a, b) {
  12188. var c = k;
  12189. d.sub(c, b, this.position), d.add(this.force, this.force, a);
  12190. var e = d.crossLength(c, a);
  12191. this.angularForce += e
  12192. }, c.prototype.toLocalFrame = function(a, b) {
  12193. d.toLocalFrame(a, b, this.position, this.angle)
  12194. }, c.prototype.toWorldFrame = function(a, b) {
  12195. d.toGlobalFrame(a, b, this.position, this.angle)
  12196. }, c.prototype.fromPolygon = function(a, b) {
  12197. b = b || {};
  12198. for (var c = this.shapes.length; c >= 0; --c) this.removeShape(this.shapes[c]);
  12199. var g = new e.Polygon;
  12200. if (g.vertices = a, g.makeCCW(), "number" == typeof b.removeCollinearPoints && g.removeCollinearPoints(b.removeCollinearPoints), "undefined" == typeof b.skipSimpleCheck && !g.isSimple()) return !1;
  12201. this.concavePath = g.vertices.slice(0);
  12202. for (var c = 0; c < this.concavePath.length; c++) {
  12203. var h = [0, 0];
  12204. d.copy(h, this.concavePath[c]), this.concavePath[c] = h
  12205. }
  12206. var i;
  12207. i = b.optimalDecomp ? g.decomp() : g.quickDecomp();
  12208. for (var j = d.create(), c = 0; c !== i.length; c++) {
  12209. for (var k = new f(i[c].vertices), l = 0; l !== k.vertices.length; l++) {
  12210. var h = k.vertices[l];
  12211. d.sub(h, h, k.centerOfMass)
  12212. }
  12213. d.scale(j, k.centerOfMass, 1), k.updateTriangles(), k.updateCenterOfMass(), k.updateBoundingRadius(), this.addShape(k, j)
  12214. }
  12215. return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0
  12216. };
  12217. var l = (d.fromValues(0, 0), d.fromValues(0, 0)),
  12218. m = d.fromValues(0, 0),
  12219. n = d.fromValues(0, 0);
  12220. c.prototype.adjustCenterOfMass = function() {
  12221. var a = l,
  12222. b = m,
  12223. c = n,
  12224. e = 0;
  12225. d.set(b, 0, 0);
  12226. for (var f = 0; f !== this.shapes.length; f++) {
  12227. var g = this.shapes[f],
  12228. h = this.shapeOffsets[f];
  12229. d.scale(a, h, g.area), d.add(b, b, a), e += g.area
  12230. }
  12231. d.scale(c, b, 1 / e);
  12232. for (var f = 0; f !== this.shapes.length; f++) {
  12233. var g = this.shapes[f],
  12234. h = this.shapeOffsets[f];
  12235. h || (h = this.shapeOffsets[f] = d.create()), d.sub(h, h, c)
  12236. }
  12237. d.add(this.position, this.position, c);
  12238. for (var f = 0; this.concavePath && f < this.concavePath.length; f++) d.sub(this.concavePath[f], this.concavePath[f], c);
  12239. this.updateMassProperties(), this.updateBoundingRadius()
  12240. }, c.prototype.setZeroForce = function() {
  12241. d.set(this.force, 0, 0), this.angularForce = 0
  12242. }, c.prototype.resetConstraintVelocity = function() {
  12243. var a = this,
  12244. b = a.vlambda;
  12245. d.set(b, 0, 0), a.wlambda = 0
  12246. }, c.prototype.addConstraintVelocity = function() {
  12247. var a = this,
  12248. b = a.velocity;
  12249. d.add(b, b, a.vlambda), a.angularVelocity += a.wlambda
  12250. }, c.prototype.applyDamping = function(a) {
  12251. if (this.motionState === c.DYNAMIC) {
  12252. a !== this.lastDampingTimeStep && (this.lastDampingScale = Math.pow(1 - this.damping, a), this.lastAngularDampingScale = Math.pow(1 - this.angularDamping, a), this.lastDampingTimeStep = a);
  12253. var b = this.velocity;
  12254. d.scale(b, b, this.lastDampingScale), this.angularVelocity *= this.lastAngularDampingScale
  12255. }
  12256. }, c.prototype.wakeUp = function() {
  12257. var a = this.sleepState;
  12258. this.sleepState = c.AWAKE, this.idleTime = 0, a !== c.AWAKE && this.emit(c.wakeUpEvent)
  12259. }, c.prototype.sleep = function() {
  12260. this.sleepState = c.SLEEPING, this.angularVelocity = 0, this.angularForce = 0, d.set(this.velocity, 0, 0), d.set(this.force, 0, 0), this.emit(c.sleepEvent)
  12261. }, c.prototype.sleepTick = function(a, b, e) {
  12262. if (this.allowSleep && this.motionState !== c.SLEEPING) {
  12263. this.wantsToSleep = !1;
  12264. var f = (this.sleepState, d.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2)),
  12265. g = Math.pow(this.sleepSpeedLimit, 2);
  12266. f >= g ? (this.idleTime = 0, this.sleepState = c.AWAKE) : (this.idleTime += e, this.sleepState = c.SLEEPY), this.idleTime > this.sleepTimeLimit && (b ? this.wantsToSleep = !0 : this.sleep())
  12267. }
  12268. }, c.prototype.getVelocityFromPosition = function(a, b) {
  12269. return a = a || d.create(), d.sub(a, this.position, this.previousPosition), d.scale(a, a, 1 / b), a
  12270. }, c.prototype.getAngularVelocityFromPosition = function(a) {
  12271. return (this.angle - this.previousAngle) / a
  12272. }, c.sleepyEvent = {
  12273. type: "sleepy"
  12274. }, c.sleepEvent = {
  12275. type: "sleep"
  12276. }, c.wakeUpEvent = {
  12277. type: "wakeup"
  12278. }, c.DYNAMIC = 1, c.STATIC = 2, c.KINEMATIC = 4, c.AWAKE = 0, c.SLEEPY = 1, c.SLEEPING = 2
  12279. }, {
  12280. "../collision/AABB": 8,
  12281. "../events/EventEmitter": 26,
  12282. "../math/vec2": 30,
  12283. "../shapes/Convex": 36,
  12284. "poly-decomp": 6
  12285. }
  12286. ],
  12287. 32: [
  12288. function(a, b) {
  12289. function c(a, b, c) {
  12290. c = e.defaults(c, {
  12291. restLength: 1,
  12292. stiffness: 100,
  12293. damping: 1,
  12294. localAnchorA: [0, 0],
  12295. localAnchorB: [0, 0]
  12296. }), this.restLength = c.restLength, this.stiffness = c.stiffness, this.damping = c.damping, this.bodyA = a, this.bodyB = b, this.localAnchorA = d.create(), d.copy(this.localAnchorA, c.localAnchorA), this.localAnchorB = d.create(), d.copy(this.localAnchorB, c.localAnchorB), c.worldAnchorA && this.setWorldAnchorA(c.worldAnchorA), c.worldAnchorB && this.setWorldAnchorB(c.worldAnchorB)
  12297. }
  12298. var d = a("../math/vec2"),
  12299. e = a("../utils/Utils");
  12300. b.exports = c, c.prototype.setWorldAnchorA = function(a) {
  12301. this.bodyA.toLocalFrame(this.localAnchorA, a)
  12302. }, c.prototype.setWorldAnchorB = function(a) {
  12303. this.bodyB.toLocalFrame(this.localAnchorB, a)
  12304. }, c.prototype.getWorldAnchorA = function(a) {
  12305. this.bodyA.toWorldFrame(a, this.localAnchorA)
  12306. }, c.prototype.getWorldAnchorB = function(a) {
  12307. this.bodyB.toWorldFrame(a, this.localAnchorB)
  12308. };
  12309. var f = d.create(),
  12310. g = d.create(),
  12311. h = d.create(),
  12312. i = d.create(),
  12313. j = d.create(),
  12314. k = d.create(),
  12315. l = d.create(),
  12316. m = d.create(),
  12317. n = d.create();
  12318. c.prototype.applyForce = function() {
  12319. var a = this.stiffness,
  12320. b = this.damping,
  12321. c = this.restLength,
  12322. e = this.bodyA,
  12323. o = this.bodyB,
  12324. p = f,
  12325. q = g,
  12326. r = h,
  12327. s = i,
  12328. t = n,
  12329. u = j,
  12330. v = k,
  12331. w = l,
  12332. x = m;
  12333. this.getWorldAnchorA(u), this.getWorldAnchorB(v), d.sub(w, u, e.position), d.sub(x, v, o.position), d.sub(p, v, u);
  12334. var y = d.len(p);
  12335. d.normalize(q, p), d.sub(r, o.velocity, e.velocity), d.crossZV(t, o.angularVelocity, x), d.add(r, r, t), d.crossZV(t, e.angularVelocity, w), d.sub(r, r, t), d.scale(s, q, -a * (y - c) - b * d.dot(r, q)), d.sub(e.force, e.force, s), d.add(o.force, o.force, s);
  12336. var z = d.crossLength(w, s),
  12337. A = d.crossLength(x, s);
  12338. e.angularForce -= z, o.angularForce += A
  12339. }
  12340. }, {
  12341. "../math/vec2": 30,
  12342. "../utils/Utils": 47
  12343. }
  12344. ],
  12345. 33: [
  12346. function(a, b) {
  12347. b.exports = {
  12348. AABB: a("./collision/AABB"),
  12349. AngleLockEquation: a("./equations/AngleLockEquation"),
  12350. Body: a("./objects/Body"),
  12351. Broadphase: a("./collision/Broadphase"),
  12352. Capsule: a("./shapes/Capsule"),
  12353. Circle: a("./shapes/Circle"),
  12354. Constraint: a("./constraints/Constraint"),
  12355. ContactEquation: a("./equations/ContactEquation"),
  12356. ContactMaterial: a("./material/ContactMaterial"),
  12357. Convex: a("./shapes/Convex"),
  12358. DistanceConstraint: a("./constraints/DistanceConstraint"),
  12359. Equation: a("./equations/Equation"),
  12360. EventEmitter: a("./events/EventEmitter"),
  12361. FrictionEquation: a("./equations/FrictionEquation"),
  12362. GearConstraint: a("./constraints/GearConstraint"),
  12363. GridBroadphase: a("./collision/GridBroadphase"),
  12364. GSSolver: a("./solver/GSSolver"),
  12365. Heightfield: a("./shapes/Heightfield"),
  12366. Line: a("./shapes/Line"),
  12367. LockConstraint: a("./constraints/LockConstraint"),
  12368. Material: a("./material/Material"),
  12369. Narrowphase: a("./collision/Narrowphase"),
  12370. NaiveBroadphase: a("./collision/NaiveBroadphase"),
  12371. Particle: a("./shapes/Particle"),
  12372. Plane: a("./shapes/Plane"),
  12373. RevoluteConstraint: a("./constraints/RevoluteConstraint"),
  12374. PrismaticConstraint: a("./constraints/PrismaticConstraint"),
  12375. Rectangle: a("./shapes/Rectangle"),
  12376. RotationalVelocityEquation: a("./equations/RotationalVelocityEquation"),
  12377. SAPBroadphase: a("./collision/SAPBroadphase"),
  12378. Shape: a("./shapes/Shape"),
  12379. Solver: a("./solver/Solver"),
  12380. Spring: a("./objects/Spring"),
  12381. Utils: a("./utils/Utils"),
  12382. World: a("./world/World"),
  12383. vec2: a("./math/vec2"),
  12384. version: a("../package.json").version
  12385. }
  12386. }, {
  12387. "../package.json": 7,
  12388. "./collision/AABB": 8,
  12389. "./collision/Broadphase": 9,
  12390. "./collision/GridBroadphase": 10,
  12391. "./collision/NaiveBroadphase": 11,
  12392. "./collision/Narrowphase": 12,
  12393. "./collision/SAPBroadphase": 13,
  12394. "./constraints/Constraint": 14,
  12395. "./constraints/DistanceConstraint": 15,
  12396. "./constraints/GearConstraint": 16,
  12397. "./constraints/LockConstraint": 17,
  12398. "./constraints/PrismaticConstraint": 18,
  12399. "./constraints/RevoluteConstraint": 19,
  12400. "./equations/AngleLockEquation": 20,
  12401. "./equations/ContactEquation": 21,
  12402. "./equations/Equation": 22,
  12403. "./equations/FrictionEquation": 23,
  12404. "./equations/RotationalVelocityEquation": 25,
  12405. "./events/EventEmitter": 26,
  12406. "./material/ContactMaterial": 27,
  12407. "./material/Material": 28,
  12408. "./math/vec2": 30,
  12409. "./objects/Body": 31,
  12410. "./objects/Spring": 32,
  12411. "./shapes/Capsule": 34,
  12412. "./shapes/Circle": 35,
  12413. "./shapes/Convex": 36,
  12414. "./shapes/Heightfield": 37,
  12415. "./shapes/Line": 38,
  12416. "./shapes/Particle": 39,
  12417. "./shapes/Plane": 40,
  12418. "./shapes/Rectangle": 41,
  12419. "./shapes/Shape": 42,
  12420. "./solver/GSSolver": 43,
  12421. "./solver/Solver": 44,
  12422. "./utils/Utils": 47,
  12423. "./world/World": 51
  12424. }
  12425. ],
  12426. 34: [
  12427. function(a, b) {
  12428. function c(a, b) {
  12429. this.length = a || 1, this.radius = b || 1, d.call(this, d.CAPSULE)
  12430. }
  12431. var d = a("./Shape"),
  12432. e = a("../math/vec2");
  12433. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  12434. var b = this.radius,
  12435. c = this.length + b,
  12436. d = 2 * b;
  12437. return a * (d * d + c * c) / 12
  12438. }, c.prototype.updateBoundingRadius = function() {
  12439. this.boundingRadius = this.radius + this.length / 2
  12440. }, c.prototype.updateArea = function() {
  12441. this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length
  12442. };
  12443. var f = e.create();
  12444. c.prototype.computeAABB = function(a, b, c) {
  12445. var d = this.radius;
  12446. e.set(f, this.length, 0), e.rotate(f, f, c), e.set(a.upperBound, Math.max(f[0] + d, -f[0] + d), Math.max(f[1] + d, -f[1] + d)), e.set(a.lowerBound, Math.min(f[0] - d, -f[0] - d), Math.min(f[1] - d, -f[1] - d)), e.add(a.lowerBound, a.lowerBound, b), e.add(a.upperBound, a.upperBound, b)
  12447. }
  12448. }, {
  12449. "../math/vec2": 30,
  12450. "./Shape": 42
  12451. }
  12452. ],
  12453. 35: [
  12454. function(a, b) {
  12455. function c(a) {
  12456. this.radius = a || 1, d.call(this, d.CIRCLE)
  12457. }
  12458. var d = a("./Shape"),
  12459. e = a("../math/vec2");
  12460. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  12461. var b = this.radius;
  12462. return a * b * b / 2
  12463. }, c.prototype.updateBoundingRadius = function() {
  12464. this.boundingRadius = this.radius
  12465. }, c.prototype.updateArea = function() {
  12466. this.area = Math.PI * this.radius * this.radius
  12467. }, c.prototype.computeAABB = function(a, b) {
  12468. var c = this.radius;
  12469. e.set(a.upperBound, c, c), e.set(a.lowerBound, -c, -c), b && (e.add(a.lowerBound, a.lowerBound, b), e.add(a.upperBound, a.upperBound, b))
  12470. }
  12471. }, {
  12472. "../math/vec2": 30,
  12473. "./Shape": 42
  12474. }
  12475. ],
  12476. 36: [
  12477. function(a, b) {
  12478. function c(a) {
  12479. this.vertices = [];
  12480. for (var b = 0; b < a.length; b++) {
  12481. var c = e.create();
  12482. e.copy(c, a[b]), this.vertices.push(c)
  12483. }
  12484. if (this.centerOfMass = e.fromValues(0, 0), this.triangles = [], this.vertices.length && (this.updateTriangles(), this.updateCenterOfMass()), this.boundingRadius = 0, d.call(this, d.CONVEX), this.updateBoundingRadius(), this.updateArea(), this.area < 0) throw new Error("Convex vertices must be given in conter-clockwise winding.")
  12485. } {
  12486. var d = a("./Shape"),
  12487. e = a("../math/vec2"),
  12488. f = a("../math/polyk");
  12489. a("poly-decomp")
  12490. }
  12491. b.exports = c, c.prototype = new d, c.prototype.updateTriangles = function() {
  12492. this.triangles.length = 0;
  12493. for (var a = [], b = 0; b < this.vertices.length; b++) {
  12494. var c = this.vertices[b];
  12495. a.push(c[0], c[1])
  12496. }
  12497. for (var d = f.Triangulate(a), b = 0; b < d.length; b += 3) {
  12498. var e = d[b],
  12499. g = d[b + 1],
  12500. h = d[b + 2];
  12501. this.triangles.push([e, g, h])
  12502. }
  12503. }; {
  12504. var g = e.create(),
  12505. h = e.create(),
  12506. i = e.create(),
  12507. j = e.create(),
  12508. k = e.create();
  12509. e.create(), e.create(), e.create(), e.create()
  12510. }
  12511. c.prototype.updateCenterOfMass = function() {
  12512. var a = this.triangles,
  12513. b = this.vertices,
  12514. d = this.centerOfMass,
  12515. f = g,
  12516. l = i,
  12517. m = j,
  12518. n = k,
  12519. o = h;
  12520. e.set(d, 0, 0);
  12521. for (var p = 0, q = 0; q !== a.length; q++) {
  12522. var r = a[q],
  12523. l = b[r[0]],
  12524. m = b[r[1]],
  12525. n = b[r[2]];
  12526. e.centroid(f, l, m, n);
  12527. var s = c.triangleArea(l, m, n);
  12528. p += s, e.scale(o, f, s), e.add(d, d, o)
  12529. }
  12530. e.scale(d, d, 1 / p)
  12531. }, c.prototype.computeMomentOfInertia = function(a) {
  12532. for (var b = 0, c = 0, d = this.vertices.length, f = d - 1, g = 0; d > g; f = g, g++) {
  12533. var h = this.vertices[f],
  12534. i = this.vertices[g],
  12535. j = Math.abs(e.crossLength(h, i)),
  12536. k = e.dot(i, i) + e.dot(i, h) + e.dot(h, h);
  12537. b += j * k, c += j
  12538. }
  12539. return a / 6 * (b / c)
  12540. }, c.prototype.updateBoundingRadius = function() {
  12541. for (var a = this.vertices, b = 0, c = 0; c !== a.length; c++) {
  12542. var d = e.squaredLength(a[c]);
  12543. d > b && (b = d)
  12544. }
  12545. this.boundingRadius = Math.sqrt(b)
  12546. }, c.triangleArea = function(a, b, c) {
  12547. return .5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]))
  12548. }, c.prototype.updateArea = function() {
  12549. this.updateTriangles(), this.area = 0;
  12550. for (var a = this.triangles, b = this.vertices, d = 0; d !== a.length; d++) {
  12551. var e = a[d],
  12552. f = b[e[0]],
  12553. g = b[e[1]],
  12554. h = b[e[2]],
  12555. i = c.triangleArea(f, g, h);
  12556. this.area += i
  12557. }
  12558. }, c.prototype.computeAABB = function(a, b, c) {
  12559. a.setFromPoints(this.vertices, b, c)
  12560. }
  12561. }, {
  12562. "../math/polyk": 29,
  12563. "../math/vec2": 30,
  12564. "./Shape": 42,
  12565. "poly-decomp": 6
  12566. }
  12567. ],
  12568. 37: [
  12569. function(a, b) {
  12570. function c(a, b) {
  12571. if (b = e.defaults(b, {
  12572. maxValue: null,
  12573. minValue: null,
  12574. elementWidth: .1
  12575. }), null === b.minValue || null === b.maxValue) {
  12576. b.maxValue = a[0], b.minValue = a[0];
  12577. for (var c = 0; c !== a.length; c++) {
  12578. var f = a[c];
  12579. f > b.maxValue && (b.maxValue = f), f < b.minValue && (b.minValue = f)
  12580. }
  12581. }
  12582. this.data = a, this.maxValue = b.maxValue, this.minValue = b.minValue, this.elementWidth = b.elementWidth, d.call(this, d.HEIGHTFIELD)
  12583. }
  12584. var d = a("./Shape"),
  12585. e = (a("../math/vec2"), a("../utils/Utils"));
  12586. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  12587. return Number.MAX_VALUE
  12588. }, c.prototype.updateBoundingRadius = function() {
  12589. this.boundingRadius = Number.MAX_VALUE
  12590. }, c.prototype.updateArea = function() {
  12591. for (var a = this.data, b = 0, c = 0; c < a.length - 1; c++) b += (a[c] + a[c + 1]) / 2 * this.elementWidth;
  12592. this.area = b
  12593. }, c.prototype.computeAABB = function(a, b) {
  12594. a.upperBound[0] = this.elementWidth * this.data.length + b[0], a.upperBound[1] = this.maxValue + b[1], a.lowerBound[0] = b[0], a.lowerBound[1] = -Number.MAX_VALUE
  12595. }
  12596. }, {
  12597. "../math/vec2": 30,
  12598. "../utils/Utils": 47,
  12599. "./Shape": 42
  12600. }
  12601. ],
  12602. 38: [
  12603. function(a, b) {
  12604. function c(a) {
  12605. this.length = a || 1, d.call(this, d.LINE)
  12606. }
  12607. var d = a("./Shape"),
  12608. e = a("../math/vec2");
  12609. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  12610. return a * Math.pow(this.length, 2) / 12
  12611. }, c.prototype.updateBoundingRadius = function() {
  12612. this.boundingRadius = this.length / 2
  12613. };
  12614. var f = [e.create(), e.create()];
  12615. c.prototype.computeAABB = function(a, b, c) {
  12616. var d = this.length;
  12617. e.set(f[0], -d / 2, 0), e.set(f[1], d / 2, 0), a.setFromPoints(f, b, c)
  12618. }
  12619. }, {
  12620. "../math/vec2": 30,
  12621. "./Shape": 42
  12622. }
  12623. ],
  12624. 39: [
  12625. function(a, b) {
  12626. function c() {
  12627. d.call(this, d.PARTICLE)
  12628. }
  12629. var d = a("./Shape"),
  12630. e = a("../math/vec2");
  12631. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  12632. return 0
  12633. }, c.prototype.updateBoundingRadius = function() {
  12634. this.boundingRadius = 0
  12635. }, c.prototype.computeAABB = function(a, b) {
  12636. this.length;
  12637. e.copy(a.lowerBound, b), e.copy(a.upperBound, b)
  12638. }
  12639. }, {
  12640. "../math/vec2": 30,
  12641. "./Shape": 42
  12642. }
  12643. ],
  12644. 40: [
  12645. function(a, b) {
  12646. function c() {
  12647. d.call(this, d.PLANE)
  12648. } {
  12649. var d = a("./Shape"),
  12650. e = a("../math/vec2");
  12651. a("../utils/Utils")
  12652. }
  12653. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  12654. return 0
  12655. }, c.prototype.updateBoundingRadius = function() {
  12656. this.boundingRadius = Number.MAX_VALUE
  12657. }, c.prototype.computeAABB = function(a, b, c) {
  12658. var d = 0,
  12659. f = e.set;
  12660. "number" == typeof c && (d = c % (2 * Math.PI)), 0 == d ? (f(a.lowerBound, -Number.MAX_VALUE, -Number.MAX_VALUE), f(a.upperBound, Number.MAX_VALUE, 0)) : d == Math.PI / 2 ? (f(a.lowerBound, 0, -Number.MAX_VALUE), f(a.upperBound, Number.MAX_VALUE, Number.MAX_VALUE)) : d == Math.PI ? (f(a.lowerBound, -Number.MAX_VALUE, 0), f(a.upperBound, Number.MAX_VALUE, Number.MAX_VALUE)) : d == 3 * Math.PI / 2 ? (f(a.lowerBound, -Number.MAX_VALUE, -Number.MAX_VALUE), f(a.upperBound, 0, Number.MAX_VALUE)) : (f(a.lowerBound, -Number.MAX_VALUE, -Number.MAX_VALUE), f(a.upperBound, Number.MAX_VALUE, Number.MAX_VALUE)), e.add(a.lowerBound, a.lowerBound, b), e.add(a.upperBound, a.upperBound, b)
  12661. }, c.prototype.updateArea = function() {
  12662. this.area = Number.MAX_VALUE
  12663. }
  12664. }, {
  12665. "../math/vec2": 30,
  12666. "../utils/Utils": 47,
  12667. "./Shape": 42
  12668. }
  12669. ],
  12670. 41: [
  12671. function(a, b) {
  12672. function c(a, b) {
  12673. a = a || 1, b = b || 1;
  12674. var c = [d.fromValues(-a / 2, -b / 2), d.fromValues(a / 2, -b / 2), d.fromValues(a / 2, b / 2), d.fromValues(-a / 2, b / 2)];
  12675. this.width = a, this.height = b, f.call(this, c), this.type = e.RECTANGLE
  12676. }
  12677. var d = a("../math/vec2"),
  12678. e = a("./Shape"),
  12679. f = a("./Convex");
  12680. b.exports = c, c.prototype = new f([]), c.prototype.computeMomentOfInertia = function(a) {
  12681. var b = this.width,
  12682. c = this.height;
  12683. return a * (c * c + b * b) / 12
  12684. }, c.prototype.updateBoundingRadius = function() {
  12685. var a = this.width,
  12686. b = this.height;
  12687. this.boundingRadius = Math.sqrt(a * a + b * b) / 2
  12688. };
  12689. d.create(), d.create(), d.create(), d.create();
  12690. c.prototype.computeAABB = function(a, b, c) {
  12691. a.setFromPoints(this.vertices, b, c)
  12692. }, c.prototype.updateArea = function() {
  12693. this.area = this.width * this.height
  12694. }
  12695. }, {
  12696. "../math/vec2": 30,
  12697. "./Convex": 36,
  12698. "./Shape": 42
  12699. }
  12700. ],
  12701. 42: [
  12702. function(a, b) {
  12703. function c(a) {
  12704. this.type = a, this.id = c.idCounter++, this.boundingRadius = 0, this.collisionGroup = 1, this.collisionMask = 1, a && this.updateBoundingRadius(), this.material = null, this.area = 0, this.sensor = !1, this.updateArea()
  12705. }
  12706. b.exports = c, c.idCounter = 0, c.CIRCLE = 1, c.PARTICLE = 2, c.PLANE = 4, c.CONVEX = 8, c.LINE = 16, c.RECTANGLE = 32, c.CAPSULE = 64, c.HEIGHTFIELD = 128, c.prototype.computeMomentOfInertia = function() {
  12707. throw new Error("Shape.computeMomentOfInertia is not implemented in this Shape...")
  12708. }, c.prototype.updateBoundingRadius = function() {
  12709. throw new Error("Shape.updateBoundingRadius is not implemented in this Shape...")
  12710. }, c.prototype.updateArea = function() {}, c.prototype.computeAABB = function() {}
  12711. }, {}
  12712. ],
  12713. 43: [
  12714. function(a, b) {
  12715. function c(a) {
  12716. f.call(this, a, f.GS), a = a || {}, this.iterations = a.iterations || 10, this.tolerance = a.tolerance || 1e-10, this.arrayStep = 30, this.lambda = new g.ARRAY_TYPE(this.arrayStep), this.Bs = new g.ARRAY_TYPE(this.arrayStep), this.invCs = new g.ARRAY_TYPE(this.arrayStep), this.useZeroRHS = !1, this.frictionIterations = 0, this.usedIterations = 0
  12717. }
  12718. function d(a) {
  12719. for (var b = a.length; b--;) a[b] = 0
  12720. }
  12721. var e = a("../math/vec2"),
  12722. f = a("./Solver"),
  12723. g = a("../utils/Utils"),
  12724. h = a("../equations/FrictionEquation");
  12725. b.exports = c, c.prototype = new f, c.prototype.solve = function(a, b) {
  12726. this.sortEquations();
  12727. var f = 0,
  12728. i = this.iterations,
  12729. j = this.frictionIterations,
  12730. k = this.equations,
  12731. l = k.length,
  12732. m = Math.pow(this.tolerance * l, 2),
  12733. n = b.bodies,
  12734. o = b.bodies.length,
  12735. p = (e.add, e.set, this.useZeroRHS),
  12736. q = this.lambda;
  12737. this.usedIterations = 0, q.length < l && (q = this.lambda = new g.ARRAY_TYPE(l + this.arrayStep), this.Bs = new g.ARRAY_TYPE(l + this.arrayStep), this.invCs = new g.ARRAY_TYPE(l + this.arrayStep)), d(q);
  12738. for (var r = this.invCs, s = this.Bs, q = this.lambda, t = 0; t !== k.length; t++) {
  12739. var u = k[t];
  12740. (u.timeStep !== a || u.needsUpdate) && (u.timeStep = a, u.update()), s[t] = u.computeB(u.a, u.b, a), r[t] = u.computeInvC(u.epsilon)
  12741. }
  12742. var u, v, t, w;
  12743. if (0 !== l) {
  12744. for (t = 0; t !== o; t++) n[t].resetConstraintVelocity();
  12745. if (j) {
  12746. for (f = 0; f !== j; f++) {
  12747. for (v = 0, w = 0; w !== l; w++) {
  12748. u = k[w];
  12749. var x = c.iterateEquation(w, u, u.epsilon, s, r, q, p, a, f);
  12750. v += Math.abs(x)
  12751. }
  12752. if (this.usedIterations++, m >= v * v) break
  12753. }
  12754. for (c.updateMultipliers(k, q, 1 / a), w = 0; w !== l; w++) {
  12755. var y = k[w];
  12756. if (y instanceof h) {
  12757. var z = y.contactEquation.multiplier * y.frictionCoefficient;
  12758. y.maxForce = z, y.minForce = -z
  12759. }
  12760. }
  12761. }
  12762. for (f = 0; f !== i; f++) {
  12763. for (v = 0, w = 0; w !== l; w++) {
  12764. u = k[w];
  12765. var x = c.iterateEquation(w, u, u.epsilon, s, r, q, p, a, f);
  12766. v += Math.abs(x)
  12767. }
  12768. if (this.usedIterations++, m >= v * v) break
  12769. }
  12770. for (t = 0; t !== o; t++) n[t].addConstraintVelocity();
  12771. c.updateMultipliers(k, q, 1 / a)
  12772. }
  12773. }, c.updateMultipliers = function(a, b, c) {
  12774. for (var d = a.length; d--;) a[d].multiplier = b[d] * c
  12775. }, c.iterateEquation = function(a, b, c, d, e, f, g, h) {
  12776. var i = d[a],
  12777. j = e[a],
  12778. k = f[a],
  12779. l = b.computeGWlambda(),
  12780. m = b.maxForce,
  12781. n = b.minForce;
  12782. g && (i = 0);
  12783. var o = j * (i - l - c * k),
  12784. p = k + o;
  12785. return n * h > p ? o = n * h - k : p > m * h && (o = m * h - k), f[a] += o, b.addToWlambda(o), o
  12786. }
  12787. }, {
  12788. "../equations/FrictionEquation": 23,
  12789. "../math/vec2": 30,
  12790. "../utils/Utils": 47,
  12791. "./Solver": 44
  12792. }
  12793. ],
  12794. 44: [
  12795. function(a, b) {
  12796. function c(a, b) {
  12797. a = a || {}, d.call(this), this.type = b, this.equations = [], this.equationSortFunction = a.equationSortFunction || !1
  12798. }
  12799. var d = (a("../utils/Utils"), a("../events/EventEmitter"));
  12800. b.exports = c, c.prototype = new d, c.prototype.solve = function() {
  12801. throw new Error("Solver.solve should be implemented by subclasses!")
  12802. };
  12803. var e = {
  12804. bodies: []
  12805. };
  12806. c.prototype.solveIsland = function(a, b) {
  12807. this.removeAllEquations(), b.equations.length && (this.addEquations(b.equations), e.bodies.length = 0, b.getBodies(e.bodies), e.bodies.length && this.solve(a, e))
  12808. }, c.prototype.sortEquations = function() {
  12809. this.equationSortFunction && this.equations.sort(this.equationSortFunction)
  12810. }, c.prototype.addEquation = function(a) {
  12811. a.enabled && this.equations.push(a)
  12812. }, c.prototype.addEquations = function(a) {
  12813. for (var b = 0, c = a.length; b !== c; b++) {
  12814. var d = a[b];
  12815. d.enabled && this.equations.push(d)
  12816. }
  12817. }, c.prototype.removeEquation = function(a) {
  12818. var b = this.equations.indexOf(a); - 1 !== b && this.equations.splice(b, 1)
  12819. }, c.prototype.removeAllEquations = function() {
  12820. this.equations.length = 0
  12821. }, c.GS = 1, c.ISLAND = 2
  12822. }, {
  12823. "../events/EventEmitter": 26,
  12824. "../utils/Utils": 47
  12825. }
  12826. ],
  12827. 45: [
  12828. function(a, b) {
  12829. function c() {
  12830. this.overlappingLastState = new e, this.overlappingCurrentState = new e, this.recordPool = [], this.tmpDict = new e, this.tmpArray1 = []
  12831. }
  12832. function d(a, b, c, d) {
  12833. this.shapeA = b, this.shapeB = d, this.bodyA = a, this.bodyB = c
  12834. } {
  12835. var e = a("./TupleDictionary");
  12836. a("./Utils")
  12837. }
  12838. b.exports = c, c.prototype.tick = function() {
  12839. for (var a = this.overlappingLastState, b = this.overlappingCurrentState, c = b.keys.length; c--;) {
  12840. var d = b.keys[c];
  12841. this.recordPool.push(b.getByKey(d))
  12842. }
  12843. a.reset(), a.copy(b), b.reset()
  12844. }, c.prototype.setOverlapping = function(a, b, c, e) {
  12845. var f = (this.overlappingLastState, this.overlappingCurrentState);
  12846. if (!f.get(b.id, e.id)) {
  12847. var g;
  12848. g = this.recordPool.length ? this.recordPool.pop() : new d(a, b, c, e), f.set(b.id, e.id, g)
  12849. }
  12850. }, c.prototype.getNewOverlaps = function(a) {
  12851. return this.getDiff(this.overlappingLastState, this.overlappingCurrentState, a)
  12852. }, c.prototype.getEndOverlaps = function(a) {
  12853. return this.getDiff(this.overlappingCurrentState, this.overlappingLastState, a)
  12854. }, c.prototype.getDiff = function(a, b, c) {
  12855. var c = c || [],
  12856. d = a,
  12857. e = b;
  12858. c.length = 0;
  12859. for (var f = e.keys.length; f--;) {
  12860. var g = e.keys[f],
  12861. h = e.data[g];
  12862. if (!h) throw new Error("Key " + g + " had no data!");
  12863. var i = d.data[g];
  12864. i || c.push(h)
  12865. }
  12866. return c
  12867. }, c.prototype.isNewOverlap = function(a, b) {
  12868. var c = 0 | a.id,
  12869. d = 0 | b.id;
  12870. return !this.overlappingLastState.get(c, d) && !!this.overlappingCurrentState.get(c, d)
  12871. }, c.prototype.getNewBodyOverlaps = function(a) {
  12872. this.tmpArray1.length = 0;
  12873. var b = this.getNewOverlaps(this.tmpArray1);
  12874. return this.getBodyDiff(b, a)
  12875. }, c.prototype.getEndBodyOverlaps = function(a) {
  12876. this.tmpArray1.length = 0;
  12877. var b = this.getEndOverlaps(this.tmpArray1);
  12878. return this.getBodyDiff(b, a)
  12879. }, c.prototype.getBodyDiff = function(a, b) {
  12880. b = b || [];
  12881. for (var c = this.tmpDict, d = a.length; d--;) {
  12882. var e = a[d];
  12883. c.set(0 | e.bodyA.id, 0 | e.bodyB.id, e)
  12884. }
  12885. for (d = c.keys.length; d--;) {
  12886. var e = c.keys[d];
  12887. b.push(e.bodyA, e.bodyB)
  12888. }
  12889. return c.reset(), b
  12890. }, d.prototype.set = function(a, b, c, e) {
  12891. d.call(this, a, b, c, e)
  12892. }
  12893. }, {
  12894. "./TupleDictionary": 46,
  12895. "./Utils": 47
  12896. }
  12897. ],
  12898. 46: [
  12899. function(a, b) {
  12900. function c() {
  12901. this.data = [], this.keys = []
  12902. }
  12903. var d = a("./Utils");
  12904. b.exports = c, c.prototype.getKey = function(a, b) {
  12905. return a = 0 | a, b = 0 | b, (0 | a) === (0 | b) ? -1 : 0 | ((0 | a) > (0 | b) ? a << 16 | 65535 & b : b << 16 | 65535 & a)
  12906. }, c.prototype.getByKey = function(a) {
  12907. return a = 0 | a, this.data[a]
  12908. }, c.prototype.get = function(a, b) {
  12909. a = 0 | a, b = 0 | b;
  12910. var c = 0 | this.getKey(a, b);
  12911. return this.data[c]
  12912. }, c.prototype.set = function(a, b, c) {
  12913. if (!c) throw new Error("No data!");
  12914. a = 0 | a, b = 0 | b;
  12915. var d = 0 | this.getKey(a, b);
  12916. return this.get(a, b) || this.keys.push(d), this.data[d] = c, d
  12917. }, c.prototype.reset = function() {
  12918. for (var a = this.data, b = this.keys, c = 0 | b.length; c--;) {
  12919. var d = 0 | b[c];
  12920. a[d] = void 0
  12921. }
  12922. b.length = 0
  12923. }, c.prototype.copy = function(a) {
  12924. this.reset(), d.appendArray(this.keys, a.keys);
  12925. for (var b = 0 | a.keys.length; b--;) {
  12926. var c = 0 | a.keys[b];
  12927. this.data[c] = a.data[c]
  12928. }
  12929. }
  12930. }, {
  12931. "./Utils": 47
  12932. }
  12933. ],
  12934. 47: [
  12935. function(a, b) {
  12936. function c() {}
  12937. b.exports = c, c.appendArray = function(a, b) {
  12938. if (b.length < 15e4) a.push.apply(a, b);
  12939. else
  12940. for (var c = 0, d = b.length; c !== d; ++c) a.push(b[c])
  12941. }, c.splice = function(a, b, c) {
  12942. c = c || 1;
  12943. for (var d = b, e = a.length - c; e > d; d++) a[d] = a[d + c];
  12944. a.length = e
  12945. }, c.ARRAY_TYPE = window.Float32Array || Array, c.extend = function(a, b) {
  12946. for (var c in b) a[c] = b[c]
  12947. }, c.defaults = function(a, b) {
  12948. a = a || {};
  12949. for (var c in b) c in a || (a[c] = b[c]);
  12950. return a
  12951. }
  12952. }, {}
  12953. ],
  12954. 48: [
  12955. function(a, b) {
  12956. function c() {
  12957. this.equations = [], this.bodies = []
  12958. }
  12959. var d = a("../objects/Body");
  12960. b.exports = c, c.prototype.reset = function() {
  12961. this.equations.length = this.bodies.length = 0
  12962. };
  12963. var e = [];
  12964. c.prototype.getBodies = function(a) {
  12965. var b = a || [],
  12966. c = this.equations;
  12967. e.length = 0;
  12968. for (var d = 0; d !== c.length; d++) {
  12969. var f = c[d]; - 1 === e.indexOf(f.bodyA.id) && (b.push(f.bodyA), e.push(f.bodyA.id)), -1 === e.indexOf(f.bodyB.id) && (b.push(f.bodyB), e.push(f.bodyB.id))
  12970. }
  12971. return b
  12972. }, c.prototype.wantsToSleep = function() {
  12973. for (var a = 0; a < this.bodies.length; a++) {
  12974. var b = this.bodies[a];
  12975. if (b.motionState === d.DYNAMIC && !b.wantsToSleep) return !1
  12976. }
  12977. return !0
  12978. }, c.prototype.sleep = function() {
  12979. for (var a = 0; a < this.bodies.length; a++) {
  12980. var b = this.bodies[a];
  12981. b.sleep()
  12982. }
  12983. return !0
  12984. }
  12985. }, {
  12986. "../objects/Body": 31
  12987. }
  12988. ],
  12989. 49: [
  12990. function(a, b) {
  12991. function c() {
  12992. this._nodePool = [], this._islandPool = [], this.equations = [], this.islands = [], this.nodes = [], this.queue = []
  12993. }
  12994. var d = (a("../math/vec2"), a("./Island")),
  12995. e = a("./IslandNode"),
  12996. f = a("../objects/Body");
  12997. b.exports = c, c.getUnvisitedNode = function(a) {
  12998. for (var b = a.length, c = 0; c !== b; c++) {
  12999. var d = a[c];
  13000. if (!d.visited && d.body.motionState === f.DYNAMIC) return d
  13001. }
  13002. return !1
  13003. }, c.prototype.visit = function(a, b, c) {
  13004. b.push(a.body);
  13005. for (var d = a.equations.length, e = 0; e !== d; e++) {
  13006. var f = a.equations[e]; - 1 === c.indexOf(f) && c.push(f)
  13007. }
  13008. }, c.prototype.bfs = function(a, b, d) {
  13009. var e = this.queue;
  13010. for (e.length = 0, e.push(a), a.visited = !0, this.visit(a, b, d); e.length;)
  13011. for (var g, h = e.pop(); g = c.getUnvisitedNode(h.neighbors);) g.visited = !0, this.visit(g, b, d), g.body.motionState === f.DYNAMIC && e.push(g)
  13012. }, c.prototype.split = function(a) {
  13013. for (var b = a.bodies, f = this.nodes, g = this.equations; f.length;) this._nodePool.push(f.pop());
  13014. for (var h = 0; h !== b.length; h++)
  13015. if (this._nodePool.length) {
  13016. var i = this._nodePool.pop();
  13017. i.reset(), i.body = b[h], f.push(i)
  13018. } else f.push(new e(b[h]));
  13019. for (var j = 0; j !== g.length; j++) {
  13020. var k = g[j],
  13021. h = b.indexOf(k.bodyA),
  13022. l = b.indexOf(k.bodyB),
  13023. m = f[h],
  13024. n = f[l];
  13025. m.neighbors.push(n), n.neighbors.push(m), m.equations.push(k), n.equations.push(k)
  13026. }
  13027. for (var o = this.islands; o.length;) {
  13028. var p = o.pop();
  13029. p.reset(), this._islandPool.push(p)
  13030. }
  13031. for (var q; q = c.getUnvisitedNode(f);) {
  13032. var p = this._islandPool.length ? this._islandPool.pop() : new d;
  13033. this.bfs(q, p.bodies, p.equations), o.push(p)
  13034. }
  13035. return o
  13036. }
  13037. }, {
  13038. "../math/vec2": 30,
  13039. "../objects/Body": 31,
  13040. "./Island": 48,
  13041. "./IslandNode": 50
  13042. }
  13043. ],
  13044. 50: [
  13045. function(a, b) {
  13046. function c(a) {
  13047. this.body = a, this.neighbors = [], this.equations = [], this.visited = !1
  13048. }
  13049. b.exports = c, c.prototype.reset = function() {
  13050. this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null
  13051. }
  13052. }, {}
  13053. ],
  13054. 51: [
  13055. function(a, b) {
  13056. function c(a) {
  13057. r.apply(this), a = a || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], this.solver = a.solver || new g, this.narrowphase = new G(this), this.islandManager = new J, this.gravity = j.fromValues(0, -9.78), a.gravity && j.copy(this.gravity, a.gravity), this.frictionGravity = j.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, this.useFrictionGravityOnZeroGravity = !0, this.doProfiling = a.doProfiling || !1, this.lastStepTime = 0, this.broadphase = a.broadphase || new i, this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new v, this.defaultContactMaterial = new w(this.defaultMaterial, this.defaultMaterial), this.lastTimeStep = 1 / 60, this.applySpringForces = !0, this.applyDamping = !0, this.applyGravity = !0, this.solveConstraints = !0, this.contactMaterials = [], this.time = 0, this.stepping = !1, this.bodiesToBeRemoved = [], this.fixedStepTime = 0, this.islandSplit = "undefined" != typeof a.islandSplit ? !!a.islandSplit : !1, this.emitImpactEvent = !0, this._constraintIdCounter = 0, this._bodyIdCounter = 0, this.postStepEvent = {
  13058. type: "postStep"
  13059. }, this.addBodyEvent = {
  13060. type: "addBody",
  13061. body: null
  13062. }, this.removeBodyEvent = {
  13063. type: "removeBody",
  13064. body: null
  13065. }, this.addSpringEvent = {
  13066. type: "addSpring",
  13067. spring: null
  13068. }, this.impactEvent = {
  13069. type: "impact",
  13070. bodyA: null,
  13071. bodyB: null,
  13072. shapeA: null,
  13073. shapeB: null,
  13074. contactEquation: null
  13075. }, this.postBroadphaseEvent = {
  13076. type: "postBroadphase",
  13077. pairs: null
  13078. }, this.enableBodySleeping = !1, this.enableIslandSleeping = !1, this.beginContactEvent = {
  13079. type: "beginContact",
  13080. shapeA: null,
  13081. shapeB: null,
  13082. bodyA: null,
  13083. bodyB: null,
  13084. contactEquations: []
  13085. }, this.endContactEvent = {
  13086. type: "endContact",
  13087. shapeA: null,
  13088. shapeB: null,
  13089. bodyA: null,
  13090. bodyB: null
  13091. }, this.preSolveEvent = {
  13092. type: "preSolve",
  13093. contactEquations: null,
  13094. frictionEquations: null
  13095. }, this.overlappingShapesLastState = {
  13096. keys: []
  13097. }, this.overlappingShapesCurrentState = {
  13098. keys: []
  13099. }, this.overlapKeeper = new I
  13100. }
  13101. function d(a) {
  13102. return a ? [a[0], a[1]] : a
  13103. }
  13104. function e(a, b) {
  13105. for (var c in b) a[c] = b[c]
  13106. }
  13107. function f(a) {
  13108. return {
  13109. id: a.id,
  13110. materialA: a.materialA.id,
  13111. materialB: a.materialB.id,
  13112. friction: a.friction,
  13113. restitution: a.restitution,
  13114. stiffness: a.stiffness,
  13115. relaxation: a.relaxation,
  13116. frictionStiffness: a.frictionStiffness,
  13117. frictionRelaxation: a.frictionRelaxation
  13118. }
  13119. }
  13120. var g = a("../solver/GSSolver"),
  13121. h = a("../solver/Solver"),
  13122. i = a("../collision/NaiveBroadphase"),
  13123. j = a("../math/vec2"),
  13124. k = a("../shapes/Circle"),
  13125. l = a("../shapes/Rectangle"),
  13126. m = a("../shapes/Convex"),
  13127. n = a("../shapes/Line"),
  13128. o = a("../shapes/Plane"),
  13129. p = a("../shapes/Capsule"),
  13130. q = a("../shapes/Particle"),
  13131. r = a("../events/EventEmitter"),
  13132. s = a("../objects/Body"),
  13133. t = a("../shapes/Shape"),
  13134. u = a("../objects/Spring"),
  13135. v = a("../material/Material"),
  13136. w = a("../material/ContactMaterial"),
  13137. x = a("../constraints/DistanceConstraint"),
  13138. y = a("../constraints/Constraint"),
  13139. z = a("../constraints/LockConstraint"),
  13140. A = a("../constraints/RevoluteConstraint"),
  13141. B = a("../constraints/PrismaticConstraint"),
  13142. C = a("../constraints/GearConstraint"),
  13143. D = a("../../package.json"),
  13144. E = a("../collision/Broadphase"),
  13145. F = a("../collision/SAPBroadphase"),
  13146. G = a("../collision/Narrowphase"),
  13147. H = a("../utils/Utils"),
  13148. I = a("../utils/OverlapKeeper"),
  13149. J = a("./IslandManager");
  13150. if (b.exports = c, "undefined" == typeof performance && (performance = {}), !performance.now) {
  13151. var K = Date.now();
  13152. performance.timing && performance.timing.navigationStart && (K = performance.timing.navigationStart), performance.now = function() {
  13153. return Date.now() - K
  13154. }
  13155. }
  13156. c.prototype = new Object(r.prototype), c.prototype.addConstraint = function(a) {
  13157. this.constraints.push(a)
  13158. }, c.prototype.addContactMaterial = function(a) {
  13159. this.contactMaterials.push(a)
  13160. }, c.prototype.removeContactMaterial = function(a) {
  13161. var b = this.contactMaterials.indexOf(a); - 1 !== b && H.splice(this.contactMaterials, b, 1)
  13162. }, c.prototype.getContactMaterial = function(a, b) {
  13163. for (var c = this.contactMaterials, d = 0, e = c.length; d !== e; d++) {
  13164. var f = c[d];
  13165. if (f.materialA === a && f.materialB === b || f.materialA === b && f.materialB === a) return f
  13166. }
  13167. return !1
  13168. }, c.prototype.removeConstraint = function(a) {
  13169. var b = this.constraints.indexOf(a); - 1 !== b && H.splice(this.constraints, b, 1)
  13170. };
  13171. var L = (j.create(), j.create(), j.create(), j.create(), j.create(), j.create(), j.create()),
  13172. M = j.fromValues(0, 0),
  13173. N = j.fromValues(0, 0),
  13174. O = (j.fromValues(0, 0), j.fromValues(0, 0));
  13175. c.prototype.step = function(a, b, c) {
  13176. if (c = c || 10, b = b || 0, 0 === b) this.internalStep(a), this.time += a;
  13177. else {
  13178. var d = Math.floor((this.time + b) / a) - Math.floor(this.time / a);
  13179. d = Math.min(d, c);
  13180. for (var e = 0; e !== d; e++) this.internalStep(a);
  13181. this.time += b;
  13182. for (var f = this.time % a, g = f / a, h = 0; h !== this.bodies.length; h++) {
  13183. var i = this.bodies[h];
  13184. i.motionState !== s.STATIC && i.sleepState !== s.SLEEPING ? (j.sub(O, i.position, i.previousPosition), j.scale(O, O, g), j.add(i.interpolatedPosition, i.position, O), i.interpolatedAngle = i.angle + (i.angle - i.previousAngle) * g) : (j.copy(i.interpolatedPosition, i.position), i.interpolatedAngle = i.angle)
  13185. }
  13186. }
  13187. };
  13188. var P = [];
  13189. c.prototype.internalStep = function(a) {
  13190. this.stepping = !0;
  13191. var b, d, e = this,
  13192. f = this.doProfiling,
  13193. g = this.springs.length,
  13194. h = this.springs,
  13195. i = this.bodies,
  13196. k = this.gravity,
  13197. l = this.solver,
  13198. m = this.bodies.length,
  13199. n = this.broadphase,
  13200. o = this.narrowphase,
  13201. p = this.constraints,
  13202. q = L,
  13203. r = (j.scale, j.add),
  13204. t = (j.rotate, this.islandManager);
  13205. if (this.lastTimeStep = a, f && (b = performance.now()), this.useWorldGravityAsFrictionGravity) {
  13206. var u = j.length(this.gravity);
  13207. 0 === u && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = u)
  13208. }
  13209. if (this.applyGravity)
  13210. for (var v = 0; v !== m; v++) {
  13211. var w = i[v],
  13212. x = w.force;
  13213. w.motionState === s.DYNAMIC && w.sleepState !== s.SLEEPING && (j.scale(q, k, w.mass * w.gravityScale), r(x, x, q))
  13214. }
  13215. if (this.applySpringForces)
  13216. for (var v = 0; v !== g; v++) {
  13217. var y = h[v];
  13218. y.applyForce()
  13219. }
  13220. if (this.applyDamping)
  13221. for (var v = 0; v !== m; v++) {
  13222. var w = i[v];
  13223. w.motionState === s.DYNAMIC && w.applyDamping(a)
  13224. }
  13225. for (var z = n.getCollisionPairs(this), A = this.disabledBodyCollisionPairs, v = A.length - 2; v >= 0; v -= 2)
  13226. for (var B = z.length - 2; B >= 0; B -= 2)(A[v] === z[B] && A[v + 1] === z[B + 1] || A[v + 1] === z[B] && A[v] === z[B + 1]) && z.splice(B, 2);
  13227. var C = p.length;
  13228. for (v = 0; v !== C; v++) {
  13229. var D = p[v];
  13230. if (!D.collideConnected)
  13231. for (var B = z.length - 2; B >= 0; B -= 2)(D.bodyA === z[B] && D.bodyB === z[B + 1] || D.bodyB === z[B] && D.bodyA === z[B + 1]) && z.splice(B, 2)
  13232. }
  13233. this.postBroadphaseEvent.pairs = z, this.emit(this.postBroadphaseEvent), o.reset(this);
  13234. for (var v = 0, E = z.length; v !== E; v += 2)
  13235. for (var F = z[v], G = z[v + 1], I = 0, J = F.shapes.length; I !== J; I++)
  13236. for (var K = F.shapes[I], M = F.shapeOffsets[I], N = F.shapeAngles[I], O = 0, Q = G.shapes.length; O !== Q; O++) {
  13237. var R = G.shapes[O],
  13238. S = G.shapeOffsets[O],
  13239. T = G.shapeAngles[O],
  13240. U = this.defaultContactMaterial;
  13241. if (K.material && R.material) {
  13242. var V = this.getContactMaterial(K.material, R.material);
  13243. V && (U = V)
  13244. }
  13245. this.runNarrowphase(o, F, K, M, N, G, R, S, T, U, this.frictionGravity)
  13246. }
  13247. for (var v = 0; v !== m; v++) {
  13248. var W = i[v];
  13249. W._wakeUpAfterNarrowphase && (W.wakeUp(), W._wakeUpAfterNarrowphase = !1)
  13250. }
  13251. if (this.has("endContact")) {
  13252. this.overlapKeeper.getEndOverlaps(P);
  13253. for (var X = this.endContactEvent, O = P.length; O--;) {
  13254. var Y = P[O];
  13255. X.shapeA = Y.shapeA, X.shapeB = Y.shapeB, X.bodyA = Y.bodyA, X.bodyB = Y.bodyA, this.emit(X)
  13256. }
  13257. }
  13258. this.overlapKeeper.tick();
  13259. var Z = this.preSolveEvent;
  13260. Z.contactEquations = o.contactEquations, Z.frictionEquations = o.frictionEquations, this.emit(Z);
  13261. var C = p.length;
  13262. for (v = 0; v !== C; v++) p[v].update();
  13263. if (o.contactEquations.length || o.frictionEquations.length || p.length)
  13264. if (this.islandSplit) {
  13265. for (t.equations.length = 0, H.appendArray(t.equations, o.contactEquations), H.appendArray(t.equations, o.frictionEquations), v = 0; v !== C; v++) H.appendArray(t.equations, p[v].equations);
  13266. t.split(this);
  13267. for (var v = 0; v !== t.islands.length; v++) {
  13268. var $ = t.islands[v];
  13269. $.equations.length && l.solveIsland(a, $)
  13270. }
  13271. } else {
  13272. for (l.addEquations(o.contactEquations), l.addEquations(o.frictionEquations), v = 0; v !== C; v++) l.addEquations(p[v].equations);
  13273. this.solveConstraints && l.solve(a, this), l.removeAllEquations()
  13274. }
  13275. for (var v = 0; v !== m; v++) {
  13276. var W = i[v];
  13277. W.sleepState !== s.SLEEPING && W.motionState !== s.STATIC && c.integrateBody(W, a)
  13278. }
  13279. for (var v = 0; v !== m; v++) i[v].setZeroForce();
  13280. if (f && (d = performance.now(), e.lastStepTime = d - b), this.emitImpactEvent && this.has("impact"))
  13281. for (var _ = this.impactEvent, v = 0; v !== o.contactEquations.length; v++) {
  13282. var ab = o.contactEquations[v];
  13283. ab.firstImpact && (_.bodyA = ab.bodyA, _.bodyB = ab.bodyB, _.shapeA = ab.shapeA, _.shapeB = ab.shapeB, _.contactEquation = ab, this.emit(_))
  13284. }
  13285. if (this.enableBodySleeping)
  13286. for (v = 0; v !== m; v++) i[v].sleepTick(this.time, !1, a);
  13287. else if (this.enableIslandSleeping && this.islandSplit) {
  13288. for (v = 0; v !== m; v++) i[v].sleepTick(this.time, !0, a);
  13289. for (var v = 0; v < this.islandManager.islands.length; v++) {
  13290. var $ = this.islandManager.islands[v];
  13291. $.wantsToSleep() && $.sleep()
  13292. }
  13293. }
  13294. if (this.stepping = !1, this.bodiesToBeRemoved.length) {
  13295. for (var v = 0; v !== this.bodiesToBeRemoved.length; v++) this.removeBody(this.bodiesToBeRemoved[v]);
  13296. this.bodiesToBeRemoved.length = 0
  13297. }
  13298. this.emit(this.postStepEvent)
  13299. };
  13300. var Q = j.create(),
  13301. R = j.create();
  13302. c.integrateBody = function(a, b) {
  13303. var c = a.invMass,
  13304. d = a.force,
  13305. e = a.position,
  13306. f = a.velocity;
  13307. j.copy(a.previousPosition, a.position), a.previousAngle = a.angle, a.fixedRotation || (a.angularVelocity += a.angularForce * a.invInertia * b, a.angle += a.angularVelocity * b), j.scale(Q, d, b * c), j.add(f, Q, f), j.scale(R, f, b), j.add(e, e, R), a.aabbNeedsUpdate = !0
  13308. }, c.prototype.runNarrowphase = function(a, b, c, d, e, f, g, h, i, k, l) {
  13309. if (0 !== (c.collisionGroup & g.collisionMask) && 0 !== (g.collisionGroup & c.collisionMask)) {
  13310. j.rotate(M, d, b.angle), j.rotate(N, h, f.angle), j.add(M, M, b.position), j.add(N, N, f.position);
  13311. var m = e + b.angle,
  13312. n = i + f.angle;
  13313. a.enableFriction = k.friction > 0, a.frictionCoefficient = k.friction;
  13314. var o;
  13315. o = b.motionState === s.STATIC || b.motionState === s.KINEMATIC ? f.mass : f.motionState === s.STATIC || f.motionState === s.KINEMATIC ? b.mass : b.mass * f.mass / (b.mass + f.mass), a.slipForce = k.friction * l * o, a.restitution = k.restitution, a.surfaceVelocity = k.surfaceVelocity, a.frictionStiffness = k.frictionStiffness, a.frictionRelaxation = k.frictionRelaxation, a.stiffness = k.stiffness, a.relaxation = k.relaxation;
  13316. var p = a[c.type | g.type],
  13317. q = 0;
  13318. if (p) {
  13319. var r = c.sensor || g.sensor,
  13320. t = a.frictionEquations.length;
  13321. q = c.type < g.type ? p.call(a, b, c, M, m, f, g, N, n, r) : p.call(a, f, g, N, n, b, c, M, m, r);
  13322. var u = a.frictionEquations.length - t;
  13323. if (q) {
  13324. if (b.allowSleep && b.motionState === s.DYNAMIC && b.sleepState === s.SLEEPING && f.sleepState === s.AWAKE && f.motionState !== s.STATIC) {
  13325. var v = j.squaredLength(f.velocity) + Math.pow(f.angularVelocity, 2),
  13326. w = Math.pow(f.sleepSpeedLimit, 2);
  13327. v >= 2 * w && (b._wakeUpAfterNarrowphase = !0)
  13328. }
  13329. if (f.allowSleep && f.motionState === s.DYNAMIC && f.sleepState === s.SLEEPING && b.sleepState === s.AWAKE && b.motionState !== s.STATIC) {
  13330. var x = j.squaredLength(b.velocity) + Math.pow(b.angularVelocity, 2),
  13331. y = Math.pow(b.sleepSpeedLimit, 2);
  13332. x >= 2 * y && (f._wakeUpAfterNarrowphase = !0)
  13333. }
  13334. if (this.overlapKeeper.setOverlapping(b, c, f, g), this.has("beginContact") && this.overlapKeeper.isNewOverlap(c, g)) {
  13335. var z = this.beginContactEvent;
  13336. if (z.shapeA = c, z.shapeB = g, z.bodyA = b, z.bodyB = f, z.contactEquations.length = 0, "number" == typeof q)
  13337. for (var A = a.contactEquations.length - q; A < a.contactEquations.length; A++) z.contactEquations.push(a.contactEquations[A]);
  13338. this.emit(z)
  13339. }
  13340. if ("number" == typeof q && u > 1)
  13341. for (var A = a.frictionEquations.length - u; A < a.frictionEquations.length; A++) {
  13342. var B = a.frictionEquations[A];
  13343. B.setSlipForce(B.getSlipForce() / u)
  13344. }
  13345. }
  13346. }
  13347. }
  13348. }, c.prototype.addSpring = function(a) {
  13349. this.springs.push(a), this.addSpringEvent.spring = a, this.emit(this.addSpringEvent)
  13350. }, c.prototype.removeSpring = function(a) {
  13351. var b = this.springs.indexOf(a); - 1 === b && H.splice(this.springs, b, 1)
  13352. }, c.prototype.addBody = function(a) {
  13353. -1 === this.bodies.indexOf(a) && (this.bodies.push(a), a.world = this, this.addBodyEvent.body = a, this.emit(this.addBodyEvent))
  13354. }, c.prototype.removeBody = function(a) {
  13355. if (this.stepping) this.bodiesToBeRemoved.push(a);
  13356. else {
  13357. a.world = null;
  13358. var b = this.bodies.indexOf(a); - 1 !== b && (H.splice(this.bodies, b, 1), this.removeBodyEvent.body = a, a.resetConstraintVelocity(), this.emit(this.removeBodyEvent))
  13359. }
  13360. }, c.prototype.getBodyById = function(a) {
  13361. for (var b = this.bodies, c = 0; c < b.length; c++) {
  13362. var d = b[c];
  13363. if (d.id === a) return d
  13364. }
  13365. return !1
  13366. }, c.prototype.disableBodyCollision = function(a, b) {
  13367. this.disabledBodyCollisionPairs.push(a, b)
  13368. }, c.prototype.enableBodyCollision = function(a, b) {
  13369. for (var c = this.disabledBodyCollisionPairs, d = 0; d < c.length; d += 2)
  13370. if (c[d] === a && c[d + 1] === b || c[d + 1] === a && c[d] === b) return void c.splice(d, 2)
  13371. }, c.prototype.toJSON = function() {
  13372. var a = this,
  13373. b = {
  13374. p2: D.version,
  13375. bodies: [],
  13376. springs: [],
  13377. solver: {},
  13378. gravity: d(a.gravity),
  13379. broadphase: {},
  13380. distanceConstraints: [],
  13381. revoluteConstraints: [],
  13382. prismaticConstraints: [],
  13383. lockConstraints: [],
  13384. gearConstraints: [],
  13385. contactMaterials: [],
  13386. materials: [],
  13387. defaultContactMaterial: f(a.defaultContactMaterial),
  13388. islandSplit: a.islandSplit,
  13389. enableIslandSleeping: a.enableIslandSleeping,
  13390. enableBodySleeping: a.enableBodySleeping
  13391. },
  13392. c = b.solver,
  13393. g = a.solver;
  13394. g.type === h.GS && (c.type = "GSSolver", c.iterations = g.iterations);
  13395. var i = b.broadphase,
  13396. j = a.broadphase;
  13397. j.type === E.NAIVE ? i.type = "NaiveBroadphase" : j.type === E.SAP ? i.type = "SAPBroadphase" : console.error("Broadphase not supported: " + j.type);
  13398. for (var k = 0; k !== a.springs.length; k++) {
  13399. var g = a.springs[k];
  13400. b.springs.push({
  13401. bodyA: a.bodies.indexOf(g.bodyA),
  13402. bodyB: a.bodies.indexOf(g.bodyB),
  13403. stiffness: g.stiffness,
  13404. damping: g.damping,
  13405. restLength: g.restLength,
  13406. localAnchorA: d(g.localAnchorA),
  13407. localAnchorB: d(g.localAnchorB)
  13408. })
  13409. }
  13410. for (var k = 0; k < a.constraints.length; k++) {
  13411. var l = a.constraints[k],
  13412. m = {
  13413. bodyA: a.bodies.indexOf(l.bodyA),
  13414. bodyB: a.bodies.indexOf(l.bodyB),
  13415. collideConnected: l.collideConnected
  13416. };
  13417. switch (l.type) {
  13418. case y.DISTANCE:
  13419. e(m, {
  13420. distance: l.distance,
  13421. maxForce: l.getMaxForce()
  13422. }), b.distanceConstraints.push(m);
  13423. break;
  13424. case y.REVOLUTE:
  13425. e(m, {
  13426. pivotA: d(l.pivotA),
  13427. pivotB: d(l.pivotB),
  13428. maxForce: l.maxForce,
  13429. motorSpeed: l.getMotorSpeed() || 0,
  13430. motorEnabled: !!l.getMotorSpeed(),
  13431. lowerLimit: l.lowerLimit,
  13432. lowerLimitEnabled: l.lowerLimitEnabled,
  13433. upperLimit: l.upperLimit,
  13434. upperLimitEnabled: l.upperLimitEnabled
  13435. }), b.revoluteConstraints.push(m);
  13436. break;
  13437. case y.PRISMATIC:
  13438. e(m, {
  13439. localAxisA: d(l.localAxisA),
  13440. localAnchorA: d(l.localAnchorA),
  13441. localAnchorB: d(l.localAnchorB),
  13442. maxForce: l.maxForce,
  13443. upperLimitEnabled: l.upperLimitEnabled,
  13444. lowerLimitEnabled: l.lowerLimitEnabled,
  13445. upperLimit: l.upperLimit,
  13446. lowerLimit: l.lowerLimit,
  13447. motorEnabled: l.motorEnabled,
  13448. motorSpeed: l.motorSpeed
  13449. }), b.prismaticConstraints.push(m);
  13450. break;
  13451. case y.LOCK:
  13452. e(m, {
  13453. localOffsetB: d(l.localOffsetB),
  13454. localAngleB: l.localAngleB,
  13455. maxForce: l.getMaxForce()
  13456. }), b.lockConstraints.push(m);
  13457. break;
  13458. case y.GEAR:
  13459. e(m, {
  13460. angle: l.angle,
  13461. ratio: l.ratio,
  13462. maxForce: l.maxForce || 1e6
  13463. }), b.gearConstraints.push(m);
  13464. break;
  13465. default:
  13466. console.error("Constraint not supported yet: ", l.type)
  13467. }
  13468. }
  13469. for (var k = 0; k !== a.bodies.length; k++) {
  13470. var n = a.bodies[k],
  13471. o = n.shapes,
  13472. p = {
  13473. id: n.id,
  13474. mass: n.mass,
  13475. angle: n.angle,
  13476. position: d(n.position),
  13477. velocity: d(n.velocity),
  13478. angularVelocity: n.angularVelocity,
  13479. force: d(n.force),
  13480. motionState: n.motionState,
  13481. fixedRotation: n.fixedRotation,
  13482. circleShapes: [],
  13483. planeShapes: [],
  13484. particleShapes: [],
  13485. lineShapes: [],
  13486. rectangleShapes: [],
  13487. convexShapes: [],
  13488. capsuleShapes: []
  13489. };
  13490. n.concavePath && (p.concavePath = n.concavePath);
  13491. for (var q = 0; q < o.length; q++) {
  13492. var g = o[q],
  13493. r = {};
  13494. switch (r.offset = d(n.shapeOffsets[q]), r.angle = n.shapeAngles[q], r.collisionGroup = g.collisionGroup, r.collisionMask = g.collisionMask, r.material = g.material ? g.material.id : null, g.type) {
  13495. case t.CIRCLE:
  13496. e(r, {
  13497. radius: g.radius
  13498. }), p.circleShapes.push(r);
  13499. break;
  13500. case t.PLANE:
  13501. p.planeShapes.push(r);
  13502. break;
  13503. case t.PARTICLE:
  13504. p.particleShapes.push(r);
  13505. break;
  13506. case t.LINE:
  13507. r.length = g.length, p.lineShapes.push(r);
  13508. break;
  13509. case t.RECTANGLE:
  13510. e(r, {
  13511. width: g.width,
  13512. height: g.height
  13513. }), p.rectangleShapes.push(r);
  13514. break;
  13515. case t.CONVEX:
  13516. for (var s = [], u = 0; u < g.vertices.length; u++) s.push(d(g.vertices[u]));
  13517. e(r, {
  13518. vertices: s
  13519. }), p.convexShapes.push(r);
  13520. break;
  13521. case t.CAPSULE:
  13522. e(r, {
  13523. length: g.length,
  13524. radius: g.radius
  13525. }), p.capsuleShapes.push(r);
  13526. break;
  13527. default:
  13528. console.error("Shape type not supported yet!")
  13529. }
  13530. }
  13531. b.bodies.push(p)
  13532. }
  13533. for (var k = 0; k < a.contactMaterials.length; k++) {
  13534. var v = a.contactMaterials[k];
  13535. b.contactMaterials.push(f(v))
  13536. }
  13537. for (var w = {}, k = 0; k < a.contactMaterials.length; k++) {
  13538. var v = a.contactMaterials[k];
  13539. w[v.materialA.id + ""] = v.materialA, w[v.materialB.id + ""] = v.materialB
  13540. }
  13541. for (var x in w) {
  13542. var z = w[parseInt(x)];
  13543. b.materials.push({
  13544. id: z.id
  13545. })
  13546. }
  13547. return b
  13548. }, c.prototype.fromJSON = function(a) {
  13549. function b(a, b, c) {
  13550. b.collisionMask = c.collisionMask, b.collisionGroup = c.collisionGroup, c.material && (b.material = h[c.material + ""]), a.addShape(b, c.offset, c.angle)
  13551. }
  13552. if (this.clear(), !a.p2) return !1;
  13553. var c = this;
  13554. switch (j.copy(c.gravity, a.gravity), c.islandSplit = a.islandSplit, c.enableIslandSleeping = a.enableIslandSleeping, c.enableBodySleeping = a.enableBodySleeping, a.solver.type) {
  13555. case "GSSolver":
  13556. var d = a.solver,
  13557. e = new g;
  13558. c.solver = e, e.iterations = d.iterations;
  13559. break;
  13560. default:
  13561. throw new Error("Solver type not recognized: " + a.solver.type)
  13562. }
  13563. switch (a.broadphase.type) {
  13564. case "NaiveBroadphase":
  13565. c.broadphase = new i;
  13566. break;
  13567. case "SAPBroadphase":
  13568. c.broadphase = new F
  13569. }
  13570. c.broadphase.setWorld(c);
  13571. for (var f = c.bodies, h = {}, r = 0; r !== a.materials.length; r++) {
  13572. var t = a.materials[r],
  13573. y = new v;
  13574. h[t.id + ""] = y, y.id = t.id
  13575. }
  13576. c.defaultMaterial.id = a.defaultContactMaterial.materialA;
  13577. for (var r = 0; r !== a.bodies.length; r++) {
  13578. var D = a.bodies[r],
  13579. E = new s({
  13580. mass: D.mass,
  13581. position: D.position,
  13582. angle: D.angle,
  13583. velocity: D.velocity,
  13584. angularVelocity: D.angularVelocity,
  13585. force: D.force,
  13586. fixedRotation: D.fixedRotation
  13587. });
  13588. E.id = D.id, E.motionState = D.motionState;
  13589. for (var G = 0; G < D.circleShapes.length; G++) {
  13590. var e = D.circleShapes[G];
  13591. b(E, new k(e.radius), e)
  13592. }
  13593. for (var G = 0; G < D.planeShapes.length; G++) {
  13594. var e = D.planeShapes[G];
  13595. b(E, new o, e)
  13596. }
  13597. for (var G = 0; G < D.particleShapes.length; G++) {
  13598. var e = D.particleShapes[G];
  13599. b(E, new q, e)
  13600. }
  13601. for (var G = 0; G < D.lineShapes.length; G++) {
  13602. var e = D.lineShapes[G];
  13603. b(E, new n(e.length), e)
  13604. }
  13605. for (var G = 0; G < D.rectangleShapes.length; G++) {
  13606. var e = D.rectangleShapes[G];
  13607. b(E, new l(e.width, e.height), e)
  13608. }
  13609. for (var G = 0; G < D.convexShapes.length; G++) {
  13610. var e = D.convexShapes[G];
  13611. b(E, new m(e.vertices), e)
  13612. }
  13613. for (var G = 0; G < D.capsuleShapes.length; G++) {
  13614. var e = D.capsuleShapes[G];
  13615. b(E, new p(e.length, e.radius), e)
  13616. }
  13617. D.concavePath && (E.concavePath = D.concavePath), c.addBody(E)
  13618. }
  13619. for (var r = 0; r < a.springs.length; r++) {
  13620. var d = a.springs[r],
  13621. H = f[d.bodyA],
  13622. I = f[d.bodyB];
  13623. if (!H) return this.error = "instance.springs[" + r + "] references instance.body[" + d.bodyA + "], which does not exist.", !1;
  13624. if (!I) return this.error = "instance.springs[" + r + "] references instance.body[" + d.bodyB + "], which does not exist.", !1;
  13625. var e = new u(H, I, {
  13626. stiffness: d.stiffness,
  13627. damping: d.damping,
  13628. restLength: d.restLength,
  13629. localAnchorA: d.localAnchorA,
  13630. localAnchorB: d.localAnchorB
  13631. });
  13632. c.addSpring(e)
  13633. }
  13634. for (var r = 0; r < a.contactMaterials.length; r++) {
  13635. var t = a.contactMaterials[r],
  13636. J = h[t.materialA + ""],
  13637. K = h[t.materialB + ""];
  13638. if (!J) return this.error = "Reference to material id " + t.materialA + ": material not found", !1;
  13639. if (!K) return this.error = "Reference to material id " + t.materialB + ": material not found", !1;
  13640. var L = new w(J, K, {
  13641. friction: t.friction,
  13642. restitution: t.restitution,
  13643. stiffness: t.stiffness,
  13644. relaxation: t.relaxation,
  13645. frictionStiffness: t.frictionStiffness,
  13646. frictionRelaxation: t.frictionRelaxation
  13647. });
  13648. L.id = t.id, c.addContactMaterial(L)
  13649. }
  13650. var t = a.defaultContactMaterial,
  13651. J = c.defaultMaterial,
  13652. K = c.defaultMaterial,
  13653. L = new w(J, K, {
  13654. friction: t.friction,
  13655. restitution: t.restitution,
  13656. stiffness: t.stiffness,
  13657. relaxation: t.relaxation,
  13658. frictionStiffness: t.frictionStiffness,
  13659. frictionRelaxation: t.frictionRelaxation
  13660. });
  13661. L.id = t.id, c.defaultContactMaterial = L;
  13662. for (var r = 0; r < a.distanceConstraints.length; r++) {
  13663. var M = a.distanceConstraints[r];
  13664. c.addConstraint(new x(f[M.bodyA], f[M.bodyB], M.distance, {
  13665. maxForce: M.maxForce,
  13666. collideConnected: M.collideConnected
  13667. }))
  13668. }
  13669. for (var r = 0; r < a.revoluteConstraints.length; r++) {
  13670. var M = a.revoluteConstraints[r],
  13671. N = new A(f[M.bodyA], M.pivotA, f[M.bodyB], M.pivotB, {
  13672. maxForce: M.maxForce,
  13673. collideConnected: M.collideConnected
  13674. });
  13675. M.motorEnabled && N.enableMotor(), N.setMotorSpeed(M.motorSpeed), N.lowerLimit = M.lowerLimit, N.upperLimit = M.upperLimit, N.lowerLimitEnabled = M.lowerLimitEnabled, N.upperLimitEnabled = M.upperLimitEnabled, c.addConstraint(N)
  13676. }
  13677. for (var r = 0; r < a.prismaticConstraints.length; r++) {
  13678. var M = a.prismaticConstraints[r],
  13679. O = new B(f[M.bodyA], f[M.bodyB], {
  13680. maxForce: M.maxForce,
  13681. localAxisA: M.localAxisA,
  13682. localAnchorA: M.localAnchorA,
  13683. localAnchorB: M.localAnchorB,
  13684. collideConnected: M.collideConnected
  13685. });
  13686. O.motorSpeed = M.motorSpeed, c.addConstraint(O)
  13687. }
  13688. for (var r = 0; r < a.lockConstraints.length; r++) {
  13689. var M = a.lockConstraints[r];
  13690. c.addConstraint(new z(f[M.bodyA], f[M.bodyB], {
  13691. maxForce: M.maxForce,
  13692. localOffsetB: M.localOffsetB,
  13693. localAngleB: M.localAngleB,
  13694. collideConnected: M.collideConnected
  13695. }))
  13696. }
  13697. for (var r = 0; r < a.gearConstraints.length; r++) {
  13698. var M = a.gearConstraints[r];
  13699. c.addConstraint(new C(f[M.bodyA], f[M.bodyB], {
  13700. maxForce: M.maxForce,
  13701. angle: M.angle,
  13702. ratio: M.ratio,
  13703. collideConnected: M.collideConnected
  13704. }))
  13705. }
  13706. return !0
  13707. }, c.prototype.clear = function() {
  13708. this.time = 0, this.fixedStepTime = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
  13709. for (var a = this.constraints, b = a.length - 1; b >= 0; b--) this.removeConstraint(a[b]);
  13710. for (var d = this.bodies, b = d.length - 1; b >= 0; b--) this.removeBody(d[b]);
  13711. for (var e = this.springs, b = e.length - 1; b >= 0; b--) this.removeSpring(e[b]);
  13712. for (var f = this.contactMaterials, b = f.length - 1; b >= 0; b--) this.removeContactMaterial(f[b]);
  13713. c.apply(this)
  13714. }, c.prototype.clone = function() {
  13715. var a = new c;
  13716. return a.fromJSON(this.toJSON()), a
  13717. };
  13718. var S = j.create(),
  13719. T = j.fromValues(0, 0),
  13720. U = j.fromValues(0, 0);
  13721. c.prototype.hitTest = function(a, b, c) {
  13722. c = c || 0;
  13723. var d = new s({
  13724. position: a
  13725. }),
  13726. e = new q,
  13727. f = a,
  13728. g = 0,
  13729. h = S,
  13730. i = T,
  13731. l = U;
  13732. d.addShape(e);
  13733. for (var n = this.narrowphase, r = [], t = 0, u = b.length; t !== u; t++)
  13734. for (var v = b[t], w = 0, x = v.shapes.length; w !== x; w++) {
  13735. var y = v.shapes[w],
  13736. z = v.shapeOffsets[w] || i,
  13737. A = v.shapeAngles[w] || 0;
  13738. j.rotate(h, z, v.angle), j.add(h, h, v.position);
  13739. var B = A + v.angle;
  13740. (y instanceof k && n.circleParticle(v, y, h, B, d, e, f, g, !0) || y instanceof m && n.particleConvex(d, e, f, g, v, y, h, B, !0) || y instanceof o && n.particlePlane(d, e, f, g, v, y, h, B, !0) || y instanceof p && n.particleCapsule(d, e, f, g, v, y, h, B, !0) || y instanceof q && j.squaredLength(j.sub(l, h, a)) < c * c) && r.push(v)
  13741. }
  13742. return r
  13743. }, c.prototype.setGlobalEquationParameters = function(a) {
  13744. a = a || {};
  13745. for (var b = 0; b !== this.constraints.length; b++)
  13746. for (var c = this.constraints[b], d = 0; d !== c.equations.length; d++) {
  13747. var e = c.equations[d];
  13748. "undefined" != typeof a.stiffness && (e.stiffness = a.stiffness), "undefined" != typeof a.relaxation && (e.relaxation = a.relaxation), e.needsUpdate = !0
  13749. }
  13750. for (var b = 0; b !== this.contactMaterials.length; b++) {
  13751. var c = this.contactMaterials[b];
  13752. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13753. }
  13754. var c = this.defaultContactMaterial;
  13755. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13756. }, c.prototype.setGlobalStiffness = function(a) {
  13757. this.setGlobalEquationParameters({
  13758. stiffness: a
  13759. })
  13760. }, c.prototype.setGlobalRelaxation = function(a) {
  13761. this.setGlobalEquationParameters({
  13762. relaxation: a
  13763. })
  13764. }
  13765. }, {
  13766. "../../package.json": 7,
  13767. "../collision/Broadphase": 9,
  13768. "../collision/NaiveBroadphase": 11,
  13769. "../collision/Narrowphase": 12,
  13770. "../collision/SAPBroadphase": 13,
  13771. "../constraints/Constraint": 14,
  13772. "../constraints/DistanceConstraint": 15,
  13773. "../constraints/GearConstraint": 16,
  13774. "../constraints/LockConstraint": 17,
  13775. "../constraints/PrismaticConstraint": 18,
  13776. "../constraints/RevoluteConstraint": 19,
  13777. "../events/EventEmitter": 26,
  13778. "../material/ContactMaterial": 27,
  13779. "../material/Material": 28,
  13780. "../math/vec2": 30,
  13781. "../objects/Body": 31,
  13782. "../objects/Spring": 32,
  13783. "../shapes/Capsule": 34,
  13784. "../shapes/Circle": 35,
  13785. "../shapes/Convex": 36,
  13786. "../shapes/Line": 38,
  13787. "../shapes/Particle": 39,
  13788. "../shapes/Plane": 40,
  13789. "../shapes/Rectangle": 41,
  13790. "../shapes/Shape": 42,
  13791. "../solver/GSSolver": 43,
  13792. "../solver/Solver": 44,
  13793. "../utils/OverlapKeeper": 45,
  13794. "../utils/Utils": 47,
  13795. "./IslandManager": 49
  13796. }
  13797. ]
  13798. }, {}, [33])(33)
  13799. }), p2.Body.prototype.parent = null, p2.Spring.prototype.parent = null, Phaser.Physics.P2 = function(a, b) {
  13800. this.game = a, "undefined" != typeof b && b.hasOwnProperty("gravity") && b.hasOwnProperty("broadphase") || (b = {
  13801. gravity: [0, 0],
  13802. broadphase: new p2.SAPBroadphase
  13803. }), this.world = new p2.World(b), this.frameRate = 1 / 60, this.useElapsedTime = !1, this.paused = !1, this.materials = [], this.gravity = new Phaser.Physics.P2.InversePointProxy(this, this.world.gravity), this.walls = {
  13804. left: null,
  13805. right: null,
  13806. top: null,
  13807. bottom: null
  13808. }, this.onBodyAdded = new Phaser.Signal, this.onBodyRemoved = new Phaser.Signal, this.onSpringAdded = new Phaser.Signal, this.onSpringRemoved = new Phaser.Signal, this.onConstraintAdded = new Phaser.Signal, this.onConstraintRemoved = new Phaser.Signal, this.onContactMaterialAdded = new Phaser.Signal, this.onContactMaterialRemoved = new Phaser.Signal, this.postBroadphaseCallback = null, this.callbackContext = null, this.onBeginContact = new Phaser.Signal, this.onEndContact = new Phaser.Signal, b.hasOwnProperty("mpx") && b.hasOwnProperty("pxm") && b.hasOwnProperty("mpxi") && b.hasOwnProperty("pxmi") && (this.mpx = b.mpx, this.mpxi = b.mpxi, this.pxm = b.pxm, this.pxmi = b.pxmi), this.world.on("beginContact", this.beginContactHandler, this), this.world.on("endContact", this.endContactHandler, this), this.collisionGroups = [], this.nothingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2147483648), this.boundsCollidesWith = [], this._toRemove = [], this._collisionGroupID = 2, this.setBoundsToWorld(!0, !0, !0, !0, !1)
  13809. }, Phaser.Physics.P2.prototype = {
  13810. removeBodyNextStep: function(a) {
  13811. this._toRemove.push(a)
  13812. },
  13813. preUpdate: function() {
  13814. for (var a = this._toRemove.length; a--;) this.removeBody(this._toRemove[a]);
  13815. this._toRemove.length = 0
  13816. },
  13817. enable: function(a, b, c) {
  13818. "undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !0);
  13819. var d = 1;
  13820. if (Array.isArray(a))
  13821. for (d = a.length; d--;) a[d] instanceof Phaser.Group ? this.enable(a[d].children, b, c) : (this.enableBody(a[d], b), c && a[d].hasOwnProperty("children") && a[d].children.length > 0 && this.enable(a[d], b, !0));
  13822. else a instanceof Phaser.Group ? this.enable(a.children, b, c) : (this.enableBody(a, b), c && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, b, !0))
  13823. },
  13824. enableBody: function(a, b) {
  13825. a.hasOwnProperty("body") && null === a.body && (a.body = new Phaser.Physics.P2.Body(this.game, a, a.x, a.y, 1), a.body.debug = b, a.anchor.set(.5))
  13826. },
  13827. setImpactEvents: function(a) {
  13828. a ? this.world.on("impact", this.impactHandler, this) : this.world.off("impact", this.impactHandler, this)
  13829. },
  13830. setPostBroadphaseCallback: function(a, b) {
  13831. this.postBroadphaseCallback = a, this.callbackContext = b, null !== a ? this.world.on("postBroadphase", this.postBroadphaseHandler, this) : this.world.off("postBroadphase", this.postBroadphaseHandler, this)
  13832. },
  13833. postBroadphaseHandler: function(a) {
  13834. if (this.postBroadphaseCallback)
  13835. for (var b = a.pairs.length; b -= 2;) a.pairs[b].parent && a.pairs[b + 1].parent && !this.postBroadphaseCallback.call(this.callbackContext, a.pairs[b].parent, a.pairs[b + 1].parent) && a.pairs.splice(b, 2)
  13836. },
  13837. impactHandler: function(a) {
  13838. if (a.bodyA.parent && a.bodyB.parent) {
  13839. var b = a.bodyA.parent,
  13840. c = a.bodyB.parent;
  13841. b._bodyCallbacks[a.bodyB.id] && b._bodyCallbacks[a.bodyB.id].call(b._bodyCallbackContext[a.bodyB.id], b, c, a.shapeA, a.shapeB), c._bodyCallbacks[a.bodyA.id] && c._bodyCallbacks[a.bodyA.id].call(c._bodyCallbackContext[a.bodyA.id], c, b, a.shapeB, a.shapeA), b._groupCallbacks[a.shapeB.collisionGroup] && b._groupCallbacks[a.shapeB.collisionGroup].call(b._groupCallbackContext[a.shapeB.collisionGroup], b, c, a.shapeA, a.shapeB), c._groupCallbacks[a.shapeA.collisionGroup] && c._groupCallbacks[a.shapeA.collisionGroup].call(c._groupCallbackContext[a.shapeA.collisionGroup], c, b, a.shapeB, a.shapeA)
  13842. }
  13843. },
  13844. beginContactHandler: function(a) {
  13845. this.onBeginContact.dispatch(a.bodyA, a.bodyB, a.shapeA, a.shapeB, a.contactEquations), a.bodyA.parent && a.bodyA.parent.onBeginContact.dispatch(a.bodyB.parent, a.shapeA, a.shapeB, a.contactEquations), a.bodyB.parent && a.bodyB.parent.onBeginContact.dispatch(a.bodyA.parent, a.shapeB, a.shapeA, a.contactEquations)
  13846. },
  13847. endContactHandler: function(a) {
  13848. this.onEndContact.dispatch(a.bodyA, a.bodyB, a.shapeA, a.shapeB), a.bodyA.parent && a.bodyA.parent.onEndContact.dispatch(a.bodyB.parent, a.shapeA, a.shapeB), a.bodyB.parent && a.bodyB.parent.onEndContact.dispatch(a.bodyA.parent, a.shapeB, a.shapeA)
  13849. },
  13850. setBoundsToWorld: function(a, b, c, d, e) {
  13851. this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, a, b, c, d, e)
  13852. },
  13853. setWorldMaterial: function(a, b, c, d, e) {
  13854. "undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = !0), b && this.walls.left && (this.walls.left.shapes[0].material = a), c && this.walls.right && (this.walls.right.shapes[0].material = a), d && this.walls.top && (this.walls.top.shapes[0].material = a), e && this.walls.bottom && (this.walls.bottom.shapes[0].material = a)
  13855. },
  13856. updateBoundsCollisionGroup: function(a) {
  13857. var b = this.everythingCollisionGroup.mask;
  13858. "undefined" == typeof a && (b = this.boundsCollisionGroup.mask), this.walls.left && (this.walls.left.shapes[0].collisionGroup = b), this.walls.right && (this.walls.right.shapes[0].collisionGroup = b), this.walls.top && (this.walls.top.shapes[0].collisionGroup = b), this.walls.bottom && (this.walls.bottom.shapes[0].collisionGroup = b)
  13859. },
  13860. setBounds: function(a, b, c, d, e, f, g, h, i) {
  13861. "undefined" == typeof e && (e = !0), "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = !0), "undefined" == typeof h && (h = !0), "undefined" == typeof i && (i = !0), this.walls.left && this.world.removeBody(this.walls.left), this.walls.right && this.world.removeBody(this.walls.right), this.walls.top && this.world.removeBody(this.walls.top), this.walls.bottom && this.world.removeBody(this.walls.bottom), e && (this.walls.left = new p2.Body({
  13862. mass: 0,
  13863. position: [this.pxmi(a), this.pxmi(b)],
  13864. angle: 1.5707963267948966
  13865. }), this.walls.left.addShape(new p2.Plane), i && (this.walls.left.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.left)), f && (this.walls.right = new p2.Body({
  13866. mass: 0,
  13867. position: [this.pxmi(a + c), this.pxmi(b)],
  13868. angle: -1.5707963267948966
  13869. }), this.walls.right.addShape(new p2.Plane), i && (this.walls.right.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.right)), g && (this.walls.top = new p2.Body({
  13870. mass: 0,
  13871. position: [this.pxmi(a), this.pxmi(b)],
  13872. angle: -3.141592653589793
  13873. }), this.walls.top.addShape(new p2.Plane), i && (this.walls.top.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.top)), h && (this.walls.bottom = new p2.Body({
  13874. mass: 0,
  13875. position: [this.pxmi(a), this.pxmi(b + d)]
  13876. }), this.walls.bottom.addShape(new p2.Plane), i && (this.walls.bottom.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.bottom))
  13877. },
  13878. pause: function() {
  13879. this.paused = !0
  13880. },
  13881. resume: function() {
  13882. this.paused = !1
  13883. },
  13884. update: function() {
  13885. this.paused || this.world.step(this.useElapsedTime ? this.game.time.physicsElapsed : this.frameRate)
  13886. },
  13887. clear: function() {
  13888. this.world.clear(), this.world.off("beginContact", this.beginContactHandler, this), this.world.off("endContact", this.endContactHandler, this), this.postBroadphaseCallback = null, this.callbackContext = null, this.impactCallback = null, this.collisionGroups = [], this._toRemove = [], this._collisionGroupID = 2, this.boundsCollidesWith = []
  13889. },
  13890. destroy: function() {
  13891. this.clear(), this.game = null
  13892. },
  13893. addBody: function(a) {
  13894. return a.data.world ? !1 : (this.world.addBody(a.data), this.onBodyAdded.dispatch(a), !0)
  13895. },
  13896. removeBody: function(a) {
  13897. return a.data.world == this.world && (this.world.removeBody(a.data), this.onBodyRemoved.dispatch(a)), a
  13898. },
  13899. addSpring: function(a) {
  13900. return this.world.addSpring(a), this.onSpringAdded.dispatch(a), a
  13901. },
  13902. removeSpring: function(a) {
  13903. return this.world.removeSpring(a), this.onSpringRemoved.dispatch(a), a
  13904. },
  13905. createDistanceConstraint: function(a, b, c, d) {
  13906. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.DistanceConstraint(this, a, b, c, d)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13907. },
  13908. createGearConstraint: function(a, b, c, d) {
  13909. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.GearConstraint(this, a, b, c, d)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13910. },
  13911. createRevoluteConstraint: function(a, b, c, d, e) {
  13912. return a = this.getBody(a), c = this.getBody(c), a && c ? this.addConstraint(new Phaser.Physics.P2.RevoluteConstraint(this, a, b, c, d, e)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13913. },
  13914. createLockConstraint: function(a, b, c, d, e) {
  13915. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.LockConstraint(this, a, b, c, d, e)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13916. },
  13917. createPrismaticConstraint: function(a, b, c, d, e, f, g) {
  13918. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.PrismaticConstraint(this, a, b, c, d, e, f, g)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13919. },
  13920. addConstraint: function(a) {
  13921. return this.world.addConstraint(a), this.onConstraintAdded.dispatch(a), a
  13922. },
  13923. removeConstraint: function(a) {
  13924. return this.world.removeConstraint(a), this.onConstraintRemoved.dispatch(a), a
  13925. },
  13926. addContactMaterial: function(a) {
  13927. return this.world.addContactMaterial(a), this.onContactMaterialAdded.dispatch(a), a
  13928. },
  13929. removeContactMaterial: function(a) {
  13930. return this.world.removeContactMaterial(a), this.onContactMaterialRemoved.dispatch(a), a
  13931. },
  13932. getContactMaterial: function(a, b) {
  13933. return this.world.getContactMaterial(a, b)
  13934. },
  13935. setMaterial: function(a, b) {
  13936. for (var c = b.length; c--;) b[c].setMaterial(a)
  13937. },
  13938. createMaterial: function(a, b) {
  13939. a = a || "";
  13940. var c = new Phaser.Physics.P2.Material(a);
  13941. return this.materials.push(c), "undefined" != typeof b && b.setMaterial(c), c
  13942. },
  13943. createContactMaterial: function(a, b, c) {
  13944. "undefined" == typeof a && (a = this.createMaterial()), "undefined" == typeof b && (b = this.createMaterial());
  13945. var d = new Phaser.Physics.P2.ContactMaterial(a, b, c);
  13946. return this.addContactMaterial(d)
  13947. },
  13948. getBodies: function() {
  13949. for (var a = [], b = this.world.bodies.length; b--;) a.push(this.world.bodies[b].parent);
  13950. return a
  13951. },
  13952. getBody: function(a) {
  13953. return a instanceof p2.Body ? a : a instanceof Phaser.Physics.P2.Body ? a.data : a.body && a.body.type === Phaser.Physics.P2JS ? a.body.data : null
  13954. },
  13955. getSprings: function() {
  13956. for (var a = [], b = this.world.springs.length; b--;) a.push(this.world.springs[b].parent);
  13957. return a
  13958. },
  13959. getConstraints: function() {
  13960. for (var a = [], b = this.world.constraints.length; b--;) a.push(this.world.constraints[b].parent);
  13961. return a
  13962. },
  13963. hitTest: function(a, b, c, d) {
  13964. "undefined" == typeof b && (b = this.world.bodies), "undefined" == typeof c && (c = 5), "undefined" == typeof d && (d = !1);
  13965. for (var e = [this.pxmi(a.x), this.pxmi(a.y)], f = [], g = b.length; g--;) b[g] instanceof Phaser.Physics.P2.Body && (!d || b[g].data.motionState !== p2.Body.STATIC) ? f.push(b[g].data) : b[g] instanceof p2.Body && b[g].parent && (!d || b[g].motionState !== p2.Body.STATIC) ? f.push(b[g]) : b[g] instanceof Phaser.Sprite && b[g].hasOwnProperty("body") && (!d || b[g].body.data.motionState !== p2.Body.STATIC) && f.push(b[g].body.data);
  13966. return this.world.hitTest(e, f, c)
  13967. },
  13968. toJSON: function() {
  13969. return this.world.toJSON()
  13970. },
  13971. createCollisionGroup: function(a) {
  13972. var b = Math.pow(2, this._collisionGroupID);
  13973. this.walls.left && (this.walls.left.shapes[0].collisionMask = this.walls.left.shapes[0].collisionMask | b), this.walls.right && (this.walls.right.shapes[0].collisionMask = this.walls.right.shapes[0].collisionMask | b), this.walls.top && (this.walls.top.shapes[0].collisionMask = this.walls.top.shapes[0].collisionMask | b), this.walls.bottom && (this.walls.bottom.shapes[0].collisionMask = this.walls.bottom.shapes[0].collisionMask | b), this._collisionGroupID++;
  13974. var c = new Phaser.Physics.P2.CollisionGroup(b);
  13975. return this.collisionGroups.push(c), a && this.setCollisionGroup(a, c), c
  13976. },
  13977. setCollisionGroup: function(a, b) {
  13978. if (a instanceof Phaser.Group)
  13979. for (var c = 0; c < a.total; c++) a.children[c].body && a.children[c].body.type === Phaser.Physics.P2JS && a.children[c].body.setCollisionGroup(b);
  13980. else a.body.setCollisionGroup(b)
  13981. },
  13982. createSpring: function(a, b, c, d, e, f, g, h, i) {
  13983. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addSpring(new Phaser.Physics.P2.Spring(this, a, b, c, d, e, f, g, h, i)) : void console.warn("Cannot create Spring, invalid body objects given")
  13984. },
  13985. createBody: function(a, b, c, d, e, f) {
  13986. "undefined" == typeof d && (d = !1);
  13987. var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
  13988. if (f) {
  13989. var h = g.addPolygon(e, f);
  13990. if (!h) return !1
  13991. }
  13992. return d && this.world.addBody(g.data), g
  13993. },
  13994. createParticle: function(a, b, c, d, e, f) {
  13995. "undefined" == typeof d && (d = !1);
  13996. var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
  13997. if (f) {
  13998. var h = g.addPolygon(e, f);
  13999. if (!h) return !1
  14000. }
  14001. return d && this.world.addBody(g.data), g
  14002. },
  14003. convertCollisionObjects: function(a, b, c) {
  14004. "undefined" == typeof c && (c = !0);
  14005. for (var d = [], e = 0, f = a.collision[b].length; f > e; e++) {
  14006. var g = a.collision[b][e],
  14007. h = this.createBody(g.x, g.y, 0, c, {}, g.polyline);
  14008. h && d.push(h)
  14009. }
  14010. return d
  14011. },
  14012. clearTilemapLayerBodies: function(a, b) {
  14013. b = a.getLayer(b);
  14014. for (var c = a.layers[b].bodies.length; c--;) a.layers[b].bodies[c].destroy();
  14015. a.layers[b].bodies.length = 0
  14016. },
  14017. convertTilemap: function(a, b, c, d) {
  14018. b = a.getLayer(b), "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !0), this.clearTilemapLayerBodies(a, b);
  14019. for (var e = 0, f = 0, g = 0, h = 0, i = a.layers[b].height; i > h; h++) {
  14020. e = 0;
  14021. for (var j = 0, k = a.layers[b].width; k > j; j++) {
  14022. var l = a.layers[b].data[h][j];
  14023. if (l && l.index > -1 && l.collides)
  14024. if (d) {
  14025. var m = a.getTileRight(b, j, h);
  14026. if (0 === e && (f = l.x * l.width, g = l.y * l.height, e = l.width), m && m.collides) e += l.width;
  14027. else {
  14028. var n = this.createBody(f, g, 0, !1);
  14029. n.addRectangle(e, l.height, e / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n), e = 0
  14030. }
  14031. } else {
  14032. var n = this.createBody(l.x * l.width, l.y * l.height, 0, !1);
  14033. n.addRectangle(l.width, l.height, l.width / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n)
  14034. }
  14035. }
  14036. }
  14037. return a.layers[b].bodies
  14038. },
  14039. mpx: function(a) {
  14040. return a *= 20
  14041. },
  14042. pxm: function(a) {
  14043. return .05 * a
  14044. },
  14045. mpxi: function(a) {
  14046. return a *= -20
  14047. },
  14048. pxmi: function(a) {
  14049. return a * -.05
  14050. }
  14051. }, Object.defineProperty(Phaser.Physics.P2.prototype, "friction", {
  14052. get: function() {
  14053. return this.world.defaultContactMaterial.friction
  14054. },
  14055. set: function(a) {
  14056. this.world.defaultContactMaterial.friction = a
  14057. }
  14058. }), Object.defineProperty(Phaser.Physics.P2.prototype, "defaultFriction", {
  14059. get: function() {
  14060. return this.world.defaultContactMaterial.friction
  14061. },
  14062. set: function(a) {
  14063. this.world.defaultContactMaterial.friction = a
  14064. }
  14065. }), Object.defineProperty(Phaser.Physics.P2.prototype, "restitution", {
  14066. get: function() {
  14067. return this.world.defaultContactMaterial.restitution
  14068. },
  14069. set: function(a) {
  14070. this.world.defaultContactMaterial.restitution = a
  14071. }
  14072. }), Object.defineProperty(Phaser.Physics.P2.prototype, "defaultRestitution", {
  14073. get: function() {
  14074. return this.world.defaultContactMaterial.restitution
  14075. },
  14076. set: function(a) {
  14077. this.world.defaultContactMaterial.restitution = a
  14078. }
  14079. }), Object.defineProperty(Phaser.Physics.P2.prototype, "contactMaterial", {
  14080. get: function() {
  14081. return this.world.defaultContactMaterial
  14082. },
  14083. set: function(a) {
  14084. this.world.defaultContactMaterial = a
  14085. }
  14086. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", {
  14087. get: function() {
  14088. return this.world.applySpringForces
  14089. },
  14090. set: function(a) {
  14091. this.world.applySpringForces = a
  14092. }
  14093. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", {
  14094. get: function() {
  14095. return this.world.applyDamping
  14096. },
  14097. set: function(a) {
  14098. this.world.applyDamping = a
  14099. }
  14100. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", {
  14101. get: function() {
  14102. return this.world.applyGravity
  14103. },
  14104. set: function(a) {
  14105. this.world.applyGravity = a
  14106. }
  14107. }), Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", {
  14108. get: function() {
  14109. return this.world.solveConstraints
  14110. },
  14111. set: function(a) {
  14112. this.world.solveConstraints = a
  14113. }
  14114. }), Object.defineProperty(Phaser.Physics.P2.prototype, "time", {
  14115. get: function() {
  14116. return this.world.time
  14117. }
  14118. }), Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", {
  14119. get: function() {
  14120. return this.world.emitImpactEvent
  14121. },
  14122. set: function(a) {
  14123. this.world.emitImpactEvent = a
  14124. }
  14125. }), Object.defineProperty(Phaser.Physics.P2.prototype, "enableBodySleeping", {
  14126. get: function() {
  14127. return this.world.enableBodySleeping
  14128. },
  14129. set: function(a) {
  14130. this.world.enableBodySleeping = a
  14131. }
  14132. }), Object.defineProperty(Phaser.Physics.P2.prototype, "total", {
  14133. get: function() {
  14134. return this.world.bodies.length
  14135. }
  14136. }), Phaser.Physics.P2.FixtureList = function(a) {
  14137. Array.isArray(a) || (a = [a]), this.rawList = a, this.init(), this.parse(this.rawList)
  14138. }, Phaser.Physics.P2.FixtureList.prototype = {
  14139. init: function() {
  14140. this.namedFixtures = {}, this.groupedFixtures = [], this.allFixtures = []
  14141. },
  14142. setCategory: function(a, b) {
  14143. var c = function(b) {
  14144. b.collisionGroup = a
  14145. };
  14146. this.getFixtures(b).forEach(c)
  14147. },
  14148. setMask: function(a, b) {
  14149. var c = function(b) {
  14150. b.collisionMask = a
  14151. };
  14152. this.getFixtures(b).forEach(c)
  14153. },
  14154. setSensor: function(a, b) {
  14155. var c = function(b) {
  14156. b.sensor = a
  14157. };
  14158. this.getFixtures(b).forEach(c)
  14159. },
  14160. setMaterial: function(a, b) {
  14161. var c = function(b) {
  14162. b.material = a
  14163. };
  14164. this.getFixtures(b).forEach(c)
  14165. },
  14166. getFixtures: function(a) {
  14167. var b = [];
  14168. if (a) {
  14169. a instanceof Array || (a = [a]);
  14170. var c = this;
  14171. return a.forEach(function(a) {
  14172. c.namedFixtures[a] && b.push(c.namedFixtures[a])
  14173. }), this.flatten(b)
  14174. }
  14175. return this.allFixtures
  14176. },
  14177. getFixtureByKey: function(a) {
  14178. return this.namedFixtures[a]
  14179. },
  14180. getGroup: function(a) {
  14181. return this.groupedFixtures[a]
  14182. },
  14183. parse: function() {
  14184. var a, b, c, d;
  14185. c = this.rawList, d = [];
  14186. for (a in c) b = c[a], isNaN(a - 0) ? this.namedFixtures[a] = this.flatten(b) : (this.groupedFixtures[a] = this.groupedFixtures[a] || [], this.groupedFixtures[a] = this.groupedFixtures[a].concat(b)), d.push(this.allFixtures = this.flatten(this.groupedFixtures))
  14187. },
  14188. flatten: function(a) {
  14189. var b, c;
  14190. return b = [], c = arguments.callee, a.forEach(function(a) {
  14191. return Array.prototype.push.apply(b, Array.isArray(a) ? c(a) : [a])
  14192. }), b
  14193. }
  14194. }, Phaser.Physics.P2.PointProxy = function(a, b) {
  14195. this.world = a, this.destination = b
  14196. }, Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProxy, Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
  14197. get: function() {
  14198. return this.destination[0]
  14199. },
  14200. set: function(a) {
  14201. this.destination[0] = this.world.pxm(a)
  14202. }
  14203. }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
  14204. get: function() {
  14205. return this.destination[1]
  14206. },
  14207. set: function(a) {
  14208. this.destination[1] = this.world.pxm(a)
  14209. }
  14210. }), Phaser.Physics.P2.InversePointProxy = function(a, b) {
  14211. this.world = a, this.destination = b
  14212. }, Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.InversePointProxy, Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
  14213. get: function() {
  14214. return this.destination[0]
  14215. },
  14216. set: function(a) {
  14217. this.destination[0] = this.world.pxm(-a)
  14218. }
  14219. }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
  14220. get: function() {
  14221. return this.destination[1]
  14222. },
  14223. set: function(a) {
  14224. this.destination[1] = this.world.pxm(-a)
  14225. }
  14226. }), Phaser.Physics.P2.Body = function(a, b, c, d, e) {
  14227. b = b || null, c = c || 0, d = d || 0, "undefined" == typeof e && (e = 1), this.game = a, this.world = a.physics.p2, this.sprite = b, this.type = Phaser.Physics.P2JS, this.offset = new Phaser.Point, this.data = new p2.Body({
  14228. position: [this.world.pxmi(c), this.world.pxmi(d)],
  14229. mass: e
  14230. }), this.data.parent = this, this.velocity = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.velocity), this.force = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.force), this.gravity = new Phaser.Point, this.onBeginContact = new Phaser.Signal, this.onEndContact = new Phaser.Signal, this.collidesWith = [], this.removeNextStep = !1, this.debugBody = null, this._collideWorldBounds = !0, this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, b && (this.setRectangleFromSprite(b), b.exists && this.game.physics.p2.addBody(this))
  14231. }, Phaser.Physics.P2.Body.prototype = {
  14232. createBodyCallback: function(a, b, c) {
  14233. var d = -1;
  14234. a.id ? d = a.id : a.body && (d = a.body.id), d > -1 && (null === b ? (delete this._bodyCallbacks[d], delete this._bodyCallbackContext[d]) : (this._bodyCallbacks[d] = b, this._bodyCallbackContext[d] = c))
  14235. },
  14236. createGroupCallback: function(a, b, c) {
  14237. null === b ? (delete this._groupCallbacks[a.mask], delete this._groupCallbacksContext[a.mask]) : (this._groupCallbacks[a.mask] = b, this._groupCallbackContext[a.mask] = c)
  14238. },
  14239. getCollisionMask: function() {
  14240. var a = 0;
  14241. this._collideWorldBounds && (a = this.game.physics.p2.boundsCollisionGroup.mask);
  14242. for (var b = 0; b < this.collidesWith.length; b++) a |= this.collidesWith[b].mask;
  14243. return a
  14244. },
  14245. updateCollisionMask: function(a) {
  14246. var b = this.getCollisionMask();
  14247. if ("undefined" == typeof a)
  14248. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].collisionMask = b;
  14249. else a.collisionMask = b
  14250. },
  14251. setCollisionGroup: function(a, b) {
  14252. var c = this.getCollisionMask();
  14253. if ("undefined" == typeof b)
  14254. for (var d = this.data.shapes.length - 1; d >= 0; d--) this.data.shapes[d].collisionGroup = a.mask, this.data.shapes[d].collisionMask = c;
  14255. else b.collisionGroup = a.mask, b.collisionMask = c
  14256. },
  14257. clearCollision: function(a, b, c) {
  14258. if ("undefined" == typeof c)
  14259. for (var d = this.data.shapes.length - 1; d >= 0; d--) a && (this.data.shapes[d].collisionGroup = null), b && (this.data.shapes[d].collisionMask = null);
  14260. else a && (c.collisionGroup = null), b && (c.collisionMask = null);
  14261. a && (this.collidesWith.length = 0)
  14262. },
  14263. collides: function(a, b, c, d) {
  14264. if (Array.isArray(a))
  14265. for (var e = 0; e < a.length; e++) - 1 === this.collidesWith.indexOf(a[e]) && (this.collidesWith.push(a[e]), b && this.createGroupCallback(a[e], b, c));
  14266. else -1 === this.collidesWith.indexOf(a) && (this.collidesWith.push(a), b && this.createGroupCallback(a, b, c));
  14267. var f = this.getCollisionMask();
  14268. if ("undefined" == typeof d)
  14269. for (var e = this.data.shapes.length - 1; e >= 0; e--) this.data.shapes[e].collisionMask = f;
  14270. else d.collisionMask = f
  14271. },
  14272. adjustCenterOfMass: function() {
  14273. this.data.adjustCenterOfMass()
  14274. },
  14275. applyDamping: function(a) {
  14276. this.data.applyDamping(a)
  14277. },
  14278. applyForce: function(a, b, c) {
  14279. this.data.applyForce(a, [this.world.pxmi(b), this.world.pxmi(c)])
  14280. },
  14281. setZeroForce: function() {
  14282. this.data.setZeroForce()
  14283. },
  14284. setZeroRotation: function() {
  14285. this.data.angularVelocity = 0
  14286. },
  14287. setZeroVelocity: function() {
  14288. this.data.velocity[0] = 0, this.data.velocity[1] = 0
  14289. },
  14290. setZeroDamping: function() {
  14291. this.data.damping = 0, this.data.angularDamping = 0
  14292. },
  14293. toLocalFrame: function(a, b) {
  14294. return this.data.toLocalFrame(a, b)
  14295. },
  14296. toWorldFrame: function(a, b) {
  14297. return this.data.toWorldFrame(a, b)
  14298. },
  14299. rotateLeft: function(a) {
  14300. this.data.angularVelocity = this.world.pxm(-a)
  14301. },
  14302. rotateRight: function(a) {
  14303. this.data.angularVelocity = this.world.pxm(a)
  14304. },
  14305. moveForward: function(a) {
  14306. var b = this.world.pxmi(-a),
  14307. c = this.data.angle + Math.PI / 2;
  14308. this.data.velocity[0] = b * Math.cos(c), this.data.velocity[1] = b * Math.sin(c)
  14309. },
  14310. moveBackward: function(a) {
  14311. var b = this.world.pxmi(-a),
  14312. c = this.data.angle + Math.PI / 2;
  14313. this.data.velocity[0] = -(b * Math.cos(c)), this.data.velocity[1] = -(b * Math.sin(c))
  14314. },
  14315. thrust: function(a) {
  14316. var b = this.world.pxmi(-a),
  14317. c = this.data.angle + Math.PI / 2;
  14318. this.data.force[0] += b * Math.cos(c), this.data.force[1] += b * Math.sin(c)
  14319. },
  14320. reverse: function(a) {
  14321. var b = this.world.pxmi(-a),
  14322. c = this.data.angle + Math.PI / 2;
  14323. this.data.force[0] -= b * Math.cos(c), this.data.force[1] -= b * Math.sin(c)
  14324. },
  14325. moveLeft: function(a) {
  14326. this.data.velocity[0] = this.world.pxmi(-a)
  14327. },
  14328. moveRight: function(a) {
  14329. this.data.velocity[0] = this.world.pxmi(a)
  14330. },
  14331. moveUp: function(a) {
  14332. this.data.velocity[1] = this.world.pxmi(-a)
  14333. },
  14334. moveDown: function(a) {
  14335. this.data.velocity[1] = this.world.pxmi(a)
  14336. },
  14337. preUpdate: function() {
  14338. this.removeNextStep && (this.removeFromWorld(), this.removeNextStep = !1)
  14339. },
  14340. postUpdate: function() {
  14341. this.sprite.x = this.world.mpxi(this.data.position[0]), this.sprite.y = this.world.mpxi(this.data.position[1]), this.fixedRotation || (this.sprite.rotation = this.data.angle)
  14342. },
  14343. reset: function(a, b, c, d) {
  14344. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), this.setZeroForce(), this.setZeroVelocity(), this.setZeroRotation(), c && this.setZeroDamping(), d && (this.mass = 1), this.x = a, this.y = b
  14345. },
  14346. addToWorld: function() {
  14347. if (this.game.physics.p2._toRemove)
  14348. for (var a = 0; a < this.game.physics.p2._toRemove.length; a++) this.game.physics.p2._toRemove[a] === this && this.game.physics.p2._toRemove.splice(a, 1);
  14349. this.data.world !== this.game.physics.p2.world && this.game.physics.p2.addBody(this)
  14350. },
  14351. removeFromWorld: function() {
  14352. this.data.world === this.game.physics.p2.world && this.game.physics.p2.removeBodyNextStep(this)
  14353. },
  14354. destroy: function() {
  14355. this.removeFromWorld(), this.clearShapes(), this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this.debugBody && this.debugBody.destroy(), this.debugBody = null, this.sprite = null
  14356. },
  14357. clearShapes: function() {
  14358. for (var a = this.data.shapes.length; a--;) this.data.removeShape(this.data.shapes[a]);
  14359. this.shapeChanged()
  14360. },
  14361. addShape: function(a, b, c, d) {
  14362. return "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), this.data.addShape(a, [this.world.pxmi(b), this.world.pxmi(c)], d), this.shapeChanged(), a
  14363. },
  14364. addCircle: function(a, b, c, d) {
  14365. var e = new p2.Circle(this.world.pxm(a));
  14366. return this.addShape(e, b, c, d)
  14367. },
  14368. addRectangle: function(a, b, c, d, e) {
  14369. var f = new p2.Rectangle(this.world.pxm(a), this.world.pxm(b));
  14370. return this.addShape(f, c, d, e)
  14371. },
  14372. addPlane: function(a, b, c) {
  14373. var d = new p2.Plane;
  14374. return this.addShape(d, a, b, c)
  14375. },
  14376. addParticle: function(a, b, c) {
  14377. var d = new p2.Particle;
  14378. return this.addShape(d, a, b, c)
  14379. },
  14380. addLine: function(a, b, c, d) {
  14381. var e = new p2.Line(this.world.pxm(a));
  14382. return this.addShape(e, b, c, d)
  14383. },
  14384. addCapsule: function(a, b, c, d, e) {
  14385. var f = new p2.Capsule(this.world.pxm(a), b);
  14386. return this.addShape(f, c, d, e)
  14387. },
  14388. addPolygon: function(a, b) {
  14389. a = a || {}, Array.isArray(b) || (b = Array.prototype.slice.call(arguments, 1));
  14390. var c = [];
  14391. if (1 === b.length && Array.isArray(b[0])) c = b[0].slice(0);
  14392. else if (Array.isArray(b[0])) c = b[0].slice(0);
  14393. else if ("number" == typeof b[0])
  14394. for (var d = 0, e = b.length; e > d; d += 2) c.push([b[d], b[d + 1]]);
  14395. var f = c.length - 1;
  14396. c[f][0] === c[0][0] && c[f][1] === c[0][1] && c.pop();
  14397. for (var g = 0; g < c.length; g++) c[g][0] = this.world.pxmi(c[g][0]), c[g][1] = this.world.pxmi(c[g][1]);
  14398. var h = this.data.fromPolygon(c, a);
  14399. return this.shapeChanged(), h
  14400. },
  14401. removeShape: function(a) {
  14402. var b = this.data.removeShape(a);
  14403. return this.shapeChanged(), b
  14404. },
  14405. setCircle: function(a, b, c, d) {
  14406. return this.clearShapes(), this.addCircle(a, b, c, d)
  14407. },
  14408. setRectangle: function(a, b, c, d, e) {
  14409. return "undefined" == typeof a && (a = 16), "undefined" == typeof b && (b = 16), this.clearShapes(), this.addRectangle(a, b, c, d, e)
  14410. },
  14411. setRectangleFromSprite: function(a) {
  14412. return "undefined" == typeof a && (a = this.sprite), this.clearShapes(), this.addRectangle(a.width, a.height, 0, 0, a.rotation)
  14413. },
  14414. setMaterial: function(a, b) {
  14415. if ("undefined" == typeof b)
  14416. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].material = a;
  14417. else b.material = a
  14418. },
  14419. shapeChanged: function() {
  14420. this.debugBody && this.debugBody.draw()
  14421. },
  14422. addPhaserPolygon: function(a, b) {
  14423. for (var c = this.game.cache.getPhysicsData(a, b), d = [], e = 0; e < c.length; e++) {
  14424. var f = c[e],
  14425. g = this.addFixture(f);
  14426. d[f.filter.group] = d[f.filter.group] || [], d[f.filter.group] = d[f.filter.group].concat(g), f.fixtureKey && (d[f.fixtureKey] = g)
  14427. }
  14428. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), d
  14429. },
  14430. addFixture: function(a) {
  14431. var b = [];
  14432. if (a.circle) {
  14433. var c = new p2.Circle(this.world.pxm(a.circle.radius));
  14434. c.collisionGroup = a.filter.categoryBits, c.collisionMask = a.filter.maskBits, c.sensor = a.isSensor;
  14435. var d = p2.vec2.create();
  14436. d[0] = this.world.pxmi(a.circle.position[0] - this.sprite.width / 2), d[1] = this.world.pxmi(a.circle.position[1] - this.sprite.height / 2), this.data.addShape(c, d), b.push(c)
  14437. } else
  14438. for (var e = a.polygons, f = p2.vec2.create(), g = 0; g < e.length; g++) {
  14439. for (var h = e[g], i = [], j = 0; j < h.length; j += 2) i.push([this.world.pxmi(h[j]), this.world.pxmi(h[j + 1])]);
  14440. for (var c = new p2.Convex(i), k = 0; k !== c.vertices.length; k++) {
  14441. var l = c.vertices[k];
  14442. p2.vec2.sub(l, l, c.centerOfMass)
  14443. }
  14444. p2.vec2.scale(f, c.centerOfMass, 1), f[0] -= this.world.pxmi(this.sprite.width / 2), f[1] -= this.world.pxmi(this.sprite.height / 2), c.updateTriangles(), c.updateCenterOfMass(), c.updateBoundingRadius(), c.collisionGroup = a.filter.categoryBits, c.collisionMask = a.filter.maskBits, c.sensor = a.isSensor, this.data.addShape(c, f), b.push(c)
  14445. }
  14446. return b
  14447. },
  14448. loadPolygon: function(a, b) {
  14449. for (var c = this.game.cache.getPhysicsData(a, b), d = p2.vec2.create(), e = 0; e < c.length; e++) {
  14450. for (var f = [], g = 0; g < c[e].shape.length; g += 2) f.push([this.world.pxmi(c[e].shape[g]), this.world.pxmi(c[e].shape[g + 1])]);
  14451. for (var h = new p2.Convex(f), i = 0; i !== h.vertices.length; i++) {
  14452. var j = h.vertices[i];
  14453. p2.vec2.sub(j, j, h.centerOfMass)
  14454. }
  14455. p2.vec2.scale(d, h.centerOfMass, 1), d[0] -= this.world.pxmi(this.sprite.width / 2), d[1] -= this.world.pxmi(this.sprite.height / 2), h.updateTriangles(), h.updateCenterOfMass(), h.updateBoundingRadius(), this.data.addShape(h, d)
  14456. }
  14457. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), !0
  14458. },
  14459. loadData: function(a, b) {
  14460. var c = this.game.cache.getPhysicsData(a, b);
  14461. return c && c.shape ? (this.mass = c.density, this.loadPolygon(a, b)) : void 0
  14462. }
  14463. }, Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body, Phaser.Physics.P2.Body.DYNAMIC = 1, Phaser.Physics.P2.Body.STATIC = 2, Phaser.Physics.P2.Body.KINEMATIC = 4, Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
  14464. get: function() {
  14465. return this.data.motionState === Phaser.Physics.P2.Body.STATIC
  14466. },
  14467. set: function(a) {
  14468. a && this.data.motionState !== Phaser.Physics.P2.Body.STATIC ? (this.data.motionState = Phaser.Physics.P2.Body.STATIC, this.mass = 0) : a || this.data.motionState !== Phaser.Physics.P2.Body.STATIC || (this.data.motionState = Phaser.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1))
  14469. }
  14470. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
  14471. get: function() {
  14472. return this.data.motionState === Phaser.Physics.P2.Body.DYNAMIC
  14473. },
  14474. set: function(a) {
  14475. a && this.data.motionState !== Phaser.Physics.P2.Body.DYNAMIC ? (this.data.motionState = Phaser.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1)) : a || this.data.motionState !== Phaser.Physics.P2.Body.DYNAMIC || (this.data.motionState = Phaser.Physics.P2.Body.STATIC, this.mass = 0)
  14476. }
  14477. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
  14478. get: function() {
  14479. return this.data.motionState === Phaser.Physics.P2.Body.KINEMATIC
  14480. },
  14481. set: function(a) {
  14482. a && this.data.motionState !== Phaser.Physics.P2.Body.KINEMATIC ? (this.data.motionState = Phaser.Physics.P2.Body.KINEMATIC, this.mass = 4) : a || this.data.motionState !== Phaser.Physics.P2.Body.KINEMATIC || (this.data.motionState = Phaser.Physics.P2.Body.STATIC, this.mass = 0)
  14483. }
  14484. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
  14485. get: function() {
  14486. return this.data.allowSleep
  14487. },
  14488. set: function(a) {
  14489. a !== this.data.allowSleep && (this.data.allowSleep = a)
  14490. }
  14491. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angle", {
  14492. get: function() {
  14493. return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.data.angle))
  14494. },
  14495. set: function(a) {
  14496. this.data.angle = Phaser.Math.degToRad(Phaser.Math.wrapAngle(a))
  14497. }
  14498. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
  14499. get: function() {
  14500. return this.data.angularDamping
  14501. },
  14502. set: function(a) {
  14503. this.data.angularDamping = a
  14504. }
  14505. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
  14506. get: function() {
  14507. return this.data.angularForce
  14508. },
  14509. set: function(a) {
  14510. this.data.angularForce = a
  14511. }
  14512. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
  14513. get: function() {
  14514. return this.data.angularVelocity
  14515. },
  14516. set: function(a) {
  14517. this.data.angularVelocity = a
  14518. }
  14519. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
  14520. get: function() {
  14521. return this.data.damping
  14522. },
  14523. set: function(a) {
  14524. this.data.damping = a
  14525. }
  14526. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
  14527. get: function() {
  14528. return this.data.fixedRotation
  14529. },
  14530. set: function(a) {
  14531. a !== this.data.fixedRotation && (this.data.fixedRotation = a)
  14532. }
  14533. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
  14534. get: function() {
  14535. return this.data.inertia
  14536. },
  14537. set: function(a) {
  14538. this.data.inertia = a
  14539. }
  14540. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
  14541. get: function() {
  14542. return this.data.mass
  14543. },
  14544. set: function(a) {
  14545. a !== this.data.mass && (this.data.mass = a, this.data.updateMassProperties())
  14546. }
  14547. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
  14548. get: function() {
  14549. return this.data.motionState
  14550. },
  14551. set: function(a) {
  14552. a !== this.data.motionState && (this.data.motionState = a)
  14553. }
  14554. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "rotation", {
  14555. get: function() {
  14556. return this.data.angle
  14557. },
  14558. set: function(a) {
  14559. this.data.angle = a
  14560. }
  14561. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
  14562. get: function() {
  14563. return this.data.sleepSpeedLimit
  14564. },
  14565. set: function(a) {
  14566. this.data.sleepSpeedLimit = a
  14567. }
  14568. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
  14569. get: function() {
  14570. return this.world.mpxi(this.data.position[0])
  14571. },
  14572. set: function(a) {
  14573. this.data.position[0] = this.world.pxmi(a)
  14574. }
  14575. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
  14576. get: function() {
  14577. return this.world.mpxi(this.data.position[1])
  14578. },
  14579. set: function(a) {
  14580. this.data.position[1] = this.world.pxmi(a)
  14581. }
  14582. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
  14583. get: function() {
  14584. return this.data.id
  14585. }
  14586. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
  14587. get: function() {
  14588. return null !== this.debugBody
  14589. },
  14590. set: function(a) {
  14591. a && !this.debugBody ? this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data) : !a && this.debugBody && (this.debugBody.destroy(), this.debugBody = null)
  14592. }
  14593. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "collideWorldBounds", {
  14594. get: function() {
  14595. return this._collideWorldBounds
  14596. },
  14597. set: function(a) {
  14598. a && !this._collideWorldBounds ? (this._collideWorldBounds = !0, this.updateCollisionMask()) : !a && this._collideWorldBounds && (this._collideWorldBounds = !1, this.updateCollisionMask())
  14599. }
  14600. }), Phaser.Physics.P2.BodyDebug = function(a, b, c) {
  14601. Phaser.Group.call(this, a);
  14602. var d = {
  14603. pixelsPerLengthUnit: 20,
  14604. debugPolygons: !1,
  14605. lineWidth: 1,
  14606. alpha: .5
  14607. };
  14608. this.settings = Phaser.Utils.extend(d, c), this.ppu = this.settings.pixelsPerLengthUnit, this.ppu = -1 * this.ppu, this.body = b, this.canvas = new Phaser.Graphics(a), this.canvas.alpha = this.settings.alpha, this.add(this.canvas), this.draw()
  14609. }, Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype), Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug, Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
  14610. update: function() {
  14611. this.updateSpriteTransform()
  14612. },
  14613. updateSpriteTransform: function() {
  14614. return this.position.x = this.body.position[0] * this.ppu, this.position.y = this.body.position[1] * this.ppu, this.rotation = this.body.angle
  14615. },
  14616. draw: function() {
  14617. var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o;
  14618. if (h = this.body, j = this.canvas, j.clear(), c = parseInt(this.randomPastelHex(), 16), f = 16711680, g = this.lineWidth, h instanceof p2.Body && h.shapes.length) {
  14619. var p = h.shapes.length;
  14620. for (d = 0; d !== p;) {
  14621. if (b = h.shapes[d], i = h.shapeOffsets[d], a = h.shapeAngles[d], i = i || 0, a = a || 0, b instanceof p2.Circle) this.drawCircle(j, i[0] * this.ppu, i[1] * this.ppu, a, b.radius * this.ppu, c, g);
  14622. else if (b instanceof p2.Convex) {
  14623. for (l = [], m = p2.vec2.create(), e = n = 0, o = b.vertices.length; o >= 0 ? o > n : n > o; e = o >= 0 ? ++n : --n) k = b.vertices[e], p2.vec2.rotate(m, k, a), l.push([(m[0] + i[0]) * this.ppu, -(m[1] + i[1]) * this.ppu]);
  14624. this.drawConvex(j, l, b.triangles, f, c, g, this.settings.debugPolygons, [i[0] * this.ppu, -i[1] * this.ppu])
  14625. } else b instanceof p2.Plane ? this.drawPlane(j, i[0] * this.ppu, -i[1] * this.ppu, c, f, 5 * g, 10 * g, 10 * g, 100 * this.ppu, a) : b instanceof p2.Line ? this.drawLine(j, b.length * this.ppu, f, g) : b instanceof p2.Rectangle && this.drawRectangle(j, i[0] * this.ppu, -i[1] * this.ppu, a, b.width * this.ppu, b.height * this.ppu, f, c, g);
  14626. d++
  14627. }
  14628. }
  14629. },
  14630. drawRectangle: function(a, b, c, d, e, f, g, h, i) {
  14631. "undefined" == typeof i && (i = 1), "undefined" == typeof g && (g = 0), a.lineStyle(i, g, 1), a.beginFill(h), a.drawRect(b - e / 2, c - f / 2, e, f)
  14632. },
  14633. drawCircle: function(a, b, c, d, e, f, g) {
  14634. "undefined" == typeof g && (g = 1), "undefined" == typeof f && (f = 16777215), a.lineStyle(g, 0, 1), a.beginFill(f, 1), a.drawCircle(b, c, -e), a.endFill(), a.moveTo(b, c), a.lineTo(b + e * Math.cos(-d), c + e * Math.sin(-d))
  14635. },
  14636. drawLine: function(a, b, c, d) {
  14637. "undefined" == typeof d && (d = 1), "undefined" == typeof c && (c = 0), a.lineStyle(5 * d, c, 1), a.moveTo(-b / 2, 0), a.lineTo(b / 2, 0)
  14638. },
  14639. drawConvex: function(a, b, c, d, e, f, g, h) {
  14640. var i, j, k, l, m, n, o, p, q, r, s;
  14641. if ("undefined" == typeof f && (f = 1), "undefined" == typeof d && (d = 0), g) {
  14642. for (i = [16711680, 65280, 255], j = 0; j !== b.length + 1;) l = b[j % b.length], m = b[(j + 1) % b.length], o = l[0], r = l[1], p = m[0], s = m[1], a.lineStyle(f, i[j % i.length], 1), a.moveTo(o, -r), a.lineTo(p, -s), a.drawCircle(o, -r, 2 * f), j++;
  14643. return a.lineStyle(f, 0, 1), a.drawCircle(h[0], h[1], 2 * f)
  14644. }
  14645. for (a.lineStyle(f, d, 1), a.beginFill(e), j = 0; j !== b.length;) k = b[j], n = k[0], q = k[1], 0 === j ? a.moveTo(n, -q) : a.lineTo(n, -q), j++;
  14646. return a.endFill(), b.length > 2 ? (a.moveTo(b[b.length - 1][0], -b[b.length - 1][1]), a.lineTo(b[0][0], -b[0][1])) : void 0
  14647. },
  14648. drawPath: function(a, b, c, d, e) {
  14649. var f, g, h, i, j, k, l, m, n, o, p, q, r;
  14650. for ("undefined" == typeof e && (e = 1), "undefined" == typeof c && (c = 0), a.lineStyle(e, c, 1), "number" == typeof d && a.beginFill(d), h = null, i = null, g = 0; g < b.length;) p = b[g], q = p[0], r = p[1], (q !== h || r !== i) && (0 === g ? a.moveTo(q, r) : (j = h, k = i, l = q, m = r, n = b[(g + 1) % b.length][0], o = b[(g + 1) % b.length][1], f = (l - j) * (o - k) - (n - j) * (m - k), 0 !== f && a.lineTo(q, r)), h = q, i = r), g++;
  14651. "number" == typeof d && a.endFill(), b.length > 2 && "number" == typeof d && (a.moveTo(b[b.length - 1][0], b[b.length - 1][1]), a.lineTo(b[0][0], b[0][1]))
  14652. },
  14653. drawPlane: function(a, b, c, d, e, f, g, h, i, j) {
  14654. var k, l, m;
  14655. "undefined" == typeof f && (f = 1), "undefined" == typeof d && (d = 16777215), a.lineStyle(f, e, 11), a.beginFill(d), k = i, a.moveTo(b, -c), l = b + Math.cos(j) * this.game.width, m = c + Math.sin(j) * this.game.height, a.lineTo(l, -m), a.moveTo(b, -c), l = b + Math.cos(j) * -this.game.width, m = c + Math.sin(j) * -this.game.height, a.lineTo(l, -m)
  14656. },
  14657. randomPastelHex: function() {
  14658. var a, b, c, d;
  14659. return c = [255, 255, 255], d = Math.floor(256 * Math.random()), b = Math.floor(256 * Math.random()), a = Math.floor(256 * Math.random()), d = Math.floor((d + 3 * c[0]) / 4), b = Math.floor((b + 3 * c[1]) / 4), a = Math.floor((a + 3 * c[2]) / 4), this.rgbToHex(d, b, a)
  14660. },
  14661. rgbToHex: function(a, b, c) {
  14662. return this.componentToHex(a) + this.componentToHex(b) + this.componentToHex(c)
  14663. },
  14664. componentToHex: function(a) {
  14665. var b;
  14666. return b = a.toString(16), 2 === b.len ? b : b + "0"
  14667. }
  14668. }), Phaser.Physics.P2.Spring = function(a, b, c, d, e, f, g, h, i, j) {
  14669. this.game = a.game, this.world = a, "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = 100), "undefined" == typeof f && (f = 1), d = a.pxm(d);
  14670. var k = {
  14671. restLength: d,
  14672. stiffness: e,
  14673. damping: f
  14674. };
  14675. "undefined" != typeof g && null !== g && (k.worldAnchorA = [a.pxm(g[0]), a.pxm(g[1])]), "undefined" != typeof h && null !== h && (k.worldAnchorB = [a.pxm(h[0]), a.pxm(h[1])]), "undefined" != typeof i && null !== i && (k.localAnchorA = [a.pxm(i[0]), a.pxm(i[1])]), "undefined" != typeof j && null !== j && (k.localAnchorB = [a.pxm(j[0]), a.pxm(j[1])]), p2.Spring.call(this, b, c, k)
  14676. }, Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype), Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring, Phaser.Physics.P2.Material = function(a) {
  14677. this.name = a, p2.Material.call(this)
  14678. }, Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype), Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material, Phaser.Physics.P2.ContactMaterial = function(a, b, c) {
  14679. p2.ContactMaterial.call(this, a, b, c)
  14680. }, Phaser.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype), Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial, Phaser.Physics.P2.CollisionGroup = function(a) {
  14681. this.mask = a
  14682. }, Phaser.Physics.P2.DistanceConstraint = function(a, b, c, d, e) {
  14683. "undefined" == typeof d && (d = 100), this.game = a.game, this.world = a, d = a.pxm(d), p2.DistanceConstraint.call(this, b, c, d, {
  14684. maxForce: e
  14685. })
  14686. }, Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype), Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint, Phaser.Physics.P2.GearConstraint = function(a, b, c, d, e) {
  14687. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 1), this.game = a.game, this.world = a;
  14688. var f = {
  14689. angle: d,
  14690. ratio: e
  14691. };
  14692. p2.GearConstraint.call(this, b, c, f)
  14693. }, Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype), Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint, Phaser.Physics.P2.LockConstraint = function(a, b, c, d, e, f) {
  14694. "undefined" == typeof d && (d = [0, 0]), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = Number.MAX_VALUE), this.game = a.game, this.world = a, d = [a.pxm(d[0]), a.pxm(d[1])];
  14695. var g = {
  14696. localOffsetB: d,
  14697. localAngleB: e,
  14698. maxForce: f
  14699. };
  14700. p2.LockConstraint.call(this, b, c, g)
  14701. }, Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype), Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint, Phaser.Physics.P2.PrismaticConstraint = function(a, b, c, d, e, f, g, h) {
  14702. "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = [0, 0]), "undefined" == typeof f && (f = [0, 0]), "undefined" == typeof g && (g = [0, 0]), "undefined" == typeof h && (h = Number.MAX_VALUE), this.game = a.game, this.world = a, e = [a.pxmi(e[0]), a.pxmi(e[1])], f = [a.pxmi(f[0]), a.pxmi(f[1])];
  14703. var i = {
  14704. localAnchorA: e,
  14705. localAnchorB: f,
  14706. localAxisA: g,
  14707. maxForce: h,
  14708. disableRotationalLock: !d
  14709. };
  14710. p2.PrismaticConstraint.call(this, b, c, i)
  14711. }, Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype), Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint, Phaser.Physics.P2.RevoluteConstraint = function(a, b, c, d, e, f) {
  14712. "undefined" == typeof f && (f = Number.MAX_VALUE), this.game = a.game, this.world = a, c = [a.pxmi(c[0]), a.pxmi(c[1])], e = [a.pxmi(e[0]), a.pxmi(e[1])], p2.RevoluteConstraint.call(this, b, c, d, e, {
  14713. maxForce: f
  14714. })
  14715. }, Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype), Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
  14716. //# sourceMappingURL=phaser.map