phaser.min.js 856 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185
  1. /* Phaser v2.3.0 - http://phaser.io - @photonstorm - (c) 2015 Photon Storm Ltd. */
  2. (function() {
  3. var a = this,
  4. b = b || {};
  5. b.WEBGL_RENDERER = 0, b.CANVAS_RENDERER = 1, b.VERSION = "v2.2.8", b._UID = 0, "undefined" != typeof Float32Array ? (b.Float32Array = Float32Array, b.Uint16Array = Uint16Array, b.Uint32Array = Uint32Array, b.ArrayBuffer = ArrayBuffer) : (b.Float32Array = Array, b.Uint16Array = Array), b.PI_2 = 2 * Math.PI, b.RAD_TO_DEG = 180 / Math.PI, b.DEG_TO_RAD = Math.PI / 180, b.RETINA_PREFIX = "@2x", b.defaultRenderOptions = {
  6. view: null,
  7. transparent: !1,
  8. antialias: !1,
  9. preserveDrawingBuffer: !1,
  10. resolution: 1,
  11. clearBeforeRender: !0,
  12. autoResize: !1
  13. }, b.DisplayObject = function() {
  14. this.position = new b.Point(0, 0), this.scale = new b.Point(1, 1), this.transformCallback = null, this.transformCallbackContext = null, this.pivot = new b.Point(0, 0), this.rotation = 0, this.alpha = 1, this.visible = !0, this.hitArea = null, this.renderable = !1, this.parent = null, this.stage = null, this.worldAlpha = 1, this.worldTransform = new b.Matrix, 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
  15. }, b.DisplayObject.prototype.constructor = b.DisplayObject, b.DisplayObject.prototype.destroy = function() {
  16. if (this.children) {
  17. for (var a = this.children.length; a--;) this.children[a].destroy();
  18. this.children = []
  19. }
  20. this.transformCallback = null, this.transformCallbackContext = null, this.hitArea = null, this.parent = null, this.stage = null, this.worldTransform = null, this.filterArea = null, this._bounds = null, this._currentBounds = null, this._mask = null, this.renderable = !1, this._destroyCachedSprite()
  21. }, Object.defineProperty(b.DisplayObject.prototype, "worldVisible", {
  22. get: function() {
  23. var a = this;
  24. do {
  25. if (!a.visible) return !1;
  26. a = a.parent
  27. } while (a);
  28. return !0
  29. }
  30. }), Object.defineProperty(b.DisplayObject.prototype, "mask", {
  31. get: function() {
  32. return this._mask
  33. },
  34. set: function(a) {
  35. this._mask && (this._mask.isMask = !1), this._mask = a, this._mask && (this._mask.isMask = !0)
  36. }
  37. }), Object.defineProperty(b.DisplayObject.prototype, "filters", {
  38. get: function() {
  39. return this._filters
  40. },
  41. set: function(a) {
  42. if (a) {
  43. for (var b = [], c = 0; c < a.length; c++)
  44. for (var d = a[c].passes, e = 0; e < d.length; e++) b.push(d[e]);
  45. this._filterBlock = {
  46. target: this,
  47. filterPasses: b
  48. }
  49. }
  50. this._filters = a
  51. }
  52. }), Object.defineProperty(b.DisplayObject.prototype, "cacheAsBitmap", {
  53. get: function() {
  54. return this._cacheAsBitmap
  55. },
  56. set: function(a) {
  57. this._cacheAsBitmap !== a && (a ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = a)
  58. }
  59. }), b.DisplayObject.prototype.updateTransform = function() {
  60. if (this.parent) {
  61. var a, c, d, e, f, g, h = this.parent.worldTransform,
  62. i = this.worldTransform;
  63. this.rotation % b.PI_2 ? (this.rotation !== this.rotationCache && (this.rotationCache = this.rotation, this._sr = Math.sin(this.rotation), this._cr = Math.cos(this.rotation)), a = this._cr * this.scale.x, c = this._sr * this.scale.x, d = -this._sr * this.scale.y, e = this._cr * this.scale.y, f = this.position.x, g = this.position.y, (this.pivot.x || this.pivot.y) && (f -= this.pivot.x * a + this.pivot.y * d, g -= this.pivot.x * c + this.pivot.y * e), i.a = a * h.a + c * h.c, i.b = a * h.b + c * h.d, i.c = d * h.a + e * h.c, i.d = d * h.b + e * h.d, i.tx = f * h.a + g * h.c + h.tx, i.ty = f * h.b + g * h.d + h.ty) : (a = this.scale.x, e = this.scale.y, f = this.position.x - this.pivot.x * a, g = this.position.y - this.pivot.y * e, i.a = a * h.a, i.b = a * h.b, i.c = e * h.c, i.d = e * h.d, i.tx = f * h.a + g * h.c + h.tx, i.ty = f * h.b + g * h.d + h.ty), this.worldAlpha = this.alpha * this.parent.worldAlpha, this.transformCallback && this.transformCallback.call(this.transformCallbackContext, i, h)
  64. }
  65. }, b.DisplayObject.prototype.displayObjectUpdateTransform = b.DisplayObject.prototype.updateTransform, b.DisplayObject.prototype.getBounds = function(a) {
  66. return a = a, b.EmptyRectangle
  67. }, b.DisplayObject.prototype.getLocalBounds = function() {
  68. return this.getBounds(b.identityMatrix)
  69. }, b.DisplayObject.prototype.setStageReference = function(a) {
  70. this.stage = a
  71. }, b.DisplayObject.prototype.preUpdate = function() {}, b.DisplayObject.prototype.generateTexture = function(a, c, d) {
  72. var e = this.getLocalBounds(),
  73. f = new b.RenderTexture(0 | e.width, 0 | e.height, d, c, a);
  74. return b.DisplayObject._tempMatrix.tx = -e.x, b.DisplayObject._tempMatrix.ty = -e.y, f.render(this, b.DisplayObject._tempMatrix), f
  75. }, b.DisplayObject.prototype.updateCache = function() {
  76. this._generateCachedSprite()
  77. }, b.DisplayObject.prototype.toGlobal = function(a) {
  78. return this.displayObjectUpdateTransform(), this.worldTransform.apply(a)
  79. }, b.DisplayObject.prototype.toLocal = function(a, b) {
  80. return b && (a = b.toGlobal(a)), this.displayObjectUpdateTransform(), this.worldTransform.applyInverse(a)
  81. }, b.DisplayObject.prototype._renderCachedSprite = function(a) {
  82. this._cachedSprite.worldAlpha = this.worldAlpha, a.gl ? b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a) : b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a)
  83. }, b.DisplayObject.prototype._generateCachedSprite = function() {
  84. this._cacheAsBitmap = !1;
  85. var a = this.getLocalBounds();
  86. if (this._cachedSprite) this._cachedSprite.texture.resize(0 | a.width, 0 | a.height);
  87. else {
  88. var c = new b.RenderTexture(0 | a.width, 0 | a.height);
  89. this._cachedSprite = new b.Sprite(c), this._cachedSprite.worldTransform = this.worldTransform
  90. }
  91. var d = this._filters;
  92. this._filters = null, this._cachedSprite.filters = d, b.DisplayObject._tempMatrix.tx = -a.x, b.DisplayObject._tempMatrix.ty = -a.y, this._cachedSprite.texture.render(this, b.DisplayObject._tempMatrix, !0), this._cachedSprite.anchor.x = -(a.x / a.width), this._cachedSprite.anchor.y = -(a.y / a.height), this._filters = d, this._cacheAsBitmap = !0
  93. }, b.DisplayObject.prototype._destroyCachedSprite = function() {
  94. this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null)
  95. }, b.DisplayObject.prototype._renderWebGL = function(a) {
  96. a = a
  97. }, b.DisplayObject.prototype._renderCanvas = function(a) {
  98. a = a
  99. }, Object.defineProperty(b.DisplayObject.prototype, "x", {
  100. get: function() {
  101. return this.position.x
  102. },
  103. set: function(a) {
  104. this.position.x = a
  105. }
  106. }), Object.defineProperty(b.DisplayObject.prototype, "y", {
  107. get: function() {
  108. return this.position.y
  109. },
  110. set: function(a) {
  111. this.position.y = a
  112. }
  113. }), b.DisplayObjectContainer = function() {
  114. b.DisplayObject.call(this), this.children = []
  115. }, b.DisplayObjectContainer.prototype = Object.create(b.DisplayObject.prototype), b.DisplayObjectContainer.prototype.constructor = b.DisplayObjectContainer, Object.defineProperty(b.DisplayObjectContainer.prototype, "width", {
  116. get: function() {
  117. return this.scale.x * this.getLocalBounds().width
  118. },
  119. set: function(a) {
  120. var b = this.getLocalBounds().width;
  121. this.scale.x = 0 !== b ? a / b : 1, this._width = a
  122. }
  123. }), Object.defineProperty(b.DisplayObjectContainer.prototype, "height", {
  124. get: function() {
  125. return this.scale.y * this.getLocalBounds().height
  126. },
  127. set: function(a) {
  128. var b = this.getLocalBounds().height;
  129. this.scale.y = 0 !== b ? a / b : 1, this._height = a
  130. }
  131. }), b.DisplayObjectContainer.prototype.addChild = function(a) {
  132. return this.addChildAt(a, this.children.length)
  133. }, b.DisplayObjectContainer.prototype.addChildAt = function(a, b) {
  134. 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;
  135. throw new Error(a + "addChildAt: The index " + b + " supplied is out of bounds " + this.children.length)
  136. }, b.DisplayObjectContainer.prototype.swapChildren = function(a, b) {
  137. if (a !== b) {
  138. var c = this.getChildIndex(a),
  139. d = this.getChildIndex(b);
  140. if (0 > c || 0 > d) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
  141. this.children[c] = b, this.children[d] = a
  142. }
  143. }, b.DisplayObjectContainer.prototype.getChildIndex = function(a) {
  144. var b = this.children.indexOf(a);
  145. if (-1 === b) throw new Error("The supplied DisplayObject must be a child of the caller");
  146. return b
  147. }, b.DisplayObjectContainer.prototype.setChildIndex = function(a, b) {
  148. if (0 > b || b >= this.children.length) throw new Error("The supplied index is out of bounds");
  149. var c = this.getChildIndex(a);
  150. this.children.splice(c, 1), this.children.splice(b, 0, a)
  151. }, b.DisplayObjectContainer.prototype.getChildAt = function(a) {
  152. if (0 > a || a >= this.children.length) throw new Error("getChildAt: Supplied index " + a + " does not exist in the child list, or the supplied DisplayObject must be a child of the caller");
  153. return this.children[a]
  154. }, b.DisplayObjectContainer.prototype.removeChild = function(a) {
  155. var b = this.children.indexOf(a);
  156. if (-1 !== b) return this.removeChildAt(b)
  157. }, b.DisplayObjectContainer.prototype.removeChildAt = function(a) {
  158. var b = this.getChildAt(a);
  159. return this.stage && b.removeStageReference(), b.parent = void 0, this.children.splice(a, 1), b
  160. }, b.DisplayObjectContainer.prototype.removeChildren = function(a, b) {
  161. var c = a || 0,
  162. d = "number" == typeof b ? b : this.children.length,
  163. e = d - c;
  164. if (e > 0 && d >= e) {
  165. for (var f = this.children.splice(c, e), g = 0; g < f.length; g++) {
  166. var h = f[g];
  167. this.stage && h.removeStageReference(), h.parent = void 0
  168. }
  169. return f
  170. }
  171. if (0 === e && 0 === this.children.length) return [];
  172. throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")
  173. }, b.DisplayObjectContainer.prototype.updateTransform = function() {
  174. if (this.visible && (this.displayObjectUpdateTransform(), !this._cacheAsBitmap))
  175. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].updateTransform()
  176. }, b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform = b.DisplayObjectContainer.prototype.updateTransform, b.DisplayObjectContainer.prototype.getBounds = function() {
  177. if (0 === this.children.length) return b.EmptyRectangle;
  178. for (var a, c, d, e = 1 / 0, f = 1 / 0, g = -1 / 0, h = -1 / 0, i = !1, j = 0, k = this.children.length; k > j; j++) {
  179. var l = this.children[j];
  180. l.visible && (i = !0, a = this.children[j].getBounds(), e = e < a.x ? e : a.x, f = f < a.y ? f : a.y, c = a.width + a.x, d = a.height + a.y, g = g > c ? g : c, h = h > d ? h : d)
  181. }
  182. if (!i) return b.EmptyRectangle;
  183. var m = this._bounds;
  184. return m.x = e, m.y = f, m.width = g - e, m.height = h - f, m
  185. }, b.DisplayObjectContainer.prototype.getLocalBounds = function() {
  186. var a = this.worldTransform;
  187. this.worldTransform = b.identityMatrix;
  188. for (var c = 0, d = this.children.length; d > c; c++) this.children[c].updateTransform();
  189. var e = this.getBounds();
  190. return this.worldTransform = a, e
  191. }, b.DisplayObjectContainer.prototype.setStageReference = function(a) {
  192. this.stage = a;
  193. for (var b = 0; b < this.children.length; b++) this.children[b].setStageReference(a)
  194. }, b.DisplayObjectContainer.prototype.removeStageReference = function() {
  195. for (var a = 0; a < this.children.length; a++) this.children[a].removeStageReference();
  196. this.stage = null
  197. }, b.DisplayObjectContainer.prototype._renderWebGL = function(a) {
  198. if (this.visible && !(this.alpha <= 0)) {
  199. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  200. var b;
  201. if (this._mask || this._filters) {
  202. 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; b < this.children.length; b++) this.children[b]._renderWebGL(a);
  203. a.spriteBatch.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), a.spriteBatch.start()
  204. } else
  205. for (b = 0; b < this.children.length; b++) this.children[b]._renderWebGL(a)
  206. }
  207. }, b.DisplayObjectContainer.prototype._renderCanvas = function(a) {
  208. if (this.visible !== !1 && 0 !== this.alpha) {
  209. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  210. this._mask && a.maskManager.pushMask(this._mask, a);
  211. for (var b = 0; b < this.children.length; b++) this.children[b]._renderCanvas(a);
  212. this._mask && a.maskManager.popMask(a)
  213. }
  214. }, b.Sprite = function(a) {
  215. b.DisplayObjectContainer.call(this), this.anchor = new b.Point, this.texture = a || b.Texture.emptyTexture, this._width = 0, this._height = 0, this.tint = 16777215, this.blendMode = b.blendModes.NORMAL, this.shader = null, this.texture.baseTexture.hasLoaded && this.onTextureUpdate(), this.renderable = !0
  216. }, b.Sprite.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Sprite.prototype.constructor = b.Sprite, Object.defineProperty(b.Sprite.prototype, "width", {
  217. get: function() {
  218. return this.scale.x * this.texture.frame.width
  219. },
  220. set: function(a) {
  221. this.scale.x = a / this.texture.frame.width, this._width = a
  222. }
  223. }), Object.defineProperty(b.Sprite.prototype, "height", {
  224. get: function() {
  225. return this.scale.y * this.texture.frame.height
  226. },
  227. set: function(a) {
  228. this.scale.y = a / this.texture.frame.height, this._height = a
  229. }
  230. }), b.Sprite.prototype.setTexture = function(a) {
  231. this.texture = a, this.cachedTint = 16777215
  232. }, b.Sprite.prototype.onTextureUpdate = function() {
  233. this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height)
  234. }, b.Sprite.prototype.getBounds = function(a) {
  235. var b = this.texture.frame.width,
  236. c = this.texture.frame.height,
  237. d = b * (1 - this.anchor.x),
  238. e = b * -this.anchor.x,
  239. f = c * (1 - this.anchor.y),
  240. g = c * -this.anchor.y,
  241. h = a || this.worldTransform,
  242. i = h.a,
  243. j = h.b,
  244. k = h.c,
  245. l = h.d,
  246. m = h.tx,
  247. n = h.ty,
  248. o = -1 / 0,
  249. p = -1 / 0,
  250. q = 1 / 0,
  251. r = 1 / 0;
  252. if (0 === j && 0 === k) 0 > i && (i *= -1), 0 > l && (l *= -1), q = i * e + m, o = i * d + m, r = l * g + n, p = l * f + n;
  253. else {
  254. var s = i * e + k * g + m,
  255. t = l * g + j * e + n,
  256. u = i * d + k * g + m,
  257. v = l * g + j * d + n,
  258. w = i * d + k * f + m,
  259. x = l * f + j * d + n,
  260. y = i * e + k * f + m,
  261. z = l * f + j * e + n;
  262. q = q > s ? s : q, q = q > u ? u : q, q = q > w ? w : q, q = q > y ? y : q, r = r > t ? t : r, r = r > v ? v : r, r = r > x ? x : r, r = r > z ? z : r, o = s > o ? s : o, o = u > o ? u : o, o = w > o ? w : o, o = y > o ? y : o, p = t > p ? t : p, p = v > p ? v : p, p = x > p ? x : p, p = z > p ? z : p
  263. }
  264. var A = this._bounds;
  265. return A.x = q, A.width = o - q, A.y = r, A.height = p - r, this._currentBounds = A, A
  266. }, b.Sprite.prototype._renderWebGL = function(a) {
  267. if (this.visible && !(this.alpha <= 0) && this.renderable) {
  268. var b;
  269. if (this._mask || this._filters) {
  270. var c = a.spriteBatch;
  271. for (this._filters && (c.flush(), a.filterManager.pushFilter(this._filterBlock)), this._mask && (c.stop(), a.maskManager.pushMask(this.mask, a), c.start()), c.render(this), b = 0; b < this.children.length; b++) this.children[b]._renderWebGL(a);
  272. c.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), c.start()
  273. } else
  274. for (a.spriteBatch.render(this), b = 0; b < this.children.length; b++) this.children[b]._renderWebGL(a)
  275. }
  276. }, b.Sprite.prototype._renderCanvas = function(a) {
  277. if (!(this.visible === !1 || 0 === this.alpha || this.renderable === !1 || this.texture.crop.width <= 0 || this.texture.crop.height <= 0)) {
  278. if (this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, a.context.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a), this.texture.valid) {
  279. var c = this.texture.baseTexture.resolution / a.resolution;
  280. a.context.globalAlpha = this.worldAlpha, a.smoothProperty && a.scaleMode !== this.texture.baseTexture.scaleMode && (a.scaleMode = this.texture.baseTexture.scaleMode, a.context[a.smoothProperty] = a.scaleMode === b.scaleModes.LINEAR);
  281. var d = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width,
  282. e = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
  283. a.roundPixels ? (a.context.setTransform(this.worldTransform.a, this.worldTransform.b, this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * a.resolution | 0, this.worldTransform.ty * a.resolution | 0), d = 0 | d, e = 0 | e) : a.context.setTransform(this.worldTransform.a, this.worldTransform.b, this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * a.resolution, this.worldTransform.ty * a.resolution), 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, d / c, e / c, this.texture.crop.width / c, this.texture.crop.height / c)) : a.context.drawImage(this.texture.baseTexture.source, this.texture.crop.x, this.texture.crop.y, this.texture.crop.width, this.texture.crop.height, d / c, e / c, this.texture.crop.width / c, this.texture.crop.height / c)
  284. }
  285. for (var f = 0; f < this.children.length; f++) this.children[f]._renderCanvas(a);
  286. this._mask && a.maskManager.popMask(a)
  287. }
  288. }, b.Sprite.fromFrame = function(a) {
  289. var c = b.TextureCache[a];
  290. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache' + this);
  291. return new b.Sprite(c)
  292. }, b.Sprite.fromImage = function(a, c, d) {
  293. var e = b.Texture.fromImage(a, c, d);
  294. return new b.Sprite(e)
  295. }, b.SpriteBatch = function(a) {
  296. b.DisplayObjectContainer.call(this), this.textureThing = a, this.ready = !1
  297. }, b.SpriteBatch.prototype = Object.create(b.DisplayObjectContainer.prototype), b.SpriteBatch.prototype.constructor = b.SpriteBatch, b.SpriteBatch.prototype.initWebGL = function(a) {
  298. this.fastSpriteBatch = new b.WebGLFastSpriteBatch(a), this.ready = !0
  299. }, b.SpriteBatch.prototype.updateTransform = function() {
  300. this.displayObjectUpdateTransform()
  301. }, b.SpriteBatch.prototype._renderWebGL = function(a) {
  302. !this.visible || this.alpha <= 0 || !this.children.length || (this.ready || this.initWebGL(a.gl), this.fastSpriteBatch.gl !== a.gl && this.fastSpriteBatch.setContext(a.gl), a.spriteBatch.stop(), a.shaderManager.setShader(a.shaderManager.fastShader), this.fastSpriteBatch.begin(this, a), this.fastSpriteBatch.render(this), a.spriteBatch.start())
  303. }, b.SpriteBatch.prototype._renderCanvas = function(a) {
  304. if (this.visible && !(this.alpha <= 0) && this.children.length) {
  305. var b = a.context;
  306. b.globalAlpha = this.worldAlpha, this.displayObjectUpdateTransform();
  307. for (var c = this.worldTransform, d = !0, e = 0; e < this.children.length; e++) {
  308. var f = this.children[e];
  309. if (f.visible) {
  310. var g = f.texture,
  311. h = g.frame;
  312. if (b.globalAlpha = this.worldAlpha * f.alpha, f.rotation % (2 * Math.PI) === 0) d && (b.setTransform(c.a, c.b, c.c, c.d, c.tx, c.ty), d = !1), b.drawImage(g.baseTexture.source, h.x, h.y, h.width, h.height, f.anchor.x * -h.width * f.scale.x + f.position.x + .5 | 0, f.anchor.y * -h.height * f.scale.y + f.position.y + .5 | 0, h.width * f.scale.x, h.height * f.scale.y);
  313. else {
  314. d || (d = !0), f.displayObjectUpdateTransform();
  315. var i = f.worldTransform;
  316. a.roundPixels ? b.setTransform(i.a, i.b, i.c, i.d, 0 | i.tx, 0 | i.ty) : b.setTransform(i.a, i.b, i.c, i.d, i.tx, i.ty), b.drawImage(g.baseTexture.source, h.x, h.y, h.width, h.height, f.anchor.x * -h.width + .5 | 0, f.anchor.y * -h.height + .5 | 0, h.width, h.height)
  317. }
  318. }
  319. }
  320. }
  321. }, b.Text = function(a, c) {
  322. this.canvas = document.createElement("canvas"), this.context = this.canvas.getContext("2d"), this.resolution = 1, b.Sprite.call(this, b.Texture.fromCanvas(this.canvas)), this.setText(a), this.setStyle(c)
  323. }, b.Text.prototype = Object.create(b.Sprite.prototype), b.Text.prototype.constructor = b.Text, Object.defineProperty(b.Text.prototype, "width", {
  324. get: function() {
  325. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width
  326. },
  327. set: function(a) {
  328. this.scale.x = a / this.texture.frame.width, this._width = a
  329. }
  330. }), Object.defineProperty(b.Text.prototype, "height", {
  331. get: function() {
  332. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height
  333. },
  334. set: function(a) {
  335. this.scale.y = a / this.texture.frame.height, this._height = a
  336. }
  337. }), b.Text.prototype.setStyle = function(a) {
  338. 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.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
  339. }, b.Text.prototype.setText = function(a) {
  340. this.text = a.toString() || " ", this.dirty = !0
  341. }, b.Text.prototype.updateText = function() {
  342. this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
  343. var a = this.text;
  344. this.style.wordWrap && (a = this.wordWrap(this.text));
  345. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
  346. var g = this.context.measureText(b[f]).width;
  347. c[f] = g, d = Math.max(d, g)
  348. }
  349. var h = d + this.style.strokeThickness;
  350. this.style.dropShadow && (h += this.style.dropShadowDistance), this.canvas.width = (h + this.context.lineWidth) * this.resolution;
  351. var i = e.fontSize + this.style.strokeThickness,
  352. j = i * b.length;
  353. this.style.dropShadow && (j += this.style.dropShadowDistance), this.canvas.height = j * this.resolution, this.context.scale(this.resolution, this.resolution), 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 = "alphabetic";
  354. var k, l;
  355. if (this.style.dropShadow) {
  356. this.context.fillStyle = this.style.dropShadowColor;
  357. var m = Math.sin(this.style.dropShadowAngle) * this.style.dropShadowDistance,
  358. n = Math.cos(this.style.dropShadowAngle) * this.style.dropShadowDistance;
  359. for (f = 0; f < b.length; f++) k = this.style.strokeThickness / 2, l = this.style.strokeThickness / 2 + f * i + e.ascent, "right" === this.style.align ? k += d - c[f] : "center" === this.style.align && (k += (d - c[f]) / 2), this.style.fill && this.context.fillText(b[f], k + m, l + n)
  360. }
  361. for (this.context.fillStyle = this.style.fill, f = 0; f < b.length; f++) k = this.style.strokeThickness / 2, l = this.style.strokeThickness / 2 + f * i + e.ascent, "right" === this.style.align ? k += d - c[f] : "center" === this.style.align && (k += (d - c[f]) / 2), this.style.stroke && this.style.strokeThickness && this.context.strokeText(b[f], k, l), this.style.fill && this.context.fillText(b[f], k, l);
  362. this.updateTexture()
  363. }, b.Text.prototype.updateTexture = function() {
  364. 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.texture.baseTexture.dirty()
  365. }, b.Text.prototype._renderWebGL = function(a) {
  366. this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderWebGL.call(this, a)
  367. }, b.Text.prototype._renderCanvas = function(a) {
  368. this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderCanvas.call(this, a)
  369. }, b.Text.prototype.determineFontProperties = function(a) {
  370. var c = b.Text.fontPropertiesCache[a];
  371. if (!c) {
  372. c = {};
  373. var d = b.Text.fontPropertiesCanvas,
  374. e = b.Text.fontPropertiesContext;
  375. e.font = a;
  376. var f = Math.ceil(e.measureText("|MÉq").width),
  377. g = Math.ceil(e.measureText("|MÉq").width),
  378. h = 2 * g;
  379. g = 1.4 * g | 0, d.width = f, d.height = h, e.fillStyle = "#f00", e.fillRect(0, 0, f, h), e.font = a, e.textBaseline = "alphabetic", e.fillStyle = "#000", e.fillText("|MÉq", 0, g);
  380. var i, j, k = e.getImageData(0, 0, f, h).data,
  381. l = k.length,
  382. m = 4 * f,
  383. n = 0,
  384. o = !1;
  385. for (i = 0; g > i; i++) {
  386. for (j = 0; m > j; j += 4)
  387. if (255 !== k[n + j]) {
  388. o = !0;
  389. break
  390. }
  391. if (o) break;
  392. n += m
  393. }
  394. for (c.ascent = g - i, n = l - m, o = !1, i = h; i > g; i--) {
  395. for (j = 0; m > j; j += 4)
  396. if (255 !== k[n + j]) {
  397. o = !0;
  398. break
  399. }
  400. if (o) break;
  401. n -= m
  402. }
  403. c.descent = i - g, c.descent += 6, c.fontSize = c.ascent + c.descent, b.Text.fontPropertiesCache[a] = c
  404. }
  405. return c
  406. }, b.Text.prototype.wordWrap = function(a) {
  407. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  408. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  409. var h = this.context.measureText(f[g]).width,
  410. i = h + this.context.measureText(" ").width;
  411. 0 === g || i > e ? (g > 0 && (b += "\n"), b += f[g], e = this.style.wordWrapWidth - h) : (e -= i, b += " " + f[g])
  412. }
  413. d < c.length - 1 && (b += "\n")
  414. }
  415. return b
  416. }, b.Text.prototype.getBounds = function(a) {
  417. return this.dirty && (this.updateText(), this.dirty = !1), b.Sprite.prototype.getBounds.call(this, a)
  418. }, b.Text.prototype.destroy = function(a) {
  419. this.context = null, this.canvas = null, this.texture.destroy(void 0 === a ? !0 : a)
  420. }, b.Text.fontPropertiesCache = {}, b.Text.fontPropertiesCanvas = document.createElement("canvas"), b.Text.fontPropertiesContext = b.Text.fontPropertiesCanvas.getContext("2d"), b.BitmapText = function(a, c) {
  421. b.DisplayObjectContainer.call(this), this.textWidth = 0, this.textHeight = 0, this.maxWidth = 0, this.anchor = new Phaser.Point(0, 0), this._prevAnchor = new Phaser.Point(0, 0), this._pool = [], this.setText(a), this.setStyle(c), this.updateText(), this.dirty = !1
  422. }, b.BitmapText.prototype = Object.create(b.DisplayObjectContainer.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setText = function(a) {
  423. this.text = a || " ", this.dirty = !0
  424. }, b.BitmapText.prototype.setStyle = function(a) {
  425. a = a || {}, a.align = a.align || "left", this.style = a;
  426. var c = a.font.split(" ");
  427. 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
  428. }, b.BitmapText.prototype.updateText = function() {
  429. 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, k = 0; k < this.text.length; k++) {
  430. var l = this.text.charCodeAt(k);
  431. if (j = /(\s)/.test(this.text.charAt(k)) ? k : j, /(?:\r\n|\r|\n)/.test(this.text.charAt(k))) g.push(c.x), f = Math.max(f, c.x), h++, c.x = 0, c.y += a.lineHeight, d = null;
  432. else if (-1 !== j && this.maxWidth > 0 && c.x * i > this.maxWidth) e.splice(j, k - j), k = j, j = -1, g.push(lastLineWidth), f = Math.max(f, lastLineWidth), h++, c.x = 0, c.y += a.lineHeight, d = null;
  433. else {
  434. var m = a.chars[l];
  435. m && (d && m.kerning[d] && (c.x += m.kerning[d]), e.push({
  436. texture: m.texture,
  437. line: h,
  438. charCode: l,
  439. position: new b.Point(c.x + m.xOffset, c.y + m.yOffset)
  440. }), c.x += m.xAdvance, d = l)
  441. }
  442. }
  443. g.push(c.x), f = Math.max(f, c.x);
  444. var n = [];
  445. for (k = 0; h >= k; k++) {
  446. var o = 0;
  447. "right" === this.style.align ? o = f - g[k] : "center" === this.style.align && (o = (f - g[k]) / 2), n.push(o)
  448. }
  449. var p = this.children.length,
  450. q = e.length,
  451. r = this.tint || 16777215;
  452. this.textWidth = f * i, this.textHeight = (c.y + a.lineHeight) * i;
  453. var s = this.textWidth * this.anchor.x,
  454. t = this.textHeight * this.anchor.y;
  455. for (k = 0; q > k; k++) {
  456. var u = p > k ? this.children[k] : this._pool.pop();
  457. u ? u.setTexture(e[k].texture) : u = new b.Sprite(e[k].texture), u.position.x = (e[k].position.x + n[e[k].line]) * i - s, u.position.y = e[k].position.y * i - t, u.scale.x = u.scale.y = i, u.tint = r, u.parent || this.addChild(u)
  458. }
  459. for (; this.children.length > q;) {
  460. var v = this.getChildAt(this.children.length - 1);
  461. this._pool.push(v), this.removeChild(v)
  462. }
  463. }, b.BitmapText.prototype.updateTransform = function() {
  464. (this.dirty || !this.anchor.equals(this._prevAnchor)) && (this.updateText(), this.dirty = !1, this._prevAnchor.copyFrom(this.anchor)), b.DisplayObjectContainer.prototype.updateTransform.call(this)
  465. }, b.BitmapText.fonts = {}, b.Stage = function(a) {
  466. b.DisplayObjectContainer.call(this), this.worldTransform = new b.Matrix, this.stage = this, this.setBackgroundColor(a)
  467. }, b.Stage.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.updateTransform = function() {
  468. this.worldAlpha = 1;
  469. for (var a = 0; a < this.children.length; a++) this.children[a].updateTransform()
  470. }, b.Stage.prototype.setBackgroundColor = function(a) {
  471. this.backgroundColor = a || 0, this.backgroundColorSplit = b.hex2rgb(this.backgroundColor);
  472. var c = this.backgroundColor.toString(16);
  473. c = "000000".substr(0, 6 - c.length) + c, this.backgroundColorString = "#" + c
  474. }, b.hex2rgb = function(a) {
  475. return [(a >> 16 & 255) / 255, (a >> 8 & 255) / 255, (255 & a) / 255]
  476. }, b.rgb2hex = function(a) {
  477. return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
  478. }, b.canUseNewCanvasBlendModes = function() {
  479. if ("undefined" == typeof document) return !1;
  480. var a = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",
  481. b = "AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",
  482. c = new Image;
  483. c.src = a + "AP804Oa6" + b;
  484. var d = new Image;
  485. d.src = a + "/wCKxvRF" + b;
  486. var e = document.createElement("canvas");
  487. e.width = 6, e.height = 1;
  488. var f = e.getContext("2d");
  489. f.globalCompositeOperation = "multiply", f.drawImage(c, 0, 0), f.drawImage(d, 2, 0);
  490. var g = f.getImageData(2, 0, 1, 1).data;
  491. return 255 === g[0] && 0 === g[1] && 0 === g[2]
  492. }, b.getNextPowerOfTwo = function(a) {
  493. if (a > 0 && 0 === (a & a - 1)) return a;
  494. for (var b = 1; a > b;) b <<= 1;
  495. return b
  496. }, b.isPowerOfTwo = function(a, b) {
  497. return a > 0 && 0 === (a & a - 1) && b > 0 && 0 === (b & b - 1)
  498. }, b.PolyK = {}, b.PolyK.Triangulate = function(a) {
  499. var c = !0,
  500. d = a.length >> 1;
  501. if (3 > d) return [];
  502. for (var e = [], f = [], g = 0; d > g; g++) f.push(g);
  503. g = 0;
  504. for (var h = d; h > 3;) {
  505. var i = f[(g + 0) % h],
  506. j = f[(g + 1) % h],
  507. k = f[(g + 2) % h],
  508. l = a[2 * i],
  509. m = a[2 * i + 1],
  510. n = a[2 * j],
  511. o = a[2 * j + 1],
  512. p = a[2 * k],
  513. q = a[2 * k + 1],
  514. r = !1;
  515. if (b.PolyK._convex(l, m, n, o, p, q, c)) {
  516. r = !0;
  517. for (var s = 0; h > s; s++) {
  518. var t = f[s];
  519. if (t !== i && t !== j && t !== k && b.PolyK._PointInTriangle(a[2 * t], a[2 * t + 1], l, m, n, o, p, q)) {
  520. r = !1;
  521. break
  522. }
  523. }
  524. }
  525. if (r) e.push(i, j, k), f.splice((g + 1) % h, 1), h--, g = 0;
  526. else if (g++ > 3 * h) {
  527. if (!c) return null;
  528. for (e = [], f = [], g = 0; d > g; g++) f.push(g);
  529. g = 0, h = d, c = !1
  530. }
  531. }
  532. return e.push(f[0], f[1], f[2]), e
  533. }, b.PolyK._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  534. var i = g - c,
  535. j = h - d,
  536. k = e - c,
  537. l = f - d,
  538. m = a - c,
  539. n = b - d,
  540. o = i * i + j * j,
  541. p = i * k + j * l,
  542. q = i * m + j * n,
  543. r = k * k + l * l,
  544. s = k * m + l * n,
  545. t = 1 / (o * r - p * p),
  546. u = (r * q - p * s) * t,
  547. v = (o * s - p * q) * t;
  548. return u >= 0 && v >= 0 && 1 > u + v
  549. }, b.PolyK._convex = function(a, b, c, d, e, f, g) {
  550. return (b - d) * (e - c) + (c - a) * (f - d) >= 0 === g
  551. }, b.initDefaultShaders = function() {}, b.CompileVertexShader = function(a, c) {
  552. return b._CompileShader(a, c, a.VERTEX_SHADER)
  553. }, b.CompileFragmentShader = function(a, c) {
  554. return b._CompileShader(a, c, a.FRAGMENT_SHADER)
  555. }, b._CompileShader = function(a, b, c) {
  556. var d = b.join("\n"),
  557. e = a.createShader(c);
  558. return a.shaderSource(e, d), a.compileShader(e), a.getShaderParameter(e, a.COMPILE_STATUS) ? e : (window.console.log(a.getShaderInfoLog(e)), null)
  559. }, b.compileProgram = function(a, c, d) {
  560. var e = b.CompileFragmentShader(a, d),
  561. f = b.CompileVertexShader(a, c),
  562. g = a.createProgram();
  563. 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
  564. }, b.PixiShader = function(a) {
  565. 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.firstRun = !0, this.dirty = !0, this.attributes = [], this.init()
  566. }, b.PixiShader.prototype.constructor = b.PixiShader, b.PixiShader.prototype.init = function() {
  567. var a = this.gl,
  568. c = b.compileProgram(a, this.vertexSrc || b.PixiShader.defaultVertexSrc, this.fragmentSrc);
  569. 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];
  570. for (var d in this.uniforms) this.uniforms[d].uniformLocation = a.getUniformLocation(c, d);
  571. this.initUniforms(), this.program = c
  572. }, b.PixiShader.prototype.initUniforms = function() {
  573. this.textureCount = 1;
  574. var a, b = this.gl;
  575. for (var c in this.uniforms) {
  576. a = this.uniforms[c];
  577. var d = a.type;
  578. "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)
  579. }
  580. }, b.PixiShader.prototype.initSampler2D = function(a) {
  581. if (a.value && a.value.baseTexture && a.value.baseTexture.hasLoaded) {
  582. var b = this.gl;
  583. if (b.activeTexture(b["TEXTURE" + this.textureCount]), b.bindTexture(b.TEXTURE_2D, a.value.baseTexture._glTextures[b.id]), a.textureData) {
  584. var c = a.textureData,
  585. d = c.magFilter ? c.magFilter : b.LINEAR,
  586. e = c.minFilter ? c.minFilter : b.LINEAR,
  587. f = c.wrapS ? c.wrapS : b.CLAMP_TO_EDGE,
  588. g = c.wrapT ? c.wrapT : b.CLAMP_TO_EDGE,
  589. h = c.luminance ? b.LUMINANCE : b.RGBA;
  590. if (c.repeat && (f = b.REPEAT, g = b.REPEAT), b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL, !!c.flipY), c.width) {
  591. var i = c.width ? c.width : 512,
  592. j = c.height ? c.height : 2,
  593. k = c.border ? c.border : 0;
  594. b.texImage2D(b.TEXTURE_2D, 0, h, i, j, k, h, b.UNSIGNED_BYTE, null)
  595. } else b.texImage2D(b.TEXTURE_2D, 0, h, b.RGBA, b.UNSIGNED_BYTE, a.value.baseTexture.source);
  596. 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)
  597. }
  598. b.uniform1i(a.uniformLocation, this.textureCount), a._init = !0, this.textureCount++
  599. }
  600. }, b.PixiShader.prototype.syncUniforms = function() {
  601. this.textureCount = 1;
  602. var a, c = this.gl;
  603. 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]), a.value.baseTexture._dirty[c.id] ? b.instances[c.id].updateTexture(a.value.baseTexture) : c.bindTexture(c.TEXTURE_2D, a.value.baseTexture._glTextures[c.id]), c.uniform1i(a.uniformLocation, this.textureCount), this.textureCount++) : this.initSampler2D(a))
  604. }, b.PixiShader.prototype.destroy = function() {
  605. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  606. }, b.PixiShader.defaultVertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "attribute vec4 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;", " vColor = vec4(aColor.rgb * aColor.a, aColor.a);", "}"], b.PixiFastShader = function(a) {
  607. 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()
  608. }, b.PixiFastShader.prototype.constructor = b.PixiFastShader, b.PixiFastShader.prototype.init = function() {
  609. var a = this.gl,
  610. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  611. 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
  612. }, b.PixiFastShader.prototype.destroy = function() {
  613. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  614. }, b.StripShader = function(a) {
  615. 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)) * alpha;", "}"], 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()
  616. }, b.StripShader.prototype.constructor = b.StripShader, b.StripShader.prototype.init = function() {
  617. var a = this.gl,
  618. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  619. 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
  620. }, b.StripShader.prototype.destroy = function() {
  621. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  622. }, b.PrimitiveShader = function(a) {
  623. 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 float flipY;", "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 * -flipY) + flipY , 0.0, 1.0);", " vColor = aColor * vec4(tint * alpha, alpha);", "}"], this.init()
  624. }, b.PrimitiveShader.prototype.constructor = b.PrimitiveShader, b.PrimitiveShader.prototype.init = function() {
  625. var a = this.gl,
  626. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  627. a.useProgram(c), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.tintColor = a.getUniformLocation(c, "tint"), this.flipY = a.getUniformLocation(c, "flipY"), 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
  628. }, b.PrimitiveShader.prototype.destroy = function() {
  629. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  630. }, b.ComplexPrimitiveShader = function(a) {
  631. 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;", "uniform float flipY;", "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 * -flipY) + flipY , 0.0, 1.0);", " vColor = vec4(color * alpha * tint, alpha);", "}"], this.init()
  632. }, b.ComplexPrimitiveShader.prototype.constructor = b.ComplexPrimitiveShader, b.ComplexPrimitiveShader.prototype.init = function() {
  633. var a = this.gl,
  634. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  635. 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.flipY = a.getUniformLocation(c, "flipY"), 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
  636. }, b.ComplexPrimitiveShader.prototype.destroy = function() {
  637. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  638. }, b.WebGLGraphics = function() {}, b.WebGLGraphics.renderGraphics = function(a, c) {
  639. var d, e = c.gl,
  640. f = c.projection,
  641. g = c.offset,
  642. h = c.shaderManager.primitiveShader;
  643. a.dirty && b.WebGLGraphics.updateGraphics(a, e);
  644. 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)) : (d = i.data[j], c.shaderManager.setShader(h), h = c.shaderManager.primitiveShader, e.uniformMatrix3fv(h.translationMatrix, !1, a.worldTransform.toArray(!0)), e.uniform1f(h.flipY, 1), 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))
  645. }, b.WebGLGraphics.updateGraphics = function(a, c) {
  646. var d = a._webGL[c.id];
  647. d || (d = a._webGL[c.id] = {
  648. lastIndex: 0,
  649. data: [],
  650. gl: c
  651. }), a.dirty = !1;
  652. var e;
  653. if (a.clearDirty) {
  654. for (a.clearDirty = !1, e = 0; e < d.data.length; e++) {
  655. var f = d.data[e];
  656. f.reset(), b.WebGLGraphics.graphicsDataPool.push(f)
  657. }
  658. d.data = [], d.lastIndex = 0
  659. }
  660. var g;
  661. for (e = d.lastIndex; e < a.graphicsData.length; e++) {
  662. var h = a.graphicsData[e];
  663. if (h.type === b.Graphics.POLY) {
  664. if (h.points = h.shape.points.slice(), h.shape.closed && (h.points[0] !== h.points[h.points.length - 2] || h.points[1] !== h.points[h.points.length - 1]) && h.points.push(h.points[0], h.points[1]), h.fill && h.points.length >= 6)
  665. if (h.points.length < 12) {
  666. g = b.WebGLGraphics.switchMode(d, 0);
  667. var i = b.WebGLGraphics.buildPoly(h, g);
  668. i || (g = b.WebGLGraphics.switchMode(d, 1), b.WebGLGraphics.buildComplexPoly(h, g))
  669. } else g = b.WebGLGraphics.switchMode(d, 1), b.WebGLGraphics.buildComplexPoly(h, g);
  670. h.lineWidth > 0 && (g = b.WebGLGraphics.switchMode(d, 0), b.WebGLGraphics.buildLine(h, g))
  671. } else 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);
  672. d.lastIndex++
  673. }
  674. for (e = 0; e < d.data.length; e++) g = d.data[e], g.dirty && g.upload()
  675. }, b.WebGLGraphics.switchMode = function(a, c) {
  676. var d;
  677. 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
  678. }, b.WebGLGraphics.buildRectangle = function(a, c) {
  679. var d = a.shape,
  680. e = d.x,
  681. f = d.y,
  682. g = d.width,
  683. h = d.height;
  684. if (a.fill) {
  685. var i = b.hex2rgb(a.fillColor),
  686. j = a.fillAlpha,
  687. k = i[0] * j,
  688. l = i[1] * j,
  689. m = i[2] * j,
  690. n = c.points,
  691. o = c.indices,
  692. p = n.length / 6;
  693. 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)
  694. }
  695. if (a.lineWidth) {
  696. var q = a.points;
  697. a.points = [e, f, e + g, f, e + g, f + h, e, f + h, e, f], b.WebGLGraphics.buildLine(a, c), a.points = q
  698. }
  699. }, b.WebGLGraphics.buildRoundedRectangle = function(a, c) {
  700. var d = a.shape,
  701. e = d.x,
  702. f = d.y,
  703. g = d.width,
  704. h = d.height,
  705. i = d.radius,
  706. j = [];
  707. 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) {
  708. var k = b.hex2rgb(a.fillColor),
  709. l = a.fillAlpha,
  710. m = k[0] * l,
  711. n = k[1] * l,
  712. o = k[2] * l,
  713. p = c.points,
  714. q = c.indices,
  715. r = p.length / 6,
  716. s = b.PolyK.Triangulate(j),
  717. t = 0;
  718. 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);
  719. for (t = 0; t < j.length; t++) p.push(j[t], j[++t], m, n, o, l)
  720. }
  721. if (a.lineWidth) {
  722. var u = a.points;
  723. a.points = j, b.WebGLGraphics.buildLine(a, c), a.points = u
  724. }
  725. }, b.WebGLGraphics.quadraticBezierCurve = function(a, b, c, d, e, f) {
  726. function g(a, b, c) {
  727. var d = b - a;
  728. return a + d * c
  729. }
  730. 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);
  731. return o
  732. }, b.WebGLGraphics.buildCircle = function(a, c) {
  733. var d, e, f = a.shape,
  734. g = f.x,
  735. h = f.y;
  736. a.type === b.Graphics.CIRC ? (d = f.radius, e = f.radius) : (d = f.width, e = f.height);
  737. var i = 40,
  738. j = 2 * Math.PI / i,
  739. k = 0;
  740. if (a.fill) {
  741. var l = b.hex2rgb(a.fillColor),
  742. m = a.fillAlpha,
  743. n = l[0] * m,
  744. o = l[1] * m,
  745. p = l[2] * m,
  746. q = c.points,
  747. r = c.indices,
  748. s = q.length / 6;
  749. for (r.push(s), k = 0; i + 1 > k; k++) q.push(g, h, n, o, p, m), q.push(g + Math.sin(j * k) * d, h + Math.cos(j * k) * e, n, o, p, m), r.push(s++, s++);
  750. r.push(s - 1)
  751. }
  752. if (a.lineWidth) {
  753. var t = a.points;
  754. for (a.points = [], k = 0; i + 1 > k; k++) a.points.push(g + Math.sin(j * k) * d, h + Math.cos(j * k) * e);
  755. b.WebGLGraphics.buildLine(a, c), a.points = t
  756. }
  757. }, b.WebGLGraphics.buildLine = function(a, c) {
  758. var d = 0,
  759. e = a.points;
  760. if (0 !== e.length) {
  761. if (a.lineWidth % 2)
  762. for (d = 0; d < e.length; d++) e[d] += .5;
  763. var f = new b.Point(e[0], e[1]),
  764. g = new b.Point(e[e.length - 2], e[e.length - 1]);
  765. if (f.x === g.x && f.y === g.y) {
  766. e = e.slice(), e.pop(), e.pop(), g = new b.Point(e[e.length - 2], e[e.length - 1]);
  767. var h = g.x + .5 * (f.x - g.x),
  768. i = g.y + .5 * (f.y - g.y);
  769. e.unshift(h, i), e.push(h, i)
  770. }
  771. 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,
  772. H = c.indices,
  773. I = e.length / 2,
  774. J = e.length,
  775. K = G.length / 6,
  776. L = a.lineWidth / 2,
  777. M = b.hex2rgb(a.lineColor),
  778. N = a.lineAlpha,
  779. O = M[0] * N,
  780. P = M[1] * N,
  781. Q = M[2] * N;
  782. 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)));
  783. 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++);
  784. H.push(K - 1)
  785. }
  786. }, b.WebGLGraphics.buildComplexPoly = function(a, c) {
  787. var d = a.points.slice();
  788. if (!(d.length < 6)) {
  789. var e = c.indices;
  790. c.points = d, c.alpha = a.fillAlpha, c.color = b.hex2rgb(a.fillColor);
  791. 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;
  792. d.push(h, j, i, j, i, k, h, k);
  793. var m = d.length / 2;
  794. for (l = 0; m > l; l++) e.push(l)
  795. }
  796. }, b.WebGLGraphics.buildPoly = function(a, c) {
  797. var d = a.points;
  798. if (!(d.length < 6)) {
  799. var e = c.points,
  800. f = c.indices,
  801. g = d.length / 2,
  802. h = b.hex2rgb(a.fillColor),
  803. i = a.fillAlpha,
  804. j = h[0] * i,
  805. k = h[1] * i,
  806. l = h[2] * i,
  807. m = b.PolyK.Triangulate(d);
  808. if (!m) return !1;
  809. var n = e.length / 6,
  810. o = 0;
  811. 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);
  812. for (o = 0; g > o; o++) e.push(d[2 * o], d[2 * o + 1], j, k, l, i);
  813. return !0
  814. }
  815. }, b.WebGLGraphics.graphicsDataPool = [], b.WebGLGraphicsData = function(a) {
  816. this.gl = a, this.color = [0, 0, 0], this.points = [], this.indices = [], this.buffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.mode = 1, this.alpha = 1, this.dirty = !0
  817. }, b.WebGLGraphicsData.prototype.reset = function() {
  818. this.points = [], this.indices = []
  819. }, b.WebGLGraphicsData.prototype.upload = function() {
  820. var a = this.gl;
  821. this.glPoints = new b.Float32Array(this.points), a.bindBuffer(a.ARRAY_BUFFER, this.buffer), a.bufferData(a.ARRAY_BUFFER, this.glPoints, a.STATIC_DRAW), this.glIndicies = new b.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
  822. }, b.glContexts = [], b.instances = [], b.WebGLRenderer = function(a, c, d) {
  823. if (d)
  824. for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
  825. else d = b.defaultRenderOptions;
  826. b.defaultRenderer || (b.defaultRenderer = this), this.type = b.WEBGL_RENDERER, this.resolution = d.resolution, this.transparent = d.transparent, this.autoResize = d.autoResize || !1, this.preserveDrawingBuffer = d.preserveDrawingBuffer, this.clearBeforeRender = d.clearBeforeRender, this.width = a || 800, this.height = c || 600, this.view = d.view || document.createElement("canvas"), this.contextLostBound = this.handleContextLost.bind(this), this.contextRestoredBound = this.handleContextRestored.bind(this), this.view.addEventListener("webglcontextlost", this.contextLostBound, !1), this.view.addEventListener("webglcontextrestored", this.contextRestoredBound, !1), this._contextOptions = {
  827. alpha: this.transparent,
  828. antialias: d.antialias,
  829. premultipliedAlpha: this.transparent && "notMultiplied" !== this.transparent,
  830. stencil: !0,
  831. preserveDrawingBuffer: d.preserveDrawingBuffer
  832. }, this.projection = new b.Point, this.offset = new b.Point(0, 0), this.shaderManager = new b.WebGLShaderManager, this.spriteBatch = new b.WebGLSpriteBatch, this.maskManager = new b.WebGLMaskManager, this.filterManager = new b.WebGLFilterManager, this.stencilManager = new b.WebGLStencilManager, this.blendModeManager = new b.WebGLBlendModeManager, 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, this.renderSession.resolution = this.resolution, this.initContext(), this.mapBlendModes()
  833. }, b.WebGLRenderer.prototype.constructor = b.WebGLRenderer, b.WebGLRenderer.prototype.initContext = function() {
  834. var a = this.view.getContext("webgl", this._contextOptions) || this.view.getContext("experimental-webgl", this._contextOptions);
  835. if (this.gl = a, !a) throw new Error("This browser does not support webGL. Try using the canvas renderer");
  836. this.glContextId = a.id = b.WebGLRenderer.glContextId++, b.glContexts[this.glContextId] = a, b.instances[this.glContextId] = this, a.disable(a.DEPTH_TEST), a.disable(a.CULL_FACE), a.enable(a.BLEND), this.shaderManager.setContext(a), this.spriteBatch.setContext(a), this.maskManager.setContext(a), this.filterManager.setContext(a), this.blendModeManager.setContext(a), this.stencilManager.setContext(a), this.renderSession.gl = this.gl, this.resize(this.width, this.height)
  837. }, b.WebGLRenderer.prototype.render = function(a) {
  838. if (!this.contextLost) {
  839. this.__stage !== a && (this.__stage = a), a.updateTransform();
  840. var b = this.gl;
  841. b.viewport(0, 0, this.width, this.height), b.bindFramebuffer(b.FRAMEBUFFER, null), this.clearBeforeRender && (this.transparent ? b.clearColor(0, 0, 0, 0) : b.clearColor(a.backgroundColorSplit[0], a.backgroundColorSplit[1], a.backgroundColorSplit[2], 1), b.clear(b.COLOR_BUFFER_BIT)), this.renderDisplayObject(a, this.projection)
  842. }
  843. }, b.WebGLRenderer.prototype.renderDisplayObject = function(a, c, d) {
  844. this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL), this.renderSession.drawCount = 0, this.renderSession.flipY = d ? -1 : 1, 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()
  845. }, b.WebGLRenderer.prototype.resize = function(a, b) {
  846. this.width = a * this.resolution, this.height = b * this.resolution, this.view.width = this.width, this.view.height = this.height, this.autoResize && (this.view.style.width = this.width / this.resolution + "px", this.view.style.height = this.height / this.resolution + "px"), this.gl.viewport(0, 0, this.width, this.height), this.projection.x = this.width / 2 / this.resolution, this.projection.y = -this.height / 2 / this.resolution
  847. }, b.WebGLRenderer.prototype.updateTexture = function(a) {
  848. if (a.hasLoaded) {
  849. var c = this.gl;
  850. return a._glTextures[c.id] || (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), a.mipmap && b.isPowerOfTwo(a.width, a.height) ? (c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MIN_FILTER, a.scaleMode === b.scaleModes.LINEAR ? c.LINEAR_MIPMAP_LINEAR : c.NEAREST_MIPMAP_NEAREST), c.generateMipmap(c.TEXTURE_2D)) : 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, a._glTextures[c.id]
  851. }
  852. }, b.WebGLRenderer.prototype.handleContextLost = function(a) {
  853. a.preventDefault(), this.contextLost = !0
  854. }, b.WebGLRenderer.prototype.handleContextRestored = function() {
  855. this.initContext();
  856. for (var a in b.TextureCache) {
  857. var c = b.TextureCache[a].baseTexture;
  858. c._glTextures = []
  859. }
  860. this.contextLost = !1
  861. }, b.WebGLRenderer.prototype.destroy = function() {
  862. this.view.removeEventListener("webglcontextlost", this.contextLostBound), this.view.removeEventListener("webglcontextrestored", this.contextRestoredBound), b.glContexts[this.glContextId] = null, this.projection = null, this.offset = null, this.shaderManager.destroy(), this.spriteBatch.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, b.instances[this.glContextId] = null, b.WebGLRenderer.glContextId--
  863. }, b.WebGLRenderer.prototype.mapBlendModes = function() {
  864. var a = this.gl;
  865. b.blendModesWebGL || (b.blendModesWebGL = [], b.blendModesWebGL[b.blendModes.NORMAL] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.ADD] = [a.SRC_ALPHA, a.DST_ALPHA], b.blendModesWebGL[b.blendModes.MULTIPLY] = [a.DST_COLOR, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SCREEN] = [a.SRC_ALPHA, a.ONE], b.blendModesWebGL[b.blendModes.OVERLAY] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.DARKEN] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.LIGHTEN] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR_DODGE] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR_BURN] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.HARD_LIGHT] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SOFT_LIGHT] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.DIFFERENCE] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.EXCLUSION] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.HUE] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SATURATION] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR] = [a.ONE, a.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.LUMINOSITY] = [a.ONE, a.ONE_MINUS_SRC_ALPHA])
  866. }, b.WebGLRenderer.glContextId = 0, b.WebGLBlendModeManager = function() {
  867. this.currentBlendMode = 99999
  868. }, b.WebGLBlendModeManager.prototype.constructor = b.WebGLBlendModeManager, b.WebGLBlendModeManager.prototype.setContext = function(a) {
  869. this.gl = a
  870. }, b.WebGLBlendModeManager.prototype.setBlendMode = function(a) {
  871. if (this.currentBlendMode === a) return !1;
  872. this.currentBlendMode = a;
  873. var c = b.blendModesWebGL[this.currentBlendMode];
  874. return this.gl.blendFunc(c[0], c[1]), !0
  875. }, b.WebGLBlendModeManager.prototype.destroy = function() {
  876. this.gl = null
  877. }, b.WebGLMaskManager = function() {}, b.WebGLMaskManager.prototype.constructor = b.WebGLMaskManager, b.WebGLMaskManager.prototype.setContext = function(a) {
  878. this.gl = a
  879. }, b.WebGLMaskManager.prototype.pushMask = function(a, c) {
  880. var d = c.gl;
  881. a.dirty && b.WebGLGraphics.updateGraphics(a, d), a._webGL[d.id].data.length && c.stencilManager.pushStencil(a, a._webGL[d.id].data[0], c)
  882. }, b.WebGLMaskManager.prototype.popMask = function(a, b) {
  883. var c = this.gl;
  884. b.stencilManager.popStencil(a, a._webGL[c.id].data[0], b)
  885. }, b.WebGLMaskManager.prototype.destroy = function() {
  886. this.gl = null
  887. }, b.WebGLStencilManager = function() {
  888. this.stencilStack = [], this.reverse = !0, this.count = 0
  889. }, b.WebGLStencilManager.prototype.setContext = function(a) {
  890. this.gl = a
  891. }, b.WebGLStencilManager.prototype.pushStencil = function(a, b, c) {
  892. var d = this.gl;
  893. 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);
  894. var e = this.count;
  895. 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++
  896. }, b.WebGLStencilManager.prototype.bindGraphics = function(a, c, d) {
  897. this._currentGraphics = a;
  898. var e, f = this.gl,
  899. g = d.projection,
  900. h = d.offset;
  901. 1 === c.mode ? (e = d.shaderManager.complexPrimitiveShader, d.shaderManager.setShader(e), f.uniform1f(e.flipY, d.flipY), 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.uniform1f(e.flipY, d.flipY), 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))
  902. }, b.WebGLStencilManager.prototype.popStencil = function(a, b, c) {
  903. var d = this.gl;
  904. if (this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length) d.disable(d.STENCIL_TEST);
  905. else {
  906. var e = this.count;
  907. 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)
  908. }
  909. }, b.WebGLStencilManager.prototype.destroy = function() {
  910. this.stencilStack = null, this.gl = null
  911. }, b.WebGLShaderManager = function() {
  912. this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [];
  913. for (var a = 0; a < this.maxAttibs; a++) this.attribState[a] = !1;
  914. this.stack = []
  915. }, b.WebGLShaderManager.prototype.constructor = b.WebGLShaderManager, b.WebGLShaderManager.prototype.setContext = function(a) {
  916. this.gl = a, this.primitiveShader = new b.PrimitiveShader(a), this.complexPrimitiveShader = 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)
  917. }, b.WebGLShaderManager.prototype.setAttribs = function(a) {
  918. var b;
  919. for (b = 0; b < this.tempAttribState.length; b++) this.tempAttribState[b] = !1;
  920. for (b = 0; b < a.length; b++) {
  921. var c = a[b];
  922. this.tempAttribState[c] = !0
  923. }
  924. var d = this.gl;
  925. 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))
  926. }, b.WebGLShaderManager.prototype.setShader = function(a) {
  927. return this._currentId === a._UID ? !1 : (this._currentId = a._UID, this.currentShader = a, this.gl.useProgram(a.program), this.setAttribs(a.attributes), !0)
  928. }, b.WebGLShaderManager.prototype.destroy = function() {
  929. this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.complexPrimitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null
  930. }, b.WebGLSpriteBatch = function() {
  931. this.vertSize = 5, this.size = 2e3;
  932. var a = 4 * this.size * 4 * this.vertSize,
  933. c = 6 * this.size;
  934. this.vertices = new b.ArrayBuffer(a), this.positions = new b.Float32Array(this.vertices), this.colors = new b.Uint32Array(this.vertices), this.indices = new b.Uint16Array(c), this.lastIndexCount = 0;
  935. 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;
  936. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.dirty = !0, this.textures = [], this.blendModes = [], this.shaders = [], this.sprites = [], this.defaultShader = new b.AbstractFilter(["precision lowp float;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"])
  937. }, b.WebGLSpriteBatch.prototype.setContext = function(a) {
  938. 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;
  939. var c = new b.PixiShader(a);
  940. c.fragmentSrc = this.defaultShader.fragmentSrc, c.uniforms = {}, c.init(), this.defaultShader.shaders[a.id] = c
  941. }, b.WebGLSpriteBatch.prototype.begin = function(a) {
  942. this.renderSession = a, this.shader = this.renderSession.shaderManager.defaultShader, this.start()
  943. }, b.WebGLSpriteBatch.prototype.end = function() {
  944. this.flush()
  945. }, b.WebGLSpriteBatch.prototype.render = function(a) {
  946. var b = a.texture;
  947. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = b.baseTexture);
  948. var c = b._uvs;
  949. if (c) {
  950. var d, e, f, g, h = a.anchor.x,
  951. i = a.anchor.y;
  952. if (b.trim) {
  953. var j = b.trim;
  954. e = j.x - h * j.width, d = e + b.crop.width, g = j.y - i * j.height, f = g + b.crop.height
  955. } else d = b.frame.width * (1 - h), e = b.frame.width * -h, f = b.frame.height * (1 - i), g = b.frame.height * -i;
  956. var k = 4 * this.currentBatchSize * this.vertSize,
  957. l = b.baseTexture.resolution,
  958. m = a.worldTransform,
  959. n = m.a / l,
  960. o = m.b / l,
  961. p = m.c / l,
  962. q = m.d / l,
  963. r = m.tx,
  964. s = m.ty,
  965. t = this.colors,
  966. u = this.positions;
  967. this.renderSession.roundPixels ? (u[k] = n * e + p * g + r | 0, u[k + 1] = q * g + o * e + s | 0, u[k + 5] = n * d + p * g + r | 0, u[k + 6] = q * g + o * d + s | 0, u[k + 10] = n * d + p * f + r | 0, u[k + 11] = q * f + o * d + s | 0, u[k + 15] = n * e + p * f + r | 0, u[k + 16] = q * f + o * e + s | 0) : (u[k] = n * e + p * g + r, u[k + 1] = q * g + o * e + s, u[k + 5] = n * d + p * g + r, u[k + 6] = q * g + o * d + s, u[k + 10] = n * d + p * f + r, u[k + 11] = q * f + o * d + s, u[k + 15] = n * e + p * f + r, u[k + 16] = q * f + o * e + s), u[k + 2] = c.x0, u[k + 3] = c.y0, u[k + 7] = c.x1, u[k + 8] = c.y1, u[k + 12] = c.x2, u[k + 13] = c.y2, u[k + 17] = c.x3, u[k + 18] = c.y3;
  968. var v = a.tint;
  969. t[k + 4] = t[k + 9] = t[k + 14] = t[k + 19] = (v >> 16) + (65280 & v) + ((255 & v) << 16) + (255 * a.worldAlpha << 24), this.sprites[this.currentBatchSize++] = a
  970. }
  971. }, b.WebGLSpriteBatch.prototype.renderTilingSprite = function(a) {
  972. var c = a.tilingTexture;
  973. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = c.baseTexture), a._uvs || (a._uvs = new b.TextureUvs);
  974. var d = a._uvs;
  975. a.tilePosition.x %= c.baseTexture.width * a.tileScaleOffset.x, a.tilePosition.y %= c.baseTexture.height * a.tileScaleOffset.y;
  976. var e = a.tilePosition.x / (c.baseTexture.width * a.tileScaleOffset.x),
  977. f = a.tilePosition.y / (c.baseTexture.height * a.tileScaleOffset.y),
  978. g = a.width / c.baseTexture.width / (a.tileScale.x * a.tileScaleOffset.x),
  979. h = a.height / c.baseTexture.height / (a.tileScale.y * a.tileScaleOffset.y);
  980. 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;
  981. var i = a.tint,
  982. j = (i >> 16) + (65280 & i) + ((255 & i) << 16) + (255 * a.alpha << 24),
  983. k = this.positions,
  984. l = this.colors,
  985. m = a.width,
  986. n = a.height,
  987. o = a.anchor.x,
  988. p = a.anchor.y,
  989. q = m * (1 - o),
  990. r = m * -o,
  991. s = n * (1 - p),
  992. t = n * -p,
  993. u = 4 * this.currentBatchSize * this.vertSize,
  994. v = c.baseTexture.resolution,
  995. w = a.worldTransform,
  996. x = w.a / v,
  997. y = w.b / v,
  998. z = w.c / v,
  999. A = w.d / v,
  1000. B = w.tx,
  1001. C = w.ty;
  1002. k[u++] = x * r + z * t + B, k[u++] = A * t + y * r + C, k[u++] = d.x0, k[u++] = d.y0, l[u++] = j, k[u++] = x * q + z * t + B, k[u++] = A * t + y * q + C, k[u++] = d.x1, k[u++] = d.y1, l[u++] = j, k[u++] = x * q + z * s + B, k[u++] = A * s + y * q + C, k[u++] = d.x2, k[u++] = d.y2, l[u++] = j, k[u++] = x * r + z * s + B, k[u++] = A * s + y * r + C, k[u++] = d.x3, k[u++] = d.y3, l[u++] = j, this.sprites[this.currentBatchSize++] = a
  1003. }, b.WebGLSpriteBatch.prototype.flush = function() {
  1004. if (0 !== this.currentBatchSize) {
  1005. var a, c = this.gl;
  1006. if (this.dirty) {
  1007. this.dirty = !1, c.activeTexture(c.TEXTURE0), c.bindBuffer(c.ARRAY_BUFFER, this.vertexBuffer), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a = this.defaultShader.shaders[c.id];
  1008. var d = 4 * this.vertSize;
  1009. c.vertexAttribPointer(a.aVertexPosition, 2, c.FLOAT, !1, d, 0), c.vertexAttribPointer(a.aTextureCoord, 2, c.FLOAT, !1, d, 8), c.vertexAttribPointer(a.colorAttribute, 4, c.UNSIGNED_BYTE, !0, d, 16)
  1010. }
  1011. if (this.currentBatchSize > .5 * this.size) c.bufferSubData(c.ARRAY_BUFFER, 0, this.vertices);
  1012. else {
  1013. var e = this.positions.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1014. c.bufferSubData(c.ARRAY_BUFFER, 0, e)
  1015. }
  1016. for (var f, g, h, i, j = 0, k = 0, l = null, m = this.renderSession.blendModeManager.currentBlendMode, n = null, o = !1, p = !1, q = 0, r = this.currentBatchSize; r > q; q++) {
  1017. if (i = this.sprites[q], f = i.texture.baseTexture, g = i.blendMode, h = i.shader || this.defaultShader, o = m !== g, p = n !== h, (l !== f || o || p) && (this.renderBatch(l, j, k), k = q, j = 0, l = f, o && (m = g, this.renderSession.blendModeManager.setBlendMode(m)), p)) {
  1018. n = h, a = n.shaders[c.id], a || (a = new b.PixiShader(c), a.fragmentSrc = n.fragmentSrc, a.uniforms = n.uniforms, a.init(), n.shaders[c.id] = a), this.renderSession.shaderManager.setShader(a), a.dirty && a.syncUniforms();
  1019. var s = this.renderSession.projection;
  1020. c.uniform2f(a.projectionVector, s.x, s.y);
  1021. var t = this.renderSession.offset;
  1022. c.uniform2f(a.offsetVector, t.x, t.y)
  1023. }
  1024. j++
  1025. }
  1026. this.renderBatch(l, j, k), this.currentBatchSize = 0
  1027. }
  1028. }, b.WebGLSpriteBatch.prototype.renderBatch = function(a, b, c) {
  1029. if (0 !== b) {
  1030. var d = this.gl;
  1031. a._dirty[d.id] ? this.renderSession.renderer.updateTexture(a) : d.bindTexture(d.TEXTURE_2D, a._glTextures[d.id]), d.drawElements(d.TRIANGLES, 6 * b, d.UNSIGNED_SHORT, 6 * c * 2), this.renderSession.drawCount++
  1032. }
  1033. }, b.WebGLSpriteBatch.prototype.stop = function() {
  1034. this.flush(), this.dirty = !0
  1035. }, b.WebGLSpriteBatch.prototype.start = function() {
  1036. this.dirty = !0
  1037. }, b.WebGLSpriteBatch.prototype.destroy = function() {
  1038. this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null
  1039. }, b.WebGLFastSpriteBatch = function(a) {
  1040. this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize;
  1041. var c = 4 * this.size * this.vertSize,
  1042. d = 6 * this.maxSize;
  1043. this.vertices = new b.Float32Array(c), this.indices = new b.Uint16Array(d), this.vertexBuffer = null, this.indexBuffer = null, this.lastIndexCount = 0;
  1044. for (var e = 0, f = 0; d > e; e += 6, f += 4) this.indices[e + 0] = f + 0, this.indices[e + 1] = f + 1, this.indices[e + 2] = f + 2, this.indices[e + 3] = f + 0, this.indices[e + 4] = f + 2, this.indices[e + 5] = f + 3;
  1045. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(a)
  1046. }, b.WebGLFastSpriteBatch.prototype.constructor = b.WebGLFastSpriteBatch, b.WebGLFastSpriteBatch.prototype.setContext = function(a) {
  1047. 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)
  1048. }, b.WebGLFastSpriteBatch.prototype.begin = function(a, b) {
  1049. this.renderSession = b, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = a.worldTransform.toArray(!0), this.start()
  1050. }, b.WebGLFastSpriteBatch.prototype.end = function() {
  1051. this.flush()
  1052. }, b.WebGLFastSpriteBatch.prototype.render = function(a) {
  1053. var b = a.children,
  1054. c = b[0];
  1055. if (c.texture._uvs) {
  1056. this.currentBaseTexture = c.texture.baseTexture, c.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(c.blendMode));
  1057. for (var d = 0, e = b.length; e > d; d++) this.renderSprite(b[d]);
  1058. this.flush()
  1059. }
  1060. }, b.WebGLFastSpriteBatch.prototype.renderSprite = function(a) {
  1061. if (a.visible && (a.texture.baseTexture === this.currentBaseTexture || (this.flush(), this.currentBaseTexture = a.texture.baseTexture, a.texture._uvs))) {
  1062. var b, c, d, e, f, g, h, i, j = this.vertices;
  1063. if (b = a.texture._uvs, c = a.texture.frame.width, d = a.texture.frame.height, a.texture.trim) {
  1064. var k = a.texture.trim;
  1065. 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
  1066. } 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;
  1067. 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()
  1068. }
  1069. }, b.WebGLFastSpriteBatch.prototype.flush = function() {
  1070. if (0 !== this.currentBatchSize) {
  1071. var a = this.gl;
  1072. if (this.currentBaseTexture._glTextures[a.id] || this.renderSession.renderer.updateTexture(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);
  1073. else {
  1074. var b = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1075. a.bufferSubData(a.ARRAY_BUFFER, 0, b)
  1076. }
  1077. a.drawElements(a.TRIANGLES, 6 * this.currentBatchSize, a.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++
  1078. }
  1079. }, b.WebGLFastSpriteBatch.prototype.stop = function() {
  1080. this.flush()
  1081. }, b.WebGLFastSpriteBatch.prototype.start = function() {
  1082. var a = this.gl;
  1083. a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  1084. var b = this.renderSession.projection;
  1085. a.uniform2f(this.shader.projectionVector, b.x, b.y), a.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix);
  1086. var c = 4 * this.vertSize;
  1087. 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)
  1088. }, b.WebGLFilterManager = function() {
  1089. this.filterStack = [], this.offsetX = 0, this.offsetY = 0
  1090. }, b.WebGLFilterManager.prototype.constructor = b.WebGLFilterManager, b.WebGLFilterManager.prototype.setContext = function(a) {
  1091. this.gl = a, this.texturePool = [], this.initShaderBuffers()
  1092. }, b.WebGLFilterManager.prototype.begin = function(a, b) {
  1093. this.renderSession = a, this.defaultShader = a.shaderManager.defaultShader;
  1094. var c = this.renderSession.projection;
  1095. this.width = 2 * c.x, this.height = 2 * -c.y, this.buffer = b
  1096. }, b.WebGLFilterManager.prototype.pushFilter = function(a) {
  1097. var c = this.gl,
  1098. d = this.renderSession.projection,
  1099. e = this.renderSession.offset;
  1100. a._filterArea = a.target.filterArea || a.target.getBounds(), this.filterStack.push(a);
  1101. var f = a.filterPasses[0];
  1102. this.offsetX += a._filterArea.x, this.offsetY += a._filterArea.y;
  1103. var g = this.texturePool.pop();
  1104. g ? g.resize(this.width, this.height) : g = new b.FilterTexture(this.gl, this.width, this.height), c.bindTexture(c.TEXTURE_2D, g.texture);
  1105. var h = a._filterArea,
  1106. i = f.padding;
  1107. 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, c.colorMask(!0, !0, !0, !0), c.clearColor(0, 0, 0, 0), c.clear(c.COLOR_BUFFER_BIT), a._glFilterTexture = g
  1108. }, b.WebGLFilterManager.prototype.popFilter = function() {
  1109. var a = this.gl,
  1110. c = this.filterStack.pop(),
  1111. d = c._filterArea,
  1112. e = c._glFilterTexture,
  1113. f = this.renderSession.projection,
  1114. g = this.renderSession.offset;
  1115. if (c.filterPasses.length > 1) {
  1116. 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);
  1117. var h = e,
  1118. i = this.texturePool.pop();
  1119. 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);
  1120. for (var j = 0; j < c.filterPasses.length - 1; j++) {
  1121. var k = c.filterPasses[j];
  1122. 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);
  1123. var l = h;
  1124. h = i, i = l
  1125. }
  1126. a.enable(a.BLEND), e = h, this.texturePool.push(i)
  1127. }
  1128. var m = c.filterPasses[c.filterPasses.length - 1];
  1129. this.offsetX -= d.x, this.offsetY -= d.y;
  1130. var n = this.width,
  1131. o = this.height,
  1132. p = 0,
  1133. q = 0,
  1134. r = this.buffer;
  1135. if (0 === this.filterStack.length) a.colorMask(!0, !0, !0, !0);
  1136. else {
  1137. var s = this.filterStack[this.filterStack.length - 1];
  1138. d = s._filterArea, n = d.width, o = d.height, p = d.x, q = d.y, r = s._glFilterTexture.frameBuffer
  1139. }
  1140. f.x = n / 2, f.y = -o / 2, g.x = p, g.y = q, d = c._filterArea;
  1141. var t = d.x - p,
  1142. u = d.y - q;
  1143. 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 * this.renderSession.resolution, o * this.renderSession.resolution), a.bindFramebuffer(a.FRAMEBUFFER, r), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, e.texture), this.applyFilterPass(m, d, n, o), this.texturePool.push(e), c._glFilterTexture = null
  1144. }, b.WebGLFilterManager.prototype.applyFilterPass = function(a, c, d, e) {
  1145. var f = this.gl,
  1146. g = a.shaders[f.id];
  1147. 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++
  1148. }, b.WebGLFilterManager.prototype.initShaderBuffers = function() {
  1149. var a = this.gl;
  1150. this.vertexBuffer = a.createBuffer(), this.uvBuffer = a.createBuffer(), this.colorBuffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.vertexArray = new b.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 b.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 b.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)
  1151. }, b.WebGLFilterManager.prototype.destroy = function() {
  1152. var a = this.gl;
  1153. this.filterStack = null, this.offsetX = 0, this.offsetY = 0;
  1154. for (var b = 0; b < this.texturePool.length; b++) this.texturePool[b].destroy();
  1155. this.texturePool = null, a.deleteBuffer(this.vertexBuffer), a.deleteBuffer(this.uvBuffer), a.deleteBuffer(this.colorBuffer), a.deleteBuffer(this.indexBuffer)
  1156. }, b.FilterTexture = function(a, c, d, e) {
  1157. 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)
  1158. }, b.FilterTexture.prototype.constructor = b.FilterTexture, b.FilterTexture.prototype.clear = function() {
  1159. var a = this.gl;
  1160. a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT)
  1161. }, b.FilterTexture.prototype.resize = function(a, b) {
  1162. if (this.width !== a || this.height !== b) {
  1163. this.width = a, this.height = b;
  1164. var c = this.gl;
  1165. 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)
  1166. }
  1167. }, b.FilterTexture.prototype.destroy = function() {
  1168. var a = this.gl;
  1169. a.deleteFramebuffer(this.frameBuffer), a.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
  1170. }, b.CanvasBuffer = function(a, b) {
  1171. 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
  1172. }, b.CanvasBuffer.prototype.constructor = b.CanvasBuffer, b.CanvasBuffer.prototype.clear = function() {
  1173. this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.clearRect(0, 0, this.width, this.height)
  1174. }, b.CanvasBuffer.prototype.resize = function(a, b) {
  1175. this.width = this.canvas.width = a, this.height = this.canvas.height = b
  1176. }, b.CanvasMaskManager = function() {}, b.CanvasMaskManager.prototype.constructor = b.CanvasMaskManager, b.CanvasMaskManager.prototype.pushMask = function(a, c) {
  1177. var d = c.context;
  1178. d.save();
  1179. var e = a.alpha,
  1180. f = a.worldTransform,
  1181. g = c.resolution;
  1182. d.setTransform(f.a * g, f.b * g, f.c * g, f.d * g, f.tx * g, f.ty * g), b.CanvasGraphics.renderGraphicsMask(a, d), d.clip(), a.worldAlpha = e
  1183. }, b.CanvasMaskManager.prototype.popMask = function(a) {
  1184. a.context.restore()
  1185. }, b.CanvasTinter = function() {}, b.CanvasTinter.getTintedTexture = function(a, c) {
  1186. var d = a.texture,
  1187. e = b.CanvasTinter.canvas || document.createElement("canvas");
  1188. if (b.CanvasTinter.tintMethod(d, c, e), b.CanvasTinter.convertTintToImage) {
  1189. var f = new Image;
  1190. f.src = e.toDataURL()
  1191. } else b.CanvasTinter.canvas = null;
  1192. return e
  1193. }, b.CanvasTinter.tintWithMultiply = function(a, b, c) {
  1194. var d = c.getContext("2d"),
  1195. e = a.crop;
  1196. 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)
  1197. }, b.CanvasTinter.tintWithOverlay = function(a, b, c) {
  1198. var d = c.getContext("2d"),
  1199. e = a.crop;
  1200. 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)
  1201. }, b.CanvasTinter.tintWithPerPixel = function(a, c, d) {
  1202. var e = d.getContext("2d"),
  1203. f = a.crop;
  1204. 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);
  1205. 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)
  1206. if (l[m + 0] *= h, l[m + 1] *= i, l[m + 2] *= j, !b.CanvasTinter.canHandleAlpha) {
  1207. var n = l[m + 3];
  1208. l[m + 0] /= 255 / n, l[m + 1] /= 255 / n, l[m + 2] /= 255 / n
  1209. }
  1210. e.putImageData(k, 0, 0)
  1211. }, b.CanvasTinter.roundColor = function(a) {
  1212. var c = b.CanvasTinter.cacheStepsPerColorChannel,
  1213. d = b.hex2rgb(a);
  1214. 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)
  1215. }, b.CanvasTinter.checkInverseAlpha = function() {
  1216. var a = new b.CanvasBuffer(2, 1);
  1217. a.context.fillStyle = "rgba(10, 20, 30, 0.5)", a.context.fillRect(0, 0, 1, 1);
  1218. var c = a.context.getImageData(0, 0, 1, 1);
  1219. a.context.putImageData(c, 1, 0);
  1220. var d = a.context.getImageData(1, 0, 1, 1);
  1221. return d.data[0] === c.data[0] && d.data[1] === c.data[1] && d.data[2] === c.data[2] && d.data[3] === c.data[3]
  1222. }, b.CanvasTinter.cacheStepsPerColorChannel = 8, b.CanvasTinter.convertTintToImage = !1, b.CanvasTinter.canHandleAlpha = b.CanvasTinter.checkInverseAlpha(), b.CanvasTinter.canUseMultiply = b.canUseNewCanvasBlendModes(), b.CanvasTinter.tintMethod = b.CanvasTinter.canUseMultiply ? b.CanvasTinter.tintWithMultiply : b.CanvasTinter.tintWithPerPixel, b.CanvasRenderer = function(a, c, d) {
  1223. if (d)
  1224. for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
  1225. else d = b.defaultRenderOptions;
  1226. b.defaultRenderer || (b.defaultRenderer = this), this.type = b.CANVAS_RENDERER, this.resolution = d.resolution, this.clearBeforeRender = d.clearBeforeRender, this.transparent = d.transparent, this.autoResize = d.autoResize || !1, this.width = a || 800, this.height = c || 600, this.width *= this.resolution, this.height *= this.resolution, this.view = d.view || document.createElement("canvas"), this.context = this.view.getContext("2d", {
  1227. alpha: this.transparent
  1228. }), this.refresh = !0, this.view.width = this.width * this.resolution, this.view.height = this.height * this.resolution, this.count = 0, this.maskManager = new b.CanvasMaskManager, this.renderSession = {
  1229. context: this.context,
  1230. maskManager: this.maskManager,
  1231. scaleMode: null,
  1232. smoothProperty: null,
  1233. roundPixels: !1
  1234. }, this.mapBlendModes(), this.resize(a, c), "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" : "msImageSmoothingEnabled" in this.context && (this.renderSession.smoothProperty = "msImageSmoothingEnabled")
  1235. }, b.CanvasRenderer.prototype.constructor = b.CanvasRenderer, b.CanvasRenderer.prototype.render = function(a) {
  1236. a.updateTransform(), this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.globalAlpha = 1, this.renderSession.currentBlendMode = b.blendModes.NORMAL, this.context.globalCompositeOperation = b.blendModesCanvas[b.blendModes.NORMAL], navigator.isCocoonJS && this.view.screencanvas && (this.context.fillStyle = "black", this.context.clear()), this.clearBeforeRender && (this.transparent ? this.context.clearRect(0, 0, this.width, this.height) : (this.context.fillStyle = a.backgroundColorString, this.context.fillRect(0, 0, this.width, this.height))), this.renderDisplayObject(a)
  1237. }, b.CanvasRenderer.prototype.destroy = function(a) {
  1238. "undefined" == typeof a && (a = !0), a && this.view.parent && this.view.parent.removeChild(this.view), this.view = null, this.context = null, this.maskManager = null, this.renderSession = null
  1239. }, b.CanvasRenderer.prototype.resize = function(a, b) {
  1240. this.width = a * this.resolution, this.height = b * this.resolution, this.view.width = this.width, this.view.height = this.height, this.autoResize && (this.view.style.width = this.width / this.resolution + "px", this.view.style.height = this.height / this.resolution + "px")
  1241. }, b.CanvasRenderer.prototype.renderDisplayObject = function(a, b) {
  1242. this.renderSession.context = b || this.context, this.renderSession.resolution = this.resolution, a._renderCanvas(this.renderSession)
  1243. }, b.CanvasRenderer.prototype.mapBlendModes = function() {
  1244. 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"))
  1245. }, b.CanvasGraphics = function() {}, b.CanvasGraphics.renderGraphics = function(a, c) {
  1246. var d = a.worldAlpha;
  1247. a.dirty && (this.updateGraphicsTint(a), a.dirty = !1);
  1248. for (var e = 0; e < a.graphicsData.length; e++) {
  1249. var f = a.graphicsData[e],
  1250. g = f.shape,
  1251. h = f._fillTint,
  1252. i = f._lineTint;
  1253. if (c.lineWidth = f.lineWidth, f.type === b.Graphics.POLY) {
  1254. c.beginPath();
  1255. var j = g.points;
  1256. c.moveTo(j[0], j[1]);
  1257. for (var k = 1; k < j.length / 2; k++) c.lineTo(j[2 * k], j[2 * k + 1]);
  1258. g.closed && c.lineTo(j[0], j[1]), j[0] === j[j.length - 2] && j[1] === j[j.length - 1] && c.closePath(), f.fill && (c.globalAlpha = f.fillAlpha * d, c.fillStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-6), c.fill()), f.lineWidth && (c.globalAlpha = f.lineAlpha * d, c.strokeStyle = "#" + ("00000" + (0 | i).toString(16)).substr(-6), c.stroke())
  1259. } else if (f.type === b.Graphics.RECT)(f.fillColor || 0 === f.fillColor) && (c.globalAlpha = f.fillAlpha * d, c.fillStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-6), c.fillRect(g.x, g.y, g.width, g.height)), f.lineWidth && (c.globalAlpha = f.lineAlpha * d, c.strokeStyle = "#" + ("00000" + (0 | i).toString(16)).substr(-6), c.strokeRect(g.x, g.y, g.width, g.height));
  1260. else if (f.type === b.Graphics.CIRC) c.beginPath(), c.arc(g.x, g.y, g.radius, 0, 2 * Math.PI), c.closePath(), f.fill && (c.globalAlpha = f.fillAlpha * d, c.fillStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-6), c.fill()), f.lineWidth && (c.globalAlpha = f.lineAlpha * d, c.strokeStyle = "#" + ("00000" + (0 | i).toString(16)).substr(-6), c.stroke());
  1261. else if (f.type === b.Graphics.ELIP) {
  1262. var l = 2 * g.width,
  1263. m = 2 * g.height,
  1264. n = g.x - l / 2,
  1265. o = g.y - m / 2;
  1266. c.beginPath();
  1267. var p = .5522848,
  1268. q = l / 2 * p,
  1269. r = m / 2 * p,
  1270. s = n + l,
  1271. t = o + m,
  1272. u = n + l / 2,
  1273. v = o + m / 2;
  1274. c.moveTo(n, v), c.bezierCurveTo(n, v - r, u - q, o, u, o), c.bezierCurveTo(u + q, o, s, v - r, s, v), c.bezierCurveTo(s, v + r, u + q, t, u, t), c.bezierCurveTo(u - q, t, n, v + r, n, v), c.closePath(), f.fill && (c.globalAlpha = f.fillAlpha * d, c.fillStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-6), c.fill()), f.lineWidth && (c.globalAlpha = f.lineAlpha * d, c.strokeStyle = "#" + ("00000" + (0 | i).toString(16)).substr(-6), c.stroke())
  1275. } else if (f.type === b.Graphics.RREC) {
  1276. var w = g.x,
  1277. x = g.y,
  1278. y = g.width,
  1279. z = g.height,
  1280. A = g.radius,
  1281. B = Math.min(y, z) / 2 | 0;
  1282. A = A > B ? B : A, c.beginPath(), c.moveTo(w, x + A), c.lineTo(w, x + z - A), c.quadraticCurveTo(w, x + z, w + A, x + z), c.lineTo(w + y - A, x + z), c.quadraticCurveTo(w + y, x + z, w + y, x + z - A), c.lineTo(w + y, x + A), c.quadraticCurveTo(w + y, x, w + y - A, x), c.lineTo(w + A, x), c.quadraticCurveTo(w, x, w, x + A), c.closePath(), (f.fillColor || 0 === f.fillColor) && (c.globalAlpha = f.fillAlpha * d, c.fillStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-6), c.fill()), f.lineWidth && (c.globalAlpha = f.lineAlpha * d, c.strokeStyle = "#" + ("00000" + (0 | i).toString(16)).substr(-6), c.stroke())
  1283. }
  1284. }
  1285. }, b.CanvasGraphics.renderGraphicsMask = function(a, c) {
  1286. var d = a.graphicsData.length;
  1287. if (0 !== d) {
  1288. c.beginPath();
  1289. for (var e = 0; d > e; e++) {
  1290. var f = a.graphicsData[e],
  1291. g = f.shape;
  1292. if (f.type === b.Graphics.POLY) {
  1293. var h = g.points;
  1294. c.moveTo(h[0], h[1]);
  1295. for (var i = 1; i < h.length / 2; i++) c.lineTo(h[2 * i], h[2 * i + 1]);
  1296. h[0] === h[h.length - 2] && h[1] === h[h.length - 1] && c.closePath()
  1297. } else if (f.type === b.Graphics.RECT) c.rect(g.x, g.y, g.width, g.height), c.closePath();
  1298. else if (f.type === b.Graphics.CIRC) c.arc(g.x, g.y, g.radius, 0, 2 * Math.PI), c.closePath();
  1299. else if (f.type === b.Graphics.ELIP) {
  1300. var j = 2 * g.width,
  1301. k = 2 * g.height,
  1302. l = g.x - j / 2,
  1303. m = g.y - k / 2,
  1304. n = .5522848,
  1305. o = j / 2 * n,
  1306. p = k / 2 * n,
  1307. q = l + j,
  1308. r = m + k,
  1309. s = l + j / 2,
  1310. t = m + k / 2;
  1311. 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()
  1312. } else if (f.type === b.Graphics.RREC) {
  1313. var u = g.x,
  1314. v = g.y,
  1315. w = g.width,
  1316. x = g.height,
  1317. y = g.radius,
  1318. z = Math.min(w, x) / 2 | 0;
  1319. y = y > z ? z : y, 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()
  1320. }
  1321. }
  1322. }
  1323. }, b.CanvasGraphics.updateGraphicsTint = function(a) {
  1324. if (16777215 !== a.tint)
  1325. for (var b = (a.tint >> 16 & 255) / 255, c = (a.tint >> 8 & 255) / 255, d = (255 & a.tint) / 255, e = 0; e < a.graphicsData.length; e++) {
  1326. var f = a.graphicsData[e],
  1327. g = 0 | f.fillColor,
  1328. h = 0 | f.lineColor;
  1329. f._fillTint = ((g >> 16 & 255) / 255 * b * 255 << 16) + ((g >> 8 & 255) / 255 * c * 255 << 8) + (255 & g) / 255 * d * 255, f._lineTint = ((h >> 16 & 255) / 255 * b * 255 << 16) + ((h >> 8 & 255) / 255 * c * 255 << 8) + (255 & h) / 255 * d * 255
  1330. }
  1331. }, b.Graphics = function() {
  1332. b.DisplayObjectContainer.call(this), this.renderable = !0, this.fillAlpha = 1, this.lineWidth = 0, this.lineColor = 0, this.graphicsData = [], this.tint = 16777215, this.blendMode = b.blendModes.NORMAL, this.currentPath = null, this._webGL = [], this.isMask = !1, this.boundsPadding = 0, this._localBounds = new b.Rectangle(0, 0, 1, 1), this.dirty = !0, this.webGLDirty = !1, this.cachedSpriteDirty = !1
  1333. }, b.Graphics.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Graphics.prototype.constructor = b.Graphics, b.Graphics.prototype.lineStyle = function(a, c, d) {
  1334. return this.lineWidth = a || 0, this.lineColor = c || 0, this.lineAlpha = void 0 === d ? 1 : d, this.currentPath && (this.currentPath.shape.points.length ? this.drawShape(new b.Polygon(this.currentPath.shape.points.slice(-2))) : (this.currentPath.lineWidth = this.lineWidth, this.currentPath.lineColor = this.lineColor, this.currentPath.lineAlpha = this.lineAlpha)), this
  1335. }, b.Graphics.prototype.moveTo = function(a, c) {
  1336. return this.drawShape(new b.Polygon([a, c])), this
  1337. }, b.Graphics.prototype.lineTo = function(a, b) {
  1338. return this.currentPath || this.moveTo(0, 0), this.currentPath.shape.points.push(a, b), this.dirty = !0, this
  1339. }, b.Graphics.prototype.quadraticCurveTo = function(a, b, c, d) {
  1340. this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
  1341. var e, f, g = 20,
  1342. h = this.currentPath.shape.points;
  1343. 0 === h.length && this.moveTo(0, 0);
  1344. 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);
  1345. return this.dirty = !0, this
  1346. }, b.Graphics.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
  1347. this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
  1348. for (var g, h, i, j, k, l = 20, m = this.currentPath.shape.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);
  1349. return this.dirty = !0, this
  1350. }, b.Graphics.prototype.arcTo = function(a, b, c, d, e) {
  1351. this.currentPath ? 0 === this.currentPath.shape.points.length && this.currentPath.shape.points.push(a, b) : this.moveTo(a, b);
  1352. var f = this.currentPath.shape.points,
  1353. g = f[f.length - 2],
  1354. h = f[f.length - 1],
  1355. i = h - b,
  1356. j = g - a,
  1357. k = d - b,
  1358. l = c - a,
  1359. m = Math.abs(i * l - j * k);
  1360. if (1e-8 > m || 0 === e)(f[f.length - 2] !== a || f[f.length - 1] !== b) && f.push(a, b);
  1361. else {
  1362. var n = i * i + j * j,
  1363. o = k * k + l * l,
  1364. p = i * k + j * l,
  1365. q = e * Math.sqrt(n) / m,
  1366. r = e * Math.sqrt(o) / m,
  1367. s = q * p / n,
  1368. t = r * p / o,
  1369. u = q * l + r * j,
  1370. v = q * k + r * i,
  1371. w = j * (r + s),
  1372. x = i * (r + s),
  1373. y = l * (q + t),
  1374. z = k * (q + t),
  1375. A = Math.atan2(x - v, w - u),
  1376. B = Math.atan2(z - v, y - u);
  1377. this.arc(u + a, v + b, e, A, B, j * k > l * i)
  1378. }
  1379. return this.dirty = !0, this
  1380. }, b.Graphics.prototype.arc = function(a, b, c, d, e, f) {
  1381. if (d === e) return this;
  1382. "undefined" == typeof f && (f = !1), !f && d >= e ? e += 2 * Math.PI : f && e >= d && (d += 2 * Math.PI);
  1383. var g = f ? -1 * (d - e) : e - d,
  1384. h = 40 * Math.ceil(Math.abs(g) / (2 * Math.PI));
  1385. if (0 === g) return this;
  1386. var i = a + Math.cos(d) * c,
  1387. j = b + Math.sin(d) * c;
  1388. f && this.filling ? this.moveTo(a, b) : this.moveTo(i, j);
  1389. for (var k = this.currentPath.shape.points, l = g / (2 * h), m = 2 * l, n = Math.cos(l), o = Math.sin(l), p = h - 1, q = p % 1 / p, r = 0; p >= r; r++) {
  1390. var s = r + q * r,
  1391. t = l + d + m * s,
  1392. u = Math.cos(t),
  1393. v = -Math.sin(t);
  1394. k.push((n * u + o * v) * c + a, (n * -v + o * u) * c + b)
  1395. }
  1396. return this.dirty = !0, this
  1397. }, b.Graphics.prototype.beginFill = function(a, b) {
  1398. return this.filling = !0, this.fillColor = a || 0, this.fillAlpha = void 0 === b ? 1 : b, this.currentPath && this.currentPath.shape.points.length <= 2 && (this.currentPath.fill = this.filling, this.currentPath.fillColor = this.fillColor, this.currentPath.fillAlpha = this.fillAlpha), this
  1399. }, b.Graphics.prototype.endFill = function() {
  1400. return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this
  1401. }, b.Graphics.prototype.drawRect = function(a, c, d, e) {
  1402. return this.drawShape(new b.Rectangle(a, c, d, e)), this
  1403. }, b.Graphics.prototype.drawRoundedRect = function(a, c, d, e, f) {
  1404. return this.drawShape(new b.RoundedRectangle(a, c, d, e, f)), this
  1405. }, b.Graphics.prototype.drawCircle = function(a, c, d) {
  1406. return this.drawShape(new b.Circle(a, c, d)), this
  1407. }, b.Graphics.prototype.drawEllipse = function(a, c, d, e) {
  1408. return this.drawShape(new b.Ellipse(a, c, d, e)), this
  1409. }, b.Graphics.prototype.drawPolygon = function(a) {
  1410. var b = a;
  1411. if (!Array.isArray(b)) {
  1412. b = new Array(arguments.length);
  1413. for (var c = 0; c < b.length; ++c) b[c] = arguments[c]
  1414. }
  1415. return this.drawShape(new Phaser.Polygon(b)), this
  1416. }, b.Graphics.prototype.clear = function() {
  1417. return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this.clearDirty = !0, this.graphicsData = [], this
  1418. }, b.Graphics.prototype.generateTexture = function(a, c) {
  1419. a = a || 1;
  1420. var d = this.getBounds(),
  1421. e = new b.CanvasBuffer(d.width * a, d.height * a),
  1422. f = b.Texture.fromCanvas(e.canvas, c);
  1423. return f.baseTexture.resolution = a, e.context.scale(a, a), e.context.translate(-d.x, -d.y), b.CanvasGraphics.renderGraphics(this, e.context), f
  1424. }, b.Graphics.prototype._renderWebGL = function(a) {
  1425. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  1426. if (this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.worldAlpha = this.worldAlpha, void b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a);
  1427. 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) {
  1428. a.spriteBatch.currentBlendMode = this.blendMode;
  1429. var c = b.blendModesWebGL[a.spriteBatch.currentBlendMode];
  1430. a.spriteBatch.gl.blendFunc(c[0], c[1])
  1431. }
  1432. if (this.webGLDirty && (this.dirty = !0, this.webGLDirty = !1), b.WebGLGraphics.renderGraphics(this, a), this.children.length) {
  1433. a.spriteBatch.start();
  1434. for (var d = 0; d < this.children.length; d++) this.children[d]._renderWebGL(a);
  1435. a.spriteBatch.stop()
  1436. }
  1437. this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this.mask, a), a.drawCount++, a.spriteBatch.start()
  1438. }
  1439. }, b.Graphics.prototype._renderCanvas = function(a) {
  1440. if (this.isMask !== !0) {
  1441. if (this._prevTint !== this.tint && (this.dirty = !0, this._prevTint = this.tint), this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.alpha = this.alpha, void b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a);
  1442. var c = a.context,
  1443. d = this.worldTransform;
  1444. this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a);
  1445. var e = a.resolution;
  1446. c.setTransform(d.a * e, d.b * e, d.c * e, d.d * e, d.tx * e, d.ty * e), b.CanvasGraphics.renderGraphics(this, c);
  1447. for (var f = 0; f < this.children.length; f++) this.children[f]._renderCanvas(a);
  1448. this._mask && a.maskManager.popMask(a)
  1449. }
  1450. }, b.Graphics.prototype.getBounds = function(a) {
  1451. if (!this._currentBounds) {
  1452. if (!this.renderable) return b.EmptyRectangle;
  1453. this.dirty && (this.updateLocalBounds(), this.webGLDirty = !0, this.cachedSpriteDirty = !0, this.dirty = !1);
  1454. var c = this._localBounds,
  1455. d = c.x,
  1456. e = c.width + c.x,
  1457. f = c.y,
  1458. g = c.height + c.y,
  1459. h = a || this.worldTransform,
  1460. i = h.a,
  1461. j = h.b,
  1462. k = h.c,
  1463. l = h.d,
  1464. m = h.tx,
  1465. n = h.ty,
  1466. o = i * e + k * g + m,
  1467. p = l * g + j * e + n,
  1468. q = i * d + k * g + m,
  1469. r = l * g + j * d + n,
  1470. s = i * d + k * f + m,
  1471. t = l * f + j * d + n,
  1472. u = i * e + k * f + m,
  1473. v = l * f + j * e + n,
  1474. w = o,
  1475. x = p,
  1476. y = o,
  1477. z = p;
  1478. y = y > q ? q : y, y = y > s ? s : y, y = y > u ? u : y, z = z > r ? r : z, z = z > t ? t : z, z = z > v ? v : z, w = q > w ? q : w, w = s > w ? s : w, w = u > w ? u : w, x = r > x ? r : x, x = t > x ? t : x, x = v > x ? v : x, this._bounds.x = y, this._bounds.width = w - y, this._bounds.y = z, this._bounds.height = x - z, this._currentBounds = this._bounds
  1479. }
  1480. return this._currentBounds
  1481. }, b.Graphics.prototype.containsPoint = function(a) {
  1482. this.worldTransform.applyInverse(a, tempPoint);
  1483. for (var b = this.graphicsData, c = 0; c < b.length; c++) {
  1484. var d = b[c];
  1485. if (d.fill && d.shape && d.shape.contains(tempPoint.x, tempPoint.y)) return !0
  1486. }
  1487. return !1
  1488. }, b.Graphics.prototype.updateLocalBounds = function() {
  1489. var a = 1 / 0,
  1490. c = -1 / 0,
  1491. d = 1 / 0,
  1492. e = -1 / 0;
  1493. if (this.graphicsData.length)
  1494. for (var f, g, h, i, j, k, l = 0; l < this.graphicsData.length; l++) {
  1495. var m = this.graphicsData[l],
  1496. n = m.type,
  1497. o = m.lineWidth;
  1498. if (f = m.shape, n === b.Graphics.RECT || n === b.Graphics.RREC) h = f.x - o / 2, i = f.y - o / 2, j = f.width + o, k = f.height + o, a = a > h ? h : a, c = h + j > c ? h + j : c, d = d > i ? i : d, e = i + k > e ? i + k : e;
  1499. else if (n === b.Graphics.CIRC) h = f.x, i = f.y, j = f.radius + o / 2, k = f.radius + o / 2, a = a > h - j ? h - j : a, c = h + j > c ? h + j : c, d = d > i - k ? i - k : d, e = i + k > e ? i + k : e;
  1500. else if (n === b.Graphics.ELIP) h = f.x, i = f.y, j = f.width + o / 2, k = f.height + o / 2, a = a > h - j ? h - j : a, c = h + j > c ? h + j : c, d = d > i - k ? i - k : d, e = i + k > e ? i + k : e;
  1501. else {
  1502. g = f.points;
  1503. for (var p = 0; p < g.length; p++) g[p] instanceof Phaser.Point ? (h = g[p].x, i = g[p].y) : (h = g[p], i = g[p + 1], p < g.length - 1 && p++), a = a > h - o ? h - o : a, c = h + o > c ? h + o : c, d = d > i - o ? i - o : d, e = i + o > e ? i + o : e
  1504. }
  1505. } else a = 0, c = 0, d = 0, e = 0;
  1506. var q = this.boundsPadding;
  1507. this._localBounds.x = a - q, this._localBounds.width = c - a + 2 * q, this._localBounds.y = d - q, this._localBounds.height = e - d + 2 * q
  1508. }, b.Graphics.prototype._generateCachedSprite = function() {
  1509. var a = this.getLocalBounds();
  1510. if (this._cachedSprite) this._cachedSprite.buffer.resize(a.width, a.height);
  1511. else {
  1512. var c = new b.CanvasBuffer(a.width, a.height),
  1513. d = b.Texture.fromCanvas(c.canvas);
  1514. this._cachedSprite = new b.Sprite(d), this._cachedSprite.buffer = c, this._cachedSprite.worldTransform = this.worldTransform
  1515. }
  1516. 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), this.worldAlpha = 1, b.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context), this._cachedSprite.alpha = this.alpha
  1517. }, b.Graphics.prototype.updateCachedSpriteTexture = function() {
  1518. var a = this._cachedSprite,
  1519. b = a.texture,
  1520. c = a.buffer.canvas;
  1521. b.baseTexture.width = c.width, b.baseTexture.height = c.height, b.crop.width = b.frame.width = c.width, b.crop.height = b.frame.height = c.height, a._width = c.width, a._height = c.height, b.baseTexture.dirty()
  1522. }, b.Graphics.prototype.destroyCachedSprite = function() {
  1523. this._cachedSprite.texture.destroy(!0), this._cachedSprite = null
  1524. }, b.Graphics.prototype.drawShape = function(a) {
  1525. this.currentPath && this.currentPath.shape.points.length <= 2 && this.graphicsData.pop(), this.currentPath = null, a instanceof b.Polygon && a.flatten();
  1526. var c = new b.GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, a);
  1527. return this.graphicsData.push(c), c.type === b.Graphics.POLY && (c.shape.closed = this.filling, this.currentPath = c), this.dirty = !0, c
  1528. }, Object.defineProperty(b.Graphics.prototype, "cacheAsBitmap", {
  1529. get: function() {
  1530. return this._cacheAsBitmap
  1531. },
  1532. set: function(a) {
  1533. this._cacheAsBitmap = a, this._cacheAsBitmap ? this._generateCachedSprite() : (this.destroyCachedSprite(), this.dirty = !0)
  1534. }
  1535. }), b.GraphicsData = function(a, b, c, d, e, f, g) {
  1536. this.lineWidth = a, this.lineColor = b, this.lineAlpha = c, this._lineTint = b, this.fillColor = d, this.fillAlpha = e, this._fillTint = d, this.fill = f, this.shape = g, this.type = g.type
  1537. }, b.GraphicsData.prototype.constructor = b.GraphicsData, b.GraphicsData.prototype.clone = function() {
  1538. return new GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.fill, this.shape)
  1539. }, b.Strip = function(a) {
  1540. b.DisplayObjectContainer.call(this), this.texture = a, this.uvs = new b.Float32Array([0, 1, 1, 1, 1, 0, 0, 1]), this.vertices = 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, this.blendMode = b.blendModes.NORMAL, this.canvasPadding = 0, this.drawMode = b.Strip.DrawModes.TRIANGLE_STRIP
  1541. }, b.Strip.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Strip.prototype.constructor = b.Strip, b.Strip.prototype._renderWebGL = function(a) {
  1542. !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())
  1543. }, b.Strip.prototype._initWebGL = function(a) {
  1544. var b = a.gl;
  1545. 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.vertices, 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)
  1546. }, b.Strip.prototype._renderStrip = function(a) {
  1547. var c = a.gl,
  1548. d = a.projection,
  1549. e = a.offset,
  1550. f = a.shaderManager.stripShader,
  1551. g = this.drawMode === b.Strip.DrawModes.TRIANGLE_STRIP ? c.TRIANGLE_STRIP : c.TRIANGLES;
  1552. a.blendModeManager.setBlendMode(this.blendMode), 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, this.worldAlpha), this.dirty ? (this.dirty = !1, c.bindBuffer(c.ARRAY_BUFFER, this._vertexBuffer), c.bufferData(c.ARRAY_BUFFER, this.vertices, 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), this.texture.baseTexture._dirty[c.id] ? a.renderer.updateTexture(this.texture.baseTexture) : c.bindTexture(c.TEXTURE_2D, this.texture.baseTexture._glTextures[c.id]), 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.vertices), 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), this.texture.baseTexture._dirty[c.id] ? a.renderer.updateTexture(this.texture.baseTexture) : c.bindTexture(c.TEXTURE_2D, this.texture.baseTexture._glTextures[c.id]), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indexBuffer)), c.drawElements(g, this.indices.length, c.UNSIGNED_SHORT, 0)
  1553. }, b.Strip.prototype._renderCanvas = function(a) {
  1554. var c = a.context,
  1555. d = this.worldTransform;
  1556. a.roundPixels ? c.setTransform(d.a, d.b, d.c, d.d, 0 | d.tx, 0 | d.ty) : c.setTransform(d.a, d.b, d.c, d.d, d.tx, d.ty), this.drawMode === b.Strip.DrawModes.TRIANGLE_STRIP ? this._renderCanvasTriangleStrip(c) : this._renderCanvasTriangles(c)
  1557. }, b.Strip.prototype._renderCanvasTriangleStrip = function(a) {
  1558. var b = this.vertices,
  1559. c = this.uvs,
  1560. d = b.length / 2;
  1561. this.count++;
  1562. for (var e = 0; d - 2 > e; e++) {
  1563. var f = 2 * e;
  1564. this._renderCanvasDrawTriangle(a, b, c, f, f + 2, f + 4)
  1565. }
  1566. }, b.Strip.prototype._renderCanvasTriangles = function(a) {
  1567. var b = this.vertices,
  1568. c = this.uvs,
  1569. d = this.indices,
  1570. e = d.length;
  1571. this.count++;
  1572. for (var f = 0; e > f; f += 3) {
  1573. var g = 2 * d[f],
  1574. h = 2 * d[f + 1],
  1575. i = 2 * d[f + 2];
  1576. this._renderCanvasDrawTriangle(a, b, c, g, h, i)
  1577. }
  1578. }, b.Strip.prototype._renderCanvasDrawTriangle = function(a, b, c, d, e, f) {
  1579. var g = this.texture.baseTexture.source,
  1580. h = this.texture.width,
  1581. i = this.texture.height,
  1582. j = b[d],
  1583. k = b[e],
  1584. l = b[f],
  1585. m = b[d + 1],
  1586. n = b[e + 1],
  1587. o = b[f + 1],
  1588. p = c[d] * h,
  1589. q = c[e] * h,
  1590. r = c[f] * h,
  1591. s = c[d + 1] * i,
  1592. t = c[e + 1] * i,
  1593. u = c[f + 1] * i;
  1594. if (this.canvasPadding > 0) {
  1595. var v = this.canvasPadding / this.worldTransform.a,
  1596. w = this.canvasPadding / this.worldTransform.d,
  1597. x = (j + k + l) / 3,
  1598. y = (m + n + o) / 3,
  1599. z = j - x,
  1600. A = m - y,
  1601. B = Math.sqrt(z * z + A * A);
  1602. j = x + z / B * (B + v), m = y + A / B * (B + w), z = k - x, A = n - y, B = Math.sqrt(z * z + A * A), k = x + z / B * (B + v), n = y + A / B * (B + w), z = l - x, A = o - y, B = Math.sqrt(z * z + A * A), l = x + z / B * (B + v), o = y + A / B * (B + w)
  1603. }
  1604. a.save(), a.beginPath(), a.moveTo(j, m), a.lineTo(k, n), a.lineTo(l, o), a.closePath(), a.clip();
  1605. var C = p * t + s * r + q * u - t * r - s * q - p * u,
  1606. D = j * t + s * l + k * u - t * l - s * k - j * u,
  1607. E = p * k + j * r + q * l - k * r - j * q - p * l,
  1608. F = p * t * l + s * k * r + j * q * u - j * t * r - s * q * l - p * k * u,
  1609. G = m * t + s * o + n * u - t * o - s * n - m * u,
  1610. H = p * n + m * r + q * o - n * r - m * q - p * o,
  1611. I = p * t * o + s * n * r + m * q * u - m * t * r - s * q * o - p * n * u;
  1612. a.transform(D / C, G / C, E / C, H / C, F / C, I / C), a.drawImage(g, 0, 0), a.restore()
  1613. }, b.Strip.prototype.renderStripFlat = function(a) {
  1614. var b = this.context,
  1615. c = a.vertices,
  1616. d = c.length / 2;
  1617. this.count++, b.beginPath();
  1618. for (var e = 1; d - 2 > e; e++) {
  1619. var f = 2 * e,
  1620. g = c[f],
  1621. h = c[f + 2],
  1622. i = c[f + 4],
  1623. j = c[f + 1],
  1624. k = c[f + 3],
  1625. l = c[f + 5];
  1626. b.moveTo(g, j), b.lineTo(h, k), b.lineTo(i, l)
  1627. }
  1628. b.fillStyle = "#FF0000", b.fill(), b.closePath()
  1629. }, b.Strip.prototype.onTextureUpdate = function() {
  1630. this.updateFrame = !0
  1631. }, b.Strip.prototype.getBounds = function(a) {
  1632. for (var c = a || this.worldTransform, d = c.a, e = c.b, f = c.c, g = c.d, h = c.tx, i = c.ty, j = -1 / 0, k = -1 / 0, l = 1 / 0, m = 1 / 0, n = this.vertices, o = 0, p = n.length; p > o; o += 2) {
  1633. var q = n[o],
  1634. r = n[o + 1],
  1635. s = d * q + f * r + h,
  1636. t = g * r + e * q + i;
  1637. l = l > s ? s : l, m = m > t ? t : m, j = s > j ? s : j, k = t > k ? t : k
  1638. }
  1639. if (l === -1 / 0 || 1 / 0 === k) return b.EmptyRectangle;
  1640. var u = this._bounds;
  1641. return u.x = l, u.width = j - l, u.y = m, u.height = k - m, this._currentBounds = u, u
  1642. }, b.Strip.DrawModes = {
  1643. TRIANGLE_STRIP: 0,
  1644. TRIANGLES: 1
  1645. }, b.Rope = function(a, c) {
  1646. b.Strip.call(this, a), this.points = c, this.vertices = 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()
  1647. }, b.Rope.prototype = Object.create(b.Strip.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.refresh = function() {
  1648. var a = this.points;
  1649. if (!(a.length < 1)) {
  1650. var b = this.uvs,
  1651. c = a[0],
  1652. d = this.indices,
  1653. e = this.colors;
  1654. 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;
  1655. 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
  1656. }
  1657. }, b.Rope.prototype.updateTransform = function() {
  1658. var a = this.points;
  1659. if (!(a.length < 1)) {
  1660. var c, d = a[0],
  1661. e = {
  1662. x: 0,
  1663. y: 0
  1664. };
  1665. this.count -= .2;
  1666. for (var f, g, h, i, j, k = this.vertices, 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;
  1667. b.DisplayObjectContainer.prototype.updateTransform.call(this)
  1668. }
  1669. }, b.Rope.prototype.setTexture = function(a) {
  1670. this.texture = a
  1671. }, b.TilingSprite = function(a, c, d) {
  1672. 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
  1673. }, b.TilingSprite.prototype = Object.create(b.Sprite.prototype), b.TilingSprite.prototype.constructor = b.TilingSprite, Object.defineProperty(b.TilingSprite.prototype, "width", {
  1674. get: function() {
  1675. return this._width
  1676. },
  1677. set: function(a) {
  1678. this._width = a
  1679. }
  1680. }), Object.defineProperty(b.TilingSprite.prototype, "height", {
  1681. get: function() {
  1682. return this._height
  1683. },
  1684. set: function(a) {
  1685. this._height = a
  1686. }
  1687. }), b.TilingSprite.prototype.setTexture = function(a) {
  1688. this.texture !== a && (this.texture = a, this.refreshTexture = !0, this.cachedTint = 16777215)
  1689. }, b.TilingSprite.prototype._renderWebGL = function(a) {
  1690. if (this.visible !== !1 && 0 !== this.alpha) {
  1691. var b, c;
  1692. 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 && (a.renderer.updateTexture(this.tilingTexture.baseTexture), this.tilingTexture.needsUpdate = !1)) : a.spriteBatch.renderTilingSprite(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a);
  1693. a.spriteBatch.stop(), this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this._mask, a), a.spriteBatch.start()
  1694. }
  1695. }, b.TilingSprite.prototype._renderCanvas = function(a) {
  1696. if (this.visible !== !1 && 0 !== this.alpha) {
  1697. var c = a.context;
  1698. this._mask && a.maskManager.pushMask(this._mask, a), c.globalAlpha = this.worldAlpha;
  1699. var d, e, f = this.worldTransform,
  1700. g = a.resolution;
  1701. if (c.setTransform(f.a * g, f.b * g, f.c * g, f.d * g, f.tx * g, f.ty * g), !this.__tilePattern || this.refreshTexture) {
  1702. if (this.generateTilingTexture(!1), !this.tilingTexture) return;
  1703. this.__tilePattern = c.createPattern(this.tilingTexture.baseTexture.source, "repeat")
  1704. }
  1705. this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]);
  1706. var h = this.tilePosition,
  1707. i = this.tileScale;
  1708. for (h.x %= this.tilingTexture.baseTexture.width, h.y %= this.tilingTexture.baseTexture.height, c.scale(i.x, i.y), c.translate(h.x + this.anchor.x * -this._width, h.y + this.anchor.y * -this._height), c.fillStyle = this.__tilePattern, c.fillRect(-h.x, -h.y, this._width / i.x, this._height / i.y), c.scale(1 / i.x, 1 / i.y), c.translate(-h.x + this.anchor.x * this._width, -h.y + this.anchor.y * this._height), this._mask && a.maskManager.popMask(a), d = 0, e = this.children.length; e > d; d++) this.children[d]._renderCanvas(a)
  1709. }
  1710. }, b.TilingSprite.prototype.getBounds = function() {
  1711. var a = this._width,
  1712. b = this._height,
  1713. c = a * (1 - this.anchor.x),
  1714. d = a * -this.anchor.x,
  1715. e = b * (1 - this.anchor.y),
  1716. f = b * -this.anchor.y,
  1717. g = this.worldTransform,
  1718. h = g.a,
  1719. i = g.b,
  1720. j = g.c,
  1721. k = g.d,
  1722. l = g.tx,
  1723. m = g.ty,
  1724. n = h * d + j * f + l,
  1725. o = k * f + i * d + m,
  1726. p = h * c + j * f + l,
  1727. q = k * f + i * c + m,
  1728. r = h * c + j * e + l,
  1729. s = k * e + i * c + m,
  1730. t = h * d + j * e + l,
  1731. u = k * e + i * d + m,
  1732. v = -1 / 0,
  1733. w = -1 / 0,
  1734. x = 1 / 0,
  1735. y = 1 / 0;
  1736. 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;
  1737. var z = this._bounds;
  1738. return z.x = x, z.width = v - x, z.y = y, z.height = w - y, this._currentBounds = z, z
  1739. }, b.TilingSprite.prototype.onTextureUpdate = function() {}, b.TilingSprite.prototype.generateTilingTexture = function(a) {
  1740. if (this.texture.baseTexture.hasLoaded) {
  1741. var c, d, e = this.originalTexture || this.texture,
  1742. f = e.frame,
  1743. g = f.width !== e.baseTexture.width || f.height !== e.baseTexture.height,
  1744. h = !1;
  1745. if (a ? (e.crop ? (c = b.getNextPowerOfTwo(e.crop.width), d = b.getNextPowerOfTwo(e.crop.height)) : (c = b.getNextPowerOfTwo(f.width), d = b.getNextPowerOfTwo(f.height)), h = !0) : g && (e.crop ? (c = e.crop.width, d = e.crop.height) : (c = f.width, d = f.height), h = !0), h) {
  1746. var i;
  1747. 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
  1748. } else this.tilingTexture && this.tilingTexture.isTiling && this.tilingTexture.destroy(!0), this.tileScaleOffset.x = 1, this.tileScaleOffset.y = 1, this.tilingTexture = e;
  1749. this.refreshTexture = !1, this.originalTexture = this.texture, this.texture = this.tilingTexture, this.tilingTexture.baseTexture._powerOf2 = !0
  1750. }
  1751. }, b.TilingSprite.prototype.destroy = function() {
  1752. b.Sprite.prototype.destroy.call(this), this.tileScale = null, this.tileScaleOffset = null, this.tilePosition = null, this.tilingTexture && (this.tilingTexture.destroy(!0), this.tilingTexture = null)
  1753. }, b.BaseTextureCache = {}, b.BaseTextureCacheIdGenerator = 0, b.BaseTexture = function(a, c) {
  1754. this.resolution = 1, this.width = 100, this.height = 100, this.scaleMode = c || b.scaleModes.DEFAULT, this.hasLoaded = !1, this.source = a, this._UID = b._UID++, this.premultipliedAlpha = !0, this._glTextures = [], this.mipmap = !1, this._dirty = [!0, !0, !0, !0], a && ((this.source.complete || this.source.getContext) && this.source.width && this.source.height && (this.hasLoaded = !0, this.width = this.source.naturalWidth || this.source.width, this.height = this.source.naturalHeight || this.source.height, this.dirty()), this.imageUrl = null, this._powerOf2 = !1)
  1755. }, b.BaseTexture.prototype.constructor = b.BaseTexture, b.BaseTexture.prototype.destroy = function() {
  1756. this.imageUrl ? (delete b.BaseTextureCache[this.imageUrl], delete b.TextureCache[this.imageUrl], this.imageUrl = null, navigator.isCocoonJS || (this.source.src = "")) : this.source && this.source._pixiId && delete b.BaseTextureCache[this.source._pixiId], this.source = null, this.unloadFromGPU()
  1757. }, b.BaseTexture.prototype.updateSourceImage = function(a) {
  1758. this.hasLoaded = !1, this.source.src = null, this.source.src = a
  1759. }, b.BaseTexture.prototype.dirty = function() {
  1760. for (var a = 0; a < this._glTextures.length; a++) this._dirty[a] = !0
  1761. }, b.BaseTexture.prototype.unloadFromGPU = function() {
  1762. this.dirty();
  1763. for (var a = this._glTextures.length - 1; a >= 0; a--) {
  1764. var c = this._glTextures[a],
  1765. d = b.glContexts[a];
  1766. d && c && d.deleteTexture(c)
  1767. }
  1768. this._glTextures.length = 0, this.dirty()
  1769. }, b.BaseTexture.fromImage = function(a, c, d) {
  1770. var e = b.BaseTextureCache[a];
  1771. if (void 0 === c && -1 === a.indexOf("data:") && (c = !0), !e) {
  1772. var f = new Image;
  1773. c && (f.crossOrigin = ""), f.src = a, e = new b.BaseTexture(f, d), e.imageUrl = a, b.BaseTextureCache[a] = e, -1 !== a.indexOf(b.RETINA_PREFIX + ".") && (e.resolution = 2)
  1774. }
  1775. return e
  1776. }, b.BaseTexture.fromCanvas = function(a, c) {
  1777. a._pixiId || (a._pixiId = "canvas_" + b.TextureCacheIdGenerator++);
  1778. var d = b.BaseTextureCache[a._pixiId];
  1779. return d || (d = new b.BaseTexture(a, c), b.BaseTextureCache[a._pixiId] = d), d
  1780. }, b.TextureCache = {}, b.FrameCache = {}, b.TextureSilentFail = !1, b.TextureCacheIdGenerator = 0, b.Texture = function(a, c, d, e) {
  1781. 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 = e, this.valid = !1, this.requiresUpdate = !1, this._uvs = null, this.width = 0, this.height = 0, this.crop = d || new b.Rectangle(0, 0, 1, 1), a.hasLoaded && (this.noFrame && (c = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(c))
  1782. }, b.Texture.prototype.constructor = b.Texture, b.Texture.prototype.onBaseTextureLoaded = function() {
  1783. var a = this.baseTexture;
  1784. this.noFrame && (this.frame = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(this.frame)
  1785. }, b.Texture.prototype.destroy = function(a) {
  1786. a && this.baseTexture.destroy(), this.valid = !1
  1787. }, b.Texture.prototype.setFrame = function(a) {
  1788. 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)) {
  1789. if (!b.TextureSilentFail) throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
  1790. return void(this.valid = !1)
  1791. }
  1792. 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 && this._updateUvs()
  1793. }, b.Texture.prototype._updateUvs = function() {
  1794. this._uvs || (this._uvs = new b.TextureUvs);
  1795. var a = this.crop,
  1796. c = this.baseTexture.width,
  1797. d = this.baseTexture.height;
  1798. 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
  1799. }, b.Texture.fromImage = function(a, c, d) {
  1800. var e = b.TextureCache[a];
  1801. return e || (e = new b.Texture(b.BaseTexture.fromImage(a, c, d)), b.TextureCache[a] = e), e
  1802. }, b.Texture.fromFrame = function(a) {
  1803. var c = b.TextureCache[a];
  1804. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache ');
  1805. return c
  1806. }, b.Texture.fromCanvas = function(a, c) {
  1807. var d = b.BaseTexture.fromCanvas(a, c);
  1808. return new b.Texture(d)
  1809. }, b.Texture.addTextureToCache = function(a, c) {
  1810. b.TextureCache[c] = a
  1811. }, b.Texture.removeTextureFromCache = function(a) {
  1812. var c = b.TextureCache[a];
  1813. return delete b.TextureCache[a], delete b.BaseTextureCache[a], c
  1814. }, b.TextureUvs = function() {
  1815. this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0
  1816. }, b.RenderTexture = function(a, c, d, e, f) {
  1817. if (this.width = a || 100, this.height = c || 100, this.resolution = f || 1, this.frame = new b.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution), this.crop = new b.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution), this.baseTexture = new b.BaseTexture, this.baseTexture.width = this.width * this.resolution, this.baseTexture.height = this.height * this.resolution, this.baseTexture._glTextures = [], this.baseTexture.resolution = this.resolution, this.baseTexture.scaleMode = e || b.scaleModes.DEFAULT, this.baseTexture.hasLoaded = !0, b.Texture.call(this, this.baseTexture, new b.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution)), this.renderer = d || b.defaultRenderer, this.renderer.type === b.WEBGL_RENDERER) {
  1818. var g = this.renderer.gl;
  1819. this.baseTexture._dirty[g.id] = !1, this.textureBuffer = new b.FilterTexture(g, this.width, this.height, this.baseTexture.scaleMode), this.baseTexture._glTextures[g.id] = this.textureBuffer.texture, this.render = this.renderWebGL, this.projection = new b.Point(.5 * this.width, .5 * -this.height)
  1820. } else this.render = this.renderCanvas, this.textureBuffer = new b.CanvasBuffer(this.width * this.resolution, this.height * this.resolution), this.baseTexture.source = this.textureBuffer.canvas;
  1821. this.valid = !0, this._updateUvs()
  1822. }, b.RenderTexture.prototype = Object.create(b.Texture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.resize = function(a, c, d) {
  1823. (a !== this.width || c !== this.height) && (this.valid = a > 0 && c > 0, this.width = a, this.height = c, this.frame.width = this.crop.width = a * this.resolution, this.frame.height = this.crop.height = c * this.resolution, d && (this.baseTexture.width = this.width * this.resolution, this.baseTexture.height = this.height * this.resolution), this.renderer.type === b.WEBGL_RENDERER && (this.projection.x = this.width / 2, this.projection.y = -this.height / 2), this.valid && this.textureBuffer.resize(this.width, this.height))
  1824. }, b.RenderTexture.prototype.clear = function() {
  1825. this.valid && (this.renderer.type === b.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear())
  1826. }, b.RenderTexture.prototype.renderWebGL = function(a, b, c) {
  1827. if (this.valid) {
  1828. var d = a.worldTransform;
  1829. d.identity(), d.translate(0, 2 * this.projection.y), b && d.append(b), d.scale(1, -1), a.worldAlpha = 1;
  1830. for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
  1831. var h = this.renderer.gl;
  1832. h.viewport(0, 0, this.width * this.resolution, this.height * this.resolution), h.bindFramebuffer(h.FRAMEBUFFER, this.textureBuffer.frameBuffer), c && this.textureBuffer.clear(), this.renderer.spriteBatch.dirty = !0, this.renderer.renderDisplayObject(a, this.projection, this.textureBuffer.frameBuffer), this.renderer.spriteBatch.dirty = !0
  1833. }
  1834. }, b.RenderTexture.prototype.renderCanvas = function(a, b, c) {
  1835. if (this.valid) {
  1836. var d = a.worldTransform;
  1837. d.identity(), b && d.append(b), a.worldAlpha = 1;
  1838. for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
  1839. c && this.textureBuffer.clear();
  1840. var h = this.textureBuffer.context,
  1841. i = this.renderer.resolution;
  1842. this.renderer.resolution = this.resolution, this.renderer.renderDisplayObject(a, h), this.renderer.resolution = i
  1843. }
  1844. }, b.RenderTexture.prototype.getImage = function() {
  1845. var a = new Image;
  1846. return a.src = this.getBase64(), a
  1847. }, b.RenderTexture.prototype.getBase64 = function() {
  1848. return this.getCanvas().toDataURL()
  1849. }, b.RenderTexture.prototype.getCanvas = function() {
  1850. if (this.renderer.type === b.WEBGL_RENDERER) {
  1851. var a = this.renderer.gl,
  1852. c = this.textureBuffer.width,
  1853. d = this.textureBuffer.height,
  1854. e = new Uint8Array(4 * c * d);
  1855. a.bindFramebuffer(a.FRAMEBUFFER, this.textureBuffer.frameBuffer), a.readPixels(0, 0, c, d, a.RGBA, a.UNSIGNED_BYTE, e), a.bindFramebuffer(a.FRAMEBUFFER, null);
  1856. var f = new b.CanvasBuffer(c, d),
  1857. g = f.context.getImageData(0, 0, c, d);
  1858. return g.data.set(e), f.context.putImageData(g, 0, 0), f.canvas
  1859. }
  1860. return this.textureBuffer.canvas
  1861. }, b.AbstractFilter = function(a, b) {
  1862. this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = b || {}, this.fragmentSrc = a || []
  1863. }, b.AbstractFilter.prototype.constructor = b.AbstractFilter, b.AbstractFilter.prototype.syncUniforms = function() {
  1864. for (var a = 0, b = this.shaders.length; b > a; a++) this.shaders[a].dirty = !0
  1865. }, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.PIXI = b) : "undefined" != typeof define && define.amd ? define("PIXI", function() {
  1866. return a.PIXI = b
  1867. }()) : a.PIXI = b
  1868. }).call(this),
  1869. function() {
  1870. function a(a, b) {
  1871. this._scaleFactor = a, this._deltaMode = b, this.originalEvent = null
  1872. }
  1873. var b = this,
  1874. c = c || {
  1875. VERSION: "2.3.0",
  1876. GAMES: [],
  1877. AUTO: 0,
  1878. CANVAS: 1,
  1879. WEBGL: 2,
  1880. HEADLESS: 3,
  1881. NONE: 0,
  1882. LEFT: 1,
  1883. RIGHT: 2,
  1884. UP: 3,
  1885. DOWN: 4,
  1886. SPRITE: 0,
  1887. BUTTON: 1,
  1888. IMAGE: 2,
  1889. GRAPHICS: 3,
  1890. TEXT: 4,
  1891. TILESPRITE: 5,
  1892. BITMAPTEXT: 6,
  1893. GROUP: 7,
  1894. RENDERTEXTURE: 8,
  1895. TILEMAP: 9,
  1896. TILEMAPLAYER: 10,
  1897. EMITTER: 11,
  1898. POLYGON: 12,
  1899. BITMAPDATA: 13,
  1900. CANVAS_FILTER: 14,
  1901. WEBGL_FILTER: 15,
  1902. ELLIPSE: 16,
  1903. SPRITEBATCH: 17,
  1904. RETROFONT: 18,
  1905. POINTER: 19,
  1906. ROPE: 20,
  1907. CIRCLE: 21,
  1908. RECTANGLE: 22,
  1909. LINE: 23,
  1910. MATRIX: 24,
  1911. POINT: 25,
  1912. ROUNDEDRECTANGLE: 26,
  1913. blendModes: {
  1914. NORMAL: 0,
  1915. ADD: 1,
  1916. MULTIPLY: 2,
  1917. SCREEN: 3,
  1918. OVERLAY: 4,
  1919. DARKEN: 5,
  1920. LIGHTEN: 6,
  1921. COLOR_DODGE: 7,
  1922. COLOR_BURN: 8,
  1923. HARD_LIGHT: 9,
  1924. SOFT_LIGHT: 10,
  1925. DIFFERENCE: 11,
  1926. EXCLUSION: 12,
  1927. HUE: 13,
  1928. SATURATION: 14,
  1929. COLOR: 15,
  1930. LUMINOSITY: 16
  1931. },
  1932. scaleModes: {
  1933. DEFAULT: 0,
  1934. LINEAR: 0,
  1935. NEAREST: 1
  1936. }
  1937. };
  1938. if (Math.trunc || (Math.trunc = function(a) {
  1939. return 0 > a ? Math.ceil(a) : Math.floor(a)
  1940. }), Function.prototype.bind || (Function.prototype.bind = function() {
  1941. var a = Array.prototype.slice;
  1942. return function(b) {
  1943. function c() {
  1944. var f = e.concat(a.call(arguments));
  1945. d.apply(this instanceof c ? this : b, f)
  1946. }
  1947. var d = this,
  1948. e = a.call(arguments, 1);
  1949. if ("function" != typeof d) throw new TypeError;
  1950. return c.prototype = function f(a) {
  1951. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  1952. }(d.prototype), c
  1953. }
  1954. }()), Array.isArray || (Array.isArray = function(a) {
  1955. return "[object Array]" == Object.prototype.toString.call(a)
  1956. }), Array.prototype.forEach || (Array.prototype.forEach = function(a) {
  1957. "use strict";
  1958. if (void 0 === this || null === this) throw new TypeError;
  1959. var b = Object(this),
  1960. c = b.length >>> 0;
  1961. if ("function" != typeof a) throw new TypeError;
  1962. 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)
  1963. }), "function" != typeof window.Uint32Array && "object" != typeof window.Uint32Array) {
  1964. var d = function(a) {
  1965. var b = new Array;
  1966. window[a] = function(a) {
  1967. if ("number" == typeof a) {
  1968. Array.call(this, a), this.length = a;
  1969. for (var b = 0; b < this.length; b++) this[b] = 0
  1970. } else {
  1971. Array.call(this, a.length), this.length = a.length;
  1972. for (var b = 0; b < this.length; b++) this[b] = a[b]
  1973. }
  1974. }, window[a].prototype = b, window[a].constructor = window[a]
  1975. };
  1976. d("Uint32Array"), d("Int16Array")
  1977. }
  1978. window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), c.Utils = {
  1979. getProperty: function(a, b) {
  1980. 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++;
  1981. return a ? a[d] : null
  1982. },
  1983. setProperty: function(a, b, c) {
  1984. 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++;
  1985. return a && (a[e] = c), a
  1986. },
  1987. chanceRoll: function(a) {
  1988. return "undefined" == typeof a && (a = 50), a > 0 && 100 * Math.random() <= a
  1989. },
  1990. randomChoice: function(a, b) {
  1991. return Math.random() < .5 ? a : b
  1992. },
  1993. transposeArray: function(a) {
  1994. return c.ArrayUtils.transposeMatrix(a)
  1995. },
  1996. rotateArray: function(a, b) {
  1997. return c.ArrayUtils.rotateMatrix(a, b)
  1998. },
  1999. shuffle: function(a) {
  2000. return c.ArrayUtils.shuffle(a)
  2001. },
  2002. parseDimension: function(a, b) {
  2003. var c = 0,
  2004. d = 0;
  2005. 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
  2006. },
  2007. pad: function(a, b, c, d) {
  2008. if ("undefined" == typeof b) var b = 0;
  2009. if ("undefined" == typeof c) var c = " ";
  2010. if ("undefined" == typeof d) var d = 3;
  2011. var e = 0;
  2012. if (b + 1 >= a.length) switch (d) {
  2013. case 1:
  2014. a = new Array(b + 1 - a.length).join(c) + a;
  2015. break;
  2016. case 3:
  2017. var f = Math.ceil((e = b - a.length) / 2),
  2018. g = e - f;
  2019. a = new Array(g + 1).join(c) + a + new Array(f + 1).join(c);
  2020. break;
  2021. default:
  2022. a += new Array(b + 1 - a.length).join(c)
  2023. }
  2024. return a
  2025. },
  2026. isPlainObject: function(a) {
  2027. if ("object" != typeof a || a.nodeType || a === a.window) return !1;
  2028. try {
  2029. if (a.constructor && !{}.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) return !1
  2030. } catch (b) {
  2031. return !1
  2032. }
  2033. return !0
  2034. },
  2035. extend: function() {
  2036. var a, b, d, e, f, g, h = arguments[0] || {},
  2037. i = 1,
  2038. j = arguments.length,
  2039. k = !1;
  2040. for ("boolean" == typeof h && (k = h, h = arguments[1] || {}, i = 2), j === i && (h = this, --i); j > i; i++)
  2041. if (null != (a = arguments[i]))
  2042. for (b in a) d = h[b], e = a[b], h !== e && (k && e && (c.Utils.isPlainObject(e) || (f = Array.isArray(e))) ? (f ? (f = !1, g = d && Array.isArray(d) ? d : []) : g = d && c.Utils.isPlainObject(d) ? d : {}, h[b] = c.Utils.extend(k, g, e)) : void 0 !== e && (h[b] = e));
  2043. return h
  2044. },
  2045. mixinPrototype: function(a, b, c) {
  2046. "undefined" == typeof c && (c = !1);
  2047. for (var d = Object.keys(b), e = 0; e < d.length; e++) {
  2048. var f = d[e],
  2049. g = b[f];
  2050. !c && f in a || (!g || "function" != typeof g.get && "function" != typeof g.set ? a[f] = g : "function" == typeof g.clone ? a[f] = g.clone() : Object.defineProperty(a, f, g))
  2051. }
  2052. },
  2053. mixin: function(a, b) {
  2054. if (!a || "object" != typeof a) return b;
  2055. for (var d in a) {
  2056. var e = a[d];
  2057. if (!e.childNodes && !e.cloneNode) {
  2058. var f = typeof a[d];
  2059. b[d] = a[d] && "object" === f ? typeof b[d] === f ? c.Utils.mixin(a[d], b[d]) : c.Utils.mixin(a[d], new e.constructor) : a[d]
  2060. }
  2061. }
  2062. return b
  2063. }
  2064. }, c.Circle = function(a, b, d) {
  2065. a = a || 0, b = b || 0, d = d || 0, this.x = a, this.y = b, this._diameter = d, this._radius = 0, d > 0 && (this._radius = .5 * d), this.type = c.CIRCLE
  2066. }, c.Circle.prototype = {
  2067. circumference: function() {
  2068. return 2 * Math.PI * this._radius
  2069. },
  2070. getBounds: function() {
  2071. return new c.Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter)
  2072. },
  2073. setTo: function(a, b, c) {
  2074. return this.x = a, this.y = b, this._diameter = c, this._radius = .5 * c, this
  2075. },
  2076. copyFrom: function(a) {
  2077. return this.setTo(a.x, a.y, a.diameter)
  2078. },
  2079. copyTo: function(a) {
  2080. return a.x = this.x, a.y = this.y, a.diameter = this._diameter, a
  2081. },
  2082. distance: function(a, b) {
  2083. var d = c.Math.distance(this.x, this.y, a.x, a.y);
  2084. return b ? Math.round(d) : d
  2085. },
  2086. clone: function(a) {
  2087. return "undefined" == typeof a || null === a ? a = new c.Circle(this.x, this.y, this.diameter) : a.setTo(this.x, this.y, this.diameter), a
  2088. },
  2089. contains: function(a, b) {
  2090. return c.Circle.contains(this, a, b)
  2091. },
  2092. circumferencePoint: function(a, b, d) {
  2093. return c.Circle.circumferencePoint(this, a, b, d)
  2094. },
  2095. offset: function(a, b) {
  2096. return this.x += a, this.y += b, this
  2097. },
  2098. offsetPoint: function(a) {
  2099. return this.offset(a.x, a.y)
  2100. },
  2101. toString: function() {
  2102. return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"
  2103. }
  2104. }, c.Circle.prototype.constructor = c.Circle, Object.defineProperty(c.Circle.prototype, "diameter", {
  2105. get: function() {
  2106. return this._diameter
  2107. },
  2108. set: function(a) {
  2109. a > 0 && (this._diameter = a, this._radius = .5 * a)
  2110. }
  2111. }), Object.defineProperty(c.Circle.prototype, "radius", {
  2112. get: function() {
  2113. return this._radius
  2114. },
  2115. set: function(a) {
  2116. a > 0 && (this._radius = a, this._diameter = 2 * a)
  2117. }
  2118. }), Object.defineProperty(c.Circle.prototype, "left", {
  2119. get: function() {
  2120. return this.x - this._radius
  2121. },
  2122. set: function(a) {
  2123. a > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - a
  2124. }
  2125. }), Object.defineProperty(c.Circle.prototype, "right", {
  2126. get: function() {
  2127. return this.x + this._radius
  2128. },
  2129. set: function(a) {
  2130. a < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.x
  2131. }
  2132. }), Object.defineProperty(c.Circle.prototype, "top", {
  2133. get: function() {
  2134. return this.y - this._radius
  2135. },
  2136. set: function(a) {
  2137. a > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - a
  2138. }
  2139. }), Object.defineProperty(c.Circle.prototype, "bottom", {
  2140. get: function() {
  2141. return this.y + this._radius
  2142. },
  2143. set: function(a) {
  2144. a < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.y
  2145. }
  2146. }), Object.defineProperty(c.Circle.prototype, "area", {
  2147. get: function() {
  2148. return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
  2149. }
  2150. }), Object.defineProperty(c.Circle.prototype, "empty", {
  2151. get: function() {
  2152. return 0 === this._diameter
  2153. },
  2154. set: function(a) {
  2155. a === !0 && this.setTo(0, 0, 0)
  2156. }
  2157. }), c.Circle.contains = function(a, b, c) {
  2158. if (a.radius > 0 && b >= a.left && b <= a.right && c >= a.top && c <= a.bottom) {
  2159. var d = (a.x - b) * (a.x - b),
  2160. e = (a.y - c) * (a.y - c);
  2161. return d + e <= a.radius * a.radius
  2162. }
  2163. return !1
  2164. }, c.Circle.equals = function(a, b) {
  2165. return a.x == b.x && a.y == b.y && a.diameter == b.diameter
  2166. }, c.Circle.intersects = function(a, b) {
  2167. return c.Math.distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius
  2168. }, c.Circle.circumferencePoint = function(a, b, d, e) {
  2169. return "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = new c.Point), d === !0 && (b = c.Math.degToRad(b)), e.x = a.x + a.radius * Math.cos(b), e.y = a.y + a.radius * Math.sin(b), e
  2170. }, c.Circle.intersectsRectangle = function(a, b) {
  2171. var c = Math.abs(a.x - b.x - b.halfWidth),
  2172. d = b.halfWidth + a.radius;
  2173. if (c > d) return !1;
  2174. var e = Math.abs(a.y - b.y - b.halfHeight),
  2175. f = b.halfHeight + a.radius;
  2176. if (e > f) return !1;
  2177. if (c <= b.halfWidth || e <= b.halfHeight) return !0;
  2178. var g = c - b.halfWidth,
  2179. h = e - b.halfHeight,
  2180. i = g * g,
  2181. j = h * h,
  2182. k = a.radius * a.radius;
  2183. return k >= i + j
  2184. }, PIXI.Circle = c.Circle, c.Ellipse = function(a, b, d, e) {
  2185. a = a || 0, b = b || 0, d = d || 0, e = e || 0, this.x = a, this.y = b, this.width = d, this.height = e, this.type = c.ELLIPSE
  2186. }, c.Ellipse.prototype = {
  2187. setTo: function(a, b, c, d) {
  2188. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2189. },
  2190. getBounds: function() {
  2191. return new c.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height)
  2192. },
  2193. copyFrom: function(a) {
  2194. return this.setTo(a.x, a.y, a.width, a.height)
  2195. },
  2196. copyTo: function(a) {
  2197. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2198. },
  2199. clone: function(a) {
  2200. return "undefined" == typeof a || null === a ? a = new c.Ellipse(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  2201. },
  2202. contains: function(a, b) {
  2203. return c.Ellipse.contains(this, a, b)
  2204. },
  2205. toString: function() {
  2206. return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"
  2207. }
  2208. }, c.Ellipse.prototype.constructor = c.Ellipse, Object.defineProperty(c.Ellipse.prototype, "left", {
  2209. get: function() {
  2210. return this.x
  2211. },
  2212. set: function(a) {
  2213. this.x = a
  2214. }
  2215. }), Object.defineProperty(c.Ellipse.prototype, "right", {
  2216. get: function() {
  2217. return this.x + this.width
  2218. },
  2219. set: function(a) {
  2220. this.width = a < this.x ? 0 : a - this.x
  2221. }
  2222. }), Object.defineProperty(c.Ellipse.prototype, "top", {
  2223. get: function() {
  2224. return this.y
  2225. },
  2226. set: function(a) {
  2227. this.y = a
  2228. }
  2229. }), Object.defineProperty(c.Ellipse.prototype, "bottom", {
  2230. get: function() {
  2231. return this.y + this.height
  2232. },
  2233. set: function(a) {
  2234. this.height = a < this.y ? 0 : a - this.y
  2235. }
  2236. }), Object.defineProperty(c.Ellipse.prototype, "empty", {
  2237. get: function() {
  2238. return 0 === this.width || 0 === this.height
  2239. },
  2240. set: function(a) {
  2241. a === !0 && this.setTo(0, 0, 0, 0)
  2242. }
  2243. }), c.Ellipse.contains = function(a, b, c) {
  2244. if (a.width <= 0 || a.height <= 0) return !1;
  2245. var d = (b - a.x) / a.width - .5,
  2246. e = (c - a.y) / a.height - .5;
  2247. return d *= d, e *= e, .25 > d + e
  2248. }, PIXI.Ellipse = c.Ellipse, c.Line = function(a, b, d, e) {
  2249. a = a || 0, b = b || 0, d = d || 0, e = e || 0, this.start = new c.Point(a, b), this.end = new c.Point(d, e), this.type = c.LINE
  2250. }, c.Line.prototype = {
  2251. setTo: function(a, b, c, d) {
  2252. return this.start.setTo(a, b), this.end.setTo(c, d), this
  2253. },
  2254. fromSprite: function(a, b, c) {
  2255. 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)
  2256. },
  2257. fromAngle: function(a, b, c, d) {
  2258. return this.start.setTo(a, b), this.end.setTo(a + Math.cos(c) * d, b + Math.sin(c) * d), this
  2259. },
  2260. intersects: function(a, b, d) {
  2261. return c.Line.intersectsPoints(this.start, this.end, a.start, a.end, b, d)
  2262. },
  2263. reflect: function(a) {
  2264. return c.Line.reflect(this, a)
  2265. },
  2266. pointOnLine: function(a, b) {
  2267. return (a - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (b - this.start.y)
  2268. },
  2269. pointOnSegment: function(a, b) {
  2270. var c = Math.min(this.start.x, this.end.x),
  2271. d = Math.max(this.start.x, this.end.x),
  2272. e = Math.min(this.start.y, this.end.y),
  2273. f = Math.max(this.start.y, this.end.y);
  2274. return this.pointOnLine(a, b) && a >= c && d >= a && b >= e && f >= b
  2275. },
  2276. coordinatesOnLine: function(a, b) {
  2277. "undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = []);
  2278. var c = Math.round(this.start.x),
  2279. d = Math.round(this.start.y),
  2280. e = Math.round(this.end.x),
  2281. f = Math.round(this.end.y),
  2282. g = Math.abs(e - c),
  2283. h = Math.abs(f - d),
  2284. i = e > c ? 1 : -1,
  2285. j = f > d ? 1 : -1,
  2286. k = g - h;
  2287. b.push([c, d]);
  2288. for (var l = 1; c != e || d != f;) {
  2289. var m = k << 1;
  2290. m > -h && (k -= h, c += i), g > m && (k += g, d += j), l % a === 0 && b.push([c, d]), l++
  2291. }
  2292. return b
  2293. },
  2294. clone: function(a) {
  2295. return "undefined" == typeof a || null === a ? a = new c.Line(this.start.x, this.start.y, this.end.x, this.end.y) : a.setTo(this.start.x, this.start.y, this.end.x, this.end.y), a
  2296. }
  2297. }, Object.defineProperty(c.Line.prototype, "length", {
  2298. get: function() {
  2299. 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))
  2300. }
  2301. }), Object.defineProperty(c.Line.prototype, "angle", {
  2302. get: function() {
  2303. return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x)
  2304. }
  2305. }), Object.defineProperty(c.Line.prototype, "slope", {
  2306. get: function() {
  2307. return (this.end.y - this.start.y) / (this.end.x - this.start.x)
  2308. }
  2309. }), Object.defineProperty(c.Line.prototype, "perpSlope", {
  2310. get: function() {
  2311. return -((this.end.x - this.start.x) / (this.end.y - this.start.y))
  2312. }
  2313. }), Object.defineProperty(c.Line.prototype, "x", {
  2314. get: function() {
  2315. return Math.min(this.start.x, this.end.x)
  2316. }
  2317. }), Object.defineProperty(c.Line.prototype, "y", {
  2318. get: function() {
  2319. return Math.min(this.start.y, this.end.y)
  2320. }
  2321. }), Object.defineProperty(c.Line.prototype, "left", {
  2322. get: function() {
  2323. return Math.min(this.start.x, this.end.x)
  2324. }
  2325. }), Object.defineProperty(c.Line.prototype, "right", {
  2326. get: function() {
  2327. return Math.max(this.start.x, this.end.x)
  2328. }
  2329. }), Object.defineProperty(c.Line.prototype, "top", {
  2330. get: function() {
  2331. return Math.min(this.start.y, this.end.y)
  2332. }
  2333. }), Object.defineProperty(c.Line.prototype, "bottom", {
  2334. get: function() {
  2335. return Math.max(this.start.y, this.end.y)
  2336. }
  2337. }), Object.defineProperty(c.Line.prototype, "width", {
  2338. get: function() {
  2339. return Math.abs(this.start.x - this.end.x)
  2340. }
  2341. }), Object.defineProperty(c.Line.prototype, "height", {
  2342. get: function() {
  2343. return Math.abs(this.start.y - this.end.y)
  2344. }
  2345. }), Object.defineProperty(c.Line.prototype, "normalX", {
  2346. get: function() {
  2347. return Math.cos(this.angle - 1.5707963267948966)
  2348. }
  2349. }), Object.defineProperty(c.Line.prototype, "normalY", {
  2350. get: function() {
  2351. return Math.sin(this.angle - 1.5707963267948966)
  2352. }
  2353. }), Object.defineProperty(c.Line.prototype, "normalAngle", {
  2354. get: function() {
  2355. return c.Math.wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI)
  2356. }
  2357. }), c.Line.intersectsPoints = function(a, b, d, e, f, g) {
  2358. "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = new c.Point);
  2359. var h = b.y - a.y,
  2360. i = e.y - d.y,
  2361. j = a.x - b.x,
  2362. k = d.x - e.x,
  2363. l = b.x * a.y - a.x * b.y,
  2364. m = e.x * d.y - d.x * e.y,
  2365. n = h * k - i * j;
  2366. if (0 === n) return null;
  2367. if (g.x = (j * m - k * l) / n, g.y = (i * l - h * m) / n, f) {
  2368. var o = (e.y - d.y) * (b.x - a.x) - (e.x - d.x) * (b.y - a.y),
  2369. p = ((e.x - d.x) * (a.y - d.y) - (e.y - d.y) * (a.x - d.x)) / o,
  2370. q = ((b.x - a.x) * (a.y - d.y) - (b.y - a.y) * (a.x - d.x)) / o;
  2371. return p >= 0 && 1 >= p && q >= 0 && 1 >= q ? g : null
  2372. }
  2373. return g
  2374. }, c.Line.intersects = function(a, b, d, e) {
  2375. return c.Line.intersectsPoints(a.start, a.end, b.start, b.end, d, e)
  2376. }, c.Line.reflect = function(a, b) {
  2377. return 2 * b.normalAngle - 3.141592653589793 - a.angle
  2378. }, c.Matrix = function() {
  2379. this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this.type = c.MATRIX
  2380. }, c.Matrix.prototype.fromArray = function(a) {
  2381. this.a = a[0], this.b = a[1], this.c = a[3], this.d = a[4], this.tx = a[2], this.ty = a[5]
  2382. }, c.Matrix.prototype.toArray = function(a) {
  2383. this.array || (this.array = new PIXI.Float32Array(9));
  2384. var b = this.array;
  2385. return a ? (b[0] = this.a, b[1] = this.b, b[2] = 0, b[3] = this.c, 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.c, b[2] = this.tx, b[3] = this.b, b[4] = this.d, b[5] = this.ty, b[6] = 0, b[7] = 0, b[8] = 1), b
  2386. }, c.Matrix.prototype.apply = function(a, b) {
  2387. b = b || new c.Point;
  2388. var d = a.x,
  2389. e = a.y;
  2390. return b.x = this.a * d + this.c * e + this.tx, b.y = this.b * d + this.d * e + this.ty, b
  2391. }, c.Matrix.prototype.applyInverse = function(a, b) {
  2392. b = b || new c.Point;
  2393. var d = 1 / (this.a * this.d + this.c * -this.b),
  2394. e = a.x,
  2395. f = a.y;
  2396. return b.x = this.d * d * e + -this.c * d * f + (this.ty * this.c - this.tx * this.d) * d, b.y = this.a * d * f + -this.b * d * e + (-this.ty * this.a + this.tx * this.b) * d, b
  2397. }, c.Matrix.prototype.translate = function(a, b) {
  2398. return this.tx += a, this.ty += b, this
  2399. }, c.Matrix.prototype.scale = function(a, b) {
  2400. return this.a *= a, this.d *= b, this.c *= a, this.b *= b, this.tx *= a, this.ty *= b, this
  2401. }, c.Matrix.prototype.rotate = function(a) {
  2402. var b = Math.cos(a),
  2403. c = Math.sin(a),
  2404. d = this.a,
  2405. e = this.c,
  2406. f = this.tx;
  2407. return this.a = d * b - this.b * c, this.b = d * c + this.b * b, this.c = e * b - this.d * c, this.d = e * c + this.d * b, this.tx = f * b - this.ty * c, this.ty = f * c + this.ty * b, this
  2408. }, c.Matrix.prototype.append = function(a) {
  2409. var b = this.a,
  2410. c = this.b,
  2411. d = this.c,
  2412. e = this.d;
  2413. return this.a = a.a * b + a.b * d, this.b = a.a * c + a.b * e, this.c = a.c * b + a.d * d, this.d = a.c * c + a.d * e, this.tx = a.tx * b + a.ty * d + this.tx, this.ty = a.tx * c + a.ty * e + this.ty, this
  2414. }, c.Matrix.prototype.identity = function() {
  2415. return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this
  2416. }, c.identityMatrix = new c.Matrix, PIXI.Matrix = c.Matrix, PIXI.identityMatrix = c.identityMatrix, c.Point = function(a, b) {
  2417. a = a || 0, b = b || 0, this.x = a, this.y = b, this.type = c.POINT
  2418. }, c.Point.prototype = {
  2419. copyFrom: function(a) {
  2420. return this.setTo(a.x, a.y)
  2421. },
  2422. invert: function() {
  2423. return this.setTo(this.y, this.x)
  2424. },
  2425. setTo: function(a, b) {
  2426. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2427. },
  2428. set: function(a, b) {
  2429. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2430. },
  2431. add: function(a, b) {
  2432. return this.x += a, this.y += b, this
  2433. },
  2434. subtract: function(a, b) {
  2435. return this.x -= a, this.y -= b, this
  2436. },
  2437. multiply: function(a, b) {
  2438. return this.x *= a, this.y *= b, this
  2439. },
  2440. divide: function(a, b) {
  2441. return this.x /= a, this.y /= b, this
  2442. },
  2443. clampX: function(a, b) {
  2444. return this.x = c.Math.clamp(this.x, a, b), this
  2445. },
  2446. clampY: function(a, b) {
  2447. return this.y = c.Math.clamp(this.y, a, b), this
  2448. },
  2449. clamp: function(a, b) {
  2450. return this.x = c.Math.clamp(this.x, a, b), this.y = c.Math.clamp(this.y, a, b), this
  2451. },
  2452. clone: function(a) {
  2453. return "undefined" == typeof a || null === a ? a = new c.Point(this.x, this.y) : a.setTo(this.x, this.y), a
  2454. },
  2455. copyTo: function(a) {
  2456. return a.x = this.x, a.y = this.y, a
  2457. },
  2458. distance: function(a, b) {
  2459. return c.Point.distance(this, a, b)
  2460. },
  2461. equals: function(a) {
  2462. return a.x === this.x && a.y === this.y
  2463. },
  2464. angle: function(a, b) {
  2465. return "undefined" == typeof b && (b = !1), b ? c.Math.radToDeg(Math.atan2(a.y - this.y, a.x - this.x)) : Math.atan2(a.y - this.y, a.x - this.x)
  2466. },
  2467. rotate: function(a, b, d, e, f) {
  2468. return c.Point.rotate(this, a, b, d, e, f)
  2469. },
  2470. getMagnitude: function() {
  2471. return Math.sqrt(this.x * this.x + this.y * this.y)
  2472. },
  2473. getMagnitudeSq: function() {
  2474. return this.x * this.x + this.y * this.y
  2475. },
  2476. setMagnitude: function(a) {
  2477. return this.normalize().multiply(a, a)
  2478. },
  2479. normalize: function() {
  2480. if (!this.isZero()) {
  2481. var a = this.getMagnitude();
  2482. this.x /= a, this.y /= a
  2483. }
  2484. return this
  2485. },
  2486. isZero: function() {
  2487. return 0 === this.x && 0 === this.y
  2488. },
  2489. dot: function(a) {
  2490. return this.x * a.x + this.y * a.y
  2491. },
  2492. cross: function(a) {
  2493. return this.x * a.y - this.y * a.x
  2494. },
  2495. perp: function() {
  2496. return this.setTo(-this.y, this.x)
  2497. },
  2498. rperp: function() {
  2499. return this.setTo(this.y, -this.x)
  2500. },
  2501. normalRightHand: function() {
  2502. return this.setTo(-1 * this.y, this.x)
  2503. },
  2504. floor: function() {
  2505. return this.setTo(Math.floor(this.x), Math.floor(this.y))
  2506. },
  2507. ceil: function() {
  2508. return this.setTo(Math.ceil(this.x), Math.ceil(this.y))
  2509. },
  2510. toString: function() {
  2511. return "[{Point (x=" + this.x + " y=" + this.y + ")}]"
  2512. }
  2513. }, c.Point.prototype.constructor = c.Point, c.Point.add = function(a, b, d) {
  2514. return "undefined" == typeof d && (d = new c.Point), d.x = a.x + b.x, d.y = a.y + b.y, d
  2515. }, c.Point.subtract = function(a, b, d) {
  2516. return "undefined" == typeof d && (d = new c.Point), d.x = a.x - b.x, d.y = a.y - b.y, d
  2517. }, c.Point.multiply = function(a, b, d) {
  2518. return "undefined" == typeof d && (d = new c.Point), d.x = a.x * b.x, d.y = a.y * b.y, d
  2519. }, c.Point.divide = function(a, b, d) {
  2520. return "undefined" == typeof d && (d = new c.Point), d.x = a.x / b.x, d.y = a.y / b.y, d
  2521. }, c.Point.equals = function(a, b) {
  2522. return a.x === b.x && a.y === b.y
  2523. }, c.Point.angle = function(a, b) {
  2524. return Math.atan2(a.y - b.y, a.x - b.x)
  2525. }, c.Point.negative = function(a, b) {
  2526. return "undefined" == typeof b && (b = new c.Point), b.setTo(-a.x, -a.y)
  2527. }, c.Point.multiplyAdd = function(a, b, d, e) {
  2528. return "undefined" == typeof e && (e = new c.Point), e.setTo(a.x + b.x * d, a.y + b.y * d)
  2529. }, c.Point.interpolate = function(a, b, d, e) {
  2530. return "undefined" == typeof e && (e = new c.Point), e.setTo(a.x + (b.x - a.x) * d, a.y + (b.y - a.y) * d)
  2531. }, c.Point.perp = function(a, b) {
  2532. return "undefined" == typeof b && (b = new c.Point), b.setTo(-a.y, a.x)
  2533. }, c.Point.rperp = function(a, b) {
  2534. return "undefined" == typeof b && (b = new c.Point), b.setTo(a.y, -a.x)
  2535. }, c.Point.distance = function(a, b, d) {
  2536. var e = c.Math.distance(a.x, a.y, b.x, b.y);
  2537. return d ? Math.round(e) : e
  2538. }, c.Point.project = function(a, b, d) {
  2539. "undefined" == typeof d && (d = new c.Point);
  2540. var e = a.dot(b) / b.getMagnitudeSq();
  2541. return 0 !== e && d.setTo(e * b.x, e * b.y), d
  2542. }, c.Point.projectUnit = function(a, b, d) {
  2543. "undefined" == typeof d && (d = new c.Point);
  2544. var e = a.dot(b);
  2545. return 0 !== e && d.setTo(e * b.x, e * b.y), d
  2546. }, c.Point.normalRightHand = function(a, b) {
  2547. return "undefined" == typeof b && (b = new c.Point), b.setTo(-1 * a.y, a.x)
  2548. }, c.Point.normalize = function(a, b) {
  2549. "undefined" == typeof b && (b = new c.Point);
  2550. var d = a.getMagnitude();
  2551. return 0 !== d && b.setTo(a.x / d, a.y / d), b
  2552. }, c.Point.rotate = function(a, b, d, e, f, g) {
  2553. f = f || !1, g = g || null, f && (e = c.Math.degToRad(e)), null === g && (g = Math.sqrt((b - a.x) * (b - a.x) + (d - a.y) * (d - a.y)));
  2554. var h = e + Math.atan2(a.y - d, a.x - b);
  2555. return a.setTo(b + g * Math.cos(h), d + g * Math.sin(h))
  2556. }, c.Point.centroid = function(a, b) {
  2557. if ("undefined" == typeof b && (b = new c.Point), "[object Array]" !== Object.prototype.toString.call(a)) throw new Error("Phaser.Point. Parameter 'points' must be an array");
  2558. var d = a.length;
  2559. if (1 > d) throw new Error("Phaser.Point. Parameter 'points' array must not be empty");
  2560. if (1 === d) return b.copyFrom(a[0]), b;
  2561. for (var e = 0; d > e; e++) c.Point.add(b, a[e], b);
  2562. return b.divide(d, d), b
  2563. }, c.Point.parse = function(a, b, d) {
  2564. b = b || "x", d = d || "y";
  2565. var e = new c.Point;
  2566. return a[b] && (e.x = parseInt(a[b], 10)), a[d] && (e.y = parseInt(a[d], 10)), e
  2567. }, PIXI.Point = c.Point, c.Polygon = function() {
  2568. this.area = 0, this._points = [], arguments.length > 0 && this.setTo.apply(this, arguments), this.closed = !0, this.type = c.POLYGON
  2569. }, c.Polygon.prototype = {
  2570. toNumberArray: function(a) {
  2571. "undefined" == typeof a && (a = []);
  2572. for (var b = 0; b < this._points.length; b++) "number" == typeof this._points[b] ? (a.push(this._points[b]), a.push(this._points[b + 1]), b++) : (a.push(this._points[b].x), a.push(this._points[b].y));
  2573. return a
  2574. },
  2575. flatten: function() {
  2576. return this._points = this.toNumberArray(), this
  2577. },
  2578. clone: function(a) {
  2579. var b = this._points.slice();
  2580. return "undefined" == typeof a || null === a ? a = new c.Polygon(b) : a.setTo(b), a
  2581. },
  2582. contains: function(a, b) {
  2583. for (var c = this._points.length, d = !1, e = -1, f = c - 1; ++e < c; f = e) {
  2584. var g = this._points[e].x,
  2585. h = this._points[e].y,
  2586. i = this._points[f].x,
  2587. j = this._points[f].y;
  2588. (b >= h && j > b || b >= j && h > b) && (i - g) * (b - h) / (j - h) + g > a && (d = !d)
  2589. }
  2590. return d
  2591. },
  2592. setTo: function(a) {
  2593. if (this.area = 0, this._points = [], arguments.length > 0) {
  2594. Array.isArray(a) || (a = Array.prototype.slice.call(arguments));
  2595. for (var b = Number.MAX_VALUE, c = 0, d = a.length; d > c; c++) {
  2596. if ("number" == typeof a[c]) {
  2597. var e = new PIXI.Point(a[c], a[c + 1]);
  2598. c++
  2599. } else var e = new PIXI.Point(a[c].x, a[c].y);
  2600. this._points.push(e), e.y < b && (b = e.y)
  2601. }
  2602. this.calculateArea(b)
  2603. }
  2604. return this
  2605. },
  2606. calculateArea: function(a) {
  2607. for (var b, c, d, e, f = 0, g = this._points.length; g > f; f++) b = this._points[f], c = f === g - 1 ? this._points[0] : this._points[f + 1], d = (b.y - a + (c.y - a)) / 2, e = b.x - c.x, this.area += d * e;
  2608. return this.area
  2609. }
  2610. }, c.Polygon.prototype.constructor = c.Polygon, Object.defineProperty(c.Polygon.prototype, "points", {
  2611. get: function() {
  2612. return this._points
  2613. },
  2614. set: function(a) {
  2615. null != a ? this.setTo(a) : this.setTo()
  2616. }
  2617. }), PIXI.Polygon = c.Polygon, c.Rectangle = function(a, b, d, e) {
  2618. a = a || 0, b = b || 0, d = d || 0, e = e || 0, this.x = a, this.y = b, this.width = d, this.height = e, this.type = c.RECTANGLE
  2619. }, c.Rectangle.prototype = {
  2620. offset: function(a, b) {
  2621. return this.x += a, this.y += b, this
  2622. },
  2623. offsetPoint: function(a) {
  2624. return this.offset(a.x, a.y)
  2625. },
  2626. setTo: function(a, b, c, d) {
  2627. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2628. },
  2629. scale: function(a, b) {
  2630. return "undefined" == typeof b && (b = a), this.width *= a, this.height *= b, this
  2631. },
  2632. centerOn: function(a, b) {
  2633. return this.centerX = a, this.centerY = b, this
  2634. },
  2635. floor: function() {
  2636. this.x = Math.floor(this.x), this.y = Math.floor(this.y)
  2637. },
  2638. floorAll: function() {
  2639. this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height)
  2640. },
  2641. copyFrom: function(a) {
  2642. return this.setTo(a.x, a.y, a.width, a.height)
  2643. },
  2644. copyTo: function(a) {
  2645. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2646. },
  2647. inflate: function(a, b) {
  2648. return c.Rectangle.inflate(this, a, b)
  2649. },
  2650. size: function(a) {
  2651. return c.Rectangle.size(this, a)
  2652. },
  2653. clone: function(a) {
  2654. return c.Rectangle.clone(this, a)
  2655. },
  2656. contains: function(a, b) {
  2657. return c.Rectangle.contains(this, a, b)
  2658. },
  2659. containsRect: function(a) {
  2660. return c.Rectangle.containsRect(a, this)
  2661. },
  2662. equals: function(a) {
  2663. return c.Rectangle.equals(this, a)
  2664. },
  2665. intersection: function(a, b) {
  2666. return c.Rectangle.intersection(this, a, b)
  2667. },
  2668. intersects: function(a) {
  2669. return c.Rectangle.intersects(this, a)
  2670. },
  2671. intersectsRaw: function(a, b, d, e, f) {
  2672. return c.Rectangle.intersectsRaw(this, a, b, d, e, f)
  2673. },
  2674. union: function(a, b) {
  2675. return c.Rectangle.union(this, a, b)
  2676. },
  2677. toString: function() {
  2678. return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"
  2679. }
  2680. }, Object.defineProperty(c.Rectangle.prototype, "halfWidth", {
  2681. get: function() {
  2682. return Math.round(this.width / 2)
  2683. }
  2684. }), Object.defineProperty(c.Rectangle.prototype, "halfHeight", {
  2685. get: function() {
  2686. return Math.round(this.height / 2)
  2687. }
  2688. }), Object.defineProperty(c.Rectangle.prototype, "bottom", {
  2689. get: function() {
  2690. return this.y + this.height
  2691. },
  2692. set: function(a) {
  2693. this.height = a <= this.y ? 0 : a - this.y
  2694. }
  2695. }), Object.defineProperty(c.Rectangle.prototype, "bottomRight", {
  2696. get: function() {
  2697. return new c.Point(this.right, this.bottom)
  2698. },
  2699. set: function(a) {
  2700. this.right = a.x, this.bottom = a.y
  2701. }
  2702. }), Object.defineProperty(c.Rectangle.prototype, "left", {
  2703. get: function() {
  2704. return this.x
  2705. },
  2706. set: function(a) {
  2707. this.width = a >= this.right ? 0 : this.right - a, this.x = a
  2708. }
  2709. }), Object.defineProperty(c.Rectangle.prototype, "right", {
  2710. get: function() {
  2711. return this.x + this.width
  2712. },
  2713. set: function(a) {
  2714. this.width = a <= this.x ? 0 : a - this.x
  2715. }
  2716. }), Object.defineProperty(c.Rectangle.prototype, "volume", {
  2717. get: function() {
  2718. return this.width * this.height
  2719. }
  2720. }), Object.defineProperty(c.Rectangle.prototype, "perimeter", {
  2721. get: function() {
  2722. return 2 * this.width + 2 * this.height
  2723. }
  2724. }), Object.defineProperty(c.Rectangle.prototype, "centerX", {
  2725. get: function() {
  2726. return this.x + this.halfWidth
  2727. },
  2728. set: function(a) {
  2729. this.x = a - this.halfWidth
  2730. }
  2731. }), Object.defineProperty(c.Rectangle.prototype, "centerY", {
  2732. get: function() {
  2733. return this.y + this.halfHeight
  2734. },
  2735. set: function(a) {
  2736. this.y = a - this.halfHeight
  2737. }
  2738. }), Object.defineProperty(c.Rectangle.prototype, "randomX", {
  2739. get: function() {
  2740. return this.x + Math.random() * this.width
  2741. }
  2742. }), Object.defineProperty(c.Rectangle.prototype, "randomY", {
  2743. get: function() {
  2744. return this.y + Math.random() * this.height
  2745. }
  2746. }), Object.defineProperty(c.Rectangle.prototype, "top", {
  2747. get: function() {
  2748. return this.y
  2749. },
  2750. set: function(a) {
  2751. a >= this.bottom ? (this.height = 0, this.y = a) : this.height = this.bottom - a
  2752. }
  2753. }), Object.defineProperty(c.Rectangle.prototype, "topLeft", {
  2754. get: function() {
  2755. return new c.Point(this.x, this.y)
  2756. },
  2757. set: function(a) {
  2758. this.x = a.x, this.y = a.y
  2759. }
  2760. }), Object.defineProperty(c.Rectangle.prototype, "topRight", {
  2761. get: function() {
  2762. return new c.Point(this.x + this.width, this.y)
  2763. },
  2764. set: function(a) {
  2765. this.right = a.x, this.y = a.y
  2766. }
  2767. }), Object.defineProperty(c.Rectangle.prototype, "empty", {
  2768. get: function() {
  2769. return !this.width || !this.height
  2770. },
  2771. set: function(a) {
  2772. a === !0 && this.setTo(0, 0, 0, 0)
  2773. }
  2774. }), c.Rectangle.prototype.constructor = c.Rectangle, c.Rectangle.inflate = function(a, b, c) {
  2775. return a.x -= b, a.width += 2 * b, a.y -= c, a.height += 2 * c, a
  2776. }, c.Rectangle.inflatePoint = function(a, b) {
  2777. return c.Rectangle.inflate(a, b.x, b.y)
  2778. }, c.Rectangle.size = function(a, b) {
  2779. return "undefined" == typeof b || null === b ? b = new c.Point(a.width, a.height) : b.setTo(a.width, a.height), b
  2780. }, c.Rectangle.clone = function(a, b) {
  2781. return "undefined" == typeof b || null === b ? b = new c.Rectangle(a.x, a.y, a.width, a.height) : b.setTo(a.x, a.y, a.width, a.height), b
  2782. }, c.Rectangle.contains = function(a, b, c) {
  2783. return a.width <= 0 || a.height <= 0 ? !1 : b >= a.x && b < a.right && c >= a.y && c < a.bottom
  2784. }, c.Rectangle.containsRaw = function(a, b, c, d, e, f) {
  2785. return e >= a && a + c > e && f >= b && b + d > f
  2786. }, c.Rectangle.containsPoint = function(a, b) {
  2787. return c.Rectangle.contains(a, b.x, b.y)
  2788. }, c.Rectangle.containsRect = function(a, b) {
  2789. return a.volume > b.volume ? !1 : a.x >= b.x && a.y >= b.y && a.right < b.right && a.bottom < b.bottom
  2790. }, c.Rectangle.equals = function(a, b) {
  2791. return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
  2792. }, c.Rectangle.sameDimensions = function(a, b) {
  2793. return a.width === b.width && a.height === b.height
  2794. }, c.Rectangle.intersection = function(a, b, d) {
  2795. return "undefined" == typeof d && (d = new c.Rectangle), c.Rectangle.intersects(a, b) && (d.x = Math.max(a.x, b.x), d.y = Math.max(a.y, b.y), d.width = Math.min(a.right, b.right) - d.x, d.height = Math.min(a.bottom, b.bottom) - d.y), d
  2796. }, c.Rectangle.intersects = function(a, b) {
  2797. 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)
  2798. }, c.Rectangle.intersectsRaw = function(a, b, c, d, e, f) {
  2799. return "undefined" == typeof f && (f = 0), !(b > a.right + f || c < a.left - f || d > a.bottom + f || e < a.top - f)
  2800. }, c.Rectangle.union = function(a, b, d) {
  2801. return "undefined" == typeof d && (d = new c.Rectangle), d.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top))
  2802. }, c.Rectangle.aabb = function(a, b) {
  2803. "undefined" == typeof b && (b = new c.Rectangle);
  2804. var d = Number.MIN_VALUE,
  2805. e = Number.MAX_VALUE,
  2806. f = Number.MIN_VALUE,
  2807. g = Number.MAX_VALUE;
  2808. return a.forEach(function(a) {
  2809. a.x > d && (d = a.x), a.x < e && (e = a.x), a.y > f && (f = a.y), a.y < g && (g = a.y)
  2810. }), b.setTo(e, g, d - e, f - g), b
  2811. }, PIXI.Rectangle = c.Rectangle, PIXI.EmptyRectangle = new c.Rectangle(0, 0, 0, 0), c.RoundedRectangle = function(a, b, d, e, f) {
  2812. this.x = a || 0, this.y = b || 0, this.width = d || 0, this.height = e || 0, this.radius = f || 20, this.type = c.ROUNDEDRECTANGLE
  2813. }, c.RoundedRectangle.prototype.clone = function() {
  2814. return new c.RoundedRectangle(this.x, this.y, this.width, this.height, this.radius)
  2815. }, c.RoundedRectangle.prototype.contains = function(a, b) {
  2816. if (this.width <= 0 || this.height <= 0) return !1;
  2817. var c = this.x;
  2818. if (a >= c && a <= c + this.width) {
  2819. var d = this.y;
  2820. if (b >= d && b <= d + this.height) return !0
  2821. }
  2822. return !1
  2823. }, c.RoundedRectangle.prototype.constructor = c.RoundedRectangle, PIXI.RoundedRectangle = c.RoundedRectangle, c.Camera = function(a, b, d, e, f, g) {
  2824. this.game = a, this.world = a.world, this.id = 0, this.view = new c.Rectangle(d, e, f, g), this.screenView = new c.Rectangle(d, e, f, g), this.bounds = new c.Rectangle(d, e, f, g), this.deadzone = null, this.visible = !0, this.roundPx = !0, this.atLimit = {
  2825. x: !1,
  2826. y: !1
  2827. }, this.target = null, this.displayObject = null, this.scale = null, this.totalInView = 0, this._targetPosition = new c.Point, this._edge = 0, this._position = new c.Point
  2828. }, c.Camera.FOLLOW_LOCKON = 0, c.Camera.FOLLOW_PLATFORMER = 1, c.Camera.FOLLOW_TOPDOWN = 2, c.Camera.FOLLOW_TOPDOWN_TIGHT = 3, c.Camera.prototype = {
  2829. preUpdate: function() {
  2830. this.totalInView = 0
  2831. },
  2832. follow: function(a, b) {
  2833. "undefined" == typeof b && (b = c.Camera.FOLLOW_LOCKON), this.target = a;
  2834. var d;
  2835. switch (b) {
  2836. case c.Camera.FOLLOW_PLATFORMER:
  2837. var e = this.width / 8,
  2838. f = this.height / 3;
  2839. this.deadzone = new c.Rectangle((this.width - e) / 2, (this.height - f) / 2 - .25 * f, e, f);
  2840. break;
  2841. case c.Camera.FOLLOW_TOPDOWN:
  2842. d = Math.max(this.width, this.height) / 4, this.deadzone = new c.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2843. break;
  2844. case c.Camera.FOLLOW_TOPDOWN_TIGHT:
  2845. d = Math.max(this.width, this.height) / 8, this.deadzone = new c.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2846. break;
  2847. case c.Camera.FOLLOW_LOCKON:
  2848. this.deadzone = null;
  2849. break;
  2850. default:
  2851. this.deadzone = null
  2852. }
  2853. },
  2854. unfollow: function() {
  2855. this.target = null
  2856. },
  2857. focusOn: function(a) {
  2858. this.setPosition(Math.round(a.x - this.view.halfWidth), Math.round(a.y - this.view.halfHeight))
  2859. },
  2860. focusOnXY: function(a, b) {
  2861. this.setPosition(Math.round(a - this.view.halfWidth), Math.round(b - this.view.halfHeight))
  2862. },
  2863. update: function() {
  2864. this.target && this.updateTarget(), this.bounds && this.checkBounds(), this.roundPx && this.view.floor(), this.displayObject.position.x = -this.view.x, this.displayObject.position.y = -this.view.y
  2865. },
  2866. updateTarget: function() {
  2867. this._targetPosition.copyFrom(this.target), this.target.parent && this._targetPosition.multiply(this.target.parent.worldTransform.a, this.target.parent.worldTransform.d), this.deadzone ? (this._edge = this._targetPosition.x - this.view.x, this._edge < this.deadzone.left ? this.view.x = this._targetPosition.x - this.deadzone.left : this._edge > this.deadzone.right && (this.view.x = this._targetPosition.x - this.deadzone.right), this._edge = this._targetPosition.y - this.view.y, this._edge < this.deadzone.top ? this.view.y = this._targetPosition.y - this.deadzone.top : this._edge > this.deadzone.bottom && (this.view.y = this._targetPosition.y - this.deadzone.bottom)) : (this.view.x = this._targetPosition.x - this.view.halfWidth, this.view.y = this._targetPosition.y - this.view.halfHeight)
  2868. },
  2869. setBoundsToWorld: function() {
  2870. this.bounds && this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  2871. },
  2872. checkBounds: function() {
  2873. 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)
  2874. },
  2875. setPosition: function(a, b) {
  2876. this.view.x = a, this.view.y = b, this.bounds && this.checkBounds()
  2877. },
  2878. setSize: function(a, b) {
  2879. this.view.width = a, this.view.height = b
  2880. },
  2881. reset: function() {
  2882. this.target = null, this.view.x = 0, this.view.y = 0
  2883. }
  2884. }, c.Camera.prototype.constructor = c.Camera, Object.defineProperty(c.Camera.prototype, "x", {
  2885. get: function() {
  2886. return this.view.x
  2887. },
  2888. set: function(a) {
  2889. this.view.x = a, this.bounds && this.checkBounds()
  2890. }
  2891. }), Object.defineProperty(c.Camera.prototype, "y", {
  2892. get: function() {
  2893. return this.view.y
  2894. },
  2895. set: function(a) {
  2896. this.view.y = a, this.bounds && this.checkBounds()
  2897. }
  2898. }), Object.defineProperty(c.Camera.prototype, "position", {
  2899. get: function() {
  2900. return this._position.set(this.view.centerX, this.view.centerY), this._position
  2901. },
  2902. set: function(a) {
  2903. "undefined" != typeof a.x && (this.view.x = a.x), "undefined" != typeof a.y && (this.view.y = a.y), this.bounds && this.checkBounds()
  2904. }
  2905. }), Object.defineProperty(c.Camera.prototype, "width", {
  2906. get: function() {
  2907. return this.view.width
  2908. },
  2909. set: function(a) {
  2910. this.view.width = a
  2911. }
  2912. }), Object.defineProperty(c.Camera.prototype, "height", {
  2913. get: function() {
  2914. return this.view.height
  2915. },
  2916. set: function(a) {
  2917. this.view.height = a
  2918. }
  2919. }), c.State = function() {
  2920. this.game = null, this.key = "", 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
  2921. }, c.State.prototype = {
  2922. init: function() {},
  2923. preload: function() {},
  2924. loadUpdate: function() {},
  2925. loadRender: function() {},
  2926. create: function() {},
  2927. update: function() {},
  2928. render: function() {},
  2929. resize: function() {},
  2930. paused: function() {},
  2931. pauseUpdate: function() {},
  2932. shutdown: function() {}
  2933. }, c.State.prototype.constructor = c.State, c.StateManager = function(a, b) {
  2934. 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.onResizeCallback = null, this.onPreRenderCallback = null, this.onLoadUpdateCallback = null, this.onLoadRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null, this.onShutDownCallback = null
  2935. }, c.StateManager.prototype = {
  2936. boot: function() {
  2937. this.game.onPause.add(this.pause, this), this.game.onResume.add(this.resume, this), null !== this._pendingState && "string" != typeof this._pendingState && this.add("default", this._pendingState, !0)
  2938. },
  2939. add: function(a, b, d) {
  2940. "undefined" == typeof d && (d = !1);
  2941. var e;
  2942. return b instanceof c.State ? e = b : "object" == typeof b ? (e = b, e.game = this.game) : "function" == typeof b && (e = new b(this.game)), this.states[a] = e, d && (this.game.isBooted ? this.start(a) : this._pendingState = a), e
  2943. },
  2944. remove: function(a) {
  2945. 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.onPreRenderCallback = null, this.onRenderCallback = null, this.onResizeCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null), delete this.states[a]
  2946. },
  2947. start: function(a, b, c) {
  2948. "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)))
  2949. },
  2950. restart: function(a, b) {
  2951. "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))
  2952. },
  2953. dummy: function() {},
  2954. preUpdate: function() {
  2955. if (this._pendingState && this.game.isBooted) {
  2956. if (this.clearCurrentState(), this.setCurrentState(this._pendingState), this.current !== this._pendingState) return;
  2957. this._pendingState = null, this.onPreloadCallback ? (this.game.load.reset(!0), 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()
  2958. }
  2959. },
  2960. clearCurrentState: function() {
  2961. 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.game.scale.reset(this._clearWorld), this.game.debug && this.game.debug.reset(), this._clearWorld && (this.game.world.shutdown(), this._clearCache === !0 && this.game.cache.destroy()))
  2962. },
  2963. checkState: function(a) {
  2964. if (this.states[a]) {
  2965. var b = !1;
  2966. return (this.states[a].preload || this.states[a].create || this.states[a].update || 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
  2967. }
  2968. return console.warn("Phaser.StateManager - No state found with the key: " + a), !1
  2969. },
  2970. link: function(a) {
  2971. 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, this.states[a].key = a
  2972. },
  2973. unlink: function(a) {
  2974. this.states[a] && (this.states[a].game = null, this.states[a].add = null, this.states[a].make = null, this.states[a].camera = null, this.states[a].cache = null, this.states[a].input = null, this.states[a].load = null, this.states[a].math = null, this.states[a].sound = null, this.states[a].scale = null, this.states[a].state = null, this.states[a].stage = null, this.states[a].time = null, this.states[a].tweens = null, this.states[a].world = null, this.states[a].particles = null, this.states[a].rnd = null, this.states[a].physics = null)
  2975. },
  2976. setCurrentState: function(a) {
  2977. 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.onResizeCallback = this.states[a].resize || 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 && this.game.physics.reset(), this.current = a, this._created = !1, this.onInitCallback.apply(this.callbackContext, this._args), a === this._pendingState && (this._args = []), this.game._kickstart = !0
  2978. },
  2979. getCurrentState: function() {
  2980. return this.states[this.current]
  2981. },
  2982. loadComplete: function() {
  2983. this._created === !1 && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0
  2984. },
  2985. pause: function() {
  2986. this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game)
  2987. },
  2988. resume: function() {
  2989. this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game)
  2990. },
  2991. update: function() {
  2992. this._created && this.onUpdateCallback ? this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2993. },
  2994. pauseUpdate: function() {
  2995. this._created && this.onPauseUpdateCallback ? this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2996. },
  2997. preRender: function(a) {
  2998. this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game, a)
  2999. },
  3000. resize: function(a, b) {
  3001. this.onResizeCallback && this.onResizeCallback.call(this.callbackContext, a, b)
  3002. },
  3003. render: function() {
  3004. this._created && this.onRenderCallback ? this.game.renderType === c.CANVAS ? (this.game.context.save(), this.game.context.setTransform(1, 0, 0, 1, 0, 0), this.onRenderCallback.call(this.callbackContext, this.game), this.game.context.restore()) : this.onRenderCallback.call(this.callbackContext, this.game) : this.onLoadRenderCallback && this.onLoadRenderCallback.call(this.callbackContext, this.game)
  3005. },
  3006. destroy: function() {
  3007. this.clearCurrentState(), 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, this.current = ""
  3008. }
  3009. }, c.StateManager.prototype.constructor = c.StateManager, c.Signal = function() {}, c.Signal.prototype = {
  3010. _bindings: null,
  3011. _prevParams: null,
  3012. memorize: !1,
  3013. _shouldPropagate: !0,
  3014. active: !0,
  3015. _boundDispatch: !0,
  3016. validateListener: function(a, b) {
  3017. if ("function" != typeof a) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", b))
  3018. },
  3019. _registerListener: function(a, b, d, e) {
  3020. var f, g = this._indexOfListener(a, d);
  3021. if (-1 !== g) {
  3022. if (f = this._bindings[g], f.isOnce() !== b) throw new Error("You cannot add" + (b ? "" : "Once") + "() then add" + (b ? "Once" : "") + "() the same listener without removing the relationship first.")
  3023. } else f = new c.SignalBinding(this, a, b, d, e), this._addBinding(f);
  3024. return this.memorize && this._prevParams && f.execute(this._prevParams), f
  3025. },
  3026. _addBinding: function(a) {
  3027. this._bindings || (this._bindings = []);
  3028. var b = this._bindings.length;
  3029. do b--; while (this._bindings[b] && a._priority <= this._bindings[b]._priority);
  3030. this._bindings.splice(b + 1, 0, a)
  3031. },
  3032. _indexOfListener: function(a, b) {
  3033. if (!this._bindings) return -1;
  3034. "undefined" == typeof b && (b = null);
  3035. for (var c, d = this._bindings.length; d--;)
  3036. if (c = this._bindings[d], c._listener === a && c.context === b) return d;
  3037. return -1
  3038. },
  3039. has: function(a, b) {
  3040. return -1 !== this._indexOfListener(a, b)
  3041. },
  3042. add: function(a, b, c) {
  3043. return this.validateListener(a, "add"), this._registerListener(a, !1, b, c)
  3044. },
  3045. addOnce: function(a, b, c) {
  3046. return this.validateListener(a, "addOnce"), this._registerListener(a, !0, b, c)
  3047. },
  3048. remove: function(a, b) {
  3049. this.validateListener(a, "remove");
  3050. var c = this._indexOfListener(a, b);
  3051. return -1 !== c && (this._bindings[c]._destroy(), this._bindings.splice(c, 1)), a
  3052. },
  3053. removeAll: function(a) {
  3054. if ("undefined" == typeof a && (a = null), this._bindings) {
  3055. 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();
  3056. a || (this._bindings.length = 0)
  3057. }
  3058. },
  3059. getNumListeners: function() {
  3060. return this._bindings ? this._bindings.length : 0
  3061. },
  3062. halt: function() {
  3063. this._shouldPropagate = !1
  3064. },
  3065. dispatch: function() {
  3066. if (this.active && this._bindings) {
  3067. var a, b = Array.prototype.slice.call(arguments),
  3068. c = this._bindings.length;
  3069. if (this.memorize && (this._prevParams = b), c) {
  3070. a = this._bindings.slice(), this._shouldPropagate = !0;
  3071. do c--; while (a[c] && this._shouldPropagate && a[c].execute(b) !== !1)
  3072. }
  3073. }
  3074. },
  3075. forget: function() {
  3076. this._prevParams && (this._prevParams = null)
  3077. },
  3078. dispose: function() {
  3079. this.removeAll(), this._bindings = null, this._prevParams && (this._prevParams = null)
  3080. },
  3081. toString: function() {
  3082. return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"
  3083. }
  3084. }, Object.defineProperty(c.Signal.prototype, "boundDispatch", {
  3085. get: function() {
  3086. var a = this;
  3087. return this._boundDispatch || (this._boundDispatch = function() {
  3088. return a.dispatch.apply(a, arguments)
  3089. })
  3090. }
  3091. }), c.Signal.prototype.constructor = c.Signal, c.SignalBinding = function(a, b, c, d, e) {
  3092. this._listener = b, c && (this._isOnce = !0), null != d && (this.context = d), this._signal = a, e && (this._priority = e)
  3093. }, c.SignalBinding.prototype = {
  3094. context: null,
  3095. _isOnce: !1,
  3096. _priority: 0,
  3097. callCount: 0,
  3098. active: !0,
  3099. params: null,
  3100. execute: function(a) {
  3101. var b, c;
  3102. return this.active && this._listener && (c = this.params ? this.params.concat(a) : a, b = this._listener.apply(this.context, c), this.callCount++, this._isOnce && this.detach()), b
  3103. },
  3104. detach: function() {
  3105. return this.isBound() ? this._signal.remove(this._listener, this.context) : null
  3106. },
  3107. isBound: function() {
  3108. return !!this._signal && !!this._listener
  3109. },
  3110. isOnce: function() {
  3111. return this._isOnce
  3112. },
  3113. getListener: function() {
  3114. return this._listener
  3115. },
  3116. getSignal: function() {
  3117. return this._signal
  3118. },
  3119. _destroy: function() {
  3120. delete this._signal, delete this._listener, delete this.context
  3121. },
  3122. toString: function() {
  3123. return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"
  3124. }
  3125. }, c.SignalBinding.prototype.constructor = c.SignalBinding, c.Filter = function(a, b, d) {
  3126. this.game = a, this.type = c.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.prevPoint = new c.Point;
  3127. var e = new Date;
  3128. if (this.uniforms = {
  3129. resolution: {
  3130. type: "2f",
  3131. value: {
  3132. x: 256,
  3133. y: 256
  3134. }
  3135. },
  3136. time: {
  3137. type: "1f",
  3138. value: 0
  3139. },
  3140. mouse: {
  3141. type: "2f",
  3142. value: {
  3143. x: 0,
  3144. y: 0
  3145. }
  3146. },
  3147. date: {
  3148. type: "4fv",
  3149. value: [e.getFullYear(), e.getMonth(), e.getDate(), 60 * e.getHours() * 60 + 60 * e.getMinutes() + e.getSeconds()]
  3150. },
  3151. sampleRate: {
  3152. type: "1f",
  3153. value: 44100
  3154. },
  3155. iChannel0: {
  3156. type: "sampler2D",
  3157. value: null,
  3158. textureData: {
  3159. repeat: !0
  3160. }
  3161. },
  3162. iChannel1: {
  3163. type: "sampler2D",
  3164. value: null,
  3165. textureData: {
  3166. repeat: !0
  3167. }
  3168. },
  3169. iChannel2: {
  3170. type: "sampler2D",
  3171. value: null,
  3172. textureData: {
  3173. repeat: !0
  3174. }
  3175. },
  3176. iChannel3: {
  3177. type: "sampler2D",
  3178. value: null,
  3179. textureData: {
  3180. repeat: !0
  3181. }
  3182. }
  3183. }, b)
  3184. for (var f in b) this.uniforms[f] = b[f];
  3185. this.fragmentSrc = d || []
  3186. }, c.Filter.prototype = {
  3187. init: function() {},
  3188. setResolution: function(a, b) {
  3189. this.uniforms.resolution.value.x = a, this.uniforms.resolution.value.y = b
  3190. },
  3191. update: function(a) {
  3192. if ("undefined" != typeof a) {
  3193. var b = a.x / this.game.width,
  3194. c = 1 - a.y / this.game.height;
  3195. (b !== this.prevPoint.x || c !== this.prevPoint.y) && (this.uniforms.mouse.value.x = b.toFixed(2), this.uniforms.mouse.value.y = c.toFixed(2), this.prevPoint.set(b, c))
  3196. }
  3197. this.uniforms.time.value = this.game.time.totalElapsedSeconds()
  3198. },
  3199. destroy: function() {
  3200. this.game = null
  3201. }
  3202. }, c.Filter.prototype.constructor = c.Filter, Object.defineProperty(c.Filter.prototype, "width", {
  3203. get: function() {
  3204. return this.uniforms.resolution.value.x
  3205. },
  3206. set: function(a) {
  3207. this.uniforms.resolution.value.x = a
  3208. }
  3209. }), Object.defineProperty(c.Filter.prototype, "height", {
  3210. get: function() {
  3211. return this.uniforms.resolution.value.y
  3212. },
  3213. set: function(a) {
  3214. this.uniforms.resolution.value.y = a
  3215. }
  3216. }), c.Plugin = function(a, b) {
  3217. "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
  3218. }, c.Plugin.prototype = {
  3219. preUpdate: function() {},
  3220. update: function() {},
  3221. render: function() {},
  3222. postRender: function() {},
  3223. destroy: function() {
  3224. this.game = null, this.parent = null, this.active = !1, this.visible = !1
  3225. }
  3226. }, c.Plugin.prototype.constructor = c.Plugin, c.PluginManager = function(a) {
  3227. this.game = a, this.plugins = [], this._len = 0, this._i = 0
  3228. }, c.PluginManager.prototype = {
  3229. add: function(a) {
  3230. var b = Array.prototype.splice.call(arguments, 1),
  3231. c = !1;
  3232. 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
  3233. },
  3234. remove: function(a) {
  3235. for (this._i = this._len; this._i--;)
  3236. if (this.plugins[this._i] === a) return a.destroy(), this.plugins.splice(this._i, 1), void this._len--
  3237. },
  3238. removeAll: function() {
  3239. for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
  3240. this.plugins.length = 0, this._len = 0
  3241. },
  3242. preUpdate: function() {
  3243. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate()
  3244. },
  3245. update: function() {
  3246. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update()
  3247. },
  3248. postUpdate: function() {
  3249. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate()
  3250. },
  3251. render: function() {
  3252. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render()
  3253. },
  3254. postRender: function() {
  3255. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender()
  3256. },
  3257. destroy: function() {
  3258. this.removeAll(), this.game = null
  3259. }
  3260. }, c.PluginManager.prototype.constructor = c.PluginManager, c.Stage = function(a) {
  3261. this.game = a, PIXI.Stage.call(this, 0), this.name = "_stage_root", this.disableVisibilityChange = !1, this.exists = !0, this.currentRenderOrderID = 0, this._hiddenVar = "hidden", this._onChange = null, this._backgroundColor = 0, a.config && this.parseConfig(a.config)
  3262. }, c.Stage.prototype = Object.create(PIXI.Stage.prototype), c.Stage.prototype.constructor = c.Stage, c.Stage.prototype.parseConfig = function(a) {
  3263. a.disableVisibilityChange && (this.disableVisibilityChange = a.disableVisibilityChange), a.backgroundColor && (this.backgroundColor = a.backgroundColor)
  3264. }, c.Stage.prototype.boot = function() {
  3265. c.DOM.getOffset(this.game.canvas, this.offset), c.Canvas.setUserSelect(this.game.canvas, "none"), c.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility()
  3266. }, c.Stage.prototype.preUpdate = function() {
  3267. this.currentRenderOrderID = 0;
  3268. for (var a = 0; a < this.children.length; a++) this.children[a].preUpdate()
  3269. }, c.Stage.prototype.update = function() {
  3270. for (var a = this.children.length; a--;) this.children[a].update()
  3271. }, c.Stage.prototype.postUpdate = function() {
  3272. if (this.game.world.camera.target) {
  3273. this.game.world.camera.target.postUpdate(), this.game.world.camera.update();
  3274. for (var a = this.children.length; a--;) this.children[a] !== this.game.world.camera.target && this.children[a].postUpdate()
  3275. } else {
  3276. this.game.world.camera.update();
  3277. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3278. }
  3279. }, c.Stage.prototype.updateTransform = function() {
  3280. this.worldAlpha = 1;
  3281. for (var a = 0; a < this.children.length; a++) this.children[a].updateTransform()
  3282. }, c.Stage.prototype.checkVisibility = function() {
  3283. this._hiddenVar = void 0 !== document.webkitHidden ? "webkitvisibilitychange" : void 0 !== document.mozHidden ? "mozvisibilitychange" : void 0 !== document.msHidden ? "msvisibilitychange" : void 0 !== document.hidden ? "visibilitychange" : null;
  3284. var a = this;
  3285. this._onChange = function(b) {
  3286. // return a.visibilityChange(b)
  3287. }/*, this._hiddenVar && document.addEventListener(this._hiddenVar, this._onChange, !1), window.onblur = this._onChange, window.onfocus = this._onChange, window.onpagehide = this._onChange, window.onpageshow = this._onChange, this.game.device.cocoonJSApp && (CocoonJS.App.onSuspended.addEventListener(function() {
  3288. /*c.Stage.prototype.visibilityChange.call(a, {
  3289. type: "pause"
  3290. })
  3291. }), CocoonJS.App.onActivated.addEventListener(function() {
  3292. c.Stage.prototype.visibilityChange.call(a, {
  3293. type: "resume"
  3294. })
  3295. }))*/
  3296. }, c.Stage.prototype.visibilityChange = function(a) {
  3297. 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 || "pause" === a.type ? this.game.gamePaused(a) : this.game.gameResumed(a)))
  3298. }, c.Stage.prototype.setBackgroundColor = function(a) {
  3299. var b = c.Color.valueToColor(a);
  3300. this._backgroundColor = c.Color.getColor(b.r, b.g, b.b), this.backgroundColorSplit = [b.r / 255, b.g / 255, b.b / 255], this.backgroundColorString = c.Color.RGBtoString(b.r, b.g, b.b, 255, "#")
  3301. }, c.Stage.prototype.destroy = function() {
  3302. this._hiddenVar && document.removeEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = null, window.onpageshow = null, window.onblur = null, window.onfocus = null
  3303. }, Object.defineProperty(c.Stage.prototype, "backgroundColor", {
  3304. get: function() {
  3305. return this._backgroundColor
  3306. },
  3307. set: function(a) {
  3308. this.game.transparent || this.setBackgroundColor(a)
  3309. }
  3310. }), Object.defineProperty(c.Stage.prototype, "smoothed", {
  3311. get: function() {
  3312. return PIXI.scaleModes.DEFAULT === PIXI.scaleModes.LINEAR
  3313. },
  3314. set: function(a) {
  3315. PIXI.scaleModes.DEFAULT = a ? PIXI.scaleModes.LINEAR : PIXI.scaleModes.NEAREST
  3316. }
  3317. }), c.Group = function(a, b, d, e, f, g) {
  3318. "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1), "undefined" == typeof g && (g = c.Physics.ARCADE), this.game = a, "undefined" == typeof b && (b = a.world), this.name = d || "group", this.z = 0, PIXI.DisplayObjectContainer.call(this), e ? (this.game.stage.addChild(this), this.z = this.game.stage.children.length) : b && (b.addChild(this), this.z = b.children.length), this.type = c.GROUP, this.physicsType = c.GROUP, this.alive = !0, this.exists = !0, this.ignoreDestroy = !1, this.classType = c.Sprite, this.scale = new c.Point(1, 1), this.cursor = null, this.enableBody = f, this.enableBodyDebug = !1, this.physicsBodyType = g, this.onDestroy = new c.Signal, this.cursorIndex = 0, this.fixedToCamera = !1, this.cameraOffset = new c.Point, this._hash = [], this._sortProperty = "z"
  3319. }, c.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), c.Group.prototype.constructor = c.Group, c.Group.RETURN_NONE = 0, c.Group.RETURN_TOTAL = 1, c.Group.RETURN_CHILD = 2, c.Group.SORT_ASCENDING = -1, c.Group.SORT_DESCENDING = 1, c.Group.prototype.add = function(a, b) {
  3320. return "undefined" == typeof b && (b = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChild(a), this._hash.push(a), a.z = this.children.length, !b && a.events && a.events.onAddedToGroup$dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  3321. }, c.Group.prototype.addMultiple = function(a, b) {
  3322. if (Array.isArray(a))
  3323. for (var c = 0; c < a.length; c++) this.add(a[c], b);
  3324. return a
  3325. }, c.Group.prototype.addAt = function(a, b, c) {
  3326. return "undefined" == typeof c && (c = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChildAt(a, b), this._hash.push(a), this.updateZ(), !c && a.events && a.events.onAddedToGroup$dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  3327. }, c.Group.prototype.getAt = function(a) {
  3328. return 0 > a || a >= this.children.length ? -1 : this.getChildAt(a)
  3329. }, c.Group.prototype.create = function(a, b, c, d, e) {
  3330. "undefined" == typeof e && (e = !0);
  3331. var f = new this.classType(this.game, a, b, c, d);
  3332. return this.enableBody && this.game.physics.enable(f, this.physicsBodyType, this.enableBodyDebug), f.exists = e, f.visible = e, f.alive = e, this.addChild(f), this._hash.push(f), f.z = this.children.length, f.events && f.events.onAddedToGroup$dispatch(f, this), null === this.cursor && (this.cursor = f), f
  3333. }, c.Group.prototype.createMultiple = function(a, b, c, d) {
  3334. "undefined" == typeof d && (d = !1);
  3335. for (var e = 0; a > e; e++) this.create(0, 0, b, c, d)
  3336. }, c.Group.prototype.updateZ = function() {
  3337. for (var a = this.children.length; a--;) this.children[a].z = a
  3338. }, c.Group.prototype.resetCursor = function(a) {
  3339. return "undefined" == typeof a && (a = 0), a > this.children.length - 1 && (a = 0), this.cursor ? (this.cursorIndex = a, this.cursor = this.children[this.cursorIndex], this.cursor) : void 0
  3340. }, c.Group.prototype.next = function() {
  3341. return this.cursor ? (this.cursorIndex >= this.children.length - 1 ? this.cursorIndex = 0 : this.cursorIndex++, this.cursor = this.children[this.cursorIndex], this.cursor) : void 0
  3342. }, c.Group.prototype.previous = function() {
  3343. return this.cursor ? (0 === this.cursorIndex ? this.cursorIndex = this.children.length - 1 : this.cursorIndex--, this.cursor = this.children[this.cursorIndex], this.cursor) : void 0
  3344. }, c.Group.prototype.swap = function(a, b) {
  3345. this.swapChildren(a, b), this.updateZ()
  3346. }, c.Group.prototype.bringToTop = function(a) {
  3347. return a.parent === this && this.getIndex(a) < this.children.length && (this.remove(a, !1, !0), this.add(a, !0)), a
  3348. }, c.Group.prototype.sendToBack = function(a) {
  3349. return a.parent === this && this.getIndex(a) > 0 && (this.remove(a, !1, !0), this.addAt(a, 0, !0)), a
  3350. }, c.Group.prototype.moveUp = function(a) {
  3351. if (a.parent === this && this.getIndex(a) < this.children.length - 1) {
  3352. var b = this.getIndex(a),
  3353. c = this.getAt(b + 1);
  3354. c && this.swap(a, c)
  3355. }
  3356. return a
  3357. }, c.Group.prototype.moveDown = function(a) {
  3358. if (a.parent === this && this.getIndex(a) > 0) {
  3359. var b = this.getIndex(a),
  3360. c = this.getAt(b - 1);
  3361. c && this.swap(a, c)
  3362. }
  3363. return a
  3364. }, c.Group.prototype.xy = function(a, b, c) {
  3365. return 0 > a || a > this.children.length ? -1 : (this.getChildAt(a).x = b, void(this.getChildAt(a).y = c))
  3366. }, c.Group.prototype.reverse = function() {
  3367. this.children.reverse(), this.updateZ()
  3368. }, c.Group.prototype.getIndex = function(a) {
  3369. return this.children.indexOf(a)
  3370. }, c.Group.prototype.replace = function(a, b) {
  3371. var d = this.getIndex(a);
  3372. return -1 !== d ? (b.parent && (b.parent instanceof c.Group ? b.parent.remove(b) : b.parent.removeChild(b)), this.remove(a), this.addAt(b, d), a) : void 0
  3373. }, c.Group.prototype.hasProperty = function(a, b) {
  3374. var c = b.length;
  3375. 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
  3376. }, c.Group.prototype.setProperty = function(a, b, c, d, e) {
  3377. if ("undefined" == typeof e && (e = !1), d = d || 0, !this.hasProperty(a, b) && (!e || d > 0)) return !1;
  3378. var f = b.length;
  3379. 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
  3380. }, c.Group.prototype.checkProperty = function(a, b, d, e) {
  3381. return "undefined" == typeof e && (e = !1), !c.Utils.getProperty(a, b) && e ? !1 : c.Utils.getProperty(a, b) !== d ? !1 : !0
  3382. }, c.Group.prototype.set = function(a, b, c, d, e, f, g) {
  3383. 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
  3384. }, c.Group.prototype.setAll = function(a, b, c, d, e, f) {
  3385. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof f && (f = !1), a = a.split("."), e = e || 0;
  3386. for (var g = 0; g < this.children.length; g++)(!c || c && this.children[g].alive) && (!d || d && this.children[g].visible) && this.setProperty(this.children[g], a, b, e, f)
  3387. }, c.Group.prototype.setAllChildren = function(a, b, d, e, f, g) {
  3388. "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), "undefined" == typeof g && (g = !1), f = f || 0;
  3389. for (var h = 0; h < this.children.length; h++)(!d || d && this.children[h].alive) && (!e || e && this.children[h].visible) && (this.children[h] instanceof c.Group ? this.children[h].setAllChildren(a, b, d, e, f, g) : this.setProperty(this.children[h], a.split("."), b, f, g))
  3390. }, c.Group.prototype.checkAll = function(a, b, c, d, e) {
  3391. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  3392. for (var f = 0; f < this.children.length; f++)
  3393. if ((!c || c && this.children[f].alive) && (!d || d && this.children[f].visible) && !this.checkProperty(this.children[f], a, b, e)) return !1;
  3394. return !0
  3395. }, c.Group.prototype.addAll = function(a, b, c, d) {
  3396. this.setAll(a, b, c, d, 1)
  3397. }, c.Group.prototype.subAll = function(a, b, c, d) {
  3398. this.setAll(a, b, c, d, 2)
  3399. }, c.Group.prototype.multiplyAll = function(a, b, c, d) {
  3400. this.setAll(a, b, c, d, 3)
  3401. }, c.Group.prototype.divideAll = function(a, b, c, d) {
  3402. this.setAll(a, b, c, d, 4)
  3403. }, c.Group.prototype.callAllExists = function(a, b) {
  3404. var c;
  3405. if (arguments.length > 2) {
  3406. c = [];
  3407. for (var d = 2; d < arguments.length; d++) c.push(arguments[d])
  3408. }
  3409. for (var d = 0; d < this.children.length; d++) this.children[d].exists === b && this.children[d][a] && this.children[d][a].apply(this.children[d], c)
  3410. }, c.Group.prototype.callbackFromArray = function(a, b, c) {
  3411. if (1 == c) {
  3412. if (a[b[0]]) return a[b[0]]
  3413. } else if (2 == c) {
  3414. if (a[b[0]][b[1]]) return a[b[0]][b[1]]
  3415. } else if (3 == c) {
  3416. if (a[b[0]][b[1]][b[2]]) return a[b[0]][b[1]][b[2]]
  3417. } else if (4 == c) {
  3418. if (a[b[0]][b[1]][b[2]][b[3]]) return a[b[0]][b[1]][b[2]][b[3]]
  3419. } else if (a[b]) return a[b];
  3420. return !1
  3421. }, c.Group.prototype.callAll = function(a, b) {
  3422. if ("undefined" != typeof a) {
  3423. a = a.split(".");
  3424. var c = a.length;
  3425. if ("undefined" == typeof b || null === b || "" === b) b = null;
  3426. else if ("string" == typeof b) {
  3427. b = b.split(".");
  3428. var d = b.length
  3429. }
  3430. var e;
  3431. if (arguments.length > 2) {
  3432. e = [];
  3433. for (var f = 2; f < arguments.length; f++) e.push(arguments[f])
  3434. }
  3435. for (var g = null, h = null, f = 0; f < this.children.length; f++) g = this.callbackFromArray(this.children[f], a, c), b && g ? (h = this.callbackFromArray(this.children[f], b, d), g && g.apply(h, e)) : g && g.apply(this.children[f], e)
  3436. }
  3437. }, c.Group.prototype.preUpdate = function() {
  3438. if (!this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  3439. for (var a = this.children.length; a--;) this.children[a].preUpdate();
  3440. return !0
  3441. }, c.Group.prototype.update = function() {
  3442. for (var a = this.children.length; a--;) this.children[a].update()
  3443. }, c.Group.prototype.postUpdate = function() {
  3444. this.fixedToCamera && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y);
  3445. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3446. }, c.Group.prototype.filter = function(a, b) {
  3447. for (var d = -1, e = this.children.length, f = []; ++d < e;) {
  3448. var g = this.children[d];
  3449. (!b || b && g.exists) && a(g, d, this.children) && f.push(g)
  3450. }
  3451. return new c.ArraySet(f)
  3452. }, c.Group.prototype.forEach = function(a, b, c) {
  3453. if ("undefined" == typeof c && (c = !1), arguments.length <= 3)
  3454. for (var d = 0; d < this.children.length; d++)(!c || c && this.children[d].exists) && a.call(b, this.children[d]);
  3455. else {
  3456. for (var e = [null], d = 3; d < arguments.length; d++) e.push(arguments[d]);
  3457. for (var d = 0; d < this.children.length; d++)(!c || c && this.children[d].exists) && (e[0] = this.children[d], a.apply(b, e))
  3458. }
  3459. }, c.Group.prototype.forEachExists = function(a, b) {
  3460. var d;
  3461. if (arguments.length > 2) {
  3462. d = [null];
  3463. for (var e = 2; e < arguments.length; e++) d.push(arguments[e])
  3464. }
  3465. this.iterate("exists", !0, c.Group.RETURN_TOTAL, a, b, d)
  3466. }, c.Group.prototype.forEachAlive = function(a, b) {
  3467. var d;
  3468. if (arguments.length > 2) {
  3469. d = [null];
  3470. for (var e = 2; e < arguments.length; e++) d.push(arguments[e])
  3471. }
  3472. this.iterate("alive", !0, c.Group.RETURN_TOTAL, a, b, d)
  3473. }, c.Group.prototype.forEachDead = function(a, b) {
  3474. var d;
  3475. if (arguments.length > 2) {
  3476. d = [null];
  3477. for (var e = 2; e < arguments.length; e++) d.push(arguments[e])
  3478. }
  3479. this.iterate("alive", !1, c.Group.RETURN_TOTAL, a, b, d)
  3480. }, c.Group.prototype.sort = function(a, b) {
  3481. this.children.length < 2 || ("undefined" == typeof a && (a = "z"), "undefined" == typeof b && (b = c.Group.SORT_ASCENDING), this._sortProperty = a, this.children.sort(b === c.Group.SORT_ASCENDING ? this.ascendingSortHandler.bind(this) : this.descendingSortHandler.bind(this)), this.updateZ())
  3482. }, c.Group.prototype.customSort = function(a, b) {
  3483. this.children.length < 2 || (this.children.sort(a.bind(b)), this.updateZ())
  3484. }, c.Group.prototype.ascendingSortHandler = function(a, b) {
  3485. return a[this._sortProperty] < b[this._sortProperty] ? -1 : a[this._sortProperty] > b[this._sortProperty] ? 1 : a.z < b.z ? -1 : 1
  3486. }, c.Group.prototype.descendingSortHandler = function(a, b) {
  3487. return a[this._sortProperty] < b[this._sortProperty] ? 1 : a[this._sortProperty] > b[this._sortProperty] ? -1 : 0
  3488. }, c.Group.prototype.iterate = function(a, b, d, e, f, g) {
  3489. if (d === c.Group.RETURN_TOTAL && 0 === this.children.length) return 0;
  3490. for (var h = 0, i = 0; i < this.children.length; i++)
  3491. if (this.children[i][a] === b && (h++, e && (g ? (g[0] = this.children[i], e.apply(f, g)) : e.call(f, this.children[i])), d === c.Group.RETURN_CHILD)) return this.children[i];
  3492. return d === c.Group.RETURN_TOTAL ? h : null
  3493. }, c.Group.prototype.getFirstExists = function(a) {
  3494. return "boolean" != typeof a && (a = !0), this.iterate("exists", a, c.Group.RETURN_CHILD)
  3495. }, c.Group.prototype.getFirstAlive = function() {
  3496. return this.iterate("alive", !0, c.Group.RETURN_CHILD)
  3497. }, c.Group.prototype.getFirstDead = function() {
  3498. return this.iterate("alive", !1, c.Group.RETURN_CHILD)
  3499. }, c.Group.prototype.getTop = function() {
  3500. return this.children.length > 0 ? this.children[this.children.length - 1] : void 0
  3501. }, c.Group.prototype.getBottom = function() {
  3502. return this.children.length > 0 ? this.children[0] : void 0
  3503. }, c.Group.prototype.countLiving = function() {
  3504. return this.iterate("alive", !0, c.Group.RETURN_TOTAL)
  3505. }, c.Group.prototype.countDead = function() {
  3506. return this.iterate("alive", !1, c.Group.RETURN_TOTAL)
  3507. }, c.Group.prototype.getRandom = function(a, b) {
  3508. return 0 === this.children.length ? null : (a = a || 0, b = b || this.children.length, c.ArrayUtils.getRandomItem(this.children, a, b))
  3509. }, c.Group.prototype.remove = function(a, b, c) {
  3510. if ("undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !1), 0 === this.children.length || -1 === this.children.indexOf(a)) return !1;
  3511. c || !a.events || a.destroyPhase || a.events.onRemovedFromGroup$dispatch(a, this);
  3512. var d = this.removeChild(a),
  3513. e = this._hash.indexOf(d);
  3514. return -1 !== e && this._hash.splice(e, 1), this.updateZ(), this.cursor === a && this.next(), b && d && d.destroy(!0), !0
  3515. }, c.Group.prototype.removeAll = function(a, b) {
  3516. if ("undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), 0 !== this.children.length) {
  3517. do {
  3518. !b && this.children[0].events && this.children[0].events.onRemovedFromGroup$dispatch(this.children[0], this);
  3519. var c = this.removeChild(this.children[0]),
  3520. d = this._hash.indexOf(c); - 1 !== d && this._hash.splice(d, 1), a && c && c.destroy(!0)
  3521. } while (this.children.length > 0);
  3522. this._hash = [], this.cursor = null
  3523. }
  3524. }, c.Group.prototype.removeBetween = function(a, b, c, d) {
  3525. if ("undefined" == typeof b && (b = this.children.length - 1), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), 0 !== this.children.length) {
  3526. if (a > b || 0 > a || b > this.children.length) return !1;
  3527. for (var e = b; e >= a;) {
  3528. !d && this.children[e].events && this.children[e].events.onRemovedFromGroup$dispatch(this.children[e], this);
  3529. var f = this.removeChild(this.children[e]),
  3530. g = this._hash.indexOf(f); - 1 !== g && this._hash.splice(g, 1), c && f && f.destroy(!0), this.cursor === this.children[e] && (this.cursor = null), e--
  3531. }
  3532. this.updateZ()
  3533. }
  3534. }, c.Group.prototype.destroy = function(a, b) {
  3535. null === this.game || this.ignoreDestroy || ("undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !1), this.onDestroy.dispatch(this, a, b), this.removeAll(a), this.cursor = null, this.filters = null, b || (this.parent && this.parent.removeChild(this), this.game = null, this.exists = !1))
  3536. }, Object.defineProperty(c.Group.prototype, "total", {
  3537. get: function() {
  3538. return this.iterate("exists", !0, c.Group.RETURN_TOTAL)
  3539. }
  3540. }), Object.defineProperty(c.Group.prototype, "length", {
  3541. get: function() {
  3542. return this.children.length
  3543. }
  3544. }), Object.defineProperty(c.Group.prototype, "angle", {
  3545. get: function() {
  3546. return c.Math.radToDeg(this.rotation)
  3547. },
  3548. set: function(a) {
  3549. this.rotation = c.Math.degToRad(a)
  3550. }
  3551. }), c.World = function(a) {
  3552. c.Group.call(this, a, null, "__world", !1), this.bounds = new c.Rectangle(0, 0, a.width, a.height), this.camera = null, this._definedSize = !1, this._width = a.width, this._height = a.height
  3553. }, c.World.prototype = Object.create(c.Group.prototype), c.World.prototype.constructor = c.World, c.World.prototype.boot = function() {
  3554. this.camera = new c.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)
  3555. }, c.World.prototype.setBounds = function(a, b, c, d) {
  3556. this._definedSize = !0, this._width = c, this._height = d, this.bounds.setTo(a, b, c, d), this.x = a, this.y = b, this.camera.bounds && this.camera.bounds.setTo(a, b, Math.max(c, this.game.width), Math.max(d, this.game.height)), this.game.physics.setBoundsToWorld()
  3557. }, c.World.prototype.resize = function(a, b) {
  3558. this._definedSize && (a < this._width && (a = this._width), b < this._height && (b = this._height)), this.bounds.width = a, this.bounds.height = b, this.game.camera.setBoundsToWorld(), this.game.physics.setBoundsToWorld()
  3559. }, c.World.prototype.shutdown = function() {
  3560. this.destroy(!0, !0)
  3561. }, c.World.prototype.wrap = function(a, b, c, d, e) {
  3562. "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))
  3563. }, Object.defineProperty(c.World.prototype, "width", {
  3564. get: function() {
  3565. return this.bounds.width
  3566. },
  3567. set: function(a) {
  3568. a < this.game.width && (a = this.game.width), this.bounds.width = a, this._width = a, this._definedSize = !0
  3569. }
  3570. }), Object.defineProperty(c.World.prototype, "height", {
  3571. get: function() {
  3572. return this.bounds.height
  3573. },
  3574. set: function(a) {
  3575. a < this.game.height && (a = this.game.height), this.bounds.height = a, this._height = a, this._definedSize = !0
  3576. }
  3577. }), Object.defineProperty(c.World.prototype, "centerX", {
  3578. get: function() {
  3579. return this.bounds.halfWidth
  3580. }
  3581. }), Object.defineProperty(c.World.prototype, "centerY", {
  3582. get: function() {
  3583. return this.bounds.halfHeight
  3584. }
  3585. }), Object.defineProperty(c.World.prototype, "randomX", {
  3586. get: function() {
  3587. 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)
  3588. }
  3589. }), Object.defineProperty(c.World.prototype, "randomY", {
  3590. get: function() {
  3591. 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)
  3592. }
  3593. }), c.FlexGrid = function(a, b, d) {
  3594. this.game = a.game, this.manager = a, this.width = b, this.height = d, this.boundsCustom = new c.Rectangle(0, 0, b, d), this.boundsFluid = new c.Rectangle(0, 0, b, d), this.boundsFull = new c.Rectangle(0, 0, b, d), this.boundsNone = new c.Rectangle(0, 0, b, d), this.positionCustom = new c.Point(0, 0), this.positionFluid = new c.Point(0, 0), this.positionFull = new c.Point(0, 0), this.positionNone = new c.Point(0, 0), this.scaleCustom = new c.Point(1, 1), this.scaleFluid = new c.Point(1, 1), this.scaleFluidInversed = new c.Point(1, 1), this.scaleFull = new c.Point(1, 1), this.scaleNone = new c.Point(1, 1), this.customWidth = 0, this.customHeight = 0, this.customOffsetX = 0, this.customOffsetY = 0, this.ratioH = b / d, this.ratioV = d / b, this.multiplier = 0, this.layers = []
  3595. }, c.FlexGrid.prototype = {
  3596. setSize: function(a, b) {
  3597. this.width = a, this.height = b, this.ratioH = a / b, this.ratioV = b / a, this.scaleNone = new c.Point(1, 1), this.boundsNone.width = this.width, this.boundsNone.height = this.height, this.refresh()
  3598. },
  3599. createCustomLayer: function(a, b, d, e) {
  3600. "undefined" == typeof e && (e = !0), this.customWidth = a, this.customHeight = b, this.boundsCustom.width = a, this.boundsCustom.height = b;
  3601. var f = new c.FlexLayer(this, this.positionCustom, this.boundsCustom, this.scaleCustom);
  3602. return e && this.game.world.add(f), this.layers.push(f), "undefined" != typeof d && null !== typeof d && f.addMultiple(d), f
  3603. },
  3604. createFluidLayer: function(a, b) {
  3605. "undefined" == typeof b && (b = !0);
  3606. var d = new c.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
  3607. return b && this.game.world.add(d), this.layers.push(d), "undefined" != typeof a && null !== typeof a && d.addMultiple(a), d
  3608. },
  3609. createFullLayer: function(a) {
  3610. var b = new c.FlexLayer(this, this.positionFull, this.boundsFull, this.scaleFluid);
  3611. return this.game.world.add(b), this.layers.push(b), "undefined" != typeof a && b.addMultiple(a), b
  3612. },
  3613. createFixedLayer: function(a) {
  3614. var b = new c.FlexLayer(this, this.positionNone, this.boundsNone, this.scaleNone);
  3615. return this.game.world.add(b), this.layers.push(b), "undefined" != typeof a && b.addMultiple(a), b
  3616. },
  3617. reset: function() {
  3618. for (var a = this.layers.length; a--;) this.layers[a].persist || (this.layers[a].position = null, this.layers[a].scale = null, this.layers.slice(a, 1))
  3619. },
  3620. onResize: function(a, b) {
  3621. this.ratioH = a / b, this.ratioV = b / a, this.refresh(a, b)
  3622. },
  3623. refresh: function() {
  3624. this.multiplier = Math.min(this.manager.height / this.height, this.manager.width / this.width), this.boundsFluid.width = Math.round(this.width * this.multiplier), this.boundsFluid.height = Math.round(this.height * this.multiplier), this.scaleFluid.set(this.boundsFluid.width / this.width, this.boundsFluid.height / this.height), this.scaleFluidInversed.set(this.width / this.boundsFluid.width, this.height / this.boundsFluid.height), this.scaleFull.set(this.boundsFull.width / this.width, this.boundsFull.height / this.height), this.boundsFull.width = Math.round(this.manager.width * this.scaleFluidInversed.x), this.boundsFull.height = Math.round(this.manager.height * this.scaleFluidInversed.y), this.boundsFluid.centerOn(this.manager.bounds.centerX, this.manager.bounds.centerY), this.boundsNone.centerOn(this.manager.bounds.centerX, this.manager.bounds.centerY), this.positionFluid.set(this.boundsFluid.x, this.boundsFluid.y), this.positionNone.set(this.boundsNone.x, this.boundsNone.y)
  3625. },
  3626. fitSprite: function(a) {
  3627. this.manager.scaleSprite(a), a.x = this.manager.bounds.centerX, a.y = this.manager.bounds.centerY
  3628. },
  3629. debug: function() {
  3630. this.game.debug.text(this.boundsFluid.width + " x " + this.boundsFluid.height, this.boundsFluid.x + 4, this.boundsFluid.y + 16), this.game.debug.geom(this.boundsFluid, "rgba(255,0,0,0.9", !1)
  3631. }
  3632. }, c.FlexGrid.prototype.constructor = c.FlexGrid, c.FlexLayer = function(a, b, d, e) {
  3633. c.Group.call(this, a.game, null, "__flexLayer" + a.game.rnd.uuid(), !1), this.manager = a.manager, this.grid = a, this.persist = !1, this.position = b, this.bounds = d, this.scale = e, this.topLeft = d.topLeft, this.topMiddle = new c.Point(d.halfWidth, 0), this.topRight = d.topRight, this.bottomLeft = d.bottomLeft, this.bottomMiddle = new c.Point(d.halfWidth, d.bottom), this.bottomRight = d.bottomRight
  3634. }, c.FlexLayer.prototype = Object.create(c.Group.prototype), c.FlexLayer.prototype.constructor = c.FlexLayer, c.FlexLayer.prototype.resize = function() {}, c.FlexLayer.prototype.debug = function() {
  3635. this.game.debug.text(this.bounds.width + " x " + this.bounds.height, this.bounds.x + 4, this.bounds.y + 16), this.game.debug.geom(this.bounds, "rgba(0,0,255,0.9", !1), this.game.debug.geom(this.topLeft, "rgba(255,255,255,0.9"), this.game.debug.geom(this.topMiddle, "rgba(255,255,255,0.9"), this.game.debug.geom(this.topRight, "rgba(255,255,255,0.9")
  3636. }, c.ScaleManager = function(a, b, d) {
  3637. this.game = a, this.dom = c.DOM, this.grid = null, this.width = 0, this.height = 0, this.minWidth = null, this.maxWidth = null, this.minHeight = null, this.maxHeight = null, this.offset = new c.Point, this.forceLandscape = !1, this.forcePortrait = !1, this.incorrectOrientation = !1, this._pageAlignHorizontally = !1, this._pageAlignVertically = !1, this.maxIterations = 5, this.onOrientationChange = new c.Signal, this.enterLandscape = new c.Signal, this.enterPortrait = new c.Signal, this.enterIncorrectOrientation = new c.Signal, this.leaveIncorrectOrientation = new c.Signal, this.fullScreenTarget = null, this._createdFullScreenTarget = null, this.onFullScreenInit = new c.Signal, this.onFullScreenChange = new c.Signal, this.onFullScreenError = new c.Signal, this.enterFullScreen = new c.Signal, this.leaveFullScreen = new c.Signal, this.fullScreenFailed = this.onFullScreenError, this.screenOrientation = this.dom.getScreenOrientation(), this.scaleFactor = new c.Point(1, 1), this.scaleFactorInversed = new c.Point(1, 1), this.margin = {
  3638. left: 0,
  3639. top: 0,
  3640. right: 0,
  3641. bottom: 0,
  3642. x: 0,
  3643. y: 0
  3644. }, this.bounds = new c.Rectangle, this.aspectRatio = 0, this.sourceAspectRatio = 0, this.event = null, this.windowConstraints = {
  3645. right: "layout",
  3646. bottom: ""
  3647. }, this.compatibility = {
  3648. supportsFullScreen: !1,
  3649. orientationFallback: null,
  3650. noMargins: !1,
  3651. scrollTo: null,
  3652. forceMinimumDocumentHeight: !1,
  3653. canExpandParent: !0,
  3654. clickTrampoline: ""
  3655. }, this._scaleMode = c.ScaleManager.NO_SCALE, this._fullScreenScaleMode = c.ScaleManager.NO_SCALE, this.parentIsWindow = !1, this.parentNode = null, this.parentScaleFactor = new c.Point(1, 1), this.trackParentInterval = 2e3, this.onSizeChange = new c.Signal, this.onResize = null, this.onResizeContext = null, this._fullScreenRestore = null, this._gameSize = new c.Rectangle, this._userScaleFactor = new c.Point(1, 1), this._userScaleTrim = new c.Point(0, 0), this._lastUpdate = 0, this._updateThrottle = 0, this._updateThrottleReset = 100, this._parentBounds = new c.Rectangle, this._tempBounds = new c.Rectangle, this._lastReportedCanvasSize = new c.Rectangle, this._lastReportedGameSize = new c.Rectangle, a.config && this.parseConfig(a.config), this.setupScale(b, d)
  3656. }, c.ScaleManager.EXACT_FIT = 0, c.ScaleManager.NO_SCALE = 1, c.ScaleManager.SHOW_ALL = 2, c.ScaleManager.RESIZE = 3, c.ScaleManager.USER_SCALE = 4, c.ScaleManager.prototype = {
  3657. boot: function() {
  3658. var a = this.compatibility;
  3659. a.supportsFullScreen = this.game.device.fullscreen && !this.game.device.cocoonJS, this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (a.scrollTo = this.game.device.android && !this.game.device.chrome ? new c.Point(0, 1) : new c.Point(0, 0)), this.game.device.desktop ? (a.orientationFallback = "screen", a.clickTrampoline = "when-not-mouse") : (a.orientationFallback = "", a.clickTrampoline = "");
  3660. var b = this;
  3661. this._orientationChange = function(a) {
  3662. return b.orientationChange(a)
  3663. }, this._windowResize = function(a) {
  3664. return b.windowResize(a)
  3665. }, window.addEventListener("orientationchange", this._orientationChange, !1), window.addEventListener("resize", this._windowResize, !1), this.compatibility.supportsFullScreen && (this._fullScreenChange = function(a) {
  3666. return b.fullScreenChange(a)
  3667. }, this._fullScreenError = function(a) {
  3668. return b.fullScreenError(a)
  3669. }, document.addEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.addEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.addEventListener("MSFullscreenChange", this._fullScreenChange, !1), document.addEventListener("fullscreenchange", this._fullScreenChange, !1), document.addEventListener("webkitfullscreenerror", this._fullScreenError, !1), document.addEventListener("mozfullscreenerror", this._fullScreenError, !1), document.addEventListener("MSFullscreenError", this._fullScreenError, !1), document.addEventListener("fullscreenerror", this._fullScreenError, !1)), this.game.onResume.add(this._gameResumed, this), this.dom.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height), this.setGameSize(this.game.width, this.game.height), this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback), this.grid = new c.FlexGrid(this, this.width, this.height)
  3670. },
  3671. parseConfig: function(a) {
  3672. a.scaleMode && (this.scaleMode = a.scaleMode), a.fullScreenScaleMode && (this.fullScreenScaleMode = a.fullScreenScaleMode), a.fullScreenTarget && (this.fullScreenTarget = a.fullScreenTarget)
  3673. },
  3674. setupScale: function(a, b) {
  3675. var d, e = new c.Rectangle;
  3676. "" !== this.game.parent && ("string" == typeof this.game.parent ? d = document.getElementById(this.game.parent) : this.game.parent && 1 === this.game.parent.nodeType && (d = this.game.parent)), d ? (this.parentNode = d, this.parentIsWindow = !1, this.getParentBounds(this._parentBounds), e.width = this._parentBounds.width, e.height = this._parentBounds.height, this.offset.set(this._parentBounds.x, this._parentBounds.y)) : (this.parentNode = null, this.parentIsWindow = !0, e.width = this.dom.visualBounds.width, e.height = this.dom.visualBounds.height, this.offset.set(0, 0));
  3677. var f = 0,
  3678. g = 0;
  3679. "number" == typeof a ? f = a : (this.parentScaleFactor.x = parseInt(a, 10) / 100, f = e.width * this.parentScaleFactor.x), "number" == typeof b ? g = b : (this.parentScaleFactor.y = parseInt(b, 10) / 100, g = e.height * this.parentScaleFactor.y), this._gameSize.setTo(0, 0, f, g), this.updateDimensions(f, g, !1)
  3680. },
  3681. _gameResumed: function() {
  3682. this.queueUpdate(!0)
  3683. },
  3684. setGameSize: function(a, b) {
  3685. this._gameSize.setTo(0, 0, a, b), this.currentScaleMode !== c.ScaleManager.RESIZE && this.updateDimensions(a, b, !0), this.queueUpdate(!0)
  3686. },
  3687. setUserScale: function(a, b, c, d) {
  3688. this._userScaleFactor.setTo(a, b), this._userScaleTrim.setTo(0 | c, 0 | d), this.queueUpdate(!0)
  3689. },
  3690. setResizeCallback: function(a, b) {
  3691. this.onResize = a, this.onResizeContext = b
  3692. },
  3693. signalSizeChange: function() {
  3694. if (!c.Rectangle.sameDimensions(this, this._lastReportedCanvasSize) || !c.Rectangle.sameDimensions(this.game, this._lastReportedGameSize)) {
  3695. var a = this.width,
  3696. b = this.height;
  3697. this._lastReportedCanvasSize.setTo(0, 0, a, b), this._lastReportedGameSize.setTo(0, 0, this.game.width, this.game.height), this.grid.onResize(a, b), this.onSizeChange.dispatch(this, a, b), this.currentScaleMode === c.ScaleManager.RESIZE && (this.game.state.resize(a, b), this.game.load.resize(a, b))
  3698. }
  3699. },
  3700. setMinMax: function(a, b, c, d) {
  3701. this.minWidth = a, this.minHeight = b, "undefined" != typeof c && (this.maxWidth = c), "undefined" != typeof d && (this.maxHeight = d)
  3702. },
  3703. preUpdate: function() {
  3704. if (!(this.game.time.time < this._lastUpdate + this._updateThrottle)) {
  3705. var a = this._updateThrottle;
  3706. this._updateThrottleReset = a >= 400 ? 0 : 100, this.dom.getOffset(this.game.canvas, this.offset);
  3707. var b = this._parentBounds.width,
  3708. d = this._parentBounds.height,
  3709. e = this.getParentBounds(this._parentBounds),
  3710. f = e.width !== b || e.height !== d,
  3711. g = this.updateOrientationState();
  3712. (f || g) && (this.onResize && this.onResize.call(this.onResizeContext, this, e), this.updateLayout(), this.signalSizeChange());
  3713. var h = 2 * this._updateThrottle;
  3714. this._updateThrottle < a && (h = Math.min(a, this._updateThrottleReset)), this._updateThrottle = c.Math.clamp(h, 25, this.trackParentInterval), this._lastUpdate = this.game.time.time
  3715. }
  3716. },
  3717. pauseUpdate: function() {
  3718. this.preUpdate(), this._updateThrottle = this.trackParentInterval
  3719. },
  3720. updateDimensions: function(a, b, c) {
  3721. this.width = a * this.parentScaleFactor.x, this.height = b * this.parentScaleFactor.y, this.game.width = this.width, this.game.height = this.height, this.sourceAspectRatio = this.width / this.height, this.updateScalingAndBounds(), c && (this.game.renderer.resize(this.width, this.height), this.game.camera.setSize(this.width, this.height), this.game.world.resize(this.width, this.height))
  3722. },
  3723. updateScalingAndBounds: function() {
  3724. 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.aspectRatio = this.width / this.height, this.game.canvas && this.dom.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height), this.game.input && this.game.input.scale && this.game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y)
  3725. },
  3726. forceOrientation: function(a, b) {
  3727. "undefined" == typeof b && (b = !1), this.forceLandscape = a, this.forcePortrait = b, this.queueUpdate(!0)
  3728. },
  3729. classifyOrientation: function(a) {
  3730. return "portrait-primary" === a || "portrait-secondary" === a ? "portrait" : "landscape-primary" === a || "landscape-secondary" === a ? "landscape" : null
  3731. },
  3732. updateOrientationState: function() {
  3733. var a = this.screenOrientation,
  3734. b = this.incorrectOrientation;
  3735. this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback), this.incorrectOrientation = this.forceLandscape && !this.isLandscape || this.forcePortrait && !this.isPortrait;
  3736. var c = a !== this.screenOrientation,
  3737. d = b !== this.incorrectOrientation;
  3738. return c && (this.isLandscape ? this.enterLandscape.dispatch(this.orientation, !0, !1) : this.enterPortrait.dispatch(this.orientation, !1, !0)), d && (this.incorrectOrientation ? this.enterIncorrectOrientation.dispatch() : this.leaveIncorrectOrientation.dispatch()), (c || d) && this.onOrientationChange.dispatch(this, a, b), c || d
  3739. },
  3740. orientationChange: function(a) {
  3741. this.event = a, this.queueUpdate(!0)
  3742. },
  3743. windowResize: function(a) {
  3744. this.event = a, this.queueUpdate(!0)
  3745. },
  3746. scrollTop: function() {
  3747. var a = this.compatibility.scrollTo;
  3748. a && window.scrollTo(a.x, a.y)
  3749. },
  3750. refresh: function() {
  3751. this.scrollTop(), this.queueUpdate(!0)
  3752. },
  3753. updateLayout: function() {
  3754. var a = this.currentScaleMode;
  3755. if (a === c.ScaleManager.RESIZE) return void this.reflowGame();
  3756. if (this.scrollTop(), this.compatibility.forceMinimumDocumentHeight && (document.documentElement.style.minHeight = window.innerHeight + "px"), this.incorrectOrientation ? this.setMaximum() : a === c.ScaleManager.EXACT_FIT ? this.setExactFit() : a === c.ScaleManager.SHOW_ALL ? !this.isFullScreen && this.boundingParent && this.compatibility.canExpandParent ? (this.setShowAll(!0), this.resetCanvas(), this.setShowAll()) : this.setShowAll() : a === c.ScaleManager.NO_SCALE ? (this.width = this.game.width, this.height = this.game.height) : a === c.ScaleManager.USER_SCALE && (this.width = this.game.width * this._userScaleFactor.x - this._userScaleTrim.x, this.height = this.game.height * this._userScaleFactor.y - this._userScaleTrim.y), !this.compatibility.canExpandParent && (a === c.ScaleManager.SHOW_ALL || a === c.ScaleManager.USER_SCALE)) {
  3757. var b = this.getParentBounds(this._tempBounds);
  3758. this.width = Math.min(this.width, b.width), this.height = Math.min(this.height, b.height)
  3759. }
  3760. this.width = 0 | this.width, this.height = 0 | this.height, this.reflowCanvas()
  3761. },
  3762. getParentBounds: function(a) {
  3763. var b = a || new c.Rectangle,
  3764. d = this.boundingParent,
  3765. e = this.dom.visualBounds,
  3766. f = this.dom.layoutBounds;
  3767. if (d) {
  3768. var g = d.getBoundingClientRect();
  3769. b.setTo(g.left, g.top, g.width, g.height);
  3770. var h = this.windowConstraints;
  3771. if (h.right) {
  3772. var i = "layout" === h.right ? f : e;
  3773. b.right = Math.min(b.right, i.width)
  3774. }
  3775. if (h.bottom) {
  3776. var i = "layout" === h.bottom ? f : e;
  3777. b.bottom = Math.min(b.bottom, i.height)
  3778. }
  3779. } else b.setTo(0, 0, e.width, e.height);
  3780. return b.setTo(Math.round(b.x), Math.round(b.y), Math.round(b.width), Math.round(b.height)), b
  3781. },
  3782. alignCanvas: function(a, b) {
  3783. var c = this.getParentBounds(this._tempBounds),
  3784. d = this.game.canvas,
  3785. e = this.margin;
  3786. if (a) {
  3787. e.left = e.right = 0;
  3788. var f = d.getBoundingClientRect();
  3789. if (this.width < c.width && !this.incorrectOrientation) {
  3790. var g = f.left - c.x,
  3791. h = c.width / 2 - this.width / 2;
  3792. h = Math.max(h, 0);
  3793. var i = h - g;
  3794. e.left = Math.round(i)
  3795. }
  3796. d.style.marginLeft = e.left + "px", 0 !== e.left && (e.right = -(c.width - f.width - e.left), d.style.marginRight = e.right + "px")
  3797. }
  3798. if (b) {
  3799. e.top = e.bottom = 0;
  3800. var f = d.getBoundingClientRect();
  3801. if (this.height < c.height && !this.incorrectOrientation) {
  3802. var g = f.top - c.y,
  3803. h = c.height / 2 - this.height / 2;
  3804. h = Math.max(h, 0);
  3805. var i = h - g;
  3806. e.top = Math.round(i)
  3807. }
  3808. d.style.marginTop = e.top + "px", 0 !== e.top && (e.bottom = -(c.height - f.height - e.top), d.style.marginBottom = e.bottom + "px")
  3809. }
  3810. e.x = e.left, e.y = e.top
  3811. },
  3812. reflowGame: function() {
  3813. this.resetCanvas("", "");
  3814. var a = this.getParentBounds(this._tempBounds);
  3815. this.updateDimensions(a.width, a.height, !0)
  3816. },
  3817. reflowCanvas: function() {
  3818. this.incorrectOrientation || (this.width = c.Math.clamp(this.width, this.minWidth || 0, this.maxWidth || this.width), this.height = c.Math.clamp(this.height, this.minHeight || 0, this.maxHeight || this.height)), this.resetCanvas(), this.compatibility.noMargins || (this.isFullScreen && this._createdFullScreenTarget ? this.alignCanvas(!0, !0) : this.alignCanvas(this.pageAlignHorizontally, this.pageAlignVertically)), this.updateScalingAndBounds()
  3819. },
  3820. resetCanvas: function(a, b) {
  3821. "undefined" == typeof a && (a = this.width + "px"), "undefined" == typeof b && (b = this.height + "px");
  3822. var c = this.game.canvas;
  3823. this.compatibility.noMargins || (c.style.marginLeft = "", c.style.marginTop = "", c.style.marginRight = "", c.style.marginBottom = ""), c.style.width = a, c.style.height = b
  3824. },
  3825. queueUpdate: function(a) {
  3826. a && (this._parentBounds.width = 0, this._parentBounds.height = 0), this._updateThrottle = this._updateThrottleReset
  3827. },
  3828. reset: function(a) {
  3829. a && this.grid.reset()
  3830. },
  3831. setMaximum: function() {
  3832. this.width = this.dom.visualBounds.width, this.height = this.dom.visualBounds.height
  3833. },
  3834. setShowAll: function(a) {
  3835. var b, c = this.getParentBounds(this._tempBounds),
  3836. d = c.width,
  3837. e = c.height;
  3838. b = a ? Math.max(e / this.game.height, d / this.game.width) : Math.min(e / this.game.height, d / this.game.width), this.width = Math.round(this.game.width * b), this.height = Math.round(this.game.height * b)
  3839. },
  3840. setExactFit: function() {
  3841. var a = this.getParentBounds(this._tempBounds);
  3842. this.width = a.width, this.height = a.height, this.isFullScreen || (this.maxWidth && (this.width = Math.min(this.width, this.maxWidth)), this.maxHeight && (this.height = Math.min(this.height, this.maxHeight)))
  3843. },
  3844. createFullScreenTarget: function() {
  3845. var a = document.createElement("div");
  3846. return a.style.margin = "0", a.style.padding = "0", a.style.background = "#000", a
  3847. },
  3848. startFullScreen: function(a, b) {
  3849. if (this.isFullScreen) return !1;
  3850. if (!this.compatibility.supportsFullScreen) {
  3851. var d = this;
  3852. return void setTimeout(function() {
  3853. d.fullScreenError()
  3854. }, 10)
  3855. }
  3856. if ("when-not-mouse" === this.compatibility.clickTrampoline) {
  3857. var e = this.game.input;
  3858. if (e.activePointer && e.activePointer !== e.mousePointer && (b || b !== !1)) return void e.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [a, !1])
  3859. }
  3860. "undefined" != typeof a && this.game.renderType === c.CANVAS && (this.game.stage.smoothed = a);
  3861. var f = this.fullScreenTarget;
  3862. f || (this.cleanupCreatedTarget(), this._createdFullScreenTarget = this.createFullScreenTarget(), f = this._createdFullScreenTarget);
  3863. var g = {
  3864. targetElement: f
  3865. };
  3866. if (this.onFullScreenInit.dispatch(this, g), this._createdFullScreenTarget) {
  3867. var h = this.game.canvas,
  3868. i = h.parentNode;
  3869. i.insertBefore(f, h), f.appendChild(h)
  3870. }
  3871. return this.game.device.fullscreenKeyboard ? f[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT) : f[this.game.device.requestFullscreen](), !0
  3872. },
  3873. stopFullScreen: function() {
  3874. return this.isFullScreen && this.compatibility.supportsFullScreen ? (document[this.game.device.cancelFullscreen](), !0) : !1
  3875. },
  3876. cleanupCreatedTarget: function() {
  3877. var a = this._createdFullScreenTarget;
  3878. if (a && a.parentNode) {
  3879. var b = a.parentNode;
  3880. b.insertBefore(this.game.canvas, a), b.removeChild(a)
  3881. }
  3882. this._createdFullScreenTarget = null
  3883. },
  3884. prepScreenMode: function(a) {
  3885. var b = !!this._createdFullScreenTarget,
  3886. d = this._createdFullScreenTarget || this.fullScreenTarget;
  3887. a ? (b || this.fullScreenScaleMode === c.ScaleManager.EXACT_FIT) && d !== this.game.canvas && (this._fullScreenRestore = {
  3888. targetWidth: d.style.width,
  3889. targetHeight: d.style.height
  3890. }, d.style.width = "100%", d.style.height = "100%") : (this._fullScreenRestore && (d.style.width = this._fullScreenRestore.targetWidth, d.style.height = this._fullScreenRestore.targetHeight, this._fullScreenRestore = null), this.updateDimensions(this._gameSize.width, this._gameSize.height, !0), this.resetCanvas())
  3891. },
  3892. fullScreenChange: function(a) {
  3893. this.event = a, this.isFullScreen ? (this.prepScreenMode(!0), this.updateLayout(), this.queueUpdate(!0), this.enterFullScreen.dispatch(this.width, this.height)) : (this.prepScreenMode(!1), this.cleanupCreatedTarget(), this.updateLayout(), this.queueUpdate(!0), this.leaveFullScreen.dispatch(this.width, this.height)), this.onFullScreenChange.dispatch(this)
  3894. },
  3895. fullScreenError: function(a) {
  3896. this.event = a, this.cleanupCreatedTarget(), console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"), this.onFullScreenError.dispatch(this)
  3897. },
  3898. scaleSprite: function(a, b, c, d) {
  3899. if ("undefined" == typeof b && (b = this.width), "undefined" == typeof c && (c = this.height), "undefined" == typeof d && (d = !1), a.scale.set(1), a.width <= 0 || a.height <= 0 || 0 >= b || 0 >= c) return a;
  3900. var e = b,
  3901. f = a.height * b / a.width,
  3902. g = a.width * c / a.height,
  3903. h = c,
  3904. i = g > b;
  3905. return i = i ? d : !d, i ? (a.width = Math.floor(e), a.height = Math.floor(f)) : (a.width = Math.floor(g), a.height = Math.floor(h)), a
  3906. },
  3907. destroy: function() {
  3908. this.game.onResume.remove(this._gameResumed, this), window.removeEventListener("orientationchange", this._orientationChange, !1), window.removeEventListener("resize", this._windowResize, !1), this.compatibility.supportsFullScreen && (document.removeEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("MSFullscreenChange", this._fullScreenChange, !1), document.removeEventListener("fullscreenchange", this._fullScreenChange, !1), document.removeEventListener("webkitfullscreenerror", this._fullScreenError, !1), document.removeEventListener("mozfullscreenerror", this._fullScreenError, !1), document.removeEventListener("MSFullscreenError", this._fullScreenError, !1), document.removeEventListener("fullscreenerror", this._fullScreenError, !1))
  3909. }
  3910. }, c.ScaleManager.prototype.constructor = c.ScaleManager, c.ScaleManager.prototype.checkResize = c.ScaleManager.prototype.windowResize, c.ScaleManager.prototype.checkOrientation = c.ScaleManager.prototype.orientationChange, c.ScaleManager.prototype.setScreenSize = c.ScaleManager.prototype.updateLayout, c.ScaleManager.prototype.setSize = c.ScaleManager.prototype.reflowCanvas, c.ScaleManager.prototype.checkOrientationState = function() {
  3911. var a = this.updateOrientationState();
  3912. return a && this.refresh(), a
  3913. }, Object.defineProperty(c.ScaleManager.prototype, "boundingParent", {
  3914. get: function() {
  3915. if (this.parentIsWindow || this.isFullScreen && !this._createdFullScreenTarget) return null;
  3916. var a = this.game.canvas && this.game.canvas.parentNode;
  3917. return a || null
  3918. }
  3919. }), Object.defineProperty(c.ScaleManager.prototype, "scaleMode", {
  3920. get: function() {
  3921. return this._scaleMode
  3922. },
  3923. set: function(a) {
  3924. return a !== this._scaleMode && (this.isFullScreen || (this.updateDimensions(this._gameSize.width, this._gameSize.height, !0), this.queueUpdate(!0)), this._scaleMode = a), this._scaleMode
  3925. }
  3926. }), Object.defineProperty(c.ScaleManager.prototype, "fullScreenScaleMode", {
  3927. get: function() {
  3928. return this._fullScreenScaleMode
  3929. },
  3930. set: function(a) {
  3931. return a !== this._fullScreenScaleMode && (this.isFullScreen ? (this.prepScreenMode(!1), this._fullScreenScaleMode = a, this.prepScreenMode(!0), this.queueUpdate(!0)) : this._fullScreenScaleMode = a), this._fullScreenScaleMode
  3932. }
  3933. }), Object.defineProperty(c.ScaleManager.prototype, "currentScaleMode", {
  3934. get: function() {
  3935. return this.isFullScreen ? this._fullScreenScaleMode : this._scaleMode
  3936. }
  3937. }), Object.defineProperty(c.ScaleManager.prototype, "pageAlignHorizontally", {
  3938. get: function() {
  3939. return this._pageAlignHorizontally
  3940. },
  3941. set: function(a) {
  3942. a !== this._pageAlignHorizontally && (this._pageAlignHorizontally = a, this.queueUpdate(!0))
  3943. }
  3944. }), Object.defineProperty(c.ScaleManager.prototype, "pageAlignVertically", {
  3945. get: function() {
  3946. return this._pageAlignVertically
  3947. },
  3948. set: function(a) {
  3949. a !== this._pageAlignVertically && (this._pageAlignVertically = a, this.queueUpdate(!0))
  3950. }
  3951. }), Object.defineProperty(c.ScaleManager.prototype, "isFullScreen", {
  3952. get: function() {
  3953. return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)
  3954. }
  3955. }), Object.defineProperty(c.ScaleManager.prototype, "isPortrait", {
  3956. get: function() {
  3957. return "portrait" === this.classifyOrientation(this.screenOrientation)
  3958. }
  3959. }), Object.defineProperty(c.ScaleManager.prototype, "isLandscape", {
  3960. get: function() {
  3961. return "landscape" === this.classifyOrientation(this.screenOrientation)
  3962. }
  3963. }), Object.defineProperty(c.ScaleManager.prototype, "orientation", {
  3964. get: function() {
  3965. return "portrait" === this.classifyOrientation(this.screenOrientation) ? 0 : 90
  3966. }
  3967. }), Object.defineProperty(c.ScaleManager.prototype, "isGamePortrait", {
  3968. get: function() {
  3969. return this.height > this.width
  3970. }
  3971. }), Object.defineProperty(c.ScaleManager.prototype, "isGameLandscape", {
  3972. get: function() {
  3973. return this.width > this.height
  3974. }
  3975. }), c.Game = function(a, b, d, e, f, g, h, i) {
  3976. return this.id = c.GAMES.push(this) - 1, this.config = null, this.physicsConfig = i, this.parent = "", this.width = 800, this.height = 600, this.resolution = 1, this._width = 800, this._height = 600, this.transparent = !1, this.antialias = !0, this.preserveDrawingBuffer = !1, this.renderer = null, this.renderType = c.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.plugins = null, this.rnd = null, this.device = c.Device, this.camera = null, this.canvas = null, this.context = null, this.debug = null, this.particles = null, this.lockRender = !1, 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, this.currentUpdateID = 0, this.updatesThisFrame = 1, this._deltaTime = 0, this._lastCount = 0, this._spiraling = 0, this._kickstart = !0, this.fpsProblemNotifier = new c.Signal, this.forceSingleUpdate = !1, this._nextFpsNotification = 0, 1 === arguments.length && "object" == typeof arguments[0] ? this.parseConfig(arguments[0]) : (this.config = {
  3977. enableDebug: !0
  3978. }, "undefined" != typeof a && (this._width = a), "undefined" != typeof b && (this._height = b), "undefined" != typeof 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 c.RandomDataGenerator([(Date.now() * Math.random()).toString()]), this.state = new c.StateManager(this, f)), this.device.whenReady(this.boot, this), this
  3979. }, c.Game.prototype = {
  3980. parseConfig: function(a) {
  3981. this.config = a, "undefined" == typeof a.enableDebug && (this.config.enableDebug = !0), a.width && (this._width = a.width), a.height && (this._height = a.height), 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.resolution && (this.resolution = a.resolution), a.preserveDrawingBuffer && (this.preserveDrawingBuffer = a.preserveDrawingBuffer), a.physicsConfig && (this.physicsConfig = a.physicsConfig);
  3982. var b = [(Date.now() * Math.random()).toString()];
  3983. a.seed && (b = a.seed), this.rnd = new c.RandomDataGenerator(b);
  3984. var d = null;
  3985. a.state && (d = a.state), this.state = new c.StateManager(this, d)
  3986. },
  3987. boot: function() {
  3988. this.isBooted || (this.onPause = new c.Signal, this.onResume = new c.Signal, this.onBlur = new c.Signal, this.onFocus = new c.Signal, this.isBooted = !0, this.math = c.Math, this.scale = new c.ScaleManager(this, this._width, this._height), this.stage = new c.Stage(this), this.setUpRenderer(), this.world = new c.World(this), this.add = new c.GameObjectFactory(this), this.make = new c.GameObjectCreator(this), this.cache = new c.Cache(this), this.load = new c.Loader(this), this.time = new c.Time(this), this.tweens = new c.TweenManager(this), this.input = new c.Input(this), this.sound = new c.SoundManager(this), this.physics = new c.Physics(this, this.physicsConfig), this.particles = new c.Particles(this), this.plugins = new c.PluginManager(this), this.net = new c.Net(this), this.time.boot(), this.stage.boot(), this.world.boot(), this.scale.boot(), this.input.boot(), this.sound.boot(), this.state.boot(), this.config.enableDebug ? (this.debug = new c.Utils.Debug(this), this.debug.boot()) : this.debug = {
  3989. preUpdate: function() {},
  3990. update: function() {},
  3991. reset: function() {}
  3992. }, this.showDebugHeader(), this.isRunning = !0, this.raf = this.config && this.config.forceSetTimeOut ? new c.RequestAnimationFrame(this, this.config.forceSetTimeOut) : new c.RequestAnimationFrame(this, !1), this._kickstart = !0, window.focus && (!window.PhaserGlobal || window.PhaserGlobal && !window.PhaserGlobal.stopFocus) && window.focus(), this.raf.start())
  3993. },
  3994. showDebugHeader: function() {
  3995. if (!window.PhaserGlobal || !window.PhaserGlobal.hideBanner) {
  3996. var a = c.VERSION,
  3997. b = "Canvas",
  3998. d = "HTML Audio",
  3999. e = 1;
  4000. if (this.renderType === c.WEBGL ? (b = "WebGL", e++) : this.renderType == c.HEADLESS && (b = "Headless"), this.device.webAudio && (d = "WebAudio", e++), this.device.chrome) {
  4001. for (var f = ["%c %c %c Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + b + " | " + d + " %c %c %c http://phaser.io %c♥%c♥%c♥", "background: #9854d8", "background: #6c2ca7", "color: #ffffff; background: #450f78;", "background: #6c2ca7", "background: #9854d8", "background: #ffffff"], g = 0; 3 > g; g++) f.push(e > g ? "color: #ff2424; background: #fff" : "color: #959595; background: #fff");
  4002. console.log.apply(console, f)
  4003. } else window.console && console.log("Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + b + " | " + d + " | http://phaser.io")
  4004. }
  4005. },
  4006. setUpRenderer: function() {
  4007. if (this.canvas = this.config.canvasID ? c.Canvas.create(this.width, this.height, this.config.canvasID) : c.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 = this.renderType === c.CANVAS ? !0 : !1), this.renderType === c.HEADLESS || this.renderType === c.CANVAS || this.renderType === c.AUTO && this.device.webGL === !1) {
  4008. if (!this.device.canvas) throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");
  4009. this.renderType === c.AUTO && (this.renderType = c.CANVAS), this.renderer = new PIXI.CanvasRenderer(this.width, this.height, {
  4010. view: this.canvas,
  4011. transparent: this.transparent,
  4012. resolution: this.resolution,
  4013. clearBeforeRender: !0
  4014. }), this.context = this.renderer.context
  4015. } else this.renderType = c.WEBGL, this.renderer = new PIXI.WebGLRenderer(this.width, this.height, {
  4016. view: this.canvas,
  4017. transparent: this.transparent,
  4018. resolution: this.resolution,
  4019. antialias: this.antialias,
  4020. preserveDrawingBuffer: this.preserveDrawingBuffer
  4021. }), this.context = null;
  4022. this.renderType !== c.HEADLESS && (this.stage.smoothed = this.antialias, c.Canvas.addToDOM(this.canvas, this.parent, !1), c.Canvas.setTouchAction(this.canvas))
  4023. },
  4024. update: function(a) {
  4025. if (this.time.update(a), this._kickstart) return this.updateLogic(1 / this.time.desiredFps), this.stage.updateTransform(), this.updateRender(this.time.slowMotion * this.time.desiredFps), void(this._kickstart = !1);
  4026. if (this._spiraling > 1 && !this.forceSingleUpdate) this.time.time > this._nextFpsNotification && (this._nextFpsNotification = this.time.time + 1e4, this.fpsProblemNotifier.dispatch()), this._deltaTime = 0, this._spiraling = 0, this.updateRender(this.time.slowMotion * this.time.desiredFps);
  4027. else {
  4028. var b = 1e3 * this.time.slowMotion / this.time.desiredFps;
  4029. this._deltaTime += Math.max(Math.min(3 * b, this.time.elapsed), 0);
  4030. var c = 0;
  4031. for (this.updatesThisFrame = Math.floor(this._deltaTime / b), this.forceSingleUpdate && (this.updatesThisFrame = Math.min(1, this.updatesThisFrame)); this._deltaTime >= b && (this._deltaTime -= b, this.currentUpdateID = c, this.updateLogic(1 / this.time.desiredFps), this.stage.updateTransform(), c++, !this.forceSingleUpdate || 1 !== c););
  4032. c > this._lastCount ? this._spiraling++ : c < this._lastCount && (this._spiraling = 0), this._lastCount = c, this.updateRender(this._deltaTime / b)
  4033. }
  4034. },
  4035. updateLogic: function(a) {
  4036. this._paused || this.pendingStep ? (this.scale.pauseUpdate(), this.state.pauseUpdate(), this.debug.preUpdate()) : (this.stepping && (this.pendingStep = !0), this.scale.preUpdate(), this.debug.preUpdate(), this.world.camera.preUpdate(), this.physics.preUpdate(), this.state.preUpdate(a), this.plugins.preUpdate(a), this.stage.preUpdate(), this.state.update(), this.stage.update(), this.tweens.update(a), this.sound.update(), this.input.update(), this.physics.update(), this.particles.update(), this.plugins.update(), this.stage.postUpdate(), this.plugins.postUpdate())
  4037. },
  4038. updateRender: function(a) {
  4039. this.lockRender || (this.state.preRender(a), this.renderer.render(this.stage), this.plugins.render(a), this.state.render(a), this.plugins.postRender(a))
  4040. },
  4041. enableStep: function() {
  4042. this.stepping = !0, this.pendingStep = !1, this.stepCount = 0
  4043. },
  4044. disableStep: function() {
  4045. this.stepping = !1, this.pendingStep = !1
  4046. },
  4047. step: function() {
  4048. this.pendingStep = !1, this.stepCount++
  4049. },
  4050. destroy: function() {
  4051. this.raf.stop(), this.state.destroy(), this.sound.destroy(), this.scale.destroy(), this.stage.destroy(), this.input.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, this.renderer.destroy(!1), c.Canvas.removeFromDOM(this.canvas), c.GAMES[this.id] = null
  4052. },
  4053. gamePaused: function(a) {
  4054. this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.setMute(), this.onPause.dispatch(a))
  4055. },
  4056. gameResumed: function(a) {
  4057. this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.unsetMute(), this.onResume.dispatch(a))
  4058. },
  4059. focusLoss: function(a) {
  4060. this.onBlur.dispatch(a), this.stage.disableVisibilityChange || this.gamePaused(a)
  4061. },
  4062. focusGain: function(a) {
  4063. this.onFocus.dispatch(a), this.stage.disableVisibilityChange || this.gameResumed(a)
  4064. }
  4065. }, c.Game.prototype.constructor = c.Game, Object.defineProperty(c.Game.prototype, "paused", {
  4066. get: function() {
  4067. return this._paused
  4068. },
  4069. set: function(a) {
  4070. 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)
  4071. }
  4072. }), c.Input = function(a) {
  4073. this.game = a, this.hitCanvas = null, this.hitContext = null, this.moveCallbacks = [], this.moveCallback = null, this.moveCallbackContext = this, this.pollRate = 0, this.enabled = !0, this.multiInputOverride = c.Input.MOUSE_TOUCH_COMBINE, this.position = null, this.speed = null, this.circle = null, this.scale = null, this.maxPointers = -1, 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.pointers = [], 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 c.ArraySet, this._localPoint = new c.Point, this._pollCounter = 0, this._oldPosition = null, this._x = 0, this._y = 0
  4074. }, c.Input.MOUSE_OVERRIDES_TOUCH = 0, c.Input.TOUCH_OVERRIDES_MOUSE = 1, c.Input.MOUSE_TOUCH_COMBINE = 2, c.Input.MAX_POINTERS = 10, c.Input.prototype = {
  4075. boot: function() {
  4076. this.mousePointer = new c.Pointer(this.game, 0), this.addPointer(), this.addPointer(), this.mouse = new c.Mouse(this.game), this.touch = new c.Touch(this.game), this.mspointer = new c.MSPointer(this.game), c.Keyboard && (this.keyboard = new c.Keyboard(this.game)), c.Gamepad && (this.gamepad = new c.Gamepad(this.game)), this.onDown = new c.Signal, this.onUp = new c.Signal, this.onTap = new c.Signal, this.onHold = new c.Signal, this.scale = new c.Point(1, 1), this.speed = new c.Point, this.position = new c.Point, this._oldPosition = new c.Point, this.circle = new c.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.touch.start(), this.mspointer.start(), this.mousePointer.active = !0, this.keyboard && this.keyboard.start();
  4077. var a = this;
  4078. this._onClickTrampoline = function(b) {
  4079. a.onClickTrampoline(b)
  4080. }, this.game.canvas.addEventListener("click", this._onClickTrampoline, !1)
  4081. },
  4082. destroy: function() {
  4083. this.mouse.stop(), this.touch.stop(), this.mspointer.stop(), this.keyboard && this.keyboard.stop(), this.gamepad && this.gamepad.stop(), this.moveCallbacks = [], this.game.canvas.removeEventListener("click", this._onClickTrampoline)
  4084. },
  4085. addMoveCallback: function(a, b) {
  4086. return this.moveCallbacks.push({
  4087. callback: a,
  4088. context: b
  4089. }) - 1
  4090. },
  4091. deleteMoveCallback: function(a) {
  4092. this.moveCallbacks[a] && this.moveCallbacks.splice(a, 1)
  4093. },
  4094. addPointer: function() {
  4095. if (this.pointers.length >= c.Input.MAX_POINTERS) return console.warn("Phaser.Input.addPointer: only " + c.Input.MAX_POINTERS + " pointer allowed"), null;
  4096. var a = this.pointers.length + 1,
  4097. b = new c.Pointer(this.game, a);
  4098. return this.pointers.push(b), this["pointer" + a] = b, b
  4099. },
  4100. update: function() {
  4101. if (this.keyboard && this.keyboard.update(), this.pollRate > 0 && this._pollCounter < this.pollRate) return void this._pollCounter++;
  4102. 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 && this.gamepad.active && this.gamepad.update();
  4103. for (var a = 0; a < this.pointers.length; a++) this.pointers[a].update();
  4104. this._pollCounter = 0
  4105. },
  4106. reset: function(a) {
  4107. if (this.game.isBooted && !this.resetLocked) {
  4108. "undefined" == typeof a && (a = !1), this.mousePointer.reset(), this.keyboard && this.keyboard.reset(a), this.gamepad && this.gamepad.reset();
  4109. for (var b = 0; b < this.pointers.length; b++) this.pointers[b].reset();
  4110. 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 c.Signal, this.onUp = new c.Signal, this.onTap = new c.Signal, this.onHold = new c.Signal, this.moveCallbacks = []), this._pollCounter = 0
  4111. }
  4112. },
  4113. resetSpeed: function(a, b) {
  4114. this._oldPosition.setTo(a, b), this.speed.setTo(0, 0)
  4115. },
  4116. startPointer: function(a) {
  4117. if (this.maxPointers >= 0 && this.countActivePointers(this.maxPointers) >= this.maxPointers) return null;
  4118. if (!this.pointer1.active) return this.pointer1.start(a);
  4119. if (!this.pointer2.active) return this.pointer2.start(a);
  4120. for (var b = 2; b < this.pointers.length; b++) {
  4121. var c = this.pointers[b];
  4122. if (!c.active) return c.start(a)
  4123. }
  4124. return null
  4125. },
  4126. updatePointer: function(a) {
  4127. if (this.pointer1.active && this.pointer1.identifier === a.identifier) return this.pointer1.move(a);
  4128. if (this.pointer2.active && this.pointer2.identifier === a.identifier) return this.pointer2.move(a);
  4129. for (var b = 2; b < this.pointers.length; b++) {
  4130. var c = this.pointers[b];
  4131. if (c.active && c.identifier === a.identifier) return c.move(a)
  4132. }
  4133. return null
  4134. },
  4135. stopPointer: function(a) {
  4136. if (this.pointer1.active && this.pointer1.identifier === a.identifier) return this.pointer1.stop(a);
  4137. if (this.pointer2.active && this.pointer2.identifier === a.identifier) return this.pointer2.stop(a);
  4138. for (var b = 2; b < this.pointers.length; b++) {
  4139. var c = this.pointers[b];
  4140. if (c.active && c.identifier === a.identifier) return c.stop(a)
  4141. }
  4142. return null
  4143. },
  4144. countActivePointers: function(a) {
  4145. "undefined" == typeof a && (a = this.pointers.length);
  4146. for (var b = a, c = 0; c < this.pointers.length && b > 0; c++) {
  4147. var d = this.pointers[c];
  4148. d.active && b--
  4149. }
  4150. return this.currentPointers = a - b, a - b
  4151. },
  4152. getPointer: function(a) {
  4153. "undefined" == typeof a && (a = !1);
  4154. for (var b = 0; b < this.pointers.length; b++) {
  4155. var c = this.pointers[b];
  4156. if (c.active === a) return c
  4157. }
  4158. return null
  4159. },
  4160. getPointerFromIdentifier: function(a) {
  4161. for (var b = 0; b < this.pointers.length; b++) {
  4162. var c = this.pointers[b];
  4163. if (c.identifier === a) return c
  4164. }
  4165. return null
  4166. },
  4167. getPointerFromId: function(a) {
  4168. for (var b = 0; b < this.pointers.length; b++) {
  4169. var c = this.pointers[b];
  4170. if (c.pointerId === a) return c
  4171. }
  4172. return null
  4173. },
  4174. getLocalPosition: function(a, b, d) {
  4175. "undefined" == typeof d && (d = new c.Point);
  4176. var e = a.worldTransform,
  4177. f = 1 / (e.a * e.d + e.c * -e.b);
  4178. return d.setTo(e.d * f * b.x + -e.c * f * b.y + (e.ty * e.c - e.tx * e.d) * f, e.a * f * b.y + -e.b * f * b.x + (-e.ty * e.a + e.tx * e.b) * f)
  4179. },
  4180. hitTest: function(a, b, d) {
  4181. if (!a.worldVisible) return !1;
  4182. if (this.getLocalPosition(a, b, this._localPoint), d.copyFrom(this._localPoint), a.hitArea && a.hitArea.contains) return a.hitArea.contains(this._localPoint.x, this._localPoint.y);
  4183. if (a instanceof c.TileSprite) {
  4184. var e = a.width,
  4185. f = a.height,
  4186. g = -e * a.anchor.x;
  4187. if (this._localPoint.x >= g && this._localPoint.x < g + e) {
  4188. var h = -f * a.anchor.y;
  4189. if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
  4190. }
  4191. } else if (a instanceof PIXI.Sprite) {
  4192. var e = a.texture.frame.width,
  4193. f = a.texture.frame.height,
  4194. g = -e * a.anchor.x;
  4195. if (this._localPoint.x >= g && this._localPoint.x < g + e) {
  4196. var h = -f * a.anchor.y;
  4197. if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
  4198. }
  4199. } else if (a instanceof c.Graphics)
  4200. for (var i = 0; i < a.graphicsData.length; i++) {
  4201. var j = a.graphicsData[i];
  4202. if (j.fill && j.shape && j.shape.contains(this._localPoint.x, this._localPoint.y)) return !0
  4203. }
  4204. for (var i = 0, k = a.children.length; k > i; i++)
  4205. if (this.hitTest(a.children[i], b, d)) return !0;
  4206. return !1
  4207. },
  4208. onClickTrampoline: function() {
  4209. this.activePointer.processClickTrampolines()
  4210. }
  4211. }, c.Input.prototype.constructor = c.Input, Object.defineProperty(c.Input.prototype, "x", {
  4212. get: function() {
  4213. return this._x
  4214. },
  4215. set: function(a) {
  4216. this._x = Math.floor(a)
  4217. }
  4218. }), Object.defineProperty(c.Input.prototype, "y", {
  4219. get: function() {
  4220. return this._y
  4221. },
  4222. set: function(a) {
  4223. this._y = Math.floor(a)
  4224. }
  4225. }), Object.defineProperty(c.Input.prototype, "pollLocked", {
  4226. get: function() {
  4227. return this.pollRate > 0 && this._pollCounter < this.pollRate
  4228. }
  4229. }), Object.defineProperty(c.Input.prototype, "totalInactivePointers", {
  4230. get: function() {
  4231. return this.pointers.length - this.countActivePointers()
  4232. }
  4233. }), Object.defineProperty(c.Input.prototype, "totalActivePointers", {
  4234. get: function() {
  4235. return this.countActivePointers()
  4236. }
  4237. }), Object.defineProperty(c.Input.prototype, "worldX", {
  4238. get: function() {
  4239. return this.game.camera.view.x + this.x
  4240. }
  4241. }), Object.defineProperty(c.Input.prototype, "worldY", {
  4242. get: function() {
  4243. return this.game.camera.view.y + this.y
  4244. }
  4245. }), Object.defineProperty(c.Input.prototype, "disabled", {
  4246. get: function() {
  4247. return !this.enabled
  4248. },
  4249. set: function(a) {
  4250. this.enabled = !a
  4251. }
  4252. }), c.Mouse = function(a) {
  4253. 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.enabled = !0, this.locked = !1, this.stopOnGameOut = !1, this.pointerLock = new c.Signal, this.event = null, this._onMouseDown = null, this._onMouseMove = null, this._onMouseUp = null, this._onMouseOut = null, this._onMouseOver = null, this._onMouseWheel = null, this._wheelEvent = null
  4254. }, c.Mouse.NO_BUTTON = -1, c.Mouse.LEFT_BUTTON = 0, c.Mouse.MIDDLE_BUTTON = 1, c.Mouse.RIGHT_BUTTON = 2, c.Mouse.WHEEL_UP = 1, c.Mouse.WHEEL_DOWN = -1, c.Mouse.prototype = {
  4255. start: function() {
  4256. if ((!this.game.device.android || this.game.device.chrome !== !1) && null === this._onMouseDown) {
  4257. var b = this;
  4258. this._onMouseDown = function(a) {
  4259. return b.onMouseDown(a)
  4260. }, this._onMouseMove = function(a) {
  4261. return b.onMouseMove(a)
  4262. }, this._onMouseUp = function(a) {
  4263. return b.onMouseUp(a)
  4264. }, this._onMouseUpGlobal = function(a) {
  4265. return b.onMouseUpGlobal(a)
  4266. }, this._onMouseOut = function(a) {
  4267. return b.onMouseOut(a)
  4268. }, this._onMouseOver = function(a) {
  4269. return b.onMouseOver(a)
  4270. }, this._onMouseWheel = function(a) {
  4271. return b.onMouseWheel(a)
  4272. }, 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.device.cocoonJS || (window.addEventListener("mouseup", this._onMouseUpGlobal, !0), this.game.canvas.addEventListener("mouseover", this._onMouseOver, !0), this.game.canvas.addEventListener("mouseout", this._onMouseOut, !0));
  4273. var c = this.game.device.wheelEvent;
  4274. c && (this.game.canvas.addEventListener(c, this._onMouseWheel, !0), "mousewheel" === c ? this._wheelEvent = new a(-1 / 40, 1) : "DOMMouseScroll" === c && (this._wheelEvent = new a(1, 1)))
  4275. }
  4276. },
  4277. onMouseDown: function(a) {
  4278. this.event = a, this.capture && a.preventDefault(), this.button = a.button, this.mouseDownCallback && this.mouseDownCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = 0, this.game.input.mousePointer.start(a))
  4279. },
  4280. onMouseMove: function(a) {
  4281. this.event = a, this.capture && a.preventDefault(), this.mouseMoveCallback && this.mouseMoveCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = 0, this.game.input.mousePointer.move(a))
  4282. },
  4283. onMouseUp: function(a) {
  4284. this.event = a, this.capture && a.preventDefault(), this.button = c.Mouse.NO_BUTTON, this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = 0, this.game.input.mousePointer.stop(a))
  4285. },
  4286. onMouseUpGlobal: function(a) {
  4287. this.game.input.mousePointer.withinGame || (this.button = c.Mouse.NO_BUTTON, this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, a), a.identifier = 0, this.game.input.mousePointer.stop(a))
  4288. },
  4289. onMouseOut: function(a) {
  4290. this.event = a, this.capture && a.preventDefault(), this.game.input.mousePointer.withinGame = !1, this.mouseOutCallback && this.mouseOutCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && this.stopOnGameOut && (a.identifier = 0, this.game.input.mousePointer.stop(a))
  4291. },
  4292. onMouseWheel: function(a) {
  4293. this._wheelEvent && (a = this._wheelEvent.bindEvent(a)), this.event = a, this.capture && a.preventDefault(), this.wheelDelta = c.Math.clamp(-a.deltaY, -1, 1), this.mouseWheelCallback && this.mouseWheelCallback.call(this.callbackContext, a)
  4294. },
  4295. onMouseOver: function(a) {
  4296. this.event = a, this.capture && a.preventDefault(), this.game.input.mousePointer.withinGame = !0, this.mouseOverCallback && this.mouseOverCallback.call(this.callbackContext, a), !this.game.input.enabled || !this.enabled
  4297. },
  4298. requestPointerLock: function() {
  4299. if (this.game.device.pointerLock) {
  4300. var a = this.game.canvas;
  4301. a.requestPointerLock = a.requestPointerLock || a.mozRequestPointerLock || a.webkitRequestPointerLock, a.requestPointerLock();
  4302. var b = this;
  4303. this._pointerLockChange = function(a) {
  4304. return b.pointerLockChange(a)
  4305. }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  4306. }
  4307. },
  4308. pointerLockChange: function(a) {
  4309. var b = this.game.canvas;
  4310. 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))
  4311. },
  4312. releasePointerLock: function() {
  4313. 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)
  4314. },
  4315. stop: function() {
  4316. 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);
  4317. var a = this.game.device.wheelEvent;
  4318. a && this.game.canvas.removeEventListener(a, this._onMouseWheel, !0), window.removeEventListener("mouseup", this._onMouseUpGlobal, !0), document.removeEventListener("pointerlockchange", this._pointerLockChange, !0), document.removeEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.removeEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  4319. }
  4320. }, c.Mouse.prototype.constructor = c.Mouse, Object.defineProperty(c.Mouse.prototype, "disabled", {
  4321. get: function() {
  4322. return !this.enabled
  4323. },
  4324. set: function(a) {
  4325. this.enabled = !a
  4326. }
  4327. }), a.prototype = {}, a.prototype.constructor = a, a.prototype.bindEvent = function(b) {
  4328. if (!a._stubsGenerated && b) {
  4329. var c = function(a) {
  4330. return function() {
  4331. var b = this.originalEvent[a];
  4332. return "function" != typeof b ? b : b.bind(this.originalEvent)
  4333. }
  4334. };
  4335. for (var d in b) d in a.prototype || Object.defineProperty(a.prototype, d, {
  4336. get: c(d)
  4337. });
  4338. a._stubsGenerated = !0
  4339. }
  4340. return this.originalEvent = b, this
  4341. }, Object.defineProperties(a.prototype, {
  4342. type: {
  4343. value: "wheel"
  4344. },
  4345. deltaMode: {
  4346. get: function() {
  4347. return this._deltaMode
  4348. }
  4349. },
  4350. deltaY: {
  4351. get: function() {
  4352. return this._scaleFactor * (this.originalEvent.wheelDelta || this.originalEvent.detail) || 0
  4353. }
  4354. },
  4355. deltaX: {
  4356. get: function() {
  4357. return this._scaleFactor * this.originalEvent.wheelDeltaX || 0
  4358. }
  4359. },
  4360. deltaZ: {
  4361. value: 0
  4362. }
  4363. }), c.MSPointer = function(a) {
  4364. this.game = a, this.callbackContext = this.game, this.pointerDownCallback = null, this.pointerMoveCallback = null, this.pointerUpCallback = null, this.capture = !0, this.button = -1, this.event = null, this.enabled = !0, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null
  4365. }, c.MSPointer.prototype = {
  4366. start: function() {
  4367. if (null === this._onMSPointerDown) {
  4368. var a = this;
  4369. this.game.device.mspointer && (this._onMSPointerDown = function(b) {
  4370. return a.onPointerDown(b)
  4371. }, this._onMSPointerMove = function(b) {
  4372. return a.onPointerMove(b)
  4373. }, this._onMSPointerUp = function(b) {
  4374. return a.onPointerUp(b)
  4375. }, this.game.canvas.addEventListener("MSPointerDown", this._onMSPointerDown, !1), this.game.canvas.addEventListener("MSPointerMove", this._onMSPointerMove, !1), this.game.canvas.addEventListener("MSPointerUp", this._onMSPointerUp, !1), this.game.canvas.addEventListener("pointerDown", this._onMSPointerDown, !1), this.game.canvas.addEventListener("pointerMove", this._onMSPointerMove, !1), this.game.canvas.addEventListener("pointerUp", this._onMSPointerUp, !1), this.game.canvas.style["-ms-content-zooming"] = "none", this.game.canvas.style["-ms-touch-action"] = "none")
  4376. }
  4377. },
  4378. onPointerDown: function(a) {
  4379. this.event = a, this.capture && a.preventDefault(), this.button = a.button, this.pointerDownCallback && this.pointerDownCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = a.pointerId, this.game.input.startPointer(a))
  4380. },
  4381. onPointerMove: function(a) {
  4382. this.event = a, this.capture && a.preventDefault(), this.pointerMoveCallback && this.pointerMoveCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = a.pointerId, this.game.input.updatePointer(a))
  4383. },
  4384. onPointerUp: function(a) {
  4385. this.event = a, this.capture && a.preventDefault(), this.button = c.Mouse.NO_BUTTON, this.pointerUpCallback && this.pointerUpCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && (a.identifier = a.pointerId, this.game.input.stopPointer(a))
  4386. },
  4387. stop: function() {
  4388. 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)
  4389. }
  4390. }, c.MSPointer.prototype.constructor = c.MSPointer, Object.defineProperty(c.MSPointer.prototype, "disabled", {
  4391. get: function() {
  4392. return !this.enabled
  4393. },
  4394. set: function(a) {
  4395. this.enabled = !a
  4396. }
  4397. }), c.Pointer = function(a, b) {
  4398. this.game = a, this.id = b, this.type = c.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.dirty = !1, this.position = new c.Point, this.positionDown = new c.Point, this.positionUp = new c.Point, this.circle = new c.Circle(0, 0, 44), 0 === b && (this.isMouse = !0), this._clickTrampolines = null, this._trampolineTargetObject = null
  4399. }, c.Pointer.prototype = {
  4400. start: function(a) {
  4401. 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.dirty = !1, this._clickTrampolines = null, this._trampolineTargetObject = null, this.msSinceLastClick = this.game.time.time - this.timeDown, this.timeDown = this.game.time.time, this._holdSent = !1, this.move(a, !0), this.positionDown.setTo(this.x, this.y), (this.game.input.multiInputOverride === c.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === c.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === c.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
  4402. },
  4403. update: function() {
  4404. this.active && (this.dirty && (this.game.input.interactiveItems.total > 0 && this.processInteractiveObjects(!1), this.dirty = !1), this._holdSent === !1 && this.duration >= this.game.input.holdRate && ((this.game.input.multiInputOverride == c.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == c.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride == c.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.time >= this._nextDrop && (this._nextDrop = this.game.time.time + this.game.input.recordRate, this._history.push({
  4405. x: this.position.x,
  4406. y: this.position.y
  4407. }), this._history.length > this.game.input.recordLimit && this._history.shift()))
  4408. },
  4409. move: function(a, b) {
  4410. if (!this.game.input.pollLocked) {
  4411. if ("undefined" == typeof b && (b = !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 && !b && (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.scale.offset.x) * this.game.input.scale.x, this.y = (this.pageY - this.game.scale.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 === c.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === c.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === c.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;
  4412. 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, b);
  4413. return null !== this.targetObject && this.targetObject.isDragged === !0 ? this.targetObject.update(this) === !1 && (this.targetObject = null) : this.game.input.interactiveItems.total > 0 && this.processInteractiveObjects(b), this
  4414. }
  4415. },
  4416. processInteractiveObjects: function(a) {
  4417. for (var b = Number.MAX_VALUE, c = -1, d = null, e = this.game.input.interactiveItems.first; e;) e.checked = !1, e.validForInput(c, b, !1) && (e.checked = !0, (a && e.checkPointerDown(this, !0) || !a && e.checkPointerOver(this, !0)) && (b = e.sprite.renderOrderID, c = e.priorityID, d = e)), e = this.game.input.interactiveItems.next;
  4418. for (var e = this.game.input.interactiveItems.first; e;) !e.checked && e.validForInput(c, b, !0) && (a && e.checkPointerDown(this, !1) || !a && e.checkPointerOver(this, !1)) && (b = e.sprite.renderOrderID, c = e.priorityID, d = e), e = this.game.input.interactiveItems.next;
  4419. return null === d ? this.targetObject && (this.targetObject._pointerOutHandler(this), this.targetObject = null) : null === this.targetObject ? (this.targetObject = d, d._pointerOverHandler(this)) : this.targetObject === d ? d.update(this) === !1 && (this.targetObject = null) : (this.targetObject._pointerOutHandler(this), this.targetObject = d, this.targetObject._pointerOverHandler(this)), null !== this.targetObject
  4420. },
  4421. leave: function(a) {
  4422. this.withinGame = !1, this.move(a, !1)
  4423. },
  4424. stop: function(a) {
  4425. return this._stateReset && this.withinGame ? void a.preventDefault() : (this.timeUp = this.game.time.time, (this.game.input.multiInputOverride === c.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === c.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === c.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._clickTrampolines && (this._trampolineTargetObject = this.targetObject), this.targetObject = null, this)
  4426. },
  4427. justPressed: function(a) {
  4428. return a = a || this.game.input.justPressedRate, this.isDown === !0 && this.timeDown + a > this.game.time.time
  4429. },
  4430. justReleased: function(a) {
  4431. return a = a || this.game.input.justReleasedRate, this.isUp === !0 && this.timeUp + a > this.game.time.time
  4432. },
  4433. addClickTrampoline: function(a, b, c, d) {
  4434. if (this.isDown) {
  4435. for (var e = this._clickTrampolines = this._clickTrampolines || [], f = 0; f < e.length; f++)
  4436. if (e[f].name === a) {
  4437. e.splice(f, 1);
  4438. break
  4439. }
  4440. e.push({
  4441. name: a,
  4442. targetObject: this.targetObject,
  4443. callback: b,
  4444. callbackContext: c,
  4445. callbackArgs: d
  4446. })
  4447. }
  4448. },
  4449. processClickTrampolines: function() {
  4450. var a = this._clickTrampolines;
  4451. if (a) {
  4452. for (var b = 0; b < a.length; b++) {
  4453. var c = a[b];
  4454. c.targetObject === this._trampolineTargetObject && c.callback.apply(c.callbackContext, c.callbackArgs)
  4455. }
  4456. this._clickTrampolines = null, this._trampolineTargetObject = null
  4457. }
  4458. },
  4459. reset: function() {
  4460. this.isMouse === !1 && (this.active = !1), this.pointerId = null, this.identifier = null, this.dirty = !1, 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
  4461. },
  4462. resetMovement: function() {
  4463. this.movementX = 0, this.movementY = 0
  4464. }
  4465. }, c.Pointer.prototype.constructor = c.Pointer, Object.defineProperty(c.Pointer.prototype, "duration", {
  4466. get: function() {
  4467. return this.isUp ? -1 : this.game.time.time - this.timeDown
  4468. }
  4469. }), Object.defineProperty(c.Pointer.prototype, "worldX", {
  4470. get: function() {
  4471. return this.game.world.camera.x + this.x
  4472. }
  4473. }), Object.defineProperty(c.Pointer.prototype, "worldY", {
  4474. get: function() {
  4475. return this.game.world.camera.y + this.y
  4476. }
  4477. }), c.Touch = function(a) {
  4478. this.game = a, this.enabled = !0, 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
  4479. }, c.Touch.prototype = {
  4480. start: function() {
  4481. if (null === this._onTouchStart) {
  4482. var a = this;
  4483. this.game.device.touch && (this._onTouchStart = function(b) {
  4484. return a.onTouchStart(b)
  4485. }, this._onTouchMove = function(b) {
  4486. return a.onTouchMove(b)
  4487. }, this._onTouchEnd = function(b) {
  4488. return a.onTouchEnd(b)
  4489. }, this._onTouchEnter = function(b) {
  4490. return a.onTouchEnter(b)
  4491. }, this._onTouchLeave = function(b) {
  4492. return a.onTouchLeave(b)
  4493. }, this._onTouchCancel = function(b) {
  4494. return a.onTouchCancel(b)
  4495. }, 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)))
  4496. }
  4497. },
  4498. consumeDocumentTouches: function() {
  4499. this._documentTouchMove = function(a) {
  4500. a.preventDefault()
  4501. }, document.addEventListener("touchmove", this._documentTouchMove, !1)
  4502. },
  4503. onTouchStart: function(a) {
  4504. if (this.event = a, this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled) {
  4505. this.preventDefault && a.preventDefault();
  4506. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.startPointer(a.changedTouches[b])
  4507. }
  4508. },
  4509. onTouchCancel: function(a) {
  4510. if (this.event = a, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled) {
  4511. this.preventDefault && a.preventDefault();
  4512. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4513. }
  4514. },
  4515. onTouchEnter: function(a) {
  4516. this.event = a, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, a), this.game.input.enabled && this.enabled && this.preventDefault && a.preventDefault()
  4517. },
  4518. onTouchLeave: function(a) {
  4519. this.event = a, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault()
  4520. },
  4521. onTouchMove: function(a) {
  4522. this.event = a, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4523. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.updatePointer(a.changedTouches[b])
  4524. },
  4525. onTouchEnd: function(a) {
  4526. this.event = a, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4527. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4528. },
  4529. stop: function() {
  4530. 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))
  4531. }
  4532. }, c.Touch.prototype.constructor = c.Touch, Object.defineProperty(c.Touch.prototype, "disabled", {
  4533. get: function() {
  4534. return !this.enabled
  4535. },
  4536. set: function(a) {
  4537. this.enabled = !a
  4538. }
  4539. }), c.InputHandler = function(a) {
  4540. 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.scaleLayer = !1, this.dragOffset = new c.Point, this.dragFromCenter = !1, this.dragStartPoint = new c.Point, this._dragPoint = new c.Point, this._dragPhase = !1, this._wasEnabled = !1, this._tempPoint = new c.Point, this._pointerData = [], this._pointerData.push({
  4541. id: 0,
  4542. x: 0,
  4543. y: 0,
  4544. isDown: !1,
  4545. isUp: !1,
  4546. isOver: !1,
  4547. isOut: !1,
  4548. timeOver: 0,
  4549. timeOut: 0,
  4550. timeDown: 0,
  4551. timeUp: 0,
  4552. downDuration: 0,
  4553. isDragged: !1
  4554. })
  4555. }, c.InputHandler.prototype = {
  4556. start: function(a, b) {
  4557. if (a = a || 0, "undefined" == typeof b && (b = !1), this.enabled === !1) {
  4558. this.game.input.interactiveItems.add(this), this.useHandCursor = b, this.priorityID = a;
  4559. for (var d = 0; 10 > d; d++) this._pointerData[d] = {
  4560. id: d,
  4561. x: 0,
  4562. y: 0,
  4563. isDown: !1,
  4564. isUp: !1,
  4565. isOver: !1,
  4566. isOut: !1,
  4567. timeOver: 0,
  4568. timeOut: 0,
  4569. timeDown: 0,
  4570. timeUp: 0,
  4571. downDuration: 0,
  4572. isDragged: !1
  4573. };
  4574. this.snapOffset = new c.Point, this.enabled = !0, this._wasEnabled = !0
  4575. }
  4576. return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.flagged = !1, this.sprite
  4577. },
  4578. addedToGroup: function() {
  4579. this._dragPhase || this._wasEnabled && !this.enabled && this.start()
  4580. },
  4581. removedFromGroup: function() {
  4582. this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1)
  4583. },
  4584. reset: function() {
  4585. this.enabled = !1, this.flagged = !1;
  4586. for (var a = 0; 10 > a; a++) this._pointerData[a] = {
  4587. id: a,
  4588. x: 0,
  4589. y: 0,
  4590. isDown: !1,
  4591. isUp: !1,
  4592. isOver: !1,
  4593. isOut: !1,
  4594. timeOver: 0,
  4595. timeOut: 0,
  4596. timeDown: 0,
  4597. timeUp: 0,
  4598. downDuration: 0,
  4599. isDragged: !1
  4600. }
  4601. },
  4602. stop: function() {
  4603. this.enabled !== !1 && (this.enabled = !1, this.game.input.interactiveItems.remove(this))
  4604. },
  4605. destroy: function() {
  4606. 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)
  4607. },
  4608. validForInput: function(a, b, c) {
  4609. 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.renderOrderID < b) ? !0 : !1
  4610. },
  4611. isPixelPerfect: function() {
  4612. return this.pixelPerfectClick || this.pixelPerfectOver
  4613. },
  4614. pointerX: function(a) {
  4615. return a = a || 0, this._pointerData[a].x
  4616. },
  4617. pointerY: function(a) {
  4618. return a = a || 0, this._pointerData[a].y
  4619. },
  4620. pointerDown: function(a) {
  4621. return a = a || 0, this._pointerData[a].isDown
  4622. },
  4623. pointerUp: function(a) {
  4624. return a = a || 0, this._pointerData[a].isUp
  4625. },
  4626. pointerTimeDown: function(a) {
  4627. return a = a || 0, this._pointerData[a].timeDown
  4628. },
  4629. pointerTimeUp: function(a) {
  4630. return a = a || 0, this._pointerData[a].timeUp
  4631. },
  4632. pointerOver: function(a) {
  4633. if (this.enabled) {
  4634. if ("undefined" != typeof a) return this._pointerData[a].isOver;
  4635. for (var b = 0; 10 > b; b++)
  4636. if (this._pointerData[b].isOver) return !0
  4637. }
  4638. return !1
  4639. },
  4640. pointerOut: function(a) {
  4641. if (this.enabled) {
  4642. if ("undefined" != typeof a) return this._pointerData[a].isOut;
  4643. for (var b = 0; 10 > b; b++)
  4644. if (this._pointerData[b].isOut) return !0
  4645. }
  4646. return !1
  4647. },
  4648. pointerTimeOver: function(a) {
  4649. return a = a || 0, this._pointerData[a].timeOver
  4650. },
  4651. pointerTimeOut: function(a) {
  4652. return a = a || 0, this._pointerData[a].timeOut
  4653. },
  4654. pointerDragged: function(a) {
  4655. return a = a || 0, this._pointerData[a].isDragged
  4656. },
  4657. checkPointerDown: function(a, b) {
  4658. 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
  4659. },
  4660. checkPointerOver: function(a, b) {
  4661. 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
  4662. },
  4663. checkPixel: function(a, b, c) {
  4664. if (this.sprite.texture.baseTexture.source) {
  4665. if (null === a && null === b) {
  4666. this.game.input.getLocalPosition(this.sprite, c, this._tempPoint);
  4667. var a = this._tempPoint.x,
  4668. b = this._tempPoint.y
  4669. }
  4670. if (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.sprite.texture.trim && (a -= this.sprite.texture.trim.x, b -= this.sprite.texture.trim.y, a < this.sprite.texture.crop.x || a > this.sprite.texture.crop.right || b < this.sprite.texture.crop.y || b > this.sprite.texture.crop.bottom)) return this._dx = a, this._dy = b, !1;
  4671. this._dx = a, this._dy = b, this.game.input.hitContext.clearRect(0, 0, 1, 1), this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, a, b, 1, 1, 0, 0, 1, 1);
  4672. var d = this.game.input.hitContext.getImageData(0, 0, 1, 1);
  4673. if (d.data[3] >= this.pixelPerfectAlpha) return !0
  4674. }
  4675. return !1
  4676. },
  4677. update: function(a) {
  4678. 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 ? 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
  4679. },
  4680. _pointerOverHandler: function(a) {
  4681. null !== this.sprite && (this._pointerData[a.id].isOver === !1 || a.dirty) && (this._pointerData[a.id].isOver = !0, this._pointerData[a.id].isOut = !1, this._pointerData[a.id].timeOver = this.game.time.time, 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))
  4682. },
  4683. _pointerOutHandler: function(a) {
  4684. null !== this.sprite && (this._pointerData[a.id].isOver = !1, this._pointerData[a.id].isOut = !0, this._pointerData[a.id].timeOut = this.game.time.time, 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))
  4685. },
  4686. _touchedHandler: function(a) {
  4687. if (null !== this.sprite) {
  4688. if (this._pointerData[a.id].isDown === !1 && this._pointerData[a.id].isOver === !0) {
  4689. if (this.pixelPerfectClick && !this.checkPixel(null, null, a)) return;
  4690. this._pointerData[a.id].isDown = !0, this._pointerData[a.id].isUp = !1, this._pointerData[a.id].timeDown = this.game.time.time, this.sprite && this.sprite.events && this.sprite.events.onInputDown$dispatch(this.sprite, a), a.dirty = !0, this.draggable && this.isDragged === !1 && this.startDrag(a), this.bringToTop && this.sprite.bringToTop()
  4691. }
  4692. return this.consumePointerEvent
  4693. }
  4694. },
  4695. _releasedHandler: function(a) {
  4696. 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.time, 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)), a.dirty = !0, this.draggable && this.isDragged && this._draggedPointerID === a.id && this.stopDrag(a))
  4697. },
  4698. updateDrag: function(a) {
  4699. if (a.isUp) return this.stopDrag(a), !1;
  4700. var b = this.globalToLocalX(a.x) + this._dragPoint.x + this.dragOffset.x,
  4701. c = this.globalToLocalY(a.y) + this._dragPoint.y + this.dragOffset.y;
  4702. return this.sprite.fixedToCamera ? (this.allowHorizontalDrag && (this.sprite.cameraOffset.x = b), this.allowVerticalDrag && (this.sprite.cameraOffset.y = c), 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 = b), this.allowVerticalDrag && (this.sprite.y = c), 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
  4703. },
  4704. justOver: function(a, b) {
  4705. return a = a || 0, b = b || 500, this._pointerData[a].isOver && this.overDuration(a) < b
  4706. },
  4707. justOut: function(a, b) {
  4708. return a = a || 0, b = b || 500, this._pointerData[a].isOut && this.game.time.time - this._pointerData[a].timeOut < b
  4709. },
  4710. justPressed: function(a, b) {
  4711. return a = a || 0, b = b || 500, this._pointerData[a].isDown && this.downDuration(a) < b
  4712. },
  4713. justReleased: function(a, b) {
  4714. return a = a || 0, b = b || 500, this._pointerData[a].isUp && this.game.time.time - this._pointerData[a].timeUp < b
  4715. },
  4716. overDuration: function(a) {
  4717. return a = a || 0, this._pointerData[a].isOver ? this.game.time.time - this._pointerData[a].timeOver : -1
  4718. },
  4719. downDuration: function(a) {
  4720. return a = a || 0, this._pointerData[a].isDown ? this.game.time.time - this._pointerData[a].timeDown : -1
  4721. },
  4722. enableDrag: function(a, b, d, e, f, g) {
  4723. "undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = null), "undefined" == typeof g && (g = null), this._dragPoint = new c.Point, this.draggable = !0, this.bringToTop = b, this.dragOffset = new c.Point, this.dragFromCenter = a, this.pixelPerfectClick = d, this.pixelPerfectAlpha = e, f && (this.boundsRect = f), g && (this.boundsSprite = g)
  4724. },
  4725. disableDrag: function() {
  4726. if (this._pointerData)
  4727. for (var a = 0; 10 > a; a++) this._pointerData[a].isDragged = !1;
  4728. this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1
  4729. },
  4730. startDrag: function(a) {
  4731. var b = this.sprite.x,
  4732. c = this.sprite.y;
  4733. 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);
  4734. else {
  4735. if (this.dragFromCenter) {
  4736. var d = this.sprite.getBounds();
  4737. this.sprite.x = this.globalToLocalX(a.x) + (this.sprite.x - d.centerX), this.sprite.y = this.globalToLocalY(a.y) + (this.sprite.y - d.centerY)
  4738. }
  4739. this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(a.x), this.sprite.y - this.globalToLocalY(a.y))
  4740. }
  4741. this.updateDrag(a), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.dragStartPoint.set(b, c), this.sprite.events.onDragStart$dispatch(this.sprite, a, b, c)
  4742. },
  4743. globalToLocalX: function(a) {
  4744. return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.x, a *= this.game.scale.grid.scaleFluidInversed.x), a
  4745. },
  4746. globalToLocalY: function(a) {
  4747. return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.y, a *= this.game.scale.grid.scaleFluidInversed.y), a
  4748. },
  4749. stopDrag: function(a) {
  4750. 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)
  4751. },
  4752. setDragLock: function(a, b) {
  4753. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), this.allowHorizontalDrag = a, this.allowVerticalDrag = b
  4754. },
  4755. enableSnap: function(a, b, c, d, e, f) {
  4756. "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
  4757. },
  4758. disableSnap: function() {
  4759. this.snapOnDrag = !1, this.snapOnRelease = !1
  4760. },
  4761. checkBoundsRect: function() {
  4762. this.sprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsRect.left ? this.sprite.cameraOffset.x = this.boundsRect.left : 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.left < this.boundsRect.left ? this.sprite.x = this.boundsRect.x + this.sprite.offsetX : this.sprite.right > this.boundsRect.right && (this.sprite.x = this.boundsRect.right - (this.sprite.width - this.sprite.offsetX)), this.sprite.top < this.boundsRect.top ? this.sprite.y = this.boundsRect.top + this.sprite.offsetY : this.sprite.bottom > this.boundsRect.bottom && (this.sprite.y = this.boundsRect.bottom - (this.sprite.height - this.sprite.offsetY)))
  4763. },
  4764. checkBoundsSprite: function() {
  4765. this.sprite.fixedToCamera && this.boundsSprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsSprite.cameraOffset.x ? this.sprite.cameraOffset.x = this.boundsSprite.cameraOffset.x : this.sprite.cameraOffset.x + this.sprite.width > this.boundsSprite.cameraOffset.x + this.boundsSprite.width && (this.sprite.cameraOffset.x = this.boundsSprite.cameraOffset.x + this.boundsSprite.width - this.sprite.width), this.sprite.cameraOffset.y < this.boundsSprite.cameraOffset.y ? this.sprite.cameraOffset.y = this.boundsSprite.cameraOffset.y : this.sprite.cameraOffset.y + this.sprite.height > this.boundsSprite.cameraOffset.y + this.boundsSprite.height && (this.sprite.cameraOffset.y = this.boundsSprite.cameraOffset.y + this.boundsSprite.height - this.sprite.height)) : (this.sprite.left < this.boundsSprite.left ? this.sprite.x = this.boundsSprite.left + this.sprite.offsetX : this.sprite.right > this.boundsSprite.right && (this.sprite.x = this.boundsSprite.right - (this.sprite.width - this.sprite.offsetX)), this.sprite.top < this.boundsSprite.top ? this.sprite.y = this.boundsSprite.top + this.sprite.offsetY : this.sprite.bottom > this.boundsSprite.bottom && (this.sprite.y = this.boundsSprite.bottom - (this.sprite.height - this.sprite.offsetY)))
  4766. }
  4767. }, c.InputHandler.prototype.constructor = c.InputHandler, c.Gamepad = function(a) {
  4768. this.game = a, this._gamepadIndexMap = {}, this._rawPads = [], this._active = !1, this.enabled = !0, 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, this._gamepads = [new c.SinglePad(a, this), new c.SinglePad(a, this), new c.SinglePad(a, this), new c.SinglePad(a, this)]
  4769. }, c.Gamepad.prototype = {
  4770. addCallbacks: function(a, b) {
  4771. "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, this.callbackContext = a)
  4772. },
  4773. start: function() {
  4774. if (!this._active) {
  4775. this._active = !0;
  4776. var a = this;
  4777. this._onGamepadConnected = function(b) {
  4778. return a.onGamepadConnected(b)
  4779. }, this._onGamepadDisconnected = function(b) {
  4780. return a.onGamepadDisconnected(b)
  4781. }, window.addEventListener("gamepadconnected", this._onGamepadConnected, !1), window.addEventListener("gamepaddisconnected", this._onGamepadDisconnected, !1)
  4782. }
  4783. },
  4784. onGamepadConnected: function(a) {
  4785. var b = a.gamepad;
  4786. this._rawPads.push(b), this._gamepads[b.index].connect(b)
  4787. },
  4788. onGamepadDisconnected: function(a) {
  4789. var b = a.gamepad;
  4790. for (var c in this._rawPads) this._rawPads[c].index === b.index && this._rawPads.splice(c, 1);
  4791. this._gamepads[b.index].disconnect()
  4792. },
  4793. update: function() {
  4794. this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus()
  4795. },
  4796. _pollGamepads: function() {
  4797. if (navigator.getGamepads) var a = navigator.getGamepads();
  4798. else if (navigator.webkitGetGamepads) var a = navigator.webkitGetGamepads();
  4799. else if (navigator.webkitGamepads) var a = navigator.webkitGamepads();
  4800. if (a) {
  4801. this._rawPads = [];
  4802. 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++);
  4803. if (b) {
  4804. for (var d, e = {
  4805. rawIndices: {},
  4806. padIndices: {}
  4807. }, f = 0; f < this._gamepads.length; f++)
  4808. if (d = this._gamepads[f], d.connected)
  4809. for (var g = 0; g < this._rawPads.length; g++) this._rawPads[g].index === d.index && (e.rawIndices[d.index] = !0, e.padIndices[f] = !0);
  4810. for (var h = 0; h < this._gamepads.length; h++)
  4811. if (d = this._gamepads[h], !e.padIndices[h]) {
  4812. this._rawPads.length < 1 && d.disconnect();
  4813. for (var i = 0; i < this._rawPads.length && !e.padIndices[h]; i++) {
  4814. var j = this._rawPads[i];
  4815. if (j) {
  4816. if (e.rawIndices[j.index]) {
  4817. d.disconnect();
  4818. continue
  4819. }
  4820. d.connect(j), e.rawIndices[j.index] = !0, e.padIndices[h] = !0
  4821. } else d.disconnect()
  4822. }
  4823. }
  4824. }
  4825. }
  4826. },
  4827. setDeadZones: function(a) {
  4828. for (var b = 0; b < this._gamepads.length; b++) this._gamepads[b].deadZone = a
  4829. },
  4830. stop: function() {
  4831. this._active = !1, window.removeEventListener("gamepadconnected", this._onGamepadConnected), window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnected)
  4832. },
  4833. reset: function() {
  4834. this.update();
  4835. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].reset()
  4836. },
  4837. justPressed: function(a, b) {
  4838. for (var c = 0; c < this._gamepads.length; c++)
  4839. if (this._gamepads[c].justPressed(a, b) === !0) return !0;
  4840. return !1
  4841. },
  4842. justReleased: function(a, b) {
  4843. for (var c = 0; c < this._gamepads.length; c++)
  4844. if (this._gamepads[c].justReleased(a, b) === !0) return !0;
  4845. return !1
  4846. },
  4847. isDown: function(a) {
  4848. for (var b = 0; b < this._gamepads.length; b++)
  4849. if (this._gamepads[b].isDown(a) === !0) return !0;
  4850. return !1
  4851. },
  4852. destroy: function() {
  4853. this.stop();
  4854. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].destroy()
  4855. }
  4856. }, c.Gamepad.prototype.constructor = c.Gamepad, Object.defineProperty(c.Gamepad.prototype, "disabled", {
  4857. get: function() {
  4858. return !this.enabled
  4859. },
  4860. set: function(a) {
  4861. this.enabled = !a
  4862. }
  4863. }), Object.defineProperty(c.Gamepad.prototype, "active", {
  4864. get: function() {
  4865. return this._active
  4866. }
  4867. }), Object.defineProperty(c.Gamepad.prototype, "supported", {
  4868. get: function() {
  4869. return this._gamepadSupportAvailable
  4870. }
  4871. }), Object.defineProperty(c.Gamepad.prototype, "padsConnected", {
  4872. get: function() {
  4873. return this._rawPads.length
  4874. }
  4875. }), Object.defineProperty(c.Gamepad.prototype, "pad1", {
  4876. get: function() {
  4877. return this._gamepads[0]
  4878. }
  4879. }), Object.defineProperty(c.Gamepad.prototype, "pad2", {
  4880. get: function() {
  4881. return this._gamepads[1]
  4882. }
  4883. }), Object.defineProperty(c.Gamepad.prototype, "pad3", {
  4884. get: function() {
  4885. return this._gamepads[2]
  4886. }
  4887. }), Object.defineProperty(c.Gamepad.prototype, "pad4", {
  4888. get: function() {
  4889. return this._gamepads[3]
  4890. }
  4891. }), c.Gamepad.BUTTON_0 = 0, c.Gamepad.BUTTON_1 = 1, c.Gamepad.BUTTON_2 = 2, c.Gamepad.BUTTON_3 = 3, c.Gamepad.BUTTON_4 = 4, c.Gamepad.BUTTON_5 = 5, c.Gamepad.BUTTON_6 = 6, c.Gamepad.BUTTON_7 = 7, c.Gamepad.BUTTON_8 = 8, c.Gamepad.BUTTON_9 = 9, c.Gamepad.BUTTON_10 = 10, c.Gamepad.BUTTON_11 = 11, c.Gamepad.BUTTON_12 = 12, c.Gamepad.BUTTON_13 = 13, c.Gamepad.BUTTON_14 = 14, c.Gamepad.BUTTON_15 = 15, c.Gamepad.AXIS_0 = 0, c.Gamepad.AXIS_1 = 1, c.Gamepad.AXIS_2 = 2, c.Gamepad.AXIS_3 = 3, c.Gamepad.AXIS_4 = 4, c.Gamepad.AXIS_5 = 5, c.Gamepad.AXIS_6 = 6, c.Gamepad.AXIS_7 = 7, c.Gamepad.AXIS_8 = 8, c.Gamepad.AXIS_9 = 9, c.Gamepad.XBOX360_A = 0, c.Gamepad.XBOX360_B = 1, c.Gamepad.XBOX360_X = 2, c.Gamepad.XBOX360_Y = 3, c.Gamepad.XBOX360_LEFT_BUMPER = 4, c.Gamepad.XBOX360_RIGHT_BUMPER = 5, c.Gamepad.XBOX360_LEFT_TRIGGER = 6, c.Gamepad.XBOX360_RIGHT_TRIGGER = 7, c.Gamepad.XBOX360_BACK = 8, c.Gamepad.XBOX360_START = 9, c.Gamepad.XBOX360_STICK_LEFT_BUTTON = 10, c.Gamepad.XBOX360_STICK_RIGHT_BUTTON = 11, c.Gamepad.XBOX360_DPAD_LEFT = 14, c.Gamepad.XBOX360_DPAD_RIGHT = 15, c.Gamepad.XBOX360_DPAD_UP = 12, c.Gamepad.XBOX360_DPAD_DOWN = 13, c.Gamepad.XBOX360_STICK_LEFT_X = 0, c.Gamepad.XBOX360_STICK_LEFT_Y = 1, c.Gamepad.XBOX360_STICK_RIGHT_X = 2, c.Gamepad.XBOX360_STICK_RIGHT_Y = 3, c.Gamepad.PS3XC_X = 0, c.Gamepad.PS3XC_CIRCLE = 1, c.Gamepad.PS3XC_SQUARE = 2, c.Gamepad.PS3XC_TRIANGLE = 3, c.Gamepad.PS3XC_L1 = 4, c.Gamepad.PS3XC_R1 = 5, c.Gamepad.PS3XC_L2 = 6, c.Gamepad.PS3XC_R2 = 7, c.Gamepad.PS3XC_SELECT = 8, c.Gamepad.PS3XC_START = 9, c.Gamepad.PS3XC_STICK_LEFT_BUTTON = 10, c.Gamepad.PS3XC_STICK_RIGHT_BUTTON = 11, c.Gamepad.PS3XC_DPAD_UP = 12, c.Gamepad.PS3XC_DPAD_DOWN = 13, c.Gamepad.PS3XC_DPAD_LEFT = 14, c.Gamepad.PS3XC_DPAD_RIGHT = 15, c.Gamepad.PS3XC_STICK_LEFT_X = 0, c.Gamepad.PS3XC_STICK_LEFT_Y = 1, c.Gamepad.PS3XC_STICK_RIGHT_X = 2, c.Gamepad.PS3XC_STICK_RIGHT_Y = 3, c.SinglePad = function(a, b) {
  4892. 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
  4893. }, c.SinglePad.prototype = {
  4894. addCallbacks: function(a, b) {
  4895. "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)
  4896. },
  4897. getButton: function(a) {
  4898. return this._buttons[a] ? this._buttons[a] : null
  4899. },
  4900. pollStatus: function() {
  4901. if (this.connected && this.game.input.enabled && this.game.input.gamepad.enabled && (!this._rawPad.timestamp || this._rawPad.timestamp !== this._prevTimestamp)) {
  4902. for (var a = 0; a < this._buttonsLen; a++) {
  4903. var b = isNaN(this._rawPad.buttons[a]) ? this._rawPad.buttons[a].value : this._rawPad.buttons[a];
  4904. b !== this._buttons[a].value && (1 === b ? this.processButtonDown(a, b) : 0 === b ? this.processButtonUp(a, b) : this.processButtonFloat(a, b))
  4905. }
  4906. for (var c = 0; c < this._axesLen; c++) {
  4907. var d = this._rawPad.axes[c];
  4908. d > 0 && d > this.deadZone || 0 > d && d < -this.deadZone ? this.processAxisChange(c, d) : this.processAxisChange(c, 0)
  4909. }
  4910. this._prevTimestamp = this._rawPad.timestamp
  4911. }
  4912. },
  4913. connect: function(a) {
  4914. var b = !this.connected;
  4915. this.connected = !0, this.index = a.index, this._rawPad = a, this._buttons = [], this._buttonsLen = a.buttons.length, this._axes = [], this._axesLen = a.axes.length;
  4916. for (var d = 0; d < this._axesLen; d++) this._axes[d] = a.axes[d];
  4917. for (var e in a.buttons) e = parseInt(e, 10), this._buttons[e] = new c.GamepadButton(this, e);
  4918. b && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), b && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
  4919. },
  4920. disconnect: function() {
  4921. var a = this.connected,
  4922. b = this.index;
  4923. this.connected = !1, this.index = null, this._rawPad = void 0;
  4924. for (var c = 0; c < this._buttonsLen; c++) this._buttons[c].destroy();
  4925. 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)
  4926. },
  4927. destroy: function() {
  4928. this._rawPad = void 0;
  4929. for (var a = 0; a < this._buttonsLen; a++) this._buttons[a].destroy();
  4930. this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0, this.onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null
  4931. },
  4932. processAxisChange: function(a, b) {
  4933. this._axes[a] !== b && (this._axes[a] = b, this._padParent.onAxisCallback && this._padParent.onAxisCallback.call(this._padParent.callbackContext, this, a, b), this.onAxisCallback && this.onAxisCallback.call(this.callbackContext, this, a, b))
  4934. },
  4935. processButtonDown: function(a, b) {
  4936. 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)
  4937. },
  4938. processButtonUp: function(a, b) {
  4939. 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)
  4940. },
  4941. processButtonFloat: function(a, b) {
  4942. 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)
  4943. },
  4944. axis: function(a) {
  4945. return this._axes[a] ? this._axes[a] : !1
  4946. },
  4947. isDown: function(a) {
  4948. return this._buttons[a] ? this._buttons[a].isDown : !1
  4949. },
  4950. isUp: function(a) {
  4951. return this._buttons[a] ? this._buttons[a].isUp : !1
  4952. },
  4953. justReleased: function(a, b) {
  4954. return this._buttons[a] ? this._buttons[a].justReleased(b) : void 0
  4955. },
  4956. justPressed: function(a, b) {
  4957. return this._buttons[a] ? this._buttons[a].justPressed(b) : void 0
  4958. },
  4959. buttonValue: function(a) {
  4960. return this._buttons[a] ? this._buttons[a].value : null
  4961. },
  4962. reset: function() {
  4963. for (var a = 0; a < this._axes.length; a++) this._axes[a] = 0
  4964. }
  4965. }, c.SinglePad.prototype.constructor = c.SinglePad, c.GamepadButton = function(a, b) {
  4966. 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 = b, this.onDown = new c.Signal, this.onUp = new c.Signal, this.onFloat = new c.Signal
  4967. }, c.GamepadButton.prototype = {
  4968. processButtonDown: function(a) {
  4969. this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.time, this.duration = 0, this.repeats = 0, this.value = a, this.onDown.dispatch(this, a)
  4970. },
  4971. processButtonUp: function(a) {
  4972. this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.value = a, this.onUp.dispatch(this, a)
  4973. },
  4974. processButtonFloat: function(a) {
  4975. this.value = a, this.onFloat.dispatch(this, a)
  4976. },
  4977. justPressed: function(a) {
  4978. return a = a || 250, this.isDown === !0 && this.timeDown + a > this.game.time.time
  4979. },
  4980. justReleased: function(a) {
  4981. return a = a || 250, this.isUp === !0 && this.timeUp + a > this.game.time.time
  4982. },
  4983. reset: function() {
  4984. this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.time, this.duration = 0, this.repeats = 0
  4985. },
  4986. destroy: function() {
  4987. this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.pad = null, this.game = null
  4988. }
  4989. }, c.GamepadButton.prototype.constructor = c.GamepadButton, c.Key = function(a, b) {
  4990. 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 = b, this.onDown = new c.Signal, this.onHoldCallback = null, this.onHoldContext = null, this.onUp = new c.Signal, this._justDown = !1, this._justUp = !1
  4991. }, c.Key.prototype = {
  4992. update: function() {
  4993. this._enabled && this.isDown && (this.duration = this.game.time.time - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this))
  4994. },
  4995. processKeyDown: function(a) {
  4996. 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.time, this.duration = 0, this.repeats = 0, this._justDown = !0, this.onDown.dispatch(this)))
  4997. },
  4998. processKeyUp: function(a) {
  4999. this._enabled && (this.event = a, this.isUp || (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.duration = this.game.time.time - this.timeDown, this._justUp = !0, this.onUp.dispatch(this)))
  5000. },
  5001. reset: function(a) {
  5002. "undefined" == typeof a && (a = !0), this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.duration = 0, this._enabled = !0, this._justDown = !1, this._justUp = !1, a && (this.onDown.removeAll(), this.onUp.removeAll(), this.onHoldCallback = null, this.onHoldContext = null)
  5003. },
  5004. downDuration: function(a) {
  5005. return "undefined" == typeof a && (a = 50), this.isDown && this.duration < a
  5006. },
  5007. upDuration: function(a) {
  5008. return "undefined" == typeof a && (a = 50), !this.isDown && this.game.time.time - this.timeUp < a
  5009. }
  5010. }, Object.defineProperty(c.Key.prototype, "justDown", {
  5011. get: function() {
  5012. var a = this._justDown;
  5013. return this._justDown = !1, a
  5014. }
  5015. }), Object.defineProperty(c.Key.prototype, "justUp", {
  5016. get: function() {
  5017. var a = this._justUp;
  5018. return this._justUp = !1, a
  5019. }
  5020. }), Object.defineProperty(c.Key.prototype, "enabled", {
  5021. get: function() {
  5022. return this._enabled
  5023. },
  5024. set: function(a) {
  5025. a = !!a, a !== this._enabled && (a || this.reset(!1), this._enabled = a)
  5026. }
  5027. }), c.Key.prototype.constructor = c.Key, c.Keyboard = function(a) {
  5028. this.game = a, this.enabled = !0, 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
  5029. }, c.Keyboard.prototype = {
  5030. addCallbacks: function(a, b, c, d) {
  5031. this.callbackContext = a, "undefined" != typeof b && (this.onDownCallback = b), "undefined" != typeof c && (this.onUpCallback = c), "undefined" != typeof d && (this.onPressCallback = d)
  5032. },
  5033. addKey: function(a) {
  5034. return this._keys[a] || (this._keys[a] = new c.Key(this.game, a), this.addKeyCapture(a)), this._keys[a]
  5035. },
  5036. removeKey: function(a) {
  5037. this._keys[a] && (this._keys[a] = null, this.removeKeyCapture(a))
  5038. },
  5039. createCursorKeys: function() {
  5040. return {
  5041. up: this.addKey(c.Keyboard.UP),
  5042. down: this.addKey(c.Keyboard.DOWN),
  5043. left: this.addKey(c.Keyboard.LEFT),
  5044. right: this.addKey(c.Keyboard.RIGHT)
  5045. }
  5046. },
  5047. start: function() {
  5048. if (!this.game.device.cocoonJS && null === this._onKeyDown) {
  5049. var a = this;
  5050. this._onKeyDown = function(b) {
  5051. return a.processKeyDown(b)
  5052. }, this._onKeyUp = function(b) {
  5053. return a.processKeyUp(b)
  5054. }, this._onKeyPress = function(b) {
  5055. return a.processKeyPress(b)
  5056. }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
  5057. }
  5058. },
  5059. stop: function() {
  5060. window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null
  5061. },
  5062. destroy: function() {
  5063. this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0
  5064. },
  5065. addKeyCapture: function(a) {
  5066. if ("object" == typeof a)
  5067. for (var b in a) this._capture[a[b]] = !0;
  5068. else this._capture[a] = !0
  5069. },
  5070. removeKeyCapture: function(a) {
  5071. delete this._capture[a]
  5072. },
  5073. clearCaptures: function() {
  5074. this._capture = {}
  5075. },
  5076. update: function() {
  5077. for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update()
  5078. },
  5079. processKeyDown: function(a) {
  5080. this.event = a, this.game.input.enabled && this.enabled && (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new c.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyDown(a), this._k = a.keyCode, this.onDownCallback && this.onDownCallback.call(this.callbackContext, a))
  5081. },
  5082. processKeyPress: function(a) {
  5083. this.pressEvent = a, this.game.input.enabled && this.enabled && this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(a.charCode), a)
  5084. },
  5085. processKeyUp: function(a) {
  5086. this.event = a, this.game.input.enabled && this.enabled && (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new c.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyUp(a), this.onUpCallback && this.onUpCallback.call(this.callbackContext, a))
  5087. },
  5088. reset: function(a) {
  5089. "undefined" == typeof a && (a = !0), this.event = null;
  5090. for (var b = this._keys.length; b--;) this._keys[b] && this._keys[b].reset(a)
  5091. },
  5092. downDuration: function(a, b) {
  5093. return this._keys[a] ? this._keys[a].downDuration(b) : null
  5094. },
  5095. upDuration: function(a, b) {
  5096. return this._keys[a] ? this._keys[a].upDuration(b) : null
  5097. },
  5098. isDown: function(a) {
  5099. return this._keys[a] ? this._keys[a].isDown : null
  5100. }
  5101. }, Object.defineProperty(c.Keyboard.prototype, "disabled", {
  5102. get: function() {
  5103. return !this.enabled
  5104. },
  5105. set: function(a) {
  5106. this.enabled = !a
  5107. }
  5108. }), Object.defineProperty(c.Keyboard.prototype, "lastChar", {
  5109. get: function() {
  5110. return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode)
  5111. }
  5112. }), Object.defineProperty(c.Keyboard.prototype, "lastKey", {
  5113. get: function() {
  5114. return this._keys[this._k]
  5115. }
  5116. }), c.Keyboard.prototype.constructor = c.Keyboard, c.Keyboard.A = "A".charCodeAt(0), c.Keyboard.B = "B".charCodeAt(0), c.Keyboard.C = "C".charCodeAt(0), c.Keyboard.D = "D".charCodeAt(0), c.Keyboard.E = "E".charCodeAt(0), c.Keyboard.F = "F".charCodeAt(0), c.Keyboard.G = "G".charCodeAt(0), c.Keyboard.H = "H".charCodeAt(0), c.Keyboard.I = "I".charCodeAt(0), c.Keyboard.J = "J".charCodeAt(0), c.Keyboard.K = "K".charCodeAt(0), c.Keyboard.L = "L".charCodeAt(0), c.Keyboard.M = "M".charCodeAt(0), c.Keyboard.N = "N".charCodeAt(0), c.Keyboard.O = "O".charCodeAt(0), c.Keyboard.P = "P".charCodeAt(0), c.Keyboard.Q = "Q".charCodeAt(0), c.Keyboard.R = "R".charCodeAt(0), c.Keyboard.S = "S".charCodeAt(0), c.Keyboard.T = "T".charCodeAt(0), c.Keyboard.U = "U".charCodeAt(0), c.Keyboard.V = "V".charCodeAt(0), c.Keyboard.W = "W".charCodeAt(0), c.Keyboard.X = "X".charCodeAt(0), c.Keyboard.Y = "Y".charCodeAt(0), c.Keyboard.Z = "Z".charCodeAt(0), c.Keyboard.ZERO = "0".charCodeAt(0), c.Keyboard.ONE = "1".charCodeAt(0), c.Keyboard.TWO = "2".charCodeAt(0), c.Keyboard.THREE = "3".charCodeAt(0), c.Keyboard.FOUR = "4".charCodeAt(0), c.Keyboard.FIVE = "5".charCodeAt(0), c.Keyboard.SIX = "6".charCodeAt(0), c.Keyboard.SEVEN = "7".charCodeAt(0), c.Keyboard.EIGHT = "8".charCodeAt(0), c.Keyboard.NINE = "9".charCodeAt(0), c.Keyboard.NUMPAD_0 = 96, c.Keyboard.NUMPAD_1 = 97, c.Keyboard.NUMPAD_2 = 98, c.Keyboard.NUMPAD_3 = 99, c.Keyboard.NUMPAD_4 = 100, c.Keyboard.NUMPAD_5 = 101, c.Keyboard.NUMPAD_6 = 102, c.Keyboard.NUMPAD_7 = 103, c.Keyboard.NUMPAD_8 = 104, c.Keyboard.NUMPAD_9 = 105, c.Keyboard.NUMPAD_MULTIPLY = 106, c.Keyboard.NUMPAD_ADD = 107, c.Keyboard.NUMPAD_ENTER = 108, c.Keyboard.NUMPAD_SUBTRACT = 109, c.Keyboard.NUMPAD_DECIMAL = 110, c.Keyboard.NUMPAD_DIVIDE = 111, c.Keyboard.F1 = 112, c.Keyboard.F2 = 113, c.Keyboard.F3 = 114, c.Keyboard.F4 = 115, c.Keyboard.F5 = 116, c.Keyboard.F6 = 117, c.Keyboard.F7 = 118, c.Keyboard.F8 = 119, c.Keyboard.F9 = 120, c.Keyboard.F10 = 121, c.Keyboard.F11 = 122, c.Keyboard.F12 = 123, c.Keyboard.F13 = 124, c.Keyboard.F14 = 125, c.Keyboard.F15 = 126, c.Keyboard.COLON = 186, c.Keyboard.EQUALS = 187, c.Keyboard.UNDERSCORE = 189, c.Keyboard.QUESTION_MARK = 191, c.Keyboard.TILDE = 192, c.Keyboard.OPEN_BRACKET = 219, c.Keyboard.BACKWARD_SLASH = 220, c.Keyboard.CLOSED_BRACKET = 221, c.Keyboard.QUOTES = 222, c.Keyboard.BACKSPACE = 8, c.Keyboard.TAB = 9, c.Keyboard.CLEAR = 12, c.Keyboard.ENTER = 13, c.Keyboard.SHIFT = 16, c.Keyboard.CONTROL = 17, c.Keyboard.ALT = 18, c.Keyboard.CAPS_LOCK = 20, c.Keyboard.ESC = 27, c.Keyboard.SPACEBAR = 32, c.Keyboard.PAGE_UP = 33, c.Keyboard.PAGE_DOWN = 34, c.Keyboard.END = 35, c.Keyboard.HOME = 36, c.Keyboard.LEFT = 37, c.Keyboard.UP = 38, c.Keyboard.RIGHT = 39, c.Keyboard.DOWN = 40, c.Keyboard.INSERT = 45, c.Keyboard.DELETE = 46, c.Keyboard.HELP = 47, c.Keyboard.NUM_LOCK = 144, c.Keyboard.PLUS = 43, c.Keyboard.MINUS = 45, c.Component = function() {}, c.Component.Angle = function() {}, c.Component.Angle.prototype = {
  5117. angle: {
  5118. get: function() {
  5119. return c.Math.wrapAngle(c.Math.radToDeg(this.rotation))
  5120. },
  5121. set: function(a) {
  5122. this.rotation = c.Math.degToRad(c.Math.wrapAngle(a))
  5123. }
  5124. }
  5125. }, c.Component.Animation = function() {}, c.Component.Animation.prototype = {
  5126. play: function(a, b, c, d) {
  5127. return this.animations ? this.animations.play(a, b, c, d) : void 0
  5128. }
  5129. }, c.Component.AutoCull = function() {}, c.Component.AutoCull.prototype = {
  5130. autoCull: !1,
  5131. inCamera: {
  5132. get: function() {
  5133. return this.autoCull || this.checkWorldBounds || (this._bounds.copyFrom(this.getBounds()), this._bounds.x += this.game.camera.view.x, this._bounds.y += this.game.camera.view.y), this.game.world.camera.view.intersects(this._bounds)
  5134. }
  5135. }
  5136. }, c.Component.Bounds = function() {}, c.Component.Bounds.prototype = {
  5137. offsetX: {
  5138. get: function() {
  5139. return this.anchor.x * this.width
  5140. }
  5141. },
  5142. offsetY: {
  5143. get: function() {
  5144. return this.anchor.y * this.height
  5145. }
  5146. },
  5147. left: {
  5148. get: function() {
  5149. return this.x - this.offsetX
  5150. }
  5151. },
  5152. right: {
  5153. get: function() {
  5154. return this.x + this.width - this.offsetX
  5155. }
  5156. },
  5157. top: {
  5158. get: function() {
  5159. return this.y - this.offsetY
  5160. }
  5161. },
  5162. bottom: {
  5163. get: function() {
  5164. return this.y + this.height - this.offsetY
  5165. }
  5166. }
  5167. }, c.Component.BringToTop = function() {}, c.Component.BringToTop.prototype.bringToTop = function() {
  5168. return this.parent && this.parent.bringToTop(this), this
  5169. }, c.Component.BringToTop.prototype.sendToBack = function() {
  5170. return this.parent && this.parent.sendToBack(this), this
  5171. }, c.Component.BringToTop.prototype.moveUp = function() {
  5172. return this.parent && this.parent.moveUp(this), this
  5173. }, c.Component.BringToTop.prototype.moveDown = function() {
  5174. return this.parent && this.parent.moveDown(this), this
  5175. }, c.Component.Core = function() {}, c.Component.Core.install = function(a) {
  5176. c.Utils.mixinPrototype(this, c.Component.Core.prototype), this.components = {};
  5177. for (var b = 0; b < a.length; b++) {
  5178. var d = a[b],
  5179. e = !1;
  5180. "Destroy" === d && (e = !0), c.Utils.mixinPrototype(this, c.Component[d].prototype, e), this.components[d] = !0
  5181. }
  5182. }, c.Component.Core.init = function(a, b, d, e, f) {
  5183. this.game = a, this.key = e, this.position.set(b, d), this.world = new c.Point(b, d), this.previousPosition = new c.Point(b, d), this.events = new c.Events(this), this._bounds = new c.Rectangle, this.components.PhysicsBody && (this.body = this.body), this.components.Animation && (this.animations = new c.AnimationManager(this)), this.components.LoadTexture && null !== e && this.loadTexture(e, f), this.components.FixedToCamera && (this.cameraOffset = new c.Point(b, d))
  5184. }, c.Component.Core.preUpdate = function() {
  5185. if (this.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, !this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  5186. this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this.renderOrderID = this.game.stage.currentRenderOrderID++), this.animations && this.animations.update(), this.body && this.body.preUpdate();
  5187. for (var a = 0; a < this.children.length; a++) this.children[a].preUpdate();
  5188. return !0
  5189. }, c.Component.Core.prototype = {
  5190. game: null,
  5191. name: "",
  5192. components: {},
  5193. z: 0,
  5194. events: void 0,
  5195. animations: void 0,
  5196. key: "",
  5197. world: null,
  5198. debug: !1,
  5199. previousPosition: null,
  5200. previousRotation: 0,
  5201. renderOrderID: 0,
  5202. fresh: !0,
  5203. _bounds: null,
  5204. _exists: !0,
  5205. exists: {
  5206. get: function() {
  5207. return this._exists
  5208. },
  5209. set: function(a) {
  5210. a ? (this._exists = !0, this.body && this.body.type === c.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._exists = !1, this.body && this.body.type === c.Physics.P2JS && this.body.removeFromWorld(), this.visible = !1)
  5211. }
  5212. },
  5213. update: function() {},
  5214. postUpdate: function() {
  5215. this.key instanceof c.BitmapData && this.key.render(), this.components.PhysicsBody && c.Component.PhysicsBody.postUpdate.call(this), this.components.FixedToCamera && c.Component.FixedToCamera.postUpdate.call(this);
  5216. for (var a = 0; a < this.children.length; a++) this.children[a].postUpdate()
  5217. }
  5218. }, c.Component.Crop = function() {}, c.Component.Crop.prototype = {
  5219. cropRect: null,
  5220. _crop: null,
  5221. crop: function(a, b) {
  5222. "undefined" == typeof b && (b = !1), a ? (b && null !== this.cropRect ? this.cropRect.setTo(a.x, a.y, a.width, a.height) : this.cropRect = b && null === this.cropRect ? new c.Rectangle(a.x, a.y, a.width, a.height) : a, this.updateCrop()) : (this._crop = null, this.cropRect = null, this.resetFrame())
  5223. },
  5224. updateCrop: function() {
  5225. if (this.cropRect) {
  5226. this._crop = c.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
  5227. var a = Math.max(this._frame.x, this._crop.x),
  5228. b = Math.max(this._frame.y, this._crop.y),
  5229. d = Math.min(this._frame.right, this._crop.right) - a,
  5230. e = Math.min(this._frame.bottom, this._crop.bottom) - b;
  5231. this.texture.crop.x = a, this.texture.crop.y = b, 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.texture._updateUvs()
  5232. }
  5233. }
  5234. }, c.Component.Delta = function() {}, c.Component.Delta.prototype = {
  5235. deltaX: {
  5236. get: function() {
  5237. return this.world.x - this.previousPosition.x
  5238. }
  5239. },
  5240. deltaY: {
  5241. get: function() {
  5242. return this.world.y - this.previousPosition.y
  5243. }
  5244. },
  5245. deltaZ: {
  5246. get: function() {
  5247. return this.rotation - this.previousRotation
  5248. }
  5249. }
  5250. }, c.Component.Destroy = function() {}, c.Component.Destroy.prototype = {
  5251. destroyPhase: !1,
  5252. destroy: function(a) {
  5253. if (null !== this.game && !this.destroyPhase) {
  5254. "undefined" == typeof a && (a = !0), this.destroyPhase = !0, this.events && this.events.onDestroy$dispatch(this), this.parent && (this.parent instanceof c.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();
  5255. var b = this.children.length;
  5256. if (a)
  5257. for (; b--;) this.children[b].destroy(a);
  5258. else
  5259. for (; b--;) this.removeChild(this.children[b]);
  5260. 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.renderable = !1, this.transformCallback = null, this.transformCallbackContext = null, this.hitArea = null, this.parent = null, this.stage = null, this.worldTransform = null, this.filterArea = null, this._bounds = null, this._currentBounds = null, this._mask = null, this._destroyCachedSprite(), this.destroyPhase = !1
  5261. }
  5262. }
  5263. }, c.Events = function(a) {
  5264. this.parent = a
  5265. }, c.Events.prototype = {
  5266. destroy: function() {
  5267. this._parent = null, this._onDestroy && this._onDestroy.dispose(), this._onAddedToGroup && this._onAddedToGroup.dispose(), this._onRemovedFromGroup && this._onRemovedFromGroup.dispose(), this._onRemovedFromWorld && this._onRemovedFromWorld.dispose(), this._onKilled && this._onKilled.dispose(), this._onRevived && this._onRevived.dispose(), this._onEnterBounds && this._onEnterBounds.dispose(), this._onOutOfBounds && this._onOutOfBounds.dispose(), this._onInputOver && this._onInputOver.dispose(), this._onInputOut && this._onInputOut.dispose(), this._onInputDown && this._onInputDown.dispose(), this._onInputUp && this._onInputUp.dispose(), this._onDragStart && this._onDragStart.dispose(), this._onDragStop && this._onDragStop.dispose(), this._onAnimationStart && this._onAnimationStart.dispose(), this._onAnimationComplete && this._onAnimationComplete.dispose(), this._onAnimationLoop && this._onAnimationLoop.dispose()
  5268. },
  5269. onAddedToGroup: null,
  5270. onRemovedFromGroup: null,
  5271. onRemovedFromWorld: null,
  5272. onDestroy: null,
  5273. onKilled: null,
  5274. onRevived: null,
  5275. onOutOfBounds: null,
  5276. onEnterBounds: null,
  5277. onInputOver: null,
  5278. onInputOut: null,
  5279. onInputDown: null,
  5280. onInputUp: null,
  5281. onDragStart: null,
  5282. onDragStop: null,
  5283. onAnimationStart: null,
  5284. onAnimationComplete: null,
  5285. onAnimationLoop: null
  5286. }, c.Events.prototype.constructor = c.Events;
  5287. for (var e in c.Events.prototype) c.Events.prototype.hasOwnProperty(e) && 0 === e.indexOf("on") && null === c.Events.prototype[e] && ! function(a, b) {
  5288. "use strict";
  5289. Object.defineProperty(c.Events.prototype, a, {
  5290. get: function() {
  5291. return this[b] || (this[b] = new c.Signal)
  5292. }
  5293. }), c.Events.prototype[a + "$dispatch"] = function() {
  5294. return this[b] ? this[b].dispatch.apply(this[b], arguments) : null
  5295. }
  5296. }(e, "_" + e);
  5297. c.Component.FixedToCamera = function() {}, c.Component.FixedToCamera.postUpdate = function() {
  5298. this.fixedToCamera && (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)
  5299. }, c.Component.FixedToCamera.prototype = {
  5300. _fixedToCamera: !1,
  5301. fixedToCamera: {
  5302. get: function() {
  5303. return this._fixedToCamera
  5304. },
  5305. set: function(a) {
  5306. a ? (this._fixedToCamera = !0, this.cameraOffset.set(this.x, this.y)) : this._fixedToCamera = !1
  5307. }
  5308. },
  5309. cameraOffset: new c.Point
  5310. }, c.Component.Health = function() {}, c.Component.Health.prototype = {
  5311. health: 1,
  5312. damage: function(a) {
  5313. return this.alive && (this.health -= a, this.health <= 0 && this.kill()), this
  5314. }
  5315. }, c.Component.InCamera = function() {}, c.Component.InCamera.prototype = {
  5316. inCamera: {
  5317. get: function() {
  5318. return this.game.world.camera.view.intersects(this._bounds)
  5319. }
  5320. }
  5321. }, c.Component.InputEnabled = function() {}, c.Component.InputEnabled.prototype = {
  5322. input: null,
  5323. inputEnabled: {
  5324. get: function() {
  5325. return this.input && this.input.enabled
  5326. },
  5327. set: function(a) {
  5328. a ? null === this.input ? (this.input = new c.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5329. }
  5330. }
  5331. }, c.Component.InWorld = function() {}, c.Component.InWorld.preUpdate = function() {
  5332. if ((this.autoCull || this.checkWorldBounds) && (this._bounds.copyFrom(this.getBounds()), this._bounds.x += this.game.camera.view.x, this._bounds.y += this.game.camera.view.y, this.autoCull && (this.game.world.camera.view.intersects(this._bounds) ? (this.renderable = !0, this.game.world.camera.totalInView++) : this.renderable = !1), this.checkWorldBounds))
  5333. if (this._outOfBoundsFired && this.game.world.bounds.intersects(this._bounds)) this._outOfBoundsFired = !1, this.events.onEnterBounds$dispatch(this);
  5334. else if (!this._outOfBoundsFired && !this.game.world.bounds.intersects(this._bounds) && (this._outOfBoundsFired = !0, this.events.onOutOfBounds$dispatch(this), this.outOfBoundsKill)) return this.kill(), !1;
  5335. return !0
  5336. }, c.Component.InWorld.prototype = {
  5337. checkWorldBounds: !1,
  5338. outOfBoundsKill: !1,
  5339. _outOfBoundsFired: !1,
  5340. inWorld: {
  5341. get: function() {
  5342. return this.game.world.bounds.intersects(this.getBounds())
  5343. }
  5344. }
  5345. }, c.Component.LifeSpan = function() {}, c.Component.LifeSpan.preUpdate = function() {
  5346. return this.lifespan > 0 && (this.lifespan -= this.game.time.physicsElapsedMS, this.lifespan <= 0) ? (this.kill(), !1) : !0
  5347. }, c.Component.LifeSpan.prototype = {
  5348. alive: !0,
  5349. lifespan: 0,
  5350. revive: function(a) {
  5351. return "undefined" == typeof a && (a = 1), this.alive = !0, this.exists = !0, this.visible = !0, "number" == typeof this.health && (this.health = a), this.events && this.events.onRevived$dispatch(this), this
  5352. },
  5353. kill: function() {
  5354. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled$dispatch(this), this
  5355. }
  5356. }, c.Component.LoadTexture = function() {}, c.Component.LoadTexture.prototype = {
  5357. _frame: null,
  5358. loadTexture: function(a, b, d) {
  5359. b = b || 0, (d || "undefined" == typeof d) && this.animations && this.animations.stop(), this.key = a;
  5360. var e = !0,
  5361. f = !this.texture.baseTexture.scaleMode,
  5362. g = !1;
  5363. c.RenderTexture && a instanceof c.RenderTexture ? (this.key = a.key, this.setTexture(a), g = !0) : c.BitmapData && a instanceof c.BitmapData ? (this.setTexture(a.texture), this.game.cache.getFrameData(a.key, c.Cache.BITMAPDATA) && (e = !this.animations.loadFrameData(this.game.cache.getFrameData(a.key, c.Cache.BITMAPDATA), b))) : 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), b)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key])), g || this.texture.baseTexture.dirty(), e && (this._frame = c.Rectangle.clone(this.texture.frame)), f || (this.texture.baseTexture.scaleMode = 1)
  5364. },
  5365. setFrame: function(a) {
  5366. 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 = {
  5367. x: a.spriteSourceSizeX,
  5368. y: a.spriteSourceSizeY,
  5369. width: a.sourceSizeW,
  5370. height: a.sourceSizeH
  5371. }, this.texture.width = a.sourceSizeW, this.texture.height = a.sourceSizeH, this.texture.frame.width = a.sourceSizeW, this.texture.frame.height = a.sourceSizeH) : !a.trimmed && this.texture.trim && (this.texture.trim = null), this.cropRect && this.updateCrop(), 16777215 !== this.tint && (this.cachedTint = -1), this.texture._updateUvs()
  5372. },
  5373. resetFrame: function() {
  5374. this._frame && this.setFrame(this._frame)
  5375. },
  5376. frame: {
  5377. get: function() {
  5378. return this.animations.frame
  5379. },
  5380. set: function(a) {
  5381. this.animations.frame = a
  5382. }
  5383. },
  5384. frameName: {
  5385. get: function() {
  5386. return this.animations.frameName
  5387. },
  5388. set: function(a) {
  5389. this.animations.frameName = a
  5390. }
  5391. }
  5392. }, c.Component.Overlap = function() {}, c.Component.Overlap.prototype = {
  5393. overlap: function(a) {
  5394. return c.Rectangle.intersects(this.getBounds(), a.getBounds())
  5395. }
  5396. }, c.Component.PhysicsBody = function() {}, c.Component.PhysicsBody.preUpdate = function() {
  5397. return this.fresh && this.exists ? (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.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, this.body && this.body.preUpdate(), this.fresh = !1, !1) : (this.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, this._exists && this.parent.exists ? !0 : (this.renderOrderID = -1, !1))
  5398. }, c.Component.PhysicsBody.postUpdate = function() {
  5399. this.exists && this.body && this.body.postUpdate()
  5400. }, c.Component.PhysicsBody.prototype = {
  5401. body: null,
  5402. x: {
  5403. get: function() {
  5404. return this.position.x
  5405. },
  5406. set: function(a) {
  5407. this.position.x = a, this.body && !this.body.dirty && (this.body._reset = !0)
  5408. }
  5409. },
  5410. y: {
  5411. get: function() {
  5412. return this.position.y
  5413. },
  5414. set: function(a) {
  5415. this.position.y = a, this.body && !this.body.dirty && (this.body._reset = !0)
  5416. }
  5417. }
  5418. }, c.Component.Reset = function() {}, c.Component.Reset.prototype.reset = function(a, b, c) {
  5419. return "undefined" == typeof c && (c = 1), this.world.set(a, b), this.position.set(a, b), this.fresh = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this.components.InWorld && (this._outOfBoundsFired = !1), this.components.LifeSpan && (this.alive = !0, this.health = c), this.components.PhysicsBody && this.body && this.body.reset(a, b, !1, !1), this
  5420. }, c.Component.ScaleMinMax = function() {}, c.Component.ScaleMinMax.prototype = {
  5421. transformCallback: this.checkTransform,
  5422. transformCallbackContext: this,
  5423. scaleMin: null,
  5424. scaleMax: null,
  5425. checkTransform: function(a) {
  5426. this.scaleMin && (a.a < this.scaleMin.x && (a.a = this.scaleMin.x), a.d < this.scaleMin.y && (a.d = this.scaleMin.y)), this.scaleMax && (a.a > this.scaleMax.x && (a.a = this.scaleMax.x), a.d > this.scaleMax.y && (a.d = this.scaleMax.y))
  5427. },
  5428. setScaleMinMax: function(a, b, d, e) {
  5429. "undefined" == typeof b ? b = d = e = a : "undefined" == typeof d && (d = e = b, b = a), null === a ? this.scaleMin = null : this.scaleMin ? this.scaleMin.set(a, b) : this.scaleMin = new c.Point(a, b), null === d ? this.scaleMax = null : this.scaleMax ? this.scaleMax.set(d, e) : this.scaleMax = new c.Point(d, e)
  5430. }
  5431. }, c.Component.Smoothed = function() {}, c.Component.Smoothed.prototype = {
  5432. smoothed: {
  5433. get: function() {
  5434. return !this.texture.baseTexture.scaleMode
  5435. },
  5436. set: function(a) {
  5437. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  5438. }
  5439. }
  5440. }, c.GameObjectFactory = function(a) {
  5441. this.game = a, this.world = this.game.world
  5442. }, c.GameObjectFactory.prototype = {
  5443. existing: function(a) {
  5444. return this.world.add(a)
  5445. },
  5446. image: function(a, b, d, e, f) {
  5447. return "undefined" == typeof f && (f = this.world), f.add(new c.Image(this.game, a, b, d, e))
  5448. },
  5449. sprite: function(a, b, c, d, e) {
  5450. return "undefined" == typeof e && (e = this.world), e.create(a, b, c, d)
  5451. },
  5452. tween: function(a) {
  5453. return this.game.tweens.create(a)
  5454. },
  5455. group: function(a, b, d, e, f) {
  5456. return new c.Group(this.game, a, b, d, e, f)
  5457. },
  5458. physicsGroup: function(a, b, d, e) {
  5459. return new c.Group(this.game, b, d, e, !0, a)
  5460. },
  5461. spriteBatch: function(a, b, d) {
  5462. return "undefined" == typeof a && (a = null), "undefined" == typeof b && (b = "group"), "undefined" == typeof d && (d = !1), new c.SpriteBatch(this.game, a, b, d)
  5463. },
  5464. audio: function(a, b, c, d) {
  5465. return this.game.sound.add(a, b, c, d)
  5466. },
  5467. sound: function(a, b, c, d) {
  5468. return this.game.sound.add(a, b, c, d)
  5469. },
  5470. audioSprite: function(a) {
  5471. return this.game.sound.addSprite(a)
  5472. },
  5473. tileSprite: function(a, b, d, e, f, g, h) {
  5474. return "undefined" == typeof h && (h = this.world), h.add(new c.TileSprite(this.game, a, b, d, e, f, g))
  5475. },
  5476. rope: function(a, b, d, e, f, g) {
  5477. return "undefined" == typeof g && (g = this.world), g.add(new c.Rope(this.game, a, b, d, e, f))
  5478. },
  5479. text: function(a, b, d, e, f) {
  5480. return "undefined" == typeof f && (f = this.world), f.add(new c.Text(this.game, a, b, d, e))
  5481. },
  5482. button: function(a, b, d, e, f, g, h, i, j, k) {
  5483. return "undefined" == typeof k && (k = this.world), k.add(new c.Button(this.game, a, b, d, e, f, g, h, i, j))
  5484. },
  5485. graphics: function(a, b, d) {
  5486. return "undefined" == typeof d && (d = this.world), d.add(new c.Graphics(this.game, a, b))
  5487. },
  5488. emitter: function(a, b, d) {
  5489. return this.game.particles.add(new c.Particles.Arcade.Emitter(this.game, a, b, d))
  5490. },
  5491. retroFont: function(a, b, d, e, f, g, h, i, j) {
  5492. return new c.RetroFont(this.game, a, b, d, e, f, g, h, i, j)
  5493. },
  5494. bitmapText: function(a, b, d, e, f, g) {
  5495. return "undefined" == typeof g && (g = this.world), g.add(new c.BitmapText(this.game, a, b, d, e, f))
  5496. },
  5497. tilemap: function(a, b, d, e, f) {
  5498. return new c.Tilemap(this.game, a, b, d, e, f)
  5499. },
  5500. renderTexture: function(a, b, d, e) {
  5501. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  5502. var f = new c.RenderTexture(this.game, a, b, d);
  5503. return e && this.game.cache.addRenderTexture(d, f), f
  5504. },
  5505. bitmapData: function(a, b, d, e) {
  5506. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  5507. var f = new c.BitmapData(this.game, d, a, b);
  5508. return e && this.game.cache.addBitmapData(d, f), f
  5509. },
  5510. filter: function(a) {
  5511. var b = Array.prototype.splice.call(arguments, 1),
  5512. a = new c.Filter[a](this.game);
  5513. return a.init.apply(a, b), a
  5514. },
  5515. plugin: function(a) {
  5516. return this.game.plugins.add(a)
  5517. }
  5518. }, c.GameObjectFactory.prototype.constructor = c.GameObjectFactory, c.GameObjectCreator = function(a) {
  5519. this.game = a, this.world = this.game.world
  5520. }, c.GameObjectCreator.prototype = {
  5521. image: function(a, b, d, e) {
  5522. return new c.Image(this.game, a, b, d, e)
  5523. },
  5524. sprite: function(a, b, d, e) {
  5525. return new c.Sprite(this.game, a, b, d, e)
  5526. },
  5527. tween: function(a) {
  5528. return new c.Tween(a, this.game, this.game.tweens)
  5529. },
  5530. group: function(a, b, d, e, f) {
  5531. return new c.Group(this.game, null, b, d, e, f)
  5532. },
  5533. spriteBatch: function(a, b, d) {
  5534. return "undefined" == typeof b && (b = "group"), "undefined" == typeof d && (d = !1), new c.SpriteBatch(this.game, a, b, d)
  5535. },
  5536. audio: function(a, b, c, d) {
  5537. return this.game.sound.add(a, b, c, d)
  5538. },
  5539. audioSprite: function(a) {
  5540. return this.game.sound.addSprite(a)
  5541. },
  5542. sound: function(a, b, c, d) {
  5543. return this.game.sound.add(a, b, c, d)
  5544. },
  5545. tileSprite: function(a, b, d, e, f, g) {
  5546. return new c.TileSprite(this.game, a, b, d, e, f, g)
  5547. },
  5548. rope: function(a, b, d, e, f) {
  5549. return new c.Rope(this.game, a, b, d, e, f)
  5550. },
  5551. text: function(a, b, d, e) {
  5552. return new c.Text(this.game, a, b, d, e)
  5553. },
  5554. button: function(a, b, d, e, f, g, h, i, j) {
  5555. return new c.Button(this.game, a, b, d, e, f, g, h, i, j)
  5556. },
  5557. graphics: function(a, b) {
  5558. return new c.Graphics(this.game, a, b)
  5559. },
  5560. emitter: function(a, b, d) {
  5561. return new c.Particles.Arcade.Emitter(this.game, a, b, d)
  5562. },
  5563. retroFont: function(a, b, d, e, f, g, h, i, j) {
  5564. return new c.RetroFont(this.game, a, b, d, e, f, g, h, i, j)
  5565. },
  5566. bitmapText: function(a, b, d, e, f) {
  5567. return new c.BitmapText(this.game, a, b, d, e, f)
  5568. },
  5569. tilemap: function(a, b, d, e, f) {
  5570. return new c.Tilemap(this.game, a, b, d, e, f)
  5571. },
  5572. renderTexture: function(a, b, d, e) {
  5573. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  5574. var f = new c.RenderTexture(this.game, a, b, d);
  5575. return e && this.game.cache.addRenderTexture(d, f), f
  5576. },
  5577. bitmapData: function(a, b, d, e) {
  5578. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  5579. var f = new c.BitmapData(this.game, d, a, b);
  5580. return e && this.game.cache.addBitmapData(d, f), f
  5581. },
  5582. filter: function(a) {
  5583. var b = Array.prototype.splice.call(arguments, 1),
  5584. a = new c.Filter[a](this.game);
  5585. return a.init.apply(a, b), a
  5586. }
  5587. }, c.GameObjectCreator.prototype.constructor = c.GameObjectCreator, c.Sprite = function(a, b, d, e, f) {
  5588. b = b || 0, d = d || 0, e = e || null, f = f || null, this.type = c.SPRITE, this.physicsType = c.SPRITE, PIXI.Sprite.call(this, PIXI.TextureCache.__default), c.Component.Core.init.call(this, a, b, d, e, f)
  5589. }, c.Sprite.prototype = Object.create(PIXI.Sprite.prototype), c.Sprite.prototype.constructor = c.Sprite, c.Component.Core.install.call(c.Sprite.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "ScaleMinMax", "Smoothed"]), c.Sprite.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.Sprite.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.Sprite.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.Sprite.prototype.preUpdateCore = c.Component.Core.preUpdate, c.Sprite.prototype.preUpdate = function() {
  5590. return this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5591. }, c.Image = function(a, b, d, e, f) {
  5592. b = b || 0, d = d || 0, e = e || null, f = f || null, this.type = c.IMAGE, PIXI.Sprite.call(this, PIXI.TextureCache.__default), c.Component.Core.init.call(this, a, b, d, e, f)
  5593. }, c.Image.prototype = Object.create(PIXI.Sprite.prototype), c.Image.prototype.constructor = c.Image, c.Component.Core.install.call(c.Image.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Destroy", "FixedToCamera", "InputEnabled", "LifeSpan", "LoadTexture", "Overlap", "Reset", "Smoothed"]), c.Image.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.Image.prototype.preUpdateCore = c.Component.Core.preUpdate, c.Image.prototype.preUpdate = function() {
  5594. return this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5595. }, c.TileSprite = function(a, b, d, e, f, g, h) {
  5596. b = b || 0, d = d || 0, e = e || 256, f = f || 256, g = g || null, h = h || null, this.type = c.TILESPRITE, this._scroll = new c.Point, PIXI.TilingSprite.call(this, PIXI.TextureCache.__default, e, f), c.Component.Core.init.call(this, a, b, d, g, h)
  5597. }, c.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), c.TileSprite.prototype.constructor = c.TileSprite, c.Component.Core.install.call(c.TileSprite.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "Smoothed"]), c.TileSprite.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.TileSprite.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.TileSprite.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.TileSprite.prototype.preUpdateCore = c.Component.Core.preUpdate, c.TileSprite.prototype.preUpdate = function() {
  5598. return 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.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5599. }, c.TileSprite.prototype.autoScroll = function(a, b) {
  5600. this._scroll.set(a, b)
  5601. }, c.TileSprite.prototype.stopScroll = function() {
  5602. this._scroll.set(0, 0)
  5603. }, c.TileSprite.prototype.destroy = function(a) {
  5604. c.Component.Destroy.prototype.destroy.call(this, a), PIXI.TilingSprite.prototype.destroy.call(this)
  5605. }, c.TileSprite.prototype.reset = function(a, b) {
  5606. return c.Component.Reset.prototype.reset.call(this, a, b), this.tilePosition.x = 0, this.tilePosition.y = 0, this
  5607. }, c.Rope = function(a, b, d, e, f, g) {
  5608. this.points = [], this.points = g, this._hasUpdateAnimation = !1, this._updateAnimationCallback = null, b = b || 0, d = d || 0, e = e || null, f = f || null, this.type = c.ROPE, this._scroll = new c.Point, PIXI.Rope.call(this, e, this.points), c.Component.Core.init.call(this, a, b, d, e, f)
  5609. }, c.Rope.prototype = Object.create(PIXI.Rope.prototype), c.Rope.prototype.constructor = c.Rope, c.Component.Core.install.call(c.Rope.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "ScaleMinMax", "Smoothed"]), c.Rope.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.Rope.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.Rope.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.Rope.prototype.preUpdateCore = c.Component.Core.preUpdate, c.Rope.prototype.preUpdate = function() {
  5610. return 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.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5611. }, c.Rope.prototype.update = function() {
  5612. this._hasUpdateAnimation && this.updateAnimation.call(this)
  5613. }, c.Rope.prototype.reset = function(a, b) {
  5614. return c.Component.Reset.prototype.reset.call(this, a, b), this.tilePosition.x = 0, this.tilePosition.y = 0, this
  5615. }, Object.defineProperty(c.Rope.prototype, "updateAnimation", {
  5616. get: function() {
  5617. return this._updateAnimation
  5618. },
  5619. set: function(a) {
  5620. a && "function" == typeof a ? (this._hasUpdateAnimation = !0, this._updateAnimation = a) : (this._hasUpdateAnimation = !1, this._updateAnimation = null)
  5621. }
  5622. }), Object.defineProperty(c.Rope.prototype, "segments", {
  5623. get: function() {
  5624. for (var a, b, d, e, f, g, h, i, j = [], k = 0; k < this.points.length; k++) a = 4 * k, b = this.verticies[a], d = this.verticies[a + 1], e = this.verticies[a + 4], f = this.verticies[a + 3], g = c.Math.difference(b, e), h = c.Math.difference(d, f), b += this.world.x, d += this.world.y, i = new c.Rectangle(b, d, g, h), j.push(i);
  5625. return j
  5626. }
  5627. }), c.Button = function(a, b, d, e, f, g, h, i, j, k) {
  5628. b = b || 0, d = d || 0, e = e || null, f = f || null, g = g || this, c.Image.call(this, a, b, d, e, i), this.type = c.BUTTON, this.physicsType = c.SPRITE, this._onOverFrame = null, this._onOutFrame = null, this._onDownFrame = null, this._onUpFrame = null, this.onOverSound = null, this.onOutSound = null, this.onDownSound = null, this.onUpSound = null, this.onOverSoundMarker = "", this.onOutSoundMarker = "", this.onDownSoundMarker = "", this.onUpSoundMarker = "", this.onInputOver = new c.Signal, this.onInputOut = new c.Signal, this.onInputDown = new c.Signal, this.onInputUp = new c.Signal, this.onOverMouseOnly = !1, 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), this.events.onRemovedFromWorld.add(this.removedFromWorld, this)
  5629. }, c.Button.prototype = Object.create(c.Image.prototype), c.Button.prototype.constructor = c.Button;
  5630. var f = "Over",
  5631. g = "Out",
  5632. h = "Down",
  5633. i = "Up";
  5634. c.Button.prototype.clearFrames = function() {
  5635. this.setFrames(null, null, null, null)
  5636. }, c.Button.prototype.removedFromWorld = function() {
  5637. this.inputEnabled = !1
  5638. }, c.Button.prototype.setStateFrame = function(a, b, c) {
  5639. var d = "_on" + a + "Frame";
  5640. null != b ? (this[d] = b, c && this.changeStateFrame(a)) : this[d] = null
  5641. }, c.Button.prototype.changeStateFrame = function(a) {
  5642. if (this.freezeFrames) return !1;
  5643. var b = "_on" + a + "Frame",
  5644. c = this[b];
  5645. return "string" == typeof c ? (this.frameName = c, !0) : "number" == typeof c ? (this.frame = c, !0) : !1
  5646. }, c.Button.prototype.setFrames = function(a, b, c, d) {
  5647. this.setStateFrame(f, a, this.input.pointerOver()), this.setStateFrame(g, b, !this.input.pointerOver()), this.setStateFrame(h, c, this.input.pointerDown()), this.setStateFrame(i, d, this.input.pointerUp())
  5648. }, c.Button.prototype.setStateSound = function(a, b, d) {
  5649. var e = "on" + a + "Sound",
  5650. f = "on" + a + "SoundMarker";
  5651. b instanceof c.Sound || b instanceof c.AudioSprite ? (this[e] = b, this[f] = "string" == typeof d ? d : "") : (this[e] = null, this[f] = "")
  5652. }, c.Button.prototype.playStateSound = function(a) {
  5653. var b = "on" + a + "Sound",
  5654. c = this[b];
  5655. if (c) {
  5656. var d = "on" + a + "SoundMarker",
  5657. e = this[d];
  5658. return c.play(e), !0
  5659. }
  5660. return !1
  5661. }, c.Button.prototype.setSounds = function(a, b, c, d, e, j, k, l) {
  5662. this.setStateSound(f, a, b), this.setStateSound(g, e, j), this.setStateSound(h, c, d), this.setStateSound(i, k, l)
  5663. }, c.Button.prototype.setOverSound = function(a, b) {
  5664. this.setStateSound(f, a, b)
  5665. }, c.Button.prototype.setOutSound = function(a, b) {
  5666. this.setStateSound(g, a, b)
  5667. }, c.Button.prototype.setDownSound = function(a, b) {
  5668. this.setStateSound(h, a, b)
  5669. }, c.Button.prototype.setUpSound = function(a, b) {
  5670. this.setStateSound(i, a, b)
  5671. }, c.Button.prototype.onInputOverHandler = function(a, b) {
  5672. b.justReleased() || (this.changeStateFrame(f), (!this.onOverMouseOnly || b.isMouse) && (this.playStateSound(f), this.onInputOver && this.onInputOver.dispatch(this, b)))
  5673. }, c.Button.prototype.onInputOutHandler = function(a, b) {
  5674. this.changeStateFrame(g), this.playStateSound(g), this.onInputOut && this.onInputOut.dispatch(this, b)
  5675. }, c.Button.prototype.onInputDownHandler = function(a, b) {
  5676. this.changeStateFrame(h), this.playStateSound(h), this.onInputDown && this.onInputDown.dispatch(this, b)
  5677. }, c.Button.prototype.onInputUpHandler = function(a, b, c) {
  5678. if (this.playStateSound(i), this.onInputUp && this.onInputUp.dispatch(this, b, c), !this.freezeFrames)
  5679. if (this.forceOut) this.changeStateFrame(g);
  5680. else {
  5681. var d = this.changeStateFrame(i);
  5682. d || this.changeStateFrame(c ? f : g)
  5683. }
  5684. }, c.SpriteBatch = function(a, b, d, e) {
  5685. ("undefined" == typeof b || null === b) && (b = a.world), PIXI.SpriteBatch.call(this), c.Group.call(this, a, b, d, e), this.type = c.SPRITEBATCH
  5686. }, c.SpriteBatch.prototype = c.Utils.extend(!0, c.SpriteBatch.prototype, c.Group.prototype, PIXI.SpriteBatch.prototype), c.SpriteBatch.prototype.constructor = c.SpriteBatch, c.Particle = function(a, b, d, e, f) {
  5687. c.Sprite.call(this, a, b, d, e, f), this.autoScale = !1, this.scaleData = null, this._s = 0, this.autoAlpha = !1, this.alphaData = null, this._a = 0
  5688. }, c.Particle.prototype = Object.create(c.Sprite.prototype), c.Particle.prototype.constructor = c.Particle, c.Particle.prototype.update = function() {
  5689. 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)
  5690. }, c.Particle.prototype.onEmit = function() {}, c.Particle.prototype.setAlphaData = function(a) {
  5691. this.alphaData = a, this._a = a.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0
  5692. }, c.Particle.prototype.setScaleData = function(a) {
  5693. this.scaleData = a, this._s = a.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0
  5694. }, c.Particle.prototype.reset = function(a, b, d) {
  5695. return c.Component.Reset.prototype.reset.call(this, a, b, d), this.alpha = 1, this.scale.set(1), this.autoScale = !1, this.autoAlpha = !1, this
  5696. }, c.BitmapData = function(a, b, d, e) {
  5697. "undefined" == typeof d && (d = 256), "undefined" == typeof e && (e = 256), this.game = a, this.key = b, this.width = d, this.height = e, this.canvas = c.Canvas.create(d, e, "", !0), this.context = this.canvas.getContext("2d", {
  5698. alpha: !0
  5699. }), 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 c.Frame(0, 0, 0, d, e, "bitmapData", a.rnd.uuid()), this.texture.frame = this.textureFrame, this.type = c.BITMAPDATA, this.disableTextureUpload = !1, this.dirty = !1, this.cls = this.clear, this._image = null, this._pos = new c.Point, this._size = new c.Point, this._scale = new c.Point, this._rotate = 0, this._alpha = {
  5700. prev: 1,
  5701. current: 1
  5702. }, this._anchor = new c.Point, this._tempR = 0, this._tempG = 0, this._tempB = 0, this._circle = new c.Circle
  5703. }, c.BitmapData.prototype = {
  5704. add: function(a) {
  5705. if (Array.isArray(a))
  5706. for (var b = 0; b < a.length; b++) a[b].loadTexture && a[b].loadTexture(this);
  5707. else a.loadTexture(this);
  5708. return this
  5709. },
  5710. load: function(a) {
  5711. return "string" == typeof a && (a = this.game.cache.getImage(a)), a ? (this.resize(a.width, a.height), this.cls(), this.draw(a), this.update(), this) : void 0
  5712. },
  5713. clear: function() {
  5714. return this.context.clearRect(0, 0, this.width, this.height), this.dirty = !0, this
  5715. },
  5716. fill: function(a, b, c, d) {
  5717. return "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, this
  5718. },
  5719. resize: function(a, b) {
  5720. return (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.update(), this.dirty = !0), this
  5721. },
  5722. update: function(a, b, c, d) {
  5723. return "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, this
  5724. },
  5725. processPixelRGB: function(a, b, d, e, f, g) {
  5726. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = this.width), "undefined" == typeof g && (g = this.height);
  5727. for (var h = d + f, i = e + g, j = c.Color.createColor(), k = {
  5728. r: 0,
  5729. g: 0,
  5730. b: 0,
  5731. a: 0
  5732. }, l = !1, m = e; i > m; m++)
  5733. for (var n = d; h > n; n++) c.Color.unpackPixel(this.getPixel32(n, m), j), k = a.call(b, 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);
  5734. return l && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
  5735. },
  5736. processPixel: function(a, b, c, d, e, f) {
  5737. "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = this.width), "undefined" == typeof f && (f = this.height);
  5738. for (var g = c + e, h = d + f, i = 0, j = 0, k = !1, l = d; h > l; l++)
  5739. 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);
  5740. return k && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
  5741. },
  5742. replaceRGB: function(a, b, d, e, f, g, h, i, j) {
  5743. var k = 0,
  5744. l = 0,
  5745. m = this.width,
  5746. n = this.height,
  5747. o = c.Color.packPixel(a, b, d, e);
  5748. void 0 !== j && j instanceof c.Rectangle && (k = j.x, l = j.y, m = j.width, n = j.height);
  5749. for (var p = 0; n > p; p++)
  5750. 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);
  5751. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  5752. },
  5753. setHSL: function(a, b, d, e) {
  5754. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof b || null === b) && (b = !1), ("undefined" == typeof d || null === d) && (d = !1), a || b || d) {
  5755. "undefined" == typeof e && (e = new c.Rectangle(0, 0, this.width, this.height));
  5756. for (var f = c.Color.createColor(), g = e.y; g < e.bottom; g++)
  5757. for (var h = e.x; h < e.right; h++) c.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = a), b && (f.s = b), d && (f.l = d), c.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  5758. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  5759. }
  5760. },
  5761. shiftHSL: function(a, b, d, e) {
  5762. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof b || null === b) && (b = !1), ("undefined" == typeof d || null === d) && (d = !1), a || b || d) {
  5763. "undefined" == typeof e && (e = new c.Rectangle(0, 0, this.width, this.height));
  5764. for (var f = c.Color.createColor(), g = e.y; g < e.bottom; g++)
  5765. for (var h = e.x; h < e.right; h++) c.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = this.game.math.wrap(f.h + a, 0, 1)), b && (f.s = this.game.math.limitValue(f.s + b, 0, 1)), d && (f.l = this.game.math.limitValue(f.l + d, 0, 1)), c.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  5766. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  5767. }
  5768. },
  5769. setPixel32: function(a, b, d, e, f, g, h) {
  5770. return "undefined" == typeof h && (h = !0), a >= 0 && a <= this.width && b >= 0 && b <= this.height && (this.pixels[b * this.width + a] = c.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)), this
  5771. },
  5772. setPixel: function(a, b, c, d, e, f) {
  5773. return this.setPixel32(a, b, c, d, e, 255, f)
  5774. },
  5775. getPixel: function(a, b, d) {
  5776. d || (d = c.Color.createColor());
  5777. var e = ~~(a + b * this.width);
  5778. return e *= 4, d.r = this.data[e], d.g = this.data[++e], d.b = this.data[++e], d.a = this.data[++e], d
  5779. },
  5780. getPixel32: function(a, b) {
  5781. return a >= 0 && a <= this.width && b >= 0 && b <= this.height ? this.pixels[b * this.width + a] : void 0
  5782. },
  5783. getPixelRGB: function(a, b, d, e, f) {
  5784. return c.Color.unpackPixel(this.getPixel32(a, b), d, e, f)
  5785. },
  5786. getPixels: function(a) {
  5787. return this.context.getImageData(a.x, a.y, a.width, a.height)
  5788. },
  5789. getFirstPixel: function(a) {
  5790. "undefined" == typeof a && (a = 0);
  5791. var b = c.Color.createColor(),
  5792. d = 0,
  5793. e = 0,
  5794. f = 1,
  5795. g = !1;
  5796. 1 === a ? (f = -1, e = this.height) : 3 === a && (f = -1, d = this.width);
  5797. do c.Color.unpackPixel(this.getPixel32(d, e), b), 0 === a || 1 === a ? (d++, d === this.width && (d = 0, e += f, (e >= this.height || 0 >= e) && (g = !0))) : (2 === a || 3 === a) && (e++, e === this.height && (e = 0, d += f, (d >= this.width || 0 >= d) && (g = !0))); while (0 === b.a && !g);
  5798. return b.x = d, b.y = e, b
  5799. },
  5800. getBounds: function(a) {
  5801. return "undefined" == typeof a && (a = new c.Rectangle), a.x = this.getFirstPixel(2).x, a.x === this.width ? a.setTo(0, 0, 0, 0) : (a.y = this.getFirstPixel(0).y, a.width = this.getFirstPixel(3).x - a.x + 1, a.height = this.getFirstPixel(1).y - a.y + 1, a)
  5802. },
  5803. addToWorld: function(a, b, c, d, e, f) {
  5804. e = e || 1, f = f || 1;
  5805. var g = this.game.add.image(a, b, this);
  5806. return g.anchor.set(c, d), g.scale.set(e, f), g
  5807. },
  5808. copy: function(a, b, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) {
  5809. if (("undefined" == typeof a || null === a) && (a = this), this._image = a, a instanceof c.Sprite || a instanceof c.Image || a instanceof c.Text) this._pos.set(a.texture.crop.x, a.texture.crop.y), this._size.set(a.texture.crop.width, a.texture.crop.height), this._scale.set(a.scale.x, a.scale.y), this._anchor.set(a.anchor.x, a.anchor.y), this._rotate = a.rotation, this._alpha.current = a.alpha, this._image = a.texture.baseTexture.source, ("undefined" == typeof g || null === g) && (g = a.x), ("undefined" == typeof h || null === h) && (h = a.y), a.texture.trim && (g += a.texture.trim.x - a.anchor.x * a.texture.trim.width, h += a.texture.trim.y - a.anchor.y * a.texture.trim.height), 16777215 !== a.tint && (a.cachedTint !== a.tint && (a.cachedTint = a.tint, a.tintedTexture = PIXI.CanvasTinter.getTintedTexture(a, a.tint)), this._image = a.tintedTexture);
  5810. else {
  5811. if (this._pos.set(0), this._scale.set(1), this._anchor.set(0), this._rotate = 0, this._alpha.current = 1, a instanceof c.BitmapData) this._image = a.canvas;
  5812. else if ("string" == typeof a) {
  5813. if (a = this.game.cache.getImage(a), null === a) return;
  5814. this._image = a
  5815. }
  5816. this._size.set(this._image.width, this._image.height)
  5817. }
  5818. return ("undefined" == typeof b || null === b) && (b = 0), ("undefined" == typeof d || null === d) && (d = 0), e && (this._size.x = e), f && (this._size.y = f), ("undefined" == typeof g || null === g) && (g = b), ("undefined" == typeof h || null === h) && (h = d), ("undefined" == typeof i || null === i) && (i = this._size.x), ("undefined" == typeof j || null === j) && (j = this._size.y), "number" == typeof k && (this._rotate = k), "number" == typeof l && (this._anchor.x = l), "number" == typeof m && (this._anchor.y = m), "number" == typeof n && (this._scale.x = n), "number" == typeof o && (this._scale.y = o), "number" == typeof p && (this._alpha.current = p), "undefined" == typeof q && (q = null), "undefined" == typeof r && (r = !1), this._alpha.current <= 0 || 0 === this._scale.x || 0 === this._scale.y || 0 === this._size.x || 0 === this._size.y ? void 0 : (this._alpha.prev = this.context.globalAlpha, this.context.save(), this.context.globalAlpha = this._alpha.current, q && (this.context.globalCompositeOperation = q), r && (g |= 0, h |= 0), this.context.translate(g, h), this.context.scale(this._scale.x, this._scale.y), this.context.rotate(this._rotate), this.context.drawImage(this._image, this._pos.x + b, this._pos.y + d, this._size.x, this._size.y, -i * this._anchor.x, -j * this._anchor.y, i, j), this.context.restore(), this.context.globalAlpha = this._alpha.prev, this.dirty = !0, this)
  5819. },
  5820. copyRect: function(a, b, c, d, e, f, g) {
  5821. return this.copy(a, b.x, b.y, b.width, b.height, c, d, b.width, b.height, 0, 0, 0, 1, 1, e, f, g)
  5822. },
  5823. draw: function(a, b, c, d, e, f, g) {
  5824. return this.copy(a, null, null, null, null, b, c, d, e, null, null, null, null, null, null, f, g)
  5825. },
  5826. drawGroup: function(a, b, c) {
  5827. return a.total > 0 && a.forEachExists(this.copy, this, null, null, null, null, null, null, null, null, null, null, null, null, null, null, b, c), this
  5828. },
  5829. shadow: function(a, b, c, d) {
  5830. "undefined" == typeof a || null === a ? this.context.shadowColor = "rgba(0,0,0,0)" : (this.context.shadowColor = a, this.context.shadowBlur = b || 5, this.context.shadowOffsetX = c || 10, this.context.shadowOffsetY = d || 10)
  5831. },
  5832. alphaMask: function(a, b, c, d) {
  5833. return "undefined" == typeof d || null === d ? this.draw(b).blendSourceAtop() : this.draw(b, d.x, d.y, d.width, d.height).blendSourceAtop(), "undefined" == typeof c || null === c ? this.draw(a).blendReset() : this.draw(a, c.x, c.y, c.width, c.height).blendReset(), this
  5834. },
  5835. extract: function(a, b, c, d, e, f, g, h, i) {
  5836. 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) {
  5837. return f.r === b && f.g === c && f.b === d && a.setPixel32(j, k, g, h, i, e, !1), !1
  5838. }, this), a.context.putImageData(a.imageData, 0, 0), a.dirty = !0, a
  5839. },
  5840. rect: function(a, b, c, d, e) {
  5841. return "undefined" != typeof e && (this.context.fillStyle = e), this.context.fillRect(a, b, c, d), this
  5842. },
  5843. text: function(a, b, c, d, e, f) {
  5844. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = "14px Courier"), "undefined" == typeof e && (e = "rgb(255,255,255)"), "undefined" == typeof f && (f = !0);
  5845. var g = this.context.font;
  5846. this.context.font = d, f && (this.context.fillStyle = "rgb(0,0,0)", this.context.fillText(a, b + 1, c + 1)), this.context.fillStyle = e, this.context.fillText(a, b, c), this.context.font = g
  5847. },
  5848. circle: function(a, b, c, d) {
  5849. return "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(), this
  5850. },
  5851. textureLine: function(a, b, d) {
  5852. if ("undefined" == typeof d && (d = "repeat-x"), "string" != typeof b || (b = this.game.cache.getImage(b))) {
  5853. var e = a.length;
  5854. return "no-repeat" === d && e > b.width && (e = b.width), this.context.fillStyle = this.context.createPattern(b, d), this._circle = new c.Circle(a.start.x, a.start.y, b.height), this._circle.circumferencePoint(a.angle - 1.5707963267948966, !1, this._pos), this.context.save(), this.context.translate(this._pos.x, this._pos.y), this.context.rotate(a.angle), this.context.fillRect(0, 0, e, b.height), this.context.restore(), this.dirty = !0, this
  5855. }
  5856. },
  5857. render: function() {
  5858. return !this.disableTextureUpload && this.dirty && (this.baseTexture.dirty(), this.dirty = !1), this
  5859. },
  5860. blendReset: function() {
  5861. return this.context.globalCompositeOperation = "source-over", this
  5862. },
  5863. blendSourceOver: function() {
  5864. return this.context.globalCompositeOperation = "source-over", this
  5865. },
  5866. blendSourceIn: function() {
  5867. return this.context.globalCompositeOperation = "source-in", this
  5868. },
  5869. blendSourceOut: function() {
  5870. return this.context.globalCompositeOperation = "source-out", this
  5871. },
  5872. blendSourceAtop: function() {
  5873. return this.context.globalCompositeOperation = "source-atop", this
  5874. },
  5875. blendDestinationOver: function() {
  5876. return this.context.globalCompositeOperation = "destination-over", this
  5877. },
  5878. blendDestinationIn: function() {
  5879. return this.context.globalCompositeOperation = "destination-in", this
  5880. },
  5881. blendDestinationOut: function() {
  5882. return this.context.globalCompositeOperation = "destination-out", this
  5883. },
  5884. blendDestinationAtop: function() {
  5885. return this.context.globalCompositeOperation = "destination-atop", this
  5886. },
  5887. blendXor: function() {
  5888. return this.context.globalCompositeOperation = "xor", this
  5889. },
  5890. blendAdd: function() {
  5891. return this.context.globalCompositeOperation = "lighter", this
  5892. },
  5893. blendMultiply: function() {
  5894. return this.context.globalCompositeOperation = "multiply", this
  5895. },
  5896. blendScreen: function() {
  5897. return this.context.globalCompositeOperation = "screen", this
  5898. },
  5899. blendOverlay: function() {
  5900. return this.context.globalCompositeOperation = "overlay", this
  5901. },
  5902. blendDarken: function() {
  5903. return this.context.globalCompositeOperation = "darken", this
  5904. },
  5905. blendLighten: function() {
  5906. return this.context.globalCompositeOperation = "lighten", this
  5907. },
  5908. blendColorDodge: function() {
  5909. return this.context.globalCompositeOperation = "color-dodge", this
  5910. },
  5911. blendColorBurn: function() {
  5912. return this.context.globalCompositeOperation = "color-burn", this
  5913. },
  5914. blendHardLight: function() {
  5915. return this.context.globalCompositeOperation = "hard-light", this
  5916. },
  5917. blendSoftLight: function() {
  5918. return this.context.globalCompositeOperation = "soft-light", this
  5919. },
  5920. blendDifference: function() {
  5921. return this.context.globalCompositeOperation = "difference", this
  5922. },
  5923. blendExclusion: function() {
  5924. return this.context.globalCompositeOperation = "exclusion", this
  5925. },
  5926. blendHue: function() {
  5927. return this.context.globalCompositeOperation = "hue", this
  5928. },
  5929. blendSaturation: function() {
  5930. return this.context.globalCompositeOperation = "saturation", this
  5931. },
  5932. blendColor: function() {
  5933. return this.context.globalCompositeOperation = "color", this
  5934. },
  5935. blendLuminosity: function() {
  5936. return this.context.globalCompositeOperation = "luminosity", this
  5937. }
  5938. }, Object.defineProperty(c.BitmapData.prototype, "smoothed", {
  5939. get: function() {
  5940. c.Canvas.getSmoothingEnabled(this.context)
  5941. },
  5942. set: function(a) {
  5943. c.Canvas.setSmoothingEnabled(this.context, a)
  5944. }
  5945. }), c.BitmapData.getTransform = function(a, b, c, d, e, f) {
  5946. return "number" != typeof a && (a = 0), "number" != typeof b && (b = 0), "number" != typeof c && (c = 1), "number" != typeof d && (d = 1), "number" != typeof e && (e = 0), "number" != typeof f && (f = 0), {
  5947. sx: c,
  5948. sy: d,
  5949. scaleX: c,
  5950. scaleY: d,
  5951. skewX: e,
  5952. skewY: f,
  5953. translateX: a,
  5954. translateY: b,
  5955. tx: a,
  5956. ty: b
  5957. }
  5958. }, c.BitmapData.prototype.constructor = c.BitmapData, c.Graphics = function(a, b, d) {
  5959. b = b || 0, d = d || 0, this.type = c.GRAPHICS, this.physicsType = c.SPRITE, PIXI.Graphics.call(this), c.Component.Core.init.call(this, a, b, d, "", null)
  5960. }, c.Graphics.prototype = Object.create(PIXI.Graphics.prototype), c.Graphics.prototype.constructor = c.Graphics, c.Component.Core.install.call(c.Graphics.prototype, ["Angle", "AutoCull", "Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "PhysicsBody", "Reset"]), c.Graphics.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.Graphics.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.Graphics.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.Graphics.prototype.preUpdateCore = c.Component.Core.preUpdate, c.Graphics.prototype.preUpdate = function() {
  5961. return this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5962. }, c.Graphics.prototype.destroy = function(a) {
  5963. this.clear(), c.Component.Destroy.prototype.destroy.call(this, a)
  5964. }, c.Graphics.prototype.drawTriangle = function(a, b) {
  5965. "undefined" == typeof b && (b = !1);
  5966. var d = new c.Polygon(a);
  5967. if (b) {
  5968. var e = new c.Point(this.game.camera.x - a[0].x, this.game.camera.y - a[0].y),
  5969. f = new c.Point(a[1].x - a[0].x, a[1].y - a[0].y),
  5970. g = new c.Point(a[1].x - a[2].x, a[1].y - a[2].y),
  5971. h = g.cross(f);
  5972. e.dot(h) > 0 && this.drawPolygon(d)
  5973. } else this.drawPolygon(d)
  5974. }, c.Graphics.prototype.drawTriangles = function(a, b, d) {
  5975. "undefined" == typeof d && (d = !1);
  5976. var e, f = new c.Point,
  5977. g = new c.Point,
  5978. h = new c.Point,
  5979. i = [];
  5980. if (b)
  5981. if (a[0] instanceof c.Point)
  5982. for (e = 0; e < b.length / 3; e++) i.push(a[b[3 * e]]), i.push(a[b[3 * e + 1]]), i.push(a[b[3 * e + 2]]), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5983. else
  5984. for (e = 0; e < b.length; e++) f.x = a[2 * b[e]], f.y = a[2 * b[e] + 1], i.push(f.copyTo({})), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5985. else if (a[0] instanceof c.Point)
  5986. for (e = 0; e < a.length / 3; e++) this.drawTriangle([a[3 * e], a[3 * e + 1], a[3 * e + 2]], d);
  5987. else
  5988. 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)
  5989. }, c.RenderTexture = function(a, b, d, e, f, g) {
  5990. "undefined" == typeof e && (e = ""), "undefined" == typeof f && (f = c.scaleModes.DEFAULT), "undefined" == typeof g && (g = 1), this.game = a, this.key = e, this.type = c.RENDERTEXTURE, this.matrix = new PIXI.Matrix, PIXI.RenderTexture.call(this, b, d, this.game.renderer, f, g), this.render = c.RenderTexture.prototype.render
  5991. }, c.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), c.RenderTexture.prototype.constructor = c.RenderTexture, c.RenderTexture.prototype.renderXY = function(a, b, c, d) {
  5992. this.matrix.tx = b, this.matrix.ty = c, this.renderer.type === PIXI.WEBGL_RENDERER ? this.renderWebGL(a, this.matrix, d) : this.renderCanvas(a, this.matrix, d)
  5993. }, c.RenderTexture.prototype.render = function(a, b, c) {
  5994. this.matrix.tx = b.x, this.matrix.ty = b.y, this.renderer.type === PIXI.WEBGL_RENDERER ? this.renderWebGL(a, this.matrix, c) : this.renderCanvas(a, this.matrix, c)
  5995. }, c.Text = function(a, b, d, e, f) {
  5996. b = b || 0, d = d || 0, e = e || " ", f = f || {}, e = 0 === e.length ? " " : e.toString(), this.type = c.TEXT, this.physicsType = c.SPRITE, this.padding = new c.Point, this._text = e, this._fontComponents = null, this._lineSpacing = 0, this._charCount = 0, this.colors = [], this.setStyle(f), PIXI.Text.call(this, e, this.style), c.Component.Core.init.call(this, a, b, d, "", null), " " !== e && this.updateText()
  5997. }, c.Text.prototype = Object.create(PIXI.Text.prototype), c.Text.prototype.constructor = c.Text, c.Component.Core.install.call(c.Text.prototype, ["Angle", "AutoCull", "Bounds", "BringToTop", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "Overlap", "PhysicsBody", "Reset", "Smoothed"]), c.Text.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.Text.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.Text.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.Text.prototype.preUpdateCore = c.Component.Core.preUpdate, c.Text.prototype.preUpdate = function() {
  5998. return this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  5999. }, c.Text.prototype.update = function() {}, c.Text.prototype.destroy = function(a) {
  6000. this.texture.destroy(!0), this.canvas && this.canvas.parentNode ? this.canvas.parentNode.removeChild(this.canvas) : (this.canvas = null, this.context = null), c.Component.Destroy.prototype.destroy.call(this, a)
  6001. }, c.Text.prototype.setShadow = function(a, b, c, d) {
  6002. "undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = "rgba(0, 0, 0, 1)"), "undefined" == typeof d && (d = 0), this.style.shadowOffsetX = a, this.style.shadowOffsetY = b, this.style.shadowColor = c, this.style.shadowBlur = d, this.dirty = !0
  6003. }, c.Text.prototype.setStyle = function(a) {
  6004. a = a || {}, a.font = a.font || "bold 20pt Arial", a.backgroundColor = a.backgroundColor || null, 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;
  6005. var b = this.fontToComponents(a.font);
  6006. a.fontStyle && (b.fontStyle = a.fontStyle), a.fontVariant && (b.fontVariant = a.fontVariant), a.fontWeight && (b.fontWeight = a.fontWeight), a.fontSize && ("number" == typeof a.fontSize && (a.fontSize = a.fontSize + "px"), b.fontSize = a.fontSize), this._fontComponents = b, a.font = this.componentsToFont(this._fontComponents), this.style = a, this.dirty = !0
  6007. }, c.Text.prototype.updateText = function() {
  6008. this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
  6009. var a = this.text;
  6010. this.style.wordWrap && (a = this.runWordWrap(this.text));
  6011. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
  6012. var g = this.context.measureText(b[f]).width + this.padding.x;
  6013. c[f] = g, d = Math.max(d, g)
  6014. }
  6015. var h = d + this.style.strokeThickness;
  6016. this.canvas.width = h * this.resolution;
  6017. var i = e.fontSize + this.style.strokeThickness + this.padding.y,
  6018. j = i * b.length,
  6019. k = this._lineSpacing;
  6020. if (0 > k && Math.abs(k) > i && (k = -i), 0 !== k) {
  6021. var l = k * (b.length - 1);
  6022. j += l
  6023. }
  6024. this.canvas.height = j * this.resolution, this.context.scale(this.resolution, this.resolution), navigator.isCocoonJS && this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.style.backgroundColor && (this.context.fillStyle = this.style.backgroundColor, this.context.fillRect(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.textBaseline = "alphabetic", 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.lineWidth = this.style.strokeThickness, this.context.lineCap = "round", this.context.lineJoin = "round";
  6025. var m, n;
  6026. for (this._charCount = 0, f = 0; f < b.length; f++) m = this.style.strokeThickness / 2, n = this.style.strokeThickness / 2 + f * i + e.ascent, f > 0 && (n += k * f), "right" === this.style.align ? m += d - c[f] : "center" === this.style.align && (m += (d - c[f]) / 2), this.colors.length > 0 ? this.updateLine(b[f], m, n) : (this.style.stroke && this.style.strokeThickness && this.context.strokeText(b[f], m, n), this.style.fill && this.context.fillText(b[f], m, n));
  6027. this.updateTexture()
  6028. }, c.Text.prototype.updateLine = function(a, b, c) {
  6029. for (var d = 0; d < a.length; d++) {
  6030. var e = a[d];
  6031. this.colors[this._charCount] && (this.context.fillStyle = this.colors[this._charCount], this.context.strokeStyle = this.colors[this._charCount]), this.style.stroke && this.style.strokeThickness && this.context.strokeText(e, b, c), this.style.fill && this.context.fillText(e, b, c), b += this.context.measureText(e).width, this._charCount++
  6032. }
  6033. }, c.Text.prototype.clearColors = function() {
  6034. this.colors = [], this.dirty = !0
  6035. }, c.Text.prototype.addColor = function(a, b) {
  6036. this.colors[b] = a, this.dirty = !0
  6037. }, c.Text.prototype.runWordWrap = function(a) {
  6038. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  6039. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  6040. var h = this.context.measureText(f[g]).width,
  6041. i = h + this.context.measureText(" ").width;
  6042. i > e ? (g > 0 && (b += "\n"), b += f[g] + " ", e = this.style.wordWrapWidth - h) : (e -= i, b += f[g] + " ")
  6043. }
  6044. d < c.length - 1 && (b += "\n")
  6045. }
  6046. return b
  6047. }, c.Text.prototype.updateFont = function(a) {
  6048. var b = this.componentsToFont(a);
  6049. this.style.font !== b && (this.style.font = b, this.dirty = !0, this.parent && this.updateTransform())
  6050. }, c.Text.prototype.fontToComponents = function(a) {
  6051. var b = a.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);
  6052. return b ? {
  6053. font: a,
  6054. fontStyle: b[1] || "normal",
  6055. fontVariant: b[2] || "normal",
  6056. fontWeight: b[3] || "normal",
  6057. fontSize: b[4] || "medium",
  6058. fontFamily: b[5]
  6059. } : (console.warn("Phaser.Text - unparsable CSS font: " + a), {
  6060. font: a
  6061. })
  6062. }, c.Text.prototype.componentsToFont = function(a) {
  6063. var b, c = [];
  6064. return b = a.fontStyle, b && "normal" !== b && c.push(b), b = a.fontVariant, b && "normal" !== b && c.push(b), b = a.fontWeight, b && "normal" !== b && c.push(b), b = a.fontSize, b && "medium" !== b && c.push(b), b = a.fontFamily, b && c.push(b), c.length || c.push(a.font), c.join(" ")
  6065. }, Object.defineProperty(c.Text.prototype, "text", {
  6066. get: function() {
  6067. return this._text
  6068. },
  6069. set: function(a) {
  6070. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0, this.parent && this.updateTransform())
  6071. }
  6072. }), Object.defineProperty(c.Text.prototype, "cssFont", {
  6073. get: function() {
  6074. return this.componentsToFont(this._fontComponents)
  6075. },
  6076. set: function(a) {
  6077. a = a || "bold 20pt Arial", this._fontComponents = this.fontToComponents(a), this.updateFont(this._fontComponents)
  6078. }
  6079. }), Object.defineProperty(c.Text.prototype, "font", {
  6080. get: function() {
  6081. return this._fontComponents.fontFamily
  6082. },
  6083. set: function(a) {
  6084. a = a || "Arial", a = a.trim(), /^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(a) || /['",]/.exec(a) || (a = "'" + a + "'"), this._fontComponents.fontFamily = a, this.updateFont(this._fontComponents)
  6085. }
  6086. }), Object.defineProperty(c.Text.prototype, "fontSize", {
  6087. get: function() {
  6088. var a = this._fontComponents.fontSize;
  6089. return a && /(?:^0$|px$)/.exec(a) ? parseInt(a, 10) : a
  6090. },
  6091. set: function(a) {
  6092. a = a || "0", "number" == typeof a && (a += "px"), this._fontComponents.fontSize = a, this.updateFont(this._fontComponents)
  6093. }
  6094. }), Object.defineProperty(c.Text.prototype, "fontWeight", {
  6095. get: function() {
  6096. return this._fontComponents.fontWeight || "normal"
  6097. },
  6098. set: function(a) {
  6099. a = a || "normal", this._fontComponents.fontWeight = a, this.updateFont(this._fontComponents)
  6100. }
  6101. }), Object.defineProperty(c.Text.prototype, "fontStyle", {
  6102. get: function() {
  6103. return this._fontComponents.fontStyle || "normal"
  6104. },
  6105. set: function(a) {
  6106. a = a || "normal", this._fontComponents.fontStyle = a, this.updateFont(this._fontComponents)
  6107. }
  6108. }), Object.defineProperty(c.Text.prototype, "fontVariant", {
  6109. get: function() {
  6110. return this._fontComponents.fontVariant || "normal"
  6111. },
  6112. set: function(a) {
  6113. a = a || "normal", this._fontComponents.fontVariant = a, this.updateFont(this._fontComponents)
  6114. }
  6115. }), Object.defineProperty(c.Text.prototype, "fill", {
  6116. get: function() {
  6117. return this.style.fill
  6118. },
  6119. set: function(a) {
  6120. a !== this.style.fill && (this.style.fill = a, this.dirty = !0)
  6121. }
  6122. }), Object.defineProperty(c.Text.prototype, "align", {
  6123. get: function() {
  6124. return this.style.align
  6125. },
  6126. set: function(a) {
  6127. a !== this.style.align && (this.style.align = a, this.dirty = !0)
  6128. }
  6129. }), Object.defineProperty(c.Text.prototype, "stroke", {
  6130. get: function() {
  6131. return this.style.stroke
  6132. },
  6133. set: function(a) {
  6134. a !== this.style.stroke && (this.style.stroke = a, this.dirty = !0)
  6135. }
  6136. }), Object.defineProperty(c.Text.prototype, "strokeThickness", {
  6137. get: function() {
  6138. return this.style.strokeThickness
  6139. },
  6140. set: function(a) {
  6141. a !== this.style.strokeThickness && (this.style.strokeThickness = a, this.dirty = !0)
  6142. }
  6143. }), Object.defineProperty(c.Text.prototype, "wordWrap", {
  6144. get: function() {
  6145. return this.style.wordWrap
  6146. },
  6147. set: function(a) {
  6148. a !== this.style.wordWrap && (this.style.wordWrap = a, this.dirty = !0)
  6149. }
  6150. }), Object.defineProperty(c.Text.prototype, "wordWrapWidth", {
  6151. get: function() {
  6152. return this.style.wordWrapWidth
  6153. },
  6154. set: function(a) {
  6155. a !== this.style.wordWrapWidth && (this.style.wordWrapWidth = a, this.dirty = !0)
  6156. }
  6157. }), Object.defineProperty(c.Text.prototype, "lineSpacing", {
  6158. get: function() {
  6159. return this._lineSpacing
  6160. },
  6161. set: function(a) {
  6162. a !== this._lineSpacing && (this._lineSpacing = parseFloat(a), this.dirty = !0, this.parent && this.updateTransform())
  6163. }
  6164. }), Object.defineProperty(c.Text.prototype, "shadowOffsetX", {
  6165. get: function() {
  6166. return this.style.shadowOffsetX
  6167. },
  6168. set: function(a) {
  6169. a !== this.style.shadowOffsetX && (this.style.shadowOffsetX = a, this.dirty = !0)
  6170. }
  6171. }), Object.defineProperty(c.Text.prototype, "shadowOffsetY", {
  6172. get: function() {
  6173. return this.style.shadowOffsetY
  6174. },
  6175. set: function(a) {
  6176. a !== this.style.shadowOffsetY && (this.style.shadowOffsetY = a, this.dirty = !0)
  6177. }
  6178. }), Object.defineProperty(c.Text.prototype, "shadowColor", {
  6179. get: function() {
  6180. return this.style.shadowColor
  6181. },
  6182. set: function(a) {
  6183. a !== this.style.shadowColor && (this.style.shadowColor = a, this.dirty = !0)
  6184. }
  6185. }), Object.defineProperty(c.Text.prototype, "shadowBlur", {
  6186. get: function() {
  6187. return this.style.shadowBlur
  6188. },
  6189. set: function(a) {
  6190. a !== this.style.shadowBlur && (this.style.shadowBlur = a, this.dirty = !0)
  6191. }
  6192. }), c.BitmapText = function(a, b, d, e, f, g) {
  6193. b = b || 0, d = d || 0, e = e || "", f = f || "", g = g || 32, this.type = c.BITMAPTEXT, this.physicsType = c.SPRITE, this._text = f, this._font = e, this._fontSize = g, this._align = "left", this._tint = 16777215, this._tw = 0, this._th = 0, PIXI.BitmapText.call(this, f), c.Component.Core.init.call(this, a, b, d, "", null)
  6194. }, c.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype), c.BitmapText.prototype.constructor = c.BitmapText, c.Component.Core.install.call(c.BitmapText.prototype, ["Angle", "AutoCull", "Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "PhysicsBody", "Reset"]), c.BitmapText.prototype.preUpdatePhysics = c.Component.PhysicsBody.preUpdate, c.BitmapText.prototype.preUpdateLifeSpan = c.Component.LifeSpan.preUpdate, c.BitmapText.prototype.preUpdateInWorld = c.Component.InWorld.preUpdate, c.BitmapText.prototype.preUpdateCore = c.Component.Core.preUpdate, c.BitmapText.prototype.preUpdate = function() {
  6195. return this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld() ? this.preUpdateCore() : !1
  6196. }, c.BitmapText.prototype.postUpdate = function() {
  6197. c.Component.PhysicsBody.postUpdate.call(this), c.Component.FixedToCamera.postUpdate.call(this), !this.body || this.textWidth === this._tw && this.textHeight === this._th || (this.body.setSize(this.textWidth, this.textHeight), this._tw = this.textWidth, this._th = this.textHeight)
  6198. }, c.BitmapText.prototype.setStyle = function() {
  6199. this.style = {
  6200. align: this._align
  6201. }, this.fontName = this._font, this.fontSize = this._fontSize, this.dirty = !0
  6202. }, Object.defineProperty(c.BitmapText.prototype, "align", {
  6203. get: function() {
  6204. return this._align
  6205. },
  6206. set: function(a) {
  6207. a !== this._align && (this._align = a, this.setStyle())
  6208. }
  6209. }), Object.defineProperty(c.BitmapText.prototype, "tint", {
  6210. get: function() {
  6211. return this._tint
  6212. },
  6213. set: function(a) {
  6214. a !== this._tint && (this._tint = a, this.dirty = !0)
  6215. }
  6216. }), Object.defineProperty(c.BitmapText.prototype, "font", {
  6217. get: function() {
  6218. return this._font
  6219. },
  6220. set: function(a) {
  6221. a !== this._font && (this._font = a.trim(), this.fontName = this._font, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  6222. }
  6223. }), Object.defineProperty(c.BitmapText.prototype, "fontSize", {
  6224. get: function() {
  6225. return this._fontSize
  6226. },
  6227. set: function(a) {
  6228. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  6229. }
  6230. }), Object.defineProperty(c.BitmapText.prototype, "text", {
  6231. get: function() {
  6232. return this._text
  6233. },
  6234. set: function(a) {
  6235. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0)
  6236. }
  6237. }), c.RetroFont = function(a, b, d, e, f, g, h, i, j, k) {
  6238. if (!a.cache.checkImageKey(b)) return !1;
  6239. ("undefined" == typeof g || null === g) && (g = a.cache.getImage(b).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(b), this._text = "", this.grabData = [], this.frameData = new c.FrameData;
  6240. for (var l = this.offsetX, m = this.offsetY, n = 0, o = 0; o < f.length; o++) {
  6241. var p = a.rnd.uuid(),
  6242. q = this.frameData.addFrame(new c.Frame(o, l, m, this.characterWidth, this.characterHeight, "", p));
  6243. this.grabData[f.charCodeAt(o)] = q.index, PIXI.TextureCache[p] = new PIXI.Texture(PIXI.BaseTextureCache[b], {
  6244. x: l,
  6245. y: m,
  6246. width: this.characterWidth,
  6247. height: this.characterHeight
  6248. }), n++, n == this.characterPerRow ? (n = 0, l = this.offsetX, m += this.characterHeight + this.characterSpacingY) : l += this.characterWidth + this.characterSpacingX
  6249. }
  6250. a.cache.updateFrameData(b, this.frameData), this.stamp = new c.Image(a, 0, 0, b, 0), c.RenderTexture.call(this, a, 100, 100, "", c.scaleModes.NEAREST), this.type = c.RETROFONT
  6251. }, c.RetroFont.prototype = Object.create(c.RenderTexture.prototype), c.RetroFont.prototype.constructor = c.RetroFont, c.RetroFont.ALIGN_LEFT = "left", c.RetroFont.ALIGN_RIGHT = "right", c.RetroFont.ALIGN_CENTER = "center", c.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", c.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ", c.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ", c.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789", c.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789", c.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ", c.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39", c.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ", c.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!", c.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", c.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789", c.RetroFont.prototype.setFixedWidth = function(a, b) {
  6252. "undefined" == typeof b && (b = "left"), this.fixedWidth = a, this.align = b
  6253. }, c.RetroFont.prototype.setText = function(a, b, c, d, e, f) {
  6254. 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)
  6255. }, c.RetroFont.prototype.buildRetroFontText = function() {
  6256. var a = 0,
  6257. b = 0;
  6258. if (this.clear(), this.multiLine) {
  6259. var d = this._text.split("\n");
  6260. 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);
  6261. for (var e = 0; e < d.length; e++) {
  6262. switch (this.align) {
  6263. case c.RetroFont.ALIGN_LEFT:
  6264. a = 0;
  6265. break;
  6266. case c.RetroFont.ALIGN_RIGHT:
  6267. a = this.width - d[e].length * (this.characterWidth + this.customSpacingX);
  6268. break;
  6269. case c.RetroFont.ALIGN_CENTER:
  6270. a = this.width / 2 - d[e].length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  6271. }
  6272. 0 > a && (a = 0), this.pasteLine(d[e], a, b, this.customSpacingX), b += this.characterHeight + this.customSpacingY
  6273. }
  6274. } else {
  6275. 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) {
  6276. case c.RetroFont.ALIGN_LEFT:
  6277. a = 0;
  6278. break;
  6279. case c.RetroFont.ALIGN_RIGHT:
  6280. a = this.width - this._text.length * (this.characterWidth + this.customSpacingX);
  6281. break;
  6282. case c.RetroFont.ALIGN_CENTER:
  6283. a = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  6284. }
  6285. this.textureBuffer.clear(), this.pasteLine(this._text, a, 0, this.customSpacingX)
  6286. }
  6287. }, c.RetroFont.prototype.pasteLine = function(a, b, d, e) {
  6288. for (var f = new c.Point, g = 0; g < a.length; g++)
  6289. if (" " == a.charAt(g)) b += this.characterWidth + e;
  6290. else if (this.grabData[a.charCodeAt(g)] >= 0 && (this.stamp.frame = this.grabData[a.charCodeAt(g)], f.set(b, d), this.render(this.stamp, f, !1), b += this.characterWidth + e, b > this.width)) break
  6291. }, c.RetroFont.prototype.getLongestLine = function() {
  6292. var a = 0;
  6293. if (this._text.length > 0)
  6294. for (var b = this._text.split("\n"), c = 0; c < b.length; c++) b[c].length > a && (a = b[c].length);
  6295. return a
  6296. }, c.RetroFont.prototype.removeUnsupportedCharacters = function(a) {
  6297. for (var b = "", c = 0; c < this._text.length; c++) {
  6298. var d = this._text[c],
  6299. e = d.charCodeAt(0);
  6300. (this.grabData[e] >= 0 || !a && "\n" === d) && (b = b.concat(d))
  6301. }
  6302. return b
  6303. }, c.RetroFont.prototype.updateOffset = function(a, b) {
  6304. if (this.offsetX !== a || this.offsetY !== b) {
  6305. 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;
  6306. this.buildRetroFontText()
  6307. }
  6308. }, Object.defineProperty(c.RetroFont.prototype, "text", {
  6309. get: function() {
  6310. return this._text
  6311. },
  6312. set: function(a) {
  6313. var b;
  6314. b = this.autoUpperCase ? a.toUpperCase() : a, b !== this._text && (this._text = b, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
  6315. }
  6316. }), Object.defineProperty(c.RetroFont.prototype, "smoothed", {
  6317. get: function() {
  6318. return this.stamp.smoothed
  6319. },
  6320. set: function(a) {
  6321. this.stamp.smoothed = a, this.buildRetroFontText()
  6322. }
  6323. }), c.Device = function() {
  6324. this.deviceReadyAt = 0, this.initialized = !1, this.desktop = !1, this.iOS = !1, this.cocoonJS = !1, this.cocoonJSApp = !1, this.cordova = !1, this.node = !1, this.nodeWebkit = !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.canvasBitBltShift = null, this.webGL = !1, this.file = !1, this.fileSystem = !1, this.localStorage = !1, this.worker = !1, this.css3D = !1, this.pointerLock = !1, this.typedArray = !1, this.vibration = !1, this.getUserMedia = !1, this.quirksMode = !1, this.touch = !1, this.mspointer = !1, this.wheelEvent = null, 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.LITTLE_ENDIAN = !1, this.support32bit = !1, this.fullscreen = !1, this.requestFullscreen = "", this.cancelFullscreen = "", this.fullscreenKeyboard = !1
  6325. }, c.Device = new c.Device, c.Device.onInitialized = new c.Signal, c.Device.whenReady = function(a, b, c) {
  6326. var d = this._readyCheck;
  6327. if (this.deviceReadyAt || !d) a.call(b, this);
  6328. else if (d._monitor || c) d._queue = d._queue || [], d._queue.push([a, b]);
  6329. else {
  6330. d._monitor = d.bind(this), d._queue = d._queue || [], d._queue.push([a, b]);
  6331. var e = "undefined" != typeof window.cordova,
  6332. f = navigator.isCocoonJS;
  6333. "complete" === document.readyState || "interactive" === document.readyState ? window.setTimeout(d._monitor, 0) : e && !f ? document.addEventListener("deviceready", d._monitor, !1) : (document.addEventListener("DOMContentLoaded", d._monitor, !1), window.addEventListener("load", d._monitor, !1))
  6334. }
  6335. }, c.Device._readyCheck = function() {
  6336. var a = this._readyCheck;
  6337. if (document.body) {
  6338. if (!this.deviceReadyAt) {
  6339. this.deviceReadyAt = Date.now(), document.removeEventListener("deviceready", a._monitor), document.removeEventListener("DOMContentLoaded", a._monitor), window.removeEventListener("load", a._monitor), this._initialize(), this.initialized = !0, this.onInitialized.dispatch(this);
  6340. for (var b; b = a._queue.shift();) {
  6341. var c = b[0],
  6342. d = b[1];
  6343. c.call(d, this)
  6344. }
  6345. this._readyCheck = null, this._initialize = null, this.onInitialized = null
  6346. }
  6347. } else window.setTimeout(a._monitor, 20)
  6348. }, c.Device._initialize = function() {
  6349. function a() {
  6350. var a = navigator.userAgent;
  6351. /Playstation Vita/.test(a) ? k.vita = !0 : /Kindle/.test(a) || /\bKF[A-Z][A-Z]+/.test(a) || /Silk.*Mobile Safari/.test(a) ? k.kindle = !0 : /Android/.test(a) ? k.android = !0 : /CrOS/.test(a) ? k.chromeOS = !0 : /iP[ao]d|iPhone/i.test(a) ? k.iOS = !0 : /Linux/.test(a) ? k.linux = !0 : /Mac OS/.test(a) ? k.macOS = !0 : /Windows/.test(a) && (k.windows = !0, /Windows Phone/i.test(a) && (k.windowsPhone = !0));
  6352. var b = /Silk/.test(a);
  6353. (k.windows || k.macOS || k.linux && !b || k.chromeOS) && (k.desktop = !0), (k.windowsPhone || /Windows NT/i.test(a) && /Touch/i.test(a)) && (k.desktop = !1)
  6354. }
  6355. function b() {
  6356. k.canvas = !!window.CanvasRenderingContext2D || k.cocoonJS;
  6357. try {
  6358. k.localStorage = !!localStorage.getItem
  6359. } catch (a) {
  6360. k.localStorage = !1
  6361. }
  6362. k.file = !!(window.File && window.FileReader && window.FileList && window.Blob), k.fileSystem = !!window.requestFileSystem, k.webGL = function() {
  6363. try {
  6364. var a = document.createElement("canvas");
  6365. return a.screencanvas = !1, !!window.WebGLRenderingContext && (a.getContext("webgl") || a.getContext("experimental-webgl"))
  6366. } catch (b) {
  6367. return !1
  6368. }
  6369. }(), k.webGL = !!k.webGL, k.worker = !!window.Worker, k.pointerLock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document, k.quirksMode = "CSS1Compat" === document.compatMode ? !1 : !0, k.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia), !k.iOS && (k.ie || k.firefox || k.chrome) && (k.canvasBitBltShift = !0), (k.safari || k.mobileSafari) && (k.canvasBitBltShift = !1)
  6370. }
  6371. function c() {
  6372. ("ontouchstart" in document.documentElement || window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1) && (k.touch = !0), (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) && (k.mspointer = !0), k.cocoonJS || ("onwheel" in window || k.ie && "WheelEvent" in window ? k.wheelEvent = "wheel" : "onmousewheel" in window ? k.wheelEvent = "mousewheel" : k.firefox && "MouseScrollEvent" in window && (k.wheelEvent = "DOMMouseScroll"))
  6373. }
  6374. function d() {
  6375. for (var a = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"], b = document.createElement("div"), c = 0; c < a.length; c++)
  6376. if (b[a[c]]) {
  6377. k.fullscreen = !0, k.requestFullscreen = a[c];
  6378. break
  6379. }
  6380. var d = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
  6381. if (k.fullscreen)
  6382. for (var c = 0; c < d.length; c++)
  6383. if (document[d[c]]) {
  6384. k.cancelFullscreen = d[c];
  6385. break
  6386. }
  6387. window.Element && Element.ALLOW_KEYBOARD_INPUT && (k.fullscreenKeyboard = !0)
  6388. }
  6389. function e() {
  6390. var a = navigator.userAgent;
  6391. if (/Arora/.test(a) ? k.arora = !0 : /Chrome/.test(a) ? k.chrome = !0 : /Epiphany/.test(a) ? k.epiphany = !0 : /Firefox/.test(a) ? k.firefox = !0 : /AppleWebKit/.test(a) && k.iOS ? k.mobileSafari = !0 : /MSIE (\d+\.\d+);/.test(a) ? (k.ie = !0, k.ieVersion = parseInt(RegExp.$1, 10)) : /Midori/.test(a) ? k.midori = !0 : /Opera/.test(a) ? k.opera = !0 : /Safari/.test(a) ? k.safari = !0 : /Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(a) && (k.ie = !0, k.trident = !0, k.tridentVersion = parseInt(RegExp.$1, 10), k.ieVersion = parseInt(RegExp.$3, 10)), /Silk/.test(a) && (k.silk = !0), navigator.standalone && (k.webApp = !0), "undefined" != typeof window.cordova && (k.cordova = !0), "undefined" != typeof process && "undefined" != typeof require && (k.node = !0), k.node) try {
  6392. k.nodeWebkit = "undefined" != typeof require("nw.gui")
  6393. } catch (b) {
  6394. k.nodeWebkit = !1
  6395. }
  6396. if (navigator.isCocoonJS && (k.cocoonJS = !0), k.cocoonJS) try {
  6397. k.cocoonJSApp = "undefined" != typeof CocoonJS
  6398. } catch (b) {
  6399. k.cocoonJSApp = !1
  6400. }
  6401. "undefined" != typeof window.ejecta && (k.ejecta = !0), /Crosswalk/.test(a) && (k.crosswalk = !0)
  6402. }
  6403. function f() {
  6404. k.audioData = !!window.Audio, k.webAudio = !(!window.AudioContext && !window.webkitAudioContext);
  6405. var a = document.createElement("audio"),
  6406. b = !1;
  6407. try {
  6408. (b = !!a.canPlayType) && (a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (k.ogg = !0), (a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, "") || a.canPlayType("audio/opus;").replace(/^no$/, "")) && (k.opus = !0), a.canPlayType("audio/mpeg;").replace(/^no$/, "") && (k.mp3 = !0), a.canPlayType('audio/wav; codecs="1"').replace(/^no$/, "") && (k.wav = !0), (a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/aac;").replace(/^no$/, "")) && (k.m4a = !0), a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "") && (k.webm = !0))
  6409. } catch (c) {}
  6410. }
  6411. function g() {
  6412. k.pixelRatio = window.devicePixelRatio || 1, k.iPhone = -1 != navigator.userAgent.toLowerCase().indexOf("iphone"), k.iPhone4 = 2 == k.pixelRatio && k.iPhone, k.iPad = -1 != navigator.userAgent.toLowerCase().indexOf("ipad"), k.typedArray = "undefined" != typeof Int8Array ? !0 : !1, "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array && "undefined" != typeof Uint32Array && (k.littleEndian = h(), k.LITTLE_ENDIAN = k.littleEndian), k.support32bit = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8ClampedArray && "undefined" != typeof Int32Array && null !== k.littleEndian && i(), navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate, navigator.vibrate && (k.vibration = !0)
  6413. }
  6414. function h() {
  6415. var a = new ArrayBuffer(4),
  6416. b = new Uint8Array(a),
  6417. c = new Uint32Array(a);
  6418. return b[0] = 161, b[1] = 178, b[2] = 195, b[3] = 212, 3569595041 == c[0] ? !0 : 2712847316 == c[0] ? !1 : null
  6419. }
  6420. function i() {
  6421. if ("undefined" == typeof Uint8ClampedArray) return !1;
  6422. var a = document.createElement("canvas"),
  6423. b = a.getContext("2d");
  6424. if (!b) return !1;
  6425. var c = b.createImageData(1, 1);
  6426. return c.data instanceof Uint8ClampedArray
  6427. }
  6428. function j() {
  6429. var a, b = document.createElement("p"),
  6430. c = {
  6431. webkitTransform: "-webkit-transform",
  6432. OTransform: "-o-transform",
  6433. msTransform: "-ms-transform",
  6434. MozTransform: "-moz-transform",
  6435. transform: "transform"
  6436. };
  6437. document.body.insertBefore(b, null);
  6438. for (var d in c) void 0 !== b.style[d] && (b.style[d] = "translate3d(1px,1px,1px)", a = window.getComputedStyle(b).getPropertyValue(c[d]));
  6439. document.body.removeChild(b), k.css3D = void 0 !== a && a.length > 0 && "none" !== a
  6440. }
  6441. var k = this;
  6442. a(), f(), e(), j(), g(), b(), d(), c()
  6443. }, c.Device.canPlayAudio = function(a) {
  6444. return "mp3" == a && this.mp3 ? !0 : "ogg" == a && (this.ogg || this.opus) ? !0 : "m4a" == a && this.m4a ? !0 : "opus" == a && this.opus ? !0 : "wav" == a && this.wav ? !0 : "webm" == a && this.webm ? !0 : !1
  6445. }, c.Device.isConsoleOpen = function() {
  6446. return window.console && window.console.firebug ? !0 : window.console && (console.profile(), console.profileEnd(), console.clear && console.clear(), console.profiles) ? console.profiles.length > 0 : !1
  6447. }, c.Device.isAndroidStockBrowser = function() {
  6448. var a = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
  6449. return a && a[1] < 537
  6450. }, c.DOM = {
  6451. getOffset: function(a, b) {
  6452. b = b || new c.Point;
  6453. var d = a.getBoundingClientRect(),
  6454. e = c.DOM.scrollY,
  6455. f = c.DOM.scrollX,
  6456. g = document.documentElement.clientTop,
  6457. h = document.documentElement.clientLeft;
  6458. return b.x = d.left + f - h, b.y = d.top + e - g, b
  6459. },
  6460. getBounds: function(a, b) {
  6461. return "undefined" == typeof b && (b = 0), a = a && !a.nodeType ? a[0] : a, a && 1 === a.nodeType ? this.calibrate(a.getBoundingClientRect(), b) : !1
  6462. },
  6463. calibrate: function(a, b) {
  6464. b = +b || 0;
  6465. var c = {
  6466. width: 0,
  6467. height: 0,
  6468. left: 0,
  6469. right: 0,
  6470. top: 0,
  6471. bottom: 0
  6472. };
  6473. return c.width = (c.right = a.right + b) - (c.left = a.left - b), c.height = (c.bottom = a.bottom + b) - (c.top = a.top - b), c
  6474. },
  6475. getAspectRatio: function(a) {
  6476. a = null == a ? this.visualBounds : 1 === a.nodeType ? this.getBounds(a) : a;
  6477. var b = a.width,
  6478. c = a.height;
  6479. return "function" == typeof b && (b = b.call(a)), "function" == typeof c && (c = c.call(a)), b / c
  6480. },
  6481. inLayoutViewport: function(a, b) {
  6482. var c = this.getBounds(a, b);
  6483. return !!c && c.bottom >= 0 && c.right >= 0 && c.top <= this.layoutBounds.width && c.left <= this.layoutBounds.height
  6484. },
  6485. getScreenOrientation: function(a) {
  6486. var b = window.screen,
  6487. c = b.orientation || b.mozOrientation || b.msOrientation;
  6488. if (c && "string" == typeof c.type) return c.type;
  6489. if ("string" == typeof c) return c;
  6490. var d = "portrait-primary",
  6491. e = "landscape-primary";
  6492. if ("screen" === a) return b.height > b.width ? d : e;
  6493. if ("viewport" === a) return this.visualBounds.height > this.visualBounds.width ? d : e;
  6494. if ("window.orientation" === a && "number" == typeof window.orientation) return 0 === window.orientation || 180 === window.orientation ? d : e;
  6495. if (window.matchMedia) {
  6496. if (window.matchMedia("(orientation: portrait)").matches) return d;
  6497. if (window.matchMedia("(orientation: landscape)").matches) return e
  6498. }
  6499. return this.visualBounds.height > this.visualBounds.width ? d : e
  6500. },
  6501. visualBounds: new c.Rectangle,
  6502. layoutBounds: new c.Rectangle,
  6503. documentBounds: new c.Rectangle
  6504. }, c.Device.whenReady(function(a) {
  6505. var b = window && "pageXOffset" in window ? function() {
  6506. return window.pageXOffset
  6507. } : function() {
  6508. return document.documentElement.scrollLeft
  6509. },
  6510. d = window && "pageYOffset" in window ? function() {
  6511. return window.pageYOffset
  6512. } : function() {
  6513. return document.documentElement.scrollTop
  6514. };
  6515. Object.defineProperty(c.DOM, "scrollX", {
  6516. get: b
  6517. }), Object.defineProperty(c.DOM, "scrollY", {
  6518. get: d
  6519. }), Object.defineProperty(c.DOM.visualBounds, "x", {
  6520. get: b
  6521. }), Object.defineProperty(c.DOM.visualBounds, "y", {
  6522. get: d
  6523. }), Object.defineProperty(c.DOM.layoutBounds, "x", {
  6524. value: 0
  6525. }), Object.defineProperty(c.DOM.layoutBounds, "y", {
  6526. value: 0
  6527. });
  6528. var e = a.desktop && document.documentElement.clientWidth <= window.innerWidth && document.documentElement.clientHeight <= window.innerHeight;
  6529. if (e) {
  6530. var f = function() {
  6531. return Math.max(window.innerWidth, document.documentElement.clientWidth)
  6532. },
  6533. g = function() {
  6534. return Math.max(window.innerHeight, document.documentElement.clientHeight)
  6535. };
  6536. Object.defineProperty(c.DOM.visualBounds, "width", {
  6537. get: f
  6538. }), Object.defineProperty(c.DOM.visualBounds, "height", {
  6539. get: g
  6540. }), Object.defineProperty(c.DOM.layoutBounds, "width", {
  6541. get: f
  6542. }), Object.defineProperty(c.DOM.layoutBounds, "height", {
  6543. get: g
  6544. })
  6545. } else Object.defineProperty(c.DOM.visualBounds, "width", {
  6546. get: function() {
  6547. return window.innerWidth
  6548. }
  6549. }), Object.defineProperty(c.DOM.visualBounds, "height", {
  6550. get: function() {
  6551. return window.innerHeight
  6552. }
  6553. }), Object.defineProperty(c.DOM.layoutBounds, "width", {
  6554. get: function() {
  6555. var a = document.documentElement.clientWidth,
  6556. b = window.innerWidth;
  6557. return b > a ? b : a
  6558. }
  6559. }), Object.defineProperty(c.DOM.layoutBounds, "height", {
  6560. get: function() {
  6561. var a = document.documentElement.clientHeight,
  6562. b = window.innerHeight;
  6563. return b > a ? b : a
  6564. }
  6565. });
  6566. Object.defineProperty(c.DOM.documentBounds, "x", {
  6567. value: 0
  6568. }), Object.defineProperty(c.DOM.documentBounds, "y", {
  6569. value: 0
  6570. }), Object.defineProperty(c.DOM.documentBounds, "width", {
  6571. get: function() {
  6572. var a = document.documentElement;
  6573. return Math.max(a.clientWidth, a.offsetWidth, a.scrollWidth)
  6574. }
  6575. }), Object.defineProperty(c.DOM.documentBounds, "height", {
  6576. get: function() {
  6577. var a = document.documentElement;
  6578. return Math.max(a.clientHeight, a.offsetHeight, a.scrollHeight)
  6579. }
  6580. })
  6581. }, null, !0), c.Canvas = {
  6582. create: function(a, b, c) {
  6583. a = a || 256, b = b || 256;
  6584. var d = document.createElement("canvas");
  6585. return "string" == typeof c && "" !== c && (d.id = c), d.width = a, d.height = b, d.style.display = "block", d
  6586. },
  6587. setBackgroundColor: function(a, b) {
  6588. return b = b || "rgb(0,0,0)", a.style.backgroundColor = b, a
  6589. },
  6590. setTouchAction: function(a, b) {
  6591. return b = b || "none", a.style.msTouchAction = b, a.style["ms-touch-action"] = b, a.style["touch-action"] = b, a
  6592. },
  6593. setUserSelect: function(a, b) {
  6594. 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
  6595. },
  6596. addToDOM: function(a, b, c) {
  6597. var d;
  6598. 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
  6599. },
  6600. removeFromDOM: function(a) {
  6601. a.parentNode && a.parentNode.removeChild(a)
  6602. },
  6603. setTransform: function(a, b, c, d, e, f, g) {
  6604. return a.setTransform(d, f, g, e, b, c), a
  6605. },
  6606. setSmoothingEnabled: function(a, b) {
  6607. return a.imageSmoothingEnabled = b, a.mozImageSmoothingEnabled = b, a.oImageSmoothingEnabled = b, a.webkitImageSmoothingEnabled = b, a.msImageSmoothingEnabled = b, a
  6608. },
  6609. getSmoothingEnabled: function(a) {
  6610. return a.imageSmoothingEnabled || a.mozImageSmoothingEnabled || a.oImageSmoothingEnabled || a.webkitImageSmoothingEnabled || a.msImageSmoothingEnabled
  6611. },
  6612. setImageRenderingCrisp: function(a) {
  6613. 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["image-rendering"] = "pixelated", a.style.msInterpolationMode = "nearest-neighbor", a
  6614. },
  6615. setImageRenderingBicubic: function(a) {
  6616. return a.style["image-rendering"] = "auto", a.style.msInterpolationMode = "bicubic", a
  6617. }
  6618. }, c.Canvas.getOffset = c.DOM.getOffset, c.Canvas.getAspectRatio = c.DOM.getAspectRatio, c.RequestAnimationFrame = function(a, b) {
  6619. "undefined" == typeof b && (b = !1), this.game = a, this.isRunning = !1, this.forceSetTimeOut = b;
  6620. 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"];
  6621. this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
  6622. }, c.RequestAnimationFrame.prototype = {
  6623. start: function() {
  6624. this.isRunning = !0;
  6625. var a = this;
  6626. !window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() {
  6627. return a.updateSetTimeout()
  6628. }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(b) {
  6629. return a.updateRAF(b)
  6630. }, this._timeOutID = window.requestAnimationFrame(this._onLoop))
  6631. },
  6632. updateRAF: function(a) {
  6633. this.game.update(Math.floor(a)), this._timeOutID = window.requestAnimationFrame(this._onLoop)
  6634. },
  6635. updateSetTimeout: function() {
  6636. this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)
  6637. },
  6638. stop: function() {
  6639. this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1
  6640. },
  6641. isSetTimeOut: function() {
  6642. return this._isSetTimeOut
  6643. },
  6644. isRAF: function() {
  6645. return this._isSetTimeOut === !1
  6646. }
  6647. }, c.RequestAnimationFrame.prototype.constructor = c.RequestAnimationFrame, c.Math = {
  6648. PI2: 2 * Math.PI,
  6649. fuzzyEqual: function(a, b, c) {
  6650. return "undefined" == typeof c && (c = 1e-4), Math.abs(a - b) < c
  6651. },
  6652. fuzzyLessThan: function(a, b, c) {
  6653. return "undefined" == typeof c && (c = 1e-4), b + c > a
  6654. },
  6655. fuzzyGreaterThan: function(a, b, c) {
  6656. return "undefined" == typeof c && (c = 1e-4), a > b - c
  6657. },
  6658. fuzzyCeil: function(a, b) {
  6659. return "undefined" == typeof b && (b = 1e-4), Math.ceil(a - b)
  6660. },
  6661. fuzzyFloor: function(a, b) {
  6662. return "undefined" == typeof b && (b = 1e-4), Math.floor(a + b)
  6663. },
  6664. average: function() {
  6665. for (var a = 0, b = 0; b < arguments.length; b++) a += +arguments[b];
  6666. return a / arguments.length
  6667. },
  6668. truncate: function(a) {
  6669. return Math.trunc(a)
  6670. },
  6671. shear: function(a) {
  6672. return a % 1
  6673. },
  6674. snapTo: function(a, b, c) {
  6675. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.round(a / b), c + a)
  6676. },
  6677. snapToFloor: function(a, b, c) {
  6678. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.floor(a / b), c + a)
  6679. },
  6680. snapToCeil: function(a, b, c) {
  6681. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.ceil(a / b), c + a)
  6682. },
  6683. snapToInArray: function(a, b, d) {
  6684. return "undefined" == typeof d && (d = !0), d && b.sort(), c.ArrayUtils.findClosest(a, b)
  6685. },
  6686. roundTo: function(a, b, c) {
  6687. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6688. var d = Math.pow(c, -b);
  6689. return Math.round(a * d) / d
  6690. },
  6691. floorTo: function(a, b, c) {
  6692. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6693. var d = Math.pow(c, -b);
  6694. return Math.floor(a * d) / d
  6695. },
  6696. ceilTo: function(a, b, c) {
  6697. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6698. var d = Math.pow(c, -b);
  6699. return Math.ceil(a * d) / d
  6700. },
  6701. interpolateFloat: function(a, b, c) {
  6702. return (b - a) * c + a
  6703. },
  6704. angleBetween: function(a, b, c, d) {
  6705. return Math.atan2(d - b, c - a)
  6706. },
  6707. angleBetweenY: function(a, b, c, d) {
  6708. return Math.atan2(c - a, d - b)
  6709. },
  6710. angleBetweenPoints: function(a, b) {
  6711. return Math.atan2(b.y - a.y, b.x - a.x)
  6712. },
  6713. angleBetweenPointsY: function(a, b) {
  6714. return Math.atan2(b.x - a.x, b.y - a.y)
  6715. },
  6716. reverseAngle: function(a) {
  6717. return this.normalizeAngle(a + Math.PI, !0)
  6718. },
  6719. normalizeAngle: function(a) {
  6720. return a %= 2 * Math.PI, a >= 0 ? a : a + 2 * Math.PI
  6721. },
  6722. normalizeLatitude: function(a) {
  6723. return c.Math.clamp(a, -90, 90)
  6724. },
  6725. normalizeLongitude: function(a) {
  6726. return c.Math.wrap(a, -180, 180)
  6727. },
  6728. chanceRoll: function(a) {
  6729. return c.Utils.chanceRoll(a)
  6730. },
  6731. numberArray: function(a, b) {
  6732. return c.ArrayUtils.numberArray(a, b)
  6733. },
  6734. numberArrayStep: function(a, b, d) {
  6735. return c.ArrayUtils.numberArrayStep(a, b, d)
  6736. },
  6737. maxAdd: function(a, b, c) {
  6738. return Math.min(a + b, c)
  6739. },
  6740. minSub: function(a, b, c) {
  6741. return Math.max(a - b, c)
  6742. },
  6743. wrap: function(a, b, c) {
  6744. var d = c - b;
  6745. if (0 >= d) return 0;
  6746. var e = (a - b) % d;
  6747. return 0 > e && (e += d), e + b
  6748. },
  6749. wrapValue: function(a, b, c) {
  6750. var d;
  6751. return a = Math.abs(a), b = Math.abs(b), c = Math.abs(c), d = (a + b) % c
  6752. },
  6753. limitValue: function(a, b, d) {
  6754. return c.Math.clamp(a, b, d)
  6755. },
  6756. randomSign: function() {
  6757. return c.Utils.randomChoice(-1, 1)
  6758. },
  6759. isOdd: function(a) {
  6760. return 1 & a
  6761. },
  6762. isEven: function(a) {
  6763. return !(1 & a)
  6764. },
  6765. min: function() {
  6766. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  6767. else var a = arguments;
  6768. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] < a[c] && (c = b);
  6769. return a[c]
  6770. },
  6771. max: function() {
  6772. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  6773. else var a = arguments;
  6774. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] > a[c] && (c = b);
  6775. return a[c]
  6776. },
  6777. minProperty: function(a) {
  6778. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  6779. else var b = arguments.slice(1);
  6780. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] < b[d][a] && (d = c);
  6781. return b[d][a]
  6782. },
  6783. maxProperty: function(a) {
  6784. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  6785. else var b = arguments.slice(1);
  6786. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] > b[d][a] && (d = c);
  6787. return b[d][a]
  6788. },
  6789. wrapAngle: function(a, b) {
  6790. return b ? this.wrap(a, -Math.PI, Math.PI) : this.wrap(a, -180, 180)
  6791. },
  6792. angleLimit: function(a, b, c) {
  6793. var d = a;
  6794. return a > c ? d = c : b > a && (d = b), d
  6795. },
  6796. linearInterpolation: function(a, b) {
  6797. var c = a.length - 1,
  6798. d = c * b,
  6799. e = Math.floor(d);
  6800. 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)
  6801. },
  6802. bezierInterpolation: function(a, b) {
  6803. 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);
  6804. return c
  6805. },
  6806. catmullRomInterpolation: function(a, b) {
  6807. var c = a.length - 1,
  6808. d = c * b,
  6809. e = Math.floor(d);
  6810. 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)
  6811. },
  6812. linear: function(a, b, c) {
  6813. return (b - a) * c + a
  6814. },
  6815. bernstein: function(a, b) {
  6816. return this.factorial(a) / this.factorial(b) / this.factorial(a - b)
  6817. },
  6818. factorial: function(a) {
  6819. if (0 === a) return 1;
  6820. for (var b = a; --a;) b *= a;
  6821. return b
  6822. },
  6823. catmullRom: function(a, b, c, d, e) {
  6824. var f = .5 * (c - a),
  6825. g = .5 * (d - b),
  6826. h = e * e,
  6827. i = e * h;
  6828. return (2 * b - 2 * c + f + g) * i + (-3 * b + 3 * c - 2 * f - g) * h + f * e + b
  6829. },
  6830. difference: function(a, b) {
  6831. return Math.abs(a - b)
  6832. },
  6833. getRandom: function(a, b, d) {
  6834. return c.ArrayUtils.getRandomItem(a, b, d)
  6835. },
  6836. removeRandom: function(a, b, d) {
  6837. return c.ArrayUtils.removeRandomItem(a, b, d)
  6838. },
  6839. floor: function(a) {
  6840. return Math.trunc(a)
  6841. },
  6842. ceil: function(a) {
  6843. return c.Math.roundAwayFromZero(a)
  6844. },
  6845. roundAwayFromZero: function(a) {
  6846. return a > 0 ? Math.ceil(a) : Math.floor(a)
  6847. },
  6848. sinCosGenerator: function(a, b, c, d) {
  6849. "undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1);
  6850. 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;
  6851. return {
  6852. sin: i,
  6853. cos: h,
  6854. length: a
  6855. }
  6856. },
  6857. shift: function(a) {
  6858. var b = a.shift();
  6859. return a.push(b), b
  6860. },
  6861. shuffleArray: function(a) {
  6862. return c.ArrayUtils.shuffle(a)
  6863. },
  6864. distance: function(a, b, c, d) {
  6865. var e = a - c,
  6866. f = b - d;
  6867. return Math.sqrt(e * e + f * f)
  6868. },
  6869. distancePow: function(a, b, c, d, e) {
  6870. return "undefined" == typeof e && (e = 2), Math.sqrt(Math.pow(c - a, e) + Math.pow(d - b, e))
  6871. },
  6872. distanceRounded: function(a, b, d, e) {
  6873. return Math.round(c.Math.distance(a, b, d, e))
  6874. },
  6875. clamp: function(a, b, c) {
  6876. return b > a ? b : a > c ? c : a
  6877. },
  6878. clampBottom: function(a, b) {
  6879. return b > a ? b : a
  6880. },
  6881. within: function(a, b, c) {
  6882. return Math.abs(a - b) <= c
  6883. },
  6884. mapLinear: function(a, b, c, d, e) {
  6885. return d + (a - b) * (e - d) / (c - b)
  6886. },
  6887. smoothstep: function(a, b, c) {
  6888. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * (3 - 2 * a)
  6889. },
  6890. smootherstep: function(a, b, c) {
  6891. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * a * (a * (6 * a - 15) + 10)
  6892. },
  6893. sign: function(a) {
  6894. return 0 > a ? -1 : a > 0 ? 1 : 0
  6895. },
  6896. percent: function(a, b, c) {
  6897. return "undefined" == typeof c && (c = 0), a > b || c > b ? 1 : c > a || c > a ? 0 : (a - c) / b
  6898. }
  6899. };
  6900. var j = Math.PI / 180,
  6901. k = 180 / Math.PI;
  6902. c.Math.degToRad = function(a) {
  6903. return a * j
  6904. }, c.Math.radToDeg = function(a) {
  6905. return a * k
  6906. }, c.RandomDataGenerator = function(a) {
  6907. "undefined" == typeof a && (a = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.sow(a)
  6908. }, c.RandomDataGenerator.prototype = {
  6909. rnd: function() {
  6910. var a = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c;
  6911. return this.c = 0 | a, this.s0 = this.s1, this.s1 = this.s2, this.s2 = a - this.c, this.s2
  6912. },
  6913. sow: function(a) {
  6914. if (this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1, a)
  6915. for (var b = 0; b < a.length && null != a[b]; b++) {
  6916. var c = a[b];
  6917. this.s0 -= this.hash(c), this.s0 += ~~(this.s0 < 0), this.s1 -= this.hash(c), this.s1 += ~~(this.s1 < 0), this.s2 -= this.hash(c), this.s2 += ~~(this.s2 < 0)
  6918. }
  6919. },
  6920. hash: function(a) {
  6921. var b, c, d;
  6922. 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;
  6923. return 2.3283064365386963e-10 * (d >>> 0)
  6924. },
  6925. integer: function() {
  6926. return 4294967296 * this.rnd.apply(this)
  6927. },
  6928. frac: function() {
  6929. return this.rnd.apply(this) + 1.1102230246251565e-16 * (2097152 * this.rnd.apply(this) | 0)
  6930. },
  6931. real: function() {
  6932. return this.integer() + this.frac()
  6933. },
  6934. integerInRange: function(a, b) {
  6935. return Math.floor(this.realInRange(0, b - a + 1) + a)
  6936. },
  6937. between: function(a, b) {
  6938. return this.integerInRange(a, b)
  6939. },
  6940. realInRange: function(a, b) {
  6941. return this.frac() * (b - a) + a
  6942. },
  6943. normal: function() {
  6944. return 1 - 2 * this.frac()
  6945. },
  6946. uuid: function() {
  6947. var a = "",
  6948. b = "";
  6949. for (b = a = ""; a++ < 36; b += ~a % 5 | 3 * a & 4 ? (15 ^ a ? 8 ^ this.frac() * (20 ^ a ? 16 : 4) : 4).toString(16) : "-");
  6950. return b
  6951. },
  6952. pick: function(a) {
  6953. return a[this.integerInRange(0, a.length - 1)]
  6954. },
  6955. weightedPick: function(a) {
  6956. return a[~~(Math.pow(this.frac(), 2) * (a.length - 1))]
  6957. },
  6958. timestamp: function(a, b) {
  6959. return this.realInRange(a || 9466848e5, b || 1577862e6)
  6960. },
  6961. angle: function() {
  6962. return this.integerInRange(-180, 180)
  6963. }
  6964. }, c.RandomDataGenerator.prototype.constructor = c.RandomDataGenerator, c.QuadTree = function(a, b, c, d, e, f, g) {
  6965. 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)
  6966. }, c.QuadTree.prototype = {
  6967. reset: function(a, b, c, d, e, f, g) {
  6968. this.maxObjects = e || 10, this.maxLevels = f || 4, this.level = g || 0, this.bounds = {
  6969. x: Math.round(a),
  6970. y: Math.round(b),
  6971. width: c,
  6972. height: d,
  6973. subWidth: Math.floor(c / 2),
  6974. subHeight: Math.floor(d / 2),
  6975. right: Math.round(a) + Math.floor(c / 2),
  6976. bottom: Math.round(b) + Math.floor(d / 2)
  6977. }, this.objects.length = 0, this.nodes.length = 0
  6978. },
  6979. populate: function(a) {
  6980. a.forEach(this.populateHandler, this, !0)
  6981. },
  6982. populateHandler: function(a) {
  6983. a.body && a.exists && this.insert(a.body)
  6984. },
  6985. split: function() {
  6986. this.nodes[0] = new c.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[1] = new c.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[2] = new c.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[3] = new c.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1)
  6987. },
  6988. insert: function(a) {
  6989. var b, c = 0;
  6990. if (null != this.nodes[0] && (b = this.getIndex(a), -1 !== b)) return void this.nodes[b].insert(a);
  6991. if (this.objects.push(a), this.objects.length > this.maxObjects && this.level < this.maxLevels)
  6992. 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++
  6993. },
  6994. getIndex: function(a) {
  6995. var b = -1;
  6996. 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
  6997. },
  6998. retrieve: function(a) {
  6999. if (a instanceof c.Rectangle) var b = this.objects,
  7000. d = this.getIndex(a);
  7001. else {
  7002. if (!a.body) return this._empty;
  7003. var b = this.objects,
  7004. d = this.getIndex(a.body)
  7005. }
  7006. return this.nodes[0] && (-1 !== d ? b = b.concat(this.nodes[d].retrieve(a)) : (b = b.concat(this.nodes[0].retrieve(a)), b = b.concat(this.nodes[1].retrieve(a)), b = b.concat(this.nodes[2].retrieve(a)), b = b.concat(this.nodes[3].retrieve(a)))), b
  7007. },
  7008. clear: function() {
  7009. this.objects.length = 0;
  7010. for (var a = this.nodes.length; a--;) this.nodes[a].clear(), this.nodes.splice(a, 1);
  7011. this.nodes.length = 0
  7012. }
  7013. }, c.QuadTree.prototype.constructor = c.QuadTree, c.Net = function(a) {
  7014. this.game = a
  7015. }, c.Net.prototype = {
  7016. getHostName: function() {
  7017. return window.location && window.location.hostname ? window.location.hostname : null
  7018. },
  7019. checkDomainName: function(a) {
  7020. return -1 !== window.location.hostname.indexOf(a)
  7021. },
  7022. updateQueryString: function(a, b, c, d) {
  7023. "undefined" == typeof c && (c = !1), ("undefined" == typeof d || "" === d) && (d = window.location.href);
  7024. var e = "",
  7025. f = new RegExp("([?|&])" + a + "=.*?(&|#|$)(.*)", "gi");
  7026. if (f.test(d)) e = "undefined" != typeof b && null !== b ? d.replace(f, "$1" + a + "=" + b + "$2$3") : d.replace(f, "$1$3").replace(/(&|\?)$/, "");
  7027. else if ("undefined" != typeof b && null !== b) {
  7028. var g = -1 !== d.indexOf("?") ? "&" : "?",
  7029. h = d.split("#");
  7030. d = h[0] + g + a + "=" + b, h[1] && (d += "#" + h[1]), e = d
  7031. } else e = d;
  7032. return c ? void(window.location.href = e) : e
  7033. },
  7034. getQueryString: function(a) {
  7035. "undefined" == typeof a && (a = "");
  7036. var b = {},
  7037. c = location.search.substring(1).split("&");
  7038. for (var d in c) {
  7039. var e = c[d].split("=");
  7040. if (e.length > 1) {
  7041. if (a && a == this.decodeURI(e[0])) return this.decodeURI(e[1]);
  7042. b[this.decodeURI(e[0])] = this.decodeURI(e[1])
  7043. }
  7044. }
  7045. return b
  7046. },
  7047. decodeURI: function(a) {
  7048. return decodeURIComponent(a.replace(/\+/g, " "))
  7049. }
  7050. }, c.Net.prototype.constructor = c.Net, c.TweenManager = function(a) {
  7051. this.game = a, this._tweens = [], this._add = [], this.easeMap = {
  7052. Power0: c.Easing.Power0,
  7053. Power1: c.Easing.Power1,
  7054. Power2: c.Easing.Power2,
  7055. Power3: c.Easing.Power3,
  7056. Power4: c.Easing.Power4,
  7057. Linear: c.Easing.Linear.None,
  7058. Quad: c.Easing.Quadratic.Out,
  7059. Cubic: c.Easing.Cubic.Out,
  7060. Quart: c.Easing.Quartic.Out,
  7061. Quint: c.Easing.Quintic.Out,
  7062. Sine: c.Easing.Sinusoidal.Out,
  7063. Expo: c.Easing.Exponential.Out,
  7064. Circ: c.Easing.Circular.Out,
  7065. Elastic: c.Easing.Elastic.Out,
  7066. Back: c.Easing.Back.Out,
  7067. Bounce: c.Easing.Bounce.Out,
  7068. "Quad.easeIn": c.Easing.Quadratic.In,
  7069. "Cubic.easeIn": c.Easing.Cubic.In,
  7070. "Quart.easeIn": c.Easing.Quartic.In,
  7071. "Quint.easeIn": c.Easing.Quintic.In,
  7072. "Sine.easeIn": c.Easing.Sinusoidal.In,
  7073. "Expo.easeIn": c.Easing.Exponential.In,
  7074. "Circ.easeIn": c.Easing.Circular.In,
  7075. "Elastic.easeIn": c.Easing.Elastic.In,
  7076. "Back.easeIn": c.Easing.Back.In,
  7077. "Bounce.easeIn": c.Easing.Bounce.In,
  7078. "Quad.easeOut": c.Easing.Quadratic.Out,
  7079. "Cubic.easeOut": c.Easing.Cubic.Out,
  7080. "Quart.easeOut": c.Easing.Quartic.Out,
  7081. "Quint.easeOut": c.Easing.Quintic.Out,
  7082. "Sine.easeOut": c.Easing.Sinusoidal.Out,
  7083. "Expo.easeOut": c.Easing.Exponential.Out,
  7084. "Circ.easeOut": c.Easing.Circular.Out,
  7085. "Elastic.easeOut": c.Easing.Elastic.Out,
  7086. "Back.easeOut": c.Easing.Back.Out,
  7087. "Bounce.easeOut": c.Easing.Bounce.Out,
  7088. "Quad.easeInOut": c.Easing.Quadratic.InOut,
  7089. "Cubic.easeInOut": c.Easing.Cubic.InOut,
  7090. "Quart.easeInOut": c.Easing.Quartic.InOut,
  7091. "Quint.easeInOut": c.Easing.Quintic.InOut,
  7092. "Sine.easeInOut": c.Easing.Sinusoidal.InOut,
  7093. "Expo.easeInOut": c.Easing.Exponential.InOut,
  7094. "Circ.easeInOut": c.Easing.Circular.InOut,
  7095. "Elastic.easeInOut": c.Easing.Elastic.InOut,
  7096. "Back.easeInOut": c.Easing.Back.InOut,
  7097. "Bounce.easeInOut": c.Easing.Bounce.InOut
  7098. }, this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this)
  7099. }, c.TweenManager.prototype = {
  7100. getAll: function() {
  7101. return this._tweens
  7102. },
  7103. removeAll: function() {
  7104. for (var a = 0; a < this._tweens.length; a++) this._tweens[a].pendingDelete = !0;
  7105. this._add = []
  7106. },
  7107. removeFrom: function(a, b) {
  7108. "undefined" == typeof b && (b = !0);
  7109. var d, e;
  7110. if (Array.isArray(a))
  7111. for (d = 0, e = a.length; e > d; d++) this.removeFrom(a[d]);
  7112. else if (a.type === c.GROUP && b)
  7113. for (var d = 0, e = a.children.length; e > d; d++) this.removeFrom(a.children[d]);
  7114. else {
  7115. for (d = 0, e = this._tweens.length; e > d; d++) a === this._tweens[d].target && this.remove(this._tweens[d]);
  7116. for (d = 0, e = this._add.length; e > d; d++) a === this._add[d].target && this.remove(this._add[d])
  7117. }
  7118. },
  7119. add: function(a) {
  7120. a._manager = this, this._add.push(a)
  7121. },
  7122. create: function(a) {
  7123. return new c.Tween(a, this.game, this)
  7124. },
  7125. remove: function(a) {
  7126. 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))
  7127. },
  7128. update: function() {
  7129. var a = this._add.length,
  7130. b = this._tweens.length;
  7131. if (0 === b && 0 === a) return !1;
  7132. for (var c = 0; b > c;) this._tweens[c].update(this.game.time.time) ? c++ : (this._tweens.splice(c, 1), b--);
  7133. return a > 0 && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
  7134. },
  7135. isTweening: function(a) {
  7136. return this._tweens.some(function(b) {
  7137. return b.target === a
  7138. })
  7139. },
  7140. _pauseAll: function() {
  7141. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._pause()
  7142. },
  7143. _resumeAll: function() {
  7144. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._resume()
  7145. },
  7146. pauseAll: function() {
  7147. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].pause()
  7148. },
  7149. resumeAll: function() {
  7150. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].resume(!0)
  7151. }
  7152. }, c.TweenManager.prototype.constructor = c.TweenManager, c.Tween = function(a, b, d) {
  7153. this.game = b, this.target = a, this.manager = d, this.timeline = [], this.reverse = !1, this.timeScale = 1, this.repeatCounter = 0, this.pendingDelete = !1, this.onStart = new c.Signal, this.onLoop = new c.Signal, this.onRepeat = new c.Signal, this.onChildComplete = new c.Signal, this.onComplete = new c.Signal, this.isRunning = !1, this.current = 0, this.properties = {}, this.chainedTween = null, this.isPaused = !1, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, this._pausedTime = 0, this._codePaused = !1
  7154. }, c.Tween.prototype = {
  7155. to: function(a, b, d, e, f, g, h) {
  7156. return "undefined" == typeof b && (b = 1e3), "undefined" == typeof d && (d = c.Easing.Default), "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), "undefined" == typeof h && (h = !1), "string" == typeof d && this.manager.easeMap[d] && (d = this.manager.easeMap[d]), this.isRunning ? (console.warn("Phaser.Tween.to cannot be called after Tween.start"), this) : (this.timeline.push(new c.TweenData(this).to(a, b, d, f, g, h)), e && this.start(), this)
  7157. },
  7158. from: function(a, b, d, e, f, g, h) {
  7159. return "undefined" == typeof b && (b = 1e3), "undefined" == typeof d && (d = c.Easing.Default), "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), "undefined" == typeof h && (h = !1), "string" == typeof d && this.manager.easeMap[d] && (d = this.manager.easeMap[d]), this.isRunning ? (console.warn("Phaser.Tween.from cannot be called after Tween.start"), this) : (this.timeline.push(new c.TweenData(this).from(a, b, d, f, g, h)), e && this.start(), this)
  7160. },
  7161. start: function(a) {
  7162. if ("undefined" == typeof a && (a = 0), null === this.game || null === this.target || 0 === this.timeline.length || this.isRunning) return this;
  7163. for (var b = 0; b < this.timeline.length; b++)
  7164. for (var c in this.timeline[b].vEnd) this.properties[c] = this.target[c] || 0, Array.isArray(this.properties[c]) || (this.properties[c] *= 1);
  7165. for (var b = 0; b < this.timeline.length; b++) this.timeline[b].loadValues();
  7166. return this.manager.add(this), this.isRunning = !0, (0 > a || a > this.timeline.length - 1) && (a = 0), this.current = a, this.timeline[this.current].start(), this.onStart.dispatch(this.target, this), this
  7167. },
  7168. stop: function(a) {
  7169. return "undefined" == typeof a && (a = !1), this.isRunning = !1, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, a && (this.onComplete.dispatch(this.target, this), this.chainedTween && this.chainedTween.start()), this.manager.remove(this), this
  7170. },
  7171. updateTweenData: function(a, b, c) {
  7172. if (0 === this.timeline.length) return this;
  7173. if ("undefined" == typeof c && (c = 0), -1 === c)
  7174. for (var d = 0; d < this.timeline.length; d++) this.timeline[d][a] = b;
  7175. else this.timeline[c][a] = b;
  7176. return this
  7177. },
  7178. delay: function(a, b) {
  7179. return this.updateTweenData("delay", a, b)
  7180. },
  7181. repeat: function(a, b, c) {
  7182. return "undefined" == typeof b && (b = 0), this.updateTweenData("repeatCounter", a, c), this.updateTweenData("repeatDelay", b, c)
  7183. },
  7184. repeatDelay: function(a, b) {
  7185. return this.updateTweenData("repeatDelay", a, b)
  7186. },
  7187. yoyo: function(a, b, c) {
  7188. return "undefined" == typeof b && (b = 0), this.updateTweenData("yoyo", a, c), this.updateTweenData("yoyoDelay", b, c)
  7189. },
  7190. yoyoDelay: function(a, b) {
  7191. return this.updateTweenData("yoyoDelay", a, b)
  7192. },
  7193. easing: function(a, b) {
  7194. return "string" == typeof a && this.manager.easeMap[a] && (a = this.manager.easeMap[a]), this.updateTweenData("easingFunction", a, b)
  7195. },
  7196. interpolation: function(a, b, d) {
  7197. return "undefined" == typeof b && (b = c.Math), this.updateTweenData("interpolationFunction", a, d), this.updateTweenData("interpolationContext", b, d)
  7198. },
  7199. repeatAll: function(a) {
  7200. return "undefined" == typeof a && (a = 0), this.repeatCounter = a, this
  7201. },
  7202. chain: function() {
  7203. for (var a = arguments.length; a--;) a > 0 ? arguments[a - 1].chainedTween = arguments[a] : this.chainedTween = arguments[a];
  7204. return this
  7205. },
  7206. loop: function(a) {
  7207. return "undefined" == typeof a && (a = !0), a ? this.repeatAll(-1) : this.repeatCounter = 0, this
  7208. },
  7209. onUpdateCallback: function(a, b) {
  7210. return this._onUpdateCallback = a, this._onUpdateCallbackContext = b, this
  7211. },
  7212. pause: function() {
  7213. this.isPaused = !0, this._codePaused = !0, this._pausedTime = this.game.time.time
  7214. },
  7215. _pause: function() {
  7216. this._codePaused || (this.isPaused = !0, this._pausedTime = this.game.time.time)
  7217. },
  7218. resume: function() {
  7219. if (this.isPaused) {
  7220. this.isPaused = !1, this._codePaused = !1;
  7221. for (var a = 0; a < this.timeline.length; a++) this.timeline[a].isRunning || (this.timeline[a].startTime += this.game.time.time - this._pausedTime)
  7222. }
  7223. },
  7224. _resume: function() {
  7225. this._codePaused || this.resume()
  7226. },
  7227. update: function(a) {
  7228. if (this.pendingDelete) return !1;
  7229. if (this.isPaused) return !0;
  7230. var b = this.timeline[this.current].update(a);
  7231. if (b === c.TweenData.PENDING) return !0;
  7232. if (b === c.TweenData.RUNNING) return null !== this._onUpdateCallback && this._onUpdateCallback.call(this._onUpdateCallbackContext, this, this.timeline[this.current].value, this.timeline[this.current]), this.isRunning;
  7233. if (b === c.TweenData.LOOPED) return this.onLoop.dispatch(this.target, this), !0;
  7234. if (b === c.TweenData.COMPLETE) {
  7235. var d = !1;
  7236. return this.reverse ? (this.current--, this.current < 0 && (this.current = this.timeline.length - 1, d = !0)) : (this.current++, this.current === this.timeline.length && (this.current = 0, d = !0)), d ? -1 === this.repeatCounter ? (this.timeline[this.current].start(), this.onRepeat.dispatch(this.target, this), !0) : this.repeatCounter > 0 ? (this.repeatCounter--, this.timeline[this.current].start(), this.onRepeat.dispatch(this.target, this), !0) : (this.isRunning = !1, this.onComplete.dispatch(this.target, this), this.chainedTween && this.chainedTween.start(), !1) : (this.onChildComplete.dispatch(this.target, this), this.timeline[this.current].start(), !0)
  7237. }
  7238. },
  7239. generateData: function(a, b) {
  7240. if (null === this.game || null === this.target) return null;
  7241. "undefined" == typeof b && (b = []);
  7242. for (var c = 0; c < this.timeline.length; c++)
  7243. for (var d in this.timeline[c].vEnd) this.properties[d] = this.target[d] || 0, Array.isArray(this.properties[d]) || (this.properties[d] *= 1);
  7244. for (var c = 0; c < this.timeline.length; c++) this.timeline[c].loadValues();
  7245. for (var c = 0; c < this.timeline.length; c++) b = b.concat(this.timeline[c].generateData(a));
  7246. return b
  7247. }
  7248. }, Object.defineProperty(c.Tween.prototype, "totalDuration", {
  7249. get: function() {
  7250. for (var a = 0, b = 0; b < this.timeline.length; b++) a += this.timeline[b].duration;
  7251. return a
  7252. }
  7253. }), c.Tween.prototype.constructor = c.Tween, c.TweenData = function(a) {
  7254. this.parent = a, this.game = a.game, this.vStart = {}, this.vStartCache = {}, this.vEnd = {}, this.vEndCache = {}, this.duration = 1e3, this.percent = 0, this.value = 0, this.repeatCounter = 0, this.repeatDelay = 0, this.interpolate = !1, this.yoyo = !1, this.yoyoDelay = 0, this.inReverse = !1, this.delay = 0, this.dt = 0, this.startTime = null, this.easingFunction = c.Easing.Default, this.interpolationFunction = c.Math.linearInterpolation, this.interpolationContext = c.Math, this.isRunning = !1, this.isFrom = !1
  7255. }, c.TweenData.PENDING = 0, c.TweenData.RUNNING = 1, c.TweenData.LOOPED = 2, c.TweenData.COMPLETE = 3, c.TweenData.prototype = {
  7256. to: function(a, b, c, d, e, f) {
  7257. return this.vEnd = a, this.duration = b, this.easingFunction = c, this.delay = d, this.repeatCounter = e, this.yoyo = f, this.isFrom = !1, this
  7258. },
  7259. from: function(a, b, c, d, e, f) {
  7260. return this.vEnd = a, this.duration = b, this.easingFunction = c, this.delay = d, this.repeatCounter = e, this.yoyo = f, this.isFrom = !0, this
  7261. },
  7262. start: function() {
  7263. if (this.startTime = this.game.time.time + this.delay, this.dt = this.parent.reverse ? this.duration : 0, this.isRunning = this.delay > 0 ? !1 : !0, this.isFrom)
  7264. for (var a in this.vStartCache) this.vStart[a] = this.vEndCache[a], this.vEnd[a] = this.vStartCache[a], this.parent.target[a] = this.vStart[a];
  7265. return this.value = 0, this.yoyoCounter = 0, this
  7266. },
  7267. loadValues: function() {
  7268. for (var a in this.parent.properties) {
  7269. if (this.vStart[a] = this.parent.properties[a], Array.isArray(this.vEnd[a])) {
  7270. if (0 === this.vEnd[a].length) continue;
  7271. this.vEnd[a] = [this.vStart[a]].concat(this.vEnd[a])
  7272. }
  7273. "undefined" != typeof this.vEnd[a] ? ("string" == typeof this.vEnd[a] && (this.vEnd[a] = this.vStart[a] + parseFloat(this.vEnd[a], 10)), this.parent.properties[a] = this.vEnd[a]) : this.vEnd[a] = this.vStart[a], this.vStartCache[a] = this.vStart[a], this.vEndCache[a] = this.vEnd[a]
  7274. }
  7275. return this
  7276. },
  7277. update: function() {
  7278. if (this.isRunning) {
  7279. if (this.game.time.time < this.startTime) return c.TweenData.RUNNING
  7280. } else {
  7281. if (!(this.game.time.time >= this.startTime)) return c.TweenData.PENDING;
  7282. this.isRunning = !0
  7283. }
  7284. this.parent.reverse ? (this.dt -= this.game.time.physicsElapsedMS * this.parent.timeScale, this.dt = Math.max(this.dt, 0)) : (this.dt += this.game.time.physicsElapsedMS * this.parent.timeScale, this.dt = Math.min(this.dt, this.duration)), this.percent = this.dt / this.duration, this.value = this.easingFunction(this.percent);
  7285. for (var a in this.vEnd) {
  7286. var b = this.vStart[a],
  7287. d = this.vEnd[a];
  7288. this.parent.target[a] = Array.isArray(d) ? this.interpolationFunction.call(this.interpolationContext, d, this.value) : b + (d - b) * this.value
  7289. }
  7290. return !this.parent.reverse && 1 === this.percent || this.parent.reverse && 0 === this.percent ? this.repeat() : c.TweenData.RUNNING
  7291. },
  7292. generateData: function(a) {
  7293. this.dt = this.parent.reverse ? this.duration : 0;
  7294. var b = [],
  7295. c = !1,
  7296. d = 1 / a * 1e3;
  7297. do {
  7298. this.parent.reverse ? (this.dt -= d, this.dt = Math.max(this.dt, 0)) : (this.dt += d, this.dt = Math.min(this.dt, this.duration)), this.percent = this.dt / this.duration, this.value = this.easingFunction(this.percent);
  7299. var e = {};
  7300. for (var f in this.vEnd) {
  7301. var g = this.vStart[f],
  7302. h = this.vEnd[f];
  7303. e[f] = Array.isArray(h) ? this.interpolationFunction(h, this.value) : g + (h - g) * this.value
  7304. }
  7305. b.push(e), (!this.parent.reverse && 1 === this.percent || this.parent.reverse && 0 === this.percent) && (c = !0)
  7306. } while (!c);
  7307. if (this.yoyo) {
  7308. var i = b.slice();
  7309. i.reverse(), b = b.concat(i)
  7310. }
  7311. return b
  7312. },
  7313. repeat: function() {
  7314. if (this.yoyo) {
  7315. if (this.inReverse && 0 === this.repeatCounter) return c.TweenData.COMPLETE;
  7316. this.inReverse = !this.inReverse
  7317. } else if (0 === this.repeatCounter) return c.TweenData.COMPLETE;
  7318. if (this.inReverse)
  7319. for (var a in this.vStartCache) this.vStart[a] = this.vEndCache[a], this.vEnd[a] = this.vStartCache[a];
  7320. else {
  7321. for (var a in this.vStartCache) this.vStart[a] = this.vStartCache[a], this.vEnd[a] = this.vEndCache[a];
  7322. this.repeatCounter > 0 && this.repeatCounter--
  7323. }
  7324. return this.startTime = this.game.time.time, this.yoyo && this.inReverse ? this.startTime += this.yoyoDelay : this.inReverse || (this.startTime += this.repeatDelay), this.dt = this.parent.reverse ? this.duration : 0, c.TweenData.LOOPED
  7325. }
  7326. }, c.TweenData.prototype.constructor = c.TweenData, c.Easing = {
  7327. Linear: {
  7328. None: function(a) {
  7329. return a
  7330. }
  7331. },
  7332. Quadratic: {
  7333. In: function(a) {
  7334. return a * a
  7335. },
  7336. Out: function(a) {
  7337. return a * (2 - a)
  7338. },
  7339. InOut: function(a) {
  7340. return (a *= 2) < 1 ? .5 * a * a : -.5 * (--a * (a - 2) - 1)
  7341. }
  7342. },
  7343. Cubic: {
  7344. In: function(a) {
  7345. return a * a * a
  7346. },
  7347. Out: function(a) {
  7348. return --a * a * a + 1
  7349. },
  7350. InOut: function(a) {
  7351. return (a *= 2) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2)
  7352. }
  7353. },
  7354. Quartic: {
  7355. In: function(a) {
  7356. return a * a * a * a
  7357. },
  7358. Out: function(a) {
  7359. return 1 - --a * a * a * a
  7360. },
  7361. InOut: function(a) {
  7362. return (a *= 2) < 1 ? .5 * a * a * a * a : -.5 * ((a -= 2) * a * a * a - 2)
  7363. }
  7364. },
  7365. Quintic: {
  7366. In: function(a) {
  7367. return a * a * a * a * a
  7368. },
  7369. Out: function(a) {
  7370. return --a * a * a * a * a + 1
  7371. },
  7372. InOut: function(a) {
  7373. return (a *= 2) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2)
  7374. }
  7375. },
  7376. Sinusoidal: {
  7377. In: function(a) {
  7378. return 0 === a ? 0 : 1 === a ? 1 : 1 - Math.cos(a * Math.PI / 2)
  7379. },
  7380. Out: function(a) {
  7381. return 0 === a ? 0 : 1 === a ? 1 : Math.sin(a * Math.PI / 2)
  7382. },
  7383. InOut: function(a) {
  7384. return 0 === a ? 0 : 1 === a ? 1 : .5 * (1 - Math.cos(Math.PI * a))
  7385. }
  7386. },
  7387. Exponential: {
  7388. In: function(a) {
  7389. return 0 === a ? 0 : Math.pow(1024, a - 1)
  7390. },
  7391. Out: function(a) {
  7392. return 1 === a ? 1 : 1 - Math.pow(2, -10 * a)
  7393. },
  7394. InOut: function(a) {
  7395. return 0 === a ? 0 : 1 === a ? 1 : (a *= 2) < 1 ? .5 * Math.pow(1024, a - 1) : .5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  7396. }
  7397. },
  7398. Circular: {
  7399. In: function(a) {
  7400. return 1 - Math.sqrt(1 - a * a)
  7401. },
  7402. Out: function(a) {
  7403. return Math.sqrt(1 - --a * a)
  7404. },
  7405. InOut: function(a) {
  7406. return (a *= 2) < 1 ? -.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  7407. }
  7408. },
  7409. Elastic: {
  7410. In: function(a) {
  7411. var b, c = .1,
  7412. d = .4;
  7413. 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)))
  7414. },
  7415. Out: function(a) {
  7416. var b, c = .1,
  7417. d = .4;
  7418. 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)
  7419. },
  7420. InOut: function(a) {
  7421. var b, c = .1,
  7422. d = .4;
  7423. 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)
  7424. }
  7425. },
  7426. Back: {
  7427. In: function(a) {
  7428. var b = 1.70158;
  7429. return a * a * ((b + 1) * a - b)
  7430. },
  7431. Out: function(a) {
  7432. var b = 1.70158;
  7433. return --a * a * ((b + 1) * a + b) + 1
  7434. },
  7435. InOut: function(a) {
  7436. var b = 2.5949095;
  7437. return (a *= 2) < 1 ? .5 * a * a * ((b + 1) * a - b) : .5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
  7438. }
  7439. },
  7440. Bounce: {
  7441. In: function(a) {
  7442. return 1 - c.Easing.Bounce.Out(1 - a)
  7443. },
  7444. Out: function(a) {
  7445. 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
  7446. },
  7447. InOut: function(a) {
  7448. return .5 > a ? .5 * c.Easing.Bounce.In(2 * a) : .5 * c.Easing.Bounce.Out(2 * a - 1) + .5
  7449. }
  7450. }
  7451. }, c.Easing.Default = c.Easing.Linear.None, c.Easing.Power0 = c.Easing.Linear.None, c.Easing.Power1 = c.Easing.Quadratic.Out, c.Easing.Power2 = c.Easing.Cubic.Out, c.Easing.Power3 = c.Easing.Quartic.Out, c.Easing.Power4 = c.Easing.Quintic.Out, c.Time = function(a) {
  7452. this.game = a, this.time = 0, this.prevTime = 0, this.now = 0, this.elapsed = 0, this.elapsedMS = 0, this.physicsElapsed = 0, this.physicsElapsedMS = 0, this.desiredFps = 60, this.suggestedFps = null, this.slowMotion = 1, this.advancedTiming = !1, this.frames = 0, this.fps = 0, this.fpsMin = 1e3, this.fpsMax = 0, this.msMin = 1e3, this.msMax = 0, this.pauseDuration = 0, this.timeToCall = 0, this.timeExpected = 0, this.events = new c.Timer(this.game, !1), this._frameCount = 0, this._elapsedAccumulator = 0, this._started = 0, this._timeLastSecond = 0, this._pauseStarted = 0, this._justResumed = !1, this._timers = []
  7453. }, c.Time.prototype = {
  7454. boot: function() {
  7455. this._started = Date.now(), this.time = Date.now(), this.events.start()
  7456. },
  7457. add: function(a) {
  7458. return this._timers.push(a), a
  7459. },
  7460. create: function(a) {
  7461. "undefined" == typeof a && (a = !0);
  7462. var b = new c.Timer(this.game, a);
  7463. return this._timers.push(b), b
  7464. },
  7465. removeAll: function() {
  7466. for (var a = 0; a < this._timers.length; a++) this._timers[a].destroy();
  7467. this._timers = [], this.events.removeAll()
  7468. },
  7469. update: function(a) {
  7470. var b = this.time;
  7471. if (this.time = Date.now(), this.elapsedMS = this.time - b, this.prevTime = this.now, this.now = a, this.elapsed = this.now - this.prevTime, this.timeToCall = Math.floor(Math.max(0, 1e3 / this.desiredFps - (this.timeCallExpected - a))), this.timeCallExpected = a + this.timeToCall, this._frameCount++, this._elapsedAccumulator += this.elapsed, this._frameCount >= 2 * this.desiredFps && (this.suggestedFps = 5 * Math.floor(200 / (this._elapsedAccumulator / this._frameCount)), this._frameCount = 0, this._elapsedAccumulator = 0), this.physicsElapsed = 1 / this.desiredFps, this.physicsElapsedMS = 1e3 * this.physicsElapsed, this.advancedTiming && (this.msMin = Math.min(this.msMin, this.elapsed), this.msMax = 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 = Math.min(this.fpsMin, this.fps), this.fpsMax = Math.max(this.fpsMax, this.fps), this._timeLastSecond = this.now, this.frames = 0)), !this.game.paused) {
  7472. this.events.update(this.time);
  7473. for (var c = 0, d = this._timers.length; d > c;) this._timers[c].update(this.time) ? c++ : (this._timers.splice(c, 1), d--)
  7474. }
  7475. },
  7476. gamePaused: function() {
  7477. this._pauseStarted = Date.now(), this.events.pause();
  7478. for (var a = this._timers.length; a--;) this._timers[a]._pause()
  7479. },
  7480. gameResumed: function() {
  7481. this.time = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume();
  7482. for (var a = this._timers.length; a--;) this._timers[a]._resume()
  7483. },
  7484. totalElapsedSeconds: function() {
  7485. return .001 * (this.time - this._started)
  7486. },
  7487. elapsedSince: function(a) {
  7488. return this.time - a
  7489. },
  7490. elapsedSecondsSince: function(a) {
  7491. return .001 * (this.time - a)
  7492. },
  7493. reset: function() {
  7494. this._started = this.time, this.removeAll()
  7495. }
  7496. }, c.Time.prototype.constructor = c.Time, c.Timer = function(a, b) {
  7497. "undefined" == typeof b && (b = !0), this.game = a, this.running = !1, this.autoDestroy = b, this.expired = !1, this.elapsed = 0, this.events = [], this.onComplete = new c.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
  7498. }, c.Timer.MINUTE = 6e4, c.Timer.SECOND = 1e3, c.Timer.HALF = 500, c.Timer.QUARTER = 250, c.Timer.prototype = {
  7499. create: function(a, b, d, e, f, g) {
  7500. a = Math.round(a);
  7501. var h = a;
  7502. h += 0 === this._now ? this.game.time.time : this._now;
  7503. var i = new c.TimerEvent(this, a, h, d, b, e, f, g);
  7504. return this.events.push(i), this.order(), this.expired = !1, i
  7505. },
  7506. add: function(a, b, c) {
  7507. return this.create(a, !1, 0, b, c, Array.prototype.splice.call(arguments, 3))
  7508. },
  7509. repeat: function(a, b, c, d) {
  7510. return this.create(a, !1, b, c, d, Array.prototype.splice.call(arguments, 4))
  7511. },
  7512. loop: function(a, b, c) {
  7513. return this.create(a, !0, 0, b, c, Array.prototype.splice.call(arguments, 3))
  7514. },
  7515. start: function(a) {
  7516. if (!this.running) {
  7517. this._started = this.game.time.time + (a || 0), this.running = !0;
  7518. for (var b = 0; b < this.events.length; b++) this.events[b].tick = this.events[b].delay + this._started
  7519. }
  7520. },
  7521. stop: function(a) {
  7522. this.running = !1, "undefined" == typeof a && (a = !0), a && (this.events.length = 0)
  7523. },
  7524. remove: function(a) {
  7525. for (var b = 0; b < this.events.length; b++)
  7526. if (this.events[b] === a) return this.events[b].pendingDelete = !0, !0;
  7527. return !1
  7528. },
  7529. order: function() {
  7530. this.events.length > 0 && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick)
  7531. },
  7532. sortHandler: function(a, b) {
  7533. return a.tick < b.tick ? -1 : a.tick > b.tick ? 1 : 0
  7534. },
  7535. clearPendingEvents: function() {
  7536. for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
  7537. this._len = this.events.length, this._i = 0
  7538. },
  7539. update: function(a) {
  7540. if (this.paused) return !0;
  7541. 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) {
  7542. for (; this._i < this._len && this.running && this._now >= this.events[this._i].tick && !this.events[this._i].pendingDelete;) 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++;
  7543. this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
  7544. }
  7545. return this.expired && this.autoDestroy ? !1 : !0
  7546. },
  7547. pause: function() {
  7548. this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.time, this.paused = !0))
  7549. },
  7550. _pause: function() {
  7551. !this.paused && this.running && (this._pauseStarted = this.game.time.time, this.paused = !0)
  7552. },
  7553. adjustEvents: function(a) {
  7554. for (var b = 0; b < this.events.length; b++)
  7555. if (!this.events[b].pendingDelete) {
  7556. var c = this.events[b].tick - a;
  7557. 0 > c && (c = 0), this.events[b].tick = this._now + c
  7558. }
  7559. var d = this.nextTick - a;
  7560. this.nextTick = 0 > d ? this._now : this._now + d
  7561. },
  7562. resume: function() {
  7563. if (this.paused) {
  7564. var a = this.game.time.time;
  7565. this._pauseTotal += a - this._now, this._now = a, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
  7566. }
  7567. },
  7568. _resume: function() {
  7569. this._codePaused || this.resume()
  7570. },
  7571. removeAll: function() {
  7572. this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0
  7573. },
  7574. destroy: function() {
  7575. this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0
  7576. }
  7577. }, Object.defineProperty(c.Timer.prototype, "next", {
  7578. get: function() {
  7579. return this.nextTick
  7580. }
  7581. }), Object.defineProperty(c.Timer.prototype, "duration", {
  7582. get: function() {
  7583. return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0
  7584. }
  7585. }), Object.defineProperty(c.Timer.prototype, "length", {
  7586. get: function() {
  7587. return this.events.length
  7588. }
  7589. }), Object.defineProperty(c.Timer.prototype, "ms", {
  7590. get: function() {
  7591. return this.running ? this._now - this._started - this._pauseTotal : 0
  7592. }
  7593. }), Object.defineProperty(c.Timer.prototype, "seconds", {
  7594. get: function() {
  7595. return this.running ? .001 * this.ms : 0
  7596. }
  7597. }), c.Timer.prototype.constructor = c.Timer, c.TimerEvent = function(a, b, c, d, e, f, g, h) {
  7598. 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
  7599. }, c.TimerEvent.prototype.constructor = c.TimerEvent, c.AnimationManager = function(a) {
  7600. 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 = []
  7601. }, c.AnimationManager.prototype = {
  7602. loadFrameData: function(a, b) {
  7603. if ("undefined" == typeof a) return !1;
  7604. if (this.isLoaded)
  7605. for (var c in this._anims) this._anims[c].updateFrameData(a);
  7606. return this._frameData = a, "undefined" == typeof b || null === b ? this.frame = 0 : "string" == typeof b ? this.frameName = b : this.frame = b, this.isLoaded = !0, !0
  7607. },
  7608. copyFrameData: function(a, b) {
  7609. if (this._frameData = a.clone(), this.isLoaded)
  7610. for (var c in this._anims) this._anims[c].updateFrameData(this._frameData);
  7611. return "undefined" == typeof b || null === b ? this.frame = 0 : "string" == typeof b ? this.frameName = b : this.frame = b, this.isLoaded = !0, !0
  7612. },
  7613. add: function(a, b, d, e, f) {
  7614. return b = b || [], d = d || 60, "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = b && "number" == typeof b[0] ? !0 : !1), this._outputFrames.length = 0, this._frameData.getFrameIndexes(b, f, this._outputFrames), this._anims[a] = new c.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]
  7615. },
  7616. validateFrames: function(a, b) {
  7617. "undefined" == typeof b && (b = !0);
  7618. for (var c = 0; c < a.length; c++)
  7619. if (b === !0) {
  7620. if (a[c] > this._frameData.total) return !1
  7621. } else if (this._frameData.checkFrameName(a[c]) === !1) return !1;
  7622. return !0
  7623. },
  7624. play: function(a, b, c, d) {
  7625. 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
  7626. },
  7627. stop: function(a, b) {
  7628. "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)
  7629. },
  7630. update: function() {
  7631. return this.updateIfVisible && !this.sprite.visible ? !1 : this.currentAnim && this.currentAnim.update() ? (this.currentFrame = this.currentAnim.currentFrame, !0) : !1
  7632. },
  7633. next: function(a) {
  7634. this.currentAnim && (this.currentAnim.next(a), this.currentFrame = this.currentAnim.currentFrame)
  7635. },
  7636. previous: function(a) {
  7637. this.currentAnim && (this.currentAnim.previous(a), this.currentFrame = this.currentAnim.currentFrame)
  7638. },
  7639. getAnimation: function(a) {
  7640. return "string" == typeof a && this._anims[a] ? this._anims[a] : null
  7641. },
  7642. refreshFrame: function() {
  7643. this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)
  7644. },
  7645. destroy: function() {
  7646. var a = null;
  7647. for (var a in this._anims) this._anims.hasOwnProperty(a) && this._anims[a].destroy();
  7648. this._anims = {}, this._outputFrames = [], this._frameData = null, this.currentAnim = null, this.currentFrame = null, this.sprite = null, this.game = null
  7649. }
  7650. }, c.AnimationManager.prototype.constructor = c.AnimationManager, Object.defineProperty(c.AnimationManager.prototype, "frameData", {
  7651. get: function() {
  7652. return this._frameData
  7653. }
  7654. }), Object.defineProperty(c.AnimationManager.prototype, "frameTotal", {
  7655. get: function() {
  7656. return this._frameData.total
  7657. }
  7658. }), Object.defineProperty(c.AnimationManager.prototype, "paused", {
  7659. get: function() {
  7660. return this.currentAnim.isPaused
  7661. },
  7662. set: function(a) {
  7663. this.currentAnim.paused = a
  7664. }
  7665. }), Object.defineProperty(c.AnimationManager.prototype, "name", {
  7666. get: function() {
  7667. return this.currentAnim ? this.currentAnim.name : void 0
  7668. }
  7669. }), Object.defineProperty(c.AnimationManager.prototype, "frame", {
  7670. get: function() {
  7671. return this.currentFrame ? this.currentFrame.index : void 0
  7672. },
  7673. set: function(a) {
  7674. "number" == typeof a && this._frameData && null !== this._frameData.getFrame(a) && (this.currentFrame = this._frameData.getFrame(a), this.currentFrame && (this.sprite.setFrame(this.currentFrame), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)))
  7675. }
  7676. }), Object.defineProperty(c.AnimationManager.prototype, "frameName", {
  7677. get: function() {
  7678. return this.currentFrame ? this.currentFrame.name : void 0
  7679. },
  7680. set: function(a) {
  7681. "string" == typeof a && 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)
  7682. }
  7683. }), c.Animation = function(a, b, d, e, f, g, h) {
  7684. "undefined" == typeof h && (h = !1), this.game = a, this._parent = b, 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 c.Signal, this.onUpdate = null, this.onComplete = new c.Signal, this.onLoop = new c.Signal, this.game.onPause.add(this.onPause, this), this.game.onResume.add(this.onResume, this)
  7685. }, c.Animation.prototype = {
  7686. play: function(a, b, c) {
  7687. 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.time, this._timeNextFrame = this.game.time.time + this.delay, this._frameIndex = 0, this.updateCurrentFrame(!1), this._parent.events.onAnimationStart$dispatch(this._parent, this), this.onStart.dispatch(this._parent, this), this._parent.animations.currentAnim = this, this._parent.animations.currentFrame = this.currentFrame, this
  7688. },
  7689. restart: function() {
  7690. this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.time, this._timeNextFrame = this.game.time.time + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), this._parent.animations.currentAnim = this, this._parent.animations.currentFrame = this.currentFrame, this.onStart.dispatch(this._parent, this)
  7691. },
  7692. setFrame: function(a, b) {
  7693. var c;
  7694. if ("undefined" == typeof b && (b = !1), "string" == typeof a)
  7695. for (var d = 0; d < this._frames.length; d++) this._frameData.getFrame(this._frames[d]).name === a && (c = d);
  7696. else if ("number" == typeof a)
  7697. if (b) c = a;
  7698. else
  7699. for (var d = 0; d < this._frames.length; d++) this._frames[d] === c && (c = d);
  7700. c && (this._frameIndex = c - 1, this._timeNextFrame = this.game.time.time, this.update())
  7701. },
  7702. stop: function(a, b) {
  7703. "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))
  7704. },
  7705. onPause: function() {
  7706. this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.time)
  7707. },
  7708. onResume: function() {
  7709. this.isPlaying && (this._timeNextFrame = this.game.time.time + this._frameDiff)
  7710. },
  7711. update: function() {
  7712. return this.isPaused ? !1 : this.isPlaying && this.game.time.time >= this._timeNextFrame ? (this._frameSkip = 1, this._frameDiff = this.game.time.time - this._timeNextFrame, this._timeLastFrame = this.game.time.time, this._frameDiff > this.delay && (this._frameSkip = Math.floor(this._frameDiff / this.delay), this._frameDiff -= this._frameSkip * this.delay), this._timeNextFrame = this.game.time.time + (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.updateCurrentFrame(!0)) : (this.complete(), !1) : this.updateCurrentFrame(!0)) : !1
  7713. },
  7714. updateCurrentFrame: function(a) {
  7715. return this._frameData ? (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)), this.onUpdate && a ? (this.onUpdate.dispatch(this, this.currentFrame), !!this._frameData) : !0) : !1
  7716. },
  7717. next: function(a) {
  7718. "undefined" == typeof a && (a = 1);
  7719. var b = this._frameIndex + a;
  7720. b >= this._frames.length && (this.loop ? b %= this._frames.length : b = this._frames.length - 1), b !== this._frameIndex && (this._frameIndex = b, this.updateCurrentFrame(!0))
  7721. },
  7722. previous: function(a) {
  7723. "undefined" == typeof a && (a = 1);
  7724. var b = this._frameIndex - a;
  7725. 0 > b && (this.loop ? b = this._frames.length + b : b++), b !== this._frameIndex && (this._frameIndex = b, this.updateCurrentFrame(!0))
  7726. },
  7727. updateFrameData: function(a) {
  7728. this._frameData = a, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null
  7729. },
  7730. destroy: function() {
  7731. this._frameData && (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(), this.onUpdate && this.onUpdate.dispose())
  7732. },
  7733. complete: function() {
  7734. this._frameIndex = this._frames.length - 1, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), 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()
  7735. }
  7736. }, c.Animation.prototype.constructor = c.Animation, Object.defineProperty(c.Animation.prototype, "paused", {
  7737. get: function() {
  7738. return this.isPaused
  7739. },
  7740. set: function(a) {
  7741. this.isPaused = a, a ? this._pauseStartTime = this.game.time.time : this.isPlaying && (this._timeNextFrame = this.game.time.time + this.delay)
  7742. }
  7743. }), Object.defineProperty(c.Animation.prototype, "frameTotal", {
  7744. get: function() {
  7745. return this._frames.length
  7746. }
  7747. }), Object.defineProperty(c.Animation.prototype, "frame", {
  7748. get: function() {
  7749. return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex
  7750. },
  7751. set: function(a) {
  7752. this.currentFrame = this._frameData.getFrame(this._frames[a]), null !== this.currentFrame && (this._frameIndex = a, this._parent.setFrame(this.currentFrame), this.onUpdate && this.onUpdate.dispatch(this, this.currentFrame))
  7753. }
  7754. }), Object.defineProperty(c.Animation.prototype, "speed", {
  7755. get: function() {
  7756. return Math.round(1e3 / this.delay)
  7757. },
  7758. set: function(a) {
  7759. a >= 1 && (this.delay = 1e3 / a)
  7760. }
  7761. }), Object.defineProperty(c.Animation.prototype, "enableUpdate", {
  7762. get: function() {
  7763. return null !== this.onUpdate
  7764. },
  7765. set: function(a) {
  7766. a && null === this.onUpdate ? this.onUpdate = new c.Signal : a || null === this.onUpdate || (this.onUpdate.dispose(), this.onUpdate = null)
  7767. }
  7768. }), c.Animation.generateFrameNames = function(a, b, d, e, f) {
  7769. "undefined" == typeof e && (e = "");
  7770. var g = [],
  7771. h = "";
  7772. if (d > b)
  7773. for (var i = b; d >= i; i++) h = "number" == typeof f ? c.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  7774. else
  7775. for (var i = b; i >= d; i--) h = "number" == typeof f ? c.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  7776. return g
  7777. }, c.Frame = function(a, b, d, e, f, g, h) {
  7778. this.index = a, this.x = b, 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 = c.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
  7779. }, c.Frame.prototype = {
  7780. setTrim: function(a, b, c, d, e, f, g) {
  7781. 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)
  7782. },
  7783. clone: function() {
  7784. var a = new c.Frame(this.index, this.x, this.y, this.width, this.height, this.name, this.uuid);
  7785. for (var b in this) this.hasOwnProperty(b) && (a[b] = this[b]);
  7786. return a
  7787. },
  7788. getRect: function(a) {
  7789. return "undefined" == typeof a ? a = new c.Rectangle(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  7790. }
  7791. }, c.Frame.prototype.constructor = c.Frame, c.FrameData = function() {
  7792. this._frames = [], this._frameNames = []
  7793. }, c.FrameData.prototype = {
  7794. addFrame: function(a) {
  7795. return a.index = this._frames.length, this._frames.push(a), "" !== a.name && (this._frameNames[a.name] = a.index), a
  7796. },
  7797. getFrame: function(a) {
  7798. return a >= this._frames.length && (a = 0), this._frames[a]
  7799. },
  7800. getFrameByName: function(a) {
  7801. return "number" == typeof this._frameNames[a] ? this._frames[this._frameNames[a]] : null
  7802. },
  7803. checkFrameName: function(a) {
  7804. return null == this._frameNames[a] ? !1 : !0
  7805. },
  7806. clone: function() {
  7807. for (var a = new c.FrameData, b = 0; b < this._frames.length; b++) a._frames.push(this._frames[b].clone());
  7808. for (var d in this._frameNames) this._frameNames.hasOwnProperty(d) && a._frameNames.push(this._frameNames[d]);
  7809. return a
  7810. },
  7811. getFrameRange: function(a, b, c) {
  7812. "undefined" == typeof c && (c = []);
  7813. for (var d = a; b >= d; d++) c.push(this._frames[d]);
  7814. return c
  7815. },
  7816. getFrames: function(a, b, c) {
  7817. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  7818. for (var d = 0; d < this._frames.length; d++) c.push(this._frames[d]);
  7819. else
  7820. for (var d = 0, e = a.length; e > d; d++) c.push(b ? this.getFrame(a[d]) : this.getFrameByName(a[d]));
  7821. return c
  7822. },
  7823. getFrameIndexes: function(a, b, c) {
  7824. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  7825. for (var d = 0, e = this._frames.length; e > d; d++) c.push(this._frames[d].index);
  7826. else
  7827. 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);
  7828. return c
  7829. }
  7830. }, c.FrameData.prototype.constructor = c.FrameData, Object.defineProperty(c.FrameData.prototype, "total", {
  7831. get: function() {
  7832. return this._frames.length
  7833. }
  7834. }), c.AnimationParser = {
  7835. spriteSheet: function(a, b, d, e, f, g, h) {
  7836. var i = a.cache.getImage(b);
  7837. if (null == i) return null;
  7838. var j = i.width,
  7839. k = i.height;
  7840. 0 >= d && (d = Math.floor(-j / Math.min(-1, d))), 0 >= e && (e = Math.floor(-k / Math.min(-1, e)));
  7841. var l = Math.floor((j - g) / (d + h)),
  7842. m = Math.floor((k - g) / (e + h)),
  7843. n = l * m;
  7844. if (-1 !== f && (n = f), 0 === j || 0 === k || d > j || e > k || 0 === n) return console.warn("Phaser.AnimationParser.spriteSheet: '" + b + "'s width/height zero or width/height < given frameWidth/frameHeight"), null;
  7845. for (var o = new c.FrameData, p = g, q = g, r = 0; n > r; r++) {
  7846. var s = a.rnd.uuid();
  7847. o.addFrame(new c.Frame(r, p, q, d, e, "", s)), PIXI.TextureCache[s] = new PIXI.Texture(PIXI.BaseTextureCache[b], {
  7848. x: p,
  7849. y: q,
  7850. width: d,
  7851. height: e
  7852. }), p += d + h, p + d > j && (p = g, q += e + h)
  7853. }
  7854. return o
  7855. },
  7856. JSONData: function(a, b, d) {
  7857. if (!b.frames) return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"), void console.log(b);
  7858. for (var e, f = new c.FrameData, g = b.frames, h = 0; h < g.length; h++) {
  7859. var i = a.rnd.uuid();
  7860. e = f.addFrame(new c.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], {
  7861. x: g[h].frame.x,
  7862. y: g[h].frame.y,
  7863. width: g[h].frame.w,
  7864. height: g[h].frame.h
  7865. }), 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)
  7866. }
  7867. return f
  7868. },
  7869. JSONDataHash: function(a, b, d) {
  7870. if (!b.frames) return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"), void console.log(b);
  7871. var e, f = new c.FrameData,
  7872. g = b.frames,
  7873. h = 0;
  7874. for (var i in g) {
  7875. var j = a.rnd.uuid();
  7876. e = f.addFrame(new c.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], {
  7877. x: g[i].frame.x,
  7878. y: g[i].frame.y,
  7879. width: g[i].frame.w,
  7880. height: g[i].frame.h
  7881. }), 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++
  7882. }
  7883. return f
  7884. },
  7885. XMLData: function(a, b, d) {
  7886. if (!b.getElementsByTagName("TextureAtlas")) return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
  7887. for (var e, f, g, h, i, j, k, l, m, n, o, p, q = new c.FrameData, r = b.getElementsByTagName("SubTexture"), s = 0; s < r.length; s++) f = a.rnd.uuid(), h = r[s].attributes, g = h.name.value, i = parseInt(h.x.value, 10), j = parseInt(h.y.value, 10), k = parseInt(h.width.value, 10), l = parseInt(h.height.value, 10), m = null, n = null, h.frameX && (m = Math.abs(parseInt(h.frameX.value, 10)), n = Math.abs(parseInt(h.frameY.value, 10)), o = parseInt(h.frameWidth.value, 10), p = parseInt(h.frameHeight.value, 10)), e = q.addFrame(new c.Frame(s, i, j, k, l, g, f)), PIXI.TextureCache[f] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  7888. x: i,
  7889. y: j,
  7890. width: k,
  7891. height: l
  7892. }), (null !== m || null !== n) && e.setTrim(!0, k, l, m, n, o, p);
  7893. return q
  7894. }
  7895. }, c.Cache = function(a) {
  7896. this.game = a, this.autoResolveURL = !1, this._canvases = {}, this._images = {}, this._textures = {}, this._sounds = {}, this._text = {}, this._json = {}, this._xml = {}, this._physics = {}, this._tilemaps = {}, this._binary = {}, this._bitmapDatas = {}, this._bitmapFont = {}, this._urlMap = {}, this._urlResolver = new Image, this._urlTemp = null, this.addDefaultImage(), this.addMissingImage(), this.onSoundUnlock = new c.Signal, this._cacheMap = [], this._cacheMap[c.Cache.CANVAS] = this._canvases, this._cacheMap[c.Cache.IMAGE] = this._images, this._cacheMap[c.Cache.TEXTURE] = this._textures, this._cacheMap[c.Cache.SOUND] = this._sounds, this._cacheMap[c.Cache.TEXT] = this._text, this._cacheMap[c.Cache.PHYSICS] = this._physics, this._cacheMap[c.Cache.TILEMAP] = this._tilemaps, this._cacheMap[c.Cache.BINARY] = this._binary, this._cacheMap[c.Cache.BITMAPDATA] = this._bitmapDatas, this._cacheMap[c.Cache.BITMAPFONT] = this._bitmapFont, this._cacheMap[c.Cache.JSON] = this._json, this._cacheMap[c.Cache.XML] = this._xml
  7897. }, c.Cache.CANVAS = 1, c.Cache.IMAGE = 2, c.Cache.TEXTURE = 3, c.Cache.SOUND = 4, c.Cache.TEXT = 5, c.Cache.PHYSICS = 6, c.Cache.TILEMAP = 7, c.Cache.BINARY = 8, c.Cache.BITMAPDATA = 9, c.Cache.BITMAPFONT = 10, c.Cache.JSON = 11, c.Cache.XML = 12, c.Cache.prototype = {
  7898. addCanvas: function(a, b, c) {
  7899. this._canvases[a] = {
  7900. canvas: b,
  7901. context: c
  7902. }
  7903. },
  7904. addBinary: function(a, b) {
  7905. this._binary[a] = b
  7906. },
  7907. addBitmapData: function(a, b, d) {
  7908. return b.key = a, "undefined" == typeof d && (d = new c.FrameData, d.addFrame(b.textureFrame)), this._bitmapDatas[a] = {
  7909. data: b,
  7910. frameData: d
  7911. }, b
  7912. },
  7913. addRenderTexture: function(a, b) {
  7914. var d = new c.Frame(0, 0, 0, b.width, b.height, "", "");
  7915. this._textures[a] = {
  7916. texture: b,
  7917. frame: d
  7918. }
  7919. },
  7920. addSpriteSheet: function(a, b, d, e, f, g, h, i) {
  7921. this._images[a] = {
  7922. url: b,
  7923. data: d,
  7924. frameWidth: e,
  7925. frameHeight: f,
  7926. margin: h,
  7927. spacing: i
  7928. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), this._images[a].frameData = c.AnimationParser.spriteSheet(this.game, a, e, f, g, h, i), this._resolveURL(b, this._images[a])
  7929. },
  7930. addTilemap: function(a, b, c, d) {
  7931. this._tilemaps[a] = {
  7932. url: b,
  7933. data: c,
  7934. format: d
  7935. }, this._resolveURL(b, this._tilemaps[a])
  7936. },
  7937. addTextureAtlas: function(a, b, d, e, f) {
  7938. this._images[a] = {
  7939. url: b,
  7940. data: d
  7941. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), f == c.Loader.TEXTURE_ATLAS_JSON_ARRAY ? this._images[a].frameData = c.AnimationParser.JSONData(this.game, e, a) : f == c.Loader.TEXTURE_ATLAS_JSON_HASH ? this._images[a].frameData = c.AnimationParser.JSONDataHash(this.game, e, a) : f == c.Loader.TEXTURE_ATLAS_XML_STARLING && (this._images[a].frameData = c.AnimationParser.XMLData(this.game, e, a)), this._resolveURL(b, this._images[a])
  7942. },
  7943. addBitmapFont: function(a, b, d, e, f, g) {
  7944. this._images[a] = {
  7945. url: b,
  7946. data: d
  7947. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), c.LoaderParser.bitmapFont(this.game, e, a, f, g), this._bitmapFont[a] = PIXI.BitmapText.fonts[a], this._resolveURL(b, this._bitmapFont[a])
  7948. },
  7949. addPhysicsData: function(a, b, c, d) {
  7950. this._physics[a] = {
  7951. url: b,
  7952. data: c,
  7953. format: d
  7954. }, this._resolveURL(b, this._physics[a])
  7955. },
  7956. addDefaultImage: function() {
  7957. var a = new Image;
  7958. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==", this._images.__default = {
  7959. url: null,
  7960. data: a
  7961. }, this._images.__default.frame = new c.Frame(0, 0, 0, 32, 32, "", ""), this._images.__default.frameData = new c.FrameData, this._images.__default.frameData.addFrame(new c.Frame(0, 0, 0, 32, 32, null, this.game.rnd.uuid())), PIXI.BaseTextureCache.__default = new PIXI.BaseTexture(a), PIXI.TextureCache.__default = new PIXI.Texture(PIXI.BaseTextureCache.__default)
  7962. },
  7963. addMissingImage: function() {
  7964. var a = new Image;
  7965. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==", this._images.__missing = {
  7966. url: null,
  7967. data: a
  7968. }, this._images.__missing.frame = new c.Frame(0, 0, 0, 32, 32, "", ""), this._images.__missing.frameData = new c.FrameData, this._images.__missing.frameData.addFrame(new c.Frame(0, 0, 0, 32, 32, null, this.game.rnd.uuid())), PIXI.BaseTextureCache.__missing = new PIXI.BaseTexture(a), PIXI.TextureCache.__missing = new PIXI.Texture(PIXI.BaseTextureCache.__missing)
  7969. },
  7970. addText: function(a, b, c) {
  7971. this._text[a] = {
  7972. url: b,
  7973. data: c
  7974. }, this._resolveURL(b, this._text[a])
  7975. },
  7976. addJSON: function(a, b, c) {
  7977. this._json[a] = {
  7978. url: b,
  7979. data: c
  7980. }, this._resolveURL(b, this._json[a])
  7981. },
  7982. addXML: function(a, b, c) {
  7983. this._xml[a] = {
  7984. url: b,
  7985. data: c
  7986. }, this._resolveURL(b, this._xml[a])
  7987. },
  7988. addImage: function(a, b, d) {
  7989. this.checkImageKey(a) && this.removeImage(a), this._images[a] = {
  7990. url: b,
  7991. data: d
  7992. }, this._images[a].frame = new c.Frame(0, 0, 0, d.width, d.height, a, this.game.rnd.uuid()), this._images[a].frameData = new c.FrameData, this._images[a].frameData.addFrame(new c.Frame(0, 0, 0, d.width, d.height, b, this.game.rnd.uuid())), PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), this._resolveURL(b, this._images[a])
  7993. },
  7994. addSound: function(a, b, c, d, e) {
  7995. d = d || !0, e = e || !1;
  7996. var f = !1;
  7997. e && (f = !0), this._sounds[a] = {
  7998. url: b,
  7999. data: c,
  8000. isDecoding: !1,
  8001. decoded: f,
  8002. webAudio: d,
  8003. audioTag: e,
  8004. locked: this.game.sound.touchLocked
  8005. }, this._resolveURL(b, this._sounds[a])
  8006. },
  8007. reloadSound: function(a) {
  8008. var b = this;
  8009. this._sounds[a] && (this._sounds[a].data.src = this._sounds[a].url, this._sounds[a].data.addEventListener("canplaythrough", function() {
  8010. return b.reloadSoundComplete(a)
  8011. }, !1), this._sounds[a].data.load())
  8012. },
  8013. reloadSoundComplete: function(a) {
  8014. this._sounds[a] && (this._sounds[a].locked = !1, this.onSoundUnlock.dispatch(a))
  8015. },
  8016. updateSound: function(a, b, c) {
  8017. this._sounds[a] && (this._sounds[a][b] = c)
  8018. },
  8019. decodedSound: function(a, b) {
  8020. this._sounds[a].data = b, this._sounds[a].decoded = !0, this._sounds[a].isDecoding = !1
  8021. },
  8022. getCanvas: function(a) {
  8023. return this._canvases[a] ? this._canvases[a].canvas : (console.warn('Phaser.Cache.getCanvas: Invalid key: "' + a + '"'), null)
  8024. },
  8025. getBitmapData: function(a) {
  8026. return this._bitmapDatas[a] ? this._bitmapDatas[a].data : (console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + a + '"'), null)
  8027. },
  8028. getBitmapFont: function(a) {
  8029. return this._bitmapFont[a] ? this._bitmapFont[a] : (console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + a + '"'), null)
  8030. },
  8031. getPhysicsData: function(a, b, c) {
  8032. if ("undefined" == typeof b || null === b) {
  8033. if (this._physics[a]) return this._physics[a].data;
  8034. console.warn('Phaser.Cache.getPhysicsData: Invalid key: "' + a + '"')
  8035. } else if (this._physics[a] && this._physics[a].data[b]) {
  8036. var d = this._physics[a].data[b];
  8037. if (!d || !c) return d;
  8038. for (var e in d)
  8039. if (e = d[e], e.fixtureKey === c) return e;
  8040. console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "' + c + " in " + a + '"')
  8041. } else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + a + " / " + b + '"');
  8042. return null
  8043. },
  8044. checkKey: function(a, b) {
  8045. return this._cacheMap[a][b] ? !0 : !1
  8046. },
  8047. checkCanvasKey: function(a) {
  8048. return this.checkKey(c.Cache.CANVAS, a)
  8049. },
  8050. checkImageKey: function(a) {
  8051. return this.checkKey(c.Cache.IMAGE, a)
  8052. },
  8053. checkTextureKey: function(a) {
  8054. return this.checkKey(c.Cache.TEXTURE, a)
  8055. },
  8056. checkSoundKey: function(a) {
  8057. return this.checkKey(c.Cache.SOUND, a)
  8058. },
  8059. checkTextKey: function(a) {
  8060. return this.checkKey(c.Cache.TEXT, a)
  8061. },
  8062. checkPhysicsKey: function(a) {
  8063. return this.checkKey(c.Cache.PHYSICS, a)
  8064. },
  8065. checkTilemapKey: function(a) {
  8066. return this.checkKey(c.Cache.TILEMAP, a)
  8067. },
  8068. checkBinaryKey: function(a) {
  8069. return this.checkKey(c.Cache.BINARY, a)
  8070. },
  8071. checkBitmapDataKey: function(a) {
  8072. return this.checkKey(c.Cache.BITMAPDATA, a)
  8073. },
  8074. checkBitmapFontKey: function(a) {
  8075. return this.checkKey(c.Cache.BITMAPFONT, a)
  8076. },
  8077. checkJSONKey: function(a) {
  8078. return this.checkKey(c.Cache.JSON, a)
  8079. },
  8080. checkXMLKey: function(a) {
  8081. return this.checkKey(c.Cache.XML, a)
  8082. },
  8083. checkURL: function(a) {
  8084. return this._urlMap[this._resolveURL(a)] ? !0 : !1
  8085. },
  8086. getImage: function(a) {
  8087. return this._images[a] ? this._images[a].data : (console.warn('Phaser.Cache.getImage: Invalid key: "' + a + '"'), null)
  8088. },
  8089. getTilemapData: function(a) {
  8090. return this._tilemaps[a] ? this._tilemaps[a] : (console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + a + '"'), null)
  8091. },
  8092. getFrameData: function(a, b) {
  8093. return "undefined" == typeof b && (b = c.Cache.IMAGE), this._cacheMap[b][a] ? this._cacheMap[b][a].frameData : null
  8094. },
  8095. updateFrameData: function(a, b) {
  8096. this._images[a] && (this._images[a].frameData = b)
  8097. },
  8098. getFrameByIndex: function(a, b) {
  8099. return this._images[a] ? this._images[a].frameData.getFrame(b) : null
  8100. },
  8101. getFrameByName: function(a, b) {
  8102. return this._images[a] ? this._images[a].frameData.getFrameByName(b) : null
  8103. },
  8104. getFrame: function(a) {
  8105. return this._images[a] ? this._images[a].frame : null
  8106. },
  8107. getTextureFrame: function(a) {
  8108. return this._textures[a] ? this._textures[a].frame : null
  8109. },
  8110. getRenderTexture: function(a) {
  8111. return this._textures[a] ? this._textures[a] : (console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"'), null)
  8112. },
  8113. getTexture: function(a) {
  8114. return this._textures[a] ? this._textures[a] : void console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"')
  8115. },
  8116. getSound: function(a) {
  8117. return this._sounds[a] ? this._sounds[a] : (console.warn('Phaser.Cache.getSound: Invalid key: "' + a + '"'), null)
  8118. },
  8119. getSoundData: function(a) {
  8120. return this._sounds[a] ? this._sounds[a].data : (console.warn('Phaser.Cache.getSoundData: Invalid key: "' + a + '"'), null)
  8121. },
  8122. isSoundDecoded: function(a) {
  8123. return this._sounds[a] ? this._sounds[a].decoded : void 0
  8124. },
  8125. isSoundReady: function(a) {
  8126. return this._sounds[a] && this._sounds[a].decoded && this.game.sound.touchLocked === !1
  8127. },
  8128. getFrameCount: function(a) {
  8129. return this._images[a] ? this._images[a].frameData.total : 0
  8130. },
  8131. getText: function(a) {
  8132. return this._text[a] ? this._text[a].data : (console.warn('Phaser.Cache.getText: Invalid key: "' + a + '"'), null)
  8133. },
  8134. getJSON: function(a) {
  8135. return this._json[a] ? this._json[a].data : (console.warn('Phaser.Cache.getJSON: Invalid key: "' + a + '"'), null)
  8136. },
  8137. getXML: function(a) {
  8138. return this._xml[a] ? this._xml[a].data : (console.warn('Phaser.Cache.getXML: Invalid key: "' + a + '"'), null)
  8139. },
  8140. getBinary: function(a) {
  8141. return this._binary[a] ? this._binary[a] : (console.warn('Phaser.Cache.getBinary: Invalid key: "' + a + '"'), null)
  8142. },
  8143. getURL: function(a) {
  8144. var a = this._resolveURL(a);
  8145. return a ? this._urlMap[a] : (console.warn('Phaser.Cache.getUrl: Invalid url: "' + a + '" or Cache.autoResolveURL was false'), null)
  8146. },
  8147. getUrl: function(a) {
  8148. return this.getURL(a)
  8149. },
  8150. getKeys: function(a) {
  8151. var b = null;
  8152. switch (a) {
  8153. case c.Cache.CANVAS:
  8154. b = this._canvases;
  8155. break;
  8156. case c.Cache.IMAGE:
  8157. b = this._images;
  8158. break;
  8159. case c.Cache.TEXTURE:
  8160. b = this._textures;
  8161. break;
  8162. case c.Cache.SOUND:
  8163. b = this._sounds;
  8164. break;
  8165. case c.Cache.TEXT:
  8166. b = this._text;
  8167. break;
  8168. case c.Cache.PHYSICS:
  8169. b = this._physics;
  8170. break;
  8171. case c.Cache.TILEMAP:
  8172. b = this._tilemaps;
  8173. break;
  8174. case c.Cache.BINARY:
  8175. b = this._binary;
  8176. break;
  8177. case c.Cache.BITMAPDATA:
  8178. b = this._bitmapDatas;
  8179. break;
  8180. case c.Cache.BITMAPFONT:
  8181. b = this._bitmapFont;
  8182. break;
  8183. case c.Cache.JSON:
  8184. b = this._json;
  8185. break;
  8186. case c.Cache.XML:
  8187. b = this._xml
  8188. }
  8189. if (b) {
  8190. var d = [];
  8191. for (var e in b) "__default" !== e && "__missing" !== e && d.push(e);
  8192. return d
  8193. }
  8194. },
  8195. removeCanvas: function(a) {
  8196. delete this._canvases[a]
  8197. },
  8198. removeImage: function(a, b) {
  8199. "undefined" == typeof b && (b = !0), delete this._images[a], b && PIXI.BaseTextureCache[a].destroy()
  8200. },
  8201. removeSound: function(a) {
  8202. delete this._sounds[a]
  8203. },
  8204. removeText: function(a) {
  8205. delete this._text[a]
  8206. },
  8207. removeJSON: function(a) {
  8208. delete this._json[a]
  8209. },
  8210. removeXML: function(a) {
  8211. delete this._xml[a]
  8212. },
  8213. removePhysics: function(a) {
  8214. delete this._physics[a]
  8215. },
  8216. removeTilemap: function(a) {
  8217. delete this._tilemaps[a]
  8218. },
  8219. removeBinary: function(a) {
  8220. delete this._binary[a]
  8221. },
  8222. removeBitmapData: function(a) {
  8223. delete this._bitmapDatas[a]
  8224. },
  8225. removeBitmapFont: function(a) {
  8226. delete this._bitmapFont[a]
  8227. },
  8228. _resolveURL: function(a, b) {
  8229. return this.autoResolveURL ? (this._urlResolver.src = this.game.load.baseURL + a, this._urlTemp = this._urlResolver.src, this._urlResolver.src = "", b && (this._urlMap[this._urlTemp] = b), this._urlTemp) : null
  8230. },
  8231. destroy: function() {
  8232. for (var a in this._images) "__default" !== a && "__missing" !== a && delete this._images[a];
  8233. for (var b = [this._canvases, this._sounds, this._text, this._json, this._xml, this._textures, this._physics, this._tilemaps, this._binary, this._bitmapDatas, this._bitmapFont], c = 0; c < b.length; c++)
  8234. for (var a in b[c]) delete b[c][a];
  8235. this._urlMap = null, this._urlResolver = null, this._urlTemp = null
  8236. }
  8237. }, c.Cache.prototype.constructor = c.Cache, c.Loader = function(a) {
  8238. this.game = a, this.resetLocked = !1, this.isLoading = !1, this.hasLoaded = !1, this.preloadSprite = null, this.crossOrigin = !1, this.baseURL = "", this.onLoadStart = new c.Signal, this.onLoadComplete = new c.Signal, this.onPackComplete = new c.Signal, this.onFileStart = new c.Signal, this.onFileComplete = new c.Signal, this.onFileError = new c.Signal, this.useXDomainRequest = !1, this._warnedAboutXDomainRequest = !1, this.enableParallel = !0, this.maxParallelDownloads = 4, this._withSyncPointDepth = 0, this._fileList = [], this._flightQueue = [], this._processingHead = 0, this._fileLoadStarted = !1, this._totalPackCount = 0, this._totalFileCount = 0, this._loadedPackCount = 0, this._loadedFileCount = 0
  8239. }, c.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0, c.Loader.TEXTURE_ATLAS_JSON_HASH = 1, c.Loader.TEXTURE_ATLAS_XML_STARLING = 2, c.Loader.PHYSICS_LIME_CORONA_JSON = 3, c.Loader.PHYSICS_PHASER_JSON = 4, c.Loader.prototype = {
  8240. setPreloadSprite: function(a, b) {
  8241. b = b || 0, this.preloadSprite = {
  8242. sprite: a,
  8243. direction: b,
  8244. width: a.width,
  8245. height: a.height,
  8246. rect: null
  8247. }, this.preloadSprite.rect = 0 === b ? new c.Rectangle(0, 0, 1, a.height) : new c.Rectangle(0, 0, a.width, 1), a.crop(this.preloadSprite.rect), a.visible = !0
  8248. },
  8249. resize: function() {
  8250. this.preloadSprite && this.preloadSprite.height !== this.preloadSprite.sprite.height && (this.preloadSprite.rect.height = this.preloadSprite.sprite.height)
  8251. },
  8252. checkKeyExists: function(a, b) {
  8253. return this.getAssetIndex(a, b) > -1
  8254. },
  8255. getAssetIndex: function(a, b) {
  8256. for (var c = -1, d = 0; d < this._fileList.length; d++) {
  8257. var e = this._fileList[d];
  8258. if (e.type === a && e.key === b && (c = d, !e.loaded && !e.loading)) break
  8259. }
  8260. return c
  8261. },
  8262. getAsset: function(a, b) {
  8263. var c = this.getAssetIndex(a, b);
  8264. return c > -1 ? {
  8265. index: c,
  8266. file: this._fileList[c]
  8267. } : !1
  8268. },
  8269. reset: function(a, b) {
  8270. "undefined" == typeof b && (b = !1), this.resetLocked || (a && (this.preloadSprite = null), this.isLoading = !1, this._processingHead = 0, this._fileList.length = 0, this._flightQueue.length = 0, this._fileLoadStarted = !1, this._totalFileCount = 0, this._totalPackCount = 0, this._loadedPackCount = 0, this._loadedFileCount = 0, b && (this.onLoadStart.removeAll(), this.onLoadComplete.removeAll(), this.onPackComplete.removeAll(), this.onFileStart.removeAll(), this.onFileComplete.removeAll(), this.onFileError.removeAll()))
  8271. },
  8272. addToFileList: function(a, b, c, d, e) {
  8273. var f = {
  8274. type: a,
  8275. key: b,
  8276. url: c,
  8277. syncPoint: this._withSyncPointDepth > 0,
  8278. data: null,
  8279. loading: !1,
  8280. loaded: !1,
  8281. error: !1
  8282. };
  8283. if (d)
  8284. for (var g in d) f[g] = d[g];
  8285. var h = this.getAssetIndex(a, b);
  8286. if (e && h > -1) {
  8287. var i = this._fileList[h];
  8288. i.loading || i.loaded ? (this._fileList.push(f), this._totalFileCount++) : this._fileList[h] = f
  8289. } else -1 === h && (this._fileList.push(f), this._totalFileCount++)
  8290. },
  8291. replaceInFileList: function(a, b, c, d) {
  8292. return this.addToFileList(a, b, c, d, !0)
  8293. },
  8294. pack: function(a, b, c, d) {
  8295. if ("undefined" == typeof b && (b = null), "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), !b && !c) return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."), this;
  8296. var e = {
  8297. type: "packfile",
  8298. key: a,
  8299. url: b,
  8300. syncPoint: !0,
  8301. data: null,
  8302. loading: !1,
  8303. loaded: !1,
  8304. error: !1,
  8305. callbackContext: d
  8306. };
  8307. c && ("string" == typeof c && (c = JSON.parse(c)), e.data = c || {}, e.loaded = !0);
  8308. for (var f = 0; f < this._fileList.length + 1; f++) {
  8309. var g = this._fileList[f];
  8310. if (!g || !g.loaded && !g.loading && "packfile" !== g.type) {
  8311. this._fileList.splice(f, 1, e), this._totalPackCount++;
  8312. break
  8313. }
  8314. }
  8315. return this
  8316. },
  8317. image: function(a, b, c) {
  8318. return "undefined" == typeof c && (c = !1), this.addToFileList("image", a, b, void 0, c), this
  8319. },
  8320. text: function(a, b, c) {
  8321. return "undefined" == typeof c && (c = !1), this.addToFileList("text", a, b, void 0, c), this
  8322. },
  8323. json: function(a, b, c) {
  8324. return "undefined" == typeof c && (c = !1), this.addToFileList("json", a, b, void 0, c), this
  8325. },
  8326. xml: function(a, b, c) {
  8327. return "undefined" == typeof c && (c = !1), this.addToFileList("xml", a, b, void 0, c), this
  8328. },
  8329. script: function(a, b, c, d) {
  8330. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("script", a, b, {
  8331. syncPoint: !0,
  8332. callback: c,
  8333. callbackContext: d
  8334. }), this
  8335. },
  8336. binary: function(a, b, c, d) {
  8337. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("binary", a, b, {
  8338. callback: c,
  8339. callbackContext: d
  8340. }), this
  8341. },
  8342. spritesheet: function(a, b, c, d, e, f, g) {
  8343. return "undefined" == typeof e && (e = -1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), this.addToFileList("spritesheet", a, b, {
  8344. frameWidth: c,
  8345. frameHeight: d,
  8346. frameMax: e,
  8347. margin: f,
  8348. spacing: g
  8349. }), this
  8350. },
  8351. audio: function(a, b, c) {
  8352. return "undefined" == typeof c && (c = !0), "string" == typeof b && (b = [b]), this.addToFileList("audio", a, b, {
  8353. buffer: null,
  8354. autoDecode: c
  8355. }), this
  8356. },
  8357. audiosprite: function(a, b, c, d, e) {
  8358. return "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = !0), this.audio(a, b, e), c ? this.json(a + "-audioatlas", c) : d ? ("string" == typeof d && (d = JSON.parse(d)), this.game.cache.addJSON(a + "-audioatlas", "", d)) : console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"), this
  8359. },
  8360. tilemap: function(a, b, d, e) {
  8361. if ("undefined" == typeof b && (b = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = c.Tilemap.CSV), !b && !d) return console.warn("Phaser.Loader.tilemap - Both url and data are null. One must be set."), this;
  8362. if (d) {
  8363. switch (e) {
  8364. case c.Tilemap.CSV:
  8365. break;
  8366. case c.Tilemap.TILED_JSON:
  8367. "string" == typeof d && (d = JSON.parse(d))
  8368. }
  8369. this.game.cache.addTilemap(a, null, d, e)
  8370. } else this.addToFileList("tilemap", a, b, {
  8371. format: e
  8372. });
  8373. return this
  8374. },
  8375. physics: function(a, b, d, e) {
  8376. return "undefined" == typeof b && (b = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = c.Physics.LIME_CORONA_JSON), b || d ? (d ? ("string" == typeof d && (d = JSON.parse(d)), this.game.cache.addPhysicsData(a, null, d, e)) : this.addToFileList("physics", a, b, {
  8377. format: e
  8378. }), this) : (console.warn("Phaser.Loader.physics - Both url and data are null. One must be set."), this)
  8379. },
  8380. bitmapFont: function(a, b, c, d, e, f) {
  8381. 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, {
  8382. xmlURL: c,
  8383. xSpacing: e,
  8384. ySpacing: f
  8385. });
  8386. else if ("string" == typeof d) {
  8387. var g = this.parseXml(d);
  8388. if (!g) throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
  8389. this.addToFileList("bitmapfont", a, b, {
  8390. xmlURL: null,
  8391. xmlData: g,
  8392. xSpacing: e,
  8393. ySpacing: f
  8394. })
  8395. }
  8396. return this
  8397. },
  8398. atlasJSONArray: function(a, b, d, e) {
  8399. return this.atlas(a, b, d, e, c.Loader.TEXTURE_ATLAS_JSON_ARRAY)
  8400. },
  8401. atlasJSONHash: function(a, b, d, e) {
  8402. return this.atlas(a, b, d, e, c.Loader.TEXTURE_ATLAS_JSON_HASH)
  8403. },
  8404. atlasXML: function(a, b, d, e) {
  8405. return this.atlas(a, b, d, e, c.Loader.TEXTURE_ATLAS_XML_STARLING)
  8406. },
  8407. atlas: function(a, b, d, e, f) {
  8408. if ("undefined" == typeof d && (d = null), "undefined" == typeof e && (e = null), "undefined" == typeof f && (f = c.Loader.TEXTURE_ATLAS_JSON_ARRAY), d) this.addToFileList("textureatlas", a, b, {
  8409. atlasURL: d,
  8410. format: f
  8411. });
  8412. else {
  8413. switch (f) {
  8414. case c.Loader.TEXTURE_ATLAS_JSON_ARRAY:
  8415. "string" == typeof e && (e = JSON.parse(e));
  8416. break;
  8417. case c.Loader.TEXTURE_ATLAS_XML_STARLING:
  8418. if ("string" == typeof e) {
  8419. var g = this.parseXml(e);
  8420. if (!g) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
  8421. e = g
  8422. }
  8423. }
  8424. this.addToFileList("textureatlas", a, b, {
  8425. atlasURL: null,
  8426. atlasData: e,
  8427. format: f
  8428. })
  8429. }
  8430. return this
  8431. },
  8432. withSyncPoint: function(a, b) {
  8433. this._withSyncPointDepth++;
  8434. try {
  8435. a.call(b || this, this)
  8436. } finally {
  8437. this._withSyncPointDepth--
  8438. }
  8439. return this
  8440. },
  8441. addSyncPoint: function(a, b) {
  8442. var c = this.getAsset(a, b);
  8443. return c && (c.file.syncPoint = !0), this
  8444. },
  8445. removeFile: function(a, b) {
  8446. var c = this.getAsset(a, b);
  8447. c && (c.loaded || c.loading || this._fileList.splice(c.index, 1))
  8448. },
  8449. removeAll: function() {
  8450. this._fileList.length = 0, this._flightQueue.length = 0
  8451. },
  8452. start: function() {
  8453. this.isLoading || (this.hasLoaded = !1, this.isLoading = !0, this.updateProgress(), this.processLoadQueue())
  8454. },
  8455. processLoadQueue: function() {
  8456. if (!this.isLoading) return console.warn("Phaser.Loader - active loading canceled / reset"), void this.finishedLoading(!0);
  8457. for (var a = 0; a < this._flightQueue.length; a++) {
  8458. var b = this._flightQueue[a];
  8459. (b.loaded || b.error) && (this._flightQueue.splice(a, 1), a--, b.loading = !1, b.requestUrl = null, b.requestObject = null, b.error && this.onFileError.dispatch(b.key, b), "packfile" !== b.type ? (this._loadedFileCount++, this.onFileComplete.dispatch(this.progress, b.key, !b.error, this._loadedFileCount, this._totalFileCount)) : "packfile" === b.type && b.error && (this._loadedPackCount++, this.onPackComplete.dispatch(b.key, !b.error, this._loadedPackCount, this._totalPackCount)))
  8460. }
  8461. for (var d = !1, e = this.enableParallel ? c.Math.clamp(this.maxParallelDownloads, 1, 12) : 1, a = this._processingHead; a < this._fileList.length; a++) {
  8462. var b = this._fileList[a];
  8463. if ("packfile" === b.type && !b.error && b.loaded && a === this._processingHead && (this.processPack(b), this._loadedPackCount++, this.onPackComplete.dispatch(b.key, !b.error, this._loadedPackCount, this._totalPackCount)), b.loaded || b.error ? a === this._processingHead && (this._processingHead = a + 1) : !b.loading && this._flightQueue.length < e && ("packfile" !== b.type || b.data ? d || (this._fileLoadStarted || (this._fileLoadStarted = !0, this.onLoadStart.dispatch()), this._flightQueue.push(b), b.loading = !0, this.onFileStart.dispatch(this.progress, b.key, b.url), this.loadFile(b)) : (this._flightQueue.push(b), b.loading = !0, this.loadFile(b))), !b.loaded && b.syncPoint && (d = !0), this._flightQueue.length >= e || d && this._loadedPackCount === this._totalPackCount) break
  8464. }
  8465. if (this.updateProgress(), this._processingHead >= this._fileList.length) this.finishedLoading();
  8466. else if (!this._flightQueue.length) {
  8467. console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");
  8468. var f = this;
  8469. setTimeout(function() {
  8470. f.finishedLoading(!0)
  8471. }, 2e3)
  8472. }
  8473. },
  8474. finishedLoading: function(a) {
  8475. this.hasLoaded || (this.hasLoaded = !0, this.isLoading = !1, a || this._fileLoadStarted || (this._fileLoadStarted = !0, this.onLoadStart.dispatch()), this.onLoadComplete.dispatch(), this.reset(), this.game.state.loadComplete())
  8476. },
  8477. asyncComplete: function(a, b) {
  8478. "undefined" == typeof b && (b = ""), a.loaded = !0, a.error = !!b, b && (a.errorMessage = b, console.warn("Phaser.Loader - " + a.type + "[" + a.key + "]: " + b)), this.processLoadQueue()
  8479. },
  8480. processPack: function(a) {
  8481. var b = a.data[a.key];
  8482. if (!b) return void console.warn("Phaser.Loader - " + a.key + ": pack has data, but not for pack key");
  8483. for (var d = 0; d < b.length; d++) {
  8484. var e = b[d];
  8485. switch (e.type) {
  8486. case "image":
  8487. this.image(e.key, e.url, e.overwrite);
  8488. break;
  8489. case "text":
  8490. this.text(e.key, e.url, e.overwrite);
  8491. break;
  8492. case "json":
  8493. this.json(e.key, e.url, e.overwrite);
  8494. break;
  8495. case "xml":
  8496. this.xml(e.key, e.url, e.overwrite);
  8497. break;
  8498. case "script":
  8499. this.script(e.key, e.url, e.callback, a.callbackContext || this);
  8500. break;
  8501. case "binary":
  8502. this.binary(e.key, e.url, e.callback, a.callbackContext || this);
  8503. break;
  8504. case "spritesheet":
  8505. this.spritesheet(e.key, e.url, e.frameWidth, e.frameHeight, e.frameMax, e.margin, e.spacing);
  8506. break;
  8507. case "audio":
  8508. this.audio(e.key, e.urls, e.autoDecode);
  8509. break;
  8510. case "audiosprite":
  8511. this.audio(e.key, e.urls, e.jsonURL);
  8512. break;
  8513. case "tilemap":
  8514. this.tilemap(e.key, e.url, e.data, c.Tilemap[e.format]);
  8515. break;
  8516. case "physics":
  8517. this.physics(e.key, e.url, e.data, c.Loader[e.format]);
  8518. break;
  8519. case "bitmapFont":
  8520. this.bitmapFont(e.key, e.textureURL, e.xmlURL, e.xmlData, e.xSpacing, e.ySpacing);
  8521. break;
  8522. case "atlasJSONArray":
  8523. this.atlasJSONArray(e.key, e.textureURL, e.atlasURL, e.atlasData);
  8524. break;
  8525. case "atlasJSONHash":
  8526. this.atlasJSONHash(e.key, e.textureURL, e.atlasURL, e.atlasData);
  8527. break;
  8528. case "atlasXML":
  8529. this.atlasXML(e.key, e.textureURL, e.atlasURL, e.atlasData);
  8530. break;
  8531. case "atlas":
  8532. this.atlas(e.key, e.textureURL, e.atlasURL, e.atlasData, c.Loader[e.format])
  8533. }
  8534. }
  8535. },
  8536. transformUrl: function(a) {
  8537. return this.baseURL + a
  8538. },
  8539. loadFile: function(a) {
  8540. switch (a.type) {
  8541. case "packfile":
  8542. this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.fileComplete);
  8543. break;
  8544. case "image":
  8545. case "spritesheet":
  8546. case "textureatlas":
  8547. case "bitmapfont":
  8548. this.loadImageTag(a);
  8549. break;
  8550. case "audio":
  8551. a.url = this.getAudioURL(a.url), a.url ? this.game.sound.usingWebAudio ? this.xhrLoad(a, this.transformUrl(a.url, a), "arraybuffer", this.fileComplete) : this.game.sound.usingAudioTag && this.loadAudioTag(a) : this.fileError(a, null, "no supported audio URL specified");
  8552. break;
  8553. case "json":
  8554. this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.jsonLoadComplete);
  8555. break;
  8556. case "xml":
  8557. this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.xmlLoadComplete);
  8558. break;
  8559. case "tilemap":
  8560. a.format === c.Tilemap.TILED_JSON ? this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.jsonLoadComplete) : a.format === c.Tilemap.CSV ? this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.csvLoadComplete) : this.asyncComplete(a, "invalid Tilemap format: " + a.format);
  8561. break;
  8562. case "text":
  8563. case "script":
  8564. case "physics":
  8565. this.xhrLoad(a, this.transformUrl(a.url, a), "text", this.fileComplete);
  8566. break;
  8567. case "binary":
  8568. this.xhrLoad(a, this.transformUrl(a.url, a), "arraybuffer", this.fileComplete)
  8569. }
  8570. },
  8571. loadImageTag: function(a) {
  8572. var b = this;
  8573. a.data = new Image, a.data.name = a.key, this.crossOrigin && (a.data.crossOrigin = this.crossOrigin), a.data.onload = function() {
  8574. a.data.onload && (a.data.onload = null, a.data.onerror = null, b.fileComplete(a))
  8575. }, a.data.onerror = function() {
  8576. a.data.onload && (a.data.onload = null, a.data.onerror = null, b.fileError(a))
  8577. }, a.data.src = this.transformUrl(a.url, a), a.data.complete && a.data.width && a.data.height && (a.data.onload = null, a.data.onerror = null, this.fileComplete(a))
  8578. },
  8579. loadAudioTag: function(a) {
  8580. var b = this;
  8581. if (this.game.sound.touchLocked) a.data = new Audio, a.data.name = a.key, a.data.preload = "auto", a.data.src = this.transformUrl(a.url, a), this.fileComplete(a);
  8582. else {
  8583. a.data = new Audio, a.data.name = a.key;
  8584. var d = function() {
  8585. a.data.removeEventListener("canplaythrough", d, !1), a.data.onerror = null, c.GAMES[b.game.id].load.fileComplete(a)
  8586. };
  8587. a.data.onerror = function() {
  8588. a.data.removeEventListener("canplaythrough", d, !1), a.data.onerror = null, b.fileError(a)
  8589. }, a.data.preload = "auto", a.data.src = this.transformUrl(a.url, a), a.data.addEventListener("canplaythrough", d, !1), a.data.load()
  8590. }
  8591. },
  8592. xhrLoad: function(a, b, c, d, e) {
  8593. if (this.useXDomainRequest && window.XDomainRequest) return void this.xhrLoadWithXDR(a, b, c, d, e);
  8594. var f = new XMLHttpRequest;
  8595. f.open("GET", b, !0), f.responseType = c, e = e || this.fileError;
  8596. var g = this;
  8597. f.onload = function() {
  8598. try {
  8599. return d.call(g, a, f)
  8600. } catch (b) {
  8601. g.hasLoaded ? window.console && console.error(b) : g.asyncComplete(a, b.message || "Exception")
  8602. }
  8603. }, f.onerror = function() {
  8604. try {
  8605. return e.call(g, a, f)
  8606. } catch (b) {
  8607. g.hasLoaded ? window.console && console.error(b) : g.asyncComplete(a, b.message || "Exception")
  8608. }
  8609. }, a.requestObject = f, a.requestUrl = b, f.send()
  8610. },
  8611. xhrLoadWithXDR: function(a, b, c, d, e) {
  8612. this._warnedAboutXDomainRequest || this.game.device.ie && !(this.game.device.ieVersion >= 10) || (this._warnedAboutXDomainRequest = !0, console.warn("Phaser.Loader - using XDomainRequest outside of IE 9"));
  8613. var f = new window.XDomainRequest;
  8614. f.open("GET", b, !0), f.responseType = c, f.timeout = 3e3, e = e || this.fileError;
  8615. var g = this;
  8616. f.onerror = function() {
  8617. try {
  8618. return e.call(g, a, f)
  8619. } catch (b) {
  8620. g.asyncComplete(a, b.message || "Exception")
  8621. }
  8622. }, f.ontimeout = function() {
  8623. try {
  8624. return e.call(g, a, f)
  8625. } catch (b) {
  8626. g.asyncComplete(a, b.message || "Exception")
  8627. }
  8628. }, f.onprogress = function() {}, f.onload = function() {
  8629. try {
  8630. return d.call(g, a, f)
  8631. } catch (b) {
  8632. g.asyncComplete(a, b.message || "Exception")
  8633. }
  8634. }, a.requestObject = f, a.requestUrl = b, setTimeout(function() {
  8635. f.send()
  8636. }, 0)
  8637. },
  8638. getAudioURL: function(a) {
  8639. for (var b = 0; b < a.length; b++) {
  8640. var c, d = a[b];
  8641. if (d.uri) d = d.uri, c = d.type;
  8642. else {
  8643. if (0 === d.indexOf("blob:") || 0 === d.indexOf("data:")) return d;
  8644. d.indexOf("?") >= 0 && (d = d.substr(0, d.indexOf("?")));
  8645. var e = d.substr((Math.max(0, d.lastIndexOf(".")) || 1 / 0) + 1);
  8646. c = e.toLowerCase()
  8647. }
  8648. if (this.game.device.canPlayAudio(c)) return a[b]
  8649. }
  8650. return null
  8651. },
  8652. fileError: function(a, b, c) {
  8653. var d = a.requestUrl || this.transformUrl(a.url, a),
  8654. e = "error loading asset from URL " + d;
  8655. !c && b && (c = b.status), c && (e = e + " (" + c + ")"), this.asyncComplete(a, e)
  8656. },
  8657. fileComplete: function(a, b) {
  8658. var d = !0;
  8659. switch (a.type) {
  8660. case "packfile":
  8661. var e = JSON.parse(b.responseText);
  8662. a.data = e || {};
  8663. break;
  8664. case "image":
  8665. this.game.cache.addImage(a.key, a.url, a.data);
  8666. break;
  8667. case "spritesheet":
  8668. this.game.cache.addSpriteSheet(a.key, a.url, a.data, a.frameWidth, a.frameHeight, a.frameMax, a.margin, a.spacing);
  8669. break;
  8670. case "textureatlas":
  8671. if (null == a.atlasURL) this.game.cache.addTextureAtlas(a.key, a.url, a.data, a.atlasData, a.format);
  8672. else if (d = !1, a.format == c.Loader.TEXTURE_ATLAS_JSON_ARRAY || a.format == c.Loader.TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(a, this.transformUrl(a.atlasURL, a), "text", this.jsonLoadComplete);
  8673. else {
  8674. if (a.format != c.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + a.format);
  8675. this.xhrLoad(a, this.transformUrl(a.atlasURL, a), "text", this.xmlLoadComplete)
  8676. }
  8677. break;
  8678. case "bitmapfont":
  8679. a.xmlURL ? (d = !1, this.xhrLoad(a, this.transformUrl(a.xmlURL, a), "text", this.xmlLoadComplete)) : this.game.cache.addBitmapFont(a.key, a.url, a.data, a.xmlData, a.xSpacing, a.ySpacing);
  8680. break;
  8681. case "audio":
  8682. this.game.sound.usingWebAudio ? (a.data = b.response, this.game.cache.addSound(a.key, a.url, a.data, !0, !1), a.autoDecode && this.game.sound.decode(a.key)) : this.game.cache.addSound(a.key, a.url, a.data, !1, !0);
  8683. break;
  8684. case "text":
  8685. a.data = b.responseText, this.game.cache.addText(a.key, a.url, a.data);
  8686. break;
  8687. case "physics":
  8688. var e = JSON.parse(b.responseText);
  8689. this.game.cache.addPhysicsData(a.key, a.url, e, a.format);
  8690. break;
  8691. case "script":
  8692. a.data = document.createElement("script"), a.data.language = "javascript", a.data.type = "text/javascript", a.data.defer = !1, a.data.text = b.responseText, document.head.appendChild(a.data), a.callback && (a.data = a.callback.call(a.callbackContext, a.key, b.responseText));
  8693. break;
  8694. case "binary":
  8695. a.data = a.callback ? a.callback.call(a.callbackContext, a.key, b.response) : b.response, this.game.cache.addBinary(a.key, a.data)
  8696. }
  8697. d && this.asyncComplete(a)
  8698. },
  8699. jsonLoadComplete: function(a, b) {
  8700. var c = JSON.parse(b.responseText);
  8701. "tilemap" === a.type ? this.game.cache.addTilemap(a.key, a.url, c, a.format) : "json" === a.type ? this.game.cache.addJSON(a.key, a.url, c) : this.game.cache.addTextureAtlas(a.key, a.url, a.data, c, a.format), this.asyncComplete(a)
  8702. },
  8703. csvLoadComplete: function(a, b) {
  8704. var c = b.responseText;
  8705. this.game.cache.addTilemap(a.key, a.url, c, a.format), this.asyncComplete(a)
  8706. },
  8707. xmlLoadComplete: function(a, b) {
  8708. var c = b.responseText,
  8709. d = this.parseXml(c);
  8710. if (!d) {
  8711. var e = b.responseType || b.contentType;
  8712. return console.warn("Phaser.Loader - " + a.key + ": invalid XML (" + e + ")"), void this.asyncComplete(a, "invalid XML")
  8713. }
  8714. "bitmapfont" === a.type ? this.game.cache.addBitmapFont(a.key, a.url, a.data, d, a.xSpacing, a.ySpacing) : "textureatlas" === a.type ? this.game.cache.addTextureAtlas(a.key, a.url, a.data, d, a.format) : "xml" === a.type && this.game.cache.addXML(a.key, a.url, d), this.asyncComplete(a)
  8715. },
  8716. parseXml: function(a) {
  8717. var b;
  8718. try {
  8719. if (window.DOMParser) {
  8720. var c = new DOMParser;
  8721. b = c.parseFromString(a, "text/xml")
  8722. } else b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a)
  8723. } catch (d) {
  8724. b = null
  8725. }
  8726. return b && b.documentElement && !b.getElementsByTagName("parsererror").length ? b : null
  8727. },
  8728. updateProgress: function() {
  8729. this.preloadSprite && (0 === this.preloadSprite.direction ? this.preloadSprite.rect.width = Math.floor(this.preloadSprite.width / 100 * this.progress) : this.preloadSprite.rect.height = Math.floor(this.preloadSprite.height / 100 * this.progress), this.preloadSprite.sprite ? this.preloadSprite.sprite.updateCrop() : this.preloadSprite = null)
  8730. },
  8731. totalLoadedFiles: function() {
  8732. return this._loadedFileCount
  8733. },
  8734. totalQueuedFiles: function() {
  8735. return this._totalFileCount - this._loadedFileCount
  8736. },
  8737. totalLoadedPacks: function() {
  8738. return this._totalPackCount
  8739. },
  8740. totalQueuedPacks: function() {
  8741. return this._totalPackCount - this._loadedPackCount
  8742. }
  8743. }, Object.defineProperty(c.Loader.prototype, "progressFloat", {
  8744. get: function() {
  8745. var a = this._loadedFileCount / this._totalFileCount * 100;
  8746. return c.Math.clamp(a || 0, 0, 100)
  8747. }
  8748. }), Object.defineProperty(c.Loader.prototype, "progress", {
  8749. get: function() {
  8750. return Math.round(this.progressFloat)
  8751. }
  8752. }), c.Loader.prototype.constructor = c.Loader, c.LoaderParser = {
  8753. bitmapFont: function(a, b, c, d, e) {
  8754. var f = {},
  8755. g = b.getElementsByTagName("info")[0],
  8756. h = b.getElementsByTagName("common")[0];
  8757. f.font = g.getAttribute("face"), f.size = parseInt(g.getAttribute("size"), 10), f.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + e, f.chars = {};
  8758. for (var i = b.getElementsByTagName("char"), j = 0; j < i.length; j++) {
  8759. var k = parseInt(i[j].getAttribute("id"), 10),
  8760. 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));
  8761. f.chars[k] = {
  8762. xOffset: parseInt(i[j].getAttribute("xoffset"), 10),
  8763. yOffset: parseInt(i[j].getAttribute("yoffset"), 10),
  8764. xAdvance: parseInt(i[j].getAttribute("xadvance"), 10) + d,
  8765. kerning: {},
  8766. texture: PIXI.TextureCache[c] = new PIXI.Texture(PIXI.BaseTextureCache[c], l)
  8767. }
  8768. }
  8769. var m = b.getElementsByTagName("kerning");
  8770. for (j = 0; j < m.length; j++) {
  8771. var n = parseInt(m[j].getAttribute("first"), 10),
  8772. o = parseInt(m[j].getAttribute("second"), 10),
  8773. p = parseInt(m[j].getAttribute("amount"), 10);
  8774. f.chars[o].kerning[n] = p
  8775. }
  8776. PIXI.BitmapText.fonts[c] = f
  8777. }
  8778. }, c.AudioSprite = function(a, b) {
  8779. this.game = a, this.key = b, this.config = this.game.cache.getJSON(b + "-audioatlas"), this.autoplayKey = null, this.autoplay = !1, this.sounds = {};
  8780. for (var c in this.config.spritemap) {
  8781. var d = this.config.spritemap[c],
  8782. e = this.game.add.sound(this.key);
  8783. e.addMarker(c, d.start, d.end - d.start, null, d.loop), this.sounds[c] = e
  8784. }
  8785. this.config.autoplay && (this.autoplayKey = this.config.autoplay, this.play(this.autoplayKey), this.autoplay = this.sounds[this.autoplayKey])
  8786. }, c.AudioSprite.prototype = {
  8787. play: function(a, b) {
  8788. return "undefined" == typeof b && (b = 1), this.sounds[a].play(a, null, b)
  8789. },
  8790. stop: function(a) {
  8791. if (a) this.sounds[a].stop();
  8792. else
  8793. for (var b in this.sounds) this.sounds[b].stop()
  8794. },
  8795. get: function(a) {
  8796. return this.sounds[a]
  8797. }
  8798. }, c.AudioSprite.prototype.constructor = c.AudioSprite, c.Sound = function(a, b, d, e, f) {
  8799. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = a.sound.connectToMaster), this.game = a, this.name = b, this.key = b, 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.fadeTween = null, this.pendingPlayback = !1, this.override = !1, this.allowMultiple = !1, this.usingWebAudio = this.game.sound.usingWebAudio, this.usingAudioTag = this.game.sound.usingAudioTag, this.externalNode = null, this.masterGainNode = null, this.gainNode = null, this._sound = 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.usingAudioTag && (this.game.cache.getSound(b) && this.game.cache.isSoundReady(b) ? (this._sound = this.game.cache.getSoundData(b), this.totalDuration = 0, this._sound.duration && (this.totalDuration = this._sound.duration)) : this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this)), this.onDecoded = new c.Signal, this.onPlay = new c.Signal, this.onPause = new c.Signal, this.onResume = new c.Signal, this.onLoop = new c.Signal, this.onStop = new c.Signal, this.onMute = new c.Signal, this.onMarkerComplete = new c.Signal, this.onFadeComplete = new c.Signal, this._volume = d, this._buffer = null, this._muted = !1, this._tempMarker = 0, this._tempPosition = 0, this._tempVolume = 0, this._muteVolume = 0, this._tempLoop = 0, this._paused = !1, this._onDecodedEventDispatched = !1
  8800. }, c.Sound.prototype = {
  8801. soundHasUnlocked: function(a) {
  8802. a === this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration)
  8803. },
  8804. addMarker: function(a, b, c, d, e) {
  8805. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), this.markers[a] = {
  8806. name: a,
  8807. start: b,
  8808. stop: b + c,
  8809. volume: d,
  8810. duration: c,
  8811. durationMS: 1e3 * c,
  8812. loop: e
  8813. }
  8814. },
  8815. removeMarker: function(a) {
  8816. delete this.markers[a]
  8817. },
  8818. onEndedHandler: function() {
  8819. this.isPlaying = !1, this.stop()
  8820. },
  8821. update: function() {
  8822. 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.time - this.startTime, this.currentTime >= this.durationMS && (this.usingWebAudio ? this.loop ? (this.onLoop.dispatch(this), "" === this.currentMarker ? (this.currentTime = 0, this.startTime = this.game.time.time) : (this.onMarkerComplete.dispatch(this.currentMarker, this), this.play(this.currentMarker, 0, this.volume, !0, !0))) : "" !== this.currentMarker && this.stop() : this.loop ? (this.onLoop.dispatch(this), this.play(this.currentMarker, 0, this.volume, !0, !0)) : this.stop()))
  8823. },
  8824. loopFull: function(a) {
  8825. this.play(null, 0, a, !0)
  8826. },
  8827. play: function(a, b, c, d, e) {
  8828. if (("undefined" == typeof a || a === !1 || null === a) && (a = ""), "undefined" == typeof e && (e = !0), this.isPlaying && !this.allowMultiple && !e && !this.override) return this;
  8829. if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || e))
  8830. if (this.usingWebAudio)
  8831. if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
  8832. else try {
  8833. this._sound.stop(0)
  8834. } catch (f) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
  8835. if ("" === a && Object.keys(this.markers).length > 0) return this;
  8836. if ("" !== a) {
  8837. if (this.currentMarker = a, !this.markers[a]) return this;
  8838. 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
  8839. } 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;
  8840. 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.loop && "" === a && (this._sound.loop = !0), this.loop || "" !== a || (this._sound.onended = this.onEndedHandler.bind(this)), this.totalDuration = this._sound.buffer.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = Math.ceil(1e3 * this.totalDuration)), "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, this.position, this.duration) : this.loop && "" === a ? this._sound.start(0) : this._sound.start(0, this.position, this.duration), this.isPlaying = !0, this.startTime = this.game.time.time, 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.time, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : this.pendingPlayback = !0, this
  8841. },
  8842. restart: function(a, b, c, d) {
  8843. a = a || "", b = b || 0, c = c || 1, "undefined" == typeof d && (d = !1), this.play(a, b, c, d, !0)
  8844. },
  8845. pause: function() {
  8846. this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.time, this.onPause.dispatch(this), this.stop())
  8847. },
  8848. resume: function() {
  8849. if (this.paused && this._sound) {
  8850. if (this.usingWebAudio) {
  8851. var a = this.position + this.pausedPosition / 1e3;
  8852. 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), this.loop || "" !== this.currentMarker || (this._sound.onended = this.onEndedHandler.bind(this));
  8853. var b = this.duration - this.pausedPosition / 1e3;
  8854. "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, a, b) : this._sound.start(0, a, b)
  8855. } else this._sound.play();
  8856. this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.time - this.pausedTime, this.onResume.dispatch(this)
  8857. }
  8858. },
  8859. stop: function() {
  8860. if (this.isPlaying && this._sound)
  8861. if (this.usingWebAudio)
  8862. if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
  8863. else try {
  8864. this._sound.stop(0)
  8865. } catch (a) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
  8866. this.pendingPlayback = !1, this.isPlaying = !1;
  8867. var b = this.currentMarker;
  8868. "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", null !== this.fadeTween && this.fadeTween.stop(), this.paused || this.onStop.dispatch(this, b)
  8869. },
  8870. fadeIn: function(a, b, c) {
  8871. "undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = this.currentMarker), this.paused || (this.play(c, 0, 0, b), this.fadeTo(a, 1))
  8872. },
  8873. fadeOut: function(a) {
  8874. this.fadeTo(a, 0)
  8875. },
  8876. fadeTo: function(a, b) {
  8877. if (this.isPlaying && !this.paused && b !== this.volume) {
  8878. if ("undefined" == typeof a && (a = 1e3), "undefined" == typeof b) return void console.warn("Phaser.Sound.fadeTo: No Volume Specified.");
  8879. this.fadeTween = this.game.add.tween(this).to({
  8880. volume: b
  8881. }, a, c.Easing.Linear.None, !0), this.fadeTween.onComplete.add(this.fadeComplete, this)
  8882. }
  8883. },
  8884. fadeComplete: function() {
  8885. this.onFadeComplete.dispatch(this, this.volume), 0 === this.volume && this.stop()
  8886. },
  8887. destroy: function(a) {
  8888. "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())
  8889. }
  8890. }, c.Sound.prototype.constructor = c.Sound, Object.defineProperty(c.Sound.prototype, "isDecoding", {
  8891. get: function() {
  8892. return this.game.cache.getSound(this.key).isDecoding
  8893. }
  8894. }), Object.defineProperty(c.Sound.prototype, "isDecoded", {
  8895. get: function() {
  8896. return this.game.cache.isSoundDecoded(this.key)
  8897. }
  8898. }), Object.defineProperty(c.Sound.prototype, "mute", {
  8899. get: function() {
  8900. return this._muted || this.game.sound.mute
  8901. },
  8902. set: function(a) {
  8903. 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)
  8904. }
  8905. }), Object.defineProperty(c.Sound.prototype, "volume", {
  8906. get: function() {
  8907. return this._volume
  8908. },
  8909. set: function(a) {
  8910. 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)
  8911. }
  8912. }), c.SoundManager = function(a) {
  8913. this.game = a, this.onSoundDecode = new c.Signal, this._codeMuted = !1, this._muted = !1, this._unlockSource = null, this._volume = 1, this._sounds = [], this._watchList = new c.ArraySet, this._watching = !1, this._watchCallback = null, this._watchContext = null, this.context = null, this.usingWebAudio = !0, this.usingAudioTag = !1, this.noAudio = !1, this.connectToMaster = !0, this.touchLocked = !1, this.channels = 32
  8914. }, c.SoundManager.prototype = {
  8915. boot: function() {
  8916. 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) {
  8917. if (window.PhaserGlobal.disableAudio === !0) return this.usingWebAudio = !1, void(this.noAudio = !0);
  8918. if (window.PhaserGlobal.disableWebAudio === !0) return this.usingWebAudio = !1, this.usingAudioTag = !0, void(this.noAudio = !1)
  8919. }
  8920. if (window.PhaserGlobal && window.PhaserGlobal.audioContext) this.context = window.PhaserGlobal.audioContext;
  8921. else if (window.AudioContext) try {
  8922. this.context = new window.AudioContext
  8923. } catch (a) {
  8924. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  8925. } else if (window.webkitAudioContext) try {
  8926. this.context = new window.webkitAudioContext
  8927. } catch (a) {
  8928. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  8929. }
  8930. 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))
  8931. },
  8932. unlock: function() {
  8933. if (this.touchLocked !== !1)
  8934. 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;
  8935. else {
  8936. var a = this.context.createBuffer(1, 1, 22050);
  8937. this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = a, this._unlockSource.connect(this.context.destination), "undefined" == typeof this._unlockSource.start ? this._unlockSource.noteOn(0) : this._unlockSource.start(0)
  8938. }
  8939. },
  8940. stopAll: function() {
  8941. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].stop()
  8942. },
  8943. pauseAll: function() {
  8944. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].pause()
  8945. },
  8946. resumeAll: function() {
  8947. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].resume()
  8948. },
  8949. decode: function(a, b) {
  8950. b = b || null;
  8951. var c = this.game.cache.getSoundData(a);
  8952. if (c && this.game.cache.isSoundDecoded(a) === !1) {
  8953. this.game.cache.updateSound(a, "isDecoding", !0);
  8954. var d = this;
  8955. this.context.decodeAudioData(c, function(c) {
  8956. c && (d.game.cache.decodedSound(a, c), d.onSoundDecode.dispatch(a, b))
  8957. })
  8958. }
  8959. },
  8960. setDecodedCallback: function(a, b, d) {
  8961. "string" == typeof a && (a = [a]), this._watchList.reset();
  8962. for (var e = 0; e < a.length; e++) a[e] instanceof c.Sound ? this.game.cache.isSoundDecoded(a[e].key) || this._watchList.add(a[e].key) : this.game.cache.isSoundDecoded(a[e]) || this._watchList.add(a[e]);
  8963. 0 === this._watchList.total ? (this._watching = !1, b.call(d)) : (this._watching = !0, this._watchCallback = b, this._watchContext = d)
  8964. },
  8965. update: function() {
  8966. 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);
  8967. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].update();
  8968. if (this._watching) {
  8969. for (var b = this._watchList.first; b;) this.game.cache.isSoundDecoded(b) && this._watchList.remove(b), b = this._watchList.next;
  8970. 0 === this._watchList.total && (this._watching = !1, this._watchCallback.call(this._watchContext))
  8971. }
  8972. },
  8973. add: function(a, b, d, e) {
  8974. "undefined" == typeof b && (b = 1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = this.connectToMaster);
  8975. var f = new c.Sound(this.game, a, b, d, e);
  8976. return this._sounds.push(f), f
  8977. },
  8978. addSprite: function(a) {
  8979. var b = new c.AudioSprite(this.game, a);
  8980. return b
  8981. },
  8982. remove: function(a) {
  8983. for (var b = this._sounds.length; b--;)
  8984. if (this._sounds[b] === a) return this._sounds[b].destroy(!1), this._sounds.splice(b, 1), !0;
  8985. return !1
  8986. },
  8987. removeByKey: function(a) {
  8988. 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++);
  8989. return c
  8990. },
  8991. play: function(a, b, c) {
  8992. var d = this.add(a, b, c);
  8993. return d.play(), d
  8994. },
  8995. setMute: function() {
  8996. if (!this._muted) {
  8997. this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
  8998. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !0)
  8999. }
  9000. },
  9001. unsetMute: function() {
  9002. if (this._muted && !this._codeMuted) {
  9003. this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
  9004. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !1)
  9005. }
  9006. },
  9007. destroy: function() {
  9008. this.stopAll();
  9009. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].destroy();
  9010. this._sounds = [], this.onSoundDecode.dispose(), this.context && window.PhaserGlobal && (window.PhaserGlobal.audioContext = this.context)
  9011. }
  9012. }, c.SoundManager.prototype.constructor = c.SoundManager, Object.defineProperty(c.SoundManager.prototype, "mute", {
  9013. get: function() {
  9014. return this._muted
  9015. },
  9016. set: function(a) {
  9017. if (a = a || null) {
  9018. if (this._muted) return;
  9019. this._codeMuted = !0, this.setMute()
  9020. } else {
  9021. if (!this._muted) return;
  9022. this._codeMuted = !1, this.unsetMute()
  9023. }
  9024. }
  9025. }), Object.defineProperty(c.SoundManager.prototype, "volume", {
  9026. get: function() {
  9027. return this.usingWebAudio ? this.masterGain.gain.value : this._volume
  9028. },
  9029. set: function(a) {
  9030. if (this._volume = a, this.usingWebAudio) this.masterGain.gain.value = a;
  9031. else
  9032. for (var b = 0; b < this._sounds.length; b++) this._sounds[b].usingAudioTag && (this._sounds[b].volume = this._sounds[b].volume * a)
  9033. }
  9034. }), c.Utils.Debug = function(a) {
  9035. this.game = a, this.sprite = null, this.bmd = null, this.canvas = 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
  9036. }, c.Utils.Debug.prototype = {
  9037. boot: function() {
  9038. this.game.renderType === c.CANVAS ? this.context = this.game.context : (this.bmd = this.game.make.bitmapData(this.game.width, this.game.height), this.sprite = this.game.make.image(0, 0, this.bmd), this.game.stage.addChild(this.sprite), this.canvas = c.Canvas.create(this.game.width, this.game.height, "", !0), this.context = this.canvas.getContext("2d"))
  9039. },
  9040. preUpdate: function() {
  9041. this.dirty && this.sprite && (this.bmd.clear(), this.bmd.draw(this.canvas, 0, 0), this.context.clearRect(0, 0, this.game.width, this.game.height), this.dirty = !1)
  9042. },
  9043. reset: function() {
  9044. this.context && this.context.clearRect(0, 0, this.game.width, this.game.height), this.sprite && this.bmd.clear()
  9045. },
  9046. start: function(a, b, c, d) {
  9047. "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.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
  9048. },
  9049. stop: function() {
  9050. this.context.restore(), this.context.globalAlpha = this.currentAlpha
  9051. },
  9052. line: function() {
  9053. 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;
  9054. this.currentY += this.lineHeight
  9055. },
  9056. soundInfo: function(a, b, c, d) {
  9057. 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()
  9058. },
  9059. cameraInfo: function(a, b, c, d) {
  9060. this.start(b, c, d), this.line("Camera (" + a.width + " x " + a.height + ")"), this.line("X: " + a.x + " Y: " + a.y), a.bounds && 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.line("Total in view: " + a.totalInView), this.stop()
  9061. },
  9062. timer: function(a, b, c, d) {
  9063. 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()
  9064. },
  9065. pointer: function(a, b, c, d, e) {
  9066. 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()))
  9067. },
  9068. spriteInputInfo: function(a, b, c, d) {
  9069. 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()
  9070. },
  9071. key: function(a, b, c, d) {
  9072. this.start(b, c, d, 150), this.line("Key:", a.keyCode, "isDown:", a.isDown), this.line("justDown:", a.justDown, "justUp:", a.justUp), this.line("Time Down:", a.timeDown.toFixed(0), "duration:", a.duration.toFixed(0)), this.stop()
  9073. },
  9074. inputInfo: function(a, b, c) {
  9075. 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()
  9076. },
  9077. spriteBounds: function(a, b, c) {
  9078. var d = a.getBounds();
  9079. d.x += this.game.camera.x, d.y += this.game.camera.y, this.rectangle(d, b, c)
  9080. },
  9081. ropeSegments: function(a, b, c) {
  9082. var d = a.segments;
  9083. d.forEach(function(a) {
  9084. this.rectangle(a, b, c)
  9085. }, this)
  9086. },
  9087. spriteInfo: function(a, b, c, d) {
  9088. 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.line("bounds x: " + a._bounds.x.toFixed(1) + " y: " + a._bounds.y.toFixed(1) + " w: " + a._bounds.width.toFixed(1) + " h: " + a._bounds.height.toFixed(1)), this.stop()
  9089. },
  9090. spriteCoords: function(a, b, c, d) {
  9091. 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()
  9092. },
  9093. lineInfo: function(a, b, c, d) {
  9094. 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()
  9095. },
  9096. pixel: function(a, b, c, d) {
  9097. d = d || 2, this.start(), this.context.fillStyle = c, this.context.fillRect(a, b, d, d), this.stop()
  9098. },
  9099. geom: function(a, b, d, e) {
  9100. "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = 0), b = b || "rgba(0,255,0,0.4)", this.start(), this.context.fillStyle = b, this.context.strokeStyle = b, a instanceof c.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 c.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 c.Point || 3 === e ? this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, 4, 4) : (a instanceof c.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()
  9101. },
  9102. rectangle: function(a, b, c) {
  9103. "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()
  9104. },
  9105. text: function(a, b, c, d, e) {
  9106. 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()
  9107. },
  9108. quadTree: function(a, b) {
  9109. b = b || "rgba(255,0,0,0.3)", this.start();
  9110. var c = a.bounds;
  9111. if (0 === a.nodes.length) {
  9112. 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)";
  9113. 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)
  9114. } else
  9115. for (var d = 0; d < a.nodes.length; d++) this.quadTree(a.nodes[d]);
  9116. this.stop()
  9117. },
  9118. body: function(a, b, d) {
  9119. a.body && (this.start(), a.body.type === c.Physics.ARCADE ? c.Physics.Arcade.Body.render(this.context, a.body, b, d) : a.body.type === c.Physics.NINJA ? c.Physics.Ninja.Body.render(this.context, a.body, b, d) : a.body.type === c.Physics.BOX2D && c.Physics.Box2D.renderBody(this.context, a.body, b), this.stop())
  9120. },
  9121. bodyInfo: function(a, b, d, e) {
  9122. a.body && (this.start(b, d, e, 210), a.body.type === c.Physics.ARCADE ? c.Physics.Arcade.Body.renderBodyInfo(this, a.body) : a.body.type === c.Physics.BOX2D && this.game.physics.box2d.renderBodyInfo(this, a.body), this.stop())
  9123. },
  9124. box2dWorld: function() {
  9125. this.start(), this.context.translate(-this.game.camera.view.x, -this.game.camera.view.y, 0), this.game.physics.box2d.renderDebugDraw(this.context), this.stop()
  9126. },
  9127. box2dBody: function(a, b) {
  9128. this.start(), c.Physics.Box2D.renderBody(this.context, a, b), this.stop()
  9129. }
  9130. }, c.Utils.Debug.prototype.constructor = c.Utils.Debug, c.ArraySet = function(a) {
  9131. this.position = 0, this.list = a || []
  9132. }, c.ArraySet.prototype = {
  9133. add: function(a) {
  9134. return this.exists(a) || this.list.push(a), a
  9135. },
  9136. getIndex: function(a) {
  9137. return this.list.indexOf(a)
  9138. },
  9139. getByKey: function(a, b) {
  9140. for (var c = this.list.length; c--;)
  9141. if (this.list[c][a] === b) return this.list[c];
  9142. return null
  9143. },
  9144. exists: function(a) {
  9145. return this.list.indexOf(a) > -1
  9146. },
  9147. reset: function() {
  9148. this.list.length = 0
  9149. },
  9150. remove: function(a) {
  9151. var b = this.list.indexOf(a);
  9152. return b > -1 ? (this.list.splice(b, 1), a) : void 0
  9153. },
  9154. setAll: function(a, b) {
  9155. for (var c = this.list.length; c--;) this.list[c] && (this.list[c][a] = b)
  9156. },
  9157. callAll: function(a) {
  9158. 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)
  9159. },
  9160. removeAll: function(a) {
  9161. "undefined" == typeof a && (a = !1);
  9162. for (var b = this.list.length; b--;)
  9163. if (this.list[b]) {
  9164. var c = this.remove(this.list[b]);
  9165. a && c.destroy()
  9166. }
  9167. this.position = 0, this.list = []
  9168. }
  9169. }, Object.defineProperty(c.ArraySet.prototype, "total", {
  9170. get: function() {
  9171. return this.list.length
  9172. }
  9173. }), Object.defineProperty(c.ArraySet.prototype, "first", {
  9174. get: function() {
  9175. return this.position = 0, this.list.length > 0 ? this.list[0] : null
  9176. }
  9177. }), Object.defineProperty(c.ArraySet.prototype, "next", {
  9178. get: function() {
  9179. return this.position < this.list.length ? (this.position++, this.list[this.position]) : null
  9180. }
  9181. }), c.ArraySet.prototype.constructor = c.ArraySet, c.ArrayList = c.ArraySet, c.ArrayUtils = {
  9182. getRandomItem: function(a, b, c) {
  9183. if (null == a) return null;
  9184. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = a.length);
  9185. var d = b + Math.floor(Math.random() * c);
  9186. return void 0 === a[d] ? null : a[d]
  9187. },
  9188. removeRandomItem: function(a, b, c) {
  9189. if (null == a) return null;
  9190. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = a.length);
  9191. var d = b + Math.floor(Math.random() * c);
  9192. if (d < a.length) {
  9193. var e = a.splice(d, 1);
  9194. return void 0 === e[0] ? null : e[0]
  9195. }
  9196. return null
  9197. },
  9198. shuffle: function(a) {
  9199. for (var b = a.length - 1; b > 0; b--) {
  9200. var c = Math.floor(Math.random() * (b + 1)),
  9201. d = a[b];
  9202. a[b] = a[c], a[c] = d
  9203. }
  9204. return a
  9205. },
  9206. transposeMatrix: function(a) {
  9207. for (var b = a.length, c = a[0].length, d = new Array(c), e = 0; c > e; e++) {
  9208. d[e] = new Array(b);
  9209. for (var f = b - 1; f > -1; f--) d[e][f] = a[f][e]
  9210. }
  9211. return d
  9212. },
  9213. rotateMatrix: function(a, b) {
  9214. if ("string" != typeof b && (b = (b % 360 + 360) % 360), 90 === b || -270 === b || "rotateLeft" === b) a = c.ArrayUtils.transposeMatrix(a), a = a.reverse();
  9215. else if (-90 === b || 270 === b || "rotateRight" === b) a = a.reverse(), a = c.ArrayUtils.transposeMatrix(a);
  9216. else if (180 === Math.abs(b) || "rotate180" === b) {
  9217. for (var d = 0; d < a.length; d++) a[d].reverse();
  9218. a = a.reverse()
  9219. }
  9220. return a
  9221. },
  9222. findClosest: function(a, b) {
  9223. if (!b.length) return 0 / 0;
  9224. if (1 === b.length || a < b[0]) return b[0];
  9225. for (var c = 1; b[c] < a;) c++;
  9226. var d = b[c - 1],
  9227. e = c < b.length ? b[c] : Number.POSITIVE_INFINITY;
  9228. return a - d >= e - a ? e : d
  9229. },
  9230. rotate: function(a) {
  9231. var b = a.shift();
  9232. return a.push(b), b
  9233. },
  9234. numberArray: function(a, b) {
  9235. for (var c = [], d = a; b >= d; d++) c.push(d);
  9236. return c
  9237. },
  9238. numberArrayStep: function(a, b, d) {
  9239. a = +a || 0;
  9240. var e = typeof b;
  9241. "number" !== e && "string" !== e || !d || d[b] !== a || (b = d = null), d = null == d ? 1 : +d || 0, null === b ? (b = a, a = 0) : b = +b || 0;
  9242. for (var f = -1, g = Math.max(c.Math.roundAwayFromZero((b - a) / (d || 1)), 0), h = new Array(g); ++f < g;) h[f] = a, a += d;
  9243. return h
  9244. }
  9245. }, c.Color = {
  9246. packPixel: function(a, b, d, e) {
  9247. return c.Device.LITTLE_ENDIAN ? (e << 24 | d << 16 | b << 8 | a) >>> 0 : (a << 24 | b << 16 | d << 8 | e) >>> 0
  9248. },
  9249. unpackPixel: function(a, b, d, e) {
  9250. return ("undefined" == typeof b || null === b) && (b = c.Color.createColor()), ("undefined" == typeof d || null === d) && (d = !1), ("undefined" == typeof e || null === e) && (e = !1), c.Device.LITTLE_ENDIAN ? (b.a = (4278190080 & a) >>> 24, b.b = (16711680 & a) >>> 16, b.g = (65280 & a) >>> 8, b.r = 255 & a) : (b.r = (4278190080 & a) >>> 24, b.g = (16711680 & a) >>> 16, b.b = (65280 & a) >>> 8, b.a = 255 & a), b.color = a, b.rgba = "rgba(" + b.r + "," + b.g + "," + b.b + "," + b.a / 255 + ")", d && c.Color.RGBtoHSL(b.r, b.g, b.b, b), e && c.Color.RGBtoHSV(b.r, b.g, b.b, b), b
  9251. },
  9252. fromRGBA: function(a, b) {
  9253. return b || (b = c.Color.createColor()), b.r = (4278190080 & a) >>> 24, b.g = (16711680 & a) >>> 16, b.b = (65280 & a) >>> 8, b.a = 255 & a, b.rgba = "rgba(" + b.r + "," + b.g + "," + b.b + "," + b.a + ")", b
  9254. },
  9255. toRGBA: function(a, b, c, d) {
  9256. return a << 24 | b << 16 | c << 8 | d
  9257. },
  9258. RGBtoHSL: function(a, b, d, e) {
  9259. e || (e = c.Color.createColor(a, b, d, 1)), a /= 255, b /= 255, d /= 255;
  9260. var f = Math.min(a, b, d),
  9261. g = Math.max(a, b, d);
  9262. if (e.h = 0, e.s = 0, e.l = (g + f) / 2, g !== f) {
  9263. var h = g - f;
  9264. e.s = e.l > .5 ? h / (2 - g - f) : h / (g + f), g === a ? e.h = (b - d) / h + (d > b ? 6 : 0) : g === b ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - b) / h + 4), e.h /= 6
  9265. }
  9266. return e
  9267. },
  9268. HSLtoRGB: function(a, b, d, e) {
  9269. if (e ? (e.r = d, e.g = d, e.b = d) : e = c.Color.createColor(d, d, d), 0 !== b) {
  9270. var f = .5 > d ? d * (1 + b) : d + b - d * b,
  9271. g = 2 * d - f;
  9272. e.r = c.Color.hueToColor(g, f, a + 1 / 3), e.g = c.Color.hueToColor(g, f, a), e.b = c.Color.hueToColor(g, f, a - 1 / 3)
  9273. }
  9274. 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), c.Color.updateColor(e), e
  9275. },
  9276. RGBtoHSV: function(a, b, d, e) {
  9277. e || (e = c.Color.createColor(a, b, d, 255)), a /= 255, b /= 255, d /= 255;
  9278. var f = Math.min(a, b, d),
  9279. g = Math.max(a, b, d),
  9280. h = g - f;
  9281. return e.h = 0, e.s = 0 === g ? 0 : h / g, e.v = g, g !== f && (g === a ? e.h = (b - d) / h + (d > b ? 6 : 0) : g === b ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - b) / h + 4), e.h /= 6), e
  9282. },
  9283. HSVtoRGB: function(a, b, d, e) {
  9284. "undefined" == typeof e && (e = c.Color.createColor(0, 0, 0, 1, a, b, 0, d));
  9285. var f, g, h, i = Math.floor(6 * a),
  9286. j = 6 * a - i,
  9287. k = d * (1 - b),
  9288. l = d * (1 - j * b),
  9289. m = d * (1 - (1 - j) * b);
  9290. switch (i % 6) {
  9291. case 0:
  9292. f = d, g = m, h = k;
  9293. break;
  9294. case 1:
  9295. f = l, g = d, h = k;
  9296. break;
  9297. case 2:
  9298. f = k, g = d, h = m;
  9299. break;
  9300. case 3:
  9301. f = k, g = l, h = d;
  9302. break;
  9303. case 4:
  9304. f = m, g = k, h = d;
  9305. break;
  9306. case 5:
  9307. f = d, g = k, h = l
  9308. }
  9309. return e.r = Math.floor(255 * f), e.g = Math.floor(255 * g), e.b = Math.floor(255 * h), c.Color.updateColor(e), e
  9310. },
  9311. hueToColor: function(a, b, c) {
  9312. 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
  9313. },
  9314. createColor: function(a, b, d, e, f, g, h, i) {
  9315. var j = {
  9316. r: a || 0,
  9317. g: b || 0,
  9318. b: d || 0,
  9319. a: e || 1,
  9320. h: f || 0,
  9321. s: g || 0,
  9322. l: h || 0,
  9323. v: i || 0,
  9324. color: 0,
  9325. color32: 0,
  9326. rgba: ""
  9327. };
  9328. return j.color = c.Color.getColor(j.r, j.g, j.b), j.color32 = c.Color.getColor32(j.a, j.r, j.g, j.b), c.Color.updateColor(j)
  9329. },
  9330. updateColor: function(a) {
  9331. return a.rgba = "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + a.a.toString() + ")", a
  9332. },
  9333. getColor32: function(a, b, c, d) {
  9334. return a << 24 | b << 16 | c << 8 | d
  9335. },
  9336. getColor: function(a, b, c) {
  9337. return a << 16 | b << 8 | c
  9338. },
  9339. RGBtoString: function(a, b, d, e, f) {
  9340. return "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = "#"), "#" === f ? "#" + ((1 << 24) + (a << 16) + (b << 8) + d).toString(16).slice(1) : "0x" + c.Color.componentToHex(e) + c.Color.componentToHex(a) + c.Color.componentToHex(b) + c.Color.componentToHex(d)
  9341. },
  9342. hexToRGB: function(a) {
  9343. var b = c.Color.hexToColor(a);
  9344. return b ? c.Color.getColor32(b.a, b.r, b.g, b.b) : void 0
  9345. },
  9346. hexToColor: function(a, b) {
  9347. a = a.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function(a, b, c, d) {
  9348. return b + b + c + c + d + d
  9349. });
  9350. var d = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
  9351. if (d) {
  9352. var e = parseInt(d[1], 16),
  9353. f = parseInt(d[2], 16),
  9354. g = parseInt(d[3], 16);
  9355. b ? (b.r = e, b.g = f, b.b = g) : b = c.Color.createColor(e, f, g)
  9356. }
  9357. return b
  9358. },
  9359. webToColor: function(a, b) {
  9360. b || (b = c.Color.createColor());
  9361. var d = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(a);
  9362. return d && (b.r = parseInt(d[1], 10), b.g = parseInt(d[2], 10), b.b = parseInt(d[3], 10), b.a = void 0 !== d[4] ? parseFloat(d[4]) : 1), b
  9363. },
  9364. valueToColor: function(a, b) {
  9365. if (b || (b = c.Color.createColor()), "string" == typeof a) return 0 === a.indexOf("rgb") ? c.Color.webToColor(a, b) : (b.a = 1, c.Color.hexToColor(a, b));
  9366. if ("number" == typeof a) {
  9367. var d = c.Color.getRGB(a);
  9368. return b.r = d.r, b.g = d.g, b.b = d.b, b.a = d.a / 255, b
  9369. }
  9370. return b
  9371. },
  9372. componentToHex: function(a) {
  9373. var b = a.toString(16);
  9374. return 1 == b.length ? "0" + b : b
  9375. },
  9376. HSVColorWheel: function(a, b) {
  9377. "undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = 1);
  9378. for (var d = [], e = 0; 359 >= e; e++) d.push(c.Color.HSVtoRGB(e / 359, a, b));
  9379. return d
  9380. },
  9381. HSLColorWheel: function(a, b) {
  9382. "undefined" == typeof a && (a = .5), "undefined" == typeof b && (b = .5);
  9383. for (var d = [], e = 0; 359 >= e; e++) d.push(c.Color.HSLtoRGB(e / 359, a, b));
  9384. return d
  9385. },
  9386. interpolateColor: function(a, b, d, e, f) {
  9387. "undefined" == typeof f && (f = 255);
  9388. var g = c.Color.getRGB(a),
  9389. h = c.Color.getRGB(b),
  9390. i = (h.red - g.red) * e / d + g.red,
  9391. j = (h.green - g.green) * e / d + g.green,
  9392. k = (h.blue - g.blue) * e / d + g.blue;
  9393. return c.Color.getColor32(f, i, j, k)
  9394. },
  9395. interpolateColorWithRGB: function(a, b, d, e, f, g) {
  9396. var h = c.Color.getRGB(a),
  9397. i = (b - h.red) * g / f + h.red,
  9398. j = (d - h.green) * g / f + h.green,
  9399. k = (e - h.blue) * g / f + h.blue;
  9400. return c.Color.getColor(i, j, k)
  9401. },
  9402. interpolateRGB: function(a, b, d, e, f, g, h, i) {
  9403. var j = (e - a) * i / h + a,
  9404. k = (f - b) * i / h + b,
  9405. l = (g - d) * i / h + d;
  9406. return c.Color.getColor(j, k, l)
  9407. },
  9408. getRandomColor: function(a, b, d) {
  9409. if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 255), "undefined" == typeof d && (d = 255), b > 255 || a > b) return c.Color.getColor(255, 255, 255);
  9410. var e = a + Math.round(Math.random() * (b - a)),
  9411. f = a + Math.round(Math.random() * (b - a)),
  9412. g = a + Math.round(Math.random() * (b - a));
  9413. return c.Color.getColor32(d, e, f, g)
  9414. },
  9415. getRGB: function(a) {
  9416. return a > 16777215 ? {
  9417. alpha: a >>> 24,
  9418. red: a >> 16 & 255,
  9419. green: a >> 8 & 255,
  9420. blue: 255 & a,
  9421. a: a >>> 24,
  9422. r: a >> 16 & 255,
  9423. g: a >> 8 & 255,
  9424. b: 255 & a
  9425. } : {
  9426. alpha: 255,
  9427. red: a >> 16 & 255,
  9428. green: a >> 8 & 255,
  9429. blue: 255 & a,
  9430. a: 255,
  9431. r: a >> 16 & 255,
  9432. g: a >> 8 & 255,
  9433. b: 255 & a
  9434. }
  9435. },
  9436. getWebRGB: function(a) {
  9437. if ("object" == typeof a) return "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + (a.a / 255).toString() + ")";
  9438. var b = c.Color.getRGB(a);
  9439. return "rgba(" + b.r.toString() + "," + b.g.toString() + "," + b.b.toString() + "," + (b.a / 255).toString() + ")"
  9440. },
  9441. getAlpha: function(a) {
  9442. return a >>> 24
  9443. },
  9444. getAlphaFloat: function(a) {
  9445. return (a >>> 24) / 255
  9446. },
  9447. getRed: function(a) {
  9448. return a >> 16 & 255
  9449. },
  9450. getGreen: function(a) {
  9451. return a >> 8 & 255
  9452. },
  9453. getBlue: function(a) {
  9454. return 255 & a
  9455. }
  9456. }, c.LinkedList = function() {
  9457. this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0
  9458. }, c.LinkedList.prototype = {
  9459. add: function(a) {
  9460. 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)
  9461. },
  9462. reset: function() {
  9463. this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0
  9464. },
  9465. remove: function(a) {
  9466. 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--)
  9467. },
  9468. callAll: function(a) {
  9469. if (this.first && this.last) {
  9470. var b = this.first;
  9471. do b && b[a] && b[a].call(b), b = b.next; while (b != this.last.next)
  9472. }
  9473. }
  9474. }, c.LinkedList.prototype.constructor = c.LinkedList, c.Physics = function(a, b) {
  9475. 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()
  9476. }, c.Physics.ARCADE = 0, c.Physics.P2JS = 1, c.Physics.NINJA = 2, c.Physics.BOX2D = 3, c.Physics.CHIPMUNK = 4, c.Physics.prototype = {
  9477. parseConfig: function() {
  9478. this.config.hasOwnProperty("arcade") && this.config.arcade !== !0 || !c.Physics.hasOwnProperty("Arcade") || (this.arcade = new c.Physics.Arcade(this.game), this.game.time.deltaCap = .2), this.config.hasOwnProperty("ninja") && this.config.ninja === !0 && c.Physics.hasOwnProperty("Ninja") && (this.ninja = new c.Physics.Ninja(this.game)), this.config.hasOwnProperty("p2") && this.config.p2 === !0 && c.Physics.hasOwnProperty("P2") && (this.p2 = new c.Physics.P2(this.game, this.config)), this.config.hasOwnProperty("box2d") && this.config.box2d === !0 && c.Physics.hasOwnProperty("BOX2D") && (this.box2d = new c.Physics.BOX2D(this.game, this.config))
  9479. },
  9480. startSystem: function(a) {
  9481. a === c.Physics.ARCADE ? this.arcade = new c.Physics.Arcade(this.game) : a === c.Physics.P2JS ? null === this.p2 ? this.p2 = new c.Physics.P2(this.game, this.config) : this.p2.reset() : a === c.Physics.NINJA ? this.ninja = new c.Physics.Ninja(this.game) : a === c.Physics.BOX2D && (null === this.box2d ? this.box2d = new c.Physics.Box2D(this.game, this.config) : this.box2d.reset())
  9482. },
  9483. enable: function(a, b, d) {
  9484. "undefined" == typeof b && (b = c.Physics.ARCADE), "undefined" == typeof d && (d = !1), b === c.Physics.ARCADE ? this.arcade.enable(a) : b === c.Physics.P2JS && this.p2 ? this.p2.enable(a, d) : b === c.Physics.NINJA && this.ninja ? this.ninja.enableAABB(a) : b === c.Physics.BOX2D && this.box2d && this.box2d.enable(a)
  9485. },
  9486. preUpdate: function() {
  9487. this.p2 && this.p2.preUpdate(), this.box2d && this.box2d.preUpdate()
  9488. },
  9489. update: function() {
  9490. this.p2 && this.p2.update(), this.box2d && this.box2d.update()
  9491. },
  9492. setBoundsToWorld: function() {
  9493. this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld(), this.box2d && this.box2d.setBoundsToWorld()
  9494. },
  9495. clear: function() {
  9496. this.p2 && this.p2.clear(), this.box2d && this.box2d.clear()
  9497. },
  9498. reset: function() {
  9499. this.p2 && this.p2.reset(), this.box2d && this.box2d.reset()
  9500. },
  9501. destroy: function() {
  9502. this.p2 && this.p2.destroy(), this.box2d && this.box2d.destroy(), this.arcade = null, this.ninja = null, this.p2 = null, this.box2d = null
  9503. }
  9504. }, c.Physics.prototype.constructor = c.Physics, c.Physics.Arcade = function(a) {
  9505. this.game = a, this.gravity = new c.Point, this.bounds = new c.Rectangle(0, 0, a.world.width, a.world.height), this.checkCollision = {
  9506. up: !0,
  9507. down: !0,
  9508. left: !0,
  9509. right: !0
  9510. }, this.maxObjects = 10, this.maxLevels = 4, this.OVERLAP_BIAS = 4, this.forceX = !1, this.sortDirection = c.Physics.Arcade.LEFT_RIGHT, this.skipQuadTree = !0, this.isPaused = !1, this.quadTree = new c.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._total = 0, this.setBoundsToWorld()
  9511. }, c.Physics.Arcade.prototype.constructor = c.Physics.Arcade, c.Physics.Arcade.SORT_NONE = 0, c.Physics.Arcade.LEFT_RIGHT = 1, c.Physics.Arcade.RIGHT_LEFT = 2, c.Physics.Arcade.TOP_BOTTOM = 3, c.Physics.Arcade.BOTTOM_TOP = 4, c.Physics.Arcade.prototype = {
  9512. setBounds: function(a, b, c, d) {
  9513. this.bounds.setTo(a, b, c, d)
  9514. },
  9515. setBoundsToWorld: function() {
  9516. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  9517. },
  9518. enable: function(a, b) {
  9519. "undefined" == typeof b && (b = !0);
  9520. var d = 1;
  9521. if (Array.isArray(a))
  9522. for (d = a.length; d--;) a[d] instanceof c.Group ? this.enable(a[d].children, b) : (this.enableBody(a[d]), b && a[d].hasOwnProperty("children") && a[d].children.length > 0 && this.enable(a[d], !0));
  9523. else a instanceof c.Group ? this.enable(a.children, b) : (this.enableBody(a), b && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, !0))
  9524. },
  9525. enableBody: function(a) {
  9526. a.hasOwnProperty("body") && null === a.body && (a.body = new c.Physics.Arcade.Body(a))
  9527. },
  9528. updateMotion: function(a) {
  9529. var b = this.computeVelocity(0, a, a.angularVelocity, a.angularAcceleration, a.angularDrag, a.maxAngular) - a.angularVelocity;
  9530. a.angularVelocity += b, 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)
  9531. },
  9532. computeVelocity: function(a, b, c, d, e, f) {
  9533. return "undefined" == typeof 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 && (e *= this.game.time.physicsElapsed, c - e > 0 ? c -= e : 0 > c + e ? c += e : c = 0), c > f ? c = f : -f > c && (c = -f), c
  9534. },
  9535. overlap: function(a, b, c, d, e) {
  9536. if (c = c || null, d = d || null, e = e || c, this._total = 0, !Array.isArray(a) && Array.isArray(b))
  9537. for (var f = 0; f < b.length; f++) this.collideHandler(a, b[f], c, d, e, !0);
  9538. else if (Array.isArray(a) && !Array.isArray(b))
  9539. for (var f = 0; f < a.length; f++) this.collideHandler(a[f], b, c, d, e, !0);
  9540. else if (Array.isArray(a) && Array.isArray(b))
  9541. for (var f = 0; f < a.length; f++)
  9542. for (var g = 0; g < b.length; g++) this.collideHandler(a[f], b[g], c, d, e, !0);
  9543. else this.collideHandler(a, b, c, d, e, !0);
  9544. return this._total > 0
  9545. },
  9546. collide: function(a, b, c, d, e) {
  9547. if (c = c || null, d = d || null, e = e || c, this._total = 0, !Array.isArray(a) && Array.isArray(b))
  9548. for (var f = 0; f < b.length; f++) this.collideHandler(a, b[f], c, d, e, !1);
  9549. else if (Array.isArray(a) && !Array.isArray(b))
  9550. for (var f = 0; f < a.length; f++) this.collideHandler(a[f], b, c, d, e, !1);
  9551. else if (Array.isArray(a) && Array.isArray(b))
  9552. for (var f = 0; f < a.length; f++)
  9553. for (var g = 0; g < b.length; g++) this.collideHandler(a[f], b[g], c, d, e, !1);
  9554. else this.collideHandler(a, b, c, d, e, !1);
  9555. return this._total > 0
  9556. },
  9557. sort: function(a) {
  9558. this.sortDirection === c.Physics.Arcade.LEFT_RIGHT ? a._hash.sort(function(a, b) {
  9559. return a.body && b.body ? a.body.x - b.body.x : -1
  9560. }) : this.sortDirection === c.Physics.Arcade.RIGHT_LEFT ? a._hash.sort(function(a, b) {
  9561. return a.body && b.body ? b.body.x - a.body.x : -1
  9562. }) : this.sortDirection === c.Physics.Arcade.TOP_BOTTOM ? a._hash.sort(function(a, b) {
  9563. return a.body && b.body ? a.body.y - b.body.y : -1
  9564. }) : this.sortDirection === c.Physics.Arcade.BOTTOM_TOP && a._hash.sort(function(a, b) {
  9565. return a.body && b.body ? b.body.y - a.body.y : -1
  9566. })
  9567. },
  9568. collideHandler: function(a, b, d, e, f, g) {
  9569. return "undefined" == typeof b && a.physicsType === c.GROUP ? (this.sort(a), void this.collideGroupVsSelf(a, d, e, f, g)) : void(a && b && a.exists && b.exists && (this.sortDirection !== c.Physics.Arcade.SORT_NONE && (a.physicsType === c.GROUP && this.sort(a), b.physicsType === c.GROUP && this.sort(b)), a.physicsType === c.SPRITE ? b.physicsType === c.SPRITE ? this.collideSpriteVsSprite(a, b, d, e, f, g) : b.physicsType === c.GROUP ? this.collideSpriteVsGroup(a, b, d, e, f, g) : b.physicsType === c.TILEMAPLAYER && this.collideSpriteVsTilemapLayer(a, b, d, e, f) : a.physicsType === c.GROUP ? b.physicsType === c.SPRITE ? this.collideSpriteVsGroup(b, a, d, e, f, g) : b.physicsType === c.GROUP ? this.collideGroupVsGroup(a, b, d, e, f, g) : b.physicsType === c.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, b, d, e, f, g) : a.physicsType === c.TILEMAPLAYER && (b.physicsType === c.SPRITE ? this.collideSpriteVsTilemapLayer(b, a, d, e, f, g) : b.physicsType === c.GROUP && this.collideGroupVsTilemapLayer(b, a, d, e, f, g))))
  9570. },
  9571. collideSpriteVsSprite: function(a, b, c, d, e, f) {
  9572. return a.body && b.body ? (this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++), !0) : !1
  9573. },
  9574. collideSpriteVsGroup: function(a, b, d, e, f, g) {
  9575. if (0 !== b.length && a.body)
  9576. if (this.skipQuadTree || a.body.skipQuadTree) {
  9577. for (var h = 0; h < b._hash.length; h++)
  9578. if (b._hash[h] && b._hash[h].exists && b._hash[h].body) {
  9579. if (this.sortDirection === c.Physics.Arcade.LEFT_RIGHT) {
  9580. if (a.body.right < b._hash[h].body.x) break;
  9581. if (b._hash[h].body.right < a.body.x) continue
  9582. } else if (this.sortDirection === c.Physics.Arcade.RIGHT_LEFT) {
  9583. if (a.body.x > b._hash[h].body.right) break;
  9584. if (b._hash[h].body.x > a.body.right) continue
  9585. } else if (this.sortDirection === c.Physics.Arcade.TOP_BOTTOM) {
  9586. if (a.body.bottom < b._hash[h].body.y) break;
  9587. if (b._hash[h].body.bottom < a.body.y) continue
  9588. } else if (this.sortDirection === c.Physics.Arcade.BOTTOM_TOP) {
  9589. if (a.body.y > b._hash[h].body.bottom) break;
  9590. if (b._hash[h].body.y > a.body.bottom) continue
  9591. }
  9592. this.collideSpriteVsSprite(a, b._hash[h], d, e, f, g)
  9593. }
  9594. } else {
  9595. 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);
  9596. for (var i = this.quadTree.retrieve(a), h = 0; h < i.length; h++) this.separate(a.body, i[h], e, f, g) && (d && d.call(f, a, i[h].sprite), this._total++)
  9597. }
  9598. },
  9599. collideGroupVsSelf: function(a, b, d, e, f) {
  9600. if (0 !== a.length)
  9601. for (var g = 0; g < a._hash.length; g++)
  9602. if (a._hash[g] && a._hash[g].exists && a._hash[g].body)
  9603. for (var h = a._hash[g], i = g + 1; i < a._hash.length; i++)
  9604. if (a._hash[i] && a._hash[i].exists && a._hash[i].body) {
  9605. var j = a._hash[i];
  9606. if (this.sortDirection === c.Physics.Arcade.LEFT_RIGHT) {
  9607. if (h.body.right < j.body.x) break;
  9608. if (j.body.right < h.body.x) continue
  9609. } else if (this.sortDirection === c.Physics.Arcade.RIGHT_LEFT) {
  9610. if (h.body.x > j.body.right) continue;
  9611. if (j.body.x > h.body.right) break
  9612. } else if (this.sortDirection === c.Physics.Arcade.TOP_BOTTOM) {
  9613. if (h.body.bottom < j.body.y) continue;
  9614. if (j.body.bottom < h.body.y) break
  9615. } else if (this.sortDirection === c.Physics.Arcade.BOTTOM_TOP) {
  9616. if (h.body.y > j.body.bottom) continue;
  9617. if (j.body.y > h.body.bottom) break
  9618. }
  9619. this.collideSpriteVsSprite(h, j, b, d, e, f)
  9620. }
  9621. },
  9622. collideGroupVsGroup: function(a, b, d, e, f, g) {
  9623. if (0 !== a.length && 0 !== b.length)
  9624. for (var h = 0; h < a.children.length; h++) a.children[h].exists && (a.children[h].physicsType === c.GROUP ? this.collideGroupVsGroup(a.children[h], b, d, e, f, g) : this.collideSpriteVsGroup(a.children[h], b, d, e, f, g))
  9625. },
  9626. separate: function(a, b, c, d, e) {
  9627. if (!a.enable || !b.enable || !this.intersects(a, b)) return !1;
  9628. if (c && c.call(d, a.sprite, b.sprite) === !1) return !1;
  9629. var f = !1;
  9630. return f = 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), e ? !0 : f
  9631. },
  9632. intersects: function(a, b) {
  9633. 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
  9634. },
  9635. separateX: function(a, b, c) {
  9636. if (a.immovable && b.immovable) return !1;
  9637. var d = 0;
  9638. if (this.intersects(a, b)) {
  9639. var e = a.deltaAbsX() + b.deltaAbsX() + this.OVERLAP_BIAS;
  9640. if (0 === a.deltaX() && 0 === b.deltaX() ? (a.embedded = !0, b.embedded = !0) : a.deltaX() > b.deltaX() ? (d = a.right - b.x, d > e || a.checkCollision.right === !1 || b.checkCollision.left === !1 ? d = 0 : (a.touching.none = !1, a.touching.right = !0, b.touching.none = !1, b.touching.left = !0)) : a.deltaX() < b.deltaX() && (d = a.x - b.width - b.x, -d > e || a.checkCollision.left === !1 || b.checkCollision.right === !1 ? d = 0 : (a.touching.none = !1, a.touching.left = !0, b.touching.none = !1, b.touching.right = !0)), a.overlapX = d, b.overlapX = d, 0 !== d) {
  9641. if (c || a.customSeparateX || b.customSeparateX) return !0;
  9642. var f = a.velocity.x,
  9643. g = b.velocity.x;
  9644. if (a.immovable || b.immovable) a.immovable ? b.immovable || (b.x += d, b.velocity.x = f - g * b.bounce.x, a.moves && (b.y += (a.y - a.prev.y) * a.friction.y)) : (a.x = a.x - d, a.velocity.x = g - f * a.bounce.x, b.moves && (a.y += (b.y - b.prev.y) * b.friction.y));
  9645. else {
  9646. d *= .5, a.x = a.x - d, b.x += d;
  9647. var h = Math.sqrt(g * g * b.mass / a.mass) * (g > 0 ? 1 : -1),
  9648. i = Math.sqrt(f * f * a.mass / b.mass) * (f > 0 ? 1 : -1),
  9649. j = .5 * (h + i);
  9650. h -= j, i -= j, a.velocity.x = j + h * a.bounce.x, b.velocity.x = j + i * b.bounce.x
  9651. }
  9652. return !0
  9653. }
  9654. }
  9655. return !1
  9656. },
  9657. separateY: function(a, b, c) {
  9658. if (a.immovable && b.immovable) return !1;
  9659. var d = 0;
  9660. if (this.intersects(a, b)) {
  9661. var e = a.deltaAbsY() + b.deltaAbsY() + this.OVERLAP_BIAS;
  9662. if (0 === a.deltaY() && 0 === b.deltaY() ? (a.embedded = !0, b.embedded = !0) : a.deltaY() > b.deltaY() ? (d = a.bottom - b.y, d > e || a.checkCollision.down === !1 || b.checkCollision.up === !1 ? d = 0 : (a.touching.none = !1, a.touching.down = !0, b.touching.none = !1, b.touching.up = !0)) : a.deltaY() < b.deltaY() && (d = a.y - b.bottom, -d > e || a.checkCollision.up === !1 || b.checkCollision.down === !1 ? d = 0 : (a.touching.none = !1, a.touching.up = !0, b.touching.none = !1, b.touching.down = !0)), a.overlapY = d, b.overlapY = d, 0 !== d) {
  9663. if (c || a.customSeparateY || b.customSeparateY) return !0;
  9664. var f = a.velocity.y,
  9665. g = b.velocity.y;
  9666. if (a.immovable || b.immovable) a.immovable ? b.immovable || (b.y += d, b.velocity.y = f - g * b.bounce.y, a.moves && (b.x += (a.x - a.prev.x) * a.friction.x)) : (a.y = a.y - d, a.velocity.y = g - f * a.bounce.y, b.moves && (a.x += (b.x - b.prev.x) * b.friction.x));
  9667. else {
  9668. d *= .5, a.y = a.y - d, b.y += d;
  9669. var h = Math.sqrt(g * g * b.mass / a.mass) * (g > 0 ? 1 : -1),
  9670. i = Math.sqrt(f * f * a.mass / b.mass) * (f > 0 ? 1 : -1),
  9671. j = .5 * (h + i);
  9672. h -= j, i -= j, a.velocity.y = j + h * a.bounce.y, b.velocity.y = j + i * b.bounce.y
  9673. }
  9674. return !0
  9675. }
  9676. }
  9677. return !1
  9678. },
  9679. getObjectsUnderPointer: function(a, b, c, d) {
  9680. return 0 !== b.length && a.exists ? this.getObjectsAtLocation(a.x, a.y, b, c, d, a) : void 0
  9681. },
  9682. getObjectsAtLocation: function(a, b, d, e, f, g) {
  9683. 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(d);
  9684. for (var h = new c.Rectangle(a, b, 1, 1), i = [], j = this.quadTree.retrieve(h), k = 0; k < j.length; k++) j[k].hitTest(a, b) && (e && e.call(f, g, j[k].sprite), i.push(j[k].sprite));
  9685. return i
  9686. },
  9687. moveToObject: function(a, b, c, d) {
  9688. "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 0);
  9689. var e = Math.atan2(b.y - a.y, b.x - a.x);
  9690. return d > 0 && (c = this.distanceBetween(a, b) / (d / 1e3)), a.body.velocity.x = Math.cos(e) * c, a.body.velocity.y = Math.sin(e) * c, e
  9691. },
  9692. moveToPointer: function(a, b, c, d) {
  9693. "undefined" == typeof b && (b = 60), c = c || this.game.input.activePointer, "undefined" == typeof d && (d = 0);
  9694. var e = this.angleToPointer(a, c);
  9695. return d > 0 && (b = this.distanceToPointer(a, c) / (d / 1e3)), a.body.velocity.x = Math.cos(e) * b, a.body.velocity.y = Math.sin(e) * b, e
  9696. },
  9697. moveToXY: function(a, b, c, d, e) {
  9698. "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 0);
  9699. var f = Math.atan2(c - a.y, b - a.x);
  9700. return e > 0 && (d = this.distanceToXY(a, b, c) / (e / 1e3)), a.body.velocity.x = Math.cos(f) * d, a.body.velocity.y = Math.sin(f) * d, f
  9701. },
  9702. velocityFromAngle: function(a, b, d) {
  9703. return "undefined" == typeof b && (b = 60), d = d || new c.Point, d.setTo(Math.cos(this.game.math.degToRad(a)) * b, Math.sin(this.game.math.degToRad(a)) * b)
  9704. },
  9705. velocityFromRotation: function(a, b, d) {
  9706. return "undefined" == typeof b && (b = 60), d = d || new c.Point, d.setTo(Math.cos(a) * b, Math.sin(a) * b)
  9707. },
  9708. accelerationFromRotation: function(a, b, d) {
  9709. return "undefined" == typeof b && (b = 60), d = d || new c.Point, d.setTo(Math.cos(a) * b, Math.sin(a) * b)
  9710. },
  9711. accelerateToObject: function(a, b, c, d, e) {
  9712. "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3);
  9713. var f = this.angleBetween(a, b);
  9714. return a.body.acceleration.setTo(Math.cos(f) * c, Math.sin(f) * c), a.body.maxVelocity.setTo(d, e), f
  9715. },
  9716. accelerateToPointer: function(a, b, c, d, e) {
  9717. "undefined" == typeof c && (c = 60), "undefined" == typeof b && (b = this.game.input.activePointer), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3);
  9718. var f = this.angleToPointer(a, b);
  9719. return a.body.acceleration.setTo(Math.cos(f) * c, Math.sin(f) * c), a.body.maxVelocity.setTo(d, e), f
  9720. },
  9721. accelerateToXY: function(a, b, c, d, e, f) {
  9722. "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 1e3), "undefined" == typeof f && (f = 1e3);
  9723. var g = this.angleToXY(a, b, c);
  9724. return a.body.acceleration.setTo(Math.cos(g) * d, Math.sin(g) * d), a.body.maxVelocity.setTo(e, f), g
  9725. },
  9726. distanceBetween: function(a, b) {
  9727. var c = a.x - b.x,
  9728. d = a.y - b.y;
  9729. return Math.sqrt(c * c + d * d)
  9730. },
  9731. distanceToXY: function(a, b, c) {
  9732. var d = a.x - b,
  9733. e = a.y - c;
  9734. return Math.sqrt(d * d + e * e)
  9735. },
  9736. distanceToPointer: function(a, b) {
  9737. b = b || this.game.input.activePointer;
  9738. var c = a.x - b.worldX,
  9739. d = a.y - b.worldY;
  9740. return Math.sqrt(c * c + d * d)
  9741. },
  9742. angleBetween: function(a, b) {
  9743. var c = b.x - a.x,
  9744. d = b.y - a.y;
  9745. return Math.atan2(d, c)
  9746. },
  9747. angleToXY: function(a, b, c) {
  9748. var d = b - a.x,
  9749. e = c - a.y;
  9750. return Math.atan2(e, d)
  9751. },
  9752. angleToPointer: function(a, b) {
  9753. b = b || this.game.input.activePointer;
  9754. var c = b.worldX - a.x,
  9755. d = b.worldY - a.y;
  9756. return Math.atan2(d, c)
  9757. }
  9758. }, c.Physics.Arcade.Body = function(a) {
  9759. this.sprite = a, this.game = a.game, this.type = c.Physics.ARCADE, this.enable = !0, this.offset = new c.Point, this.position = new c.Point(a.x, a.y), this.prev = new c.Point(this.position.x, this.position.y), this.allowRotation = !0, this.rotation = a.rotation, this.preRotation = a.rotation, this.width = a.width, this.height = a.height, this.sourceWidth = a.width, this.sourceHeight = a.height, a.texture && (this.sourceWidth = a.texture.frame.width, this.sourceHeight = a.texture.frame.height), this.halfWidth = Math.abs(a.width / 2), this.halfHeight = Math.abs(a.height / 2), this.center = new c.Point(a.x + this.halfWidth, a.y + this.halfHeight), this.velocity = new c.Point, this.newVelocity = new c.Point(0, 0), this.deltaMax = new c.Point(0, 0), this.acceleration = new c.Point, this.drag = new c.Point, this.allowGravity = !0, this.gravity = new c.Point(0, 0), this.bounce = new c.Point, this.maxVelocity = new c.Point(1e4, 1e4), this.friction = new c.Point(1, 0), this.angularVelocity = 0, this.angularAcceleration = 0, this.angularDrag = 0, this.maxAngular = 1e3, this.mass = 1, this.angle = 0, this.speed = 0, this.facing = c.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 = {
  9760. none: !1,
  9761. any: !0,
  9762. up: !0,
  9763. down: !0,
  9764. left: !0,
  9765. right: !0
  9766. }, this.touching = {
  9767. none: !0,
  9768. up: !1,
  9769. down: !1,
  9770. left: !1,
  9771. right: !1
  9772. }, this.wasTouching = {
  9773. none: !0,
  9774. up: !1,
  9775. down: !1,
  9776. left: !1,
  9777. right: !1
  9778. }, this.blocked = {
  9779. up: !1,
  9780. down: !1,
  9781. left: !1,
  9782. right: !1
  9783. }, this.tilePadding = new c.Point, this.dirty = !1, this.skipQuadTree = !1, this._reset = !0, this._sx = a.scale.x, this._sy = a.scale.y, this._dx = 0, this._dy = 0
  9784. }, c.Physics.Arcade.Body.prototype = {
  9785. updateBounds: function() {
  9786. var a = Math.abs(this.sprite.scale.x),
  9787. b = Math.abs(this.sprite.scale.y);
  9788. (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)
  9789. },
  9790. preUpdate: function() {
  9791. this.enable && !this.game.physics.arcade.isPaused && (this.dirty = !0, 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 || this.sprite.fresh) && (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)
  9792. },
  9793. postUpdate: function() {
  9794. this.enable && this.dirty && (this.dirty = !1, this.deltaX() < 0 ? this.facing = c.LEFT : this.deltaX() > 0 && (this.facing = c.RIGHT), this.deltaY() < 0 ? this.facing = c.UP : this.deltaY() > 0 && (this.facing = c.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.position.x += this._dx, this.sprite.position.y += this._dy, this._reset = !0), 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)
  9795. },
  9796. destroy: function() {
  9797. this.sprite.body = null, this.sprite = null
  9798. },
  9799. checkWorldBounds: function() {
  9800. 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)
  9801. },
  9802. setSize: function(a, b, c, d) {
  9803. "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)
  9804. },
  9805. reset: function(a, b) {
  9806. this.velocity.set(0), this.acceleration.set(0), this.speed = 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)
  9807. },
  9808. hitTest: function(a, b) {
  9809. return c.Rectangle.contains(this, a, b)
  9810. },
  9811. onFloor: function() {
  9812. return this.blocked.down
  9813. },
  9814. onWall: function() {
  9815. return this.blocked.left || this.blocked.right
  9816. },
  9817. deltaAbsX: function() {
  9818. return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
  9819. },
  9820. deltaAbsY: function() {
  9821. return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
  9822. },
  9823. deltaX: function() {
  9824. return this.position.x - this.prev.x
  9825. },
  9826. deltaY: function() {
  9827. return this.position.y - this.prev.y
  9828. },
  9829. deltaZ: function() {
  9830. return this.rotation - this.preRotation
  9831. }
  9832. }, Object.defineProperty(c.Physics.Arcade.Body.prototype, "bottom", {
  9833. get: function() {
  9834. return this.position.y + this.height
  9835. }
  9836. }), Object.defineProperty(c.Physics.Arcade.Body.prototype, "right", {
  9837. get: function() {
  9838. return this.position.x + this.width
  9839. }
  9840. }), Object.defineProperty(c.Physics.Arcade.Body.prototype, "x", {
  9841. get: function() {
  9842. return this.position.x
  9843. },
  9844. set: function(a) {
  9845. this.position.x = a
  9846. }
  9847. }), Object.defineProperty(c.Physics.Arcade.Body.prototype, "y", {
  9848. get: function() {
  9849. return this.position.y
  9850. },
  9851. set: function(a) {
  9852. this.position.y = a
  9853. }
  9854. }), c.Physics.Arcade.Body.render = function(a, b, c, d) {
  9855. "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))
  9856. }, c.Physics.Arcade.Body.renderBodyInfo = function(a, b) {
  9857. 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)
  9858. }, c.Physics.Arcade.Body.prototype.constructor = c.Physics.Arcade.Body, c.Physics.Arcade.TilemapCollision = function() {}, c.Physics.Arcade.TilemapCollision.prototype = {
  9859. TILE_BIAS: 16,
  9860. collideSpriteVsTilemapLayer: function(a, b, c, d, e) {
  9861. if (a.body) {
  9862. var f = 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);
  9863. if (0 !== f.length)
  9864. for (var g = 0; g < f.length; g++) d ? d.call(e, a, f[g]) && this.separateTile(g, a.body, f[g]) && (this._total++, c && c.call(e, a, f[g])) : this.separateTile(g, a.body, f[g]) && (this._total++, c && c.call(e, a, f[g]))
  9865. }
  9866. },
  9867. collideGroupVsTilemapLayer: function(a, b, c, d, e) {
  9868. if (0 !== a.length)
  9869. for (var f = 0; f < a.children.length; f++) a.children[f].exists && this.collideSpriteVsTilemapLayer(a.children[f], b, c, d, e)
  9870. },
  9871. separateTile: function(a, b, c) {
  9872. if (!b.enable || !c.intersects(b.position.x, b.position.y, b.right, b.bottom)) return !1;
  9873. if (c.collisionCallback && !c.collisionCallback.call(c.collisionCallbackContext, b.sprite, c)) return !1;
  9874. if (c.layer.callbacks[c.index] && !c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext, b.sprite, c)) return !1;
  9875. if (!(c.faceLeft || c.faceRight || c.faceTop || c.faceBottom)) return !1;
  9876. var d = 0,
  9877. e = 0,
  9878. f = 0,
  9879. g = 1;
  9880. 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) {
  9881. 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;
  9882. (c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c))
  9883. } else {
  9884. 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;
  9885. (c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c))
  9886. }
  9887. return 0 !== d || 0 !== e
  9888. },
  9889. tileCheckX: function(a, b) {
  9890. var c = 0;
  9891. 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 && (a.customSeparateX ? a.overlapX = c : this.processTileSeparationX(a, c)), c
  9892. },
  9893. tileCheckY: function(a, b) {
  9894. var c = 0;
  9895. 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 && (a.customSeparateY ? a.overlapY = c : this.processTileSeparationY(a, c)), c
  9896. },
  9897. processTileSeparationX: function(a, b) {
  9898. 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
  9899. },
  9900. processTileSeparationY: function(a, b) {
  9901. 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
  9902. }
  9903. }, c.Utils.mixinPrototype(c.Physics.Arcade.prototype, c.Physics.Arcade.TilemapCollision.prototype), ! function(a) {
  9904. "object" == typeof exports ? module.exports = a() : "function" == typeof define && define.amd ? define(a) : "undefined" != typeof window ? window.p2 = a() : "undefined" != typeof global ? global.p2 = a() : "undefined" != typeof self && (self.p2 = a())
  9905. }(function() {
  9906. return function a(b, c, d) {
  9907. function e(g, h) {
  9908. if (!c[g]) {
  9909. if (!b[g]) {
  9910. var i = "function" == typeof require && require;
  9911. if (!h && i) return i(g, !0);
  9912. if (f) return f(g, !0);
  9913. throw new Error("Cannot find module '" + g + "'")
  9914. }
  9915. var j = c[g] = {
  9916. exports: {}
  9917. };
  9918. b[g][0].call(j.exports, function(a) {
  9919. var c = b[g][1][a];
  9920. return e(c ? c : a)
  9921. }, j, j.exports, a, b, c, d)
  9922. }
  9923. return c[g].exports
  9924. }
  9925. for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
  9926. return e
  9927. }({
  9928. 1: [function(a, b) {
  9929. function c() {}
  9930. var d = a("./Scalar");
  9931. b.exports = c, c.lineInt = function(a, b, c) {
  9932. c = c || 0;
  9933. var e, f, g, h, i, j, k, l = [0, 0];
  9934. 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
  9935. }, c.segmentsIntersect = function(a, b, c, d) {
  9936. var e = b[0] - a[0],
  9937. f = b[1] - a[1],
  9938. g = d[0] - c[0],
  9939. h = d[1] - c[1];
  9940. if (g * f - h * e == 0) return !1;
  9941. var i = (e * (c[1] - a[1]) + f * (a[0] - c[0])) / (g * f - h * e),
  9942. j = (g * (a[1] - c[1]) + h * (c[0] - a[0])) / (h * e - g * f);
  9943. return i >= 0 && 1 >= i && j >= 0 && 1 >= j
  9944. }
  9945. }, {
  9946. "./Scalar": 4
  9947. }],
  9948. 2: [function(a, b) {
  9949. function c() {}
  9950. b.exports = c, c.area = function(a, b, c) {
  9951. return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])
  9952. }, c.left = function(a, b, d) {
  9953. return c.area(a, b, d) > 0
  9954. }, c.leftOn = function(a, b, d) {
  9955. return c.area(a, b, d) >= 0
  9956. }, c.right = function(a, b, d) {
  9957. return c.area(a, b, d) < 0
  9958. }, c.rightOn = function(a, b, d) {
  9959. return c.area(a, b, d) <= 0
  9960. };
  9961. var d = [],
  9962. e = [];
  9963. c.collinear = function(a, b, f, g) {
  9964. if (g) {
  9965. var h = d,
  9966. i = e;
  9967. h[0] = b[0] - a[0], h[1] = b[1] - a[1], i[0] = f[0] - b[0], i[1] = f[1] - b[1];
  9968. var j = h[0] * i[0] + h[1] * i[1],
  9969. k = Math.sqrt(h[0] * h[0] + h[1] * h[1]),
  9970. l = Math.sqrt(i[0] * i[0] + i[1] * i[1]),
  9971. m = Math.acos(j / (k * l));
  9972. return g > m
  9973. }
  9974. return 0 == c.area(a, b, f)
  9975. }, c.sqdist = function(a, b) {
  9976. var c = b[0] - a[0],
  9977. d = b[1] - a[1];
  9978. return c * c + d * d
  9979. }
  9980. }, {}],
  9981. 3: [function(a, b) {
  9982. function c() {
  9983. this.vertices = []
  9984. }
  9985. function d(a, b, c, d, e) {
  9986. e = e || 0;
  9987. var f = b[1] - a[1],
  9988. h = a[0] - b[0],
  9989. i = f * a[0] + h * a[1],
  9990. j = d[1] - c[1],
  9991. k = c[0] - d[0],
  9992. l = j * c[0] + k * c[1],
  9993. m = f * k - j * h;
  9994. return g.eq(m, 0, e) ? [0, 0] : [(k * i - h * l) / m, (f * l - j * i) / m]
  9995. }
  9996. var e = a("./Line"),
  9997. f = a("./Point"),
  9998. g = a("./Scalar");
  9999. b.exports = c, c.prototype.at = function(a) {
  10000. var b = this.vertices,
  10001. c = b.length;
  10002. return b[0 > a ? a % c + c : a % c]
  10003. }, c.prototype.first = function() {
  10004. return this.vertices[0]
  10005. }, c.prototype.last = function() {
  10006. return this.vertices[this.vertices.length - 1]
  10007. }, c.prototype.clear = function() {
  10008. this.vertices.length = 0
  10009. }, c.prototype.append = function(a, b, c) {
  10010. if ("undefined" == typeof b) throw new Error("From is not given!");
  10011. if ("undefined" == typeof c) throw new Error("To is not given!");
  10012. if (b > c - 1) throw new Error("lol1");
  10013. if (c > a.vertices.length) throw new Error("lol2");
  10014. if (0 > b) throw new Error("lol3");
  10015. for (var d = b; c > d; d++) this.vertices.push(a.vertices[d])
  10016. }, c.prototype.makeCCW = function() {
  10017. 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);
  10018. f.left(this.at(a - 1), this.at(a), this.at(a + 1)) || this.reverse()
  10019. }, c.prototype.reverse = function() {
  10020. for (var a = [], b = 0, c = this.vertices.length; b !== c; b++) a.push(this.vertices.pop());
  10021. this.vertices = a
  10022. }, c.prototype.isReflex = function(a) {
  10023. return f.right(this.at(a - 1), this.at(a), this.at(a + 1))
  10024. };
  10025. var h = [],
  10026. i = [];
  10027. c.prototype.canSee = function(a, b) {
  10028. var c, d, g = h,
  10029. j = i;
  10030. 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;
  10031. d = f.sqdist(this.at(a), this.at(b));
  10032. for (var k = 0; k !== this.vertices.length; ++k)
  10033. 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;
  10034. return !0
  10035. }, c.prototype.copy = function(a, b, d) {
  10036. var e = d || new c;
  10037. if (e.clear(), b > a)
  10038. for (var f = a; b >= f; f++) e.vertices.push(this.vertices[f]);
  10039. else {
  10040. for (var f = 0; b >= f; f++) e.vertices.push(this.vertices[f]);
  10041. for (var f = a; f < this.vertices.length; f++) e.vertices.push(this.vertices[f])
  10042. }
  10043. return e
  10044. }, c.prototype.getCutEdges = function() {
  10045. for (var a = [], b = [], d = [], e = new c, f = Number.MAX_VALUE, g = 0; g < this.vertices.length; ++g)
  10046. if (this.isReflex(g))
  10047. for (var h = 0; h < this.vertices.length; ++h)
  10048. if (this.canSee(g, h)) {
  10049. b = this.copy(g, h, e).getCutEdges(), d = this.copy(h, g, e).getCutEdges();
  10050. for (var i = 0; i < d.length; i++) b.push(d[i]);
  10051. b.length < f && (a = b, f = b.length, a.push([this.at(g), this.at(h)]))
  10052. }
  10053. return a
  10054. }, c.prototype.decomp = function() {
  10055. var a = this.getCutEdges();
  10056. return a.length > 0 ? this.slice(a) : [this]
  10057. }, c.prototype.slice = function(a) {
  10058. if (0 == a.length) return [this];
  10059. if (a instanceof Array && a.length && a[0] instanceof Array && 2 == a[0].length && a[0][0] instanceof Array) {
  10060. for (var b = [this], c = 0; c < a.length; c++)
  10061. for (var d = a[c], e = 0; e < b.length; e++) {
  10062. var f = b[e],
  10063. g = f.slice(d);
  10064. if (g) {
  10065. b.splice(e, 1), b.push(g[0], g[1]);
  10066. break
  10067. }
  10068. }
  10069. return b
  10070. }
  10071. var d = a,
  10072. c = this.vertices.indexOf(d[0]),
  10073. e = this.vertices.indexOf(d[1]);
  10074. return -1 != c && -1 != e ? [this.copy(c, e), this.copy(e, c)] : !1
  10075. }, c.prototype.isSimple = function() {
  10076. for (var a = this.vertices, b = 0; b < a.length - 1; b++)
  10077. for (var c = 0; b - 1 > c; c++)
  10078. if (e.segmentsIntersect(a[b], a[b + 1], a[c], a[c + 1])) return !1;
  10079. for (var b = 1; b < a.length - 2; b++)
  10080. if (e.segmentsIntersect(a[0], a[a.length - 1], a[b], a[b + 1])) return !1;
  10081. return !0
  10082. }, c.prototype.quickDecomp = function(a, b, e, g, h, i) {
  10083. h = h || 100, i = i || 0, g = g || 25, a = "undefined" != typeof a ? a : [], b = b || [], e = e || [];
  10084. var j = [0, 0],
  10085. k = [0, 0],
  10086. l = [0, 0],
  10087. m = 0,
  10088. n = 0,
  10089. o = 0,
  10090. p = 0,
  10091. q = 0,
  10092. r = 0,
  10093. s = 0,
  10094. t = new c,
  10095. u = new c,
  10096. v = this,
  10097. w = this.vertices;
  10098. if (w.length < 3) return a;
  10099. if (i++, i > h) return console.warn("quickDecomp: max level (" + h + ") reached."), a;
  10100. for (var x = 0; x < this.vertices.length; ++x)
  10101. if (v.isReflex(x)) {
  10102. b.push(v.vertices[x]), m = n = Number.MAX_VALUE;
  10103. 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)));
  10104. 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));
  10105. else {
  10106. if (r > q && (q += this.vertices.length), p = Number.MAX_VALUE, r > q) return a;
  10107. 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));
  10108. 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))
  10109. }
  10110. 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
  10111. }
  10112. return a.push(this), a
  10113. }, c.prototype.removeCollinearPoints = function(a) {
  10114. 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++);
  10115. return b
  10116. }
  10117. }, {
  10118. "./Line": 1,
  10119. "./Point": 2,
  10120. "./Scalar": 4
  10121. }],
  10122. 4: [function(a, b) {
  10123. function c() {}
  10124. b.exports = c, c.eq = function(a, b, c) {
  10125. return c = c || 0, Math.abs(a - b) < c
  10126. }
  10127. }, {}],
  10128. 5: [function(a, b) {
  10129. b.exports = {
  10130. Polygon: a("./Polygon"),
  10131. Point: a("./Point")
  10132. }
  10133. }, {
  10134. "./Point": 2,
  10135. "./Polygon": 3
  10136. }],
  10137. 6: [function(a, b) {
  10138. b.exports = {
  10139. name: "p2",
  10140. version: "0.6.0",
  10141. description: "A JavaScript 2D physics engine.",
  10142. author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
  10143. keywords: ["p2.js", "p2", "physics", "engine", "2d"],
  10144. main: "./src/p2.js",
  10145. engines: {
  10146. node: "*"
  10147. },
  10148. repository: {
  10149. type: "git",
  10150. url: "https://github.com/schteppe/p2.js.git"
  10151. },
  10152. bugs: {
  10153. url: "https://github.com/schteppe/p2.js/issues"
  10154. },
  10155. licenses: [{
  10156. type: "MIT"
  10157. }],
  10158. devDependencies: {
  10159. grunt: "~0.4.0",
  10160. "grunt-contrib-jshint": "~0.9.2",
  10161. "grunt-contrib-nodeunit": "~0.1.2",
  10162. "grunt-contrib-uglify": "~0.4.0",
  10163. "grunt-contrib-watch": "~0.5.0",
  10164. "grunt-browserify": "~2.0.1",
  10165. "grunt-contrib-concat": "^0.4.0"
  10166. },
  10167. dependencies: {
  10168. "poly-decomp": "0.1.0"
  10169. }
  10170. }
  10171. }, {}],
  10172. 7: [function(a, b) {
  10173. function c(a) {
  10174. 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)
  10175. } {
  10176. var d = a("../math/vec2");
  10177. a("../utils/Utils")
  10178. }
  10179. b.exports = c;
  10180. var e = d.create();
  10181. c.prototype.setFromPoints = function(a, b, c, f) {
  10182. var g = this.lowerBound,
  10183. h = this.upperBound;
  10184. "number" != typeof c && (c = 0), 0 !== c ? d.rotate(g, a[0], c) : d.copy(g, a[0]), d.copy(h, g);
  10185. for (var i = Math.cos(c), j = Math.sin(c), k = 1; k < a.length; k++) {
  10186. var l = a[k];
  10187. if (0 !== c) {
  10188. var m = l[0],
  10189. n = l[1];
  10190. e[0] = i * m - j * n, e[1] = j * m + i * n, l = e
  10191. }
  10192. for (var o = 0; 2 > o; o++) l[o] > h[o] && (h[o] = l[o]), l[o] < g[o] && (g[o] = l[o])
  10193. }
  10194. b && (d.add(this.lowerBound, this.lowerBound, b), d.add(this.upperBound, this.upperBound, b)), f && (this.lowerBound[0] -= f, this.lowerBound[1] -= f, this.upperBound[0] += f, this.upperBound[1] += f)
  10195. }, c.prototype.copy = function(a) {
  10196. d.copy(this.lowerBound, a.lowerBound), d.copy(this.upperBound, a.upperBound)
  10197. }, c.prototype.extend = function(a) {
  10198. for (var b = 2; b--;) {
  10199. var c = a.lowerBound[b];
  10200. this.lowerBound[b] > c && (this.lowerBound[b] = c);
  10201. var d = a.upperBound[b];
  10202. this.upperBound[b] < d && (this.upperBound[b] = d)
  10203. }
  10204. }, c.prototype.overlaps = function(a) {
  10205. var b = this.lowerBound,
  10206. c = this.upperBound,
  10207. d = a.lowerBound,
  10208. e = a.upperBound;
  10209. 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])
  10210. }
  10211. }, {
  10212. "../math/vec2": 31,
  10213. "../utils/Utils": 50
  10214. }],
  10215. 8: [function(a, b) {
  10216. function c(a) {
  10217. this.type = a, this.result = [], this.world = null, this.boundingVolumeType = c.AABB
  10218. }
  10219. var d = a("../math/vec2"),
  10220. e = a("../objects/Body");
  10221. b.exports = c, c.AABB = 1, c.BOUNDING_CIRCLE = 2, c.prototype.setWorld = function(a) {
  10222. this.world = a
  10223. }, c.prototype.getCollisionPairs = function() {
  10224. throw new Error("getCollisionPairs must be implemented in a subclass!")
  10225. };
  10226. var f = d.create();
  10227. c.boundingRadiusCheck = function(a, b) {
  10228. d.sub(f, a.position, b.position);
  10229. var c = d.squaredLength(f),
  10230. e = a.boundingRadius + b.boundingRadius;
  10231. return e * e >= c
  10232. }, c.aabbCheck = function(a, b) {
  10233. return a.getAABB().overlaps(b.getAABB())
  10234. }, c.prototype.boundingVolumeCheck = function(a, b) {
  10235. var d;
  10236. switch (this.boundingVolumeType) {
  10237. case c.BOUNDING_CIRCLE:
  10238. d = c.boundingRadiusCheck(a, b);
  10239. break;
  10240. case c.AABB:
  10241. d = c.aabbCheck(a, b);
  10242. break;
  10243. default:
  10244. throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType)
  10245. }
  10246. return d
  10247. }, c.canCollide = function(a, b) {
  10248. return a.type === e.STATIC && b.type === e.STATIC ? !1 : a.type === e.KINEMATIC && b.type === e.STATIC || a.type === e.STATIC && b.type === e.KINEMATIC ? !1 : a.type === e.KINEMATIC && b.type === e.KINEMATIC ? !1 : a.sleepState === e.SLEEPING && b.sleepState === e.SLEEPING ? !1 : a.sleepState === e.SLEEPING && b.type === e.STATIC || b.sleepState === e.SLEEPING && a.type === e.STATIC ? !1 : !0
  10249. }, c.NAIVE = 1, c.SAP = 2
  10250. }, {
  10251. "../math/vec2": 31,
  10252. "../objects/Body": 32
  10253. }],
  10254. 9: [function(a, b) {
  10255. function c(a) {
  10256. d.apply(this), a = e.defaults(a, {
  10257. xmin: -100,
  10258. xmax: 100,
  10259. ymin: -100,
  10260. ymax: 100,
  10261. nx: 10,
  10262. ny: 10
  10263. }), 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
  10264. }
  10265. var d = (a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Particle"), a("../collision/Broadphase")),
  10266. e = (a("../math/vec2"), a("../utils/Utils"));
  10267. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.getCollisionPairs = function(a) {
  10268. 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([]);
  10269. for (var o = f / (j - h), p = g / (k - i), n = 0; n !== e; n++)
  10270. 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++)
  10271. for (var B = x; z >= B; B++) {
  10272. var C = A,
  10273. D = B,
  10274. E = C * (g - 1) + D;
  10275. E >= 0 && m > E && l[E].push(q)
  10276. }
  10277. for (var n = 0; n !== m; n++)
  10278. for (var F = l[n], A = 0, G = F.length; A !== G; A++)
  10279. for (var q = F[A], B = 0; B !== A; B++) {
  10280. var H = F[B];
  10281. d.canCollide(q, H) && this.boundingVolumeCheck(q, H) && b.push(q, H)
  10282. }
  10283. return b
  10284. }
  10285. }, {
  10286. "../collision/Broadphase": 8,
  10287. "../math/vec2": 31,
  10288. "../shapes/Circle": 38,
  10289. "../shapes/Particle": 42,
  10290. "../shapes/Plane": 43,
  10291. "../utils/Utils": 50
  10292. }],
  10293. 10: [function(a, b) {
  10294. function c() {
  10295. d.call(this, d.NAIVE)
  10296. } {
  10297. var d = (a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Shape"), a("../shapes/Particle"), a("../collision/Broadphase"));
  10298. a("../math/vec2")
  10299. }
  10300. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.getCollisionPairs = function(a) {
  10301. var b = a.bodies,
  10302. c = this.result;
  10303. c.length = 0;
  10304. for (var e = 0, f = b.length; e !== f; e++)
  10305. for (var g = b[e], h = 0; e > h; h++) {
  10306. var i = b[h];
  10307. d.canCollide(g, i) && this.boundingVolumeCheck(g, i) && c.push(g, i)
  10308. }
  10309. return c
  10310. }, c.prototype.aabbQuery = function(a, b, c) {
  10311. c = c || [];
  10312. for (var d = a.bodies, e = 0; e < d.length; e++) {
  10313. var f = d[e];
  10314. f.aabbNeedsUpdate && f.updateAABB(), f.aabb.overlaps(b) && c.push(f)
  10315. }
  10316. return c
  10317. }
  10318. }, {
  10319. "../collision/Broadphase": 8,
  10320. "../math/vec2": 31,
  10321. "../shapes/Circle": 38,
  10322. "../shapes/Particle": 42,
  10323. "../shapes/Plane": 43,
  10324. "../shapes/Shape": 45
  10325. }],
  10326. 11: [function(a, b) {
  10327. function c() {
  10328. this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, this.enabledEquations = !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.enableFrictionReduction = !0, this.collidingBodiesLastStep = new k, this.contactSkinSize = .01
  10329. }
  10330. function d(a, b) {
  10331. 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)
  10332. }
  10333. function e(a, b, c, d) {
  10334. for (var e = T, i = U, j = V, k = W, l = a, m = b.vertices, n = null, o = 0; o !== m.length + 1; o++) {
  10335. var p = m[o % m.length],
  10336. q = m[(o + 1) % m.length];
  10337. 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);
  10338. var r = f.crossLength(j, k);
  10339. if (null === n && (n = r), 0 >= r * n) return !1;
  10340. n = r
  10341. }
  10342. return !0
  10343. }
  10344. var f = a("../math/vec2"),
  10345. g = f.sub,
  10346. h = f.add,
  10347. i = f.dot,
  10348. j = a("../utils/Utils"),
  10349. k = a("../utils/TupleDictionary"),
  10350. l = a("../equations/Equation"),
  10351. m = a("../equations/ContactEquation"),
  10352. n = a("../equations/FrictionEquation"),
  10353. o = a("../shapes/Circle"),
  10354. p = a("../shapes/Convex"),
  10355. q = a("../shapes/Shape"),
  10356. r = (a("../objects/Body"), a("../shapes/Rectangle"));
  10357. b.exports = c;
  10358. var s = f.fromValues(0, 1),
  10359. t = f.fromValues(0, 0),
  10360. u = f.fromValues(0, 0),
  10361. v = f.fromValues(0, 0),
  10362. w = f.fromValues(0, 0),
  10363. x = f.fromValues(0, 0),
  10364. y = f.fromValues(0, 0),
  10365. z = f.fromValues(0, 0),
  10366. A = f.fromValues(0, 0),
  10367. B = f.fromValues(0, 0),
  10368. C = f.fromValues(0, 0),
  10369. D = f.fromValues(0, 0),
  10370. E = f.fromValues(0, 0),
  10371. F = f.fromValues(0, 0),
  10372. G = f.fromValues(0, 0),
  10373. H = f.fromValues(0, 0),
  10374. I = f.fromValues(0, 0),
  10375. J = f.fromValues(0, 0),
  10376. K = f.fromValues(0, 0),
  10377. L = [],
  10378. M = f.create(),
  10379. N = f.create();
  10380. c.prototype.bodiesOverlap = function(a, b) {
  10381. for (var c = M, d = N, e = 0, f = a.shapes.length; e !== f; e++) {
  10382. {
  10383. var g = a.shapes[e],
  10384. h = a.shapeOffsets[e];
  10385. a.shapeAngles[e]
  10386. }
  10387. a.toWorldFrame(c, h);
  10388. for (var i = 0, j = b.shapes.length; i !== j; i++) {
  10389. {
  10390. var k = b.shapes[i],
  10391. l = b.shapeOffsets[i];
  10392. b.shapeAngles[i]
  10393. }
  10394. if (b.toWorldFrame(d, l), this[g.type | k.type](a, g, c, g.angle + a.angle, b, k, d, k.angle + b.angle, !0)) return !0
  10395. }
  10396. }
  10397. return !1
  10398. }, c.prototype.collidedLastStep = function(a, b) {
  10399. var c = 0 | a.id,
  10400. d = 0 | b.id;
  10401. return !!this.collidingBodiesLastStep.get(c, d)
  10402. }, c.prototype.reset = function() {
  10403. this.collidingBodiesLastStep.reset();
  10404. for (var a = this.contactEquations, b = a.length; b--;) {
  10405. var c = a[b],
  10406. d = c.bodyA.id,
  10407. e = c.bodyB.id;
  10408. this.collidingBodiesLastStep.set(d, e, !0)
  10409. }
  10410. if (this.reuseObjects) {
  10411. var f = this.contactEquations,
  10412. g = this.frictionEquations,
  10413. h = this.reusableFrictionEquations,
  10414. i = this.reusableContactEquations;
  10415. j.appendArray(i, f), j.appendArray(h, g)
  10416. }
  10417. this.contactEquations.length = this.frictionEquations.length = 0
  10418. }, c.prototype.createContactEquation = function(a, b, c, d) {
  10419. var e = this.reusableContactEquations.length ? this.reusableContactEquations.pop() : new m(a, b);
  10420. 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 = this.enabledEquations, e.offset = this.contactSkinSize, e
  10421. }, c.prototype.createFrictionEquation = function(a, b, c, d) {
  10422. var e = this.reusableFrictionEquations.length ? this.reusableFrictionEquations.pop() : new n(a, b);
  10423. 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 = this.enabledEquations, e.needsUpdate = !0, e.stiffness = this.frictionStiffness, e.relaxation = this.frictionRelaxation, e.contactEquations.length = 0, e
  10424. }, c.prototype.createFrictionFromContact = function(a) {
  10425. var b = this.createFrictionEquation(a.bodyA, a.bodyB, a.shapeA, a.shapeB);
  10426. return f.copy(b.contactPointA, a.contactPointA), f.copy(b.contactPointB, a.contactPointB), f.rotate90cw(b.t, a.normalA), b.contactEquations.push(a), b
  10427. }, c.prototype.createFrictionFromAverage = function(a) {
  10428. {
  10429. var b = this.contactEquations[this.contactEquations.length - 1],
  10430. c = this.createFrictionEquation(b.bodyA, b.bodyB, b.shapeA, b.shapeB),
  10431. d = b.bodyA;
  10432. b.bodyB
  10433. }
  10434. f.set(c.contactPointA, 0, 0), f.set(c.contactPointB, 0, 0), f.set(c.t, 0, 0);
  10435. for (var e = 0; e !== a; e++) b = this.contactEquations[this.contactEquations.length - 1 - e], b.bodyA === d ? (f.add(c.t, c.t, b.normalA), f.add(c.contactPointA, c.contactPointA, b.contactPointA), f.add(c.contactPointB, c.contactPointB, b.contactPointB)) : (f.sub(c.t, c.t, b.normalA), f.add(c.contactPointA, c.contactPointA, b.contactPointB), f.add(c.contactPointB, c.contactPointB, b.contactPointA)), c.contactEquations.push(b);
  10436. var g = 1 / a;
  10437. return f.scale(c.contactPointA, c.contactPointA, g), f.scale(c.contactPointB, c.contactPointB, g), f.normalize(c.t, c.t), f.rotate90cw(c.t, c.t), c
  10438. }, c.prototype[q.LINE | q.CONVEX] = c.prototype.convexLine = function(a, b, c, d, e, f, g, h, i) {
  10439. return i ? !1 : 0
  10440. }, c.prototype[q.LINE | q.RECTANGLE] = c.prototype.lineRectangle = function(a, b, c, d, e, f, g, h, i) {
  10441. return i ? !1 : 0
  10442. };
  10443. var O = new r(1, 1),
  10444. P = f.create();
  10445. 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) {
  10446. var l = P;
  10447. f.set(l, h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  10448. var m = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  10449. f.set(l, -h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  10450. var n = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  10451. if (k && (m || n)) return !0;
  10452. var o = O;
  10453. d(o, h);
  10454. var p = this.convexConvex(a, b, c, e, g, o, i, j, k);
  10455. return p + m + n
  10456. }, c.prototype[q.CAPSULE | q.LINE] = c.prototype.lineCapsule = function(a, b, c, d, e, f, g, h, i) {
  10457. return i ? !1 : 0
  10458. };
  10459. var Q = f.create(),
  10460. R = f.create(),
  10461. S = new r(1, 1);
  10462. c.prototype[q.CAPSULE | q.CAPSULE] = c.prototype.capsuleCapsule = function(a, b, c, e, g, h, i, j, k) {
  10463. for (var l, m = Q, n = R, o = 0, p = 0; 2 > p; p++) {
  10464. f.set(m, (0 === p ? -1 : 1) * b.length / 2, 0), f.rotate(m, m, e), f.add(m, m, c);
  10465. for (var q = 0; 2 > q; q++) {
  10466. f.set(n, (0 === q ? -1 : 1) * h.length / 2, 0), f.rotate(n, n, j), f.add(n, n, i), this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1);
  10467. var r = this.circleCircle(a, b, m, e, g, h, n, j, k, b.radius, h.radius);
  10468. if (this.enableFrictionReduction && (this.enableFriction = l), k && r) return !0;
  10469. o += r
  10470. }
  10471. }
  10472. this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1);
  10473. var s = S;
  10474. d(s, b);
  10475. var t = this.convexCapsule(a, s, c, e, g, h, i, j, k);
  10476. if (this.enableFrictionReduction && (this.enableFriction = l), k && t) return !0;
  10477. if (o += t, this.enableFrictionReduction) {
  10478. var l = this.enableFriction;
  10479. this.enableFriction = !1
  10480. }
  10481. d(s, h);
  10482. var u = this.convexCapsule(g, s, i, j, a, b, c, e, k);
  10483. return this.enableFrictionReduction && (this.enableFriction = l), k && u ? !0 : (o += u, this.enableFrictionReduction && o && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(o)), o)
  10484. }, c.prototype[q.LINE | q.LINE] = c.prototype.lineLine = function(a, b, c, d, e, f, g, h, i) {
  10485. return i ? !1 : 0
  10486. }, c.prototype[q.PLANE | q.LINE] = c.prototype.planeLine = function(a, b, c, d, e, j, k, l, m) {
  10487. var n = t,
  10488. o = u,
  10489. p = v,
  10490. q = w,
  10491. r = x,
  10492. C = y,
  10493. D = z,
  10494. E = A,
  10495. F = B,
  10496. G = L,
  10497. H = 0;
  10498. 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;
  10499. for (var I = 0; I < G.length; I++) {
  10500. var J = G[I];
  10501. g(D, J, c);
  10502. var K = i(D, E);
  10503. if (0 > K) {
  10504. if (m) return !0;
  10505. var M = this.createContactEquation(a, e, b, j);
  10506. H++, f.copy(M.normalA, E), f.normalize(M.normalA, M.normalA), f.scale(D, E, K), g(M.contactPointA, J, D), g(M.contactPointA, M.contactPointA, a.position), g(M.contactPointB, J, k), h(M.contactPointB, M.contactPointB, k), g(M.contactPointB, M.contactPointB, e.position), this.contactEquations.push(M), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(M))
  10507. }
  10508. }
  10509. return m ? !1 : (this.enableFrictionReduction || H && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(H)), H)
  10510. }, c.prototype[q.PARTICLE | q.CAPSULE] = c.prototype.particleCapsule = function(a, b, c, d, e, f, g, h, i) {
  10511. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius, 0)
  10512. }, c.prototype[q.CIRCLE | q.LINE] = c.prototype.circleLine = function(a, b, c, d, e, j, k, l, m, n, o) {
  10513. var n = n || 0,
  10514. o = "undefined" != typeof o ? o : b.radius,
  10515. p = t,
  10516. q = u,
  10517. r = v,
  10518. s = w,
  10519. H = x,
  10520. I = y,
  10521. J = z,
  10522. K = A,
  10523. M = B,
  10524. N = C,
  10525. O = D,
  10526. P = E,
  10527. Q = F,
  10528. R = G,
  10529. S = L;
  10530. f.set(K, -j.length / 2, 0), f.set(M, j.length / 2, 0), f.rotate(N, K, l), f.rotate(O, M, l), h(N, N, k), h(O, O, k), f.copy(K, N), f.copy(M, O), g(I, M, K), f.normalize(J, I), f.rotate90cw(H, J), g(P, c, K);
  10531. var T = i(P, H);
  10532. g(s, K, k), g(Q, c, k);
  10533. var U = o + n;
  10534. if (Math.abs(T) < U) {
  10535. f.scale(p, H, T), g(r, c, p), f.scale(q, H, i(H, Q)), f.normalize(q, q), f.scale(q, q, n), h(r, r, q);
  10536. var V = i(J, r),
  10537. W = i(J, K),
  10538. X = i(J, M);
  10539. if (V > W && X > V) {
  10540. if (m) return !0;
  10541. var Y = this.createContactEquation(a, e, b, j);
  10542. return f.scale(Y.normalA, p, -1), f.normalize(Y.normalA, Y.normalA), f.scale(Y.contactPointA, Y.normalA, o), h(Y.contactPointA, Y.contactPointA, c), g(Y.contactPointA, Y.contactPointA, a.position), g(Y.contactPointB, r, k), h(Y.contactPointB, Y.contactPointB, k), g(Y.contactPointB, Y.contactPointB, e.position), this.contactEquations.push(Y), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Y)), 1
  10543. }
  10544. }
  10545. S[0] = K, S[1] = M;
  10546. for (var Z = 0; Z < S.length; Z++) {
  10547. var $ = S[Z];
  10548. if (g(P, $, c), f.squaredLength(P) < Math.pow(U, 2)) {
  10549. if (m) return !0;
  10550. var Y = this.createContactEquation(a, e, b, j);
  10551. return f.copy(Y.normalA, P), f.normalize(Y.normalA, Y.normalA), f.scale(Y.contactPointA, Y.normalA, o), h(Y.contactPointA, Y.contactPointA, c), g(Y.contactPointA, Y.contactPointA, a.position), g(Y.contactPointB, $, k), f.scale(R, Y.normalA, -n), h(Y.contactPointB, Y.contactPointB, R), h(Y.contactPointB, Y.contactPointB, k), g(Y.contactPointB, Y.contactPointB, e.position), this.contactEquations.push(Y), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Y)), 1
  10552. }
  10553. }
  10554. return 0
  10555. }, c.prototype[q.CIRCLE | q.CAPSULE] = c.prototype.circleCapsule = function(a, b, c, d, e, f, g, h, i) {
  10556. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius)
  10557. }, 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) {
  10558. for (var n = "number" == typeof n ? n : b.radius, o = t, p = u, q = v, r = w, s = x, y = C, z = D, A = F, B = G, E = H, J = I, K = !1, L = Number.MAX_VALUE, M = j.vertices, N = 0; N !== M.length + 1; N++) {
  10559. var O = M[N % M.length],
  10560. P = M[(N + 1) % M.length];
  10561. if (f.rotate(o, O, l), f.rotate(p, P, l), h(o, o, k), h(p, p, k), g(q, p, o), f.normalize(r, q), f.rotate90cw(s, r), f.scale(B, s, -b.radius), h(B, B, c), e(B, j, k, l)) {
  10562. f.sub(E, o, B);
  10563. var Q = Math.abs(f.dot(E, s));
  10564. L > Q && (f.copy(J, B), L = Q, f.scale(A, s, Q), f.add(A, A, B), K = !0)
  10565. }
  10566. }
  10567. if (K) {
  10568. if (m) return !0;
  10569. var R = this.createContactEquation(a, i, b, j);
  10570. return f.sub(R.normalA, J, c), f.normalize(R.normalA, R.normalA), f.scale(R.contactPointA, R.normalA, n), h(R.contactPointA, R.contactPointA, c), g(R.contactPointA, R.contactPointA, a.position), g(R.contactPointB, A, k), h(R.contactPointB, R.contactPointB, k), g(R.contactPointB, R.contactPointB, i.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1
  10571. }
  10572. if (n > 0)
  10573. for (var N = 0; N < M.length; N++) {
  10574. var S = M[N];
  10575. if (f.rotate(z, S, l), h(z, z, k), g(y, z, c), f.squaredLength(y) < Math.pow(n, 2)) {
  10576. if (m) return !0;
  10577. var R = this.createContactEquation(a, i, b, j);
  10578. return f.copy(R.normalA, y), f.normalize(R.normalA, R.normalA), f.scale(R.contactPointA, R.normalA, n), h(R.contactPointA, R.contactPointA, c), g(R.contactPointA, R.contactPointA, a.position), g(R.contactPointB, z, k), h(R.contactPointB, R.contactPointB, k), g(R.contactPointB, R.contactPointB, i.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1
  10579. }
  10580. }
  10581. return 0
  10582. };
  10583. var T = f.create(),
  10584. U = f.create(),
  10585. V = f.create(),
  10586. W = f.create();
  10587. 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) {
  10588. var o = t,
  10589. p = u,
  10590. q = v,
  10591. r = w,
  10592. s = x,
  10593. A = y,
  10594. B = z,
  10595. D = C,
  10596. E = F,
  10597. G = J,
  10598. H = K,
  10599. I = Number.MAX_VALUE,
  10600. L = !1,
  10601. M = k.vertices;
  10602. if (!e(c, k, l, m)) return 0;
  10603. if (n) return !0;
  10604. for (var N = 0; N !== M.length + 1; N++) {
  10605. var O = M[N % M.length],
  10606. P = M[(N + 1) % M.length];
  10607. f.rotate(o, O, m), f.rotate(p, P, m), h(o, o, l), h(p, p, l), g(q, p, o), f.normalize(r, q), f.rotate90cw(s, r), g(D, c, o); {
  10608. i(D, s)
  10609. }
  10610. g(A, o, l), g(B, c, l), f.sub(G, o, c);
  10611. var Q = Math.abs(f.dot(G, s));
  10612. I > Q && (I = Q, f.scale(E, s, Q), f.add(E, E, c), f.copy(H, s), L = !0)
  10613. }
  10614. if (L) {
  10615. var R = this.createContactEquation(a, j, b, k);
  10616. return f.scale(R.normalA, H, -1), f.normalize(R.normalA, R.normalA), f.set(R.contactPointA, 0, 0), h(R.contactPointA, R.contactPointA, c), g(R.contactPointA, R.contactPointA, a.position), g(R.contactPointB, E, l), h(R.contactPointB, R.contactPointB, l), g(R.contactPointB, R.contactPointB, j.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1
  10617. }
  10618. return 0
  10619. }, c.prototype[q.CIRCLE] = c.prototype.circleCircle = function(a, b, c, d, e, i, j, k, l, m, n) {
  10620. var o = t,
  10621. m = m || b.radius,
  10622. n = n || i.radius;
  10623. g(o, c, j);
  10624. var p = m + n;
  10625. if (f.squaredLength(o) > Math.pow(p, 2)) return 0;
  10626. if (l) return !0;
  10627. var q = this.createContactEquation(a, e, b, i);
  10628. return g(q.normalA, j, c), f.normalize(q.normalA, q.normalA), f.scale(q.contactPointA, q.normalA, m), f.scale(q.contactPointB, q.normalA, -n), h(q.contactPointA, q.contactPointA, c), g(q.contactPointA, q.contactPointA, a.position), h(q.contactPointB, q.contactPointB, j), g(q.contactPointB, q.contactPointB, e.position), this.contactEquations.push(q), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(q)), 1
  10629. }, c.prototype[q.PLANE | q.CONVEX] = c.prototype[q.PLANE | q.RECTANGLE] = c.prototype.planeConvex = function(a, b, c, d, e, j, k, l, m) {
  10630. var n = t,
  10631. o = u,
  10632. p = v,
  10633. q = 0;
  10634. f.rotate(o, s, d);
  10635. for (var r = 0; r !== j.vertices.length; r++) {
  10636. var w = j.vertices[r];
  10637. if (f.rotate(n, w, l), h(n, n, k), g(p, n, c), i(p, o) <= 0) {
  10638. if (m) return !0;
  10639. q++;
  10640. var x = this.createContactEquation(a, e, b, j);
  10641. g(p, n, c), f.copy(x.normalA, o);
  10642. var y = i(p, x.normalA);
  10643. f.scale(p, x.normalA, y), g(x.contactPointB, n, e.position), g(x.contactPointA, n, p), g(x.contactPointA, x.contactPointA, a.position), this.contactEquations.push(x), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x))
  10644. }
  10645. }
  10646. return this.enableFrictionReduction && this.enableFriction && q && this.frictionEquations.push(this.createFrictionFromAverage(q)), q
  10647. }, c.prototype[q.PARTICLE | q.PLANE] = c.prototype.particlePlane = function(a, b, c, d, e, h, j, k, l) {
  10648. var m = t,
  10649. n = u;
  10650. k = k || 0, g(m, c, j), f.rotate(n, s, k);
  10651. var o = i(m, n);
  10652. if (o > 0) return 0;
  10653. if (l) return !0;
  10654. var p = this.createContactEquation(e, a, h, b);
  10655. return f.copy(p.normalA, n), f.scale(m, p.normalA, o), g(p.contactPointA, c, m), g(p.contactPointA, p.contactPointA, e.position), g(p.contactPointB, c, a.position), this.contactEquations.push(p), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(p)), 1
  10656. }, c.prototype[q.CIRCLE | q.PARTICLE] = c.prototype.circleParticle = function(a, b, c, d, e, i, j, k, l) {
  10657. var m = t;
  10658. if (g(m, j, c), f.squaredLength(m) > Math.pow(b.radius, 2)) return 0;
  10659. if (l) return !0;
  10660. var n = this.createContactEquation(a, e, b, i);
  10661. return f.copy(n.normalA, m), f.normalize(n.normalA, n.normalA), f.scale(n.contactPointA, n.normalA, b.radius), h(n.contactPointA, n.contactPointA, c), g(n.contactPointA, n.contactPointA, a.position), g(n.contactPointB, j, e.position), this.contactEquations.push(n), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(n)), 1
  10662. }; {
  10663. var X = new o(1),
  10664. Y = f.create(),
  10665. Z = f.create();
  10666. f.create()
  10667. }
  10668. c.prototype[q.PLANE | q.CAPSULE] = c.prototype.planeCapsule = function(a, b, c, d, e, g, i, j, k) {
  10669. var l = Y,
  10670. m = Z,
  10671. n = X;
  10672. 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;
  10673. var o;
  10674. this.enableFrictionReduction && (o = this.enableFriction, this.enableFriction = !1);
  10675. var p = this.circlePlane(e, n, l, 0, a, b, c, d, k),
  10676. q = this.circlePlane(e, n, m, 0, a, b, c, d, k);
  10677. if (this.enableFrictionReduction && (this.enableFriction = o), k) return p || q;
  10678. var r = p + q;
  10679. return this.enableFrictionReduction && r && this.frictionEquations.push(this.createFrictionFromAverage(r)), r
  10680. }, c.prototype[q.CIRCLE | q.PLANE] = c.prototype.circlePlane = function(a, b, c, d, e, j, k, l, m) {
  10681. var n = a,
  10682. o = b,
  10683. p = c,
  10684. q = e,
  10685. r = k,
  10686. w = l;
  10687. w = w || 0;
  10688. var x = t,
  10689. y = u,
  10690. z = v;
  10691. g(x, p, r), f.rotate(y, s, w);
  10692. var A = i(y, x);
  10693. if (A > o.radius) return 0;
  10694. if (m) return !0;
  10695. var B = this.createContactEquation(q, n, j, b);
  10696. 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
  10697. }, 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) {
  10698. var p = t,
  10699. q = u,
  10700. r = v,
  10701. s = w,
  10702. y = x,
  10703. C = z,
  10704. D = A,
  10705. E = B,
  10706. F = 0,
  10707. o = "number" == typeof o ? o : 0,
  10708. G = c.findSeparatingAxis(b, d, e, k, l, m, p);
  10709. if (!G) return 0;
  10710. g(D, l, d), i(p, D) > 0 && f.scale(p, p, -1);
  10711. var H = c.getClosestEdge(b, e, p, !0),
  10712. I = c.getClosestEdge(k, m, p);
  10713. if (-1 === H || -1 === I) return 0;
  10714. for (var J = 0; 2 > J; J++) {
  10715. var K = H,
  10716. L = I,
  10717. M = b,
  10718. N = k,
  10719. O = d,
  10720. P = l,
  10721. Q = e,
  10722. R = m,
  10723. S = a,
  10724. T = j;
  10725. if (0 === J) {
  10726. var U;
  10727. 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
  10728. }
  10729. for (var V = L; L + 2 > V; V++) {
  10730. var W = N.vertices[(V + N.vertices.length) % N.vertices.length];
  10731. f.rotate(q, W, R), h(q, q, P);
  10732. for (var X = 0, Y = K - 1; K + 2 > Y; Y++) {
  10733. var Z = M.vertices[(Y + M.vertices.length) % M.vertices.length],
  10734. $ = M.vertices[(Y + 1 + M.vertices.length) % M.vertices.length];
  10735. 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);
  10736. var _ = i(E, D);
  10737. (Y === K && o >= _ || Y !== K && 0 >= _) && X++
  10738. }
  10739. if (X >= 3) {
  10740. if (n) return !0;
  10741. var ab = this.createContactEquation(S, T, M, N);
  10742. F++;
  10743. var Z = M.vertices[K % M.vertices.length],
  10744. $ = M.vertices[(K + 1) % M.vertices.length];
  10745. 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);
  10746. var _ = i(ab.normalA, D);
  10747. 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.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(ab))
  10748. }
  10749. }
  10750. }
  10751. return this.enableFrictionReduction && this.enableFriction && F && this.frictionEquations.push(this.createFrictionFromAverage(F)), F
  10752. };
  10753. var $ = f.fromValues(0, 0);
  10754. c.projectConvexOntoAxis = function(a, b, c, d, e) {
  10755. var g, h, j = null,
  10756. k = null,
  10757. l = $;
  10758. f.rotate(l, d, -c);
  10759. 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);
  10760. if (k > j) {
  10761. var n = k;
  10762. k = j, j = n
  10763. }
  10764. var o = i(b, d);
  10765. f.set(e, k + o, j + o)
  10766. };
  10767. var _ = f.fromValues(0, 0),
  10768. ab = f.fromValues(0, 0),
  10769. bb = f.fromValues(0, 0),
  10770. cb = f.fromValues(0, 0),
  10771. db = f.fromValues(0, 0),
  10772. eb = f.fromValues(0, 0);
  10773. c.findSeparatingAxis = function(a, b, d, e, h, i, j) {
  10774. var k = null,
  10775. l = !1,
  10776. m = !1,
  10777. n = _,
  10778. o = ab,
  10779. p = bb,
  10780. q = cb,
  10781. s = db,
  10782. t = eb;
  10783. if (a instanceof r && e instanceof r)
  10784. for (var u = 0; 2 !== u; u++) {
  10785. var v = a,
  10786. w = d;
  10787. 1 === u && (v = e, w = i);
  10788. for (var x = 0; 2 !== x; x++) {
  10789. 0 === x ? f.set(q, 0, 1) : 1 === x && f.set(q, 1, 0), 0 !== w && f.rotate(q, q, w), c.projectConvexOntoAxis(a, b, d, q, s), c.projectConvexOntoAxis(e, h, i, q, t);
  10790. var y = s,
  10791. z = t,
  10792. A = !1;
  10793. s[0] > t[0] && (z = s, y = t, A = !0);
  10794. var B = z[0] - y[1];
  10795. l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
  10796. }
  10797. } else
  10798. for (var u = 0; 2 !== u; u++) {
  10799. var v = a,
  10800. w = d;
  10801. 1 === u && (v = e, w = i);
  10802. for (var x = 0; x !== v.vertices.length; x++) {
  10803. f.rotate(o, v.vertices[x], w), f.rotate(p, v.vertices[(x + 1) % v.vertices.length], w), g(n, p, o), f.rotate90cw(q, n), f.normalize(q, q), c.projectConvexOntoAxis(a, b, d, q, s), c.projectConvexOntoAxis(e, h, i, q, t);
  10804. var y = s,
  10805. z = t,
  10806. A = !1;
  10807. s[0] > t[0] && (z = s, y = t, A = !0);
  10808. var B = z[0] - y[1];
  10809. l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
  10810. }
  10811. }
  10812. return m
  10813. };
  10814. var fb = f.fromValues(0, 0),
  10815. gb = f.fromValues(0, 0),
  10816. hb = f.fromValues(0, 0);
  10817. c.getClosestEdge = function(a, b, c, d) {
  10818. var e = fb,
  10819. h = gb,
  10820. j = hb;
  10821. f.rotate(e, c, -b), d && f.scale(e, e, -1);
  10822. for (var k = -1, l = a.vertices.length, m = -1, n = 0; n !== l; n++) {
  10823. g(h, a.vertices[(n + 1) % l], a.vertices[n % l]), f.rotate90cw(j, h), f.normalize(j, j);
  10824. var o = i(j, e);
  10825. (-1 === k || o > m) && (k = n % l, m = o)
  10826. }
  10827. return k
  10828. };
  10829. var ib = f.create(),
  10830. jb = f.create(),
  10831. kb = f.create(),
  10832. lb = f.create(),
  10833. mb = f.create(),
  10834. nb = f.create(),
  10835. ob = f.create();
  10836. c.prototype[q.CIRCLE | q.HEIGHTFIELD] = c.prototype.circleHeightfield = function(a, b, c, d, e, i, j, k, l, m) {
  10837. var n = i.data,
  10838. m = m || b.radius,
  10839. o = i.elementWidth,
  10840. p = jb,
  10841. q = ib,
  10842. r = mb,
  10843. s = ob,
  10844. t = nb,
  10845. u = kb,
  10846. v = lb,
  10847. w = Math.floor((c[0] - m - j[0]) / o),
  10848. x = Math.ceil((c[0] + m - j[0]) / o);
  10849. 0 > w && (w = 0), x >= n.length && (x = n.length - 1);
  10850. 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]);
  10851. if (c[1] - m > y) return l ? !1 : 0;
  10852. for (var B = !1, A = w; x > A; A++) {
  10853. 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);
  10854. var C = f.dot(p, t);
  10855. if (q[0] >= u[0] && q[0] < v[0] && 0 >= C) {
  10856. if (l) return !0;
  10857. B = !0, f.scale(p, t, -C), f.add(r, q, p), f.copy(s, t);
  10858. var D = this.createContactEquation(e, a, i, b);
  10859. 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))
  10860. }
  10861. }
  10862. if (B = !1, m > 0)
  10863. for (var A = w; x >= A; A++)
  10864. if (f.set(u, A * o, n[A]), f.add(u, u, j), f.sub(p, c, u), f.squaredLength(p) < Math.pow(m, 2)) {
  10865. if (l) return !0;
  10866. B = !0;
  10867. var D = this.createContactEquation(e, a, i, b);
  10868. 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))
  10869. }
  10870. return B ? 1 : 0
  10871. };
  10872. var pb = f.create(),
  10873. qb = f.create(),
  10874. rb = f.create(),
  10875. sb = new p([f.create(), f.create(), f.create(), f.create()]);
  10876. 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) {
  10877. var k = g.data,
  10878. l = g.elementWidth,
  10879. m = pb,
  10880. n = qb,
  10881. o = rb,
  10882. p = sb,
  10883. q = Math.floor((a.aabb.lowerBound[0] - h[0]) / l),
  10884. r = Math.ceil((a.aabb.upperBound[0] - h[0]) / l);
  10885. 0 > q && (q = 0), r >= k.length && (r = k.length - 1);
  10886. 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]);
  10887. if (a.aabb.lowerBound[1] > s) return j ? !1 : 0;
  10888. for (var v = 0, u = q; r > u; u++) {
  10889. 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);
  10890. var w = 100;
  10891. 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)
  10892. }
  10893. return v
  10894. }
  10895. }, {
  10896. "../equations/ContactEquation": 22,
  10897. "../equations/Equation": 23,
  10898. "../equations/FrictionEquation": 24,
  10899. "../math/vec2": 31,
  10900. "../objects/Body": 32,
  10901. "../shapes/Circle": 38,
  10902. "../shapes/Convex": 39,
  10903. "../shapes/Rectangle": 44,
  10904. "../shapes/Shape": 45,
  10905. "../utils/TupleDictionary": 49,
  10906. "../utils/Utils": 50
  10907. }],
  10908. 12: [function(a, b) {
  10909. function c(a) {
  10910. a = a || {}, this.from = a.from ? e.fromValues(a.from[0], a.from[1]) : e.create(), this.to = a.to ? e.fromValues(a.to[0], a.to[1]) : e.create(), this._direction = e.create(), this.precision = 1e-4, this.checkCollisionResponse = !0, this.skipBackfaces = !1, this.collisionMask = -1, this.collisionGroup = -1, this.mode = c.ANY, this.result = new f, this.hasHit = !1, this.callback = function() {}
  10911. }
  10912. function d(a, b, c) {
  10913. e.sub(z, c, a);
  10914. var d = e.dot(z, b);
  10915. e.scale(A, b, d), e.add(A, A, a);
  10916. var f = e.distance(c, A);
  10917. return f
  10918. }
  10919. b.exports = c;
  10920. var e = a("../math/vec2"),
  10921. f = a("../collision/RaycastResult"),
  10922. g = a("../shapes/Shape"),
  10923. h = a("../collision/AABB");
  10924. c.prototype.constructor = c, c.CLOSEST = 1, c.ANY = 2, c.ALL = 4;
  10925. var i = new h,
  10926. j = [];
  10927. c.prototype.intersectWorld = function(a, b) {
  10928. return this.mode = b.mode || c.ANY, this.result = b.result || new f, this.skipBackfaces = !!b.skipBackfaces, this.collisionMask = "undefined" != typeof b.collisionMask ? b.collisionMask : -1, this.collisionGroup = "undefined" != typeof b.collisionGroup ? b.collisionGroup : -1, b.from && e.copy(this.from, b.from), b.to && e.copy(this.to, b.to), this.callback = b.callback || function() {}, this.hasHit = !1, this.result.reset(), this._updateDirection(), this.getAABB(i), j.length = 0, a.broadphase.aabbQuery(a, i, j), this.intersectBodies(j), this.hasHit
  10929. };
  10930. var k = (e.create(), e.create(), e.create());
  10931. c.prototype.intersectBody = function(a, b) {
  10932. b && (this.result = b, this._updateDirection());
  10933. var c = this.checkCollisionResponse;
  10934. if (!c || a.collisionResponse)
  10935. for (var d = k, f = 0, g = a.shapes.length; g > f; f++) {
  10936. var h = a.shapes[f];
  10937. if (!c || h.collisionResponse) {
  10938. e.copy(d, a.shapeOffsets[f]), e.rotate(d, d, a.angle), e.add(d, d, a.position);
  10939. var i = a.shapeAngles[f] + a.angle;
  10940. if (this.intersectShape(h, i, d, a), this.result._shouldStop) break
  10941. }
  10942. }
  10943. }, c.prototype.intersectBodies = function(a, b) {
  10944. b && (this.result = b, this._updateDirection());
  10945. for (var c = 0, d = a.length; !this.result._shouldStop && d > c; c++) this.intersectBody(a[c])
  10946. }, c.prototype._updateDirection = function() {
  10947. var a = this._direction;
  10948. e.sub(a, this.to, this.from), e.normalize(a, a)
  10949. }, c.prototype.intersectShape = function(a, b, c, e) {
  10950. var f = this.from,
  10951. g = d(f, this._direction, c);
  10952. if (!(g > a.boundingSphereRadius)) {
  10953. var h = this[a.type];
  10954. h && h.call(this, a, b, c, e)
  10955. }
  10956. };
  10957. var l = (e.create(), e.create(), e.create(), e.create(), e.create(), e.create(), e.create(), new f, e.create()),
  10958. m = e.create(),
  10959. n = e.create(),
  10960. o = e.create(),
  10961. p = e.create(),
  10962. q = e.create(),
  10963. r = e.create();
  10964. c.prototype.intersectRectangle = function(a, b, c, d) {
  10965. var f = -Number.MAX_VALUE,
  10966. g = Number.MAX_VALUE,
  10967. h = l,
  10968. i = m,
  10969. j = n,
  10970. k = o,
  10971. s = p,
  10972. t = q,
  10973. u = r;
  10974. if (e.set(t, .5 * -a.width, .5 * -a.height), e.set(u, .5 * a.width, .5 * a.height), e.rotate(h, this._direction, -b), d.toLocalFrame(i, this.from), 0 !== h[0]) {
  10975. var v = (t[0] - i[0]) / h[0],
  10976. w = (u[0] - i[0]) / h[0],
  10977. x = f;
  10978. f = Math.max(f, Math.min(v, w)), f !== x && e.set(j, v > w ? 1 : -1, 0);
  10979. var y = g;
  10980. g = Math.min(g, Math.max(v, w)), g !== y && e.set(k, w > v ? 1 : -1, 0)
  10981. }
  10982. if (0 !== h[1]) {
  10983. var z = (t[1] - i[1]) / h[1],
  10984. A = (u[1] - i[1]) / h[1],
  10985. x = f;
  10986. f = Math.max(f, Math.min(z, A)), f !== x && e.set(j, 0, z > A ? 1 : -1);
  10987. var y = g;
  10988. g = Math.min(g, Math.max(z, A)), g !== y && e.set(k, 0, A > z ? 1 : -1)
  10989. }
  10990. if (g >= f) {
  10991. if (e.set(s, i[0] + h[0] * f, i[1] + h[1] * f), e.rotate(j, j, b), d.toWorldFrame(s, s), this.reportIntersection(j, s, a, d, -1), this._shouldStop) return;
  10992. e.rotate(k, k, b), e.set(s, i[0] + h[0] * g, i[1] + h[1] * g), d.toWorldFrame(s, s), this.reportIntersection(k, s, a, d, -1)
  10993. }
  10994. }, c.prototype[g.RECTANGLE] = c.prototype.intersectRectangle;
  10995. var s = e.create(),
  10996. t = e.create(),
  10997. u = e.create(),
  10998. v = e.create(),
  10999. w = e.create();
  11000. c.prototype.intersectPlane = function(a, b, c, d) {
  11001. var f = this.from,
  11002. g = this.to,
  11003. h = this._direction,
  11004. i = s,
  11005. j = t,
  11006. k = u,
  11007. l = v,
  11008. m = w;
  11009. e.set(l, 0, 1), e.rotate(l, l, b), e.sub(m, f, c);
  11010. var n = e.dot(m, l);
  11011. e.sub(m, g, c);
  11012. var o = e.dot(m, l);
  11013. if (!(n * o > 0 || e.distance(f, g) < n)) {
  11014. var p = e.dot(l, h);
  11015. e.sub(i, f, c);
  11016. var q = -e.dot(l, i) / p;
  11017. e.scale(j, h, q), e.add(k, f, j), this.reportIntersection(l, k, a, d, -1)
  11018. }
  11019. }, c.prototype[g.PLANE] = c.prototype.intersectPlane;
  11020. var x = e.create(),
  11021. y = e.create();
  11022. c.prototype.intersectCircle = function(a, b, c, d) {
  11023. var f = this.from,
  11024. g = this.to,
  11025. h = a.radius,
  11026. i = Math.pow(g[0] - f[0], 2) + Math.pow(g[1] - f[1], 2),
  11027. j = 2 * ((g[0] - f[0]) * (f[0] - c[0]) + (g[1] - f[1]) * (f[1] - c[1])),
  11028. k = Math.pow(f[0] - c[0], 2) + Math.pow(f[1] - c[1], 2) - Math.pow(h, 2),
  11029. l = Math.pow(j, 2) - 4 * i * k,
  11030. m = x,
  11031. n = y;
  11032. if (!(0 > l))
  11033. if (0 === l) e.lerp(m, f, g, l), e.sub(n, m, c), e.normalize(n, n), this.reportIntersection(n, m, a, d, -1);
  11034. else {
  11035. var o = (-j - Math.sqrt(l)) / (2 * i),
  11036. p = (-j + Math.sqrt(l)) / (2 * i);
  11037. if (e.lerp(m, f, g, o), e.sub(n, m, c), e.normalize(n, n), this.reportIntersection(n, m, a, d, -1), this.result._shouldStop) return;
  11038. e.lerp(m, f, g, p), e.sub(n, m, c), e.normalize(n, n), this.reportIntersection(n, m, a, d, -1)
  11039. }
  11040. }, c.prototype[g.CIRCLE] = c.prototype.intersectCircle, c.prototype.getAABB = function(a) {
  11041. var b = this.to,
  11042. c = this.from;
  11043. a.lowerBound[0] = Math.min(b[0], c[0]), a.lowerBound[1] = Math.min(b[1], c[1]), a.upperBound[0] = Math.max(b[0], c[0]), a.upperBound[1] = Math.max(b[1], c[1])
  11044. }, c.prototype.reportIntersection = function(a, b, d, f, g) {
  11045. var h = this.from,
  11046. i = this.to,
  11047. j = e.distance(h, b),
  11048. k = this.result;
  11049. if (!(this.skipBackfaces && e.dot(a, this._direction) > 0)) switch (k.hitFaceIndex = "undefined" != typeof g ? g : -1, this.mode) {
  11050. case c.ALL:
  11051. this.hasHit = !0, k.set(h, i, a, b, d, f, j), k.hasHit = !0, this.callback(k);
  11052. break;
  11053. case c.CLOSEST:
  11054. (j < k.distance || !k.hasHit) && (this.hasHit = !0, k.hasHit = !0, k.set(h, i, a, b, d, f, j));
  11055. break;
  11056. case c.ANY:
  11057. this.hasHit = !0, k.hasHit = !0, k.set(h, i, a, b, d, f, j), k._shouldStop = !0
  11058. }
  11059. };
  11060. var z = e.create(),
  11061. A = e.create()
  11062. }, {
  11063. "../collision/AABB": 7,
  11064. "../collision/RaycastResult": 13,
  11065. "../math/vec2": 31,
  11066. "../shapes/Shape": 45
  11067. }],
  11068. 13: [function(a, b) {
  11069. function c() {
  11070. this.rayFromWorld = d.create(), this.rayToWorld = d.create(), this.hitNormalWorld = d.create(), this.hitPointWorld = d.create(), this.hasHit = !1, this.shape = null, this.body = null, this.hitFaceIndex = -1, this.distance = -1, this._shouldStop = !1
  11071. }
  11072. var d = a("../math/vec2");
  11073. b.exports = c, c.prototype.reset = function() {
  11074. d.set(this.rayFromWorld, 0, 0), d.set(this.rayToWorld, 0, 0), d.set(this.hitNormalWorld, 0, 0), d.set(this.hitPointWorld, 0, 0), this.hasHit = !1, this.shape = null, this.body = null, this.hitFaceIndex = -1, this.distance = -1, this._shouldStop = !1
  11075. }, c.prototype.abort = function() {
  11076. this._shouldStop = !0
  11077. }, c.prototype.set = function(a, b, c, e, f, g, h) {
  11078. d.copy(this.rayFromWorld, a), d.copy(this.rayToWorld, b), d.copy(this.hitNormalWorld, c), d.copy(this.hitPointWorld, e), this.shape = f, this.body = g, this.distance = h
  11079. }
  11080. }, {
  11081. "../math/vec2": 31
  11082. }],
  11083. 14: [function(a, b) {
  11084. function c() {
  11085. e.call(this, e.SAP), this.axisList = [], this.axisIndex = 0;
  11086. var a = this;
  11087. this._addBodyHandler = function(b) {
  11088. a.axisList.push(b.body)
  11089. }, this._removeBodyHandler = function(b) {
  11090. var c = a.axisList.indexOf(b.body); - 1 !== c && a.axisList.splice(c, 1)
  11091. }
  11092. }
  11093. var d = a("../utils/Utils"),
  11094. e = a("../collision/Broadphase");
  11095. b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setWorld = function(a) {
  11096. 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
  11097. }, c.sortAxisList = function(a, b) {
  11098. b = 0 | b;
  11099. for (var c = 1, d = a.length; d > c; c++) {
  11100. 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];
  11101. a[f + 1] = e
  11102. }
  11103. return a
  11104. }, c.prototype.sortList = function() {
  11105. var a = this.axisList,
  11106. b = this.axisIndex;
  11107. c.sortAxisList(a, b)
  11108. }, c.prototype.getCollisionPairs = function() {
  11109. var a = this.axisList,
  11110. b = this.result,
  11111. c = this.axisIndex;
  11112. b.length = 0;
  11113. for (var d = a.length; d--;) {
  11114. var f = a[d];
  11115. f.aabbNeedsUpdate && f.updateAABB()
  11116. }
  11117. this.sortList();
  11118. for (var g = 0, h = 0 | a.length; g !== h; g++)
  11119. for (var i = a[g], j = g + 1; h > j; j++) {
  11120. var k = a[j],
  11121. l = k.aabb.lowerBound[c] <= i.aabb.upperBound[c];
  11122. if (!l) break;
  11123. e.canCollide(i, k) && this.boundingVolumeCheck(i, k) && b.push(i, k)
  11124. }
  11125. return b
  11126. }, c.prototype.aabbQuery = function(a, b, c) {
  11127. c = c || [], this.sortList();
  11128. var d = this.axisIndex,
  11129. e = "x";
  11130. 1 === d && (e = "y"), 2 === d && (e = "z");
  11131. for (var f = this.axisList, g = (b.lowerBound[e], b.upperBound[e], 0); g < f.length; g++) {
  11132. var h = f[g];
  11133. h.aabbNeedsUpdate && h.updateAABB(), h.aabb.overlaps(b) && c.push(h)
  11134. }
  11135. return c
  11136. }
  11137. }, {
  11138. "../collision/Broadphase": 8,
  11139. "../utils/Utils": 50
  11140. }],
  11141. 15: [function(a, b) {
  11142. function c(a, b, c, e) {
  11143. this.type = c, e = d.defaults(e, {
  11144. collideConnected: !0,
  11145. wakeUpBodies: !0
  11146. }), this.equations = [], this.bodyA = a, this.bodyB = b, this.collideConnected = e.collideConnected, e.wakeUpBodies && (a && a.wakeUp(), b && b.wakeUp())
  11147. }
  11148. b.exports = c;
  11149. var d = a("../utils/Utils");
  11150. c.prototype.update = function() {
  11151. throw new Error("method update() not implmemented in this Constraint subclass!")
  11152. }, c.DISTANCE = 1, c.GEAR = 2, c.LOCK = 3, c.PRISMATIC = 4, c.REVOLUTE = 5, c.prototype.setStiffness = function(a) {
  11153. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11154. var d = b[c];
  11155. d.stiffness = a, d.needsUpdate = !0
  11156. }
  11157. }, c.prototype.setRelaxation = function(a) {
  11158. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11159. var d = b[c];
  11160. d.relaxation = a, d.needsUpdate = !0
  11161. }
  11162. }
  11163. }, {
  11164. "../utils/Utils": 50
  11165. }],
  11166. 16: [function(a, b) {
  11167. function c(a, b, c) {
  11168. c = g.defaults(c, {
  11169. localAnchorA: [0, 0],
  11170. localAnchorB: [0, 0]
  11171. }), d.call(this, a, b, d.DISTANCE, c), this.localAnchorA = f.fromValues(c.localAnchorA[0], c.localAnchorA[1]), this.localAnchorB = f.fromValues(c.localAnchorB[0], c.localAnchorB[1]);
  11172. var h = this.localAnchorA,
  11173. i = this.localAnchorB;
  11174. if (this.distance = 0, "number" == typeof c.distance) this.distance = c.distance;
  11175. else {
  11176. var j = f.create(),
  11177. k = f.create(),
  11178. l = f.create();
  11179. f.rotate(j, h, a.angle), f.rotate(k, i, b.angle), f.add(l, b.position, k), f.sub(l, l, j), f.sub(l, l, a.position), this.distance = f.length(l)
  11180. }
  11181. var m;
  11182. m = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce;
  11183. var n = new e(a, b, -m, m);
  11184. this.equations = [n], this.maxForce = m;
  11185. var l = f.create(),
  11186. o = f.create(),
  11187. p = f.create(),
  11188. q = this;
  11189. n.computeGq = function() {
  11190. var a = this.bodyA,
  11191. b = this.bodyB,
  11192. c = a.position,
  11193. d = b.position;
  11194. return f.rotate(o, h, a.angle), f.rotate(p, i, b.angle), f.add(l, d, p), f.sub(l, l, o), f.sub(l, l, c), f.length(l) - q.distance
  11195. }, this.setMaxForce(m), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, this.lowerLimit = 0, this.position = 0
  11196. }
  11197. var d = a("./Constraint"),
  11198. e = a("../equations/Equation"),
  11199. f = a("../math/vec2"),
  11200. g = a("../utils/Utils");
  11201. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  11202. var h = f.create(),
  11203. i = f.create(),
  11204. j = f.create();
  11205. c.prototype.update = function() {
  11206. var a = this.equations[0],
  11207. b = this.bodyA,
  11208. c = this.bodyB,
  11209. d = (this.distance, b.position),
  11210. e = c.position,
  11211. g = this.equations[0],
  11212. k = a.G;
  11213. f.rotate(i, this.localAnchorA, b.angle), f.rotate(j, this.localAnchorB, c.angle), f.add(h, e, j), f.sub(h, h, i), f.sub(h, h, d), this.position = f.length(h);
  11214. var l = !1;
  11215. if (this.upperLimitEnabled && this.position > this.upperLimit && (g.maxForce = 0, g.minForce = -this.maxForce, this.distance = this.upperLimit, l = !0), this.lowerLimitEnabled && this.position < this.lowerLimit && (g.maxForce = this.maxForce, g.minForce = 0, this.distance = this.lowerLimit, l = !0), (this.lowerLimitEnabled || this.upperLimitEnabled) && !l) return void(g.enabled = !1);
  11216. g.enabled = !0, f.normalize(h, h);
  11217. var m = f.crossLength(i, h),
  11218. n = f.crossLength(j, h);
  11219. k[0] = -h[0], k[1] = -h[1], k[2] = -m, k[3] = h[0], k[4] = h[1], k[5] = n
  11220. }, c.prototype.setMaxForce = function(a) {
  11221. var b = this.equations[0];
  11222. b.minForce = -a, b.maxForce = a
  11223. }, c.prototype.getMaxForce = function() {
  11224. var a = this.equations[0];
  11225. return a.maxForce
  11226. }
  11227. }, {
  11228. "../equations/Equation": 23,
  11229. "../math/vec2": 31,
  11230. "../utils/Utils": 50,
  11231. "./Constraint": 15
  11232. }],
  11233. 17: [function(a, b) {
  11234. function c(a, b, c) {
  11235. c = c || {}, d.call(this, a, b, d.GEAR, c), this.ratio = "number" == typeof c.ratio ? c.ratio : 1, this.angle = "number" == typeof c.angle ? c.angle : b.angle - this.ratio * a.angle, c.angle = this.angle, c.ratio = this.ratio, this.equations = [new e(a, b, c)], "number" == typeof c.maxTorque && this.setMaxTorque(c.maxTorque)
  11236. } {
  11237. var d = a("./Constraint"),
  11238. e = (a("../equations/Equation"), a("../equations/AngleLockEquation"));
  11239. a("../math/vec2")
  11240. }
  11241. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.update = function() {
  11242. var a = this.equations[0];
  11243. a.ratio !== this.ratio && a.setRatio(this.ratio), a.angle = this.angle
  11244. }, c.prototype.setMaxTorque = function(a) {
  11245. this.equations[0].setMaxTorque(a)
  11246. }, c.prototype.getMaxTorque = function() {
  11247. return this.equations[0].maxForce
  11248. }
  11249. }, {
  11250. "../equations/AngleLockEquation": 21,
  11251. "../equations/Equation": 23,
  11252. "../math/vec2": 31,
  11253. "./Constraint": 15
  11254. }],
  11255. 18: [function(a, b) {
  11256. function c(a, b, c) {
  11257. c = c || {}, d.call(this, a, b, d.LOCK, c);
  11258. var g = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce,
  11259. h = (c.localAngleB || 0, new f(a, b, -g, g)),
  11260. i = new f(a, b, -g, g),
  11261. j = new f(a, b, -g, g),
  11262. k = e.create(),
  11263. l = e.create(),
  11264. m = this;
  11265. h.computeGq = function() {
  11266. return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[0]
  11267. }, i.computeGq = function() {
  11268. return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[1]
  11269. };
  11270. var n = e.create(),
  11271. o = e.create();
  11272. j.computeGq = function() {
  11273. return e.rotate(n, m.localOffsetB, b.angle - m.localAngleB), e.scale(n, n, -1), e.sub(l, a.position, b.position), e.add(l, l, n), e.rotate(o, n, -Math.PI / 2), e.normalize(o, o), e.dot(l, o)
  11274. }, this.localOffsetB = e.create(), c.localOffsetB ? e.copy(this.localOffsetB, c.localOffsetB) : (e.sub(this.localOffsetB, b.position, a.position), e.rotate(this.localOffsetB, this.localOffsetB, -a.angle)), this.localAngleB = 0, this.localAngleB = "number" == typeof c.localAngleB ? c.localAngleB : b.angle - a.angle, this.equations.push(h, i, j), this.setMaxForce(g)
  11275. }
  11276. var d = a("./Constraint"),
  11277. e = a("../math/vec2"),
  11278. f = a("../equations/Equation");
  11279. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.setMaxForce = function(a) {
  11280. for (var b = this.equations, c = 0; c < this.equations.length; c++) b[c].maxForce = a, b[c].minForce = -a
  11281. }, c.prototype.getMaxForce = function() {
  11282. return this.equations[0].maxForce
  11283. };
  11284. var g = e.create(),
  11285. h = e.create(),
  11286. i = e.create(),
  11287. j = e.fromValues(1, 0),
  11288. k = e.fromValues(0, 1);
  11289. c.prototype.update = function() {
  11290. var a = this.equations[0],
  11291. b = this.equations[1],
  11292. c = this.equations[2],
  11293. d = this.bodyA,
  11294. f = this.bodyB;
  11295. 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)
  11296. }
  11297. }, {
  11298. "../equations/Equation": 23,
  11299. "../math/vec2": 31,
  11300. "./Constraint": 15
  11301. }],
  11302. 19: [function(a, b) {
  11303. function c(a, b, c) {
  11304. c = c || {}, d.call(this, a, b, d.PRISMATIC, c);
  11305. var i = g.fromValues(0, 0),
  11306. j = g.fromValues(1, 0),
  11307. k = g.fromValues(0, 0);
  11308. 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;
  11309. var l = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE,
  11310. m = new f(a, b, -l, l),
  11311. n = new g.create,
  11312. o = new g.create,
  11313. p = new g.create,
  11314. q = new g.create;
  11315. if (m.computeGq = function() {
  11316. return g.dot(p, q)
  11317. }, m.updateJacobian = function() {
  11318. var c = this.G,
  11319. d = a.position,
  11320. e = b.position;
  11321. 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)
  11322. }, this.equations.push(m), !c.disableRotationalLock) {
  11323. var r = new h(a, b, -l, l);
  11324. this.equations.push(r)
  11325. }
  11326. 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; {
  11327. var s = this,
  11328. t = this.motorEquation;
  11329. t.computeGW
  11330. }
  11331. t.computeGq = function() {
  11332. return 0
  11333. }, t.computeGW = function() {
  11334. var a = this.G,
  11335. b = this.bodyA,
  11336. c = this.bodyB,
  11337. d = b.velocity,
  11338. e = c.velocity,
  11339. f = b.angularVelocity,
  11340. g = c.angularVelocity;
  11341. return this.gmult(a, d, f, e, g) + s.motorSpeed
  11342. }
  11343. }
  11344. var d = a("./Constraint"),
  11345. e = a("../equations/ContactEquation"),
  11346. f = a("../equations/Equation"),
  11347. g = a("../math/vec2"),
  11348. h = a("../equations/RotationalLockEquation");
  11349. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  11350. var i = g.create(),
  11351. j = g.create(),
  11352. k = g.create(),
  11353. l = g.create(),
  11354. m = g.create(),
  11355. n = g.create();
  11356. c.prototype.update = function() {
  11357. var a = this.equations,
  11358. b = a[0],
  11359. c = this.upperLimit,
  11360. d = this.lowerLimit,
  11361. e = this.upperLimitEquation,
  11362. f = this.lowerLimitEquation,
  11363. h = this.bodyA,
  11364. o = this.bodyB,
  11365. p = this.localAxisA,
  11366. q = this.localAnchorA,
  11367. r = this.localAnchorB;
  11368. 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);
  11369. var s = this.position = g.dot(k, i) - g.dot(j, i);
  11370. if (this.motorEnabled) {
  11371. var t = this.motorEquation.G;
  11372. 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)
  11373. }
  11374. 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);
  11375. else {
  11376. var u = a.indexOf(e); - 1 !== u && a.splice(u, 1)
  11377. }
  11378. 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);
  11379. else {
  11380. var u = a.indexOf(f); - 1 !== u && a.splice(u, 1)
  11381. }
  11382. }, c.prototype.enableMotor = function() {
  11383. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  11384. }, c.prototype.disableMotor = function() {
  11385. if (this.motorEnabled) {
  11386. var a = this.equations.indexOf(this.motorEquation);
  11387. this.equations.splice(a, 1), this.motorEnabled = !1
  11388. }
  11389. }, c.prototype.setLimits = function(a, b) {
  11390. "number" == typeof a ? (this.lowerLimit = a, this.lowerLimitEnabled = !0) : (this.lowerLimit = a, this.lowerLimitEnabled = !1), "number" == typeof b ? (this.upperLimit = b, this.upperLimitEnabled = !0) : (this.upperLimit = b, this.upperLimitEnabled = !1)
  11391. }
  11392. }, {
  11393. "../equations/ContactEquation": 22,
  11394. "../equations/Equation": 23,
  11395. "../equations/RotationalLockEquation": 25,
  11396. "../math/vec2": 31,
  11397. "./Constraint": 15
  11398. }],
  11399. 20: [function(a, b) {
  11400. function c(a, b, c) {
  11401. c = c || {}, d.call(this, a, b, d.REVOLUTE, c);
  11402. var n = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE;
  11403. this.pivotA = h.create(), this.pivotB = h.create(), c.worldPivot ? (h.sub(this.pivotA, c.worldPivot, a.position), h.sub(this.pivotB, c.worldPivot, b.position), h.rotate(this.pivotA, this.pivotA, -a.angle), h.rotate(this.pivotB, this.pivotB, -b.angle)) : (h.copy(this.pivotA, c.localPivotA), h.copy(this.pivotB, c.localPivotB));
  11404. var o = this.equations = [new e(a, b, -n, n), new e(a, b, -n, n)],
  11405. p = o[0],
  11406. q = o[1],
  11407. r = this;
  11408. p.computeGq = function() {
  11409. return h.rotate(i, r.pivotA, a.angle), h.rotate(j, r.pivotB, b.angle), h.add(m, b.position, j), h.sub(m, m, a.position), h.sub(m, m, i), h.dot(m, k)
  11410. }, q.computeGq = function() {
  11411. return h.rotate(i, r.pivotA, a.angle), h.rotate(j, r.pivotB, b.angle), h.add(m, b.position, j), h.sub(m, m, a.position), h.sub(m, m, i), h.dot(m, l)
  11412. }, q.minForce = p.minForce = -n, q.maxForce = p.maxForce = n, this.motorEquation = new f(a, b), this.motorEnabled = !1, this.angle = 0, this.lowerLimitEnabled = !1, this.upperLimitEnabled = !1, this.lowerLimit = 0, this.upperLimit = 0, this.upperLimitEquation = new g(a, b), this.lowerLimitEquation = new g(a, b), this.upperLimitEquation.minForce = 0, this.lowerLimitEquation.maxForce = 0
  11413. }
  11414. var d = a("./Constraint"),
  11415. e = a("../equations/Equation"),
  11416. f = a("../equations/RotationalVelocityEquation"),
  11417. g = a("../equations/RotationalLockEquation"),
  11418. h = a("../math/vec2");
  11419. b.exports = c;
  11420. var i = h.create(),
  11421. j = h.create(),
  11422. k = h.fromValues(1, 0),
  11423. l = h.fromValues(0, 1),
  11424. m = h.create();
  11425. c.prototype = new d, c.prototype.constructor = c, c.prototype.setLimits = function(a, b) {
  11426. "number" == typeof a ? (this.lowerLimit = a, this.lowerLimitEnabled = !0) : (this.lowerLimit = a, this.lowerLimitEnabled = !1), "number" == typeof b ? (this.upperLimit = b, this.upperLimitEnabled = !0) : (this.upperLimit = b, this.upperLimitEnabled = !1)
  11427. }, c.prototype.update = function() {
  11428. var a = this.bodyA,
  11429. b = this.bodyB,
  11430. c = this.pivotA,
  11431. d = this.pivotB,
  11432. e = this.equations,
  11433. f = (e[0], e[1], e[0]),
  11434. g = e[1],
  11435. m = this.upperLimit,
  11436. n = this.lowerLimit,
  11437. o = this.upperLimitEquation,
  11438. p = this.lowerLimitEquation,
  11439. q = this.angle = b.angle - a.angle;
  11440. if (this.upperLimitEnabled && q > m) o.angle = m, -1 === e.indexOf(o) && e.push(o);
  11441. else {
  11442. var r = e.indexOf(o); - 1 !== r && e.splice(r, 1)
  11443. }
  11444. if (this.lowerLimitEnabled && n > q) p.angle = n, -1 === e.indexOf(p) && e.push(p);
  11445. else {
  11446. var r = e.indexOf(p); - 1 !== r && e.splice(r, 1)
  11447. }
  11448. 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)
  11449. }, c.prototype.enableMotor = function() {
  11450. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  11451. }, c.prototype.disableMotor = function() {
  11452. if (this.motorEnabled) {
  11453. var a = this.equations.indexOf(this.motorEquation);
  11454. this.equations.splice(a, 1), this.motorEnabled = !1
  11455. }
  11456. }, c.prototype.motorIsEnabled = function() {
  11457. return !!this.motorEnabled
  11458. }, c.prototype.setMotorSpeed = function(a) {
  11459. if (this.motorEnabled) {
  11460. var b = this.equations.indexOf(this.motorEquation);
  11461. this.equations[b].relativeVelocity = a
  11462. }
  11463. }, c.prototype.getMotorSpeed = function() {
  11464. return this.motorEnabled ? this.motorEquation.relativeVelocity : !1
  11465. }
  11466. }, {
  11467. "../equations/Equation": 23,
  11468. "../equations/RotationalLockEquation": 25,
  11469. "../equations/RotationalVelocityEquation": 26,
  11470. "../math/vec2": 31,
  11471. "./Constraint": 15
  11472. }],
  11473. 21: [function(a, b) {
  11474. function c(a, b, c) {
  11475. 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)
  11476. } {
  11477. var d = a("./Equation");
  11478. a("../math/vec2")
  11479. }
  11480. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeGq = function() {
  11481. return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle
  11482. }, c.prototype.setRatio = function(a) {
  11483. var b = this.G;
  11484. b[2] = a, b[5] = -1, this.ratio = a
  11485. }, c.prototype.setMaxTorque = function(a) {
  11486. this.maxForce = a, this.minForce = -a
  11487. }
  11488. }, {
  11489. "../math/vec2": 31,
  11490. "./Equation": 23
  11491. }],
  11492. 22: [function(a, b) {
  11493. function c(a, b) {
  11494. 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
  11495. }
  11496. var d = a("./Equation"),
  11497. e = a("../math/vec2");
  11498. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  11499. var d = this.bodyA,
  11500. f = this.bodyB,
  11501. g = this.contactPointA,
  11502. h = this.contactPointB,
  11503. i = d.position,
  11504. j = f.position,
  11505. k = this.penetrationVec,
  11506. l = this.normalA,
  11507. m = this.G,
  11508. n = e.crossLength(g, l),
  11509. o = e.crossLength(h, l);
  11510. 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);
  11511. var p, q;
  11512. this.firstImpact && 0 !== this.restitution ? (q = 0, p = 1 / b * (1 + this.restitution) * this.computeGW()) : (q = e.dot(l, k) + this.offset, p = this.computeGW());
  11513. var r = this.computeGiMf(),
  11514. s = -q * a - p * b - c * r;
  11515. return s
  11516. }
  11517. }, {
  11518. "../math/vec2": 31,
  11519. "./Equation": 23
  11520. }],
  11521. 23: [function(a, b) {
  11522. function c(a, b, d, f) {
  11523. this.minForce = "undefined" == typeof d ? -Number.MAX_VALUE : d, this.maxForce = "undefined" == typeof f ? Number.MAX_VALUE : f, this.bodyA = a, this.bodyB = b, this.stiffness = c.DEFAULT_STIFFNESS, this.relaxation = c.DEFAULT_RELAXATION, this.G = new e.ARRAY_TYPE(6);
  11524. for (var g = 0; 6 > g; g++) this.G[g] = 0;
  11525. 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
  11526. }
  11527. b.exports = c; {
  11528. var d = a("../math/vec2"),
  11529. e = a("../utils/Utils");
  11530. a("../objects/Body")
  11531. }
  11532. c.prototype.constructor = c, c.DEFAULT_STIFFNESS = 1e6, c.DEFAULT_RELAXATION = 4, c.prototype.update = function() {
  11533. var a = this.stiffness,
  11534. b = this.relaxation,
  11535. c = this.timeStep;
  11536. 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
  11537. }, c.prototype.gmult = function(a, b, c, d, e) {
  11538. return a[0] * b[0] + a[1] * b[1] + a[2] * c + a[3] * d[0] + a[4] * d[1] + a[5] * e
  11539. }, c.prototype.computeB = function(a, b, c) {
  11540. var d = this.computeGW(),
  11541. e = this.computeGq(),
  11542. f = this.computeGiMf();
  11543. return -e * a - d * b - f * c
  11544. };
  11545. var f = d.create(),
  11546. g = d.create();
  11547. c.prototype.computeGq = function() {
  11548. var a = this.G,
  11549. b = this.bodyA,
  11550. c = this.bodyB,
  11551. d = (b.position, c.position, b.angle),
  11552. e = c.angle;
  11553. return this.gmult(a, f, d, g, e) + this.offset
  11554. }, c.prototype.computeGW = function() {
  11555. var a = this.G,
  11556. b = this.bodyA,
  11557. c = this.bodyB,
  11558. d = b.velocity,
  11559. e = c.velocity,
  11560. f = b.angularVelocity,
  11561. g = c.angularVelocity;
  11562. return this.gmult(a, d, f, e, g) + this.relativeVelocity
  11563. }, c.prototype.computeGWlambda = function() {
  11564. var a = this.G,
  11565. b = this.bodyA,
  11566. c = this.bodyB,
  11567. d = b.vlambda,
  11568. e = c.vlambda,
  11569. f = b.wlambda,
  11570. g = c.wlambda;
  11571. return this.gmult(a, d, f, e, g)
  11572. };
  11573. var h = d.create(),
  11574. i = d.create();
  11575. c.prototype.computeGiMf = function() {
  11576. var a = this.bodyA,
  11577. b = this.bodyB,
  11578. c = a.force,
  11579. e = a.angularForce,
  11580. f = b.force,
  11581. g = b.angularForce,
  11582. j = a.invMassSolve,
  11583. k = b.invMassSolve,
  11584. l = a.invInertiaSolve,
  11585. m = b.invInertiaSolve,
  11586. n = this.G;
  11587. return d.scale(h, c, j), d.scale(i, f, k), this.gmult(n, h, e * l, i, g * m)
  11588. }, c.prototype.computeGiMGt = function() {
  11589. var a = this.bodyA,
  11590. b = this.bodyB,
  11591. c = a.invMassSolve,
  11592. d = b.invMassSolve,
  11593. e = a.invInertiaSolve,
  11594. f = b.invInertiaSolve,
  11595. g = this.G;
  11596. return g[0] * g[0] * c + g[1] * g[1] * c + g[2] * g[2] * e + g[3] * g[3] * d + g[4] * g[4] * d + g[5] * g[5] * f
  11597. }; {
  11598. var j = d.create(),
  11599. k = d.create(),
  11600. l = d.create();
  11601. d.create(), d.create(), d.create()
  11602. }
  11603. c.prototype.addToWlambda = function(a) {
  11604. var b = this.bodyA,
  11605. c = this.bodyB,
  11606. e = j,
  11607. f = k,
  11608. g = l,
  11609. h = b.invMassSolve,
  11610. i = c.invMassSolve,
  11611. m = b.invInertiaSolve,
  11612. n = c.invInertiaSolve,
  11613. o = this.G;
  11614. f[0] = o[0], f[1] = o[1], g[0] = o[3], g[1] = o[4], d.scale(e, f, h * a), d.add(b.vlambda, b.vlambda, e), b.wlambda += m * o[2] * a, d.scale(e, g, i * a), d.add(c.vlambda, c.vlambda, e), c.wlambda += n * o[5] * a
  11615. }, c.prototype.computeInvC = function(a) {
  11616. return 1 / (this.computeGiMGt() + a)
  11617. }
  11618. }, {
  11619. "../math/vec2": 31,
  11620. "../objects/Body": 32,
  11621. "../utils/Utils": 50
  11622. }],
  11623. 24: [function(a, b) {
  11624. function c(a, b, c) {
  11625. e.call(this, a, b, -c, c), this.contactPointA = d.create(), this.contactPointB = d.create(), this.t = d.create(), this.contactEquations = [], this.shapeA = null, this.shapeB = null, this.frictionCoefficient = .3
  11626. } {
  11627. var d = a("../math/vec2"),
  11628. e = a("./Equation");
  11629. a("../utils/Utils")
  11630. }
  11631. b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setSlipForce = function(a) {
  11632. this.maxForce = a, this.minForce = -a
  11633. }, c.prototype.getSlipForce = function() {
  11634. return this.maxForce
  11635. }, c.prototype.computeB = function(a, b, c) {
  11636. var e = (this.bodyA, this.bodyB, this.contactPointA),
  11637. f = this.contactPointB,
  11638. g = this.t,
  11639. h = this.G;
  11640. 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);
  11641. var i = this.computeGW(),
  11642. j = this.computeGiMf(),
  11643. k = -i * b - c * j;
  11644. return k
  11645. }
  11646. }, {
  11647. "../math/vec2": 31,
  11648. "../utils/Utils": 50,
  11649. "./Equation": 23
  11650. }],
  11651. 25: [function(a, b) {
  11652. function c(a, b, c) {
  11653. c = c || {}, d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0;
  11654. var e = this.G;
  11655. e[2] = 1, e[5] = -1
  11656. }
  11657. var d = a("./Equation"),
  11658. e = a("../math/vec2");
  11659. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  11660. var f = e.create(),
  11661. g = e.create(),
  11662. h = e.fromValues(1, 0),
  11663. i = e.fromValues(0, 1);
  11664. c.prototype.computeGq = function() {
  11665. return e.rotate(f, h, this.bodyA.angle + this.angle), e.rotate(g, i, this.bodyB.angle), e.dot(f, g)
  11666. }
  11667. }, {
  11668. "../math/vec2": 31,
  11669. "./Equation": 23
  11670. }],
  11671. 26: [function(a, b) {
  11672. function c(a, b) {
  11673. d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1
  11674. } {
  11675. var d = a("./Equation");
  11676. a("../math/vec2")
  11677. }
  11678. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  11679. var d = this.G;
  11680. d[2] = -1, d[5] = this.ratio;
  11681. var e = this.computeGiMf(),
  11682. f = this.computeGW(),
  11683. g = -f * b - c * e;
  11684. return g
  11685. }
  11686. }, {
  11687. "../math/vec2": 31,
  11688. "./Equation": 23
  11689. }],
  11690. 27: [function(a, b) {
  11691. var c = function() {};
  11692. b.exports = c, c.prototype = {
  11693. constructor: c,
  11694. on: function(a, b, c) {
  11695. b.context = c || this, void 0 === this._listeners && (this._listeners = {});
  11696. var d = this._listeners;
  11697. return void 0 === d[a] && (d[a] = []), -1 === d[a].indexOf(b) && d[a].push(b), this
  11698. },
  11699. has: function(a, b) {
  11700. if (void 0 === this._listeners) return !1;
  11701. var c = this._listeners;
  11702. if (b) {
  11703. if (void 0 !== c[a] && -1 !== c[a].indexOf(b)) return !0
  11704. } else if (void 0 !== c[a]) return !0;
  11705. return !1
  11706. },
  11707. off: function(a, b) {
  11708. if (void 0 === this._listeners) return this;
  11709. var c = this._listeners,
  11710. d = c[a].indexOf(b);
  11711. return -1 !== d && c[a].splice(d, 1), this
  11712. },
  11713. emit: function(a) {
  11714. if (void 0 === this._listeners) return this;
  11715. var b = this._listeners,
  11716. c = b[a.type];
  11717. if (void 0 !== c) {
  11718. a.target = this;
  11719. for (var d = 0, e = c.length; e > d; d++) {
  11720. var f = c[d];
  11721. f.call(f.context, a)
  11722. }
  11723. }
  11724. return this
  11725. }
  11726. }
  11727. }, {}],
  11728. 28: [function(a, b) {
  11729. function c(a, b, f) {
  11730. if (f = f || {}, !(a instanceof d && b instanceof d)) throw new Error("First two arguments must be Material instances.");
  11731. 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, this.contactSkinSize = .005
  11732. }
  11733. var d = a("./Material"),
  11734. e = a("../equations/Equation");
  11735. b.exports = c, c.idCounter = 0
  11736. }, {
  11737. "../equations/Equation": 23,
  11738. "./Material": 29
  11739. }],
  11740. 29: [function(a, b) {
  11741. function c(a) {
  11742. this.id = a || c.idCounter++
  11743. }
  11744. b.exports = c, c.idCounter = 0
  11745. }, {}],
  11746. 30: [function(a, b) {
  11747. var c = {};
  11748. c.GetArea = function(a) {
  11749. if (a.length < 6) return 0;
  11750. 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]);
  11751. return c += (a[0] - a[b]) * (a[b + 1] + a[1]), .5 * -c
  11752. }, c.Triangulate = function(a) {
  11753. var b = a.length >> 1;
  11754. if (3 > b) return [];
  11755. for (var d = [], e = [], f = 0; b > f; f++) e.push(f);
  11756. for (var f = 0, g = b; g > 3;) {
  11757. var h = e[(f + 0) % g],
  11758. i = e[(f + 1) % g],
  11759. j = e[(f + 2) % g],
  11760. k = a[2 * h],
  11761. l = a[2 * h + 1],
  11762. m = a[2 * i],
  11763. n = a[2 * i + 1],
  11764. o = a[2 * j],
  11765. p = a[2 * j + 1],
  11766. q = !1;
  11767. if (c._convex(k, l, m, n, o, p)) {
  11768. q = !0;
  11769. for (var r = 0; g > r; r++) {
  11770. var s = e[r];
  11771. if (s != h && s != i && s != j && c._PointInTriangle(a[2 * s], a[2 * s + 1], k, l, m, n, o, p)) {
  11772. q = !1;
  11773. break
  11774. }
  11775. }
  11776. }
  11777. if (q) d.push(h, i, j), e.splice((f + 1) % g, 1), g--, f = 0;
  11778. else if (f++ > 3 * g) break
  11779. }
  11780. return d.push(e[0], e[1], e[2]), d
  11781. }, c._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  11782. var i = g - c,
  11783. j = h - d,
  11784. k = e - c,
  11785. l = f - d,
  11786. m = a - c,
  11787. n = b - d,
  11788. o = i * i + j * j,
  11789. p = i * k + j * l,
  11790. q = i * m + j * n,
  11791. r = k * k + l * l,
  11792. s = k * m + l * n,
  11793. t = 1 / (o * r - p * p),
  11794. u = (r * q - p * s) * t,
  11795. v = (o * s - p * q) * t;
  11796. return u >= 0 && v >= 0 && 1 > u + v
  11797. }, c._convex = function(a, b, c, d, e, f) {
  11798. return (b - d) * (e - c) + (c - a) * (f - d) >= 0
  11799. }, b.exports = c
  11800. }, {}],
  11801. 31: [function(a, b) {
  11802. var c = b.exports = {},
  11803. d = a("../utils/Utils");
  11804. c.crossLength = function(a, b) {
  11805. return a[0] * b[1] - a[1] * b[0]
  11806. }, c.crossVZ = function(a, b, d) {
  11807. return c.rotate(a, b, -Math.PI / 2), c.scale(a, a, d), a
  11808. }, c.crossZV = function(a, b, d) {
  11809. return c.rotate(a, d, Math.PI / 2), c.scale(a, a, b), a
  11810. }, c.rotate = function(a, b, c) {
  11811. if (0 !== c) {
  11812. var d = Math.cos(c),
  11813. e = Math.sin(c),
  11814. f = b[0],
  11815. g = b[1];
  11816. a[0] = d * f - e * g, a[1] = e * f + d * g
  11817. } else a[0] = b[0], a[1] = b[1]
  11818. }, c.rotate90cw = function(a, b) {
  11819. var c = b[0],
  11820. d = b[1];
  11821. a[0] = d, a[1] = -c
  11822. }, c.toLocalFrame = function(a, b, d, e) {
  11823. c.copy(a, b), c.sub(a, a, d), c.rotate(a, a, -e)
  11824. }, c.toGlobalFrame = function(a, b, d, e) {
  11825. c.copy(a, b), c.rotate(a, a, e), c.add(a, a, d)
  11826. }, c.centroid = function(a, b, d, e) {
  11827. return c.add(a, b, d), c.add(a, a, e), c.scale(a, a, 1 / 3), a
  11828. }, c.create = function() {
  11829. var a = new d.ARRAY_TYPE(2);
  11830. return a[0] = 0, a[1] = 0, a
  11831. }, c.clone = function(a) {
  11832. var b = new d.ARRAY_TYPE(2);
  11833. return b[0] = a[0], b[1] = a[1], b
  11834. }, c.fromValues = function(a, b) {
  11835. var c = new d.ARRAY_TYPE(2);
  11836. return c[0] = a, c[1] = b, c
  11837. }, c.copy = function(a, b) {
  11838. return a[0] = b[0], a[1] = b[1], a
  11839. }, c.set = function(a, b, c) {
  11840. return a[0] = b, a[1] = c, a
  11841. }, c.add = function(a, b, c) {
  11842. return a[0] = b[0] + c[0], a[1] = b[1] + c[1], a
  11843. }, c.subtract = function(a, b, c) {
  11844. return a[0] = b[0] - c[0], a[1] = b[1] - c[1], a
  11845. }, c.sub = c.subtract, c.multiply = function(a, b, c) {
  11846. return a[0] = b[0] * c[0], a[1] = b[1] * c[1], a
  11847. }, c.mul = c.multiply, c.divide = function(a, b, c) {
  11848. return a[0] = b[0] / c[0], a[1] = b[1] / c[1], a
  11849. }, c.div = c.divide, c.scale = function(a, b, c) {
  11850. return a[0] = b[0] * c, a[1] = b[1] * c, a
  11851. }, c.distance = function(a, b) {
  11852. var c = b[0] - a[0],
  11853. d = b[1] - a[1];
  11854. return Math.sqrt(c * c + d * d)
  11855. }, c.dist = c.distance, c.squaredDistance = function(a, b) {
  11856. var c = b[0] - a[0],
  11857. d = b[1] - a[1];
  11858. return c * c + d * d
  11859. }, c.sqrDist = c.squaredDistance, c.length = function(a) {
  11860. var b = a[0],
  11861. c = a[1];
  11862. return Math.sqrt(b * b + c * c)
  11863. }, c.len = c.length, c.squaredLength = function(a) {
  11864. var b = a[0],
  11865. c = a[1];
  11866. return b * b + c * c
  11867. }, c.sqrLen = c.squaredLength, c.negate = function(a, b) {
  11868. return a[0] = -b[0], a[1] = -b[1], a
  11869. }, c.normalize = function(a, b) {
  11870. var c = b[0],
  11871. d = b[1],
  11872. e = c * c + d * d;
  11873. return e > 0 && (e = 1 / Math.sqrt(e), a[0] = b[0] * e, a[1] = b[1] * e), a
  11874. }, c.dot = function(a, b) {
  11875. return a[0] * b[0] + a[1] * b[1]
  11876. }, c.str = function(a) {
  11877. return "vec2(" + a[0] + ", " + a[1] + ")"
  11878. }, c.lerp = function(a, b, c, d) {
  11879. var e = b[0],
  11880. f = b[1];
  11881. return a[0] = e + d * (c[0] - e), a[1] = f + d * (c[1] - f), a
  11882. }
  11883. }, {
  11884. "../utils/Utils": 50
  11885. }],
  11886. 32: [function(a, b) {
  11887. function c(a) {
  11888. 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.invMassSolve = 0, this.invInertiaSolve = 0, this.fixedRotation = !!a.fixedRotation, 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.type = c.STATIC, this.type = "undefined" != typeof a.type ? a.type : a.mass ? c.DYNAMIC : c.STATIC, 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.collisionResponse = !0, this.idleTime = 0, this.timeLastSleepy = 0, this.ccdSpeedThreshold = void 0 !== a.ccdSpeedThreshold ? a.ccdSpeedThreshold : -1, this.ccdIterations = void 0 !== a.ccdIterations ? a.ccdIterations : 10, this.concavePath = null, this._wakeUpAfterNarrowphase = !1, this.updateMassProperties()
  11889. }
  11890. var d = a("../math/vec2"),
  11891. e = a("poly-decomp"),
  11892. f = a("../shapes/Convex"),
  11893. g = a("../collision/AABB"),
  11894. h = a("../events/EventEmitter");
  11895. b.exports = c, c.prototype = new h, c.prototype.constructor = c, c._idCounter = 0, c.prototype.updateSolveMassProperties = function() {
  11896. this.sleepState === c.SLEEPING || this.type === c.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia)
  11897. }, c.prototype.setDensity = function(a) {
  11898. var b = this.getArea();
  11899. this.mass = b * a, this.updateMassProperties()
  11900. }, c.prototype.getArea = function() {
  11901. for (var a = 0, b = 0; b < this.shapes.length; b++) a += this.shapes[b].area;
  11902. return a
  11903. }, c.prototype.getAABB = function() {
  11904. return this.aabbNeedsUpdate && this.updateAABB(), this.aabb
  11905. };
  11906. var i = new g,
  11907. j = d.create();
  11908. c.prototype.updateAABB = function() {
  11909. for (var a = this.shapes, b = this.shapeOffsets, c = this.shapeAngles, e = a.length, f = j, g = this.angle, h = 0; h !== e; h++) {
  11910. var k = a[h],
  11911. l = c[h] + g;
  11912. d.rotate(f, b[h], g), d.add(f, f, this.position), k.computeAABB(i, f, l), 0 === h ? this.aabb.copy(i) : this.aabb.extend(i)
  11913. }
  11914. this.aabbNeedsUpdate = !1
  11915. }, c.prototype.updateBoundingRadius = function() {
  11916. for (var a = this.shapes, b = this.shapeOffsets, c = a.length, e = 0, f = 0; f !== c; f++) {
  11917. var g = a[f],
  11918. h = d.length(b[f]),
  11919. i = g.boundingRadius;
  11920. h + i > e && (e = h + i)
  11921. }
  11922. this.boundingRadius = e
  11923. }, c.prototype.addShape = function(a, b, c) {
  11924. 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
  11925. }, c.prototype.removeShape = function(a) {
  11926. var b = this.shapes.indexOf(a);
  11927. return -1 !== b ? (this.shapes.splice(b, 1), this.shapeOffsets.splice(b, 1), this.shapeAngles.splice(b, 1), this.aabbNeedsUpdate = !0, !0) : !1
  11928. }, c.prototype.updateMassProperties = function() {
  11929. if (this.type === c.STATIC || this.type === c.KINEMATIC) this.mass = Number.MAX_VALUE, this.invMass = 0, this.inertia = Number.MAX_VALUE, this.invInertia = 0;
  11930. else {
  11931. var a = this.shapes,
  11932. b = a.length,
  11933. e = this.mass / b,
  11934. f = 0;
  11935. if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0;
  11936. else {
  11937. for (var g = 0; b > g; g++) {
  11938. var h = a[g],
  11939. i = d.squaredLength(this.shapeOffsets[g]),
  11940. j = h.computeMomentOfInertia(e);
  11941. f += j + e * i
  11942. }
  11943. this.inertia = f, this.invInertia = f > 0 ? 1 / f : 0
  11944. }
  11945. this.invMass = 1 / this.mass
  11946. }
  11947. };
  11948. var k = d.create();
  11949. c.prototype.applyForce = function(a, b) {
  11950. var c = k;
  11951. d.sub(c, b, this.position), d.add(this.force, this.force, a);
  11952. var e = d.crossLength(c, a);
  11953. this.angularForce += e
  11954. }, c.prototype.toLocalFrame = function(a, b) {
  11955. d.toLocalFrame(a, b, this.position, this.angle)
  11956. }, c.prototype.toWorldFrame = function(a, b) {
  11957. d.toGlobalFrame(a, b, this.position, this.angle)
  11958. }, c.prototype.fromPolygon = function(a, b) {
  11959. b = b || {};
  11960. for (var c = this.shapes.length; c >= 0; --c) this.removeShape(this.shapes[c]);
  11961. var g = new e.Polygon;
  11962. if (g.vertices = a, g.makeCCW(), "number" == typeof b.removeCollinearPoints && g.removeCollinearPoints(b.removeCollinearPoints), "undefined" == typeof b.skipSimpleCheck && !g.isSimple()) return !1;
  11963. this.concavePath = g.vertices.slice(0);
  11964. for (var c = 0; c < this.concavePath.length; c++) {
  11965. var h = [0, 0];
  11966. d.copy(h, this.concavePath[c]), this.concavePath[c] = h
  11967. }
  11968. var i;
  11969. i = b.optimalDecomp ? g.decomp() : g.quickDecomp();
  11970. for (var j = d.create(), c = 0; c !== i.length; c++) {
  11971. for (var k = new f(i[c].vertices), l = 0; l !== k.vertices.length; l++) {
  11972. var h = k.vertices[l];
  11973. d.sub(h, h, k.centerOfMass)
  11974. }
  11975. d.scale(j, k.centerOfMass, 1), k.updateTriangles(), k.updateCenterOfMass(), k.updateBoundingRadius(), this.addShape(k, j)
  11976. }
  11977. return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0
  11978. };
  11979. var l = (d.fromValues(0, 0), d.fromValues(0, 0)),
  11980. m = d.fromValues(0, 0),
  11981. n = d.fromValues(0, 0);
  11982. c.prototype.adjustCenterOfMass = function() {
  11983. var a = l,
  11984. b = m,
  11985. c = n,
  11986. e = 0;
  11987. d.set(b, 0, 0);
  11988. for (var f = 0; f !== this.shapes.length; f++) {
  11989. var g = this.shapes[f],
  11990. h = this.shapeOffsets[f];
  11991. d.scale(a, h, g.area), d.add(b, b, a), e += g.area
  11992. }
  11993. d.scale(c, b, 1 / e);
  11994. for (var f = 0; f !== this.shapes.length; f++) {
  11995. var g = this.shapes[f],
  11996. h = this.shapeOffsets[f];
  11997. h || (h = this.shapeOffsets[f] = d.create()), d.sub(h, h, c)
  11998. }
  11999. d.add(this.position, this.position, c);
  12000. for (var f = 0; this.concavePath && f < this.concavePath.length; f++) d.sub(this.concavePath[f], this.concavePath[f], c);
  12001. this.updateMassProperties(), this.updateBoundingRadius()
  12002. }, c.prototype.setZeroForce = function() {
  12003. d.set(this.force, 0, 0), this.angularForce = 0
  12004. }, c.prototype.resetConstraintVelocity = function() {
  12005. var a = this,
  12006. b = a.vlambda;
  12007. d.set(b, 0, 0), a.wlambda = 0
  12008. }, c.prototype.addConstraintVelocity = function() {
  12009. var a = this,
  12010. b = a.velocity;
  12011. d.add(b, b, a.vlambda), a.angularVelocity += a.wlambda
  12012. }, c.prototype.applyDamping = function(a) {
  12013. if (this.type === c.DYNAMIC) {
  12014. var b = this.velocity;
  12015. d.scale(b, b, Math.pow(1 - this.damping, a)), this.angularVelocity *= Math.pow(1 - this.angularDamping, a)
  12016. }
  12017. }, c.prototype.wakeUp = function() {
  12018. var a = this.sleepState;
  12019. this.sleepState = c.AWAKE, this.idleTime = 0, a !== c.AWAKE && this.emit(c.wakeUpEvent)
  12020. }, c.prototype.sleep = function() {
  12021. 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)
  12022. }, c.prototype.sleepTick = function(a, b, e) {
  12023. if (this.allowSleep && this.type !== c.SLEEPING) {
  12024. this.wantsToSleep = !1;
  12025. var f = (this.sleepState, d.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2)),
  12026. g = Math.pow(this.sleepSpeedLimit, 2);
  12027. 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())
  12028. }
  12029. }, c.prototype.getVelocityFromPosition = function(a, b) {
  12030. return a = a || d.create(), d.sub(a, this.position, this.previousPosition), d.scale(a, a, 1 / b), a
  12031. }, c.prototype.getAngularVelocityFromPosition = function(a) {
  12032. return (this.angle - this.previousAngle) / a
  12033. }, c.prototype.overlaps = function(a) {
  12034. return this.world.overlapKeeper.bodiesAreOverlapping(this, a)
  12035. };
  12036. var o = d.create(),
  12037. p = d.create();
  12038. c.prototype.integrate = function(a) {
  12039. var b = this.invMass,
  12040. c = this.force,
  12041. e = this.position,
  12042. f = this.velocity;
  12043. d.copy(this.previousPosition, this.position), this.previousAngle = this.angle, this.fixedRotation || (this.angularVelocity += this.angularForce * this.invInertia * a), d.scale(o, c, a * b), d.add(f, o, f), this.integrateToTimeOfImpact(a) || (d.scale(p, f, a), d.add(e, e, p), this.fixedRotation || (this.angle += this.angularVelocity * a)), this.aabbNeedsUpdate = !0
  12044. };
  12045. var q = d.create(),
  12046. r = d.create(),
  12047. s = d.create(),
  12048. t = d.create();
  12049. c.prototype.integrateToTimeOfImpact = function(a) {
  12050. if (this.ccdSpeedThreshold < 0 || d.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2)) return !1;
  12051. d.normalize(q, this.velocity), d.scale(r, this.velocity, a), d.add(r, r, this.position), d.sub(s, r, this.position);
  12052. var b, c = this.angularVelocity * a,
  12053. e = d.length(s),
  12054. f = 1,
  12055. g = this;
  12056. if (this.world.raycastAll(this.position, r, {}, function(a) {
  12057. a.body !== g && (b = a.body, d.copy(r, a.hitPointWorld), d.sub(s, a.hitPointWorld, g.position), f = d.length(s) / e, a.abort())
  12058. }), !b) return !1;
  12059. var h = this.angle;
  12060. d.copy(t, this.position);
  12061. for (var i = 0, j = 0, k = 0, l = f; l >= j && i < this.ccdIterations;) {
  12062. i++, k = (l - j) / 2, d.scale(p, s, f), d.add(this.position, t, p), this.angle = h + c * f, this.updateAABB();
  12063. var m = this.aabb.overlaps(b.aabb) && this.world.narrowphase.bodiesOverlap(this, b);
  12064. m ? j = k : l = k
  12065. }
  12066. return f = k, d.copy(this.position, t), this.angle = h, d.scale(p, s, f), d.add(this.position, this.position, p), this.fixedRotation || (this.angle += c * f), !0
  12067. }, c.sleepyEvent = {
  12068. type: "sleepy"
  12069. }, c.sleepEvent = {
  12070. type: "sleep"
  12071. }, c.wakeUpEvent = {
  12072. type: "wakeup"
  12073. }, c.DYNAMIC = 1, c.STATIC = 2, c.KINEMATIC = 4, c.AWAKE = 0, c.SLEEPY = 1, c.SLEEPING = 2
  12074. }, {
  12075. "../collision/AABB": 7,
  12076. "../events/EventEmitter": 27,
  12077. "../math/vec2": 31,
  12078. "../shapes/Convex": 39,
  12079. "poly-decomp": 5
  12080. }],
  12081. 33: [function(a, b) {
  12082. function c(a, b, c) {
  12083. c = c || {}, e.call(this, a, b, c), this.localAnchorA = d.fromValues(0, 0), this.localAnchorB = d.fromValues(0, 0), c.localAnchorA && d.copy(this.localAnchorA, c.localAnchorA), c.localAnchorB && d.copy(this.localAnchorB, c.localAnchorB), c.worldAnchorA && this.setWorldAnchorA(c.worldAnchorA), c.worldAnchorB && this.setWorldAnchorB(c.worldAnchorB);
  12084. var f = d.create(),
  12085. g = d.create();
  12086. this.getWorldAnchorA(f), this.getWorldAnchorB(g);
  12087. var h = d.distance(f, g);
  12088. this.restLength = "number" == typeof c.restLength ? c.restLength : h
  12089. } {
  12090. var d = a("../math/vec2"),
  12091. e = a("./Spring");
  12092. a("../utils/Utils")
  12093. }
  12094. b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setWorldAnchorA = function(a) {
  12095. this.bodyA.toLocalFrame(this.localAnchorA, a)
  12096. }, c.prototype.setWorldAnchorB = function(a) {
  12097. this.bodyB.toLocalFrame(this.localAnchorB, a)
  12098. }, c.prototype.getWorldAnchorA = function(a) {
  12099. this.bodyA.toWorldFrame(a, this.localAnchorA)
  12100. }, c.prototype.getWorldAnchorB = function(a) {
  12101. this.bodyB.toWorldFrame(a, this.localAnchorB)
  12102. };
  12103. var f = d.create(),
  12104. g = d.create(),
  12105. h = d.create(),
  12106. i = d.create(),
  12107. j = d.create(),
  12108. k = d.create(),
  12109. l = d.create(),
  12110. m = d.create(),
  12111. n = d.create();
  12112. c.prototype.applyForce = function() {
  12113. var a = this.stiffness,
  12114. b = this.damping,
  12115. c = this.restLength,
  12116. e = this.bodyA,
  12117. o = this.bodyB,
  12118. p = f,
  12119. q = g,
  12120. r = h,
  12121. s = i,
  12122. t = n,
  12123. u = j,
  12124. v = k,
  12125. w = l,
  12126. x = m;
  12127. this.getWorldAnchorA(u), this.getWorldAnchorB(v), d.sub(w, u, e.position), d.sub(x, v, o.position), d.sub(p, v, u);
  12128. var y = d.len(p);
  12129. 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);
  12130. var z = d.crossLength(w, s),
  12131. A = d.crossLength(x, s);
  12132. e.angularForce -= z, o.angularForce += A
  12133. }
  12134. }, {
  12135. "../math/vec2": 31,
  12136. "../utils/Utils": 50,
  12137. "./Spring": 35
  12138. }],
  12139. 34: [function(a, b) {
  12140. function c(a, b, c) {
  12141. c = c || {}, d.call(this, a, b, c), this.restAngle = "number" == typeof c.restAngle ? c.restAngle : b.angle - a.angle
  12142. }
  12143. var d = (a("../math/vec2"), a("./Spring"));
  12144. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.applyForce = function() {
  12145. var a = this.stiffness,
  12146. b = this.damping,
  12147. c = this.restAngle,
  12148. d = this.bodyA,
  12149. e = this.bodyB,
  12150. f = e.angle - d.angle,
  12151. g = e.angularVelocity - d.angularVelocity,
  12152. h = -a * (f - c) - b * g * 0;
  12153. d.angularForce -= h, e.angularForce += h
  12154. }
  12155. }, {
  12156. "../math/vec2": 31,
  12157. "./Spring": 35
  12158. }],
  12159. 35: [function(a, b) {
  12160. function c(a, b, c) {
  12161. c = d.defaults(c, {
  12162. stiffness: 100,
  12163. damping: 1
  12164. }), this.stiffness = c.stiffness, this.damping = c.damping, this.bodyA = a, this.bodyB = b
  12165. }
  12166. var d = (a("../math/vec2"), a("../utils/Utils"));
  12167. b.exports = c, c.prototype.applyForce = function() {}
  12168. }, {
  12169. "../math/vec2": 31,
  12170. "../utils/Utils": 50
  12171. }],
  12172. 36: [function(a, b) {
  12173. b.exports = {
  12174. AABB: a("./collision/AABB"),
  12175. AngleLockEquation: a("./equations/AngleLockEquation"),
  12176. Body: a("./objects/Body"),
  12177. Broadphase: a("./collision/Broadphase"),
  12178. Capsule: a("./shapes/Capsule"),
  12179. Circle: a("./shapes/Circle"),
  12180. Constraint: a("./constraints/Constraint"),
  12181. ContactEquation: a("./equations/ContactEquation"),
  12182. ContactMaterial: a("./material/ContactMaterial"),
  12183. Convex: a("./shapes/Convex"),
  12184. DistanceConstraint: a("./constraints/DistanceConstraint"),
  12185. Equation: a("./equations/Equation"),
  12186. EventEmitter: a("./events/EventEmitter"),
  12187. FrictionEquation: a("./equations/FrictionEquation"),
  12188. GearConstraint: a("./constraints/GearConstraint"),
  12189. GridBroadphase: a("./collision/GridBroadphase"),
  12190. GSSolver: a("./solver/GSSolver"),
  12191. Heightfield: a("./shapes/Heightfield"),
  12192. Line: a("./shapes/Line"),
  12193. LockConstraint: a("./constraints/LockConstraint"),
  12194. Material: a("./material/Material"),
  12195. Narrowphase: a("./collision/Narrowphase"),
  12196. NaiveBroadphase: a("./collision/NaiveBroadphase"),
  12197. Particle: a("./shapes/Particle"),
  12198. Plane: a("./shapes/Plane"),
  12199. RevoluteConstraint: a("./constraints/RevoluteConstraint"),
  12200. PrismaticConstraint: a("./constraints/PrismaticConstraint"),
  12201. Ray: a("./collision/Ray"),
  12202. RaycastResult: a("./collision/RaycastResult"),
  12203. Rectangle: a("./shapes/Rectangle"),
  12204. RotationalVelocityEquation: a("./equations/RotationalVelocityEquation"),
  12205. SAPBroadphase: a("./collision/SAPBroadphase"),
  12206. Shape: a("./shapes/Shape"),
  12207. Solver: a("./solver/Solver"),
  12208. Spring: a("./objects/Spring"),
  12209. LinearSpring: a("./objects/LinearSpring"),
  12210. RotationalSpring: a("./objects/RotationalSpring"),
  12211. Utils: a("./utils/Utils"),
  12212. World: a("./world/World"),
  12213. vec2: a("./math/vec2"),
  12214. version: a("../package.json").version
  12215. }
  12216. }, {
  12217. "../package.json": 6,
  12218. "./collision/AABB": 7,
  12219. "./collision/Broadphase": 8,
  12220. "./collision/GridBroadphase": 9,
  12221. "./collision/NaiveBroadphase": 10,
  12222. "./collision/Narrowphase": 11,
  12223. "./collision/Ray": 12,
  12224. "./collision/RaycastResult": 13,
  12225. "./collision/SAPBroadphase": 14,
  12226. "./constraints/Constraint": 15,
  12227. "./constraints/DistanceConstraint": 16,
  12228. "./constraints/GearConstraint": 17,
  12229. "./constraints/LockConstraint": 18,
  12230. "./constraints/PrismaticConstraint": 19,
  12231. "./constraints/RevoluteConstraint": 20,
  12232. "./equations/AngleLockEquation": 21,
  12233. "./equations/ContactEquation": 22,
  12234. "./equations/Equation": 23,
  12235. "./equations/FrictionEquation": 24,
  12236. "./equations/RotationalVelocityEquation": 26,
  12237. "./events/EventEmitter": 27,
  12238. "./material/ContactMaterial": 28,
  12239. "./material/Material": 29,
  12240. "./math/vec2": 31,
  12241. "./objects/Body": 32,
  12242. "./objects/LinearSpring": 33,
  12243. "./objects/RotationalSpring": 34,
  12244. "./objects/Spring": 35,
  12245. "./shapes/Capsule": 37,
  12246. "./shapes/Circle": 38,
  12247. "./shapes/Convex": 39,
  12248. "./shapes/Heightfield": 40,
  12249. "./shapes/Line": 41,
  12250. "./shapes/Particle": 42,
  12251. "./shapes/Plane": 43,
  12252. "./shapes/Rectangle": 44,
  12253. "./shapes/Shape": 45,
  12254. "./solver/GSSolver": 46,
  12255. "./solver/Solver": 47,
  12256. "./utils/Utils": 50,
  12257. "./world/World": 54
  12258. }],
  12259. 37: [function(a, b) {
  12260. function c(a, b) {
  12261. this.length = a || 1, this.radius = b || 1, d.call(this, d.CAPSULE)
  12262. }
  12263. var d = a("./Shape"),
  12264. e = a("../math/vec2");
  12265. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function(a) {
  12266. var b = this.radius,
  12267. c = this.length + b,
  12268. d = 2 * b;
  12269. return a * (d * d + c * c) / 12
  12270. }, c.prototype.updateBoundingRadius = function() {
  12271. this.boundingRadius = this.radius + this.length / 2
  12272. }, c.prototype.updateArea = function() {
  12273. this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length
  12274. };
  12275. var f = e.create();
  12276. c.prototype.computeAABB = function(a, b, c) {
  12277. var d = this.radius;
  12278. e.set(f, this.length / 2, 0), 0 !== c && 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)
  12279. }
  12280. }, {
  12281. "../math/vec2": 31,
  12282. "./Shape": 45
  12283. }],
  12284. 38: [function(a, b) {
  12285. function c(a) {
  12286. this.radius = a || 1, d.call(this, d.CIRCLE)
  12287. }
  12288. var d = a("./Shape"),
  12289. e = a("../math/vec2");
  12290. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function(a) {
  12291. var b = this.radius;
  12292. return a * b * b / 2
  12293. }, c.prototype.updateBoundingRadius = function() {
  12294. this.boundingRadius = this.radius
  12295. }, c.prototype.updateArea = function() {
  12296. this.area = Math.PI * this.radius * this.radius
  12297. }, c.prototype.computeAABB = function(a, b) {
  12298. var c = this.radius;
  12299. 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))
  12300. }
  12301. }, {
  12302. "../math/vec2": 31,
  12303. "./Shape": 45
  12304. }],
  12305. 39: [function(a, b) {
  12306. function c(a, b) {
  12307. this.vertices = [], this.axes = [];
  12308. for (var c = 0; c < a.length; c++) {
  12309. var f = e.create();
  12310. e.copy(f, a[c]), this.vertices.push(f)
  12311. }
  12312. if (b)
  12313. for (var c = 0; c < b.length; c++) {
  12314. var g = e.create();
  12315. e.copy(g, b[c]), this.axes.push(g)
  12316. } else
  12317. for (var c = 0; c < a.length; c++) {
  12318. var h = a[c],
  12319. i = a[(c + 1) % a.length],
  12320. j = e.create();
  12321. e.sub(j, i, h), e.rotate90cw(j, j), e.normalize(j, j), this.axes.push(j)
  12322. }
  12323. 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.")
  12324. } {
  12325. var d = a("./Shape"),
  12326. e = a("../math/vec2"),
  12327. f = a("../math/polyk");
  12328. a("poly-decomp")
  12329. }
  12330. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  12331. var g = e.create(),
  12332. h = e.create();
  12333. c.prototype.projectOntoLocalAxis = function(a, b) {
  12334. for (var c, d, f = null, h = null, a = g, i = 0; i < this.vertices.length; i++) c = this.vertices[i], d = e.dot(c, a), (null === f || d > f) && (f = d), (null === h || h > d) && (h = d);
  12335. if (h > f) {
  12336. var j = h;
  12337. h = f, f = j
  12338. }
  12339. e.set(b, h, f)
  12340. }, c.prototype.projectOntoWorldAxis = function(a, b, c, d) {
  12341. var f = h;
  12342. this.projectOntoLocalAxis(a, d), 0 !== c ? e.rotate(f, a, c) : f = a;
  12343. var g = e.dot(b, f);
  12344. e.set(d, d[0] + g, d[1] + g)
  12345. }, c.prototype.updateTriangles = function() {
  12346. this.triangles.length = 0;
  12347. for (var a = [], b = 0; b < this.vertices.length; b++) {
  12348. var c = this.vertices[b];
  12349. a.push(c[0], c[1])
  12350. }
  12351. for (var d = f.Triangulate(a), b = 0; b < d.length; b += 3) {
  12352. var e = d[b],
  12353. g = d[b + 1],
  12354. h = d[b + 2];
  12355. this.triangles.push([e, g, h])
  12356. }
  12357. }; {
  12358. var i = e.create(),
  12359. j = e.create(),
  12360. k = e.create(),
  12361. l = e.create(),
  12362. m = e.create();
  12363. e.create(), e.create(), e.create(), e.create()
  12364. }
  12365. c.prototype.updateCenterOfMass = function() {
  12366. var a = this.triangles,
  12367. b = this.vertices,
  12368. d = this.centerOfMass,
  12369. f = i,
  12370. g = k,
  12371. h = l,
  12372. n = m,
  12373. o = j;
  12374. e.set(d, 0, 0);
  12375. for (var p = 0, q = 0; q !== a.length; q++) {
  12376. var r = a[q],
  12377. g = b[r[0]],
  12378. h = b[r[1]],
  12379. n = b[r[2]];
  12380. e.centroid(f, g, h, n);
  12381. var s = c.triangleArea(g, h, n);
  12382. p += s, e.scale(o, f, s), e.add(d, d, o)
  12383. }
  12384. e.scale(d, d, 1 / p)
  12385. }, c.prototype.computeMomentOfInertia = function(a) {
  12386. for (var b = 0, c = 0, d = this.vertices.length, f = d - 1, g = 0; d > g; f = g, g++) {
  12387. var h = this.vertices[f],
  12388. i = this.vertices[g],
  12389. j = Math.abs(e.crossLength(h, i)),
  12390. k = e.dot(i, i) + e.dot(i, h) + e.dot(h, h);
  12391. b += j * k, c += j
  12392. }
  12393. return a / 6 * (b / c)
  12394. }, c.prototype.updateBoundingRadius = function() {
  12395. for (var a = this.vertices, b = 0, c = 0; c !== a.length; c++) {
  12396. var d = e.squaredLength(a[c]);
  12397. d > b && (b = d)
  12398. }
  12399. this.boundingRadius = Math.sqrt(b)
  12400. }, c.triangleArea = function(a, b, c) {
  12401. return .5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]))
  12402. }, c.prototype.updateArea = function() {
  12403. this.updateTriangles(), this.area = 0;
  12404. for (var a = this.triangles, b = this.vertices, d = 0; d !== a.length; d++) {
  12405. var e = a[d],
  12406. f = b[e[0]],
  12407. g = b[e[1]],
  12408. h = b[e[2]],
  12409. i = c.triangleArea(f, g, h);
  12410. this.area += i
  12411. }
  12412. }, c.prototype.computeAABB = function(a, b, c) {
  12413. a.setFromPoints(this.vertices, b, c, 0)
  12414. }
  12415. }, {
  12416. "../math/polyk": 30,
  12417. "../math/vec2": 31,
  12418. "./Shape": 45,
  12419. "poly-decomp": 5
  12420. }],
  12421. 40: [function(a, b) {
  12422. function c(a, b) {
  12423. if (b = e.defaults(b, {
  12424. maxValue: null,
  12425. minValue: null,
  12426. elementWidth: .1
  12427. }), null === b.minValue || null === b.maxValue) {
  12428. b.maxValue = a[0], b.minValue = a[0];
  12429. for (var c = 0; c !== a.length; c++) {
  12430. var f = a[c];
  12431. f > b.maxValue && (b.maxValue = f), f < b.minValue && (b.minValue = f)
  12432. }
  12433. }
  12434. this.data = a, this.maxValue = b.maxValue, this.minValue = b.minValue, this.elementWidth = b.elementWidth, d.call(this, d.HEIGHTFIELD)
  12435. }
  12436. var d = a("./Shape"),
  12437. e = (a("../math/vec2"), a("../utils/Utils"));
  12438. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function() {
  12439. return Number.MAX_VALUE
  12440. }, c.prototype.updateBoundingRadius = function() {
  12441. this.boundingRadius = Number.MAX_VALUE
  12442. }, c.prototype.updateArea = function() {
  12443. for (var a = this.data, b = 0, c = 0; c < a.length - 1; c++) b += (a[c] + a[c + 1]) / 2 * this.elementWidth;
  12444. this.area = b
  12445. }, c.prototype.computeAABB = function(a, b) {
  12446. 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
  12447. }
  12448. }, {
  12449. "../math/vec2": 31,
  12450. "../utils/Utils": 50,
  12451. "./Shape": 45
  12452. }],
  12453. 41: [function(a, b) {
  12454. function c(a) {
  12455. this.length = a || 1, d.call(this, d.LINE)
  12456. }
  12457. var d = a("./Shape"),
  12458. e = a("../math/vec2");
  12459. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function(a) {
  12460. return a * Math.pow(this.length, 2) / 12
  12461. }, c.prototype.updateBoundingRadius = function() {
  12462. this.boundingRadius = this.length / 2
  12463. };
  12464. var f = [e.create(), e.create()];
  12465. c.prototype.computeAABB = function(a, b, c) {
  12466. var d = this.length / 2;
  12467. e.set(f[0], -d, 0), e.set(f[1], d, 0), a.setFromPoints(f, b, c, 0)
  12468. }
  12469. }, {
  12470. "../math/vec2": 31,
  12471. "./Shape": 45
  12472. }],
  12473. 42: [function(a, b) {
  12474. function c() {
  12475. d.call(this, d.PARTICLE)
  12476. }
  12477. var d = a("./Shape"),
  12478. e = a("../math/vec2");
  12479. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function() {
  12480. return 0
  12481. }, c.prototype.updateBoundingRadius = function() {
  12482. this.boundingRadius = 0
  12483. }, c.prototype.computeAABB = function(a, b) {
  12484. e.copy(a.lowerBound, b), e.copy(a.upperBound, b)
  12485. }
  12486. }, {
  12487. "../math/vec2": 31,
  12488. "./Shape": 45
  12489. }],
  12490. 43: [function(a, b) {
  12491. function c() {
  12492. d.call(this, d.PLANE)
  12493. } {
  12494. var d = a("./Shape"),
  12495. e = a("../math/vec2");
  12496. a("../utils/Utils")
  12497. }
  12498. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function() {
  12499. return 0
  12500. }, c.prototype.updateBoundingRadius = function() {
  12501. this.boundingRadius = Number.MAX_VALUE
  12502. }, c.prototype.computeAABB = function(a, b, c) {
  12503. var d = 0,
  12504. f = e.set;
  12505. "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)
  12506. }, c.prototype.updateArea = function() {
  12507. this.area = Number.MAX_VALUE
  12508. }
  12509. }, {
  12510. "../math/vec2": 31,
  12511. "../utils/Utils": 50,
  12512. "./Shape": 45
  12513. }],
  12514. 44: [function(a, b) {
  12515. function c(a, b) {
  12516. this.width = a || 1, this.height = b || 1;
  12517. 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)],
  12518. g = [d.fromValues(1, 0), d.fromValues(0, 1)];
  12519. f.call(this, c, g), this.type = e.RECTANGLE
  12520. }
  12521. var d = a("../math/vec2"),
  12522. e = a("./Shape"),
  12523. f = a("./Convex");
  12524. b.exports = c, c.prototype = new f([]), c.prototype.constructor = c, c.prototype.computeMomentOfInertia = function(a) {
  12525. var b = this.width,
  12526. c = this.height;
  12527. return a * (c * c + b * b) / 12
  12528. }, c.prototype.updateBoundingRadius = function() {
  12529. var a = this.width,
  12530. b = this.height;
  12531. this.boundingRadius = Math.sqrt(a * a + b * b) / 2
  12532. };
  12533. d.create(), d.create(), d.create(), d.create();
  12534. c.prototype.computeAABB = function(a, b, c) {
  12535. a.setFromPoints(this.vertices, b, c, 0)
  12536. }, c.prototype.updateArea = function() {
  12537. this.area = this.width * this.height
  12538. }
  12539. }, {
  12540. "../math/vec2": 31,
  12541. "./Convex": 39,
  12542. "./Shape": 45
  12543. }],
  12544. 45: [function(a, b) {
  12545. function c(a) {
  12546. this.type = a, this.id = c.idCounter++, this.boundingRadius = 0, this.collisionGroup = 1, this.collisionResponse = !0, this.collisionMask = 1, a && this.updateBoundingRadius(), this.material = null, this.area = 0, this.sensor = !1, this.updateArea()
  12547. }
  12548. 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() {
  12549. throw new Error("Shape.computeMomentOfInertia is not implemented in this Shape...")
  12550. }, c.prototype.updateBoundingRadius = function() {
  12551. throw new Error("Shape.updateBoundingRadius is not implemented in this Shape...")
  12552. }, c.prototype.updateArea = function() {}, c.prototype.computeAABB = function() {}
  12553. }, {}],
  12554. 46: [function(a, b) {
  12555. function c(a) {
  12556. 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
  12557. }
  12558. function d(a) {
  12559. for (var b = a.length; b--;) a[b] = 0
  12560. }
  12561. var e = a("../math/vec2"),
  12562. f = a("./Solver"),
  12563. g = a("../utils/Utils"),
  12564. h = a("../equations/FrictionEquation");
  12565. b.exports = c, c.prototype = new f, c.prototype.constructor = c, c.prototype.solve = function(a, b) {
  12566. this.sortEquations();
  12567. var f = 0,
  12568. i = this.iterations,
  12569. j = this.frictionIterations,
  12570. k = this.equations,
  12571. l = k.length,
  12572. m = Math.pow(this.tolerance * l, 2),
  12573. n = b.bodies,
  12574. o = b.bodies.length,
  12575. p = (e.add, e.set, this.useZeroRHS),
  12576. q = this.lambda;
  12577. if (this.usedIterations = 0, l)
  12578. for (var r = 0; r !== o; r++) {
  12579. var s = n[r];
  12580. s.updateSolveMassProperties()
  12581. }
  12582. 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);
  12583. for (var t = this.invCs, u = this.Bs, q = this.lambda, r = 0; r !== k.length; r++) {
  12584. var v = k[r];
  12585. (v.timeStep !== a || v.needsUpdate) && (v.timeStep = a, v.update()), u[r] = v.computeB(v.a, v.b, a), t[r] = v.computeInvC(v.epsilon)
  12586. }
  12587. var v, w, r, x;
  12588. if (0 !== l) {
  12589. for (r = 0; r !== o; r++) {
  12590. var s = n[r];
  12591. s.resetConstraintVelocity()
  12592. }
  12593. if (j) {
  12594. for (f = 0; f !== j; f++) {
  12595. for (w = 0, x = 0; x !== l; x++) {
  12596. v = k[x];
  12597. var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
  12598. w += Math.abs(y)
  12599. }
  12600. if (this.usedIterations++, m >= w * w) break
  12601. }
  12602. for (c.updateMultipliers(k, q, 1 / a), x = 0; x !== l; x++) {
  12603. var z = k[x];
  12604. if (z instanceof h) {
  12605. for (var A = 0, B = 0; B !== z.contactEquations.length; B++) A += z.contactEquations[B].multiplier;
  12606. A *= z.frictionCoefficient / z.contactEquations.length, z.maxForce = A, z.minForce = -A
  12607. }
  12608. }
  12609. }
  12610. for (f = 0; f !== i; f++) {
  12611. for (w = 0, x = 0; x !== l; x++) {
  12612. v = k[x];
  12613. var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
  12614. w += Math.abs(y)
  12615. }
  12616. if (this.usedIterations++, m >= w * w) break
  12617. }
  12618. for (r = 0; r !== o; r++) n[r].addConstraintVelocity();
  12619. c.updateMultipliers(k, q, 1 / a)
  12620. }
  12621. }, c.updateMultipliers = function(a, b, c) {
  12622. for (var d = a.length; d--;) a[d].multiplier = b[d] * c
  12623. }, c.iterateEquation = function(a, b, c, d, e, f, g, h) {
  12624. var i = d[a],
  12625. j = e[a],
  12626. k = f[a],
  12627. l = b.computeGWlambda(),
  12628. m = b.maxForce,
  12629. n = b.minForce;
  12630. g && (i = 0);
  12631. var o = j * (i - l - c * k),
  12632. p = k + o;
  12633. return n * h > p ? o = n * h - k : p > m * h && (o = m * h - k), f[a] += o, b.addToWlambda(o), o
  12634. }
  12635. }, {
  12636. "../equations/FrictionEquation": 24,
  12637. "../math/vec2": 31,
  12638. "../utils/Utils": 50,
  12639. "./Solver": 47
  12640. }],
  12641. 47: [function(a, b) {
  12642. function c(a, b) {
  12643. a = a || {}, d.call(this), this.type = b, this.equations = [], this.equationSortFunction = a.equationSortFunction || !1
  12644. }
  12645. var d = (a("../utils/Utils"), a("../events/EventEmitter"));
  12646. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.solve = function() {
  12647. throw new Error("Solver.solve should be implemented by subclasses!")
  12648. };
  12649. var e = {
  12650. bodies: []
  12651. };
  12652. c.prototype.solveIsland = function(a, b) {
  12653. this.removeAllEquations(), b.equations.length && (this.addEquations(b.equations), e.bodies.length = 0, b.getBodies(e.bodies), e.bodies.length && this.solve(a, e))
  12654. }, c.prototype.sortEquations = function() {
  12655. this.equationSortFunction && this.equations.sort(this.equationSortFunction)
  12656. }, c.prototype.addEquation = function(a) {
  12657. a.enabled && this.equations.push(a)
  12658. }, c.prototype.addEquations = function(a) {
  12659. for (var b = 0, c = a.length; b !== c; b++) {
  12660. var d = a[b];
  12661. d.enabled && this.equations.push(d)
  12662. }
  12663. }, c.prototype.removeEquation = function(a) {
  12664. var b = this.equations.indexOf(a); - 1 !== b && this.equations.splice(b, 1)
  12665. }, c.prototype.removeAllEquations = function() {
  12666. this.equations.length = 0
  12667. }, c.GS = 1, c.ISLAND = 2
  12668. }, {
  12669. "../events/EventEmitter": 27,
  12670. "../utils/Utils": 50
  12671. }],
  12672. 48: [function(a, b) {
  12673. function c() {
  12674. this.overlappingShapesLastState = new e, this.overlappingShapesCurrentState = new e, this.recordPool = [], this.tmpDict = new e, this.tmpArray1 = []
  12675. }
  12676. function d(a, b, c, d) {
  12677. this.shapeA = b, this.shapeB = d, this.bodyA = a, this.bodyB = c
  12678. } {
  12679. var e = a("./TupleDictionary");
  12680. a("./Utils")
  12681. }
  12682. b.exports = c, c.prototype.tick = function() {
  12683. for (var a = this.overlappingShapesLastState, b = this.overlappingShapesCurrentState, c = a.keys.length; c--;) {
  12684. var d = a.keys[c],
  12685. e = a.getByKey(d),
  12686. f = b.getByKey(d);
  12687. e && !f && this.recordPool.push(e)
  12688. }
  12689. a.reset(), a.copy(b), b.reset()
  12690. }, c.prototype.setOverlapping = function(a, b, c, e) {
  12691. var f = (this.overlappingShapesLastState, this.overlappingShapesCurrentState);
  12692. if (!f.get(b.id, e.id)) {
  12693. var g;
  12694. this.recordPool.length ? (g = this.recordPool.pop(), g.set(a, b, c, e)) : g = new d(a, b, c, e), f.set(b.id, e.id, g)
  12695. }
  12696. }, c.prototype.getNewOverlaps = function(a) {
  12697. return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, a)
  12698. }, c.prototype.getEndOverlaps = function(a) {
  12699. return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, a)
  12700. }, c.prototype.bodiesAreOverlapping = function(a, b) {
  12701. for (var c = this.overlappingShapesCurrentState, d = c.keys.length; d--;) {
  12702. var e = c.keys[d],
  12703. f = c.data[e];
  12704. if (f.bodyA === a && f.bodyB === b || f.bodyA === b && f.bodyB === a) return !0
  12705. }
  12706. return !1
  12707. }, c.prototype.getDiff = function(a, b, c) {
  12708. var c = c || [],
  12709. d = a,
  12710. e = b;
  12711. c.length = 0;
  12712. for (var f = e.keys.length; f--;) {
  12713. var g = e.keys[f],
  12714. h = e.data[g];
  12715. if (!h) throw new Error("Key " + g + " had no data!");
  12716. var i = d.data[g];
  12717. i || c.push(h)
  12718. }
  12719. return c
  12720. }, c.prototype.isNewOverlap = function(a, b) {
  12721. var c = 0 | a.id,
  12722. d = 0 | b.id,
  12723. e = this.overlappingShapesLastState,
  12724. f = this.overlappingShapesCurrentState;
  12725. return !e.get(c, d) && !!f.get(c, d)
  12726. }, c.prototype.getNewBodyOverlaps = function(a) {
  12727. this.tmpArray1.length = 0;
  12728. var b = this.getNewOverlaps(this.tmpArray1);
  12729. return this.getBodyDiff(b, a)
  12730. }, c.prototype.getEndBodyOverlaps = function(a) {
  12731. this.tmpArray1.length = 0;
  12732. var b = this.getEndOverlaps(this.tmpArray1);
  12733. return this.getBodyDiff(b, a)
  12734. }, c.prototype.getBodyDiff = function(a, b) {
  12735. b = b || [];
  12736. for (var c = this.tmpDict, d = a.length; d--;) {
  12737. var e = a[d];
  12738. c.set(0 | e.bodyA.id, 0 | e.bodyB.id, e)
  12739. }
  12740. for (d = c.keys.length; d--;) {
  12741. var e = c.getByKey(c.keys[d]);
  12742. e && b.push(e.bodyA, e.bodyB)
  12743. }
  12744. return c.reset(), b
  12745. }, d.prototype.set = function(a, b, c, e) {
  12746. d.call(this, a, b, c, e)
  12747. }
  12748. }, {
  12749. "./TupleDictionary": 49,
  12750. "./Utils": 50
  12751. }],
  12752. 49: [function(a, b) {
  12753. function c() {
  12754. this.data = {}, this.keys = []
  12755. }
  12756. var d = a("./Utils");
  12757. b.exports = c, c.prototype.getKey = function(a, b) {
  12758. 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)
  12759. }, c.prototype.getByKey = function(a) {
  12760. return a = 0 | a, this.data[a]
  12761. }, c.prototype.get = function(a, b) {
  12762. return this.data[this.getKey(a, b)]
  12763. }, c.prototype.set = function(a, b, c) {
  12764. if (!c) throw new Error("No data!");
  12765. var d = this.getKey(a, b);
  12766. return this.data[d] || this.keys.push(d), this.data[d] = c, d
  12767. }, c.prototype.reset = function() {
  12768. for (var a = this.data, b = this.keys, c = b.length; c--;) delete a[b[c]];
  12769. b.length = 0
  12770. }, c.prototype.copy = function(a) {
  12771. this.reset(), d.appendArray(this.keys, a.keys);
  12772. for (var b = a.keys.length; b--;) {
  12773. var c = a.keys[b];
  12774. this.data[c] = a.data[c]
  12775. }
  12776. }
  12777. }, {
  12778. "./Utils": 50
  12779. }],
  12780. 50: [function(a, b) {
  12781. function c() {}
  12782. b.exports = c, c.appendArray = function(a, b) {
  12783. if (b.length < 15e4) a.push.apply(a, b);
  12784. else
  12785. for (var c = 0, d = b.length; c !== d; ++c) a.push(b[c])
  12786. }, c.splice = function(a, b, c) {
  12787. c = c || 1;
  12788. for (var d = b, e = a.length - c; e > d; d++) a[d] = a[d + c];
  12789. a.length = e
  12790. }, c.ARRAY_TYPE = window.Float32Array || Array, c.extend = function(a, b) {
  12791. for (var c in b) a[c] = b[c]
  12792. }, c.defaults = function(a, b) {
  12793. a = a || {};
  12794. for (var c in b) c in a || (a[c] = b[c]);
  12795. return a
  12796. }
  12797. }, {}],
  12798. 51: [function(a, b) {
  12799. function c() {
  12800. this.equations = [], this.bodies = []
  12801. }
  12802. var d = a("../objects/Body");
  12803. b.exports = c, c.prototype.reset = function() {
  12804. this.equations.length = this.bodies.length = 0
  12805. };
  12806. var e = [];
  12807. c.prototype.getBodies = function(a) {
  12808. var b = a || [],
  12809. c = this.equations;
  12810. e.length = 0;
  12811. for (var d = 0; d !== c.length; d++) {
  12812. 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))
  12813. }
  12814. return b
  12815. }, c.prototype.wantsToSleep = function() {
  12816. for (var a = 0; a < this.bodies.length; a++) {
  12817. var b = this.bodies[a];
  12818. if (b.type === d.DYNAMIC && !b.wantsToSleep) return !1
  12819. }
  12820. return !0
  12821. }, c.prototype.sleep = function() {
  12822. for (var a = 0; a < this.bodies.length; a++) {
  12823. var b = this.bodies[a];
  12824. b.sleep()
  12825. }
  12826. return !0
  12827. }
  12828. }, {
  12829. "../objects/Body": 32
  12830. }],
  12831. 52: [function(a, b) {
  12832. function c() {
  12833. this._nodePool = [], this._islandPool = [], this.equations = [], this.islands = [], this.nodes = [], this.queue = []
  12834. }
  12835. var d = (a("../math/vec2"), a("./Island")),
  12836. e = a("./IslandNode"),
  12837. f = a("../objects/Body");
  12838. b.exports = c, c.getUnvisitedNode = function(a) {
  12839. for (var b = a.length, c = 0; c !== b; c++) {
  12840. var d = a[c];
  12841. if (!d.visited && d.body.type === f.DYNAMIC) return d
  12842. }
  12843. return !1
  12844. }, c.prototype.visit = function(a, b, c) {
  12845. b.push(a.body);
  12846. for (var d = a.equations.length, e = 0; e !== d; e++) {
  12847. var f = a.equations[e]; - 1 === c.indexOf(f) && c.push(f)
  12848. }
  12849. }, c.prototype.bfs = function(a, b, d) {
  12850. var e = this.queue;
  12851. for (e.length = 0, e.push(a), a.visited = !0, this.visit(a, b, d); e.length;)
  12852. for (var g, h = e.pop(); g = c.getUnvisitedNode(h.neighbors);) g.visited = !0, this.visit(g, b, d), g.body.type === f.DYNAMIC && e.push(g)
  12853. }, c.prototype.split = function(a) {
  12854. for (var b = a.bodies, f = this.nodes, g = this.equations; f.length;) this._nodePool.push(f.pop());
  12855. for (var h = 0; h !== b.length; h++)
  12856. if (this._nodePool.length) {
  12857. var i = this._nodePool.pop();
  12858. i.reset(), i.body = b[h], f.push(i)
  12859. } else f.push(new e(b[h]));
  12860. for (var j = 0; j !== g.length; j++) {
  12861. var k = g[j],
  12862. h = b.indexOf(k.bodyA),
  12863. l = b.indexOf(k.bodyB),
  12864. m = f[h],
  12865. n = f[l];
  12866. m.neighbors.push(n), n.neighbors.push(m), m.equations.push(k), n.equations.push(k)
  12867. }
  12868. for (var o = this.islands; o.length;) {
  12869. var p = o.pop();
  12870. p.reset(), this._islandPool.push(p)
  12871. }
  12872. for (var q; q = c.getUnvisitedNode(f);) {
  12873. var p = this._islandPool.length ? this._islandPool.pop() : new d;
  12874. this.bfs(q, p.bodies, p.equations), o.push(p)
  12875. }
  12876. return o
  12877. }
  12878. }, {
  12879. "../math/vec2": 31,
  12880. "../objects/Body": 32,
  12881. "./Island": 51,
  12882. "./IslandNode": 53
  12883. }],
  12884. 53: [function(a, b) {
  12885. function c(a) {
  12886. this.body = a, this.neighbors = [], this.equations = [], this.visited = !1
  12887. }
  12888. b.exports = c, c.prototype.reset = function() {
  12889. this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null
  12890. }
  12891. }, {}],
  12892. 54: [function(a, b) {
  12893. function c(a) {
  12894. l.apply(this), a = a || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], this.solver = a.solver || new d, this.narrowphase = new q(this), this.islandManager = new t, this.gravity = f.fromValues(0, -9.78), a.gravity && f.copy(this.gravity, a.gravity), this.frictionGravity = f.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, this.useFrictionGravityOnZeroGravity = !0, this.doProfiling = a.doProfiling || !1, this.lastStepTime = 0, this.broadphase = a.broadphase || new p, this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new n, this.defaultContactMaterial = new o(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 = {
  12895. type: "postStep"
  12896. }, this.addBodyEvent = {
  12897. type: "addBody",
  12898. body: null
  12899. }, this.removeBodyEvent = {
  12900. type: "removeBody",
  12901. body: null
  12902. }, this.addSpringEvent = {
  12903. type: "addSpring",
  12904. spring: null
  12905. }, this.impactEvent = {
  12906. type: "impact",
  12907. bodyA: null,
  12908. bodyB: null,
  12909. shapeA: null,
  12910. shapeB: null,
  12911. contactEquation: null
  12912. }, this.postBroadphaseEvent = {
  12913. type: "postBroadphase",
  12914. pairs: null
  12915. }, this.sleepMode = c.NO_SLEEPING, this.beginContactEvent = {
  12916. type: "beginContact",
  12917. shapeA: null,
  12918. shapeB: null,
  12919. bodyA: null,
  12920. bodyB: null,
  12921. contactEquations: []
  12922. }, this.endContactEvent = {
  12923. type: "endContact",
  12924. shapeA: null,
  12925. shapeB: null,
  12926. bodyA: null,
  12927. bodyB: null
  12928. }, this.preSolveEvent = {
  12929. type: "preSolve",
  12930. contactEquations: null,
  12931. frictionEquations: null
  12932. }, this.overlappingShapesLastState = {
  12933. keys: []
  12934. }, this.overlappingShapesCurrentState = {
  12935. keys: []
  12936. }, this.overlapKeeper = new s
  12937. } {
  12938. var d = a("../solver/GSSolver"),
  12939. e = (a("../solver/Solver"), a("../collision/NaiveBroadphase"), a("../collision/Ray")),
  12940. f = a("../math/vec2"),
  12941. g = a("../shapes/Circle"),
  12942. h = (a("../shapes/Rectangle"), a("../shapes/Convex")),
  12943. i = (a("../shapes/Line"), a("../shapes/Plane")),
  12944. j = a("../shapes/Capsule"),
  12945. k = a("../shapes/Particle"),
  12946. l = a("../events/EventEmitter"),
  12947. m = a("../objects/Body"),
  12948. n = (a("../shapes/Shape"), a("../objects/LinearSpring"), a("../material/Material")),
  12949. o = a("../material/ContactMaterial"),
  12950. p = (a("../constraints/DistanceConstraint"), a("../constraints/Constraint"), a("../constraints/LockConstraint"), a("../constraints/RevoluteConstraint"), a("../constraints/PrismaticConstraint"), a("../constraints/GearConstraint"), a("../../package.json"), a("../collision/Broadphase"), a("../collision/SAPBroadphase")),
  12951. q = a("../collision/Narrowphase"),
  12952. r = a("../utils/Utils"),
  12953. s = a("../utils/OverlapKeeper"),
  12954. t = a("./IslandManager");
  12955. a("../objects/RotationalSpring")
  12956. }
  12957. if (b.exports = c, "undefined" == typeof performance && (performance = {}), !performance.now) {
  12958. var u = Date.now();
  12959. performance.timing && performance.timing.navigationStart && (u = performance.timing.navigationStart), performance.now = function() {
  12960. return Date.now() - u
  12961. }
  12962. }
  12963. c.prototype = new Object(l.prototype), c.prototype.constructor = c, c.NO_SLEEPING = 1, c.BODY_SLEEPING = 2, c.ISLAND_SLEEPING = 4, c.prototype.addConstraint = function(a) {
  12964. this.constraints.push(a)
  12965. }, c.prototype.addContactMaterial = function(a) {
  12966. this.contactMaterials.push(a)
  12967. }, c.prototype.removeContactMaterial = function(a) {
  12968. var b = this.contactMaterials.indexOf(a); - 1 !== b && r.splice(this.contactMaterials, b, 1)
  12969. }, c.prototype.getContactMaterial = function(a, b) {
  12970. for (var c = this.contactMaterials, d = 0, e = c.length; d !== e; d++) {
  12971. var f = c[d];
  12972. if (f.materialA.id === a.id && f.materialB.id === b.id || f.materialA.id === b.id && f.materialB.id === a.id) return f
  12973. }
  12974. return !1
  12975. }, c.prototype.removeConstraint = function(a) {
  12976. var b = this.constraints.indexOf(a); - 1 !== b && r.splice(this.constraints, b, 1)
  12977. };
  12978. var v = (f.create(), f.create(), f.create(), f.create(), f.create(), f.create(), f.create()),
  12979. w = f.fromValues(0, 0),
  12980. x = f.fromValues(0, 0),
  12981. y = (f.fromValues(0, 0), f.fromValues(0, 0));
  12982. c.prototype.step = function(a, b, c) {
  12983. if (c = c || 10, b = b || 0, 0 === b) this.internalStep(a), this.time += a;
  12984. else {
  12985. var d = Math.floor((this.time + b) / a) - Math.floor(this.time / a);
  12986. d = Math.min(d, c);
  12987. for (var e = performance.now(), g = 0; g !== d && (this.internalStep(a), !(performance.now() - e > 1e3 * a)); g++);
  12988. this.time += b;
  12989. for (var h = this.time % a, i = h / a, j = 0; j !== this.bodies.length; j++) {
  12990. var k = this.bodies[j];
  12991. k.type !== m.STATIC && k.sleepState !== m.SLEEPING ? (f.sub(y, k.position, k.previousPosition), f.scale(y, y, i), f.add(k.interpolatedPosition, k.position, y), k.interpolatedAngle = k.angle + (k.angle - k.previousAngle) * i) : (f.copy(k.interpolatedPosition, k.position), k.interpolatedAngle = k.angle)
  12992. }
  12993. }
  12994. };
  12995. var z = [];
  12996. c.prototype.internalStep = function(a) {
  12997. this.stepping = !0;
  12998. var b, d, e = this,
  12999. g = this.doProfiling,
  13000. h = this.springs.length,
  13001. i = this.springs,
  13002. j = this.bodies,
  13003. k = this.gravity,
  13004. l = this.solver,
  13005. n = this.bodies.length,
  13006. o = this.broadphase,
  13007. p = this.narrowphase,
  13008. q = this.constraints,
  13009. s = v,
  13010. t = (f.scale, f.add),
  13011. u = (f.rotate, this.islandManager);
  13012. if (this.overlapKeeper.tick(), this.lastTimeStep = a, g && (b = performance.now()), this.useWorldGravityAsFrictionGravity) {
  13013. var w = f.length(this.gravity);
  13014. 0 === w && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = w)
  13015. }
  13016. if (this.applyGravity)
  13017. for (var x = 0; x !== n; x++) {
  13018. var y = j[x],
  13019. A = y.force;
  13020. y.type === m.DYNAMIC && y.sleepState !== m.SLEEPING && (f.scale(s, k, y.mass * y.gravityScale), t(A, A, s))
  13021. }
  13022. if (this.applySpringForces)
  13023. for (var x = 0; x !== h; x++) {
  13024. var B = i[x];
  13025. B.applyForce()
  13026. }
  13027. if (this.applyDamping)
  13028. for (var x = 0; x !== n; x++) {
  13029. var y = j[x];
  13030. y.type === m.DYNAMIC && y.applyDamping(a)
  13031. }
  13032. for (var C = o.getCollisionPairs(this), D = this.disabledBodyCollisionPairs, x = D.length - 2; x >= 0; x -= 2)
  13033. for (var E = C.length - 2; E >= 0; E -= 2)(D[x] === C[E] && D[x + 1] === C[E + 1] || D[x + 1] === C[E] && D[x] === C[E + 1]) && C.splice(E, 2);
  13034. var F = q.length;
  13035. for (x = 0; x !== F; x++) {
  13036. var G = q[x];
  13037. if (!G.collideConnected)
  13038. for (var E = C.length - 2; E >= 0; E -= 2)(G.bodyA === C[E] && G.bodyB === C[E + 1] || G.bodyB === C[E] && G.bodyA === C[E + 1]) && C.splice(E, 2)
  13039. }
  13040. this.postBroadphaseEvent.pairs = C, this.emit(this.postBroadphaseEvent), p.reset(this);
  13041. for (var x = 0, H = C.length; x !== H; x += 2)
  13042. for (var I = C[x], J = C[x + 1], K = 0, L = I.shapes.length; K !== L; K++)
  13043. for (var M = I.shapes[K], N = I.shapeOffsets[K], O = I.shapeAngles[K], P = 0, Q = J.shapes.length; P !== Q; P++) {
  13044. var R = J.shapes[P],
  13045. S = J.shapeOffsets[P],
  13046. T = J.shapeAngles[P],
  13047. U = this.defaultContactMaterial;
  13048. if (M.material && R.material) {
  13049. var V = this.getContactMaterial(M.material, R.material);
  13050. V && (U = V)
  13051. }
  13052. this.runNarrowphase(p, I, M, N, O, J, R, S, T, U, this.frictionGravity)
  13053. }
  13054. for (var x = 0; x !== n; x++) {
  13055. var W = j[x];
  13056. W._wakeUpAfterNarrowphase && (W.wakeUp(), W._wakeUpAfterNarrowphase = !1)
  13057. }
  13058. if (this.has("endContact")) {
  13059. this.overlapKeeper.getEndOverlaps(z);
  13060. for (var X = this.endContactEvent, P = z.length; P--;) {
  13061. var Y = z[P];
  13062. X.shapeA = Y.shapeA, X.shapeB = Y.shapeB, X.bodyA = Y.bodyA, X.bodyB = Y.bodyB, this.emit(X)
  13063. }
  13064. }
  13065. var Z = this.preSolveEvent;
  13066. Z.contactEquations = p.contactEquations, Z.frictionEquations = p.frictionEquations, this.emit(Z);
  13067. var F = q.length;
  13068. for (x = 0; x !== F; x++) q[x].update();
  13069. if (p.contactEquations.length || p.frictionEquations.length || q.length)
  13070. if (this.islandSplit) {
  13071. for (u.equations.length = 0, r.appendArray(u.equations, p.contactEquations), r.appendArray(u.equations, p.frictionEquations), x = 0; x !== F; x++) r.appendArray(u.equations, q[x].equations);
  13072. u.split(this);
  13073. for (var x = 0; x !== u.islands.length; x++) {
  13074. var $ = u.islands[x];
  13075. $.equations.length && l.solveIsland(a, $)
  13076. }
  13077. } else {
  13078. for (l.addEquations(p.contactEquations), l.addEquations(p.frictionEquations), x = 0; x !== F; x++) l.addEquations(q[x].equations);
  13079. this.solveConstraints && l.solve(a, this), l.removeAllEquations()
  13080. }
  13081. for (var x = 0; x !== n; x++) {
  13082. var W = j[x];
  13083. W.sleepState !== m.SLEEPING && W.type !== m.STATIC && W.integrate(a)
  13084. }
  13085. for (var x = 0; x !== n; x++) j[x].setZeroForce();
  13086. if (g && (d = performance.now(), e.lastStepTime = d - b), this.emitImpactEvent && this.has("impact"))
  13087. for (var _ = this.impactEvent, x = 0; x !== p.contactEquations.length; x++) {
  13088. var ab = p.contactEquations[x];
  13089. ab.firstImpact && (_.bodyA = ab.bodyA, _.bodyB = ab.bodyB, _.shapeA = ab.shapeA, _.shapeB = ab.shapeB, _.contactEquation = ab, this.emit(_))
  13090. }
  13091. if (this.sleepMode === c.BODY_SLEEPING)
  13092. for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !1, a);
  13093. else if (this.sleepMode === c.ISLAND_SLEEPING && this.islandSplit) {
  13094. for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !0, a);
  13095. for (var x = 0; x < this.islandManager.islands.length; x++) {
  13096. var $ = this.islandManager.islands[x];
  13097. $.wantsToSleep() && $.sleep()
  13098. }
  13099. }
  13100. if (this.stepping = !1, this.bodiesToBeRemoved.length) {
  13101. for (var x = 0; x !== this.bodiesToBeRemoved.length; x++) this.removeBody(this.bodiesToBeRemoved[x]);
  13102. this.bodiesToBeRemoved.length = 0
  13103. }
  13104. this.emit(this.postStepEvent)
  13105. }, c.prototype.runNarrowphase = function(a, b, c, d, e, g, h, i, j, k, l) {
  13106. if (0 !== (c.collisionGroup & h.collisionMask) && 0 !== (h.collisionGroup & c.collisionMask)) {
  13107. f.rotate(w, d, b.angle), f.rotate(x, i, g.angle), f.add(w, w, b.position), f.add(x, x, g.position);
  13108. var n = e + b.angle,
  13109. o = j + g.angle;
  13110. a.enableFriction = k.friction > 0, a.frictionCoefficient = k.friction;
  13111. var p;
  13112. p = b.type === m.STATIC || b.type === m.KINEMATIC ? g.mass : g.type === m.STATIC || g.type === m.KINEMATIC ? b.mass : b.mass * g.mass / (b.mass + g.mass), a.slipForce = k.friction * l * p, a.restitution = k.restitution, a.surfaceVelocity = k.surfaceVelocity, a.frictionStiffness = k.frictionStiffness, a.frictionRelaxation = k.frictionRelaxation, a.stiffness = k.stiffness, a.relaxation = k.relaxation, a.contactSkinSize = k.contactSkinSize, a.enabledEquations = b.collisionResponse && g.collisionResponse && c.collisionResponse && h.collisionResponse;
  13113. var q = a[c.type | h.type],
  13114. r = 0;
  13115. if (q) {
  13116. var s = c.sensor || h.sensor,
  13117. t = a.frictionEquations.length;
  13118. r = c.type < h.type ? q.call(a, b, c, w, n, g, h, x, o, s) : q.call(a, g, h, x, o, b, c, w, n, s);
  13119. var u = a.frictionEquations.length - t;
  13120. if (r) {
  13121. if (b.allowSleep && b.type === m.DYNAMIC && b.sleepState === m.SLEEPING && g.sleepState === m.AWAKE && g.type !== m.STATIC) {
  13122. var v = f.squaredLength(g.velocity) + Math.pow(g.angularVelocity, 2),
  13123. y = Math.pow(g.sleepSpeedLimit, 2);
  13124. v >= 2 * y && (b._wakeUpAfterNarrowphase = !0)
  13125. }
  13126. if (g.allowSleep && g.type === m.DYNAMIC && g.sleepState === m.SLEEPING && b.sleepState === m.AWAKE && b.type !== m.STATIC) {
  13127. var z = f.squaredLength(b.velocity) + Math.pow(b.angularVelocity, 2),
  13128. A = Math.pow(b.sleepSpeedLimit, 2);
  13129. z >= 2 * A && (g._wakeUpAfterNarrowphase = !0)
  13130. }
  13131. if (this.overlapKeeper.setOverlapping(b, c, g, h), this.has("beginContact") && this.overlapKeeper.isNewOverlap(c, h)) {
  13132. var B = this.beginContactEvent;
  13133. if (B.shapeA = c, B.shapeB = h, B.bodyA = b, B.bodyB = g, B.contactEquations.length = 0, "number" == typeof r)
  13134. for (var C = a.contactEquations.length - r; C < a.contactEquations.length; C++) B.contactEquations.push(a.contactEquations[C]);
  13135. this.emit(B)
  13136. }
  13137. if ("number" == typeof r && u > 1)
  13138. for (var C = a.frictionEquations.length - u; C < a.frictionEquations.length; C++) {
  13139. var D = a.frictionEquations[C];
  13140. D.setSlipForce(D.getSlipForce() / u)
  13141. }
  13142. }
  13143. }
  13144. }
  13145. }, c.prototype.addSpring = function(a) {
  13146. this.springs.push(a), this.addSpringEvent.spring = a, this.emit(this.addSpringEvent)
  13147. }, c.prototype.removeSpring = function(a) {
  13148. var b = this.springs.indexOf(a); - 1 !== b && r.splice(this.springs, b, 1)
  13149. }, c.prototype.addBody = function(a) {
  13150. -1 === this.bodies.indexOf(a) && (this.bodies.push(a), a.world = this, this.addBodyEvent.body = a, this.emit(this.addBodyEvent))
  13151. }, c.prototype.removeBody = function(a) {
  13152. if (this.stepping) this.bodiesToBeRemoved.push(a);
  13153. else {
  13154. a.world = null;
  13155. var b = this.bodies.indexOf(a); - 1 !== b && (r.splice(this.bodies, b, 1), this.removeBodyEvent.body = a, a.resetConstraintVelocity(), this.emit(this.removeBodyEvent))
  13156. }
  13157. }, c.prototype.getBodyById = function(a) {
  13158. for (var b = this.bodies, c = 0; c < b.length; c++) {
  13159. var d = b[c];
  13160. if (d.id === a) return d
  13161. }
  13162. return !1
  13163. }, c.prototype.disableBodyCollision = function(a, b) {
  13164. this.disabledBodyCollisionPairs.push(a, b)
  13165. }, c.prototype.enableBodyCollision = function(a, b) {
  13166. for (var c = this.disabledBodyCollisionPairs, d = 0; d < c.length; d += 2)
  13167. if (c[d] === a && c[d + 1] === b || c[d + 1] === a && c[d] === b) return void c.splice(d, 2)
  13168. }, c.prototype.clear = function() {
  13169. this.time = 0, this.fixedStepTime = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
  13170. for (var a = this.constraints, b = a.length - 1; b >= 0; b--) this.removeConstraint(a[b]);
  13171. for (var d = this.bodies, b = d.length - 1; b >= 0; b--) this.removeBody(d[b]);
  13172. for (var e = this.springs, b = e.length - 1; b >= 0; b--) this.removeSpring(e[b]);
  13173. for (var f = this.contactMaterials, b = f.length - 1; b >= 0; b--) this.removeContactMaterial(f[b]);
  13174. c.apply(this)
  13175. }, c.prototype.clone = function() {
  13176. var a = new c;
  13177. return a.fromJSON(this.toJSON()), a
  13178. };
  13179. var A = f.create(),
  13180. B = f.fromValues(0, 0),
  13181. C = f.fromValues(0, 0);
  13182. c.prototype.hitTest = function(a, b, c) {
  13183. c = c || 0;
  13184. var d = new m({
  13185. position: a
  13186. }),
  13187. e = new k,
  13188. l = a,
  13189. n = 0,
  13190. o = A,
  13191. p = B,
  13192. q = C;
  13193. d.addShape(e);
  13194. for (var r = this.narrowphase, s = [], t = 0, u = b.length; t !== u; t++)
  13195. for (var v = b[t], w = 0, x = v.shapes.length; w !== x; w++) {
  13196. var y = v.shapes[w],
  13197. z = v.shapeOffsets[w] || p,
  13198. D = v.shapeAngles[w] || 0;
  13199. f.rotate(o, z, v.angle), f.add(o, o, v.position);
  13200. var E = D + v.angle;
  13201. (y instanceof g && r.circleParticle(v, y, o, E, d, e, l, n, !0) || y instanceof h && r.particleConvex(d, e, l, n, v, y, o, E, !0) || y instanceof i && r.particlePlane(d, e, l, n, v, y, o, E, !0) || y instanceof j && r.particleCapsule(d, e, l, n, v, y, o, E, !0) || y instanceof k && f.squaredLength(f.sub(q, o, a)) < c * c) && s.push(v)
  13202. }
  13203. return s
  13204. }, c.prototype.setGlobalEquationParameters = function(a) {
  13205. a = a || {};
  13206. for (var b = 0; b !== this.constraints.length; b++)
  13207. for (var c = this.constraints[b], d = 0; d !== c.equations.length; d++) {
  13208. var e = c.equations[d];
  13209. "undefined" != typeof a.stiffness && (e.stiffness = a.stiffness), "undefined" != typeof a.relaxation && (e.relaxation = a.relaxation), e.needsUpdate = !0
  13210. }
  13211. for (var b = 0; b !== this.contactMaterials.length; b++) {
  13212. var c = this.contactMaterials[b];
  13213. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13214. }
  13215. var c = this.defaultContactMaterial;
  13216. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13217. }, c.prototype.setGlobalStiffness = function(a) {
  13218. this.setGlobalEquationParameters({
  13219. stiffness: a
  13220. })
  13221. }, c.prototype.setGlobalRelaxation = function(a) {
  13222. this.setGlobalEquationParameters({
  13223. relaxation: a
  13224. })
  13225. };
  13226. var D = new e;
  13227. c.prototype.raycastAll = function(a, b, c, d) {
  13228. return c.mode = e.ALL, c.from = a, c.to = b, c.callback = d, D.intersectWorld(this, c)
  13229. }, c.prototype.raycastAny = function(a, b, c, d) {
  13230. return c.mode = e.ANY, c.from = a, c.to = b, c.result = d, D.intersectWorld(this, c)
  13231. }, c.prototype.raycastClosest = function(a, b, c, d) {
  13232. return c.mode = e.CLOSEST, c.from = a, c.to = b, c.result = d, D.intersectWorld(this, c)
  13233. }
  13234. }, {
  13235. "../../package.json": 6,
  13236. "../collision/Broadphase": 8,
  13237. "../collision/NaiveBroadphase": 10,
  13238. "../collision/Narrowphase": 11,
  13239. "../collision/Ray": 12,
  13240. "../collision/SAPBroadphase": 14,
  13241. "../constraints/Constraint": 15,
  13242. "../constraints/DistanceConstraint": 16,
  13243. "../constraints/GearConstraint": 17,
  13244. "../constraints/LockConstraint": 18,
  13245. "../constraints/PrismaticConstraint": 19,
  13246. "../constraints/RevoluteConstraint": 20,
  13247. "../events/EventEmitter": 27,
  13248. "../material/ContactMaterial": 28,
  13249. "../material/Material": 29,
  13250. "../math/vec2": 31,
  13251. "../objects/Body": 32,
  13252. "../objects/LinearSpring": 33,
  13253. "../objects/RotationalSpring": 34,
  13254. "../shapes/Capsule": 37,
  13255. "../shapes/Circle": 38,
  13256. "../shapes/Convex": 39,
  13257. "../shapes/Line": 41,
  13258. "../shapes/Particle": 42,
  13259. "../shapes/Plane": 43,
  13260. "../shapes/Rectangle": 44,
  13261. "../shapes/Shape": 45,
  13262. "../solver/GSSolver": 46,
  13263. "../solver/Solver": 47,
  13264. "../utils/OverlapKeeper": 48,
  13265. "../utils/Utils": 50,
  13266. "./IslandManager": 52
  13267. }]
  13268. }, {}, [36])(36)
  13269. }), p2.Body.prototype.parent = null, p2.Spring.prototype.parent = null, c.Physics.P2 = function(a, b) {
  13270. this.game = a, "undefined" == typeof b ? b = {
  13271. gravity: [0, 0],
  13272. broadphase: new p2.SAPBroadphase
  13273. } : (b.hasOwnProperty("gravity") || (b.gravity = [0, 0]), b.hasOwnProperty("broadphase") || (b.broadphase = new p2.SAPBroadphase)), this.config = b, this.world = new p2.World(this.config), this.frameRate = 1 / 60, this.useElapsedTime = !1, this.paused = !1, this.materials = [], this.gravity = new c.Physics.P2.InversePointProxy(this, this.world.gravity), this.walls = {
  13274. left: null,
  13275. right: null,
  13276. top: null,
  13277. bottom: null
  13278. }, this.onBodyAdded = new c.Signal, this.onBodyRemoved = new c.Signal, this.onSpringAdded = new c.Signal, this.onSpringRemoved = new c.Signal, this.onConstraintAdded = new c.Signal, this.onConstraintRemoved = new c.Signal, this.onContactMaterialAdded = new c.Signal, this.onContactMaterialRemoved = new c.Signal, this.postBroadphaseCallback = null, this.callbackContext = null, this.onBeginContact = new c.Signal, this.onEndContact = new c.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 c.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new c.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new c.Physics.P2.CollisionGroup(2147483648), this.boundsCollidesWith = [], this._toRemove = [], this._collisionGroupID = 2, this._boundsLeft = !0, this._boundsRight = !0, this._boundsTop = !0, this._boundsBottom = !0, this._boundsOwnGroup = !1, this.setBoundsToWorld(!0, !0, !0, !0, !1)
  13279. }, c.Physics.P2.prototype = {
  13280. removeBodyNextStep: function(a) {
  13281. this._toRemove.push(a)
  13282. },
  13283. preUpdate: function() {
  13284. for (var a = this._toRemove.length; a--;) this.removeBody(this._toRemove[a]);
  13285. this._toRemove.length = 0
  13286. },
  13287. enable: function(a, b, d) {
  13288. "undefined" == typeof b && (b = !1), "undefined" == typeof d && (d = !0);
  13289. var e = 1;
  13290. if (Array.isArray(a))
  13291. for (e = a.length; e--;) a[e] instanceof c.Group ? this.enable(a[e].children, b, d) : (this.enableBody(a[e], b), d && a[e].hasOwnProperty("children") && a[e].children.length > 0 && this.enable(a[e], b, !0));
  13292. else a instanceof c.Group ? this.enable(a.children, b, d) : (this.enableBody(a, b), d && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, b, !0))
  13293. },
  13294. enableBody: function(a, b) {
  13295. a.hasOwnProperty("body") && null === a.body && (a.body = new c.Physics.P2.Body(this.game, a, a.x, a.y, 1), a.body.debug = b, a.anchor.set(.5))
  13296. },
  13297. setImpactEvents: function(a) {
  13298. a ? this.world.on("impact", this.impactHandler, this) : this.world.off("impact", this.impactHandler, this)
  13299. },
  13300. setPostBroadphaseCallback: function(a, b) {
  13301. this.postBroadphaseCallback = a, this.callbackContext = b, null !== a ? this.world.on("postBroadphase", this.postBroadphaseHandler, this) : this.world.off("postBroadphase", this.postBroadphaseHandler, this)
  13302. },
  13303. postBroadphaseHandler: function(a) {
  13304. if (this.postBroadphaseCallback && 0 !== a.pairs.length)
  13305. for (var b = a.pairs.length - 2; b >= 0; 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)
  13306. },
  13307. impactHandler: function(a) {
  13308. if (a.bodyA.parent && a.bodyB.parent) {
  13309. var b = a.bodyA.parent,
  13310. c = a.bodyB.parent;
  13311. 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)
  13312. }
  13313. },
  13314. beginContactHandler: function(a) {
  13315. 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)
  13316. },
  13317. endContactHandler: function(a) {
  13318. 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)
  13319. },
  13320. setBoundsToWorld: function(a, b, c, d, e) {
  13321. 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)
  13322. },
  13323. setWorldMaterial: function(a, b, c, d, e) {
  13324. "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)
  13325. },
  13326. updateBoundsCollisionGroup: function(a) {
  13327. var b = this.everythingCollisionGroup.mask;
  13328. "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)
  13329. },
  13330. setBounds: function(a, b, c, d, e, f, g, h, i) {
  13331. "undefined" == typeof e && (e = this._boundsLeft), "undefined" == typeof f && (f = this._boundsRight), "undefined" == typeof g && (g = this._boundsTop), "undefined" == typeof h && (h = this._boundsBottom), "undefined" == typeof i && (i = this._boundsOwnGroup), 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({
  13332. mass: 0,
  13333. position: [this.pxmi(a), this.pxmi(b)],
  13334. angle: 1.5707963267948966
  13335. }), 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({
  13336. mass: 0,
  13337. position: [this.pxmi(a + c), this.pxmi(b)],
  13338. angle: -1.5707963267948966
  13339. }), 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({
  13340. mass: 0,
  13341. position: [this.pxmi(a), this.pxmi(b)],
  13342. angle: -3.141592653589793
  13343. }), 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({
  13344. mass: 0,
  13345. position: [this.pxmi(a), this.pxmi(b + d)]
  13346. }), this.walls.bottom.addShape(new p2.Plane), i && (this.walls.bottom.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.bottom)), this._boundsLeft = e, this._boundsRight = f, this._boundsTop = g, this._boundsBottom = h, this._boundsOwnGroup = i
  13347. },
  13348. pause: function() {
  13349. this.paused = !0
  13350. },
  13351. resume: function() {
  13352. this.paused = !1
  13353. },
  13354. update: function() {
  13355. this.paused || this.world.step(this.useElapsedTime ? this.game.time.physicsElapsed : this.frameRate)
  13356. },
  13357. reset: function() {
  13358. this.world.on("beginContact", this.beginContactHandler, this), this.world.on("endContact", this.endContactHandler, this), this.nothingCollisionGroup = new c.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new c.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new c.Physics.P2.CollisionGroup(2147483648), this._collisionGroupID = 2, this.setBoundsToWorld(!0, !0, !0, !0, !1)
  13359. },
  13360. clear: function() {
  13361. this.world.time = 0, this.world.fixedStepTime = 0, this.world.solver && this.world.solver.equations.length && this.world.solver.removeAllEquations();
  13362. for (var a = this.world.constraints, b = a.length - 1; b >= 0; b--) this.world.removeConstraint(a[b]);
  13363. for (var c = this.world.bodies, b = c.length - 1; b >= 0; b--) this.world.removeBody(c[b]);
  13364. for (var d = this.world.springs, b = d.length - 1; b >= 0; b--) this.world.removeSpring(d[b]);
  13365. for (var e = this.world.contactMaterials, b = e.length - 1; b >= 0; b--) this.world.removeContactMaterial(e[b]);
  13366. 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.boundsCollidesWith = []
  13367. },
  13368. destroy: function() {
  13369. this.clear(), this.game = null
  13370. },
  13371. addBody: function(a) {
  13372. return a.data.world ? !1 : (this.world.addBody(a.data), this.onBodyAdded.dispatch(a), !0)
  13373. },
  13374. removeBody: function(a) {
  13375. return a.data.world == this.world && (this.world.removeBody(a.data), this.onBodyRemoved.dispatch(a)), a
  13376. },
  13377. addSpring: function(a) {
  13378. return this.world.addSpring(a instanceof c.Physics.P2.Spring || a instanceof c.Physics.P2.RotationalSpring ? a.data : a), this.onSpringAdded.dispatch(a), a
  13379. },
  13380. removeSpring: function(a) {
  13381. return this.world.removeSpring(a instanceof c.Physics.P2.Spring || a instanceof c.Physics.P2.RotationalSpring ? a.data : a), this.onSpringRemoved.dispatch(a), a
  13382. },
  13383. createDistanceConstraint: function(a, b, d, e, f, g) {
  13384. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new c.Physics.P2.DistanceConstraint(this, a, b, d, e, f, g)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13385. },
  13386. createGearConstraint: function(a, b, d, e) {
  13387. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new c.Physics.P2.GearConstraint(this, a, b, d, e)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13388. },
  13389. createRevoluteConstraint: function(a, b, d, e, f, g) {
  13390. return a = this.getBody(a), d = this.getBody(d), a && d ? this.addConstraint(new c.Physics.P2.RevoluteConstraint(this, a, b, d, e, f, g)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13391. },
  13392. createLockConstraint: function(a, b, d, e, f) {
  13393. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new c.Physics.P2.LockConstraint(this, a, b, d, e, f)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13394. },
  13395. createPrismaticConstraint: function(a, b, d, e, f, g, h) {
  13396. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new c.Physics.P2.PrismaticConstraint(this, a, b, d, e, f, g, h)) : void console.warn("Cannot create Constraint, invalid body objects given")
  13397. },
  13398. addConstraint: function(a) {
  13399. return this.world.addConstraint(a), this.onConstraintAdded.dispatch(a), a
  13400. },
  13401. removeConstraint: function(a) {
  13402. return this.world.removeConstraint(a), this.onConstraintRemoved.dispatch(a), a
  13403. },
  13404. addContactMaterial: function(a) {
  13405. return this.world.addContactMaterial(a), this.onContactMaterialAdded.dispatch(a), a
  13406. },
  13407. removeContactMaterial: function(a) {
  13408. return this.world.removeContactMaterial(a), this.onContactMaterialRemoved.dispatch(a), a
  13409. },
  13410. getContactMaterial: function(a, b) {
  13411. return this.world.getContactMaterial(a, b)
  13412. },
  13413. setMaterial: function(a, b) {
  13414. for (var c = b.length; c--;) b[c].setMaterial(a)
  13415. },
  13416. createMaterial: function(a, b) {
  13417. a = a || "";
  13418. var d = new c.Physics.P2.Material(a);
  13419. return this.materials.push(d), "undefined" != typeof b && b.setMaterial(d), d
  13420. },
  13421. createContactMaterial: function(a, b, d) {
  13422. "undefined" == typeof a && (a = this.createMaterial()), "undefined" == typeof b && (b = this.createMaterial());
  13423. var e = new c.Physics.P2.ContactMaterial(a, b, d);
  13424. return this.addContactMaterial(e)
  13425. },
  13426. getBodies: function() {
  13427. for (var a = [], b = this.world.bodies.length; b--;) a.push(this.world.bodies[b].parent);
  13428. return a
  13429. },
  13430. getBody: function(a) {
  13431. return a instanceof p2.Body ? a : a instanceof c.Physics.P2.Body ? a.data : a.body && a.body.type === c.Physics.P2JS ? a.body.data : null
  13432. },
  13433. getSprings: function() {
  13434. for (var a = [], b = this.world.springs.length; b--;) a.push(this.world.springs[b].parent);
  13435. return a
  13436. },
  13437. getConstraints: function() {
  13438. for (var a = [], b = this.world.constraints.length; b--;) a.push(this.world.constraints[b].parent);
  13439. return a
  13440. },
  13441. hitTest: function(a, b, d, e) {
  13442. "undefined" == typeof b && (b = this.world.bodies), "undefined" == typeof d && (d = 5), "undefined" == typeof e && (e = !1);
  13443. for (var f = [this.pxmi(a.x), this.pxmi(a.y)], g = [], h = b.length; h--;) b[h] instanceof c.Physics.P2.Body && (!e || b[h].data.type !== p2.Body.STATIC) ? g.push(b[h].data) : b[h] instanceof p2.Body && b[h].parent && (!e || b[h].type !== p2.Body.STATIC) ? g.push(b[h]) : b[h] instanceof c.Sprite && b[h].hasOwnProperty("body") && (!e || b[h].body.data.type !== p2.Body.STATIC) && g.push(b[h].body.data);
  13444. return this.world.hitTest(f, g, d)
  13445. },
  13446. toJSON: function() {
  13447. return this.world.toJSON()
  13448. },
  13449. createCollisionGroup: function(a) {
  13450. var b = Math.pow(2, this._collisionGroupID);
  13451. 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++;
  13452. var d = new c.Physics.P2.CollisionGroup(b);
  13453. return this.collisionGroups.push(d), a && this.setCollisionGroup(a, d), d
  13454. },
  13455. setCollisionGroup: function(a, b) {
  13456. if (a instanceof c.Group)
  13457. for (var d = 0; d < a.total; d++) a.children[d].body && a.children[d].body.type === c.Physics.P2JS && a.children[d].body.setCollisionGroup(b);
  13458. else a.body.setCollisionGroup(b)
  13459. },
  13460. createSpring: function(a, b, d, e, f, g, h, i, j) {
  13461. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addSpring(new c.Physics.P2.Spring(this, a, b, d, e, f, g, h, i, j)) : void console.warn("Cannot create Spring, invalid body objects given")
  13462. },
  13463. createRotationalSpring: function(a, b, d, e, f) {
  13464. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addSpring(new c.Physics.P2.RotationalSpring(this, a, b, d, e, f)) : void console.warn("Cannot create Rotational Spring, invalid body objects given")
  13465. },
  13466. createBody: function(a, b, d, e, f, g) {
  13467. "undefined" == typeof e && (e = !1);
  13468. var h = new c.Physics.P2.Body(this.game, null, a, b, d);
  13469. if (g) {
  13470. var i = h.addPolygon(f, g);
  13471. if (!i) return !1
  13472. }
  13473. return e && this.world.addBody(h.data), h
  13474. },
  13475. createParticle: function(a, b, d, e, f, g) {
  13476. "undefined" == typeof e && (e = !1);
  13477. var h = new c.Physics.P2.Body(this.game, null, a, b, d);
  13478. if (g) {
  13479. var i = h.addPolygon(f, g);
  13480. if (!i) return !1
  13481. }
  13482. return e && this.world.addBody(h.data), h
  13483. },
  13484. convertCollisionObjects: function(a, b, c) {
  13485. "undefined" == typeof c && (c = !0);
  13486. for (var d = [], e = 0, f = a.collision[b].length; f > e; e++) {
  13487. var g = a.collision[b][e],
  13488. h = this.createBody(g.x, g.y, 0, c, {}, g.polyline);
  13489. h && d.push(h)
  13490. }
  13491. return d
  13492. },
  13493. clearTilemapLayerBodies: function(a, b) {
  13494. b = a.getLayer(b);
  13495. for (var c = a.layers[b].bodies.length; c--;) a.layers[b].bodies[c].destroy();
  13496. a.layers[b].bodies.length = 0
  13497. },
  13498. convertTilemap: function(a, b, c, d) {
  13499. b = a.getLayer(b), "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !0), this.clearTilemapLayerBodies(a, b);
  13500. for (var e = 0, f = 0, g = 0, h = 0, i = a.layers[b].height; i > h; h++) {
  13501. e = 0;
  13502. for (var j = 0, k = a.layers[b].width; k > j; j++) {
  13503. var l = a.layers[b].data[h][j];
  13504. if (l && l.index > -1 && l.collides)
  13505. if (d) {
  13506. var m = a.getTileRight(b, j, h);
  13507. if (0 === e && (f = l.x * l.width, g = l.y * l.height, e = l.width), m && m.collides) e += l.width;
  13508. else {
  13509. var n = this.createBody(f, g, 0, !1);
  13510. n.addRectangle(e, l.height, e / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n), e = 0
  13511. }
  13512. } else {
  13513. var n = this.createBody(l.x * l.width, l.y * l.height, 0, !1);
  13514. n.addRectangle(l.width, l.height, l.width / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n)
  13515. }
  13516. }
  13517. }
  13518. return a.layers[b].bodies
  13519. },
  13520. mpx: function(a) {
  13521. return a *= 20
  13522. },
  13523. pxm: function(a) {
  13524. return .05 * a
  13525. },
  13526. mpxi: function(a) {
  13527. return a *= -20
  13528. },
  13529. pxmi: function(a) {
  13530. return a * -.05
  13531. }
  13532. }, Object.defineProperty(c.Physics.P2.prototype, "friction", {
  13533. get: function() {
  13534. return this.world.defaultContactMaterial.friction
  13535. },
  13536. set: function(a) {
  13537. this.world.defaultContactMaterial.friction = a
  13538. }
  13539. }), Object.defineProperty(c.Physics.P2.prototype, "restitution", {
  13540. get: function() {
  13541. return this.world.defaultContactMaterial.restitution
  13542. },
  13543. set: function(a) {
  13544. this.world.defaultContactMaterial.restitution = a
  13545. }
  13546. }), Object.defineProperty(c.Physics.P2.prototype, "contactMaterial", {
  13547. get: function() {
  13548. return this.world.defaultContactMaterial
  13549. },
  13550. set: function(a) {
  13551. this.world.defaultContactMaterial = a
  13552. }
  13553. }), Object.defineProperty(c.Physics.P2.prototype, "applySpringForces", {
  13554. get: function() {
  13555. return this.world.applySpringForces
  13556. },
  13557. set: function(a) {
  13558. this.world.applySpringForces = a
  13559. }
  13560. }), Object.defineProperty(c.Physics.P2.prototype, "applyDamping", {
  13561. get: function() {
  13562. return this.world.applyDamping
  13563. },
  13564. set: function(a) {
  13565. this.world.applyDamping = a
  13566. }
  13567. }), Object.defineProperty(c.Physics.P2.prototype, "applyGravity", {
  13568. get: function() {
  13569. return this.world.applyGravity
  13570. },
  13571. set: function(a) {
  13572. this.world.applyGravity = a
  13573. }
  13574. }), Object.defineProperty(c.Physics.P2.prototype, "solveConstraints", {
  13575. get: function() {
  13576. return this.world.solveConstraints
  13577. },
  13578. set: function(a) {
  13579. this.world.solveConstraints = a
  13580. }
  13581. }), Object.defineProperty(c.Physics.P2.prototype, "time", {
  13582. get: function() {
  13583. return this.world.time
  13584. }
  13585. }), Object.defineProperty(c.Physics.P2.prototype, "emitImpactEvent", {
  13586. get: function() {
  13587. return this.world.emitImpactEvent
  13588. },
  13589. set: function(a) {
  13590. this.world.emitImpactEvent = a
  13591. }
  13592. }), Object.defineProperty(c.Physics.P2.prototype, "sleepMode", {
  13593. get: function() {
  13594. return this.world.sleepMode
  13595. },
  13596. set: function(a) {
  13597. this.world.sleepMode = a
  13598. }
  13599. }), Object.defineProperty(c.Physics.P2.prototype, "total", {
  13600. get: function() {
  13601. return this.world.bodies.length
  13602. }
  13603. }), c.Physics.P2.FixtureList = function(a) {
  13604. Array.isArray(a) || (a = [a]), this.rawList = a, this.init(), this.parse(this.rawList)
  13605. }, c.Physics.P2.FixtureList.prototype = {
  13606. init: function() {
  13607. this.namedFixtures = {}, this.groupedFixtures = [], this.allFixtures = []
  13608. },
  13609. setCategory: function(a, b) {
  13610. var c = function(b) {
  13611. b.collisionGroup = a
  13612. };
  13613. this.getFixtures(b).forEach(c)
  13614. },
  13615. setMask: function(a, b) {
  13616. var c = function(b) {
  13617. b.collisionMask = a
  13618. };
  13619. this.getFixtures(b).forEach(c)
  13620. },
  13621. setSensor: function(a, b) {
  13622. var c = function(b) {
  13623. b.sensor = a
  13624. };
  13625. this.getFixtures(b).forEach(c)
  13626. },
  13627. setMaterial: function(a, b) {
  13628. var c = function(b) {
  13629. b.material = a
  13630. };
  13631. this.getFixtures(b).forEach(c)
  13632. },
  13633. getFixtures: function(a) {
  13634. var b = [];
  13635. if (a) {
  13636. a instanceof Array || (a = [a]);
  13637. var c = this;
  13638. return a.forEach(function(a) {
  13639. c.namedFixtures[a] && b.push(c.namedFixtures[a])
  13640. }), this.flatten(b)
  13641. }
  13642. return this.allFixtures
  13643. },
  13644. getFixtureByKey: function(a) {
  13645. return this.namedFixtures[a]
  13646. },
  13647. getGroup: function(a) {
  13648. return this.groupedFixtures[a]
  13649. },
  13650. parse: function() {
  13651. var a, b, c, d;
  13652. c = this.rawList, d = [];
  13653. 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))
  13654. },
  13655. flatten: function(a) {
  13656. var b, c;
  13657. return b = [], c = arguments.callee, a.forEach(function(a) {
  13658. return Array.prototype.push.apply(b, Array.isArray(a) ? c(a) : [a])
  13659. }), b
  13660. }
  13661. }, c.Physics.P2.PointProxy = function(a, b) {
  13662. this.world = a, this.destination = b
  13663. }, c.Physics.P2.PointProxy.prototype.constructor = c.Physics.P2.PointProxy, Object.defineProperty(c.Physics.P2.PointProxy.prototype, "x", {
  13664. get: function() {
  13665. return this.world.mpx(this.destination[0])
  13666. },
  13667. set: function(a) {
  13668. this.destination[0] = this.world.pxm(a)
  13669. }
  13670. }), Object.defineProperty(c.Physics.P2.PointProxy.prototype, "y", {
  13671. get: function() {
  13672. return this.world.mpx(this.destination[1])
  13673. },
  13674. set: function(a) {
  13675. this.destination[1] = this.world.pxm(a)
  13676. }
  13677. }), Object.defineProperty(c.Physics.P2.PointProxy.prototype, "mx", {
  13678. get: function() {
  13679. return this.destination[0]
  13680. },
  13681. set: function(a) {
  13682. this.destination[0] = a
  13683. }
  13684. }), Object.defineProperty(c.Physics.P2.PointProxy.prototype, "my", {
  13685. get: function() {
  13686. return this.destination[1]
  13687. },
  13688. set: function(a) {
  13689. this.destination[1] = a
  13690. }
  13691. }), c.Physics.P2.InversePointProxy = function(a, b) {
  13692. this.world = a, this.destination = b
  13693. }, c.Physics.P2.InversePointProxy.prototype.constructor = c.Physics.P2.InversePointProxy, Object.defineProperty(c.Physics.P2.InversePointProxy.prototype, "x", {
  13694. get: function() {
  13695. return this.world.mpxi(this.destination[0])
  13696. },
  13697. set: function(a) {
  13698. this.destination[0] = this.world.pxmi(a)
  13699. }
  13700. }), Object.defineProperty(c.Physics.P2.InversePointProxy.prototype, "y", {
  13701. get: function() {
  13702. return this.world.mpxi(this.destination[1])
  13703. },
  13704. set: function(a) {
  13705. this.destination[1] = this.world.pxmi(a)
  13706. }
  13707. }), Object.defineProperty(c.Physics.P2.InversePointProxy.prototype, "mx", {
  13708. get: function() {
  13709. return this.destination[0]
  13710. },
  13711. set: function(a) {
  13712. this.destination[0] = -a
  13713. }
  13714. }), Object.defineProperty(c.Physics.P2.InversePointProxy.prototype, "my", {
  13715. get: function() {
  13716. return this.destination[1]
  13717. },
  13718. set: function(a) {
  13719. this.destination[1] = -a
  13720. }
  13721. }), c.Physics.P2.Body = function(a, b, d, e, f) {
  13722. b = b || null, d = d || 0, e = e || 0, "undefined" == typeof f && (f = 1), this.game = a, this.world = a.physics.p2, this.sprite = b, this.type = c.Physics.P2JS, this.offset = new c.Point, this.data = new p2.Body({
  13723. position: [this.world.pxmi(d), this.world.pxmi(e)],
  13724. mass: f
  13725. }), this.data.parent = this, this.velocity = new c.Physics.P2.InversePointProxy(this.world, this.data.velocity), this.force = new c.Physics.P2.InversePointProxy(this.world, this.data.force), this.gravity = new c.Point, this.onBeginContact = new c.Signal, this.onEndContact = new c.Signal, this.collidesWith = [], this.removeNextStep = !1, this.debugBody = null, this.dirty = !1, this._collideWorldBounds = !0, this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this._reset = !1, b && (this.setRectangleFromSprite(b), b.exists && this.game.physics.p2.addBody(this))
  13726. }, c.Physics.P2.Body.prototype = {
  13727. createBodyCallback: function(a, b, c) {
  13728. var d = -1;
  13729. 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))
  13730. },
  13731. createGroupCallback: function(a, b, c) {
  13732. null === b ? (delete this._groupCallbacks[a.mask], delete this._groupCallbacksContext[a.mask]) : (this._groupCallbacks[a.mask] = b, this._groupCallbackContext[a.mask] = c)
  13733. },
  13734. getCollisionMask: function() {
  13735. var a = 0;
  13736. this._collideWorldBounds && (a = this.game.physics.p2.boundsCollisionGroup.mask);
  13737. for (var b = 0; b < this.collidesWith.length; b++) a |= this.collidesWith[b].mask;
  13738. return a
  13739. },
  13740. updateCollisionMask: function(a) {
  13741. var b = this.getCollisionMask();
  13742. if ("undefined" == typeof a)
  13743. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].collisionMask = b;
  13744. else a.collisionMask = b
  13745. },
  13746. setCollisionGroup: function(a, b) {
  13747. var c = this.getCollisionMask();
  13748. if ("undefined" == typeof b)
  13749. for (var d = this.data.shapes.length - 1; d >= 0; d--) this.data.shapes[d].collisionGroup = a.mask, this.data.shapes[d].collisionMask = c;
  13750. else b.collisionGroup = a.mask, b.collisionMask = c
  13751. },
  13752. clearCollision: function(a, b, c) {
  13753. if ("undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), "undefined" == typeof c)
  13754. 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);
  13755. else a && (c.collisionGroup = null), b && (c.collisionMask = null);
  13756. a && (this.collidesWith.length = 0)
  13757. },
  13758. collides: function(a, b, c, d) {
  13759. if (Array.isArray(a))
  13760. 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));
  13761. else -1 === this.collidesWith.indexOf(a) && (this.collidesWith.push(a), b && this.createGroupCallback(a, b, c));
  13762. var f = this.getCollisionMask();
  13763. if ("undefined" == typeof d)
  13764. for (var e = this.data.shapes.length - 1; e >= 0; e--) this.data.shapes[e].collisionMask = f;
  13765. else d.collisionMask = f
  13766. },
  13767. adjustCenterOfMass: function() {
  13768. this.data.adjustCenterOfMass(), this.shapeChanged()
  13769. },
  13770. applyDamping: function(a) {
  13771. this.data.applyDamping(a)
  13772. },
  13773. applyForce: function(a, b, c) {
  13774. this.data.applyForce(a, [this.world.pxmi(b), this.world.pxmi(c)])
  13775. },
  13776. setZeroForce: function() {
  13777. this.data.setZeroForce()
  13778. },
  13779. setZeroRotation: function() {
  13780. this.data.angularVelocity = 0
  13781. },
  13782. setZeroVelocity: function() {
  13783. this.data.velocity[0] = 0, this.data.velocity[1] = 0
  13784. },
  13785. setZeroDamping: function() {
  13786. this.data.damping = 0, this.data.angularDamping = 0
  13787. },
  13788. toLocalFrame: function(a, b) {
  13789. return this.data.toLocalFrame(a, b)
  13790. },
  13791. toWorldFrame: function(a, b) {
  13792. return this.data.toWorldFrame(a, b)
  13793. },
  13794. rotateLeft: function(a) {
  13795. this.data.angularVelocity = this.world.pxm(-a)
  13796. },
  13797. rotateRight: function(a) {
  13798. this.data.angularVelocity = this.world.pxm(a)
  13799. },
  13800. moveForward: function(a) {
  13801. var b = this.world.pxmi(-a),
  13802. c = this.data.angle + Math.PI / 2;
  13803. this.data.velocity[0] = b * Math.cos(c), this.data.velocity[1] = b * Math.sin(c)
  13804. },
  13805. moveBackward: function(a) {
  13806. var b = this.world.pxmi(-a),
  13807. c = this.data.angle + Math.PI / 2;
  13808. this.data.velocity[0] = -(b * Math.cos(c)), this.data.velocity[1] = -(b * Math.sin(c))
  13809. },
  13810. thrust: function(a) {
  13811. var b = this.world.pxmi(-a),
  13812. c = this.data.angle + Math.PI / 2;
  13813. this.data.force[0] += b * Math.cos(c), this.data.force[1] += b * Math.sin(c)
  13814. },
  13815. reverse: function(a) {
  13816. var b = this.world.pxmi(-a),
  13817. c = this.data.angle + Math.PI / 2;
  13818. this.data.force[0] -= b * Math.cos(c), this.data.force[1] -= b * Math.sin(c)
  13819. },
  13820. moveLeft: function(a) {
  13821. this.data.velocity[0] = this.world.pxmi(-a)
  13822. },
  13823. moveRight: function(a) {
  13824. this.data.velocity[0] = this.world.pxmi(a)
  13825. },
  13826. moveUp: function(a) {
  13827. this.data.velocity[1] = this.world.pxmi(-a)
  13828. },
  13829. moveDown: function(a) {
  13830. this.data.velocity[1] = this.world.pxmi(a)
  13831. },
  13832. preUpdate: function() {
  13833. this.dirty = !0, this.removeNextStep && (this.removeFromWorld(), this.removeNextStep = !1)
  13834. },
  13835. postUpdate: function() {
  13836. 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), this.debugBody && this.debugBody.updateSpriteTransform(), this.dirty = !1
  13837. },
  13838. reset: function(a, b, c, d) {
  13839. "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
  13840. },
  13841. addToWorld: function() {
  13842. if (this.game.physics.p2._toRemove)
  13843. 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);
  13844. this.data.world !== this.game.physics.p2.world && this.game.physics.p2.addBody(this)
  13845. },
  13846. removeFromWorld: function() {
  13847. this.data.world === this.game.physics.p2.world && this.game.physics.p2.removeBodyNextStep(this)
  13848. },
  13849. destroy: function() {
  13850. this.removeFromWorld(), this.clearShapes(), this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this.debugBody && this.debugBody.destroy(!0, !0), this.debugBody = null, this.sprite.body = null, this.sprite = null
  13851. },
  13852. clearShapes: function() {
  13853. for (var a = this.data.shapes.length; a--;) this.data.removeShape(this.data.shapes[a]);
  13854. this.shapeChanged()
  13855. },
  13856. addShape: function(a, b, c, d) {
  13857. 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
  13858. },
  13859. addCircle: function(a, b, c, d) {
  13860. var e = new p2.Circle(this.world.pxm(a));
  13861. return this.addShape(e, b, c, d)
  13862. },
  13863. addRectangle: function(a, b, c, d, e) {
  13864. var f = new p2.Rectangle(this.world.pxm(a), this.world.pxm(b));
  13865. return this.addShape(f, c, d, e)
  13866. },
  13867. addPlane: function(a, b, c) {
  13868. var d = new p2.Plane;
  13869. return this.addShape(d, a, b, c)
  13870. },
  13871. addParticle: function(a, b, c) {
  13872. var d = new p2.Particle;
  13873. return this.addShape(d, a, b, c)
  13874. },
  13875. addLine: function(a, b, c, d) {
  13876. var e = new p2.Line(this.world.pxm(a));
  13877. return this.addShape(e, b, c, d)
  13878. },
  13879. addCapsule: function(a, b, c, d, e) {
  13880. var f = new p2.Capsule(this.world.pxm(a), this.world.pxm(b));
  13881. return this.addShape(f, c, d, e)
  13882. },
  13883. addPolygon: function(a, b) {
  13884. a = a || {}, Array.isArray(b) || (b = Array.prototype.slice.call(arguments, 1));
  13885. var c = [];
  13886. if (1 === b.length && Array.isArray(b[0])) c = b[0].slice(0);
  13887. else if (Array.isArray(b[0])) c = b.slice();
  13888. else if ("number" == typeof b[0])
  13889. for (var d = 0, e = b.length; e > d; d += 2) c.push([b[d], b[d + 1]]);
  13890. var f = c.length - 1;
  13891. c[f][0] === c[0][0] && c[f][1] === c[0][1] && c.pop();
  13892. 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]);
  13893. var h = this.data.fromPolygon(c, a);
  13894. return this.shapeChanged(), h
  13895. },
  13896. removeShape: function(a) {
  13897. var b = this.data.removeShape(a);
  13898. return this.shapeChanged(), b
  13899. },
  13900. setCircle: function(a, b, c, d) {
  13901. return this.clearShapes(), this.addCircle(a, b, c, d)
  13902. },
  13903. setRectangle: function(a, b, c, d, e) {
  13904. return "undefined" == typeof a && (a = 16), "undefined" == typeof b && (b = 16), this.clearShapes(), this.addRectangle(a, b, c, d, e)
  13905. },
  13906. setRectangleFromSprite: function(a) {
  13907. return "undefined" == typeof a && (a = this.sprite), this.clearShapes(), this.addRectangle(a.width, a.height, 0, 0, a.rotation)
  13908. },
  13909. setMaterial: function(a, b) {
  13910. if ("undefined" == typeof b)
  13911. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].material = a;
  13912. else b.material = a
  13913. },
  13914. shapeChanged: function() {
  13915. this.debugBody && this.debugBody.draw()
  13916. },
  13917. addPhaserPolygon: function(a, b) {
  13918. for (var c = this.game.cache.getPhysicsData(a, b), d = [], e = 0; e < c.length; e++) {
  13919. var f = c[e],
  13920. g = this.addFixture(f);
  13921. d[f.filter.group] = d[f.filter.group] || [], d[f.filter.group] = d[f.filter.group].concat(g), f.fixtureKey && (d[f.fixtureKey] = g)
  13922. }
  13923. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), d
  13924. },
  13925. addFixture: function(a) {
  13926. var b = [];
  13927. if (a.circle) {
  13928. var c = new p2.Circle(this.world.pxm(a.circle.radius));
  13929. c.collisionGroup = a.filter.categoryBits, c.collisionMask = a.filter.maskBits, c.sensor = a.isSensor;
  13930. var d = p2.vec2.create();
  13931. 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)
  13932. } else
  13933. for (var e = a.polygons, f = p2.vec2.create(), g = 0; g < e.length; g++) {
  13934. 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])]);
  13935. for (var c = new p2.Convex(i), k = 0; k !== c.vertices.length; k++) {
  13936. var l = c.vertices[k];
  13937. p2.vec2.sub(l, l, c.centerOfMass)
  13938. }
  13939. 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)
  13940. }
  13941. return b
  13942. },
  13943. loadPolygon: function(a, b) {
  13944. for (var c = this.game.cache.getPhysicsData(a, b), d = p2.vec2.create(), e = 0; e < c.length; e++) {
  13945. 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])]);
  13946. for (var h = new p2.Convex(f), i = 0; i !== h.vertices.length; i++) {
  13947. var j = h.vertices[i];
  13948. p2.vec2.sub(j, j, h.centerOfMass)
  13949. }
  13950. 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)
  13951. }
  13952. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), !0
  13953. }
  13954. }, c.Physics.P2.Body.prototype.constructor = c.Physics.P2.Body, c.Physics.P2.Body.DYNAMIC = 1, c.Physics.P2.Body.STATIC = 2, c.Physics.P2.Body.KINEMATIC = 4, Object.defineProperty(c.Physics.P2.Body.prototype, "static", {
  13955. get: function() {
  13956. return this.data.type === c.Physics.P2.Body.STATIC
  13957. },
  13958. set: function(a) {
  13959. a && this.data.type !== c.Physics.P2.Body.STATIC ? (this.data.type = c.Physics.P2.Body.STATIC, this.mass = 0) : a || this.data.type !== c.Physics.P2.Body.STATIC || (this.data.type = c.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1))
  13960. }
  13961. }), Object.defineProperty(c.Physics.P2.Body.prototype, "dynamic", {
  13962. get: function() {
  13963. return this.data.type === c.Physics.P2.Body.DYNAMIC
  13964. },
  13965. set: function(a) {
  13966. a && this.data.type !== c.Physics.P2.Body.DYNAMIC ? (this.data.type = c.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1)) : a || this.data.type !== c.Physics.P2.Body.DYNAMIC || (this.data.type = c.Physics.P2.Body.STATIC, this.mass = 0)
  13967. }
  13968. }), Object.defineProperty(c.Physics.P2.Body.prototype, "kinematic", {
  13969. get: function() {
  13970. return this.data.type === c.Physics.P2.Body.KINEMATIC
  13971. },
  13972. set: function(a) {
  13973. a && this.data.type !== c.Physics.P2.Body.KINEMATIC ? (this.data.type = c.Physics.P2.Body.KINEMATIC, this.mass = 4) : a || this.data.type !== c.Physics.P2.Body.KINEMATIC || (this.data.type = c.Physics.P2.Body.STATIC, this.mass = 0)
  13974. }
  13975. }), Object.defineProperty(c.Physics.P2.Body.prototype, "allowSleep", {
  13976. get: function() {
  13977. return this.data.allowSleep
  13978. },
  13979. set: function(a) {
  13980. a !== this.data.allowSleep && (this.data.allowSleep = a)
  13981. }
  13982. }), Object.defineProperty(c.Physics.P2.Body.prototype, "angle", {
  13983. get: function() {
  13984. return c.Math.wrapAngle(c.Math.radToDeg(this.data.angle))
  13985. },
  13986. set: function(a) {
  13987. this.data.angle = c.Math.degToRad(c.Math.wrapAngle(a))
  13988. }
  13989. }), Object.defineProperty(c.Physics.P2.Body.prototype, "angularDamping", {
  13990. get: function() {
  13991. return this.data.angularDamping
  13992. },
  13993. set: function(a) {
  13994. this.data.angularDamping = a
  13995. }
  13996. }), Object.defineProperty(c.Physics.P2.Body.prototype, "angularForce", {
  13997. get: function() {
  13998. return this.data.angularForce
  13999. },
  14000. set: function(a) {
  14001. this.data.angularForce = a
  14002. }
  14003. }), Object.defineProperty(c.Physics.P2.Body.prototype, "angularVelocity", {
  14004. get: function() {
  14005. return this.data.angularVelocity
  14006. },
  14007. set: function(a) {
  14008. this.data.angularVelocity = a
  14009. }
  14010. }), Object.defineProperty(c.Physics.P2.Body.prototype, "damping", {
  14011. get: function() {
  14012. return this.data.damping
  14013. },
  14014. set: function(a) {
  14015. this.data.damping = a
  14016. }
  14017. }), Object.defineProperty(c.Physics.P2.Body.prototype, "fixedRotation", {
  14018. get: function() {
  14019. return this.data.fixedRotation
  14020. },
  14021. set: function(a) {
  14022. a !== this.data.fixedRotation && (this.data.fixedRotation = a)
  14023. }
  14024. }), Object.defineProperty(c.Physics.P2.Body.prototype, "inertia", {
  14025. get: function() {
  14026. return this.data.inertia
  14027. },
  14028. set: function(a) {
  14029. this.data.inertia = a
  14030. }
  14031. }), Object.defineProperty(c.Physics.P2.Body.prototype, "mass", {
  14032. get: function() {
  14033. return this.data.mass
  14034. },
  14035. set: function(a) {
  14036. a !== this.data.mass && (this.data.mass = a, this.data.updateMassProperties())
  14037. }
  14038. }), Object.defineProperty(c.Physics.P2.Body.prototype, "motionState", {
  14039. get: function() {
  14040. return this.data.type
  14041. },
  14042. set: function(a) {
  14043. a !== this.data.type && (this.data.type = a)
  14044. }
  14045. }), Object.defineProperty(c.Physics.P2.Body.prototype, "rotation", {
  14046. get: function() {
  14047. return this.data.angle
  14048. },
  14049. set: function(a) {
  14050. this.data.angle = a
  14051. }
  14052. }), Object.defineProperty(c.Physics.P2.Body.prototype, "sleepSpeedLimit", {
  14053. get: function() {
  14054. return this.data.sleepSpeedLimit
  14055. },
  14056. set: function(a) {
  14057. this.data.sleepSpeedLimit = a
  14058. }
  14059. }), Object.defineProperty(c.Physics.P2.Body.prototype, "x", {
  14060. get: function() {
  14061. return this.world.mpxi(this.data.position[0])
  14062. },
  14063. set: function(a) {
  14064. this.data.position[0] = this.world.pxmi(a)
  14065. }
  14066. }), Object.defineProperty(c.Physics.P2.Body.prototype, "y", {
  14067. get: function() {
  14068. return this.world.mpxi(this.data.position[1])
  14069. },
  14070. set: function(a) {
  14071. this.data.position[1] = this.world.pxmi(a)
  14072. }
  14073. }), Object.defineProperty(c.Physics.P2.Body.prototype, "id", {
  14074. get: function() {
  14075. return this.data.id
  14076. }
  14077. }), Object.defineProperty(c.Physics.P2.Body.prototype, "debug", {
  14078. get: function() {
  14079. return null !== this.debugBody
  14080. },
  14081. set: function(a) {
  14082. a && !this.debugBody ? this.debugBody = new c.Physics.P2.BodyDebug(this.game, this.data) : !a && this.debugBody && (this.debugBody.destroy(), this.debugBody = null)
  14083. }
  14084. }), Object.defineProperty(c.Physics.P2.Body.prototype, "collideWorldBounds", {
  14085. get: function() {
  14086. return this._collideWorldBounds
  14087. },
  14088. set: function(a) {
  14089. a && !this._collideWorldBounds ? (this._collideWorldBounds = !0, this.updateCollisionMask()) : !a && this._collideWorldBounds && (this._collideWorldBounds = !1, this.updateCollisionMask())
  14090. }
  14091. }), c.Physics.P2.BodyDebug = function(a, b, d) {
  14092. c.Group.call(this, a);
  14093. var e = {
  14094. pixelsPerLengthUnit: 20,
  14095. debugPolygons: !1,
  14096. lineWidth: 1,
  14097. alpha: .5
  14098. };
  14099. this.settings = c.Utils.extend(e, d), this.ppu = this.settings.pixelsPerLengthUnit, this.ppu = -1 * this.ppu, this.body = b, this.canvas = new c.Graphics(a), this.canvas.alpha = this.settings.alpha, this.add(this.canvas), this.draw(), this.updateSpriteTransform()
  14100. }, c.Physics.P2.BodyDebug.prototype = Object.create(c.Group.prototype), c.Physics.P2.BodyDebug.prototype.constructor = c.Physics.P2.BodyDebug, c.Utils.extend(c.Physics.P2.BodyDebug.prototype, {
  14101. updateSpriteTransform: function() {
  14102. this.position.x = this.body.position[0] * this.ppu, this.position.y = this.body.position[1] * this.ppu, this.rotation = this.body.angle
  14103. },
  14104. draw: function() {
  14105. var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o;
  14106. 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) {
  14107. var p = h.shapes.length;
  14108. for (d = 0; d !== p;) {
  14109. 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);
  14110. else if (b instanceof p2.Capsule) this.drawCapsule(j, i[0] * this.ppu, i[1] * this.ppu, a, b.length * this.ppu, b.radius * this.ppu, f, c, g);
  14111. else if (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);
  14112. else if (b instanceof p2.Line) this.drawLine(j, b.length * this.ppu, f, g);
  14113. else if (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);
  14114. else if (b instanceof p2.Convex) {
  14115. 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]);
  14116. this.drawConvex(j, l, b.triangles, f, c, g, this.settings.debugPolygons, [i[0] * this.ppu, -i[1] * this.ppu])
  14117. }
  14118. d++
  14119. }
  14120. }
  14121. },
  14122. drawRectangle: function(a, b, c, d, e, f, g, h, i) {
  14123. "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)
  14124. },
  14125. drawCircle: function(a, b, c, d, e, f, g) {
  14126. "undefined" == typeof g && (g = 1), "undefined" == typeof f && (f = 16777215), a.lineStyle(g, 0, 1), a.beginFill(f, 1), a.drawCircle(b, c, 2 * -e), a.endFill(), a.moveTo(b, c), a.lineTo(b + e * Math.cos(-d), c + e * Math.sin(-d))
  14127. },
  14128. drawLine: function(a, b, c, d) {
  14129. "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)
  14130. },
  14131. drawConvex: function(a, b, c, d, e, f, g, h) {
  14132. var i, j, k, l, m, n, o, p, q, r, s;
  14133. if ("undefined" == typeof f && (f = 1), "undefined" == typeof d && (d = 0), g) {
  14134. 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++;
  14135. return a.lineStyle(f, 0, 1), a.drawCircle(h[0], h[1], 2 * f)
  14136. }
  14137. 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++;
  14138. 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
  14139. },
  14140. drawPath: function(a, b, c, d, e) {
  14141. var f, g, h, i, j, k, l, m, n, o, p, q, r;
  14142. 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++;
  14143. "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]))
  14144. },
  14145. drawPlane: function(a, b, c, d, e, f, g, h, i, j) {
  14146. var k, l, m;
  14147. "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)
  14148. },
  14149. drawCapsule: function(a, b, c, d, e, f, g, h, i) {
  14150. "undefined" == typeof i && (i = 1), "undefined" == typeof g && (g = 0), a.lineStyle(i, g, 1);
  14151. var j = Math.cos(d),
  14152. k = Math.sin(d);
  14153. a.beginFill(h, 1), a.drawCircle(-e / 2 * j + b, -e / 2 * k + c, 2 * -f), a.drawCircle(e / 2 * j + b, e / 2 * k + c, 2 * -f), a.endFill(), a.lineStyle(i, g, 0), a.beginFill(h, 1), a.moveTo(-e / 2 * j + f * k + b, -e / 2 * k + f * j + c), a.lineTo(e / 2 * j + f * k + b, e / 2 * k + f * j + c), a.lineTo(e / 2 * j - f * k + b, e / 2 * k - f * j + c), a.lineTo(-e / 2 * j - f * k + b, -e / 2 * k - f * j + c), a.endFill(), a.lineStyle(i, g, 1), a.moveTo(-e / 2 * j + f * k + b, -e / 2 * k + f * j + c), a.lineTo(e / 2 * j + f * k + b, e / 2 * k + f * j + c), a.moveTo(-e / 2 * j - f * k + b, -e / 2 * k - f * j + c), a.lineTo(e / 2 * j - f * k + b, e / 2 * k - f * j + c)
  14154. },
  14155. randomPastelHex: function() {
  14156. var a, b, c, d;
  14157. 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)
  14158. },
  14159. rgbToHex: function(a, b, c) {
  14160. return this.componentToHex(a) + this.componentToHex(b) + this.componentToHex(c)
  14161. },
  14162. componentToHex: function(a) {
  14163. var b;
  14164. return b = a.toString(16), 2 === b.len ? b : b + "0"
  14165. }
  14166. }), c.Physics.P2.Spring = function(a, b, c, d, e, f, g, h, i, j) {
  14167. 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);
  14168. var k = {
  14169. restLength: d,
  14170. stiffness: e,
  14171. damping: f
  14172. };
  14173. "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])]), this.data = new p2.LinearSpring(b, c, k), this.data.parent = this
  14174. }, c.Physics.P2.Spring.prototype.constructor = c.Physics.P2.Spring, c.Physics.P2.RotationalSpring = function(a, b, c, d, e, f) {
  14175. this.game = a.game, this.world = a, "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = 100), "undefined" == typeof f && (f = 1), d && (d = a.pxm(d));
  14176. var g = {
  14177. restAngle: d,
  14178. stiffness: e,
  14179. damping: f
  14180. };
  14181. this.data = new p2.RotationalSpring(b, c, g), this.data.parent = this
  14182. }, c.Physics.P2.Spring.prototype.constructor = c.Physics.P2.Spring, c.Physics.P2.Material = function(a) {
  14183. this.name = a, p2.Material.call(this)
  14184. }, c.Physics.P2.Material.prototype = Object.create(p2.Material.prototype), c.Physics.P2.Material.prototype.constructor = c.Physics.P2.Material, c.Physics.P2.ContactMaterial = function(a, b, c) {
  14185. p2.ContactMaterial.call(this, a, b, c)
  14186. }, c.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype), c.Physics.P2.ContactMaterial.prototype.constructor = c.Physics.P2.ContactMaterial, c.Physics.P2.CollisionGroup = function(a) {
  14187. this.mask = a
  14188. }, c.Physics.P2.DistanceConstraint = function(a, b, c, d, e, f, g) {
  14189. "undefined" == typeof d && (d = 100), "undefined" == typeof e && (e = [0, 0]), "undefined" == typeof f && (f = [0, 0]), "undefined" == typeof g && (g = Number.MAX_VALUE), this.game = a.game, this.world = a, d = a.pxm(d), e = [a.pxmi(e[0]), a.pxmi(e[1])], f = [a.pxmi(f[0]), a.pxmi(f[1])];
  14190. var h = {
  14191. distance: d,
  14192. localAnchorA: e,
  14193. localAnchorB: f,
  14194. maxForce: g
  14195. };
  14196. p2.DistanceConstraint.call(this, b, c, h)
  14197. }, c.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype), c.Physics.P2.DistanceConstraint.prototype.constructor = c.Physics.P2.DistanceConstraint, c.Physics.P2.GearConstraint = function(a, b, c, d, e) {
  14198. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 1), this.game = a.game, this.world = a;
  14199. var f = {
  14200. angle: d,
  14201. ratio: e
  14202. };
  14203. p2.GearConstraint.call(this, b, c, f)
  14204. }, c.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype), c.Physics.P2.GearConstraint.prototype.constructor = c.Physics.P2.GearConstraint, c.Physics.P2.LockConstraint = function(a, b, c, d, e, f) {
  14205. "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])];
  14206. var g = {
  14207. localOffsetB: d,
  14208. localAngleB: e,
  14209. maxForce: f
  14210. };
  14211. p2.LockConstraint.call(this, b, c, g)
  14212. }, c.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype), c.Physics.P2.LockConstraint.prototype.constructor = c.Physics.P2.LockConstraint, c.Physics.P2.PrismaticConstraint = function(a, b, c, d, e, f, g, h) {
  14213. "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])];
  14214. var i = {
  14215. localAnchorA: e,
  14216. localAnchorB: f,
  14217. localAxisA: g,
  14218. maxForce: h,
  14219. disableRotationalLock: !d
  14220. };
  14221. p2.PrismaticConstraint.call(this, b, c, i)
  14222. }, c.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype), c.Physics.P2.PrismaticConstraint.prototype.constructor = c.Physics.P2.PrismaticConstraint, c.Physics.P2.RevoluteConstraint = function(a, b, c, d, e, f, g) {
  14223. "undefined" == typeof f && (f = Number.MAX_VALUE), "undefined" == typeof g && (g = null), 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])], g && (g = [a.pxmi(g[0]), a.pxmi(g[1])]);
  14224. var h = {
  14225. worldPivot: g,
  14226. localPivotA: c,
  14227. localPivotB: e,
  14228. maxForce: f
  14229. };
  14230. p2.RevoluteConstraint.call(this, b, d, h)
  14231. }, c.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype), c.Physics.P2.RevoluteConstraint.prototype.constructor = c.Physics.P2.RevoluteConstraint, c.Tile = function(a, b, c, d, e, f) {
  14232. this.layer = a, this.index = b, this.x = c, this.y = d, this.rotation = 0, this.flipped = !1, 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
  14233. }, c.Tile.prototype = {
  14234. containsPoint: function(a, b) {
  14235. return !(a < this.worldX || b < this.worldY || a > this.right || b > this.bottom)
  14236. },
  14237. intersects: function(a, b, c, d) {
  14238. return c <= this.worldX ? !1 : d <= this.worldY ? !1 : a >= this.worldX + this.width ? !1 : b >= this.worldY + this.height ? !1 : !0
  14239. },
  14240. setCollisionCallback: function(a, b) {
  14241. this.collisionCallback = a, this.collisionCallbackContext = b
  14242. },
  14243. destroy: function() {
  14244. this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null
  14245. },
  14246. setCollision: function(a, b, c, d) {
  14247. this.collideLeft = a, this.collideRight = b, this.collideUp = c, this.collideDown = d, this.faceLeft = a, this.faceRight = b, this.faceTop = c, this.faceBottom = d
  14248. },
  14249. resetCollision: function() {
  14250. this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1
  14251. },
  14252. isInteresting: function(a, b) {
  14253. 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
  14254. },
  14255. copy: function(a) {
  14256. 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
  14257. }
  14258. }, c.Tile.prototype.constructor = c.Tile, Object.defineProperty(c.Tile.prototype, "collides", {
  14259. get: function() {
  14260. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown
  14261. }
  14262. }), Object.defineProperty(c.Tile.prototype, "canCollide", {
  14263. get: function() {
  14264. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback
  14265. }
  14266. }), Object.defineProperty(c.Tile.prototype, "left", {
  14267. get: function() {
  14268. return this.worldX
  14269. }
  14270. }), Object.defineProperty(c.Tile.prototype, "right", {
  14271. get: function() {
  14272. return this.worldX + this.width
  14273. }
  14274. }), Object.defineProperty(c.Tile.prototype, "top", {
  14275. get: function() {
  14276. return this.worldY
  14277. }
  14278. }), Object.defineProperty(c.Tile.prototype, "bottom", {
  14279. get: function() {
  14280. return this.worldY + this.height
  14281. }
  14282. }), c.Tilemap = function(a, b, d, e, f, g) {
  14283. this.game = a, this.key = b;
  14284. var h = c.TilemapParser.parse(this.game, b, d, e, f, g);
  14285. 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)
  14286. }, c.Tilemap.CSV = 0, c.Tilemap.TILED_JSON = 1, c.Tilemap.NORTH = 0, c.Tilemap.EAST = 1, c.Tilemap.SOUTH = 2, c.Tilemap.WEST = 3, c.Tilemap.prototype = {
  14287. create: function(a, b, c, d, e, f) {
  14288. 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)
  14289. },
  14290. setTileSize: function(a, b) {
  14291. this.tileWidth = a, this.tileHeight = b, this.widthInPixels = this.width * a, this.heightInPixels = this.height * b
  14292. },
  14293. addTilesetImage: function(a, b, d, e, f, g, h) {
  14294. 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 b) {
  14295. if ("string" != typeof a) return null;
  14296. if (b = a, !this.game.cache.checkImageKey(b)) return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + b + '"'), null
  14297. }
  14298. if ("string" == typeof a && (a = this.getTilesetIndex(a), null === a && this.format === c.Tilemap.TILED_JSON)) return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + b + '"'), null;
  14299. if (this.tilesets[a]) return this.tilesets[a].setImage(this.game.cache.getImage(b)), this.tilesets[a];
  14300. var i = new c.Tileset(b, h, d, e, f, g, {});
  14301. i.setImage(this.game.cache.getImage(b)), this.tilesets.push(i);
  14302. 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++);
  14303. return i
  14304. },
  14305. createFromObjects: function(a, b, d, e, f, g, h, i, j) {
  14306. if ("undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = !1), "undefined" == typeof h && (h = this.game.world), "undefined" == typeof i && (i = c.Sprite), "undefined" == typeof j && (j = !0), !this.objects[a]) return void console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: " + a);
  14307. for (var k, l = 0, m = this.objects[a].length; m > l; l++)
  14308. if (this.objects[a][l].gid === b) {
  14309. 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, this.objects[a][l].rotation && (k.angle = this.objects[a][l].rotation), j && (k.y -= k.height), h.add(k);
  14310. for (var n in this.objects[a][l].properties) h.set(k, n, this.objects[a][l].properties[n], !1, !1, 0, !0)
  14311. }
  14312. },
  14313. createFromTiles: function(a, b, d, e, f, g) {
  14314. "number" == typeof a && (a = [a]), "undefined" == typeof b || null === b ? b = [] : "number" == typeof b && (b = [b]), e = this.getLayer(e), "undefined" == typeof f && (f = this.game.world), "undefined" == typeof g && (g = {}), void 0 === g.customClass && (g.customClass = c.Sprite), void 0 === g.adjustY && (g.adjustY = !0);
  14315. var h = this.layers[e].width,
  14316. i = this.layers[e].height;
  14317. if (this.copy(0, 0, h, i, e), this._results.length < 2) return 0;
  14318. for (var j, k = 0, l = 1, m = this._results.length; m > l; l++)
  14319. if (-1 !== a.indexOf(this._results[l].index)) {
  14320. j = new g.customClass(this.game, this._results[l].worldX, this._results[l].worldY, d);
  14321. for (var n in g) j[n] = g[n];
  14322. f.add(j), k++
  14323. }
  14324. if (1 === b.length)
  14325. for (l = 0; l < a.length; l++) this.replace(a[l], b[0], 0, 0, h, i, e);
  14326. else if (b.length > 1)
  14327. for (l = 0; l < a.length; l++) this.replace(a[l], b[l], 0, 0, h, i, e);
  14328. return k
  14329. },
  14330. createLayer: function(a, b, d, e) {
  14331. "undefined" == typeof b && (b = this.game.width), "undefined" == typeof d && (d = this.game.height), "undefined" == typeof e && (e = this.game.world);
  14332. var f = a;
  14333. 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 c.TilemapLayer(this.game, this, f, b, d))
  14334. },
  14335. createBlankLayer: function(a, b, d, e, f, g) {
  14336. if ("undefined" == typeof g && (g = this.game.world), null !== this.getLayerIndex(a)) return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists");
  14337. for (var h, i = {
  14338. name: a,
  14339. x: 0,
  14340. y: 0,
  14341. width: b,
  14342. height: d,
  14343. widthInPixels: b * e,
  14344. heightInPixels: d * f,
  14345. alpha: 1,
  14346. visible: !0,
  14347. properties: {},
  14348. indexes: [],
  14349. callbacks: [],
  14350. bodies: [],
  14351. data: null
  14352. }, j = [], k = 0; d > k; k++) {
  14353. h = [];
  14354. for (var l = 0; b > l; l++) h.push(new c.Tile(i, -1, l, k, e, f));
  14355. j.push(h)
  14356. }
  14357. i.data = j, this.layers.push(i), this.currentLayer = this.layers.length - 1;
  14358. var m = i.widthInPixels,
  14359. n = i.heightInPixels;
  14360. m > this.game.width && (m = this.game.width), n > this.game.height && (n = this.game.height);
  14361. var j = new c.TilemapLayer(this.game, this, this.layers.length - 1, m, n);
  14362. return j.name = a, g.add(j)
  14363. },
  14364. getIndex: function(a, b) {
  14365. for (var c = 0; c < a.length; c++)
  14366. if (a[c].name === b) return c;
  14367. return null
  14368. },
  14369. getLayerIndex: function(a) {
  14370. return this.getIndex(this.layers, a)
  14371. },
  14372. getTilesetIndex: function(a) {
  14373. return this.getIndex(this.tilesets, a)
  14374. },
  14375. getImageIndex: function(a) {
  14376. return this.getIndex(this.images, a)
  14377. },
  14378. getObjectIndex: function(a) {
  14379. return this.getIndex(this.objects, a)
  14380. },
  14381. setTileIndexCallback: function(a, b, c, d) {
  14382. if (d = this.getLayer(d), "number" == typeof a) this.layers[d].callbacks[a] = {
  14383. callback: b,
  14384. callbackContext: c
  14385. };
  14386. else
  14387. for (var e = 0, f = a.length; f > e; e++) this.layers[d].callbacks[a[e]] = {
  14388. callback: b,
  14389. callbackContext: c
  14390. }
  14391. },
  14392. setTileLocationCallback: function(a, b, c, d, e, f, g) {
  14393. if (g = this.getLayer(g), this.copy(a, b, c, d, g), !(this._results.length < 2))
  14394. for (var h = 1; h < this._results.length; h++) this._results[h].setCollisionCallback(e, f)
  14395. },
  14396. setCollision: function(a, b, c, d) {
  14397. 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);
  14398. if (Array.isArray(a)) {
  14399. for (var e = 0; e < a.length; e++) this.setCollisionByIndex(a[e], b, c, !1);
  14400. d && this.calculateFaces(c)
  14401. }
  14402. },
  14403. setCollisionBetween: function(a, b, c, d, e) {
  14404. if ("undefined" == typeof c && (c = !0), "undefined" == typeof e && (e = !0), d = this.getLayer(d), !(a > b)) {
  14405. for (var f = a; b >= f; f++) this.setCollisionByIndex(f, c, d, !1);
  14406. e && this.calculateFaces(d)
  14407. }
  14408. },
  14409. setCollisionByExclusion: function(a, b, c, d) {
  14410. "undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c);
  14411. for (var e = 0, f = this.tiles.length; f > e; e++) - 1 === a.indexOf(e) && this.setCollisionByIndex(e, b, c, !1);
  14412. d && this.calculateFaces(c)
  14413. },
  14414. setCollisionByIndex: function(a, b, c, d) {
  14415. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = this.currentLayer), "undefined" == typeof d && (d = !0), b) this.collideIndexes.push(a);
  14416. else {
  14417. var e = this.collideIndexes.indexOf(a);
  14418. e > -1 && this.collideIndexes.splice(e, 1)
  14419. }
  14420. for (var f = 0; f < this.layers[c].height; f++)
  14421. for (var g = 0; g < this.layers[c].width; g++) {
  14422. var h = this.layers[c].data[f][g];
  14423. 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)
  14424. }
  14425. return d && this.calculateFaces(c), c
  14426. },
  14427. getLayer: function(a) {
  14428. return "undefined" == typeof a ? a = this.currentLayer : "string" == typeof a ? a = this.getLayerIndex(a) : a instanceof c.TilemapLayer && (a = a.index), a
  14429. },
  14430. setPreventRecalculate: function(a) {
  14431. if (a === !0 && this.preventingRecalculate !== !0 && (this.preventingRecalculate = !0, this.needToRecalculate = {}), a === !1 && this.preventingRecalculate === !0) {
  14432. this.preventingRecalculate = !1;
  14433. for (var b in this.needToRecalculate) this.calculateFaces(b);
  14434. this.needToRecalculate = !1
  14435. }
  14436. },
  14437. calculateFaces: function(a) {
  14438. if (this.preventingRecalculate) return void(this.needToRecalculate[a] = !0);
  14439. for (var b = null, c = null, d = null, e = null, f = 0, g = this.layers[a].height; g > f; f++)
  14440. for (var h = 0, i = this.layers[a].width; i > h; h++) {
  14441. var j = this.layers[a].data[f][h];
  14442. 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))
  14443. }
  14444. },
  14445. getTileAbove: function(a, b, c) {
  14446. return c > 0 ? this.layers[a].data[c - 1][b] : null
  14447. },
  14448. getTileBelow: function(a, b, c) {
  14449. return c < this.layers[a].height - 1 ? this.layers[a].data[c + 1][b] : null
  14450. },
  14451. getTileLeft: function(a, b, c) {
  14452. return b > 0 ? this.layers[a].data[c][b - 1] : null
  14453. },
  14454. getTileRight: function(a, b, c) {
  14455. return b < this.layers[a].width - 1 ? this.layers[a].data[c][b + 1] : null
  14456. },
  14457. setLayer: function(a) {
  14458. a = this.getLayer(a), this.layers[a] && (this.currentLayer = a)
  14459. },
  14460. hasTile: function(a, b, c) {
  14461. return c = this.getLayer(c), this.layers[c].data[b][a].index > -1
  14462. },
  14463. removeTile: function(a, b, d) {
  14464. if (d = this.getLayer(d), a >= 0 && a < this.layers[d].width && b >= 0 && b < this.layers[d].height && this.hasTile(a, b, d)) {
  14465. var e = this.layers[d].data[b][a];
  14466. return this.layers[d].data[b][a] = new c.Tile(this.layers[d], -1, a, b, this.tileWidth, this.tileHeight), this.layers[d].dirty = !0, this.calculateFaces(d), e
  14467. }
  14468. },
  14469. removeTileWorldXY: function(a, b, c, d, e) {
  14470. 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)
  14471. },
  14472. putTile: function(a, b, d, e) {
  14473. if (null === a) return this.removeTile(b, d, e);
  14474. if (e = this.getLayer(e), b >= 0 && b < this.layers[e].width && d >= 0 && d < this.layers[e].height) {
  14475. var f;
  14476. return a instanceof c.Tile ? (f = a.index, this.hasTile(b, d, e) ? this.layers[e].data[d][b].copy(a) : this.layers[e].data[d][b] = new c.Tile(e, f, b, d, a.width, a.height)) : (f = a, this.hasTile(b, d, e) ? this.layers[e].data[d][b].index = f : this.layers[e].data[d][b] = new c.Tile(this.layers[e], f, b, d, this.tileWidth, this.tileHeight)), this.collideIndexes.indexOf(f) > -1 ? this.layers[e].data[d][b].setCollision(!0, !0, !0, !0) : this.layers[e].data[d][b].resetCollision(), this.layers[e].dirty = !0, this.calculateFaces(e), this.layers[e].data[d][b]
  14477. }
  14478. return null
  14479. },
  14480. putTileWorldXY: function(a, b, c, d, e, f) {
  14481. 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)
  14482. },
  14483. searchTileIndex: function(a, b, c, d) {
  14484. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), d = this.getLayer(d);
  14485. var e = 0;
  14486. if (c) {
  14487. for (var f = this.layers[d].height - 1; f >= 0; f--)
  14488. for (var g = this.layers[d].width - 1; g >= 0; g--)
  14489. if (this.layers[d].data[f][g].index === a) {
  14490. if (e === b) return this.layers[d].data[f][g];
  14491. e++
  14492. }
  14493. } else
  14494. for (var f = 0; f < this.layers[d].height; f++)
  14495. for (var g = 0; g < this.layers[d].width; g++)
  14496. if (this.layers[d].data[f][g].index === a) {
  14497. if (e === b) return this.layers[d].data[f][g];
  14498. e++
  14499. }
  14500. return null
  14501. },
  14502. getTile: function(a, b, c, d) {
  14503. 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
  14504. },
  14505. getTileWorldXY: function(a, b, c, d, e) {
  14506. 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)
  14507. },
  14508. copy: function(a, b, c, d, e) {
  14509. if (e = this.getLayer(e), !this.layers[e]) return void(this._results.length = 0);
  14510. "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({
  14511. x: a,
  14512. y: b,
  14513. width: c,
  14514. height: d,
  14515. layer: e
  14516. });
  14517. for (var f = b; b + d > f; f++)
  14518. for (var g = a; a + c > g; g++) this._results.push(this.layers[e].data[f][g]);
  14519. return this._results
  14520. },
  14521. paste: function(a, b, c, d) {
  14522. if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), d = this.getLayer(d), c && !(c.length < 2)) {
  14523. for (var e = a - c[1].x, f = b - c[1].y, g = 1; g < c.length; g++) this.layers[d].data[f + c[g].y][e + c[g].x].copy(c[g]);
  14524. this.layers[d].dirty = !0, this.calculateFaces(d)
  14525. }
  14526. },
  14527. swap: function(a, b, c, d, e, f, g) {
  14528. 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))
  14529. },
  14530. swapHandler: function(a) {
  14531. a.index === this._tempA ? a.index = this._tempB : a.index === this._tempB && (a.index = this._tempA)
  14532. },
  14533. forEach: function(a, b, c, d, e, f, g) {
  14534. 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))
  14535. },
  14536. replace: function(a, b, c, d, e, f, g) {
  14537. if (g = this.getLayer(g), this.copy(c, d, e, f, g), !(this._results.length < 2)) {
  14538. for (var h = 1; h < this._results.length; h++) this._results[h].index === a && (this._results[h].index = b);
  14539. this.paste(c, d, this._results, g)
  14540. }
  14541. },
  14542. random: function(a, b, c, d, e) {
  14543. if (e = this.getLayer(e), this.copy(a, b, c, d, e), !(this._results.length < 2)) {
  14544. for (var f = [], g = 1; g < this._results.length; g++)
  14545. if (this._results[g].index) {
  14546. var h = this._results[g].index; - 1 === f.indexOf(h) && f.push(h)
  14547. }
  14548. for (var i = 1; i < this._results.length; i++) this._results[i].index = this.game.rnd.pick(f);
  14549. this.paste(a, b, this._results, e)
  14550. }
  14551. },
  14552. shuffle: function(a, b, d, e, f) {
  14553. if (f = this.getLayer(f), this.copy(a, b, d, e, f), !(this._results.length < 2)) {
  14554. for (var g = [], h = 1; h < this._results.length; h++) this._results[h].index && g.push(this._results[h].index);
  14555. c.Utils.shuffle(g);
  14556. for (var i = 1; i < this._results.length; i++) this._results[i].index = g[i - 1];
  14557. this.paste(a, b, this._results, f)
  14558. }
  14559. },
  14560. fill: function(a, b, c, d, e, f) {
  14561. if (f = this.getLayer(f), this.copy(b, c, d, e, f), !(this._results.length < 2)) {
  14562. for (var g = 1; g < this._results.length; g++) this._results[g].index = a;
  14563. this.paste(b, c, this._results, f)
  14564. }
  14565. },
  14566. removeAllLayers: function() {
  14567. this.layers.length = 0, this.currentLayer = 0
  14568. },
  14569. dump: function() {
  14570. for (var a = "", b = [""], c = 0; c < this.layers[this.currentLayer].height; c++) {
  14571. 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)");
  14572. a += "\n"
  14573. }
  14574. b[0] = a, console.log.apply(console, b)
  14575. },
  14576. destroy: function() {
  14577. this.removeAllLayers(), this.data = [], this.game = null
  14578. }
  14579. }, c.Tilemap.prototype.constructor = c.Tilemap, Object.defineProperty(c.Tilemap.prototype, "layer", {
  14580. get: function() {
  14581. return this.layers[this.currentLayer]
  14582. },
  14583. set: function(a) {
  14584. a !== this.currentLayer && this.setLayer(a)
  14585. }
  14586. }), c.TilemapLayer = function(a, b, d, e, f) {
  14587. e |= 0, f |= 0, PIXI.Sprite.call(this, PIXI.TextureCache.__default), c.Component.Core.init.call(this, a, 0, 0, null, null), this.map = b, this.index = d, this.layer = b.layers[d], this.canvas = c.Canvas.create(e, f), this.context = this.canvas.getContext("2d"), this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new c.Frame(0, 0, 0, e, f, "tilemapLayer", a.rnd.uuid()), this.type = c.TILEMAPLAYER, this.physicsType = c.TILEMAPLAYER, this.renderSettings = {
  14588. enableScrollDelta: !0,
  14589. overdrawRatio: .2,
  14590. copyCanvas: null
  14591. }, this.debug = !1, this.exists = !0, this.debugSettings = {
  14592. missingImageFill: "rgb(255,255,255)",
  14593. debuggedTileOverfill: "rgba(0,255,0,0.4)",
  14594. forceFullRedraw: !0,
  14595. debugAlpha: .5,
  14596. facingEdgeStroke: "rgba(0,255,0,1)",
  14597. collidingTileOverfill: "rgba(0,255,0,0.2)"
  14598. }, this.scrollFactorX = 1, this.scrollFactorY = 1, this.dirty = !0, this.rayStepRate = 4, this._wrap = !1, this._mc = {
  14599. scrollX: 0,
  14600. scrollY: 0,
  14601. renderWidth: 0,
  14602. renderHeight: 0,
  14603. tileWidth: b.tileWidth,
  14604. tileHeight: b.tileHeight,
  14605. cw: b.tileWidth,
  14606. ch: b.tileHeight,
  14607. tilesets: []
  14608. }, this._scrollX = 0, this._scrollY = 0, this._results = [], a.device.canvasBitBltShift || (this.renderSettings.copyCanvas = c.TilemapLayer.ensureSharedCopyCanvas()), this.fixedToCamera = !0
  14609. }, c.TilemapLayer.prototype = Object.create(PIXI.Sprite.prototype), c.TilemapLayer.prototype.constructor = c.TilemapLayer;
  14610. var l = ["Bounds", "Destroy", "FixedToCamera", "Reset", "Smoothed"];
  14611. c.Component.Core.install.call(c.TilemapLayer.prototype, l), c.TilemapLayer.sharedCopyCanvas = null, c.TilemapLayer.ensureSharedCopyCanvas = function() {
  14612. return this.sharedCopyCanvas || (this.sharedCopyCanvas = c.Canvas.create(2, 2)), this.sharedCopyCanvas
  14613. }, c.TilemapLayer.prototype.preUpdate = function() {
  14614. return c.Component.Core.preUpdate.call(this), !0
  14615. }, c.TilemapLayer.prototype.postUpdate = function() {
  14616. c.Component.Core.prototype.postUpdate.call(this);
  14617. var a = this.game.camera;
  14618. this.scrollX = a.x * this.scrollFactorX / this.scale.x, this.scrollY = a.y * this.scrollFactorY / this.scale.y, this.render()
  14619. }, c.TilemapLayer.prototype.resizeWorld = function() {
  14620. this.game.world.setBounds(0, 0, this.layer.widthInPixels * this.scale.x, this.layer.heightInPixels * this.scale.y)
  14621. }, c.TilemapLayer.prototype._fixX = function(a) {
  14622. return 0 > a && (a = 0), 1 === this.scrollFactorX ? a : this._scrollX + (a - this._scrollX / this.scrollFactorX)
  14623. }, c.TilemapLayer.prototype._unfixX = function(a) {
  14624. return 1 === this.scrollFactorX ? a : this._scrollX / this.scrollFactorX + (a - this._scrollX)
  14625. }, c.TilemapLayer.prototype._fixY = function(a) {
  14626. return 0 > a && (a = 0), 1 === this.scrollFactorY ? a : this._scrollY + (a - this._scrollY / this.scrollFactorY)
  14627. }, c.TilemapLayer.prototype._unfixY = function(a) {
  14628. return 1 === this.scrollFactorY ? a : this._scrollY / this.scrollFactorY + (a - this._scrollY)
  14629. }, c.TilemapLayer.prototype.getTileX = function(a) {
  14630. return Math.floor(this._fixX(a) / this._mc.tileWidth)
  14631. }, c.TilemapLayer.prototype.getTileY = function(a) {
  14632. return Math.floor(this._fixY(a) / this._mc.tileHeight)
  14633. }, c.TilemapLayer.prototype.getTileXY = function(a, b, c) {
  14634. return c.x = this.getTileX(a), c.y = this.getTileY(b), c
  14635. }, c.TilemapLayer.prototype.getRayCastTiles = function(a, b, c, d) {
  14636. b || (b = this.rayStepRate), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1);
  14637. var e = this.getTiles(a.x, a.y, a.width, a.height, c, d);
  14638. if (0 === e.length) return [];
  14639. for (var f = a.coordinatesOnLine(b), g = [], h = 0; h < e.length; h++)
  14640. for (var i = 0; i < f.length; i++) {
  14641. var j = e[h],
  14642. k = f[i];
  14643. if (j.containsPoint(k[0], k[1])) {
  14644. g.push(j);
  14645. break
  14646. }
  14647. }
  14648. return g
  14649. }, c.TilemapLayer.prototype.getTiles = function(a, b, c, d, e, f) {
  14650. "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1);
  14651. var g = !(e || f);
  14652. a = this._fixX(a), b = this._fixY(b);
  14653. for (var h = Math.floor(a / (this._mc.cw * this.scale.x)), i = Math.floor(b / (this._mc.ch * this.scale.y)), j = Math.ceil((a + c) / (this._mc.cw * this.scale.x)) - h, k = Math.ceil((b + d) / (this._mc.ch * this.scale.y)) - i; this._results.length;) this._results.pop();
  14654. for (var l = i; i + k > l; l++)
  14655. for (var m = h; h + j > m; m++) {
  14656. var n = this.layer.data[l];
  14657. n && n[m] && (g || n[m].isInteresting(e, f)) && this._results.push(n[m])
  14658. }
  14659. return this._results.slice()
  14660. }, Object.defineProperty(c.TilemapLayer.prototype, "tileColor", {
  14661. get: function() {
  14662. return this.debugSettings.missingImageFill
  14663. },
  14664. set: function(a) {
  14665. this.debugSettings.missingImageFill = a
  14666. }
  14667. }), Object.defineProperty(c.TilemapLayer.prototype, "wrap", {
  14668. get: function() {
  14669. return this._wrap
  14670. },
  14671. set: function(a) {
  14672. this._wrap = a, this.dirty = !0
  14673. }
  14674. }), c.TilemapLayer.prototype.resolveTileset = function(a) {
  14675. var b = this._mc.tilesets;
  14676. if (2e3 > a)
  14677. for (; b.length < a;) b.push(void 0);
  14678. var c = this.map.tiles[a] && this.map.tiles[a][2];
  14679. if (null != c) {
  14680. var d = this.map.tilesets[c];
  14681. if (d && d.containsTileIndex(a)) return b[a] = d
  14682. }
  14683. return b[a] = null
  14684. }, c.TilemapLayer.prototype.resetTilesetCache = function() {
  14685. for (var a = this._mc.tilesets; a.length;) a.pop()
  14686. }, c.TilemapLayer.prototype.setScale = function(a, b) {
  14687. a = a || 1, b = b || a;
  14688. for (var c = 0; c < this.layer.data.length; c++)
  14689. for (var d = this.layer.data[c], e = 0; e < d.length; e++) {
  14690. var f = d[e];
  14691. f.width = this.map.tileWidth * a, f.height = this.map.tileHeight * b, f.worldX = f.x * f.width, f.worldY = f.y * f.height
  14692. }
  14693. this.scale.setTo(a, b)
  14694. }, c.TilemapLayer.prototype.shiftCanvas = function(a, b, c) {
  14695. var d = a.canvas,
  14696. e = d.width - Math.abs(b),
  14697. f = d.height - Math.abs(c),
  14698. g = 0,
  14699. h = 0,
  14700. i = b,
  14701. j = c;
  14702. 0 > b && (g = -b, i = 0), 0 > c && (h = -c, j = 0);
  14703. var k = this.renderSettings.copyCanvas;
  14704. if (k) {
  14705. (k.width < e || k.height < f) && (k.width = e, k.height = f);
  14706. var l = k.getContext("2d");
  14707. l.clearRect(0, 0, e, f), l.drawImage(d, g, h, e, f, 0, 0, e, f), a.clearRect(i, j, e, f), a.drawImage(k, 0, 0, e, f, i, j, e, f)
  14708. } else a.save(), a.globalCompositeOperation = "copy", a.drawImage(d, g, h, e, f, i, j, e, f), a.restore()
  14709. }, c.TilemapLayer.prototype.renderRegion = function(a, b, c, d, e, f) {
  14710. var g = this.context,
  14711. h = this.layer.width,
  14712. i = this.layer.height,
  14713. j = this._mc.tileWidth,
  14714. k = this._mc.tileHeight,
  14715. l = this._mc.tilesets,
  14716. m = 0 / 0;
  14717. this._wrap || (e >= c && (c = Math.max(0, c), e = Math.min(h - 1, e)), f >= d && (d = Math.max(0, d), f = Math.min(i - 1, f)));
  14718. var n, o, p, q, r, s, t = c * j - a,
  14719. u = d * k - b,
  14720. v = (c + (1 << 20) * h) % h,
  14721. w = (d + (1 << 20) * i) % i;
  14722. for (g.fillStyle = this.tileColor, q = w, s = f - d, o = u; s >= 0; q++, s--, o += k) {
  14723. q >= i && (q -= i);
  14724. var x = this.layer.data[q];
  14725. for (p = v, r = e - c, n = t; r >= 0; p++, r--, n += j) {
  14726. p >= h && (p -= h);
  14727. var y = x[p];
  14728. if (y && !(y.index < 0)) {
  14729. var z = y.index,
  14730. A = l[z];
  14731. void 0 === A && (A = this.resolveTileset(z)), y.alpha === m || this.debug || (g.globalAlpha = y.alpha, m = y.alpha), A ? y.rotation || y.flipped ? (g.save(), g.translate(n + y.centerX, o + y.centerY), g.rotate(y.rotation), y.flipped && g.scale(-1, 1), A.draw(g, -y.centerX, -y.centerY, z), g.restore()) : A.draw(g, n, o, z) : this.debugSettings.missingImageFill && (g.fillStyle = this.debugSettings.missingImageFill, g.fillRect(n, o, j, k)), y.debug && this.debugSettings.debuggedTileOverfill && (g.fillStyle = this.debugSettings.debuggedTileOverfill, g.fillRect(n, o, j, k))
  14732. }
  14733. }
  14734. }
  14735. }, c.TilemapLayer.prototype.renderDeltaScroll = function(a, b) {
  14736. var c = this._mc.scrollX,
  14737. d = this._mc.scrollY,
  14738. e = this.canvas.width,
  14739. f = this.canvas.height,
  14740. g = this._mc.tileWidth,
  14741. h = this._mc.tileHeight,
  14742. i = 0,
  14743. j = -g,
  14744. k = 0,
  14745. l = -h;
  14746. if (0 > a ? (i = e + a, j = e - 1) : a > 0 && (j = a), 0 > b ? (k = f + b, l = f - 1) : b > 0 && (l = b), this.shiftCanvas(this.context, a, b), i = Math.floor((i + c) / g), j = Math.floor((j + c) / g), k = Math.floor((k + d) / h), l = Math.floor((l + d) / h), j >= i) {
  14747. this.context.clearRect(i * g - c, 0, (j - i + 1) * g, f);
  14748. var m = Math.floor((0 + d) / h),
  14749. n = Math.floor((f - 1 + d) / h);
  14750. this.renderRegion(c, d, i, m, j, n)
  14751. }
  14752. if (l >= k) {
  14753. this.context.clearRect(0, k * h - d, e, (l - k + 1) * h);
  14754. var o = Math.floor((0 + c) / g),
  14755. p = Math.floor((e - 1 + c) / g);
  14756. this.renderRegion(c, d, o, k, p, l)
  14757. }
  14758. }, c.TilemapLayer.prototype.renderFull = function() {
  14759. var a = this._mc.scrollX,
  14760. b = this._mc.scrollY,
  14761. c = this.canvas.width,
  14762. d = this.canvas.height,
  14763. e = this._mc.tileWidth,
  14764. f = this._mc.tileHeight,
  14765. g = Math.floor(a / e),
  14766. h = Math.floor((c - 1 + a) / e),
  14767. i = Math.floor(b / f),
  14768. j = Math.floor((d - 1 + b) / f);
  14769. this.context.clearRect(0, 0, c, d), this.renderRegion(a, b, g, i, h, j)
  14770. }, c.TilemapLayer.prototype.render = function() {
  14771. var a = !1;
  14772. if (this.visible) {
  14773. this.context.save(), (this.dirty || this.layer.dirty) && (this.layer.dirty = !1, a = !0);
  14774. var b = this.canvas.width,
  14775. c = this.canvas.height,
  14776. d = 0 | this._scrollX,
  14777. e = 0 | this._scrollY,
  14778. f = this._mc,
  14779. g = f.scrollX - d,
  14780. h = f.scrollY - e;
  14781. if (a || 0 !== g || 0 !== h || f.renderWidth !== b || f.renderHeight !== c) return f.scrollX = d, f.scrollY = e, (f.renderWidth !== b || f.renderHeight !== c) && (f.renderWidth = b, f.renderHeight = c), this.debug && (this.context.globalAlpha = this.debugSettings.debugAlpha, this.debugSettings.forceFullRedraw && (a = !0)), !a && this.renderSettings.enableScrollDelta && Math.abs(g) + Math.abs(h) < Math.min(b, c) ? this.renderDeltaScroll(g, h) : this.renderFull(), this.debug && (this.context.globalAlpha = 1, this.renderDebug()), this.baseTexture.dirty(), this.dirty = !1, this.context.restore(), !0
  14782. }
  14783. }, c.TilemapLayer.prototype.renderDebug = function() {
  14784. var a, b, c, d, e, f, g = this._mc.scrollX,
  14785. h = this._mc.scrollY,
  14786. i = this.context,
  14787. j = this.canvas.width,
  14788. k = this.canvas.height,
  14789. l = this.layer.width,
  14790. m = this.layer.height,
  14791. n = this._mc.tileWidth,
  14792. o = this._mc.tileHeight,
  14793. p = Math.floor(g / n),
  14794. q = Math.floor((j - 1 + g) / n),
  14795. r = Math.floor(h / o),
  14796. s = Math.floor((k - 1 + h) / o),
  14797. t = p * n - g,
  14798. u = r * o - h,
  14799. v = (p + (1 << 20) * l) % l,
  14800. w = (r + (1 << 20) * m) % m;
  14801. for (i.strokeStyle = this.debugSettings.facingEdgeStroke, d = w, f = s - r, b = u; f >= 0; d++, f--, b += o) {
  14802. d >= m && (d -= m);
  14803. var x = this.layer.data[d];
  14804. for (c = v, e = q - p, a = t; e >= 0; c++, e--, a += n) {
  14805. c >= l && (c -= l);
  14806. var y = x[c];
  14807. !y || y.index < 0 || !y.collides || (this.debugSettings.collidingTileOverfill && (i.fillStyle = this.debugSettings.collidingTileOverfill, i.fillRect(a, b, this._mc.cw, this._mc.ch)), this.debugSettings.facingEdgeStroke && (i.beginPath(), y.faceTop && (i.moveTo(a, b), i.lineTo(a + this._mc.cw, b)), y.faceBottom && (i.moveTo(a, b + this._mc.ch), i.lineTo(a + this._mc.cw, b + this._mc.ch)), y.faceLeft && (i.moveTo(a, b), i.lineTo(a, b + this._mc.ch)), y.faceRight && (i.moveTo(a + this._mc.cw, b), i.lineTo(a + this._mc.cw, b + this._mc.ch)), i.stroke()))
  14808. }
  14809. }
  14810. }, Object.defineProperty(c.TilemapLayer.prototype, "scrollX", {
  14811. get: function() {
  14812. return this._scrollX
  14813. },
  14814. set: function(a) {
  14815. this._scrollX = a
  14816. }
  14817. }), Object.defineProperty(c.TilemapLayer.prototype, "scrollY", {
  14818. get: function() {
  14819. return this._scrollY
  14820. },
  14821. set: function(a) {
  14822. this._scrollY = a
  14823. }
  14824. }), Object.defineProperty(c.TilemapLayer.prototype, "collisionWidth", {
  14825. get: function() {
  14826. return this._mc.cw
  14827. },
  14828. set: function(a) {
  14829. this._mc.cw = 0 | a, this.dirty = !0
  14830. }
  14831. }), Object.defineProperty(c.TilemapLayer.prototype, "collisionHeight", {
  14832. get: function() {
  14833. return this._mc.ch
  14834. },
  14835. set: function(a) {
  14836. this._mc.ch = 0 | a, this.dirty = !0
  14837. }
  14838. }), c.TilemapParser = {
  14839. parse: function(a, b, d, e, f, g) {
  14840. if ("undefined" == typeof d && (d = 32), "undefined" == typeof e && (e = 32), "undefined" == typeof f && (f = 10), "undefined" == typeof g && (g = 10), "undefined" == typeof b) return this.getEmptyData();
  14841. if (null === b) return this.getEmptyData(d, e, f, g);
  14842. var h = a.cache.getTilemapData(b);
  14843. if (h) {
  14844. if (h.format === c.Tilemap.CSV) return this.parseCSV(b, h.data, d, e);
  14845. if (!h.format || h.format === c.Tilemap.TILED_JSON) return this.parseTiledJSON(h.data)
  14846. } else console.warn("Phaser.TilemapParser.parse - No map data found for key " + b)
  14847. },
  14848. parseCSV: function(a, b, d, e) {
  14849. var f = this.getEmptyData();
  14850. b = b.trim();
  14851. for (var g = [], h = b.split("\n"), i = h.length, j = 0, k = 0; k < h.length; k++) {
  14852. g[k] = [];
  14853. for (var l = h[k].split(","), m = 0; m < l.length; m++) g[k][m] = new c.Tile(f.layers[0], parseInt(l[m], 10), m, k, d, e);
  14854. 0 === j && (j = l.length)
  14855. }
  14856. return f.format = c.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
  14857. },
  14858. getEmptyData: function(a, b, c, d) {
  14859. var e = {};
  14860. 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;
  14861. var f = [],
  14862. g = {
  14863. name: "layer",
  14864. x: 0,
  14865. y: 0,
  14866. width: 0,
  14867. height: 0,
  14868. widthInPixels: 0,
  14869. heightInPixels: 0,
  14870. alpha: 1,
  14871. visible: !0,
  14872. properties: {},
  14873. indexes: [],
  14874. callbacks: [],
  14875. bodies: [],
  14876. data: []
  14877. };
  14878. return f.push(g), e.layers = f, e.images = [], e.objects = {}, e.collision = {}, e.tilesets = [], e.tiles = [], e
  14879. },
  14880. parseTiledJSON: function(a) {
  14881. function b(a, b) {
  14882. var c = {};
  14883. for (var d in b) {
  14884. var e = b[d];
  14885. a[e] && (c[e] = a[e])
  14886. }
  14887. return c
  14888. }
  14889. if ("orthogonal" !== a.orientation) return console.warn("TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser"), null;
  14890. var d = {};
  14891. d.width = a.width, d.height = a.height, d.tileWidth = a.tilewidth, d.tileHeight = a.tileheight, d.orientation = a.orientation, d.format = c.Tilemap.TILED_JSON, d.version = a.version, d.properties = a.properties, d.widthInPixels = d.width * d.tileWidth, d.heightInPixels = d.height * d.tileHeight;
  14892. for (var e = [], f = 0; f < a.layers.length; f++)
  14893. if ("tilelayer" === a.layers[f].type) {
  14894. var g = {
  14895. name: a.layers[f].name,
  14896. x: a.layers[f].x,
  14897. y: a.layers[f].y,
  14898. width: a.layers[f].width,
  14899. height: a.layers[f].height,
  14900. widthInPixels: a.layers[f].width * a.tilewidth,
  14901. heightInPixels: a.layers[f].height * a.tileheight,
  14902. alpha: a.layers[f].opacity,
  14903. visible: a.layers[f].visible,
  14904. properties: {},
  14905. indexes: [],
  14906. callbacks: [],
  14907. bodies: []
  14908. };
  14909. a.layers[f].properties && (g.properties = a.layers[f].properties);
  14910. for (var h, i, j, k, l = 0, m = [], n = [], o = 0, p = a.layers[f].data.length; p > o; o++) {
  14911. if (h = 0, i = !1, k = a.layers[f].data[o], k > 536870912) switch (j = 0, k > 2147483648 && (k -= 2147483648, j += 4), k > 1073741824 && (k -= 1073741824, j += 2), k > 536870912 && (k -= 536870912, j += 1), j) {
  14912. case 5:
  14913. h = Math.PI / 2;
  14914. break;
  14915. case 6:
  14916. h = Math.PI;
  14917. break;
  14918. case 3:
  14919. h = 3 * Math.PI / 2;
  14920. break;
  14921. case 4:
  14922. h = 0, i = !0;
  14923. break;
  14924. case 7:
  14925. h = Math.PI / 2, i = !0;
  14926. break;
  14927. case 2:
  14928. h = Math.PI, i = !0;
  14929. break;
  14930. case 1:
  14931. h = 3 * Math.PI / 2, i = !0
  14932. }
  14933. k > 0 ? (m.push(new c.Tile(g, k, l, n.length, a.tilewidth, a.tileheight)), m[m.length - 1].rotation = h, m[m.length - 1].flipped = i) : m.push(new c.Tile(g, -1, l, n.length, a.tilewidth, a.tileheight)), l++, l === a.layers[f].width && (n.push(m), l = 0, m = [])
  14934. }
  14935. g.data = n, e.push(g)
  14936. }
  14937. d.layers = e;
  14938. for (var q = [], f = 0; f < a.layers.length; f++)
  14939. if ("imagelayer" === a.layers[f].type) {
  14940. var r = {
  14941. name: a.layers[f].name,
  14942. image: a.layers[f].image,
  14943. x: a.layers[f].x,
  14944. y: a.layers[f].y,
  14945. alpha: a.layers[f].opacity,
  14946. visible: a.layers[f].visible,
  14947. properties: {}
  14948. };
  14949. a.layers[f].properties && (r.properties = a.layers[f].properties), q.push(r)
  14950. }
  14951. d.images = q;
  14952. for (var s = [], f = 0; f < a.tilesets.length; f++) {
  14953. var t = a.tilesets[f];
  14954. if (t.image) {
  14955. var u = new c.Tileset(t.name, t.firstgid, t.tilewidth, t.tileheight, t.margin, t.spacing, t.properties);
  14956. t.tileproperties && (u.tileProperties = t.tileproperties), u.updateTileData(t.imagewidth, t.imageheight), s.push(u)
  14957. } else console.warn("Phaser.TilemapParser - Image Collection Tilesets are not support")
  14958. }
  14959. d.tilesets = s;
  14960. for (var v = {}, w = {}, f = 0; f < a.layers.length; f++)
  14961. if ("objectgroup" === a.layers[f].type) {
  14962. v[a.layers[f].name] = [], w[a.layers[f].name] = [];
  14963. for (var x = 0, p = a.layers[f].objects.length; p > x; x++)
  14964. if (a.layers[f].objects[x].gid) {
  14965. var y = {
  14966. gid: a.layers[f].objects[x].gid,
  14967. name: a.layers[f].objects[x].name,
  14968. type: a.layers[f].objects[x].hasOwnProperty("type") ? a.layers[f].objects[x].type : "",
  14969. x: a.layers[f].objects[x].x,
  14970. y: a.layers[f].objects[x].y,
  14971. visible: a.layers[f].objects[x].visible,
  14972. properties: a.layers[f].objects[x].properties
  14973. };
  14974. a.layers[f].objects[x].rotation && (y.rotation = a.layers[f].objects[x].rotation), v[a.layers[f].name].push(y)
  14975. } else if (a.layers[f].objects[x].polyline) {
  14976. var y = {
  14977. name: a.layers[f].objects[x].name,
  14978. type: a.layers[f].objects[x].type,
  14979. x: a.layers[f].objects[x].x,
  14980. y: a.layers[f].objects[x].y,
  14981. width: a.layers[f].objects[x].width,
  14982. height: a.layers[f].objects[x].height,
  14983. visible: a.layers[f].objects[x].visible,
  14984. properties: a.layers[f].objects[x].properties
  14985. };
  14986. a.layers[f].objects[x].rotation && (y.rotation = a.layers[f].objects[x].rotation), y.polyline = [];
  14987. for (var z = 0; z < a.layers[f].objects[x].polyline.length; z++) y.polyline.push([a.layers[f].objects[x].polyline[z].x, a.layers[f].objects[x].polyline[z].y]);
  14988. w[a.layers[f].name].push(y), v[a.layers[f].name].push(y)
  14989. } else if (a.layers[f].objects[x].polygon) {
  14990. var y = b(a.layers[f].objects[x], ["name", "type", "x", "y", "visible", "rotation", "properties"]);
  14991. y.polygon = [];
  14992. for (var z = 0; z < a.layers[f].objects[x].polygon.length; z++) y.polygon.push([a.layers[f].objects[x].polygon[z].x, a.layers[f].objects[x].polygon[z].y]);
  14993. v[a.layers[f].name].push(y)
  14994. } else if (a.layers[f].objects[x].ellipse) {
  14995. var y = b(a.layers[f].objects[x], ["name", "type", "ellipse", "x", "y", "width", "height", "visible", "rotation", "properties"]);
  14996. v[a.layers[f].name].push(y)
  14997. } else {
  14998. var y = b(a.layers[f].objects[x], ["name", "type", "x", "y", "width", "height", "visible", "rotation", "properties"]);
  14999. y.rectangle = !0, v[a.layers[f].name].push(y)
  15000. }
  15001. }
  15002. d.objects = v, d.collision = w, d.tiles = [];
  15003. for (var f = 0; f < d.tilesets.length; f++)
  15004. for (var t = d.tilesets[f], l = t.tileMargin, A = t.tileMargin, B = 0, C = 0, D = 0, o = t.firstgid; o < t.firstgid + t.total && (d.tiles[o] = [l, A, f], l += t.tileWidth + t.tileSpacing, B++, B !== t.total) && (C++, C !== t.columns || (l = t.tileMargin, A += t.tileHeight + t.tileSpacing, C = 0, D++, D !== t.rows)); o++);
  15005. for (var g, E, F, t, f = 0; f < d.layers.length; f++) {
  15006. g = d.layers[f];
  15007. for (var G = 0; G < g.data.length; G++) {
  15008. m = g.data[G];
  15009. for (var H = 0; H < m.length; H++) E = m[H], E.index < 0 || (F = d.tiles[E.index][2], t = d.tilesets[F], t.tileProperties && t.tileProperties[E.index - t.firstgid] && (E.properties = c.Utils.mixin(t.tileProperties[E.index - t.firstgid], E.properties)))
  15010. }
  15011. }
  15012. return d
  15013. }
  15014. }, c.Tileset = function(a, b, c, d, e, f, g) {
  15015. ("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 = 0 | b, this.tileWidth = 0 | c, this.tileHeight = 0 | d, this.tileMargin = 0 | e, this.tileSpacing = 0 | f, this.properties = g || {}, this.image = null, this.rows = 0, this.columns = 0, this.total = 0, this.drawCoords = []
  15016. }, c.Tileset.prototype = {
  15017. draw: function(a, b, c, d) {
  15018. var e = d - this.firstgid << 1;
  15019. e >= 0 && e + 1 < this.drawCoords.length && a.drawImage(this.image, this.drawCoords[e], this.drawCoords[e + 1], this.tileWidth, this.tileHeight, b, c, this.tileWidth, this.tileHeight)
  15020. },
  15021. containsTileIndex: function(a) {
  15022. return a >= this.firstgid && a < this.firstgid + this.total
  15023. },
  15024. setImage: function(a) {
  15025. this.image = a, this.updateTileData(a.width, a.height)
  15026. },
  15027. setSpacing: function(a, b) {
  15028. this.tileMargin = 0 | a, this.tileSpacing = 0 | b, this.image && this.updateTileData(this.image.width, this.image.height)
  15029. },
  15030. updateTileData: function(a, b) {
  15031. var c = (b - 2 * this.tileMargin + this.tileSpacing) / (this.tileHeight + this.tileSpacing),
  15032. d = (a - 2 * this.tileMargin + this.tileSpacing) / (this.tileWidth + this.tileSpacing);
  15033. (c % 1 !== 0 || d % 1 !== 0) && console.warn("Phaser.Tileset - image tile area is not an even multiple of tile size"), c = Math.floor(c), d = Math.floor(d), (this.rows && this.rows !== c || this.columns && this.columns !== d) && console.warn("Phaser.Tileset - actual and expected number of tile rows and columns differ"), this.rows = c, this.columns = d, this.total = c * d, this.drawCoords.length = 0;
  15034. for (var e = this.tileMargin, f = this.tileMargin, g = 0; g < this.rows; g++) {
  15035. for (var h = 0; h < this.columns; h++) this.drawCoords.push(e), this.drawCoords.push(f), e += this.tileWidth + this.tileSpacing;
  15036. e = this.tileMargin, f += this.tileHeight + this.tileSpacing
  15037. }
  15038. }
  15039. }, c.Tileset.prototype.constructor = c.Tileset, c.Particles = function(a) {
  15040. this.game = a, this.emitters = {}, this.ID = 0
  15041. }, c.Particles.prototype = {
  15042. add: function(a) {
  15043. return this.emitters[a.name] = a, a
  15044. },
  15045. remove: function(a) {
  15046. delete this.emitters[a.name]
  15047. },
  15048. update: function() {
  15049. for (var a in this.emitters) this.emitters[a].exists && this.emitters[a].update()
  15050. }
  15051. }, c.Particles.prototype.constructor = c.Particles, c.Particles.Arcade = {}, c.Particles.Arcade.Emitter = function(a, b, d, e) {
  15052. this.maxParticles = e || 50, c.Group.call(this, a), this.name = "emitter" + this.game.particles.ID++, this.type = c.EMITTER, this.physicsType = c.GROUP, this.area = new c.Rectangle(b, d, 1, 1), this.minParticleSpeed = new c.Point(-100, -100), this.maxParticleSpeed = new c.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 = c.Particle, this.particleDrag = new c.Point, this.angularDrag = 0, this.frequency = 100, this.lifespan = 2e3, this.bounce = new c.Point, this.on = !1, this.particleAnchor = new c.Point(.5, .5), this.blendMode = c.blendModes.NORMAL, this.emitX = b, this.emitY = d, this.autoScale = !1, this.autoAlpha = !1, this.particleBringToTop = !1, this.particleSendToBack = !1, this._minParticleScale = new c.Point(1, 1), this._maxParticleScale = new c.Point(1, 1), this._quantity = 0, this._timer = 0, this._counter = 0, this._flowQuantity = 0, this._flowTotal = 0, this._explode = !0, this._frames = null
  15053. }, c.Particles.Arcade.Emitter.prototype = Object.create(c.Group.prototype), c.Particles.Arcade.Emitter.prototype.constructor = c.Particles.Arcade.Emitter, c.Particles.Arcade.Emitter.prototype.update = function() {
  15054. if (this.on && this.game.time.time >= this._timer)
  15055. if (this._timer = this.game.time.time + this.frequency * this.game.time.slowMotion, 0 !== this._flowTotal)
  15056. if (this._flowQuantity > 0) {
  15057. for (var a = 0; a < this._flowQuantity; a++)
  15058. if (this.emitParticle() && (this._counter++, -1 !== this._flowTotal && this._counter >= this._flowTotal)) {
  15059. this.on = !1;
  15060. break
  15061. }
  15062. } else this.emitParticle() && (this._counter++, -1 !== this._flowTotal && this._counter >= this._flowTotal && (this.on = !1));
  15063. else this.emitParticle() && (this._counter++, this._quantity > 0 && this._counter >= this._quantity && (this.on = !1));
  15064. for (var a = this.children.length; a--;) this.children[a].exists && this.children[a].update()
  15065. }, c.Particles.Arcade.Emitter.prototype.makeParticles = function(a, b, c, d, e) {
  15066. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.maxParticles), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  15067. var f, g = 0,
  15068. h = a,
  15069. i = b;
  15070. for (this._frames = b, c > this.maxParticles && (this.maxParticles = c); 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.body.skipQuadTree = !0, f.exists = !1, f.visible = !1, f.anchor.copyFrom(this.particleAnchor), this.add(f), g++;
  15071. return this
  15072. }, c.Particles.Arcade.Emitter.prototype.kill = function() {
  15073. this.on = !1, this.alive = !1, this.exists = !1
  15074. }, c.Particles.Arcade.Emitter.prototype.revive = function() {
  15075. this.alive = !0, this.exists = !0
  15076. }, c.Particles.Arcade.Emitter.prototype.explode = function(a, b) {
  15077. this._flowTotal = 0, this.start(!0, a, 0, b, !1)
  15078. }, c.Particles.Arcade.Emitter.prototype.flow = function(a, b, c, d, e) {
  15079. ("undefined" == typeof c || 0 === c) && (c = 1), "undefined" == typeof d && (d = -1), "undefined" == typeof e && (e = !0), c > this.maxParticles && (c = this.maxParticles), this._counter = 0, this._flowQuantity = c, this._flowTotal = d, e ? (this.start(!0, a, b, c), this._counter += c, this.on = !0, this._timer = this.game.time.time + b * this.game.time.slowMotion) : this.start(!1, a, b, c)
  15080. }, c.Particles.Arcade.Emitter.prototype.start = function(a, b, c, d, e) {
  15081. if ("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), d > this.maxParticles && (d = this.maxParticles), this.revive(), this.visible = !0, this.lifespan = b, this.frequency = c, a || e)
  15082. for (var f = 0; d > f; f++) this.emitParticle();
  15083. else this.on = !0, this._quantity += d, this._counter = 0, this._timer = this.game.time.time + c * this.game.time.slowMotion
  15084. }, c.Particles.Arcade.Emitter.prototype.emitParticle = function() {
  15085. var a = this.getFirstExists(!1);
  15086. return null === a ? !1 : (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.between(this.minParticleSpeed.x, this.maxParticleSpeed.x), a.body.velocity.y = this.game.rnd.between(this.minParticleSpeed.y, this.maxParticleSpeed.y), a.body.angularVelocity = this.game.rnd.between(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(), !0)
  15087. }, c.Particles.Arcade.Emitter.prototype.destroy = function() {
  15088. this.game.particles.remove(this), c.Group.prototype.destroy.call(this, !0, !1)
  15089. }, c.Particles.Arcade.Emitter.prototype.setSize = function(a, b) {
  15090. this.area.width = a, this.area.height = b
  15091. }, c.Particles.Arcade.Emitter.prototype.setXSpeed = function(a, b) {
  15092. a = a || 0, b = b || 0, this.minParticleSpeed.x = a, this.maxParticleSpeed.x = b
  15093. }, c.Particles.Arcade.Emitter.prototype.setYSpeed = function(a, b) {
  15094. a = a || 0, b = b || 0, this.minParticleSpeed.y = a, this.maxParticleSpeed.y = b
  15095. }, c.Particles.Arcade.Emitter.prototype.setRotation = function(a, b) {
  15096. a = a || 0, b = b || 0, this.minRotation = a, this.maxRotation = b
  15097. }, c.Particles.Arcade.Emitter.prototype.setAlpha = function(a, b, d, e, f) {
  15098. if ("undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = 1), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = c.Easing.Linear.None), "undefined" == typeof f && (f = !1), this.minParticleAlpha = a, this.maxParticleAlpha = b, this.autoAlpha = !1, d > 0 && a !== b) {
  15099. var g = {
  15100. v: a
  15101. },
  15102. h = this.game.make.tween(g).to({
  15103. v: b
  15104. }, d, e);
  15105. h.yoyo(f), this.alphaData = h.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0
  15106. }
  15107. }, c.Particles.Arcade.Emitter.prototype.setScale = function(a, b, d, e, f, g, h) {
  15108. if ("undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = 1), "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = 1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = c.Easing.Linear.None), "undefined" == typeof h && (h = !1), this.minParticleScale = 1, this.maxParticleScale = 1, this._minParticleScale.set(a, d), this._maxParticleScale.set(b, e), this.autoScale = !1, f > 0 && (a !== b || d !== e)) {
  15109. var i = {
  15110. x: a,
  15111. y: d
  15112. },
  15113. j = this.game.make.tween(i).to({
  15114. x: b,
  15115. y: e
  15116. }, f, g);
  15117. j.yoyo(h), this.scaleData = j.generateData(60), this.scaleData.reverse(), this.autoScale = !0
  15118. }
  15119. }, c.Particles.Arcade.Emitter.prototype.at = function(a) {
  15120. 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)
  15121. }, Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "width", {
  15122. get: function() {
  15123. return this.area.width
  15124. },
  15125. set: function(a) {
  15126. this.area.width = a
  15127. }
  15128. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "height", {
  15129. get: function() {
  15130. return this.area.height
  15131. },
  15132. set: function(a) {
  15133. this.area.height = a
  15134. }
  15135. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "x", {
  15136. get: function() {
  15137. return this.emitX
  15138. },
  15139. set: function(a) {
  15140. this.emitX = a
  15141. }
  15142. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "y", {
  15143. get: function() {
  15144. return this.emitY
  15145. },
  15146. set: function(a) {
  15147. this.emitY = a
  15148. }
  15149. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "left", {
  15150. get: function() {
  15151. return Math.floor(this.x - this.area.width / 2)
  15152. }
  15153. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "right", {
  15154. get: function() {
  15155. return Math.floor(this.x + this.area.width / 2)
  15156. }
  15157. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "top", {
  15158. get: function() {
  15159. return Math.floor(this.y - this.area.height / 2)
  15160. }
  15161. }), Object.defineProperty(c.Particles.Arcade.Emitter.prototype, "bottom", {
  15162. get: function() {
  15163. return Math.floor(this.y + this.area.height / 2)
  15164. }
  15165. }), void 0 === PIXI.blendModes && (PIXI.blendModes = c.blendModes), void 0 === PIXI.scaleModes && (PIXI.scaleModes = c.scaleModes), void 0 === PIXI.Texture.emptyTexture && (PIXI.Texture.emptyTexture = new PIXI.Texture(new PIXI.BaseTexture)), void 0 === PIXI.DisplayObject._tempMatrix && (PIXI.DisplayObject._tempMatrix = new PIXI.Matrix), void 0 === PIXI.RenderTexture.tempMatrix && (PIXI.RenderTexture.tempMatrix = new PIXI.Matrix), void 0 === PIXI.Graphics.POLY && (PIXI.Graphics.POLY = c.POLYGON, PIXI.Graphics.RECT = c.RECTANGLE, PIXI.Graphics.CIRC = c.CIRCLE, PIXI.Graphics.ELIP = c.ELLIPSE, PIXI.Graphics.RREC = c.ROUNDEDRECTANGLE), "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = c), exports.Phaser = c) : "undefined" != typeof define && define.amd ? define("Phaser", function() {
  15166. return b.Phaser = c
  15167. }()) : b.Phaser = c
  15168. }.call(this);
  15169. //# sourceMappingURL=phaser.map