black-hole.js 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658
  1. (function() {
  2. var a = this,
  3. b = b || {};
  4. b.WEBGL_RENDERER = 0, b.CANVAS_RENDERER = 1, b.VERSION = "v2.0.0", b.blendModes = {
  5. NORMAL: 0,
  6. ADD: 1,
  7. MULTIPLY: 2,
  8. SCREEN: 3,
  9. OVERLAY: 4,
  10. DARKEN: 5,
  11. LIGHTEN: 6,
  12. COLOR_DODGE: 7,
  13. COLOR_BURN: 8,
  14. HARD_LIGHT: 9,
  15. SOFT_LIGHT: 10,
  16. DIFFERENCE: 11,
  17. EXCLUSION: 12,
  18. HUE: 13,
  19. SATURATION: 14,
  20. COLOR: 15,
  21. LUMINOSITY: 16
  22. }, b.scaleModes = {
  23. DEFAULT: 0,
  24. LINEAR: 0,
  25. NEAREST: 1
  26. }, b._UID = 0, "undefined" != typeof Float32Array ? (b.Float32Array = Float32Array, b.Uint16Array = Uint16Array) : (b.Float32Array = Array, b.Uint16Array = Array), b.INTERACTION_FREQUENCY = 30, b.AUTO_PREVENT_DEFAULT = !0, b.PI_2 = 2 * Math.PI, b.RAD_TO_DEG = 180 / Math.PI, b.DEG_TO_RAD = Math.PI / 180, b.RETINA_PREFIX = "@2x", b.dontSayHello = !1, b.defaultRenderOptions = {
  27. view: null,
  28. transparent: !1,
  29. antialias: !1,
  30. preserveDrawingBuffer: !1,
  31. resolution: 1,
  32. clearBeforeRender: !0
  33. }, b.sayHello = function(a) {
  34. if (!b.dontSayHello) {
  35. if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) {
  36. var c = ["%c %c %c Pixi.js " + b.VERSION + " - " + a + " %c %c http://www.play68.com/ %c %c ♥%c♥%c♥ ", "background: #ff66a5", "background: #ff66a5", "color: #ff66a5; background: #030307;", "background: #ff66a5", "background: #ffc3dc", "background: #ff66a5", "color: #ff2424; background: #fff", "color: #ff2424; background: #fff", "color: #ff2424; background: #fff"];
  37. console.log.apply(console, c)
  38. } else window.console && console.log("Pixi.js " + b.VERSION + " - http://www.play68.com/");
  39. b.dontSayHello = !0
  40. }
  41. }, b.Polygon = function(a) {
  42. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
  43. for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
  44. a = c
  45. }
  46. this.closed = !0, this.points = a
  47. }, b.Polygon.prototype.clone = function() {
  48. var a = this.points.slice();
  49. return new b.Polygon(a)
  50. }, b.Polygon.prototype.contains = function(a, b) {
  51. for (var c = !1, d = this.points.length / 2, e = 0, f = d - 1; d > e; f = e++) {
  52. var g = this.points[2 * e],
  53. h = this.points[2 * e + 1],
  54. i = this.points[2 * f],
  55. j = this.points[2 * f + 1],
  56. k = h > b != j > b && (i - g) * (b - h) / (j - h) + g > a;
  57. k && (c = !c)
  58. }
  59. return c
  60. }, b.Polygon.prototype.constructor = b.Polygon, b.Matrix = function() {
  61. this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0
  62. }, b.Matrix.prototype.fromArray = function(a) {
  63. this.a = a[0], this.b = a[1], this.c = a[3], this.d = a[4], this.tx = a[2], this.ty = a[5]
  64. }, b.Matrix.prototype.toArray = function(a) {
  65. this.array || (this.array = new b.Float32Array(9));
  66. var c = this.array;
  67. return a ? (c[0] = this.a, c[1] = this.b, c[2] = 0, c[3] = this.c, c[4] = this.d, c[5] = 0, c[6] = this.tx, c[7] = this.ty, c[8] = 1) : (c[0] = this.a, c[1] = this.c, c[2] = this.tx, c[3] = this.b, c[4] = this.d, c[5] = this.ty, c[6] = 0, c[7] = 0, c[8] = 1), c
  68. }, b.Matrix.prototype.apply = function(a, c) {
  69. return c = c || new b.Point, c.x = this.a * a.x + this.b * a.y + this.tx, c.y = this.c * a.x + this.d * a.y + this.ty, c
  70. }, b.Matrix.prototype.applyInverse = function(a, c) {
  71. c = c || new b.Point;
  72. var d = 1 / (this.a * this.d + this.c * -this.b);
  73. return c.x = this.d * d * a.x + -this.c * d * a.y + (this.ty * this.c - this.tx * this.d) * d, c.y = this.a * d * a.y + -this.b * d * a.x + (-this.ty * this.a + this.tx * this.b) * d, c
  74. }, b.Matrix.prototype.translate = function(a, b) {
  75. return this.tx += a, this.ty += b, this
  76. }, b.Matrix.prototype.scale = function(a, b) {
  77. return this.a *= a, this.d *= b, this.c *= a, this.b *= b, this.tx *= a, this.ty *= b, this
  78. }, b.Matrix.prototype.rotate = function(a) {
  79. var b = Math.cos(a),
  80. c = Math.sin(a),
  81. d = this.a,
  82. e = this.c,
  83. f = this.tx;
  84. 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
  85. }, b.Matrix.prototype.append = function(a) {
  86. var b = this.a,
  87. c = this.b,
  88. d = this.c,
  89. e = this.d;
  90. 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
  91. }, b.Matrix.prototype.identity = function() {
  92. return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this
  93. }, b.identityMatrix = new b.Matrix, b.DisplayObject = function() {
  94. this.position = new b.Point, this.scale = new b.Point(1, 1), this.pivot = new b.Point(0, 0), this.rotation = 0, this.alpha = 1, this.visible = !0, this.hitArea = null, this.buttonMode = !1, this.renderable = !1, this.parent = null, this.stage = null, this.worldAlpha = 1, this._interactive = !1, this.defaultCursor = "pointer", this.worldTransform = new b.Matrix, this._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
  95. }, b.DisplayObject.prototype.constructor = b.DisplayObject, Object.defineProperty(b.DisplayObject.prototype, "interactive", {
  96. get: function() {
  97. return this._interactive
  98. },
  99. set: function(a) {
  100. this._interactive = a, this.stage && (this.stage.dirty = !0)
  101. }
  102. }), Object.defineProperty(b.DisplayObject.prototype, "worldVisible", {
  103. get: function() {
  104. var a = this;
  105. do {
  106. if (!a.visible) return !1;
  107. a = a.parent
  108. } while (a);
  109. return !0
  110. }
  111. }), Object.defineProperty(b.DisplayObject.prototype, "mask", {
  112. get: function() {
  113. return this._mask
  114. },
  115. set: function(a) {
  116. this._mask && (this._mask.isMask = !1), this._mask = a, this._mask && (this._mask.isMask = !0)
  117. }
  118. }), Object.defineProperty(b.DisplayObject.prototype, "filters", {
  119. get: function() {
  120. return this._filters
  121. },
  122. set: function(a) {
  123. if (a) {
  124. for (var b = [], c = 0; c < a.length; c++)
  125. for (var d = a[c].passes, e = 0; e < d.length; e++) b.push(d[e]);
  126. this._filterBlock = {
  127. target: this,
  128. filterPasses: b
  129. }
  130. }
  131. this._filters = a
  132. }
  133. }), Object.defineProperty(b.DisplayObject.prototype, "cacheAsBitmap", {
  134. get: function() {
  135. return this._cacheAsBitmap
  136. },
  137. set: function(a) {
  138. this._cacheAsBitmap !== a && (a ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = a)
  139. }
  140. }), b.DisplayObject.prototype.updateTransform = function() {
  141. var a, c, d, e, f, g, h = this.parent.worldTransform,
  142. i = this.worldTransform;
  143. 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 = h.a * a, i.b = h.b * e, i.c = h.c * a, i.d = h.d * e, 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
  144. }, b.DisplayObject.prototype.getBounds = function(a) {
  145. return a = a, b.EmptyRectangle
  146. }, b.DisplayObject.prototype.getLocalBounds = function() {
  147. return this.getBounds(b.identityMatrix)
  148. }, b.DisplayObject.prototype.setStageReference = function(a) {
  149. this.stage = a, this._interactive && (this.stage.dirty = !0)
  150. }, b.DisplayObject.prototype.generateTexture = function(a, c, d) {
  151. var e = this.getLocalBounds(),
  152. f = new b.RenderTexture(0 | e.width, 0 | e.height, d, c, a);
  153. return b.DisplayObject._tempMatrix.tx = -e.x, b.DisplayObject._tempMatrix.ty = -e.y, f.render(this, b.DisplayObject._tempMatrix), f
  154. }, b.DisplayObject.prototype.updateCache = function() {
  155. this._generateCachedSprite()
  156. }, b.DisplayObject.prototype.toGlobal = function(a) {
  157. return this.updateTransform(), this.worldTransform.apply(a)
  158. }, b.DisplayObject.prototype.toLocal = function(a, b) {
  159. return b && (a = b.toGlobal(a)), this.updateTransform(), this.worldTransform.applyInverse(a)
  160. }, b.DisplayObject.prototype._renderCachedSprite = function(a) {
  161. this._cachedSprite.worldAlpha = this.worldAlpha, a.gl ? b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a) : b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a)
  162. }, b.DisplayObject.prototype._generateCachedSprite = function() {
  163. this._cacheAsBitmap = !1;
  164. var a = this.getLocalBounds();
  165. if (this._cachedSprite) this._cachedSprite.texture.resize(0 | a.width, 0 | a.height);
  166. else {
  167. var c = new b.RenderTexture(0 | a.width, 0 | a.height);
  168. this._cachedSprite = new b.Sprite(c), this._cachedSprite.worldTransform = this.worldTransform
  169. }
  170. var d = this._filters;
  171. 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), this._cachedSprite.anchor.x = -(a.x / a.width), this._cachedSprite.anchor.y = -(a.y / a.height), this._filters = d, this._cacheAsBitmap = !0
  172. }, b.DisplayObject.prototype._destroyCachedSprite = function() {
  173. this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null)
  174. }, b.DisplayObject.prototype._renderWebGL = function(a) {
  175. a = a
  176. }, b.DisplayObject.prototype._renderCanvas = function(a) {
  177. a = a
  178. }, b.DisplayObject._tempMatrix = new b.Matrix, Object.defineProperty(b.DisplayObject.prototype, "x", {
  179. get: function() {
  180. return this.position.x
  181. },
  182. set: function(a) {
  183. this.position.x = a
  184. }
  185. }), Object.defineProperty(b.DisplayObject.prototype, "y", {
  186. get: function() {
  187. return this.position.y
  188. },
  189. set: function(a) {
  190. this.position.y = a
  191. }
  192. }), b.DisplayObjectContainer = function() {
  193. b.DisplayObject.call(this), this.children = []
  194. }, b.DisplayObjectContainer.prototype = Object.create(b.DisplayObject.prototype), b.DisplayObjectContainer.prototype.constructor = b.DisplayObjectContainer, Object.defineProperty(b.DisplayObjectContainer.prototype, "width", {
  195. get: function() {
  196. return this.scale.x * this.getLocalBounds().width
  197. },
  198. set: function(a) {
  199. var b = this.getLocalBounds().width;
  200. this.scale.x = 0 !== b ? a / (b / this.scale.x) : 1, this._width = a
  201. }
  202. }), Object.defineProperty(b.DisplayObjectContainer.prototype, "height", {
  203. get: function() {
  204. return this.scale.y * this.getLocalBounds().height
  205. },
  206. set: function(a) {
  207. var b = this.getLocalBounds().height;
  208. this.scale.y = 0 !== b ? a / (b / this.scale.y) : 1, this._height = a
  209. }
  210. }), b.DisplayObjectContainer.prototype.addChild = function(a) {
  211. return this.addChildAt(a, this.children.length)
  212. }, b.DisplayObjectContainer.prototype.addChildAt = function(a, b) {
  213. 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;
  214. throw new Error(a + "addChildAt: The index " + b + " supplied is out of bounds " + this.children.length)
  215. }, b.DisplayObjectContainer.prototype.swapChildren = function(a, b) {
  216. if (a !== b) {
  217. var c = this.getChildIndex(a),
  218. d = this.getChildIndex(b);
  219. if (0 > c || 0 > d) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
  220. this.children[c] = b, this.children[d] = a
  221. }
  222. }, b.DisplayObjectContainer.prototype.getChildIndex = function(a) {
  223. var b = this.children.indexOf(a);
  224. if (-1 === b) throw new Error("The supplied DisplayObject must be a child of the caller");
  225. return b
  226. }, b.DisplayObjectContainer.prototype.setChildIndex = function(a, b) {
  227. if (0 > b || b >= this.children.length) throw new Error("The supplied index is out of bounds");
  228. var c = this.getChildIndex(a);
  229. this.children.splice(c, 1), this.children.splice(b, 0, a)
  230. }, b.DisplayObjectContainer.prototype.getChildAt = function(a) {
  231. 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");
  232. return this.children[a]
  233. }, b.DisplayObjectContainer.prototype.removeChild = function(a) {
  234. var b = this.children.indexOf(a);
  235. if (-1 !== b) return this.removeChildAt(b)
  236. }, b.DisplayObjectContainer.prototype.removeChildAt = function(a) {
  237. var b = this.getChildAt(a);
  238. return this.stage && b.removeStageReference(), b.parent = void 0, this.children.splice(a, 1), b
  239. }, b.DisplayObjectContainer.prototype.removeChildren = function(a, b) {
  240. var c = a || 0,
  241. d = "number" == typeof b ? b : this.children.length,
  242. e = d - c;
  243. if (e > 0 && d >= e) {
  244. for (var f = this.children.splice(c, e), g = 0; g < f.length; g++) {
  245. var h = f[g];
  246. this.stage && h.removeStageReference(), h.parent = void 0
  247. }
  248. return f
  249. }
  250. if (0 === e && 0 === this.children.length) return [];
  251. throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")
  252. }, b.DisplayObjectContainer.prototype.updateTransform = function() {
  253. if (this.visible && (b.DisplayObject.prototype.updateTransform.call(this), !this._cacheAsBitmap))
  254. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].updateTransform()
  255. }, b.DisplayObjectContainer.prototype.getBounds = function() {
  256. if (0 === this.children.length) return b.EmptyRectangle;
  257. 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++) {
  258. var l = this.children[j];
  259. 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)
  260. }
  261. if (!i) return b.EmptyRectangle;
  262. var m = this._bounds;
  263. return m.x = e, m.y = f, m.width = g - e, m.height = h - f, m
  264. }, b.DisplayObjectContainer.prototype.getLocalBounds = function() {
  265. var a = this.worldTransform;
  266. this.worldTransform = b.identityMatrix;
  267. for (var c = 0, d = this.children.length; d > c; c++) this.children[c].updateTransform();
  268. var e = this.getBounds();
  269. return this.worldTransform = a, e
  270. }, b.DisplayObjectContainer.prototype.setStageReference = function(a) {
  271. this.stage = a, this._interactive && (this.stage.dirty = !0);
  272. for (var b = 0, c = this.children.length; c > b; b++) {
  273. var d = this.children[b];
  274. d.setStageReference(a)
  275. }
  276. }, b.DisplayObjectContainer.prototype.removeStageReference = function() {
  277. for (var a = 0, b = this.children.length; b > a; a++) {
  278. var c = this.children[a];
  279. c.removeStageReference()
  280. }
  281. this._interactive && (this.stage.dirty = !0), this.stage = null
  282. }, b.DisplayObjectContainer.prototype._renderWebGL = function(a) {
  283. if (this.visible && !(this.alpha <= 0)) {
  284. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  285. var b, c;
  286. if (this._mask || this._filters) {
  287. for (this._filters && (a.spriteBatch.flush(), a.filterManager.pushFilter(this._filterBlock)), this._mask && (a.spriteBatch.stop(), a.maskManager.pushMask(this.mask, a), a.spriteBatch.start()), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a);
  288. a.spriteBatch.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), a.spriteBatch.start()
  289. } else
  290. for (b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  291. }
  292. }, b.DisplayObjectContainer.prototype._renderCanvas = function(a) {
  293. if (this.visible !== !1 && 0 !== this.alpha) {
  294. if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
  295. this._mask && a.maskManager.pushMask(this._mask, a);
  296. for (var b = 0, c = this.children.length; c > b; b++) {
  297. var d = this.children[b];
  298. d._renderCanvas(a)
  299. }
  300. this._mask && a.maskManager.popMask(a)
  301. }
  302. }, b.Sprite = function(a) {
  303. b.DisplayObjectContainer.call(this), this.anchor = new b.Point, this.texture = a, this._width = 0, this._height = 0, this.tint = 16777215, this.blendMode = b.blendModes.NORMAL, this.shader = null, a.baseTexture.hasLoaded ? this.onTextureUpdate() : (this.onTextureUpdateBind = this.onTextureUpdate.bind(this), this.texture.on("update", this.onTextureUpdateBind)), this.renderable = !0
  304. }, b.Sprite.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Sprite.prototype.constructor = b.Sprite, Object.defineProperty(b.Sprite.prototype, "width", {
  305. get: function() {
  306. return this.scale.x * this.texture.frame.width
  307. },
  308. set: function(a) {
  309. this.scale.x = a / this.texture.frame.width, this._width = a
  310. }
  311. }), Object.defineProperty(b.Sprite.prototype, "height", {
  312. get: function() {
  313. return this.scale.y * this.texture.frame.height
  314. },
  315. set: function(a) {
  316. this.scale.y = a / this.texture.frame.height, this._height = a
  317. }
  318. }), b.Sprite.prototype.setTexture = function(a) {
  319. this.texture = a, this.cachedTint = 16777215
  320. }, b.Sprite.prototype.onTextureUpdate = function() {
  321. this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height)
  322. }, b.Sprite.prototype.getBounds = function(a) {
  323. var b = this.texture.frame.width,
  324. c = this.texture.frame.height,
  325. d = b * (1 - this.anchor.x),
  326. e = b * -this.anchor.x,
  327. f = c * (1 - this.anchor.y),
  328. g = c * -this.anchor.y,
  329. h = a || this.worldTransform,
  330. i = h.a,
  331. j = h.c,
  332. k = h.b,
  333. l = h.d,
  334. m = h.tx,
  335. n = h.ty,
  336. o = i * e + k * g + m,
  337. p = l * g + j * e + n,
  338. q = i * d + k * g + m,
  339. r = l * g + j * d + n,
  340. s = i * d + k * f + m,
  341. t = l * f + j * d + n,
  342. u = i * e + k * f + m,
  343. v = l * f + j * e + n,
  344. w = -1 / 0,
  345. x = -1 / 0,
  346. y = 1 / 0,
  347. z = 1 / 0;
  348. y = y > o ? o : y, y = y > q ? q : y, y = y > s ? s : y, y = y > u ? u : y, z = z > p ? p : z, z = z > r ? r : z, z = z > t ? t : z, z = z > v ? v : z, w = o > w ? o : w, w = q > w ? q : w, w = s > w ? s : w, w = u > w ? u : w, x = p > x ? p : x, x = r > x ? r : x, x = t > x ? t : x, x = v > x ? v : x;
  349. var A = this._bounds;
  350. return A.x = y, A.width = w - y, A.y = z, A.height = x - z, this._currentBounds = A, A
  351. }, b.Sprite.prototype._renderWebGL = function(a) {
  352. if (this.visible && !(this.alpha <= 0)) {
  353. var b, c;
  354. if (this._mask || this._filters) {
  355. var d = a.spriteBatch;
  356. for (this._filters && (d.flush(), a.filterManager.pushFilter(this._filterBlock)), this._mask && (d.stop(), a.maskManager.pushMask(this.mask, a), d.start()), d.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a);
  357. d.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), d.start()
  358. } else
  359. for (a.spriteBatch.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  360. }
  361. }, b.Sprite.prototype._renderCanvas = function(a) {
  362. if (!(this.visible === !1 || 0 === this.alpha || this.texture.crop.width <= 0 || this.texture.crop.height <= 0)) {
  363. 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) {
  364. var c = this.texture.baseTexture.resolution / a.resolution;
  365. a.context.globalAlpha = this.worldAlpha, 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) : 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), a.smoothProperty && a.scaleMode !== this.texture.baseTexture.scaleMode && (a.scaleMode = this.texture.baseTexture.scaleMode, a.context[a.smoothProperty] = a.scaleMode === b.scaleModes.LINEAR);
  366. var d = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width,
  367. e = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
  368. 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)
  369. }
  370. for (var f = 0, g = this.children.length; g > f; f++) this.children[f]._renderCanvas(a);
  371. this._mask && a.maskManager.popMask(a)
  372. }
  373. }, b.Sprite.fromFrame = function(a) {
  374. var c = b.TextureCache[a];
  375. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache' + this);
  376. return new b.Sprite(c)
  377. }, b.Sprite.fromImage = function(a, c, d) {
  378. var e = b.Texture.fromImage(a, c, d);
  379. return new b.Sprite(e)
  380. }, b.SpriteBatch = function(a) {
  381. b.DisplayObjectContainer.call(this), this.textureThing = a, this.ready = !1
  382. }, b.SpriteBatch.prototype = Object.create(b.DisplayObjectContainer.prototype), b.SpriteBatch.prototype.constructor = b.SpriteBatch, b.SpriteBatch.prototype.initWebGL = function(a) {
  383. this.fastSpriteBatch = new b.WebGLFastSpriteBatch(a), this.ready = !0
  384. }, b.SpriteBatch.prototype.updateTransform = function() {
  385. b.DisplayObject.prototype.updateTransform.call(this)
  386. }, b.SpriteBatch.prototype._renderWebGL = function(a) {
  387. !this.visible || this.alpha <= 0 || !this.children.length || (this.ready || this.initWebGL(a.gl), a.spriteBatch.stop(), a.shaderManager.setShader(a.shaderManager.fastShader), this.fastSpriteBatch.begin(this, a), this.fastSpriteBatch.render(this), a.spriteBatch.start())
  388. }, b.SpriteBatch.prototype._renderCanvas = function(a) {
  389. if (this.visible && !(this.alpha <= 0) && this.children.length) {
  390. var c = a.context;
  391. c.globalAlpha = this.worldAlpha, b.DisplayObject.prototype.updateTransform.call(this);
  392. for (var d = this.worldTransform, e = !0, f = 0; f < this.children.length; f++) {
  393. var g = this.children[f];
  394. if (g.visible) {
  395. var h = g.texture,
  396. i = h.frame;
  397. if (c.globalAlpha = this.worldAlpha * g.alpha, g.rotation % (2 * Math.PI) === 0) e && (c.setTransform(d.a, d.b, d.c, d.d, d.tx, d.ty), e = !1), c.drawImage(h.baseTexture.source, i.x, i.y, i.width, i.height, g.anchor.x * -i.width * g.scale.x + g.position.x + .5 | 0, g.anchor.y * -i.height * g.scale.y + g.position.y + .5 | 0, i.width * g.scale.x, i.height * g.scale.y);
  398. else {
  399. e || (e = !0), b.DisplayObject.prototype.updateTransform.call(g);
  400. var j = g.worldTransform;
  401. a.roundPixels ? c.setTransform(j.a, j.b, j.c, j.d, 0 | j.tx, 0 | j.ty) : c.setTransform(j.a, j.b, j.c, j.d, j.tx, j.ty), c.drawImage(h.baseTexture.source, i.x, i.y, i.width, i.height, g.anchor.x * -i.width + .5 | 0, g.anchor.y * -i.height + .5 | 0, i.width, i.height)
  402. }
  403. }
  404. }
  405. }
  406. }, b.FilterBlock = function() {
  407. this.visible = !0, this.renderable = !0
  408. }, b.FilterBlock.prototype.constructor = b.FilterBlock, b.Text = function(a, c) {
  409. 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)
  410. }, b.Text.prototype = Object.create(b.Sprite.prototype), b.Text.prototype.constructor = b.Text, Object.defineProperty(b.Text.prototype, "width", {
  411. get: function() {
  412. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width
  413. },
  414. set: function(a) {
  415. this.scale.x = a / this.texture.frame.width, this._width = a
  416. }
  417. }), Object.defineProperty(b.Text.prototype, "height", {
  418. get: function() {
  419. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height
  420. },
  421. set: function(a) {
  422. this.scale.y = a / this.texture.frame.height, this._height = a
  423. }
  424. }), b.Text.prototype.setStyle = function(a) {
  425. 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
  426. }, b.Text.prototype.setText = function(a) {
  427. this.text = a.toString() || " ", this.dirty = !0
  428. }, b.Text.prototype.updateText = function() {
  429. this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
  430. var a = this.text;
  431. this.style.wordWrap && (a = this.wordWrap(this.text));
  432. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
  433. var g = this.context.measureText(b[f]).width;
  434. c[f] = g, d = Math.max(d, g)
  435. }
  436. var h = d + this.style.strokeThickness;
  437. this.style.dropShadow && (h += this.style.dropShadowDistance), this.canvas.width = (h + this.context.lineWidth) * this.resolution;
  438. var i = e.fontSize + this.style.strokeThickness,
  439. j = i * b.length;
  440. 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", this.context.lineJoin = "round";
  441. var k, l;
  442. if (this.style.dropShadow) {
  443. this.context.fillStyle = this.style.dropShadowColor;
  444. var m = Math.sin(this.style.dropShadowAngle) * this.style.dropShadowDistance,
  445. n = Math.cos(this.style.dropShadowAngle) * this.style.dropShadowDistance;
  446. 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)
  447. }
  448. 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);
  449. this.updateTexture()
  450. }, b.Text.prototype.updateTexture = function() {
  451. 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()
  452. }, b.Text.prototype._renderWebGL = function(a) {
  453. this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderWebGL.call(this, a)
  454. }, b.Text.prototype._renderCanvas = function(a) {
  455. this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderCanvas.call(this, a)
  456. }, b.Text.prototype.determineFontProperties = function(a) {
  457. var c = b.Text.fontPropertiesCache[a];
  458. if (!c) {
  459. c = {};
  460. var d = b.Text.fontPropertiesCanvas,
  461. e = b.Text.fontPropertiesContext;
  462. e.font = a;
  463. var f = Math.ceil(e.measureText("|Mq").width),
  464. g = Math.ceil(e.measureText("M").width),
  465. h = 2 * g;
  466. 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("|Mq", 0, g);
  467. var i, j, k = e.getImageData(0, 0, f, h).data,
  468. l = k.length,
  469. m = 4 * f,
  470. n = 0,
  471. o = !1;
  472. for (i = 0; g > i; i++) {
  473. for (j = 0; m > j; j += 4)
  474. if (255 !== k[n + j]) {
  475. o = !0;
  476. break
  477. }
  478. if (o) break;
  479. n += m
  480. }
  481. for (c.ascent = g - i, n = l - m, o = !1, i = h; i > g; i--) {
  482. for (j = 0; m > j; j += 4)
  483. if (255 !== k[n + j]) {
  484. o = !0;
  485. break
  486. }
  487. if (o) break;
  488. n -= m
  489. }
  490. c.descent = i - g, c.fontSize = c.ascent + c.descent, b.Text.fontPropertiesCache[a] = c
  491. }
  492. return c
  493. }, b.Text.prototype.wordWrap = function(a) {
  494. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  495. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  496. var h = this.context.measureText(f[g]).width,
  497. i = h + this.context.measureText(" ").width;
  498. 0 === g || i > e ? (g > 0 && (b += "\n"), b += f[g], e = this.style.wordWrapWidth - h) : (e -= i, b += " " + f[g])
  499. }
  500. d < c.length - 1 && (b += "\n")
  501. }
  502. return b
  503. }, b.Text.prototype.destroy = function(a) {
  504. this.context = null, this.canvas = null, this.texture.destroy(void 0 === a ? !0 : a)
  505. }, b.Text.fontPropertiesCache = {}, b.Text.fontPropertiesCanvas = document.createElement("canvas"), b.Text.fontPropertiesContext = b.Text.fontPropertiesCanvas.getContext("2d"), b.BitmapText = function(a, c) {
  506. b.DisplayObjectContainer.call(this), this.textWidth = 0, this.textHeight = 0, this._pool = [], this.setText(a), this.setStyle(c), this.updateText(), this.dirty = !1
  507. }, b.BitmapText.prototype = Object.create(b.DisplayObjectContainer.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setText = function(a) {
  508. this.text = a || " ", this.dirty = !0
  509. }, b.BitmapText.prototype.setStyle = function(a) {
  510. a = a || {}, a.align = a.align || "left", this.style = a;
  511. var c = a.font.split(" ");
  512. 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
  513. }, b.BitmapText.prototype.updateText = function() {
  514. for (var a = b.BitmapText.fonts[this.fontName], c = new b.Point, d = null, e = [], f = 0, g = [], h = 0, i = this.fontSize / a.size, j = 0; j < this.text.length; j++) {
  515. var k = this.text.charCodeAt(j);
  516. if (/(?:\r\n|\r|\n)/.test(this.text.charAt(j))) g.push(c.x), f = Math.max(f, c.x), h++, c.x = 0, c.y += a.lineHeight, d = null;
  517. else {
  518. var l = a.chars[k];
  519. l && (d && l.kerning[d] && (c.x += l.kerning[d]), e.push({
  520. texture: l.texture,
  521. line: h,
  522. charCode: k,
  523. position: new b.Point(c.x + l.xOffset, c.y + l.yOffset)
  524. }), c.x += l.xAdvance, d = k)
  525. }
  526. }
  527. g.push(c.x), f = Math.max(f, c.x);
  528. var m = [];
  529. for (j = 0; h >= j; j++) {
  530. var n = 0;
  531. "right" === this.style.align ? n = f - g[j] : "center" === this.style.align && (n = (f - g[j]) / 2), m.push(n)
  532. }
  533. var o = this.children.length,
  534. p = e.length,
  535. q = this.tint || 16777215;
  536. for (j = 0; p > j; j++) {
  537. var r = o > j ? this.children[j] : this._pool.pop();
  538. r ? r.setTexture(e[j].texture) : r = new b.Sprite(e[j].texture), r.position.x = (e[j].position.x + m[e[j].line]) * i, r.position.y = e[j].position.y * i, r.scale.x = r.scale.y = i, r.tint = q, r.parent || this.addChild(r)
  539. }
  540. for (; this.children.length > p;) {
  541. var s = this.getChildAt(this.children.length - 1);
  542. this._pool.push(s), this.removeChild(s)
  543. }
  544. this.textWidth = f * i, this.textHeight = (c.y + a.lineHeight) * i
  545. }, b.BitmapText.prototype.updateTransform = function() {
  546. this.dirty && (this.updateText(), this.dirty = !1), b.DisplayObjectContainer.prototype.updateTransform.call(this)
  547. }, b.BitmapText.fonts = {}, b.Stage = function(a) {
  548. b.DisplayObjectContainer.call(this), this.worldTransform = new b.Matrix, this.interactive = !0, this.interactionManager = new b.InteractionManager(this), this.dirty = !0, this.stage = this, this.stage.hitArea = new b.Rectangle(0, 0, 1e5, 1e5), this.setBackgroundColor(a)
  549. }, b.Stage.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.setInteractionDelegate = function(a) {
  550. this.interactionManager.setTargetDomElement(a)
  551. }, b.Stage.prototype.updateTransform = function() {
  552. this.worldAlpha = 1;
  553. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].updateTransform();
  554. this.dirty && (this.dirty = !1, this.interactionManager.dirty = !0), this.interactive && this.interactionManager.update()
  555. }, b.Stage.prototype.setBackgroundColor = function(a) {
  556. this.backgroundColor = a || 0, this.backgroundColorSplit = b.hex2rgb(this.backgroundColor);
  557. var c = this.backgroundColor.toString(16);
  558. c = "000000".substr(0, 6 - c.length) + c, this.backgroundColorString = "#" + c
  559. }, b.Stage.prototype.getMousePosition = function() {
  560. return this.interactionManager.mouse.global
  561. },
  562. function(a) {
  563. for (var b = 0, c = ["ms", "moz", "webkit", "o"], d = 0; d < c.length && !a.requestAnimationFrame; ++d) a.requestAnimationFrame = a[c[d] + "RequestAnimationFrame"], a.cancelAnimationFrame = a[c[d] + "CancelAnimationFrame"] || a[c[d] + "CancelRequestAnimationFrame"];
  564. a.requestAnimationFrame || (a.requestAnimationFrame = function(c) {
  565. var d = (new Date).getTime(),
  566. e = Math.max(0, 16 - (d - b)),
  567. f = a.setTimeout(function() {
  568. c(d + e)
  569. }, e);
  570. return b = d + e, f
  571. }), a.cancelAnimationFrame || (a.cancelAnimationFrame = function(a) {
  572. clearTimeout(a)
  573. }), a.requestAnimFrame = a.requestAnimationFrame
  574. }(this), b.hex2rgb = function(a) {
  575. return [(a >> 16 & 255) / 255, (a >> 8 & 255) / 255, (255 & a) / 255]
  576. }, b.rgb2hex = function(a) {
  577. return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
  578. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  579. return function(a) {
  580. function b() {
  581. for (var d = arguments.length, f = new Array(d); d--;) f[d] = arguments[d];
  582. return f = e.concat(f), c.apply(this instanceof b ? this : a, f)
  583. }
  584. var c = this,
  585. d = arguments.length - 1,
  586. e = [];
  587. if (d > 0)
  588. for (e.length = d; d--;) e[d] = arguments[d + 1];
  589. if ("function" != typeof c) throw new TypeError;
  590. return b.prototype = function f(a) {
  591. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  592. }(c.prototype), b
  593. }
  594. }()), b.AjaxRequest = function() {
  595. var a = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Microsoft.XMLHTTP"];
  596. if (!window.ActiveXObject) return window.XMLHttpRequest ? new window.XMLHttpRequest : !1;
  597. for (var b = 0; b < a.length; b++) try {
  598. return new window.ActiveXObject(a[b])
  599. } catch (c) {}
  600. }, b.canUseNewCanvasBlendModes = function() {
  601. if ("undefined" == typeof document) return !1;
  602. var a = document.createElement("canvas");
  603. a.width = 1, a.height = 1;
  604. var b = a.getContext("2d");
  605. return b.fillStyle = "#000", b.fillRect(0, 0, 1, 1), b.globalCompositeOperation = "multiply", b.fillStyle = "#fff", b.fillRect(0, 0, 1, 1), 0 === b.getImageData(0, 0, 1, 1).data[0]
  606. }, b.getNextPowerOfTwo = function(a) {
  607. if (a > 0 && 0 === (a & a - 1)) return a;
  608. for (var b = 1; a > b;) b <<= 1;
  609. return b
  610. }, b.EventTarget = {
  611. call: function(a) {
  612. a && (a = a.prototype || a, b.EventTarget.mixin(a))
  613. },
  614. mixin: function(a) {
  615. a.listeners = function(a) {
  616. return this._listeners = this._listeners || {}, this._listeners[a] ? this._listeners[a].slice() : []
  617. }, a.emit = a.dispatchEvent = function(a, c) {
  618. if (this._listeners = this._listeners || {}, "object" == typeof a && (c = a, a = a.type), c && c.__isEventObject === !0 || (c = new b.Event(this, a, c)), this._listeners && this._listeners[a]) {
  619. var d, e = this._listeners[a],
  620. f = e.length,
  621. g = e[0];
  622. for (d = 0; f > d; g = e[++d])
  623. if (g.call(this, c), c.stoppedImmediate) return this;
  624. if (c.stopped) return this
  625. }
  626. return this.parent && this.parent.emit && this.parent.emit.call(this.parent, a, c), this
  627. }, a.on = a.addEventListener = function(a, b) {
  628. return this._listeners = this._listeners || {}, (this._listeners[a] = this._listeners[a] || []).push(b), this
  629. }, a.once = function(a, b) {
  630. function c() {
  631. b.apply(d.off(a, c), arguments)
  632. }
  633. this._listeners = this._listeners || {};
  634. var d = this;
  635. return c._originalHandler = b, this.on(a, c)
  636. }, a.off = a.removeEventListener = function(a, b) {
  637. if (this._listeners = this._listeners || {}, !this._listeners[a]) return this;
  638. for (var c = this._listeners[a], d = b ? c.length : 0; d-- > 0;)(c[d] === b || c[d]._originalHandler === b) && c.splice(d, 1);
  639. return 0 === c.length && delete this._listeners[a], this
  640. }, a.removeAllListeners = function(a) {
  641. return this._listeners = this._listeners || {}, this._listeners[a] ? (delete this._listeners[a], this) : this
  642. }
  643. }
  644. }, b.Event = function(a, b, c) {
  645. this.__isEventObject = !0, this.stopped = !1, this.stoppedImmediate = !1, this.target = a, this.type = b, this.data = c, this.content = c, this.timeStamp = Date.now()
  646. }, b.Event.prototype.stopPropagation = function() {
  647. this.stopped = !0
  648. }, b.Event.prototype.stopImmediatePropagation = function() {
  649. this.stoppedImmediate = !0
  650. }, b.PolyK = {}, b.PolyK.Triangulate = function(a) {
  651. var c = !0,
  652. d = a.length >> 1;
  653. if (3 > d) return [];
  654. for (var e = [], f = [], g = 0; d > g; g++) f.push(g);
  655. g = 0;
  656. for (var h = d; h > 3;) {
  657. var i = f[(g + 0) % h],
  658. j = f[(g + 1) % h],
  659. k = f[(g + 2) % h],
  660. l = a[2 * i],
  661. m = a[2 * i + 1],
  662. n = a[2 * j],
  663. o = a[2 * j + 1],
  664. p = a[2 * k],
  665. q = a[2 * k + 1],
  666. r = !1;
  667. if (b.PolyK._convex(l, m, n, o, p, q, c)) {
  668. r = !0;
  669. for (var s = 0; h > s; s++) {
  670. var t = f[s];
  671. if (t !== i && t !== j && t !== k && b.PolyK._PointInTriangle(a[2 * t], a[2 * t + 1], l, m, n, o, p, q)) {
  672. r = !1;
  673. break
  674. }
  675. }
  676. }
  677. if (r) e.push(i, j, k), f.splice((g + 1) % h, 1), h--, g = 0;
  678. else if (g++ > 3 * h) {
  679. if (!c) return window.console.log("PIXI Warning: shape too complex to fill"), [];
  680. for (e = [], f = [], g = 0; d > g; g++) f.push(g);
  681. g = 0, h = d, c = !1
  682. }
  683. }
  684. return e.push(f[0], f[1], f[2]), e
  685. }, b.PolyK._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  686. var i = g - c,
  687. j = h - d,
  688. k = e - c,
  689. l = f - d,
  690. m = a - c,
  691. n = b - d,
  692. o = i * i + j * j,
  693. p = i * k + j * l,
  694. q = i * m + j * n,
  695. r = k * k + l * l,
  696. s = k * m + l * n,
  697. t = 1 / (o * r - p * p),
  698. u = (r * q - p * s) * t,
  699. v = (o * s - p * q) * t;
  700. return u >= 0 && v >= 0 && 1 > u + v
  701. }, b.PolyK._convex = function(a, b, c, d, e, f, g) {
  702. return (b - d) * (e - c) + (c - a) * (f - d) >= 0 === g
  703. }, b.initDefaultShaders = function() {}, b.CompileVertexShader = function(a, c) {
  704. return b._CompileShader(a, c, a.VERTEX_SHADER)
  705. }, b.CompileFragmentShader = function(a, c) {
  706. return b._CompileShader(a, c, a.FRAGMENT_SHADER)
  707. }, b._CompileShader = function(a, b, c) {
  708. var d = b.join("\n"),
  709. e = a.createShader(c);
  710. return a.shaderSource(e, d), a.compileShader(e), a.getShaderParameter(e, a.COMPILE_STATUS) ? e : (window.console.log(a.getShaderInfoLog(e)), null)
  711. }, b.compileProgram = function(a, c, d) {
  712. var e = b.CompileFragmentShader(a, d),
  713. f = b.CompileVertexShader(a, c),
  714. g = a.createProgram();
  715. 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
  716. }, b.PixiShader = function(a) {
  717. 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()
  718. }, b.PixiShader.prototype.constructor = b.PixiShader, b.PixiShader.prototype.init = function() {
  719. var a = this.gl,
  720. c = b.compileProgram(a, this.vertexSrc || b.PixiShader.defaultVertexSrc, this.fragmentSrc);
  721. a.useProgram(c), this.uSampler = a.getUniformLocation(c, "uSampler"), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.dimensions = a.getUniformLocation(c, "dimensions"), this.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];
  722. for (var d in this.uniforms) this.uniforms[d].uniformLocation = a.getUniformLocation(c, d);
  723. this.initUniforms(), this.program = c
  724. }, b.PixiShader.prototype.initUniforms = function() {
  725. this.textureCount = 1;
  726. var a, b = this.gl;
  727. for (var c in this.uniforms) {
  728. a = this.uniforms[c];
  729. var d = a.type;
  730. "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)
  731. }
  732. }, b.PixiShader.prototype.initSampler2D = function(a) {
  733. if (a.value && a.value.baseTexture && a.value.baseTexture.hasLoaded) {
  734. var b = this.gl;
  735. if (b.activeTexture(b["TEXTURE" + this.textureCount]), b.bindTexture(b.TEXTURE_2D, a.value.baseTexture._glTextures[b.id]), a.textureData) {
  736. var c = a.textureData,
  737. d = c.magFilter ? c.magFilter : b.LINEAR,
  738. e = c.minFilter ? c.minFilter : b.LINEAR,
  739. f = c.wrapS ? c.wrapS : b.CLAMP_TO_EDGE,
  740. g = c.wrapT ? c.wrapT : b.CLAMP_TO_EDGE,
  741. h = c.luminance ? b.LUMINANCE : b.RGBA;
  742. if (c.repeat && (f = b.REPEAT, g = b.REPEAT), b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL, !!c.flipY), c.width) {
  743. var i = c.width ? c.width : 512,
  744. j = c.height ? c.height : 2,
  745. k = c.border ? c.border : 0;
  746. b.texImage2D(b.TEXTURE_2D, 0, h, i, j, k, h, b.UNSIGNED_BYTE, null)
  747. } else b.texImage2D(b.TEXTURE_2D, 0, h, b.RGBA, b.UNSIGNED_BYTE, a.value.baseTexture.source);
  748. 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)
  749. }
  750. b.uniform1i(a.uniformLocation, this.textureCount), a._init = !0, this.textureCount++
  751. }
  752. }, b.PixiShader.prototype.syncUniforms = function() {
  753. this.textureCount = 1;
  754. var a, c = this.gl;
  755. 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.defaultRenderer.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))
  756. }, b.PixiShader.prototype.destroy = function() {
  757. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  758. }, 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;", " vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;", " vColor = vec4(color * aColor.x, aColor.x);", "}"], b.PixiFastShader = function(a) {
  759. 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()
  760. }, b.PixiFastShader.prototype.constructor = b.PixiFastShader, b.PixiFastShader.prototype.init = function() {
  761. var a = this.gl,
  762. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  763. 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
  764. }, b.PixiFastShader.prototype.destroy = function() {
  765. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  766. }, b.StripShader = function(a) {
  767. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec2 vTextureCoord;", "uniform float alpha;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", "}"], this.init()
  768. }, b.StripShader.prototype.constructor = b.StripShader, b.StripShader.prototype.init = function() {
  769. var a = this.gl,
  770. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  771. 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
  772. }, b.StripShader.prototype.destroy = function() {
  773. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  774. }, b.PrimitiveShader = function(a) {
  775. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec4 aColor;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform float alpha;", "uniform vec3 tint;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vColor = aColor * vec4(tint * alpha, alpha);", "}"], this.init()
  776. }, b.PrimitiveShader.prototype.constructor = b.PrimitiveShader, b.PrimitiveShader.prototype.init = function() {
  777. var a = this.gl,
  778. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  779. a.useProgram(c), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.tintColor = a.getUniformLocation(c, "tint"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.colorAttribute = a.getAttribLocation(c, "aColor"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = a.getUniformLocation(c, "translationMatrix"), this.alpha = a.getUniformLocation(c, "alpha"), this.program = c
  780. }, b.PrimitiveShader.prototype.destroy = function() {
  781. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  782. }, b.ComplexPrimitiveShader = function(a) {
  783. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform vec3 tint;", "uniform float alpha;", "uniform vec3 color;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vColor = vec4(color * alpha * tint, alpha);", "}"], this.init()
  784. }, b.ComplexPrimitiveShader.prototype.constructor = b.ComplexPrimitiveShader, b.ComplexPrimitiveShader.prototype.init = function() {
  785. var a = this.gl,
  786. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  787. a.useProgram(c), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.tintColor = a.getUniformLocation(c, "tint"), this.color = a.getUniformLocation(c, "color"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = a.getUniformLocation(c, "translationMatrix"), this.alpha = a.getUniformLocation(c, "alpha"), this.program = c
  788. }, b.ComplexPrimitiveShader.prototype.destroy = function() {
  789. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  790. }, b.WebGLGraphics = function() {}, b.WebGLGraphics.renderGraphics = function(a, c) {
  791. var d, e = c.gl,
  792. f = c.projection,
  793. g = c.offset,
  794. h = c.shaderManager.primitiveShader;
  795. a.dirty && b.WebGLGraphics.updateGraphics(a, e);
  796. 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.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))
  797. }, b.WebGLGraphics.updateGraphics = function(a, c) {
  798. var d = a._webGL[c.id];
  799. d || (d = a._webGL[c.id] = {
  800. lastIndex: 0,
  801. data: [],
  802. gl: c
  803. }), a.dirty = !1;
  804. var e;
  805. if (a.clearDirty) {
  806. for (a.clearDirty = !1, e = 0; e < d.data.length; e++) {
  807. var f = d.data[e];
  808. f.reset(), b.WebGLGraphics.graphicsDataPool.push(f)
  809. }
  810. d.data = [], d.lastIndex = 0
  811. }
  812. var g;
  813. for (e = d.lastIndex; e < a.graphicsData.length; e++) {
  814. var h = a.graphicsData[e];
  815. h.type === b.Graphics.POLY ? (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 && (h.points.length > 10 ? (g = b.WebGLGraphics.switchMode(d, 1), b.WebGLGraphics.buildComplexPoly(h, g)) : (g = b.WebGLGraphics.switchMode(d, 0), b.WebGLGraphics.buildPoly(h, g))), h.lineWidth > 0 && (g = b.WebGLGraphics.switchMode(d, 0), b.WebGLGraphics.buildLine(h, g))) : (g = b.WebGLGraphics.switchMode(d, 0), h.type === b.Graphics.RECT ? b.WebGLGraphics.buildRectangle(h, g) : h.type === b.Graphics.CIRC || h.type === b.Graphics.ELIP ? b.WebGLGraphics.buildCircle(h, g) : h.type === b.Graphics.RREC && b.WebGLGraphics.buildRoundedRectangle(h, g)), d.lastIndex++
  816. }
  817. for (e = 0; e < d.data.length; e++) g = d.data[e], g.dirty && g.upload()
  818. }, b.WebGLGraphics.switchMode = function(a, c) {
  819. var d;
  820. 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
  821. }, b.WebGLGraphics.buildRectangle = function(a, c) {
  822. var d = a.shape,
  823. e = d.x,
  824. f = d.y,
  825. g = d.width,
  826. h = d.height;
  827. if (a.fill) {
  828. var i = b.hex2rgb(a.fillColor),
  829. j = a.fillAlpha,
  830. k = i[0] * j,
  831. l = i[1] * j,
  832. m = i[2] * j,
  833. n = c.points,
  834. o = c.indices,
  835. p = n.length / 6;
  836. 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)
  837. }
  838. if (a.lineWidth) {
  839. var q = a.points;
  840. a.points = [e, f, e + g, f, e + g, f + h, e, f + h, e, f], b.WebGLGraphics.buildLine(a, c), a.points = q
  841. }
  842. }, b.WebGLGraphics.buildRoundedRectangle = function(a, c) {
  843. var d = a.shape.points,
  844. e = d[0],
  845. f = d[1],
  846. g = d[2],
  847. h = d[3],
  848. i = d[4],
  849. j = [];
  850. 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) {
  851. var k = b.hex2rgb(a.fillColor),
  852. l = a.fillAlpha,
  853. m = k[0] * l,
  854. n = k[1] * l,
  855. o = k[2] * l,
  856. p = c.points,
  857. q = c.indices,
  858. r = p.length / 6,
  859. s = b.PolyK.Triangulate(j),
  860. t = 0;
  861. 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);
  862. for (t = 0; t < j.length; t++) p.push(j[t], j[++t], m, n, o, l)
  863. }
  864. if (a.lineWidth) {
  865. var u = a.points;
  866. a.points = j, b.WebGLGraphics.buildLine(a, c), a.points = u
  867. }
  868. }, b.WebGLGraphics.quadraticBezierCurve = function(a, b, c, d, e, f) {
  869. function g(a, b, c) {
  870. var d = b - a;
  871. return a + d * c
  872. }
  873. 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);
  874. return o
  875. }, b.WebGLGraphics.buildCircle = function(a, c) {
  876. var d, e, f = a.shape,
  877. g = f.x,
  878. h = f.y;
  879. a.type === b.Graphics.CIRC ? (d = f.radius, e = f.radius) : (d = f.width, e = f.height);
  880. var i = 40,
  881. j = 2 * Math.PI / i,
  882. k = 0;
  883. if (a.fill) {
  884. var l = b.hex2rgb(a.fillColor),
  885. m = a.fillAlpha,
  886. n = l[0] * m,
  887. o = l[1] * m,
  888. p = l[2] * m,
  889. q = c.points,
  890. r = c.indices,
  891. s = q.length / 6;
  892. 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++);
  893. r.push(s - 1)
  894. }
  895. if (a.lineWidth) {
  896. var t = a.points;
  897. for (a.points = [], k = 0; i + 1 > k; k++) a.points.push(g + Math.sin(j * k) * d, h + Math.cos(j * k) * e);
  898. b.WebGLGraphics.buildLine(a, c), a.points = t
  899. }
  900. }, b.WebGLGraphics.buildLine = function(a, c) {
  901. var d = 0,
  902. e = a.points;
  903. if (0 !== e.length) {
  904. if (a.lineWidth % 2)
  905. for (d = 0; d < e.length; d++) e[d] += .5;
  906. var f = new b.Point(e[0], e[1]),
  907. g = new b.Point(e[e.length - 2], e[e.length - 1]);
  908. if (f.x === g.x && f.y === g.y) {
  909. e = e.slice(), e.pop(), e.pop(), g = new b.Point(e[e.length - 2], e[e.length - 1]);
  910. var h = g.x + .5 * (f.x - g.x),
  911. i = g.y + .5 * (f.y - g.y);
  912. e.unshift(h, i), e.push(h, i)
  913. }
  914. 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,
  915. H = c.indices,
  916. I = e.length / 2,
  917. J = e.length,
  918. K = G.length / 6,
  919. L = a.lineWidth / 2,
  920. M = b.hex2rgb(a.lineColor),
  921. N = a.lineAlpha,
  922. O = M[0] * N,
  923. P = M[1] * N,
  924. Q = M[2] * N;
  925. 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)));
  926. 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++);
  927. H.push(K - 1)
  928. }
  929. }, b.WebGLGraphics.buildComplexPoly = function(a, c) {
  930. var d = a.points.slice();
  931. if (!(d.length < 6)) {
  932. var e = c.indices;
  933. c.points = d, c.alpha = a.fillAlpha, c.color = b.hex2rgb(a.fillColor);
  934. 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;
  935. d.push(h, j, i, j, i, k, h, k);
  936. var m = d.length / 2;
  937. for (l = 0; m > l; l++) e.push(l)
  938. }
  939. }, b.WebGLGraphics.buildPoly = function(a, c) {
  940. var d = a.points;
  941. if (!(d.length < 6)) {
  942. var e = c.points,
  943. f = c.indices,
  944. g = d.length / 2,
  945. h = b.hex2rgb(a.fillColor),
  946. i = a.fillAlpha,
  947. j = h[0] * i,
  948. k = h[1] * i,
  949. l = h[2] * i,
  950. m = b.PolyK.Triangulate(d),
  951. n = e.length / 6,
  952. o = 0;
  953. 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);
  954. for (o = 0; g > o; o++) e.push(d[2 * o], d[2 * o + 1], j, k, l, i)
  955. }
  956. }, b.WebGLGraphics.graphicsDataPool = [], b.WebGLGraphicsData = function(a) {
  957. this.gl = a, this.color = [0, 0, 0], this.points = [], this.indices = [], this.lastIndex = 0, this.buffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.mode = 1, this.alpha = 1, this.dirty = !0
  958. }, b.WebGLGraphicsData.prototype.reset = function() {
  959. this.points = [], this.indices = [], this.lastIndex = 0
  960. }, b.WebGLGraphicsData.prototype.upload = function() {
  961. var a = this.gl;
  962. this.glPoints = new Float32Array(this.points), a.bindBuffer(a.ARRAY_BUFFER, this.buffer), a.bufferData(a.ARRAY_BUFFER, this.glPoints, a.STATIC_DRAW), this.glIndicies = new Uint16Array(this.indices), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, this.glIndicies, a.STATIC_DRAW), this.dirty = !1
  963. }, b.glContexts = [], b.WebGLRenderer = function(a, c, d) {
  964. if (d)
  965. for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
  966. else d = b.defaultRenderOptions;
  967. b.defaultRenderer || (b.sayHello("webGL"), b.defaultRenderer = this), this.type = b.WEBGL_RENDERER, this.resolution = d.resolution, this.transparent = d.transparent, 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 = {
  968. alpha: this.transparent,
  969. antialias: d.antialias,
  970. premultipliedAlpha: this.transparent && "notMultiplied" !== this.transparent,
  971. stencil: !0,
  972. preserveDrawingBuffer: d.preserveDrawingBuffer
  973. }, 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()
  974. }, b.WebGLRenderer.prototype.constructor = b.WebGLRenderer, b.WebGLRenderer.prototype.initContext = function() {
  975. var a = this.view.getContext("webgl", this._contextOptions) || this.view.getContext("experimental-webgl", this._contextOptions);
  976. if (this.gl = a, !a) throw new Error("This browser does not support webGL. Try using the canvas renderer");
  977. this.glContextId = a.id = b.WebGLRenderer.glContextId++, b.glContexts[this.glContextId] = a, 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)
  978. }, b.WebGLRenderer.prototype.render = function(a) {
  979. if (!this.contextLost) {
  980. this.__stage !== a && (a.interactive && a.interactionManager.removeEvents(), this.__stage = a), a.updateTransform();
  981. var b = this.gl;
  982. a._interactive ? a._interactiveEventsAdded || (a._interactiveEventsAdded = !0, a.interactionManager.setTarget(this)) : a._interactiveEventsAdded && (a._interactiveEventsAdded = !1, a.interactionManager.setTarget(this)), 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)
  983. }
  984. }, b.WebGLRenderer.prototype.renderDisplayObject = function(a, c, d) {
  985. this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL), this.renderSession.drawCount = 0, 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()
  986. }, b.WebGLRenderer.prototype.resize = function(a, b) {
  987. this.width = a * this.resolution, this.height = b * this.resolution, this.view.width = this.width, this.view.height = this.height, 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
  988. }, b.WebGLRenderer.prototype.updateTexture = function(a) {
  989. if (a.hasLoaded) {
  990. var c = this.gl;
  991. 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), 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]
  992. }
  993. }, b.WebGLRenderer.prototype.handleContextLost = function(a) {
  994. a.preventDefault(), this.contextLost = !0
  995. }, b.WebGLRenderer.prototype.handleContextRestored = function() {
  996. this.initContext();
  997. for (var a in b.TextureCache) {
  998. var c = b.TextureCache[a].baseTexture;
  999. c._glTextures = []
  1000. }
  1001. this.contextLost = !1
  1002. }, b.WebGLRenderer.prototype.destroy = function() {
  1003. this.view.off("webglcontextlost", this.contextLostBound), this.view.off("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
  1004. }, b.WebGLRenderer.prototype.mapBlendModes = function() {
  1005. var a = this.gl;
  1006. 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])
  1007. }, b.WebGLRenderer.glContextId = 0, b.WebGLBlendModeManager = function() {
  1008. this.currentBlendMode = 99999
  1009. }, b.WebGLBlendModeManager.prototype.constructor = b.WebGLBlendModeManager, b.WebGLBlendModeManager.prototype.setContext = function(a) {
  1010. this.gl = a
  1011. }, b.WebGLBlendModeManager.prototype.setBlendMode = function(a) {
  1012. if (this.currentBlendMode === a) return !1;
  1013. this.currentBlendMode = a;
  1014. var c = b.blendModesWebGL[this.currentBlendMode];
  1015. return this.gl.blendFunc(c[0], c[1]), !0
  1016. }, b.WebGLBlendModeManager.prototype.destroy = function() {
  1017. this.gl = null
  1018. }, b.WebGLMaskManager = function() {}, b.WebGLMaskManager.prototype.constructor = b.WebGLMaskManager, b.WebGLMaskManager.prototype.setContext = function(a) {
  1019. this.gl = a
  1020. }, b.WebGLMaskManager.prototype.pushMask = function(a, c) {
  1021. var d = c.gl;
  1022. a.dirty && b.WebGLGraphics.updateGraphics(a, d), a._webGL[d.id].data.length && c.stencilManager.pushStencil(a, a._webGL[d.id].data[0], c)
  1023. }, b.WebGLMaskManager.prototype.popMask = function(a, b) {
  1024. var c = this.gl;
  1025. b.stencilManager.popStencil(a, a._webGL[c.id].data[0], b)
  1026. }, b.WebGLMaskManager.prototype.destroy = function() {
  1027. this.gl = null
  1028. }, b.WebGLStencilManager = function() {
  1029. this.stencilStack = [], this.reverse = !0, this.count = 0
  1030. }, b.WebGLStencilManager.prototype.setContext = function(a) {
  1031. this.gl = a
  1032. }, b.WebGLStencilManager.prototype.pushStencil = function(a, b, c) {
  1033. var d = this.gl;
  1034. 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);
  1035. var e = this.count;
  1036. 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++
  1037. }, b.WebGLStencilManager.prototype.bindGraphics = function(a, c, d) {
  1038. this._currentGraphics = a;
  1039. var e, f = this.gl,
  1040. g = d.projection,
  1041. h = d.offset;
  1042. 1 === c.mode ? (e = d.shaderManager.complexPrimitiveShader, d.shaderManager.setShader(e), f.uniformMatrix3fv(e.translationMatrix, !1, a.worldTransform.toArray(!0)), f.uniform2f(e.projectionVector, g.x, -g.y), f.uniform2f(e.offsetVector, -h.x, -h.y), f.uniform3fv(e.tintColor, b.hex2rgb(a.tint)), f.uniform3fv(e.color, c.color), f.uniform1f(e.alpha, a.worldAlpha * c.alpha), f.bindBuffer(f.ARRAY_BUFFER, c.buffer), f.vertexAttribPointer(e.aVertexPosition, 2, f.FLOAT, !1, 8, 0), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, c.indexBuffer)) : (e = d.shaderManager.primitiveShader, d.shaderManager.setShader(e), f.uniformMatrix3fv(e.translationMatrix, !1, a.worldTransform.toArray(!0)), f.uniform2f(e.projectionVector, g.x, -g.y), f.uniform2f(e.offsetVector, -h.x, -h.y), f.uniform3fv(e.tintColor, b.hex2rgb(a.tint)), f.uniform1f(e.alpha, a.worldAlpha), f.bindBuffer(f.ARRAY_BUFFER, c.buffer), f.vertexAttribPointer(e.aVertexPosition, 2, f.FLOAT, !1, 24, 0), f.vertexAttribPointer(e.colorAttribute, 4, f.FLOAT, !1, 24, 8), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, c.indexBuffer))
  1043. }, b.WebGLStencilManager.prototype.popStencil = function(a, b, c) {
  1044. var d = this.gl;
  1045. if (this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length) d.disable(d.STENCIL_TEST);
  1046. else {
  1047. var e = this.count;
  1048. 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)
  1049. }
  1050. }, b.WebGLStencilManager.prototype.destroy = function() {
  1051. this.stencilStack = null, this.gl = null
  1052. }, b.WebGLShaderManager = function() {
  1053. this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [];
  1054. for (var a = 0; a < this.maxAttibs; a++) this.attribState[a] = !1;
  1055. this.stack = []
  1056. }, b.WebGLShaderManager.prototype.constructor = b.WebGLShaderManager, b.WebGLShaderManager.prototype.setContext = function(a) {
  1057. 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)
  1058. }, b.WebGLShaderManager.prototype.setAttribs = function(a) {
  1059. var b;
  1060. for (b = 0; b < this.tempAttribState.length; b++) this.tempAttribState[b] = !1;
  1061. for (b = 0; b < a.length; b++) {
  1062. var c = a[b];
  1063. this.tempAttribState[c] = !0
  1064. }
  1065. var d = this.gl;
  1066. 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))
  1067. }, b.WebGLShaderManager.prototype.setShader = function(a) {
  1068. return this._currentId === a._UID ? !1 : (this._currentId = a._UID, this.currentShader = a, this.gl.useProgram(a.program), this.setAttribs(a.attributes), !0)
  1069. }, b.WebGLShaderManager.prototype.destroy = function() {
  1070. this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.complexPrimitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null
  1071. }, b.WebGLSpriteBatch = function() {
  1072. this.vertSize = 6, this.size = 2e3;
  1073. var a = 4 * this.size * this.vertSize,
  1074. c = 6 * this.size;
  1075. this.vertices = new Float32Array(a), this.indices = new Uint16Array(c), this.lastIndexCount = 0;
  1076. 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;
  1077. 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 ;", "}"])
  1078. }, b.WebGLSpriteBatch.prototype.setContext = function(a) {
  1079. 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;
  1080. var c = new b.PixiShader(a);
  1081. c.fragmentSrc = this.defaultShader.fragmentSrc, c.uniforms = {}, c.init(), this.defaultShader.shaders[a.id] = c
  1082. }, b.WebGLSpriteBatch.prototype.begin = function(a) {
  1083. this.renderSession = a, this.shader = this.renderSession.shaderManager.defaultShader, this.start()
  1084. }, b.WebGLSpriteBatch.prototype.end = function() {
  1085. this.flush()
  1086. }, b.WebGLSpriteBatch.prototype.render = function(a) {
  1087. var b = a.texture;
  1088. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = b.baseTexture);
  1089. var c = b._uvs;
  1090. if (c) {
  1091. var d, e, f, g, h = a.worldAlpha,
  1092. i = a.tint,
  1093. j = this.vertices,
  1094. k = a.anchor.x,
  1095. l = a.anchor.y;
  1096. if (b.trim) {
  1097. var m = b.trim;
  1098. e = m.x - k * m.width, d = e + b.crop.width, g = m.y - l * m.height, f = g + b.crop.height
  1099. } else d = b.frame.width * (1 - k), e = b.frame.width * -k, f = b.frame.height * (1 - l), g = b.frame.height * -l;
  1100. var n = 4 * this.currentBatchSize * this.vertSize,
  1101. o = b.baseTexture.resolution,
  1102. p = a.worldTransform,
  1103. q = p.a / o,
  1104. r = p.b / o,
  1105. s = p.c / o,
  1106. t = p.d / o,
  1107. u = p.tx,
  1108. v = p.ty;
  1109. j[n++] = q * e + s * g + u, j[n++] = t * g + r * e + v, j[n++] = c.x0, j[n++] = c.y0, j[n++] = h, j[n++] = i, j[n++] = q * d + s * g + u, j[n++] = t * g + r * d + v, j[n++] = c.x1, j[n++] = c.y1, j[n++] = h, j[n++] = i, j[n++] = q * d + s * f + u, j[n++] = t * f + r * d + v, j[n++] = c.x2, j[n++] = c.y2, j[n++] = h, j[n++] = i, j[n++] = q * e + s * f + u, j[n++] = t * f + r * e + v, j[n++] = c.x3, j[n++] = c.y3, j[n++] = h, j[n++] = i, this.sprites[this.currentBatchSize++] = a
  1110. }
  1111. }, b.WebGLSpriteBatch.prototype.renderTilingSprite = function(a) {
  1112. var c = a.tilingTexture;
  1113. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = c.baseTexture), a._uvs || (a._uvs = new b.TextureUvs);
  1114. var d = a._uvs;
  1115. a.tilePosition.x %= c.baseTexture.width * a.tileScaleOffset.x, a.tilePosition.y %= c.baseTexture.height * a.tileScaleOffset.y;
  1116. var e = a.tilePosition.x / (c.baseTexture.width * a.tileScaleOffset.x),
  1117. f = a.tilePosition.y / (c.baseTexture.height * a.tileScaleOffset.y),
  1118. g = a.width / c.baseTexture.width / (a.tileScale.x * a.tileScaleOffset.x),
  1119. h = a.height / c.baseTexture.height / (a.tileScale.y * a.tileScaleOffset.y);
  1120. 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;
  1121. var i = a.worldAlpha,
  1122. j = a.tint,
  1123. k = this.vertices,
  1124. l = a.width,
  1125. m = a.height,
  1126. n = a.anchor.x,
  1127. o = a.anchor.y,
  1128. p = l * (1 - n),
  1129. q = l * -n,
  1130. r = m * (1 - o),
  1131. s = m * -o,
  1132. t = 4 * this.currentBatchSize * this.vertSize,
  1133. u = c.baseTexture.resolution,
  1134. v = a.worldTransform,
  1135. w = v.a / u,
  1136. x = v.b / u,
  1137. y = v.c / u,
  1138. z = v.d / u,
  1139. A = v.tx,
  1140. B = v.ty;
  1141. k[t++] = w * q + y * s + A, k[t++] = z * s + x * q + B, k[t++] = d.x0, k[t++] = d.y0, k[t++] = i, k[t++] = j, k[t++] = w * p + y * s + A, k[t++] = z * s + x * p + B, k[t++] = d.x1, k[t++] = d.y1, k[t++] = i, k[t++] = j, k[t++] = w * p + y * r + A, k[t++] = z * r + x * p + B, k[t++] = d.x2, k[t++] = d.y2, k[t++] = i, k[t++] = j, k[t++] = w * q + y * r + A, k[t++] = z * r + x * q + B, k[t++] = d.x3, k[t++] = d.y3, k[t++] = i, k[t++] = j, this.sprites[this.currentBatchSize++] = a
  1142. }, b.WebGLSpriteBatch.prototype.flush = function() {
  1143. if (0 !== this.currentBatchSize) {
  1144. var a, c = this.gl;
  1145. if (this.dirty) {
  1146. 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];
  1147. var d = 4 * this.vertSize;
  1148. c.vertexAttribPointer(a.aVertexPosition, 2, c.FLOAT, !1, d, 0), c.vertexAttribPointer(a.aTextureCoord, 2, c.FLOAT, !1, d, 8), c.vertexAttribPointer(a.colorAttribute, 2, c.FLOAT, !1, d, 16)
  1149. }
  1150. if (this.currentBatchSize > .5 * this.size) c.bufferSubData(c.ARRAY_BUFFER, 0, this.vertices);
  1151. else {
  1152. var e = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1153. c.bufferSubData(c.ARRAY_BUFFER, 0, e)
  1154. }
  1155. 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++) {
  1156. 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)) {
  1157. 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();
  1158. var s = this.renderSession.projection;
  1159. c.uniform2f(a.projectionVector, s.x, s.y);
  1160. var t = this.renderSession.offset;
  1161. c.uniform2f(a.offsetVector, t.x, t.y)
  1162. }
  1163. j++
  1164. }
  1165. this.renderBatch(l, j, k), this.currentBatchSize = 0
  1166. }
  1167. }, b.WebGLSpriteBatch.prototype.renderBatch = function(a, b, c) {
  1168. if (0 !== b) {
  1169. var d = this.gl;
  1170. 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++
  1171. }
  1172. }, b.WebGLSpriteBatch.prototype.stop = function() {
  1173. this.flush(), this.dirty = !0
  1174. }, b.WebGLSpriteBatch.prototype.start = function() {
  1175. this.dirty = !0
  1176. }, b.WebGLSpriteBatch.prototype.destroy = function() {
  1177. this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null
  1178. }, b.WebGLFastSpriteBatch = function(a) {
  1179. this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize;
  1180. var b = 4 * this.size * this.vertSize,
  1181. c = 6 * this.maxSize;
  1182. this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.vertexBuffer = null, this.indexBuffer = null, this.lastIndexCount = 0;
  1183. 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;
  1184. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(a)
  1185. }, b.WebGLFastSpriteBatch.prototype.constructor = b.WebGLFastSpriteBatch, b.WebGLFastSpriteBatch.prototype.setContext = function(a) {
  1186. 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)
  1187. }, b.WebGLFastSpriteBatch.prototype.begin = function(a, b) {
  1188. this.renderSession = b, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = a.worldTransform.toArray(!0), this.start()
  1189. }, b.WebGLFastSpriteBatch.prototype.end = function() {
  1190. this.flush()
  1191. }, b.WebGLFastSpriteBatch.prototype.render = function(a) {
  1192. var b = a.children,
  1193. c = b[0];
  1194. if (c.texture._uvs) {
  1195. this.currentBaseTexture = c.texture.baseTexture, c.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(c.blendMode));
  1196. for (var d = 0, e = b.length; e > d; d++) this.renderSprite(b[d]);
  1197. this.flush()
  1198. }
  1199. }, b.WebGLFastSpriteBatch.prototype.renderSprite = function(a) {
  1200. if (a.visible && (a.texture.baseTexture === this.currentBaseTexture || (this.flush(), this.currentBaseTexture = a.texture.baseTexture, a.texture._uvs))) {
  1201. var b, c, d, e, f, g, h, i, j = this.vertices;
  1202. if (b = a.texture._uvs, c = a.texture.frame.width, d = a.texture.frame.height, a.texture.trim) {
  1203. var k = a.texture.trim;
  1204. 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
  1205. } 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;
  1206. 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()
  1207. }
  1208. }, b.WebGLFastSpriteBatch.prototype.flush = function() {
  1209. if (0 !== this.currentBatchSize) {
  1210. var a = this.gl;
  1211. 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);
  1212. else {
  1213. var b = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
  1214. a.bufferSubData(a.ARRAY_BUFFER, 0, b)
  1215. }
  1216. a.drawElements(a.TRIANGLES, 6 * this.currentBatchSize, a.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++
  1217. }
  1218. }, b.WebGLFastSpriteBatch.prototype.stop = function() {
  1219. this.flush()
  1220. }, b.WebGLFastSpriteBatch.prototype.start = function() {
  1221. var a = this.gl;
  1222. a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  1223. var b = this.renderSession.projection;
  1224. a.uniform2f(this.shader.projectionVector, b.x, b.y), a.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix);
  1225. var c = 4 * this.vertSize;
  1226. 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)
  1227. }, b.WebGLFilterManager = function() {
  1228. this.filterStack = [], this.offsetX = 0, this.offsetY = 0
  1229. }, b.WebGLFilterManager.prototype.constructor = b.WebGLFilterManager, b.WebGLFilterManager.prototype.setContext = function(a) {
  1230. this.gl = a, this.texturePool = [], this.initShaderBuffers()
  1231. }, b.WebGLFilterManager.prototype.begin = function(a, b) {
  1232. this.renderSession = a, this.defaultShader = a.shaderManager.defaultShader;
  1233. var c = this.renderSession.projection;
  1234. this.width = 2 * c.x, this.height = 2 * -c.y, this.buffer = b
  1235. }, b.WebGLFilterManager.prototype.pushFilter = function(a) {
  1236. var c = this.gl,
  1237. d = this.renderSession.projection,
  1238. e = this.renderSession.offset;
  1239. a._filterArea = a.target.filterArea || a.target.getBounds(), this.filterStack.push(a);
  1240. var f = a.filterPasses[0];
  1241. this.offsetX += a._filterArea.x, this.offsetY += a._filterArea.y;
  1242. var g = this.texturePool.pop();
  1243. g ? g.resize(this.width, this.height) : g = new b.FilterTexture(this.gl, this.width, this.height), c.bindTexture(c.TEXTURE_2D, g.texture);
  1244. var h = a._filterArea,
  1245. i = f.padding;
  1246. 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
  1247. }, b.WebGLFilterManager.prototype.popFilter = function() {
  1248. var a = this.gl,
  1249. c = this.filterStack.pop(),
  1250. d = c._filterArea,
  1251. e = c._glFilterTexture,
  1252. f = this.renderSession.projection,
  1253. g = this.renderSession.offset;
  1254. if (c.filterPasses.length > 1) {
  1255. 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);
  1256. var h = e,
  1257. i = this.texturePool.pop();
  1258. 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);
  1259. for (var j = 0; j < c.filterPasses.length - 1; j++) {
  1260. var k = c.filterPasses[j];
  1261. 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);
  1262. var l = h;
  1263. h = i, i = l
  1264. }
  1265. a.enable(a.BLEND), e = h, this.texturePool.push(i)
  1266. }
  1267. var m = c.filterPasses[c.filterPasses.length - 1];
  1268. this.offsetX -= d.x, this.offsetY -= d.y;
  1269. var n = this.width,
  1270. o = this.height,
  1271. p = 0,
  1272. q = 0,
  1273. r = this.buffer;
  1274. if (0 === this.filterStack.length) a.colorMask(!0, !0, !0, !0);
  1275. else {
  1276. var s = this.filterStack[this.filterStack.length - 1];
  1277. d = s._filterArea, n = d.width, o = d.height, p = d.x, q = d.y, r = s._glFilterTexture.frameBuffer
  1278. }
  1279. f.x = n / 2, f.y = -o / 2, g.x = p, g.y = q, d = c._filterArea;
  1280. var t = d.x - p,
  1281. u = d.y - q;
  1282. a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = t, this.vertexArray[1] = u + d.height, this.vertexArray[2] = t + d.width, this.vertexArray[3] = u + d.height, this.vertexArray[4] = t, this.vertexArray[5] = u, this.vertexArray[6] = t + d.width, this.vertexArray[7] = u, a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertexArray), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = d.width / this.width, this.uvArray[5] = d.height / this.height, this.uvArray[6] = d.width / this.width, this.uvArray[7] = d.height / this.height, a.bufferSubData(a.ARRAY_BUFFER, 0, this.uvArray), a.viewport(0, 0, n, o), a.bindFramebuffer(a.FRAMEBUFFER, r), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, e.texture), this.applyFilterPass(m, d, n, o), this.texturePool.push(e), c._glFilterTexture = null
  1283. }, b.WebGLFilterManager.prototype.applyFilterPass = function(a, c, d, e) {
  1284. var f = this.gl,
  1285. g = a.shaders[f.id];
  1286. 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++
  1287. }, b.WebGLFilterManager.prototype.initShaderBuffers = function() {
  1288. var a = this.gl;
  1289. this.vertexBuffer = a.createBuffer(), this.uvBuffer = a.createBuffer(), this.colorBuffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.vertexArray = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bufferData(a.ARRAY_BUFFER, this.vertexArray, a.STATIC_DRAW), this.uvArray = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), a.bufferData(a.ARRAY_BUFFER, this.uvArray, a.STATIC_DRAW), this.colorArray = new Float32Array([1, 16777215, 1, 16777215, 1, 16777215, 1, 16777215]), a.bindBuffer(a.ARRAY_BUFFER, this.colorBuffer), a.bufferData(a.ARRAY_BUFFER, this.colorArray, a.STATIC_DRAW), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 1, 3, 2]), a.STATIC_DRAW)
  1290. }, b.WebGLFilterManager.prototype.destroy = function() {
  1291. var a = this.gl;
  1292. this.filterStack = null, this.offsetX = 0, this.offsetY = 0;
  1293. for (var b = 0; b < this.texturePool.length; b++) this.texturePool[b].destroy();
  1294. this.texturePool = null, a.deleteBuffer(this.vertexBuffer), a.deleteBuffer(this.uvBuffer), a.deleteBuffer(this.colorBuffer), a.deleteBuffer(this.indexBuffer)
  1295. }, b.FilterTexture = function(a, c, d, e) {
  1296. 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)
  1297. }, b.FilterTexture.prototype.constructor = b.FilterTexture, b.FilterTexture.prototype.clear = function() {
  1298. var a = this.gl;
  1299. a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT)
  1300. }, b.FilterTexture.prototype.resize = function(a, b) {
  1301. if (this.width !== a || this.height !== b) {
  1302. this.width = a, this.height = b;
  1303. var c = this.gl;
  1304. 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)
  1305. }
  1306. }, b.FilterTexture.prototype.destroy = function() {
  1307. var a = this.gl;
  1308. a.deleteFramebuffer(this.frameBuffer), a.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
  1309. }, b.CanvasBuffer = function(a, b) {
  1310. 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
  1311. }, b.CanvasBuffer.prototype.constructor = b.CanvasBuffer, b.CanvasBuffer.prototype.clear = function() {
  1312. this.context.clearRect(0, 0, this.width, this.height)
  1313. }, b.CanvasBuffer.prototype.resize = function(a, b) {
  1314. this.width = this.canvas.width = a, this.height = this.canvas.height = b
  1315. }, b.CanvasMaskManager = function() {}, b.CanvasMaskManager.prototype.constructor = b.CanvasMaskManager, b.CanvasMaskManager.prototype.pushMask = function(a, c) {
  1316. var d = c.context;
  1317. d.save();
  1318. var e = a.alpha,
  1319. f = a.worldTransform,
  1320. g = c.resolution;
  1321. 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
  1322. }, b.CanvasMaskManager.prototype.popMask = function(a) {
  1323. a.context.restore()
  1324. }, b.CanvasTinter = function() {}, b.CanvasTinter.getTintedTexture = function(a, c) {
  1325. var d = a.texture;
  1326. c = b.CanvasTinter.roundColor(c);
  1327. var e = "#" + ("00000" + (0 | c).toString(16)).substr(-6);
  1328. if (d.tintCache = d.tintCache || {}, d.tintCache[e]) return d.tintCache[e];
  1329. var f = b.CanvasTinter.canvas || document.createElement("canvas");
  1330. if (b.CanvasTinter.tintMethod(d, c, f), b.CanvasTinter.convertTintToImage) {
  1331. var g = new Image;
  1332. g.src = f.toDataURL(), d.tintCache[e] = g
  1333. } else d.tintCache[e] = f, b.CanvasTinter.canvas = null;
  1334. return f
  1335. }, b.CanvasTinter.tintWithMultiply = function(a, b, c) {
  1336. var d = c.getContext("2d"),
  1337. e = a.crop;
  1338. 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)
  1339. }, b.CanvasTinter.tintWithOverlay = function(a, b, c) {
  1340. var d = c.getContext("2d"),
  1341. e = a.crop;
  1342. 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)
  1343. }, b.CanvasTinter.tintWithPerPixel = function(a, c, d) {
  1344. var e = d.getContext("2d"),
  1345. f = a.crop;
  1346. 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);
  1347. for (var g = b.hex2rgb(c), h = g[0], i = g[1], j = g[2], k = e.getImageData(0, 0, f.width, f.height), l = k.data, m = 0; m < l.length; m += 4) l[m + 0] *= h, l[m + 1] *= i, l[m + 2] *= j;
  1348. e.putImageData(k, 0, 0)
  1349. }, b.CanvasTinter.roundColor = function(a) {
  1350. var c = b.CanvasTinter.cacheStepsPerColorChannel,
  1351. d = b.hex2rgb(a);
  1352. 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)
  1353. }, b.CanvasTinter.cacheStepsPerColorChannel = 8, b.CanvasTinter.convertTintToImage = !1, b.CanvasTinter.canUseMultiply = b.canUseNewCanvasBlendModes(), b.CanvasTinter.tintMethod = b.CanvasTinter.canUseMultiply ? b.CanvasTinter.tintWithMultiply : b.CanvasTinter.tintWithPerPixel, b.CanvasRenderer = function(a, c, d) {
  1354. if (d)
  1355. for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
  1356. else d = b.defaultRenderOptions;
  1357. b.defaultRenderer || (b.sayHello("Canvas"), b.defaultRenderer = this), this.type = b.CANVAS_RENDERER, this.resolution = d.resolution, this.clearBeforeRender = d.clearBeforeRender, this.transparent = d.transparent, 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", {
  1358. alpha: this.transparent
  1359. }), 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 = {
  1360. context: this.context,
  1361. maskManager: this.maskManager,
  1362. scaleMode: null,
  1363. smoothProperty: null,
  1364. roundPixels: !1
  1365. }, 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")
  1366. }, b.CanvasRenderer.prototype.constructor = b.CanvasRenderer, b.CanvasRenderer.prototype.render = function(a) {
  1367. 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), a.interactive && (a._interactiveEventsAdded || (a._interactiveEventsAdded = !0, a.interactionManager.setTarget(this)))
  1368. }, b.CanvasRenderer.prototype.destroy = function(a) {
  1369. "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
  1370. }, b.CanvasRenderer.prototype.resize = function(a, b) {
  1371. this.width = a * this.resolution, this.height = b * this.resolution, this.view.width = this.width, this.view.height = this.height, this.view.style.width = this.width / this.resolution + "px", this.view.style.height = this.height / this.resolution + "px"
  1372. }, b.CanvasRenderer.prototype.renderDisplayObject = function(a, b) {
  1373. this.renderSession.context = b || this.context, this.renderSession.resolution = this.resolution, a._renderCanvas(this.renderSession)
  1374. }, b.CanvasRenderer.prototype.mapBlendModes = function() {
  1375. 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"))
  1376. }, b.CanvasGraphics = function() {}, b.CanvasGraphics.renderGraphics = function(a, c) {
  1377. for (var d = a.worldAlpha, e = "", f = 0; f < a.graphicsData.length; f++) {
  1378. var g = a.graphicsData[f],
  1379. h = g.shape;
  1380. if (c.strokeStyle = e = "#" + ("00000" + (0 | g.lineColor).toString(16)).substr(-6), c.lineWidth = g.lineWidth, g.type === b.Graphics.POLY) {
  1381. c.beginPath();
  1382. var i = h.points;
  1383. c.moveTo(i[0], i[1]);
  1384. for (var j = 1; j < i.length / 2; j++) c.lineTo(i[2 * j], i[2 * j + 1]);
  1385. h.closed && c.lineTo(i[0], i[1]), i[0] === i[i.length - 2] && i[1] === i[i.length - 1] && c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())
  1386. } else if (g.type === b.Graphics.RECT)(g.fillColor || 0 === g.fillColor) && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fillRect(h.x, h.y, h.width, h.height)), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.strokeRect(h.x, h.y, h.width, h.height));
  1387. else if (g.type === b.Graphics.CIRC) c.beginPath(), c.arc(h.x, h.y, h.radius, 0, 2 * Math.PI), c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke());
  1388. else if (g.type === b.Graphics.ELIP) {
  1389. var k = 2 * h.width,
  1390. l = 2 * h.height,
  1391. m = h.x - k / 2,
  1392. n = h.y - l / 2;
  1393. c.beginPath();
  1394. var o = .5522848,
  1395. p = k / 2 * o,
  1396. q = l / 2 * o,
  1397. r = m + k,
  1398. s = n + l,
  1399. t = m + k / 2,
  1400. u = n + l / 2;
  1401. c.moveTo(m, u), c.bezierCurveTo(m, u - q, t - p, n, t, n), c.bezierCurveTo(t + p, n, r, u - q, r, u), c.bezierCurveTo(r, u + q, t + p, s, t, s), c.bezierCurveTo(t - p, s, m, u + q, m, u), c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())
  1402. } else if (g.type === b.Graphics.RREC) {
  1403. var v = h.points,
  1404. w = v[0],
  1405. x = v[1],
  1406. y = v[2],
  1407. z = v[3],
  1408. A = v[4],
  1409. B = Math.min(y, z) / 2 | 0;
  1410. 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(), (g.fillColor || 0 === g.fillColor) && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())
  1411. }
  1412. }
  1413. }, b.CanvasGraphics.renderGraphicsMask = function(a, c) {
  1414. var d = a.graphicsData.length;
  1415. if (0 !== d) {
  1416. d > 1 && (d = 1, window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));
  1417. for (var e = 0; 1 > e; e++) {
  1418. var f = a.graphicsData[e],
  1419. g = f.shape;
  1420. if (f.type === b.Graphics.POLY) {
  1421. c.beginPath();
  1422. var h = g.points;
  1423. c.moveTo(h[0], h[1]);
  1424. for (var i = 1; i < h.length / 2; i++) c.lineTo(h[2 * i], h[2 * i + 1]);
  1425. h[0] === h[h.length - 2] && h[1] === h[h.length - 1] && c.closePath()
  1426. } else if (f.type === b.Graphics.RECT) c.beginPath(), c.rect(g.x, g.y, g.width, g.height), c.closePath();
  1427. else if (f.type === b.Graphics.CIRC) c.beginPath(), c.arc(g.x, g.y, g.radius, 0, 2 * Math.PI), c.closePath();
  1428. else if (f.type === b.Graphics.ELIP) {
  1429. var j = 2 * g.width,
  1430. k = 2 * g.height,
  1431. l = g.x - j / 2,
  1432. m = g.y - k / 2;
  1433. c.beginPath();
  1434. var n = .5522848,
  1435. o = j / 2 * n,
  1436. p = k / 2 * n,
  1437. q = l + j,
  1438. r = m + k,
  1439. s = l + j / 2,
  1440. t = m + k / 2;
  1441. c.moveTo(l, t), c.bezierCurveTo(l, t - p, s - o, m, s, m), c.bezierCurveTo(s + o, m, q, t - p, q, t), c.bezierCurveTo(q, t + p, s + o, r, s, r), c.bezierCurveTo(s - o, r, l, t + p, l, t), c.closePath()
  1442. } else if (f.type === b.Graphics.RREC) {
  1443. var u = g.points,
  1444. v = u[0],
  1445. w = u[1],
  1446. x = u[2],
  1447. y = u[3],
  1448. z = u[4],
  1449. A = Math.min(x, y) / 2 | 0;
  1450. z = z > A ? A : z, c.beginPath(), c.moveTo(v, w + z), c.lineTo(v, w + y - z), c.quadraticCurveTo(v, w + y, v + z, w + y), c.lineTo(v + x - z, w + y), c.quadraticCurveTo(v + x, w + y, v + x, w + y - z), c.lineTo(v + x, w + z), c.quadraticCurveTo(v + x, w, v + x - z, w), c.lineTo(v + z, w), c.quadraticCurveTo(v, w, v, w + z), c.closePath()
  1451. }
  1452. }
  1453. }
  1454. }, b.Strip = function(a) {
  1455. b.DisplayObjectContainer.call(this), this.texture = a, this.uvs = new b.Float32Array([0, 1, 1, 1, 1, 0, 0, 1]), this.verticies = new b.Float32Array([0, 0, 100, 0, 100, 100, 0, 100]), this.colors = new b.Float32Array([1, 1, 1, 1]), this.indices = new b.Uint16Array([0, 1, 2, 3]), this.dirty = !0, this.padding = 0
  1456. }, b.Strip.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Strip.prototype.constructor = b.Strip, b.Strip.prototype._renderWebGL = function(a) {
  1457. !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())
  1458. }, b.Strip.prototype._initWebGL = function(a) {
  1459. var b = a.gl;
  1460. this._vertexBuffer = b.createBuffer(), this._indexBuffer = b.createBuffer(), this._uvBuffer = b.createBuffer(), this._colorBuffer = b.createBuffer(), b.bindBuffer(b.ARRAY_BUFFER, this._vertexBuffer), b.bufferData(b.ARRAY_BUFFER, this.verticies, b.DYNAMIC_DRAW), b.bindBuffer(b.ARRAY_BUFFER, this._uvBuffer), b.bufferData(b.ARRAY_BUFFER, this.uvs, b.STATIC_DRAW), b.bindBuffer(b.ARRAY_BUFFER, this._colorBuffer), b.bufferData(b.ARRAY_BUFFER, this.colors, b.STATIC_DRAW), b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, this._indexBuffer), b.bufferData(b.ELEMENT_ARRAY_BUFFER, this.indices, b.STATIC_DRAW)
  1461. }, b.Strip.prototype._renderStrip = function(a) {
  1462. var b = a.gl,
  1463. c = a.projection,
  1464. d = a.offset,
  1465. e = a.shaderManager.stripShader;
  1466. b.blendFunc(b.ONE, b.ONE_MINUS_SRC_ALPHA), b.uniformMatrix3fv(e.translationMatrix, !1, this.worldTransform.toArray(!0)), b.uniform2f(e.projectionVector, c.x, -c.y), b.uniform2f(e.offsetVector, -d.x, -d.y), b.uniform1f(e.alpha, this.worldAlpha), this.dirty ? (this.dirty = !1, b.bindBuffer(b.ARRAY_BUFFER, this._vertexBuffer), b.bufferData(b.ARRAY_BUFFER, this.verticies, b.STATIC_DRAW), b.vertexAttribPointer(e.aVertexPosition, 2, b.FLOAT, !1, 0, 0), b.bindBuffer(b.ARRAY_BUFFER, this._uvBuffer), b.bufferData(b.ARRAY_BUFFER, this.uvs, b.STATIC_DRAW), b.vertexAttribPointer(e.aTextureCoord, 2, b.FLOAT, !1, 0, 0), b.activeTexture(b.TEXTURE0), this.texture.baseTexture._dirty[b.id] ? a.renderer.updateTexture(this.texture.baseTexture) : b.bindTexture(b.TEXTURE_2D, this.texture.baseTexture._glTextures[b.id]), b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, this._indexBuffer), b.bufferData(b.ELEMENT_ARRAY_BUFFER, this.indices, b.STATIC_DRAW)) : (b.bindBuffer(b.ARRAY_BUFFER, this._vertexBuffer), b.bufferSubData(b.ARRAY_BUFFER, 0, this.verticies), b.vertexAttribPointer(e.aVertexPosition, 2, b.FLOAT, !1, 0, 0), b.bindBuffer(b.ARRAY_BUFFER, this._uvBuffer), b.vertexAttribPointer(e.aTextureCoord, 2, b.FLOAT, !1, 0, 0), b.activeTexture(b.TEXTURE0), this.texture.baseTexture._dirty[b.id] ? a.renderer.updateTexture(this.texture.baseTexture) : b.bindTexture(b.TEXTURE_2D, this.texture.baseTexture._glTextures[b.id]), b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, this._indexBuffer)), b.drawElements(b.TRIANGLE_STRIP, this.indices.length, b.UNSIGNED_SHORT, 0)
  1467. }, b.Strip.prototype._renderCanvas = function(a) {
  1468. var b = a.context,
  1469. c = this.worldTransform;
  1470. a.roundPixels ? b.setTransform(c.a, c.b, c.c, c.d, 0 | c.tx, 0 | c.ty) : b.setTransform(c.a, c.b, c.c, c.d, c.tx, c.ty);
  1471. var d = this,
  1472. e = d.verticies,
  1473. f = d.uvs,
  1474. g = e.length / 2;
  1475. this.count++;
  1476. for (var h = 0; g - 2 > h; h++) {
  1477. var i = 2 * h,
  1478. j = e[i],
  1479. k = e[i + 2],
  1480. l = e[i + 4],
  1481. m = e[i + 1],
  1482. n = e[i + 3],
  1483. o = e[i + 5];
  1484. if (this.padding > 0) {
  1485. var p = (j + k + l) / 3,
  1486. q = (m + n + o) / 3,
  1487. r = j - p,
  1488. s = m - q,
  1489. t = Math.sqrt(r * r + s * s);
  1490. j = p + r / t * (t + 3), m = q + s / t * (t + 3), r = k - p, s = n - q, t = Math.sqrt(r * r + s * s), k = p + r / t * (t + 3), n = q + s / t * (t + 3), r = l - p, s = o - q, t = Math.sqrt(r * r + s * s), l = p + r / t * (t + 3), o = q + s / t * (t + 3)
  1491. }
  1492. var u = f[i] * d.texture.width,
  1493. v = f[i + 2] * d.texture.width,
  1494. w = f[i + 4] * d.texture.width,
  1495. x = f[i + 1] * d.texture.height,
  1496. y = f[i + 3] * d.texture.height,
  1497. z = f[i + 5] * d.texture.height;
  1498. b.save(), b.beginPath(), b.moveTo(j, m), b.lineTo(k, n), b.lineTo(l, o), b.closePath(), b.clip();
  1499. var A = u * y + x * w + v * z - y * w - x * v - u * z,
  1500. B = j * y + x * l + k * z - y * l - x * k - j * z,
  1501. C = u * k + j * w + v * l - k * w - j * v - u * l,
  1502. D = u * y * l + x * k * w + j * v * z - j * y * w - x * v * l - u * k * z,
  1503. E = m * y + x * o + n * z - y * o - x * n - m * z,
  1504. F = u * n + m * w + v * o - n * w - m * v - u * o,
  1505. G = u * y * o + x * n * w + m * v * z - m * y * w - x * v * o - u * n * z;
  1506. b.transform(B / A, E / A, C / A, F / A, D / A, G / A), b.drawImage(d.texture.baseTexture.source, 0, 0), b.restore()
  1507. }
  1508. }, b.Strip.prototype.renderStripFlat = function(a) {
  1509. var b = this.context,
  1510. c = a.verticies,
  1511. d = c.length / 2;
  1512. this.count++, b.beginPath();
  1513. for (var e = 1; d - 2 > e; e++) {
  1514. var f = 2 * e,
  1515. g = c[f],
  1516. h = c[f + 2],
  1517. i = c[f + 4],
  1518. j = c[f + 1],
  1519. k = c[f + 3],
  1520. l = c[f + 5];
  1521. b.moveTo(g, j), b.lineTo(h, k), b.lineTo(i, l)
  1522. }
  1523. b.fillStyle = "#FF0000", b.fill(), b.closePath()
  1524. }, b.Strip.prototype.onTextureUpdate = function() {
  1525. this.updateFrame = !0
  1526. }, b.Rope = function(a, c) {
  1527. b.Strip.call(this, a), this.points = c, this.verticies = new b.Float32Array(4 * c.length), this.uvs = new b.Float32Array(4 * c.length), this.colors = new b.Float32Array(2 * c.length), this.indices = new b.Uint16Array(2 * c.length), this.refresh()
  1528. }, b.Rope.prototype = Object.create(b.Strip.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.refresh = function() {
  1529. var a = this.points;
  1530. if (!(a.length < 1)) {
  1531. var b = this.uvs,
  1532. c = a[0],
  1533. d = this.indices,
  1534. e = this.colors;
  1535. 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;
  1536. 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
  1537. }
  1538. }, b.Rope.prototype.updateTransform = function() {
  1539. var a = this.points;
  1540. if (!(a.length < 1)) {
  1541. var c, d = a[0],
  1542. e = {
  1543. x: 0,
  1544. y: 0
  1545. };
  1546. this.count -= .2;
  1547. for (var f, g, h, i, j, k = this.verticies, l = a.length, m = 0; l > m; m++) f = a[m], g = 4 * m, c = m < a.length - 1 ? a[m + 1] : f, e.y = -(c.x - d.x), e.x = c.y - d.y, h = 10 * (1 - m / (l - 1)), h > 1 && (h = 1), i = Math.sqrt(e.x * e.x + e.y * e.y), j = this.texture.height / 2, e.x /= i, e.y /= i, e.x *= j, e.y *= j, k[g] = f.x + e.x, k[g + 1] = f.y + e.y, k[g + 2] = f.x - e.x, k[g + 3] = f.y - e.y, d = f;
  1548. b.DisplayObjectContainer.prototype.updateTransform.call(this)
  1549. }
  1550. }, b.Rope.prototype.setTexture = function(a) {
  1551. this.texture = a
  1552. }, b.TilingSprite = function(a, c, d) {
  1553. 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
  1554. }, b.TilingSprite.prototype = Object.create(b.Sprite.prototype), b.TilingSprite.prototype.constructor = b.TilingSprite, Object.defineProperty(b.TilingSprite.prototype, "width", {
  1555. get: function() {
  1556. return this._width
  1557. },
  1558. set: function(a) {
  1559. this._width = a
  1560. }
  1561. }), Object.defineProperty(b.TilingSprite.prototype, "height", {
  1562. get: function() {
  1563. return this._height
  1564. },
  1565. set: function(a) {
  1566. this._height = a
  1567. }
  1568. }), b.TilingSprite.prototype.setTexture = function(a) {
  1569. this.texture !== a && (this.texture = a, this.refreshTexture = !0, this.cachedTint = 16777215)
  1570. }, b.TilingSprite.prototype._renderWebGL = function(a) {
  1571. if (this.visible !== !1 && 0 !== this.alpha) {
  1572. var c, d;
  1573. for (this._mask && (a.spriteBatch.stop(), a.maskManager.pushMask(this.mask, a), a.spriteBatch.start()), this._filters && (a.spriteBatch.flush(), a.filterManager.pushFilter(this._filterBlock)), !this.tilingTexture || this.refreshTexture ? (this.generateTilingTexture(!0), this.tilingTexture && this.tilingTexture.needsUpdate && (b.updateWebGLTexture(this.tilingTexture.baseTexture, a.gl), this.tilingTexture.needsUpdate = !1)) : a.spriteBatch.renderTilingSprite(this), c = 0, d = this.children.length; d > c; c++) this.children[c]._renderWebGL(a);
  1574. a.spriteBatch.stop(), this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this._mask, a), a.spriteBatch.start()
  1575. }
  1576. }, b.TilingSprite.prototype._renderCanvas = function(a) {
  1577. if (this.visible !== !1 && 0 !== this.alpha) {
  1578. var c = a.context;
  1579. this._mask && a.maskManager.pushMask(this._mask, c), c.globalAlpha = this.worldAlpha;
  1580. var d, e, f = this.worldTransform,
  1581. g = a.resolution;
  1582. if (c.setTransform(f.a * g, f.c * g, f.b * g, f.d * g, f.tx * g, f.ty * g), !this.__tilePattern || this.refreshTexture) {
  1583. if (this.generateTilingTexture(!1), !this.tilingTexture) return;
  1584. this.__tilePattern = c.createPattern(this.tilingTexture.baseTexture.source, "repeat")
  1585. }
  1586. this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]);
  1587. var h = this.tilePosition,
  1588. i = this.tileScale;
  1589. 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.context), d = 0, e = this.children.length; e > d; d++) this.children[d]._renderCanvas(a)
  1590. }
  1591. }, b.TilingSprite.prototype.getBounds = function() {
  1592. var a = this._width,
  1593. b = this._height,
  1594. c = a * (1 - this.anchor.x),
  1595. d = a * -this.anchor.x,
  1596. e = b * (1 - this.anchor.y),
  1597. f = b * -this.anchor.y,
  1598. g = this.worldTransform,
  1599. h = g.a,
  1600. i = g.c,
  1601. j = g.b,
  1602. k = g.d,
  1603. l = g.tx,
  1604. m = g.ty,
  1605. n = h * d + j * f + l,
  1606. o = k * f + i * d + m,
  1607. p = h * c + j * f + l,
  1608. q = k * f + i * c + m,
  1609. r = h * c + j * e + l,
  1610. s = k * e + i * c + m,
  1611. t = h * d + j * e + l,
  1612. u = k * e + i * d + m,
  1613. v = -1 / 0,
  1614. w = -1 / 0,
  1615. x = 1 / 0,
  1616. y = 1 / 0;
  1617. 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;
  1618. var z = this._bounds;
  1619. return z.x = x, z.width = v - x, z.y = y, z.height = w - y, this._currentBounds = z, z
  1620. }, b.TilingSprite.prototype.onTextureUpdate = function() {}, b.TilingSprite.prototype.generateTilingTexture = function(a) {
  1621. if (this.texture.baseTexture.hasLoaded) {
  1622. var c, d, e = this.originalTexture || this.texture,
  1623. f = e.frame,
  1624. g = f.width !== e.baseTexture.width || f.height !== e.baseTexture.height,
  1625. h = !1;
  1626. if (a ? (c = b.getNextPowerOfTwo(f.width), d = b.getNextPowerOfTwo(f.height), (f.width !== c || f.height !== d) && (h = !0)) : g && (c = f.width, d = f.height, h = !0), h) {
  1627. var i;
  1628. 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
  1629. } else this.tilingTexture && this.tilingTexture.isTiling && this.tilingTexture.destroy(!0), this.tileScaleOffset.x = 1, this.tileScaleOffset.y = 1, this.tilingTexture = e;
  1630. this.refreshTexture = !1, this.originalTexture = this.texture, this.texture = this.tilingTexture, this.tilingTexture.baseTexture._powerOf2 = !0
  1631. }
  1632. }, b.BaseTextureCache = {}, b.BaseTextureCacheIdGenerator = 0, b.BaseTexture = function(a, c) {
  1633. if (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._dirty = [!0, !0, !0, !0], a) {
  1634. if ((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();
  1635. else {
  1636. var d = this;
  1637. this.source.onload = function() {
  1638. d.hasLoaded = !0, d.width = d.source.naturalWidth || d.source.width, d.height = d.source.naturalHeight || d.source.height, d.dirty(), d.dispatchEvent({
  1639. type: "loaded",
  1640. content: d
  1641. })
  1642. }, this.source.onerror = function() {
  1643. d.dispatchEvent({
  1644. type: "error",
  1645. content: d
  1646. })
  1647. }
  1648. }
  1649. this.imageUrl = null, this._powerOf2 = !1
  1650. }
  1651. }, b.BaseTexture.prototype.constructor = b.BaseTexture, b.EventTarget.mixin(b.BaseTexture.prototype), b.BaseTexture.prototype.destroy = function() {
  1652. this.imageUrl ? (delete b.BaseTextureCache[this.imageUrl], delete b.TextureCache[this.imageUrl], this.imageUrl = null, this.source.src = "") : this.source && this.source._pixiId && delete b.BaseTextureCache[this.source._pixiId], this.source = null;
  1653. for (var a = this._glTextures.length - 1; a >= 0; a--) {
  1654. var c = this._glTextures[a],
  1655. d = b.glContexts[a];
  1656. d && c && d.deleteTexture(c)
  1657. }
  1658. this._glTextures.length = 0
  1659. }, b.BaseTexture.prototype.updateSourceImage = function(a) {
  1660. this.hasLoaded = !1, this.source.src = null, this.source.src = a
  1661. }, b.BaseTexture.prototype.dirty = function() {
  1662. for (var a = 0; a < this._glTextures.length; a++) this._dirty[a] = !0
  1663. }, b.BaseTexture.fromImage = function(a, c, d) {
  1664. var e = b.BaseTextureCache[a];
  1665. if (void 0 === c && -1 === a.indexOf("data:") && (c = !0), !e) {
  1666. var f = new Image;
  1667. 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)
  1668. }
  1669. return e
  1670. }, b.BaseTexture.fromCanvas = function(a, c) {
  1671. a._pixiId || (a._pixiId = "canvas_" + b.TextureCacheIdGenerator++);
  1672. var d = b.BaseTextureCache[a._pixiId];
  1673. return d || (d = new b.BaseTexture(a, c), b.BaseTextureCache[a._pixiId] = d), d
  1674. }, b.TextureCache = {}, b.FrameCache = {}, b.TextureCacheIdGenerator = 0, b.Texture = function(a, c, d, e) {
  1675. 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)) : a.addEventListener("loaded", this.onBaseTextureLoaded.bind(this))
  1676. }, b.Texture.prototype.constructor = b.Texture, b.EventTarget.mixin(b.Texture.prototype), b.Texture.prototype.onBaseTextureLoaded = function() {
  1677. var a = this.baseTexture;
  1678. a.removeEventListener("loaded", this.onLoaded), this.noFrame && (this.frame = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(this.frame), this.dispatchEvent({
  1679. type: "update",
  1680. content: this
  1681. })
  1682. }, b.Texture.prototype.destroy = function(a) {
  1683. a && this.baseTexture.destroy(), this.valid = !1
  1684. }, b.Texture.prototype.setFrame = function(a) {
  1685. if (this.noFrame = !1, this.frame = a, this.width = a.width, this.height = a.height, this.crop.x = a.x, this.crop.y = a.y, this.crop.width = a.width, this.crop.height = a.height, !this.trim && (a.x + a.width > this.baseTexture.width || a.y + a.height > this.baseTexture.height)) throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
  1686. 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()
  1687. }, b.Texture.prototype._updateUvs = function() {
  1688. this._uvs || (this._uvs = new b.TextureUvs);
  1689. var a = this.crop,
  1690. c = this.baseTexture.width,
  1691. d = this.baseTexture.height;
  1692. 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
  1693. }, b.Texture.fromImage = function(a, c, d) {
  1694. var e = b.TextureCache[a];
  1695. return e || (e = new b.Texture(b.BaseTexture.fromImage(a, c, d)), b.TextureCache[a] = e), e
  1696. }, b.Texture.fromFrame = function(a) {
  1697. var c = b.TextureCache[a];
  1698. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache ');
  1699. return c
  1700. }, b.Texture.fromCanvas = function(a, c) {
  1701. var d = b.BaseTexture.fromCanvas(a, c);
  1702. return new b.Texture(d)
  1703. }, b.Texture.addTextureToCache = function(a, c) {
  1704. b.TextureCache[c] = a
  1705. }, b.Texture.removeTextureFromCache = function(a) {
  1706. var c = b.TextureCache[a];
  1707. return delete b.TextureCache[a], delete b.BaseTextureCache[a], c
  1708. }, b.TextureUvs = function() {
  1709. this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0
  1710. }, b.RenderTexture = function(a, c, d, e, f) {
  1711. 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.height)), this.renderer = d || b.defaultRenderer, this.renderer.type === b.WEBGL_RENDERER) {
  1712. var g = this.renderer.gl;
  1713. this.baseTexture._dirty[g.id] = !1, this.textureBuffer = new b.FilterTexture(g, this.width * this.resolution, this.height * this.resolution, 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)
  1714. } else this.render = this.renderCanvas, this.textureBuffer = new b.CanvasBuffer(this.width * this.resolution, this.height * this.resolution), this.baseTexture.source = this.textureBuffer.canvas;
  1715. this.valid = !0, this._updateUvs()
  1716. }, b.RenderTexture.prototype = Object.create(b.Texture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.resize = function(a, c, d) {
  1717. (a !== this.width || c !== this.height) && (this.valid = a > 0 && c > 0, this.width = this.frame.width = this.crop.width = a, this.height = this.frame.height = this.crop.height = c, d && (this.baseTexture.width = this.width, this.baseTexture.height = this.height), this.renderer.type === b.WEBGL_RENDERER && (this.projection.x = this.width / 2, this.projection.y = -this.height / 2), this.valid && this.textureBuffer.resize(this.width * this.resolution, this.height * this.resolution))
  1718. }, b.RenderTexture.prototype.clear = function() {
  1719. this.valid && (this.renderer.type === b.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear())
  1720. }, b.RenderTexture.prototype.renderWebGL = function(a, b, c) {
  1721. if (this.valid) {
  1722. var d = a.worldTransform;
  1723. d.identity(), d.translate(0, 2 * this.projection.y), b && d.append(b), d.scale(1, -1), a.worldAlpha = 1;
  1724. for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
  1725. var h = this.renderer.gl;
  1726. 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
  1727. }
  1728. }, b.RenderTexture.prototype.renderCanvas = function(a, b, c) {
  1729. if (this.valid) {
  1730. var d = a.worldTransform;
  1731. d.identity(), b && d.append(b);
  1732. for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
  1733. c && this.textureBuffer.clear();
  1734. var h = this.textureBuffer.context,
  1735. i = this.renderer.resolution;
  1736. this.renderer.resolution = this.resolution, this.renderer.renderDisplayObject(a, h), this.renderer.resolution = i
  1737. }
  1738. }, b.RenderTexture.prototype.getImage = function() {
  1739. var a = new Image;
  1740. return a.src = this.getBase64(), a
  1741. }, b.RenderTexture.prototype.getBase64 = function() {
  1742. return this.getCanvas().toDataURL()
  1743. }, b.RenderTexture.prototype.getCanvas = function() {
  1744. if (this.renderer.type === b.WEBGL_RENDERER) {
  1745. var a = this.renderer.gl,
  1746. c = this.textureBuffer.width,
  1747. d = this.textureBuffer.height,
  1748. e = new Uint8Array(4 * c * d);
  1749. a.bindFramebuffer(a.FRAMEBUFFER, this.textureBuffer.frameBuffer), a.readPixels(0, 0, c, d, a.RGBA, a.UNSIGNED_BYTE, e), a.bindFramebuffer(a.FRAMEBUFFER, null);
  1750. for (var f = new b.CanvasBuffer(c, d), g = f.context.getImageData(0, 0, c, d), h = g.data, i = 0; i < e.length; i += 4) {
  1751. var j = e[i + 3];
  1752. h[i] = e[i] * j, h[i + 1] = e[i + 1] * j, h[i + 2] = e[i + 2] * j, h[i + 3] = j
  1753. }
  1754. return f.context.putImageData(g, 0, 0), f.canvas
  1755. }
  1756. return this.textureBuffer.canvas
  1757. }, b.RenderTexture.tempMatrix = new b.Matrix, b.AbstractFilter = function(a, b) {
  1758. this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = b || {}, this.fragmentSrc = a || []
  1759. }, b.AbstractFilter.prototype.constructor = b.AbstractFilter, b.AbstractFilter.prototype.syncUniforms = function() {
  1760. for (var a = 0, b = this.shaders.length; b > a; a++) this.shaders[a].dirty = !0
  1761. }, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.PIXI = b) : "undefined" != typeof define && define.amd ? define("PIXI", function() {
  1762. return a.PIXI = b
  1763. }()) : a.PIXI = b
  1764. }).call(this),
  1765. function() {
  1766. var a = this,
  1767. b = b || {
  1768. VERSION: "2.1.3",
  1769. GAMES: [],
  1770. AUTO: 0,
  1771. CANVAS: 1,
  1772. WEBGL: 2,
  1773. HEADLESS: 3,
  1774. NONE: 0,
  1775. LEFT: 1,
  1776. RIGHT: 2,
  1777. UP: 3,
  1778. DOWN: 4,
  1779. SPRITE: 0,
  1780. BUTTON: 1,
  1781. IMAGE: 2,
  1782. GRAPHICS: 3,
  1783. TEXT: 4,
  1784. TILESPRITE: 5,
  1785. BITMAPTEXT: 6,
  1786. GROUP: 7,
  1787. RENDERTEXTURE: 8,
  1788. TILEMAP: 9,
  1789. TILEMAPLAYER: 10,
  1790. EMITTER: 11,
  1791. POLYGON: 12,
  1792. BITMAPDATA: 13,
  1793. CANVAS_FILTER: 14,
  1794. WEBGL_FILTER: 15,
  1795. ELLIPSE: 16,
  1796. SPRITEBATCH: 17,
  1797. RETROFONT: 18,
  1798. POINTER: 19,
  1799. ROPE: 20,
  1800. blendModes: {
  1801. NORMAL: 0,
  1802. ADD: 1,
  1803. MULTIPLY: 2,
  1804. SCREEN: 3,
  1805. OVERLAY: 4,
  1806. DARKEN: 5,
  1807. LIGHTEN: 6,
  1808. COLOR_DODGE: 7,
  1809. COLOR_BURN: 8,
  1810. HARD_LIGHT: 9,
  1811. SOFT_LIGHT: 10,
  1812. DIFFERENCE: 11,
  1813. EXCLUSION: 12,
  1814. HUE: 13,
  1815. SATURATION: 14,
  1816. COLOR: 15,
  1817. LUMINOSITY: 16
  1818. },
  1819. scaleModes: {
  1820. DEFAULT: 0,
  1821. LINEAR: 0,
  1822. NEAREST: 1
  1823. }
  1824. };
  1825. if (PIXI.InteractionManager = PIXI.InteractionManager || function() {}, PIXI.dontSayHello = !0, b.Utils = {
  1826. getProperty: function(a, b) {
  1827. 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++;
  1828. return a ? a[d] : null
  1829. },
  1830. setProperty: function(a, b, c) {
  1831. 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++;
  1832. return a && (a[e] = c), a
  1833. },
  1834. transposeArray: function(a) {
  1835. for (var b = new Array(a[0].length), c = 0; c < a[0].length; c++) {
  1836. b[c] = new Array(a.length - 1);
  1837. for (var d = a.length - 1; d > -1; d--) b[c][d] = a[d][c]
  1838. }
  1839. return b
  1840. },
  1841. rotateArray: function(a, c) {
  1842. if ("string" != typeof c && (c = (c % 360 + 360) % 360), 90 === c || -270 === c || "rotateLeft" === c) a = b.Utils.transposeArray(a), a = a.reverse();
  1843. else if (-90 === c || 270 === c || "rotateRight" === c) a = a.reverse(), a = b.Utils.transposeArray(a);
  1844. else if (180 === Math.abs(c) || "rotate180" === c) {
  1845. for (var d = 0; d < a.length; d++) a[d].reverse();
  1846. a = a.reverse()
  1847. }
  1848. return a
  1849. },
  1850. parseDimension: function(a, b) {
  1851. var c = 0,
  1852. d = 0;
  1853. 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
  1854. },
  1855. shuffle: function(a) {
  1856. for (var b = a.length - 1; b > 0; b--) {
  1857. var c = Math.floor(Math.random() * (b + 1)),
  1858. d = a[b];
  1859. a[b] = a[c], a[c] = d
  1860. }
  1861. return a
  1862. },
  1863. pad: function(a, b, c, d) {
  1864. if ("undefined" == typeof b) var b = 0;
  1865. if ("undefined" == typeof c) var c = " ";
  1866. if ("undefined" == typeof d) var d = 3;
  1867. var e = 0;
  1868. if (b + 1 >= a.length) switch (d) {
  1869. case 1:
  1870. a = new Array(b + 1 - a.length).join(c) + a;
  1871. break;
  1872. case 3:
  1873. var f = Math.ceil((e = b - a.length) / 2),
  1874. g = e - f;
  1875. a = new Array(g + 1).join(c) + a + new Array(f + 1).join(c);
  1876. break;
  1877. default:
  1878. a += new Array(b + 1 - a.length).join(c)
  1879. }
  1880. return a
  1881. },
  1882. isPlainObject: function(a) {
  1883. if ("object" != typeof a || a.nodeType || a === a.window) return !1;
  1884. try {
  1885. if (a.constructor && !{}.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) return !1
  1886. } catch (b) {
  1887. return !1
  1888. }
  1889. return !0
  1890. },
  1891. extend: function() {
  1892. var a, c, d, e, f, g, h = arguments[0] || {},
  1893. i = 1,
  1894. j = arguments.length,
  1895. k = !1;
  1896. for ("boolean" == typeof h && (k = h, h = arguments[1] || {}, i = 2), j === i && (h = this, --i); j > i; i++)
  1897. if (null != (a = arguments[i]))
  1898. for (c in a) d = h[c], e = a[c], h !== e && (k && e && (b.Utils.isPlainObject(e) || (f = Array.isArray(e))) ? (f ? (f = !1, g = d && Array.isArray(d) ? d : []) : g = d && b.Utils.isPlainObject(d) ? d : {}, h[c] = b.Utils.extend(k, g, e)) : void 0 !== e && (h[c] = e));
  1899. return h
  1900. },
  1901. mixin: function(a, c) {
  1902. if (!a || "object" != typeof a) return c;
  1903. for (var d in a) {
  1904. var e = a[d];
  1905. if (!e.childNodes && !e.cloneNode) {
  1906. var f = typeof a[d];
  1907. c[d] = a[d] && "object" === f ? typeof c[d] === f ? b.Utils.mixin(a[d], c[d]) : b.Utils.mixin(a[d], new e.constructor) : a[d]
  1908. }
  1909. }
  1910. return c
  1911. }
  1912. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  1913. var a = Array.prototype.slice;
  1914. return function(b) {
  1915. function c() {
  1916. var f = e.concat(a.call(arguments));
  1917. d.apply(this instanceof c ? this : b, f)
  1918. }
  1919. var d = this,
  1920. e = a.call(arguments, 1);
  1921. if ("function" != typeof d) throw new TypeError;
  1922. return c.prototype = function f(a) {
  1923. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  1924. }(d.prototype), c
  1925. }
  1926. }()), Array.isArray || (Array.isArray = function(a) {
  1927. return "[object Array]" == Object.prototype.toString.call(a)
  1928. }), Array.prototype.forEach || (Array.prototype.forEach = function(a) {
  1929. "use strict";
  1930. if (void 0 === this || null === this) throw new TypeError;
  1931. var b = Object(this),
  1932. c = b.length >>> 0;
  1933. if ("function" != typeof a) throw new TypeError;
  1934. 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)
  1935. }), "function" != typeof window.Uint32Array && "object" != typeof window.Uint32Array) {
  1936. var c = function(a) {
  1937. var b = new Array;
  1938. window[a] = function(a) {
  1939. if ("number" == typeof a) {
  1940. Array.call(this, a), this.length = a;
  1941. for (var b = 0; b < this.length; b++) this[b] = 0
  1942. } else {
  1943. Array.call(this, a.length), this.length = a.length;
  1944. for (var b = 0; b < this.length; b++) this[b] = a[b]
  1945. }
  1946. }, window[a].prototype = b, window[a].constructor = window[a]
  1947. };
  1948. c("Uint32Array"), c("Int16Array")
  1949. }
  1950. window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), b.Circle = function(a, b, c) {
  1951. a = a || 0, b = b || 0, c = c || 0, this.x = a, this.y = b, this._diameter = c, this._radius = c > 0 ? .5 * c : 0
  1952. }, b.Circle.prototype = {
  1953. type: null,
  1954. circumference: function() {
  1955. return 2 * Math.PI * this._radius
  1956. },
  1957. getBounds: function() {
  1958. return new b.Rectangle(this.x - this.radius, this.y - this.radius, 2 * this.radius, 2 * this.radius)
  1959. },
  1960. setTo: function(a, b, c) {
  1961. return this.x = a, this.y = b, this._diameter = c, this._radius = .5 * c, this
  1962. },
  1963. copyFrom: function(a) {
  1964. return this.setTo(a.x, a.y, a.diameter)
  1965. },
  1966. copyTo: function(a) {
  1967. return a.x = this.x, a.y = this.y, a.diameter = this._diameter, a
  1968. },
  1969. distance: function(a, c) {
  1970. return "undefined" == typeof c && (c = !1), c ? b.Math.distanceRounded(this.x, this.y, a.x, a.y) : b.Math.distance(this.x, this.y, a.x, a.y)
  1971. },
  1972. clone: function(a) {
  1973. return "undefined" == typeof a || null === a ? a = new b.Circle(this.x, this.y, this.diameter) : a.setTo(this.x, this.y, this.diameter), a
  1974. },
  1975. contains: function(a, c) {
  1976. return b.Circle.contains(this, a, c)
  1977. },
  1978. circumferencePoint: function(a, c, d) {
  1979. return b.Circle.circumferencePoint(this, a, c, d)
  1980. },
  1981. offset: function(a, b) {
  1982. return this.x += a, this.y += b, this
  1983. },
  1984. offsetPoint: function(a) {
  1985. return this.offset(a.x, a.y)
  1986. },
  1987. toString: function() {
  1988. return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"
  1989. }
  1990. }, b.Circle.prototype.constructor = b.Circle, Object.defineProperty(b.Circle.prototype, "diameter", {
  1991. get: function() {
  1992. return this._diameter
  1993. },
  1994. set: function(a) {
  1995. a > 0 && (this._diameter = a, this._radius = .5 * a)
  1996. }
  1997. }), Object.defineProperty(b.Circle.prototype, "radius", {
  1998. get: function() {
  1999. return this._radius
  2000. },
  2001. set: function(a) {
  2002. a > 0 && (this._radius = a, this._diameter = 2 * a)
  2003. }
  2004. }), Object.defineProperty(b.Circle.prototype, "left", {
  2005. get: function() {
  2006. return this.x - this._radius
  2007. },
  2008. set: function(a) {
  2009. a > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - a
  2010. }
  2011. }), Object.defineProperty(b.Circle.prototype, "right", {
  2012. get: function() {
  2013. return this.x + this._radius
  2014. },
  2015. set: function(a) {
  2016. a < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.x
  2017. }
  2018. }), Object.defineProperty(b.Circle.prototype, "top", {
  2019. get: function() {
  2020. return this.y - this._radius
  2021. },
  2022. set: function(a) {
  2023. a > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - a
  2024. }
  2025. }), Object.defineProperty(b.Circle.prototype, "bottom", {
  2026. get: function() {
  2027. return this.y + this._radius
  2028. },
  2029. set: function(a) {
  2030. a < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.y
  2031. }
  2032. }), Object.defineProperty(b.Circle.prototype, "area", {
  2033. get: function() {
  2034. return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
  2035. }
  2036. }), Object.defineProperty(b.Circle.prototype, "empty", {
  2037. get: function() {
  2038. return 0 === this._diameter
  2039. },
  2040. set: function(a) {
  2041. a === !0 && this.setTo(0, 0, 0)
  2042. }
  2043. }), b.Circle.contains = function(a, b, c) {
  2044. if (a.radius > 0 && b >= a.left && b <= a.right && c >= a.top && c <= a.bottom) {
  2045. var d = (a.x - b) * (a.x - b),
  2046. e = (a.y - c) * (a.y - c);
  2047. return d + e <= a.radius * a.radius
  2048. }
  2049. return !1
  2050. }, b.Circle.equals = function(a, b) {
  2051. return a.x == b.x && a.y == b.y && a.diameter == b.diameter
  2052. }, b.Circle.intersects = function(a, c) {
  2053. return b.Math.distance(a.x, a.y, c.x, c.y) <= a.radius + c.radius
  2054. }, b.Circle.circumferencePoint = function(a, c, d, e) {
  2055. return "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = new b.Point), d === !0 && (c = b.Math.degToRad(c)), e.x = a.x + a.radius * Math.cos(c), e.y = a.y + a.radius * Math.sin(c), e
  2056. }, b.Circle.intersectsRectangle = function(a, b) {
  2057. var c = Math.abs(a.x - b.x - b.halfWidth),
  2058. d = b.halfWidth + a.radius;
  2059. if (c > d) return !1;
  2060. var e = Math.abs(a.y - b.y - b.halfHeight),
  2061. f = b.halfHeight + a.radius;
  2062. if (e > f) return !1;
  2063. if (c <= b.halfWidth || e <= b.halfHeight) return !0;
  2064. var g = c - b.halfWidth,
  2065. h = e - b.halfHeight,
  2066. i = g * g,
  2067. j = h * h,
  2068. k = a.radius * a.radius;
  2069. return k >= i + j
  2070. }, PIXI.Circle = b.Circle, b.Point = function(a, b) {
  2071. a = a || 0, b = b || 0, this.x = a, this.y = b
  2072. }, b.Point.prototype = {
  2073. copyFrom: function(a) {
  2074. return this.setTo(a.x, a.y)
  2075. },
  2076. invert: function() {
  2077. return this.setTo(this.y, this.x)
  2078. },
  2079. setTo: function(a, b) {
  2080. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2081. },
  2082. set: function(a, b) {
  2083. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  2084. },
  2085. add: function(a, b) {
  2086. return this.x += a, this.y += b, this
  2087. },
  2088. subtract: function(a, b) {
  2089. return this.x -= a, this.y -= b, this
  2090. },
  2091. multiply: function(a, b) {
  2092. return this.x *= a, this.y *= b, this
  2093. },
  2094. divide: function(a, b) {
  2095. return this.x /= a, this.y /= b, this
  2096. },
  2097. clampX: function(a, c) {
  2098. return this.x = b.Math.clamp(this.x, a, c), this
  2099. },
  2100. clampY: function(a, c) {
  2101. return this.y = b.Math.clamp(this.y, a, c), this
  2102. },
  2103. clamp: function(a, c) {
  2104. return this.x = b.Math.clamp(this.x, a, c), this.y = b.Math.clamp(this.y, a, c), this
  2105. },
  2106. clone: function(a) {
  2107. return "undefined" == typeof a || null === a ? a = new b.Point(this.x, this.y) : a.setTo(this.x, this.y), a
  2108. },
  2109. copyTo: function(a) {
  2110. return a.x = this.x, a.y = this.y, a
  2111. },
  2112. distance: function(a, c) {
  2113. return b.Point.distance(this, a, c)
  2114. },
  2115. equals: function(a) {
  2116. return a.x === this.x && a.y === this.y
  2117. },
  2118. angle: function(a, c) {
  2119. return "undefined" == typeof c && (c = !1), c ? b.Math.radToDeg(Math.atan2(a.y - this.y, a.x - this.x)) : Math.atan2(a.y - this.y, a.x - this.x)
  2120. },
  2121. angleSq: function(a) {
  2122. return this.subtract(a).angle(a.subtract(this))
  2123. },
  2124. rotate: function(a, c, d, e, f) {
  2125. return b.Point.rotate(this, a, c, d, e, f)
  2126. },
  2127. getMagnitude: function() {
  2128. return Math.sqrt(this.x * this.x + this.y * this.y)
  2129. },
  2130. getMagnitudeSq: function() {
  2131. return this.x * this.x + this.y * this.y
  2132. },
  2133. setMagnitude: function(a) {
  2134. return this.normalize().multiply(a, a)
  2135. },
  2136. normalize: function() {
  2137. if (!this.isZero()) {
  2138. var a = this.getMagnitude();
  2139. this.x /= a, this.y /= a
  2140. }
  2141. return this
  2142. },
  2143. isZero: function() {
  2144. return 0 === this.x && 0 === this.y
  2145. },
  2146. dot: function(a) {
  2147. return this.x * a.x + this.y * a.y
  2148. },
  2149. cross: function(a) {
  2150. return this.x * a.y - this.y * a.x
  2151. },
  2152. perp: function() {
  2153. return this.setTo(-this.y, this.x)
  2154. },
  2155. rperp: function() {
  2156. return this.setTo(this.y, -this.x)
  2157. },
  2158. normalRightHand: function() {
  2159. return this.setTo(-1 * this.y, this.x)
  2160. },
  2161. toString: function() {
  2162. return "[{Point (x=" + this.x + " y=" + this.y + ")}]"
  2163. }
  2164. }, b.Point.prototype.constructor = b.Point, b.Point.add = function(a, c, d) {
  2165. return "undefined" == typeof d && (d = new b.Point), d.x = a.x + c.x, d.y = a.y + c.y, d
  2166. }, b.Point.subtract = function(a, c, d) {
  2167. return "undefined" == typeof d && (d = new b.Point), d.x = a.x - c.x, d.y = a.y - c.y, d
  2168. }, b.Point.multiply = function(a, c, d) {
  2169. return "undefined" == typeof d && (d = new b.Point), d.x = a.x * c.x, d.y = a.y * c.y, d
  2170. }, b.Point.divide = function(a, c, d) {
  2171. return "undefined" == typeof d && (d = new b.Point), d.x = a.x / c.x, d.y = a.y / c.y, d
  2172. }, b.Point.equals = function(a, b) {
  2173. return a.x === b.x && a.y === b.y
  2174. }, b.Point.angle = function(a, b) {
  2175. return Math.atan2(a.y - b.y, a.x - b.x)
  2176. }, b.Point.angleSq = function(a, b) {
  2177. return a.subtract(b).angle(b.subtract(a))
  2178. }, b.Point.negative = function(a, c) {
  2179. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.x, -a.y)
  2180. }, b.Point.multiplyAdd = function(a, c, d, e) {
  2181. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + c.x * d, a.y + c.y * d)
  2182. }, b.Point.interpolate = function(a, c, d, e) {
  2183. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + (c.x - a.x) * d, a.y + (c.y - a.y) * d)
  2184. }, b.Point.perp = function(a, c) {
  2185. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.y, a.x)
  2186. }, b.Point.rperp = function(a, c) {
  2187. return "undefined" == typeof c && (c = new b.Point), c.setTo(a.y, -a.x)
  2188. }, b.Point.distance = function(a, c, d) {
  2189. return "undefined" == typeof d && (d = !1), d ? b.Math.distanceRounded(a.x, a.y, c.x, c.y) : b.Math.distance(a.x, a.y, c.x, c.y)
  2190. }, b.Point.project = function(a, c, d) {
  2191. "undefined" == typeof d && (d = new b.Point);
  2192. var e = a.dot(c) / c.getMagnitudeSq();
  2193. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  2194. }, b.Point.projectUnit = function(a, c, d) {
  2195. "undefined" == typeof d && (d = new b.Point);
  2196. var e = a.dot(c);
  2197. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  2198. }, b.Point.normalRightHand = function(a, c) {
  2199. return "undefined" == typeof c && (c = new b.Point), c.setTo(-1 * a.y, a.x)
  2200. }, b.Point.normalize = function(a, c) {
  2201. "undefined" == typeof c && (c = new b.Point);
  2202. var d = a.getMagnitude();
  2203. return 0 !== d && c.setTo(a.x / d, a.y / d), c
  2204. }, b.Point.rotate = function(a, c, d, e, f, g) {
  2205. f = f || !1, g = g || null, f && (e = b.Math.degToRad(e)), null === g && (g = Math.sqrt((c - a.x) * (c - a.x) + (d - a.y) * (d - a.y)));
  2206. var h = e + Math.atan2(a.y - d, a.x - c);
  2207. return a.setTo(c + g * Math.cos(h), d + g * Math.sin(h))
  2208. }, b.Point.centroid = function(a, c) {
  2209. if ("undefined" == typeof c && (c = new b.Point), "[object Array]" !== Object.prototype.toString.call(a)) throw new Error("Phaser.Point. Parameter 'points' must be an array");
  2210. var d = a.length;
  2211. if (1 > d) throw new Error("Phaser.Point. Parameter 'points' array must not be empty");
  2212. if (1 === d) return c.copyFrom(a[0]), c;
  2213. for (var e = 0; d > e; e++) b.Point.add(c, a[e], c);
  2214. return c.divide(d, d), c
  2215. }, b.Point.parse = function(a, c, d) {
  2216. c = c || "x", d = d || "y";
  2217. var e = new b.Point;
  2218. return a[c] && (e.x = parseInt(a[c], 10)), a[d] && (e.y = parseInt(a[d], 10)), e
  2219. }, PIXI.Point = b.Point, b.Rectangle = function(a, b, c, d) {
  2220. a = a || 0, b = b || 0, c = c || 0, d = d || 0, this.x = a, this.y = b, this.width = c, this.height = d
  2221. }, b.Rectangle.prototype = {
  2222. offset: function(a, b) {
  2223. return this.x += a, this.y += b, this
  2224. },
  2225. offsetPoint: function(a) {
  2226. return this.offset(a.x, a.y)
  2227. },
  2228. setTo: function(a, b, c, d) {
  2229. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2230. },
  2231. scale: function(a, b) {
  2232. return "undefined" == typeof b && (b = a), this.width *= a, this.height *= b, this
  2233. },
  2234. centerOn: function(a, b) {
  2235. return this.centerX = a, this.centerY = b, this
  2236. },
  2237. floor: function() {
  2238. this.x = Math.floor(this.x), this.y = Math.floor(this.y)
  2239. },
  2240. floorAll: function() {
  2241. this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height)
  2242. },
  2243. copyFrom: function(a) {
  2244. return this.setTo(a.x, a.y, a.width, a.height)
  2245. },
  2246. copyTo: function(a) {
  2247. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2248. },
  2249. inflate: function(a, c) {
  2250. return b.Rectangle.inflate(this, a, c)
  2251. },
  2252. size: function(a) {
  2253. return b.Rectangle.size(this, a)
  2254. },
  2255. clone: function(a) {
  2256. return b.Rectangle.clone(this, a)
  2257. },
  2258. contains: function(a, c) {
  2259. return b.Rectangle.contains(this, a, c)
  2260. },
  2261. containsRect: function(a) {
  2262. return b.Rectangle.containsRect(a, this)
  2263. },
  2264. equals: function(a) {
  2265. return b.Rectangle.equals(this, a)
  2266. },
  2267. intersection: function(a, c) {
  2268. return b.Rectangle.intersection(this, a, c)
  2269. },
  2270. intersects: function(a, c) {
  2271. return b.Rectangle.intersects(this, a, c)
  2272. },
  2273. intersectsRaw: function(a, c, d, e, f) {
  2274. return b.Rectangle.intersectsRaw(this, a, c, d, e, f)
  2275. },
  2276. union: function(a, c) {
  2277. return b.Rectangle.union(this, a, c)
  2278. },
  2279. toString: function() {
  2280. return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"
  2281. }
  2282. }, Object.defineProperty(b.Rectangle.prototype, "halfWidth", {
  2283. get: function() {
  2284. return Math.round(this.width / 2)
  2285. }
  2286. }), Object.defineProperty(b.Rectangle.prototype, "halfHeight", {
  2287. get: function() {
  2288. return Math.round(this.height / 2)
  2289. }
  2290. }), Object.defineProperty(b.Rectangle.prototype, "bottom", {
  2291. get: function() {
  2292. return this.y + this.height
  2293. },
  2294. set: function(a) {
  2295. this.height = a <= this.y ? 0 : a - this.y
  2296. }
  2297. }), Object.defineProperty(b.Rectangle.prototype, "bottomRight", {
  2298. get: function() {
  2299. return new b.Point(this.right, this.bottom)
  2300. },
  2301. set: function(a) {
  2302. this.right = a.x, this.bottom = a.y
  2303. }
  2304. }), Object.defineProperty(b.Rectangle.prototype, "left", {
  2305. get: function() {
  2306. return this.x
  2307. },
  2308. set: function(a) {
  2309. this.width = a >= this.right ? 0 : this.right - a, this.x = a
  2310. }
  2311. }), Object.defineProperty(b.Rectangle.prototype, "right", {
  2312. get: function() {
  2313. return this.x + this.width
  2314. },
  2315. set: function(a) {
  2316. this.width = a <= this.x ? 0 : a - this.x
  2317. }
  2318. }), Object.defineProperty(b.Rectangle.prototype, "volume", {
  2319. get: function() {
  2320. return this.width * this.height
  2321. }
  2322. }), Object.defineProperty(b.Rectangle.prototype, "perimeter", {
  2323. get: function() {
  2324. return 2 * this.width + 2 * this.height
  2325. }
  2326. }), Object.defineProperty(b.Rectangle.prototype, "centerX", {
  2327. get: function() {
  2328. return this.x + this.halfWidth
  2329. },
  2330. set: function(a) {
  2331. this.x = a - this.halfWidth
  2332. }
  2333. }), Object.defineProperty(b.Rectangle.prototype, "centerY", {
  2334. get: function() {
  2335. return this.y + this.halfHeight
  2336. },
  2337. set: function(a) {
  2338. this.y = a - this.halfHeight
  2339. }
  2340. }), Object.defineProperty(b.Rectangle.prototype, "randomX", {
  2341. get: function() {
  2342. return this.x + Math.random() * this.width
  2343. }
  2344. }), Object.defineProperty(b.Rectangle.prototype, "randomY", {
  2345. get: function() {
  2346. return this.y + Math.random() * this.height
  2347. }
  2348. }), Object.defineProperty(b.Rectangle.prototype, "top", {
  2349. get: function() {
  2350. return this.y
  2351. },
  2352. set: function(a) {
  2353. a >= this.bottom ? (this.height = 0, this.y = a) : this.height = this.bottom - a
  2354. }
  2355. }), Object.defineProperty(b.Rectangle.prototype, "topLeft", {
  2356. get: function() {
  2357. return new b.Point(this.x, this.y)
  2358. },
  2359. set: function(a) {
  2360. this.x = a.x, this.y = a.y
  2361. }
  2362. }), Object.defineProperty(b.Rectangle.prototype, "topRight", {
  2363. get: function() {
  2364. return new b.Point(this.x + this.width, this.y)
  2365. },
  2366. set: function(a) {
  2367. this.right = a.x, this.y = a.y
  2368. }
  2369. }), Object.defineProperty(b.Rectangle.prototype, "empty", {
  2370. get: function() {
  2371. return !this.width || !this.height
  2372. },
  2373. set: function(a) {
  2374. a === !0 && this.setTo(0, 0, 0, 0)
  2375. }
  2376. }), b.Rectangle.prototype.constructor = b.Rectangle, b.Rectangle.inflate = function(a, b, c) {
  2377. return a.x -= b, a.width += 2 * b, a.y -= c, a.height += 2 * c, a
  2378. }, b.Rectangle.inflatePoint = function(a, c) {
  2379. return b.Rectangle.inflate(a, c.x, c.y)
  2380. }, b.Rectangle.size = function(a, c) {
  2381. return "undefined" == typeof c || null === c ? c = new b.Point(a.width, a.height) : c.setTo(a.width, a.height), c
  2382. }, b.Rectangle.clone = function(a, c) {
  2383. return "undefined" == typeof c || null === c ? c = new b.Rectangle(a.x, a.y, a.width, a.height) : c.setTo(a.x, a.y, a.width, a.height), c
  2384. }, b.Rectangle.contains = function(a, b, c) {
  2385. return a.width <= 0 || a.height <= 0 ? !1 : b >= a.x && b < a.right && c >= a.y && c < a.bottom
  2386. }, b.Rectangle.containsRaw = function(a, b, c, d, e, f) {
  2387. return e >= a && a + c > e && f >= b && b + d > f
  2388. }, b.Rectangle.containsPoint = function(a, c) {
  2389. return b.Rectangle.contains(a, c.x, c.y)
  2390. }, b.Rectangle.containsRect = function(a, b) {
  2391. return a.volume > b.volume ? !1 : a.x >= b.x && a.y >= b.y && a.right < b.right && a.bottom < b.bottom
  2392. }, b.Rectangle.equals = function(a, b) {
  2393. return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
  2394. }, b.Rectangle.intersection = function(a, c, d) {
  2395. return "undefined" == typeof d && (d = new b.Rectangle), b.Rectangle.intersects(a, c) && (d.x = Math.max(a.x, c.x), d.y = Math.max(a.y, c.y), d.width = Math.min(a.right, c.right) - d.x, d.height = Math.min(a.bottom, c.bottom) - d.y), d
  2396. }, b.Rectangle.intersects = function(a, b) {
  2397. 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)
  2398. }, b.Rectangle.intersectsRaw = function(a, b, c, d, e, f) {
  2399. return "undefined" == typeof f && (f = 0), !(b > a.right + f || c < a.left - f || d > a.bottom + f || e < a.top - f)
  2400. }, b.Rectangle.union = function(a, c, d) {
  2401. return "undefined" == typeof d && (d = new b.Rectangle), d.setTo(Math.min(a.x, c.x), Math.min(a.y, c.y), Math.max(a.right, c.right) - Math.min(a.left, c.left), Math.max(a.bottom, c.bottom) - Math.min(a.top, c.top))
  2402. }, b.Rectangle.aabb = function(a, c) {
  2403. "undefined" == typeof c && (c = new b.Rectangle);
  2404. var d = Number.MIN_VALUE,
  2405. e = Number.MAX_VALUE,
  2406. f = Number.MIN_VALUE,
  2407. g = Number.MAX_VALUE;
  2408. return a.forEach(function(a) {
  2409. a.x > d && (d = a.x), a.x < e && (e = a.x), a.y > f && (f = a.y), a.y < g && (g = a.y)
  2410. }), c.setTo(e, g, d - e, f - g), c
  2411. }, PIXI.Rectangle = b.Rectangle, PIXI.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Line = function(a, c, d, e) {
  2412. a = a || 0, c = c || 0, d = d || 0, e = e || 0, this.start = new b.Point(a, c), this.end = new b.Point(d, e)
  2413. }, b.Line.prototype = {
  2414. setTo: function(a, b, c, d) {
  2415. return this.start.setTo(a, b), this.end.setTo(c, d), this
  2416. },
  2417. fromSprite: function(a, b, c) {
  2418. 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)
  2419. },
  2420. intersects: function(a, c, d) {
  2421. return b.Line.intersectsPoints(this.start, this.end, a.start, a.end, c, d)
  2422. },
  2423. pointOnLine: function(a, b) {
  2424. return (a - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (b - this.start.y)
  2425. },
  2426. pointOnSegment: function(a, b) {
  2427. var c = Math.min(this.start.x, this.end.x),
  2428. d = Math.max(this.start.x, this.end.x),
  2429. e = Math.min(this.start.y, this.end.y),
  2430. f = Math.max(this.start.y, this.end.y);
  2431. return this.pointOnLine(a, b) && a >= c && d >= a && b >= e && f >= b
  2432. },
  2433. coordinatesOnLine: function(a, b) {
  2434. "undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = []);
  2435. var c = Math.round(this.start.x),
  2436. d = Math.round(this.start.y),
  2437. e = Math.round(this.end.x),
  2438. f = Math.round(this.end.y),
  2439. g = Math.abs(e - c),
  2440. h = Math.abs(f - d),
  2441. i = e > c ? 1 : -1,
  2442. j = f > d ? 1 : -1,
  2443. k = g - h;
  2444. b.push([c, d]);
  2445. for (var l = 1; c != e || d != f;) {
  2446. var m = k << 1;
  2447. m > -h && (k -= h, c += i), g > m && (k += g, d += j), l % a === 0 && b.push([c, d]), l++
  2448. }
  2449. return b
  2450. },
  2451. clone: function(a) {
  2452. return "undefined" == typeof a || null === a ? a = new b.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
  2453. }
  2454. }, Object.defineProperty(b.Line.prototype, "length", {
  2455. get: function() {
  2456. 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))
  2457. }
  2458. }), Object.defineProperty(b.Line.prototype, "angle", {
  2459. get: function() {
  2460. return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x)
  2461. }
  2462. }), Object.defineProperty(b.Line.prototype, "slope", {
  2463. get: function() {
  2464. return (this.end.y - this.start.y) / (this.end.x - this.start.x)
  2465. }
  2466. }), Object.defineProperty(b.Line.prototype, "perpSlope", {
  2467. get: function() {
  2468. return -((this.end.x - this.start.x) / (this.end.y - this.start.y))
  2469. }
  2470. }), Object.defineProperty(b.Line.prototype, "x", {
  2471. get: function() {
  2472. return Math.min(this.start.x, this.end.x)
  2473. }
  2474. }), Object.defineProperty(b.Line.prototype, "y", {
  2475. get: function() {
  2476. return Math.min(this.start.y, this.end.y)
  2477. }
  2478. }), Object.defineProperty(b.Line.prototype, "left", {
  2479. get: function() {
  2480. return Math.min(this.start.x, this.end.x)
  2481. }
  2482. }), Object.defineProperty(b.Line.prototype, "right", {
  2483. get: function() {
  2484. return Math.max(this.start.x, this.end.x)
  2485. }
  2486. }), Object.defineProperty(b.Line.prototype, "top", {
  2487. get: function() {
  2488. return Math.min(this.start.y, this.end.y)
  2489. }
  2490. }), Object.defineProperty(b.Line.prototype, "bottom", {
  2491. get: function() {
  2492. return Math.max(this.start.y, this.end.y)
  2493. }
  2494. }), Object.defineProperty(b.Line.prototype, "width", {
  2495. get: function() {
  2496. return Math.abs(this.start.x - this.end.x)
  2497. }
  2498. }), Object.defineProperty(b.Line.prototype, "height", {
  2499. get: function() {
  2500. return Math.abs(this.start.y - this.end.y)
  2501. }
  2502. }), b.Line.intersectsPoints = function(a, c, d, e, f, g) {
  2503. "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = new b.Point);
  2504. var h = c.y - a.y,
  2505. i = e.y - d.y,
  2506. j = a.x - c.x,
  2507. k = d.x - e.x,
  2508. l = c.x * a.y - a.x * c.y,
  2509. m = e.x * d.y - d.x * e.y,
  2510. n = h * k - i * j;
  2511. if (0 === n) return null;
  2512. if (g.x = (j * m - k * l) / n, g.y = (i * l - h * m) / n, f) {
  2513. var o = (e.y - d.y) * (c.x - a.x) - (e.x - d.x) * (c.y - a.y),
  2514. p = ((e.x - d.x) * (a.y - d.y) - (e.y - d.y) * (a.x - d.x)) / o,
  2515. q = ((c.x - a.x) * (a.y - d.y) - (c.y - a.y) * (a.x - d.x)) / o;
  2516. return p >= 0 && 1 >= p && q >= 0 && 1 >= q ? g : null
  2517. }
  2518. return g
  2519. }, b.Line.intersects = function(a, c, d, e) {
  2520. return b.Line.intersectsPoints(a.start, a.end, c.start, c.end, d, e)
  2521. }, b.Ellipse = function(a, c, d, e) {
  2522. this.type = b.ELLIPSE, a = a || 0, c = c || 0, d = d || 0, e = e || 0, this.x = a, this.y = c, this.width = d, this.height = e
  2523. }, b.Ellipse.prototype = {
  2524. setTo: function(a, b, c, d) {
  2525. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2526. },
  2527. getBounds: function() {
  2528. return new b.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height)
  2529. },
  2530. copyFrom: function(a) {
  2531. return this.setTo(a.x, a.y, a.width, a.height)
  2532. },
  2533. copyTo: function(a) {
  2534. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2535. },
  2536. clone: function(a) {
  2537. return "undefined" == typeof a || null === a ? a = new b.Ellipse(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  2538. },
  2539. contains: function(a, c) {
  2540. return b.Ellipse.contains(this, a, c)
  2541. },
  2542. toString: function() {
  2543. return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"
  2544. }
  2545. }, b.Ellipse.prototype.constructor = b.Ellipse, Object.defineProperty(b.Ellipse.prototype, "left", {
  2546. get: function() {
  2547. return this.x
  2548. },
  2549. set: function(a) {
  2550. this.x = a
  2551. }
  2552. }), Object.defineProperty(b.Ellipse.prototype, "right", {
  2553. get: function() {
  2554. return this.x + this.width
  2555. },
  2556. set: function(a) {
  2557. this.width = a < this.x ? 0 : this.x + a
  2558. }
  2559. }), Object.defineProperty(b.Ellipse.prototype, "top", {
  2560. get: function() {
  2561. return this.y
  2562. },
  2563. set: function(a) {
  2564. this.y = a
  2565. }
  2566. }), Object.defineProperty(b.Ellipse.prototype, "bottom", {
  2567. get: function() {
  2568. return this.y + this.height
  2569. },
  2570. set: function(a) {
  2571. this.height = a < this.y ? 0 : this.y + a
  2572. }
  2573. }), Object.defineProperty(b.Ellipse.prototype, "empty", {
  2574. get: function() {
  2575. return 0 === this.width || 0 === this.height
  2576. },
  2577. set: function(a) {
  2578. a === !0 && this.setTo(0, 0, 0, 0)
  2579. }
  2580. }), b.Ellipse.contains = function(a, b, c) {
  2581. if (a.width <= 0 || a.height <= 0) return !1;
  2582. var d = (b - a.x) / a.width - .5,
  2583. e = (c - a.y) / a.height - .5;
  2584. return d *= d, e *= e, .25 > d + e
  2585. }, b.Ellipse.prototype.getBounds = function() {
  2586. return new b.Rectangle(this.x, this.y, this.width, this.height)
  2587. }, PIXI.Ellipse = b.Ellipse, b.Polygon = function(a) {
  2588. if (this.type = b.POLYGON, a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
  2589. for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
  2590. a = c
  2591. }
  2592. this.points = a, this.closed = !0
  2593. }, b.Polygon.prototype = {
  2594. clone: function(a) {
  2595. var c = this.points.slice();
  2596. return "undefined" == typeof a || null === a ? a = new b.Polygon(c) : a.setTo(c), a
  2597. },
  2598. contains: function(a, b) {
  2599. for (var c = !1, d = this.points.length / 2, e = 0, f = d - 1; d > e; f = e++) {
  2600. var g = this.points[2 * e].x,
  2601. h = this.points[2 * e + 1].y,
  2602. i = this.points[2 * f].x,
  2603. j = this.points[2 * f + 1].y,
  2604. k = h > b != j > b && (i - g) * (b - h) / (j - h) + g > a;
  2605. k && (c = !c)
  2606. }
  2607. return c
  2608. },
  2609. setTo: function(a) {
  2610. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
  2611. for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
  2612. a = c
  2613. }
  2614. return this.points = a, this
  2615. }
  2616. }, b.Polygon.prototype.constructor = b.Polygon, Object.defineProperty(b.Polygon.prototype, "points", {
  2617. get: function() {
  2618. return this._points
  2619. },
  2620. set: function(a) {
  2621. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  2622. for (var c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  2623. a = c
  2624. }
  2625. this._points = a
  2626. }
  2627. }), Object.defineProperty(b.Polygon.prototype, "area", {
  2628. get: function() {
  2629. var a, b, c, d, e, f = Number.MAX_VALUE,
  2630. g = 0;
  2631. for (e = 0; e < this.points.length; e++) this.points[e].y < f && (f = this.points[e].y);
  2632. for (e = 0; e < this.points.length; e++) a = this.points[e], b = e === this.points.length - 1 ? this.points[0] : this.points[e + 1], c = (a.y - f + (b.y - f)) / 2, d = a.x - b.x, g += c * d;
  2633. return g
  2634. }
  2635. }), PIXI.Graphics = function() {
  2636. PIXI.DisplayObjectContainer.call(this), this.renderable = !0, this.fillAlpha = 1, this.lineWidth = 0, this.lineColor = 0, this.graphicsData = [], this.tint = 16777215, this.blendMode = PIXI.blendModes.NORMAL, this.currentPath = null, this._webGL = [], this.isMask = !1, this.boundsPadding = 0, this.dirty = !0, this.webGLDirty = !1, this.cachedSpriteDirty = !1
  2637. }, PIXI.Graphics.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), PIXI.Graphics.prototype.constructor = PIXI.Graphics, Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", {
  2638. get: function() {
  2639. return this._cacheAsBitmap
  2640. },
  2641. set: function(a) {
  2642. this._cacheAsBitmap = a, this._cacheAsBitmap ? this._generateCachedSprite() : (this.destroyCachedSprite(), this.dirty = !0)
  2643. }
  2644. }), PIXI.Graphics.prototype.lineStyle = function(a, b, c) {
  2645. if (this.lineWidth = a || 0, this.lineColor = b || 0, this.lineAlpha = arguments.length < 3 ? 1 : c, this.currentPath) {
  2646. if (this.currentPath.shape.points.length) return this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))), this;
  2647. this.currentPath.lineWidth = this.lineWidth, this.currentPath.lineColor = this.lineColor, this.currentPath.lineAlpha = this.lineAlpha
  2648. }
  2649. return this
  2650. }, PIXI.Graphics.prototype.moveTo = function(a, b) {
  2651. return this.drawShape(new PIXI.Polygon([a, b])), this
  2652. }, PIXI.Graphics.prototype.lineTo = function(a, b) {
  2653. return this.currentPath.shape.points.push(a, b), this.dirty = !0, this
  2654. }, PIXI.Graphics.prototype.quadraticCurveTo = function(a, b, c, d) {
  2655. this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
  2656. var e, f, g = 20,
  2657. h = this.currentPath.shape.points;
  2658. 0 === h.length && this.moveTo(0, 0);
  2659. 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);
  2660. return this.dirty = !0, this
  2661. }, PIXI.Graphics.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
  2662. this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
  2663. 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);
  2664. return this.dirty = !0, this
  2665. }, PIXI.Graphics.prototype.arcTo = function(a, b, c, d, e) {
  2666. this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [a, b]) : this.moveTo(a, b), 0 === this.currentPath.length && this.moveTo(a, b);
  2667. var f = this.currentPath,
  2668. g = f[f.length - 2],
  2669. h = f[f.length - 1],
  2670. i = h - b,
  2671. j = g - a,
  2672. k = d - b,
  2673. l = c - a,
  2674. m = Math.abs(i * l - j * k);
  2675. if (1e-8 > m || 0 === e) f.push(a, b);
  2676. else {
  2677. var n = i * i + j * j,
  2678. o = k * k + l * l,
  2679. p = i * k + j * l,
  2680. q = e * Math.sqrt(n) / m,
  2681. r = e * Math.sqrt(o) / m,
  2682. s = q * p / n,
  2683. t = r * p / o,
  2684. u = q * l + r * j,
  2685. v = q * k + r * i,
  2686. w = j * (r + s),
  2687. x = i * (r + s),
  2688. y = l * (q + t),
  2689. z = k * (q + t),
  2690. A = Math.atan2(x - v, w - u),
  2691. B = Math.atan2(z - v, y - u);
  2692. this.arc(u + a, v + b, e, A, B, j * k > l * i)
  2693. }
  2694. return this.dirty = !0, this
  2695. }, PIXI.Graphics.prototype.arc = function(a, b, c, d, e, f) {
  2696. var g = a + Math.cos(d) * c,
  2697. h = b + Math.sin(d) * c,
  2698. i = this.currentPath.shape.points;
  2699. if ((0 !== i.length && i[i.length - 2] !== g || i[i.length - 1] !== h) && (this.moveTo(g, h), i = this.currentPath.shape.points), d === e) return this;
  2700. !f && d >= e ? e += 2 * Math.PI : f && e >= d && (d += 2 * Math.PI);
  2701. var j = f ? -1 * (d - e) : e - d,
  2702. k = Math.abs(j) / (2 * Math.PI) * 40;
  2703. if (0 === j) return this;
  2704. for (var l = j / (2 * k), m = 2 * l, n = Math.cos(l), o = Math.sin(l), p = k - 1, q = p % 1 / p, r = 0; p >= r; r++) {
  2705. var s = r + q * r,
  2706. t = l + d + m * s,
  2707. u = Math.cos(t),
  2708. v = -Math.sin(t);
  2709. i.push((n * u + o * v) * c + a, (n * -v + o * u) * c + b)
  2710. }
  2711. return this.dirty = !0, this
  2712. }, PIXI.Graphics.prototype.beginFill = function(a, b) {
  2713. 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
  2714. }, PIXI.Graphics.prototype.endFill = function() {
  2715. return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this
  2716. }, PIXI.Graphics.prototype.drawRect = function(a, b, c, d) {
  2717. return this.drawShape(new PIXI.Rectangle(a, b, c, d)), this
  2718. }, PIXI.Graphics.prototype.drawRoundedRect = function(a, b, c, d, e) {
  2719. return this.drawShape({
  2720. points: [a, b, c, d, e],
  2721. type: PIXI.Graphics.RREC
  2722. }), this
  2723. }, PIXI.Graphics.prototype.drawCircle = function(a, b, c) {
  2724. return this.drawShape(new PIXI.Circle(a, b, c)), this
  2725. }, PIXI.Graphics.prototype.drawEllipse = function(a, b, c, d) {
  2726. return this.drawShape(new PIXI.Ellipse(a, b, c, d)), this
  2727. }, PIXI.Graphics.prototype.drawPolygon = function(a) {
  2728. return a instanceof Array || (a = Array.prototype.slice.call(arguments)), this.drawShape(new PIXI.Polygon(a)), this
  2729. }, PIXI.Graphics.prototype.clear = function() {
  2730. return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this.clearDirty = !0, this.graphicsData = [], this
  2731. }, PIXI.Graphics.prototype.generateTexture = function(a, b) {
  2732. a = a || 1;
  2733. var c = this.getBounds(),
  2734. d = new PIXI.CanvasBuffer(c.width * a, c.height * a),
  2735. e = PIXI.Texture.fromCanvas(d.canvas, b);
  2736. return e.baseTexture.resolution = a, d.context.scale(a, a), d.context.translate(-c.x, -c.y), PIXI.CanvasGraphics.renderGraphics(this, d.context), e
  2737. }, PIXI.Graphics.prototype._renderWebGL = function(a) {
  2738. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  2739. if (this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.alpha = this.alpha, void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, a);
  2740. 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) {
  2741. a.spriteBatch.currentBlendMode = this.blendMode;
  2742. var b = PIXI.blendModesWebGL[a.spriteBatch.currentBlendMode];
  2743. a.spriteBatch.gl.blendFunc(b[0], b[1])
  2744. }
  2745. if (this.webGLDirty && (this.dirty = !0, this.webGLDirty = !1), PIXI.WebGLGraphics.renderGraphics(this, a), this.children.length) {
  2746. a.spriteBatch.start();
  2747. for (var c = 0, d = this.children.length; d > c; c++) this.children[c]._renderWebGL(a);
  2748. a.spriteBatch.stop()
  2749. }
  2750. this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this.mask, a), a.drawCount++, a.spriteBatch.start()
  2751. }
  2752. }, PIXI.Graphics.prototype._renderCanvas = function(a) {
  2753. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  2754. if (this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.alpha = this.alpha, void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite, a);
  2755. var b = a.context,
  2756. c = this.worldTransform;
  2757. this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, b.globalCompositeOperation = PIXI.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a);
  2758. var d = a.resolution;
  2759. b.setTransform(c.a * d, c.b * d, c.c * d, c.d * d, c.tx * d, c.ty * d), PIXI.CanvasGraphics.renderGraphics(this, b);
  2760. for (var e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
  2761. this._mask && a.maskManager.popMask(a)
  2762. }
  2763. }, PIXI.Graphics.prototype.getBounds = function(a) {
  2764. this.dirty && (this.updateBounds(), this.webGLDirty = !0, this.cachedSpriteDirty = !0, this.dirty = !1);
  2765. var b = this._bounds,
  2766. c = b.x,
  2767. d = b.width + b.x,
  2768. e = b.y,
  2769. f = b.height + b.y,
  2770. g = a || this.worldTransform,
  2771. h = g.a,
  2772. i = g.c,
  2773. j = g.b,
  2774. k = g.d,
  2775. l = g.tx,
  2776. m = g.ty,
  2777. n = h * d + j * f + l,
  2778. o = k * f + i * d + m,
  2779. p = h * c + j * f + l,
  2780. q = k * f + i * c + m,
  2781. r = h * c + j * e + l,
  2782. s = k * e + i * c + m,
  2783. t = h * d + j * e + l,
  2784. u = k * e + i * d + m,
  2785. v = n,
  2786. w = o,
  2787. x = n,
  2788. y = o;
  2789. return x = x > p ? p : x, x = x > r ? r : x, x = x > t ? t : x, y = y > q ? q : y, y = y > s ? s : y, y = y > u ? u : y, v = p > v ? p : v, v = r > v ? r : v, v = t > v ? t : v, w = q > w ? q : w, w = s > w ? s : w, w = u > w ? u : w, b.x = x, b.width = v - x, b.y = y, b.height = w - y, b
  2790. }, PIXI.Graphics.prototype.updateBounds = function() {
  2791. var a = 1 / 0,
  2792. b = -1 / 0,
  2793. c = 1 / 0,
  2794. d = -1 / 0;
  2795. if (this.graphicsData.length)
  2796. for (var e, f, g, h, i, j, k = 0; k < this.graphicsData.length; k++) {
  2797. var l = this.graphicsData[k],
  2798. m = l.type,
  2799. n = l.lineWidth;
  2800. if (e = l.shape, m === PIXI.Graphics.RECT || m === PIXI.Graphics.RRECT) g = e.x - n / 2, h = e.y - n / 2, i = e.width + n, j = e.height + n, a = a > g ? g : a, b = g + i > b ? g + i : b, c = c > h ? h : c, d = h + j > d ? h + j : d;
  2801. else if (m === PIXI.Graphics.CIRC) g = e.x, h = e.y, i = e.radius + n / 2, j = e.radius + n / 2, a = a > g - i ? g - i : a, b = g + i > b ? g + i : b, c = c > h - j ? h - j : c, d = h + j > d ? h + j : d;
  2802. else if (m === PIXI.Graphics.ELIP) g = e.x, h = e.y, i = e.width + n / 2, j = e.height + n / 2, a = a > g - i ? g - i : a, b = g + i > b ? g + i : b, c = c > h - j ? h - j : c, d = h + j > d ? h + j : d;
  2803. else {
  2804. f = e.points;
  2805. for (var o = 0; o < f.length; o += 2) g = f[o], h = f[o + 1], a = a > g - n ? g - n : a, b = g + n > b ? g + n : b, c = c > h - n ? h - n : c, d = h + n > d ? h + n : d
  2806. }
  2807. } else a = 0, b = 0, c = 0, d = 0;
  2808. var p = this.boundsPadding,
  2809. q = this._bounds;
  2810. q.x = a - p, q.width = b - a + 2 * p, q.y = c - p, q.height = d - c + 2 * p
  2811. }, PIXI.Graphics.prototype._generateCachedSprite = function() {
  2812. var a = this.getLocalBounds();
  2813. if (this._cachedSprite) this._cachedSprite.buffer.resize(a.width, a.height);
  2814. else {
  2815. var b = new PIXI.CanvasBuffer(a.width, a.height),
  2816. c = PIXI.Texture.fromCanvas(b.canvas);
  2817. this._cachedSprite = new PIXI.Sprite(c), this._cachedSprite.buffer = b, this._cachedSprite.worldTransform = this.worldTransform
  2818. }
  2819. 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, PIXI.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context), this._cachedSprite.alpha = this.alpha
  2820. }, PIXI.Graphics.prototype.updateCachedSpriteTexture = function() {
  2821. var a = this._cachedSprite,
  2822. b = a.texture,
  2823. c = a.buffer.canvas;
  2824. 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()
  2825. }, PIXI.Graphics.prototype.destroyCachedSprite = function() {
  2826. this._cachedSprite.texture.destroy(!0), this._cachedSprite = null
  2827. }, PIXI.Graphics.prototype.drawShape = function(a) {
  2828. this.currentPath && this.currentPath.shape.points.length <= 2 && this.graphicsData.pop(), this.currentPath = null;
  2829. var b = new PIXI.GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, a);
  2830. return this.graphicsData.push(b), b.type === PIXI.Graphics.POLY && (b.shape.closed = this.filling, this.currentPath = b), this.dirty = !0, b
  2831. }, PIXI.GraphicsData = function(a, b, c, d, e, f, g) {
  2832. this.lineWidth = a, this.lineColor = b, this.lineAlpha = c, this.fillColor = d, this.fillAlpha = e, this.fill = f, this.shape = g, this.type = g.type
  2833. }, PIXI.Graphics.POLY = 0, PIXI.Graphics.RECT = 1, PIXI.Graphics.CIRC = 2, PIXI.Graphics.ELIP = 3, PIXI.Graphics.RREC = 4, PIXI.Polygon.prototype.type = PIXI.Graphics.POLY, PIXI.Rectangle.prototype.type = PIXI.Graphics.RECT, PIXI.Circle.prototype.type = PIXI.Graphics.CIRC, PIXI.Ellipse.prototype.type = PIXI.Graphics.ELIP, b.Camera = function(a, c, d, e, f, g) {
  2834. this.game = a, this.world = a.world, this.id = 0, this.view = new b.Rectangle(d, e, f, g), this.screenView = new b.Rectangle(d, e, f, g), this.bounds = new b.Rectangle(d, e, f, g), this.deadzone = null, this.visible = !0, this.roundPx = !0, this.atLimit = {
  2835. x: !1,
  2836. y: !1
  2837. }, this.target = null, this._edge = 0, this._position = new b.Point, this.displayObject = null, this.scale = null, this._targetPosition = new b.Point
  2838. }, b.Camera.FOLLOW_LOCKON = 0, b.Camera.FOLLOW_PLATFORMER = 1, b.Camera.FOLLOW_TOPDOWN = 2, b.Camera.FOLLOW_TOPDOWN_TIGHT = 3, b.Camera.prototype = {
  2839. follow: function(a, c) {
  2840. "undefined" == typeof c && (c = b.Camera.FOLLOW_LOCKON), this.target = a;
  2841. var d;
  2842. switch (c) {
  2843. case b.Camera.FOLLOW_PLATFORMER:
  2844. var e = this.width / 8,
  2845. f = this.height / 3;
  2846. this.deadzone = new b.Rectangle((this.width - e) / 2, (this.height - f) / 2 - .25 * f, e, f);
  2847. break;
  2848. case b.Camera.FOLLOW_TOPDOWN:
  2849. d = Math.max(this.width, this.height) / 4, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2850. break;
  2851. case b.Camera.FOLLOW_TOPDOWN_TIGHT:
  2852. d = Math.max(this.width, this.height) / 8, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2853. break;
  2854. case b.Camera.FOLLOW_LOCKON:
  2855. this.deadzone = null;
  2856. break;
  2857. default:
  2858. this.deadzone = null
  2859. }
  2860. },
  2861. unfollow: function() {
  2862. this.target = null
  2863. },
  2864. focusOn: function(a) {
  2865. this.setPosition(Math.round(a.x - this.view.halfWidth), Math.round(a.y - this.view.halfHeight))
  2866. },
  2867. focusOnXY: function(a, b) {
  2868. this.setPosition(Math.round(a - this.view.halfWidth), Math.round(b - this.view.halfHeight))
  2869. },
  2870. update: function() {
  2871. 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
  2872. },
  2873. updateTarget: function() {
  2874. this._targetPosition.copyFrom(this.target).multiply(this.target.parent ? this.target.parent.worldTransform.a : 1, this.target.parent ? this.target.parent.worldTransform.d : 1), 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)
  2875. },
  2876. setBoundsToWorld: function() {
  2877. 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)
  2878. },
  2879. checkBounds: function() {
  2880. 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)
  2881. },
  2882. setPosition: function(a, b) {
  2883. this.view.x = a, this.view.y = b, this.bounds && this.checkBounds()
  2884. },
  2885. setSize: function(a, b) {
  2886. this.view.width = a, this.view.height = b
  2887. },
  2888. reset: function() {
  2889. this.target = null, this.view.x = 0, this.view.y = 0
  2890. }
  2891. }, b.Camera.prototype.constructor = b.Camera, Object.defineProperty(b.Camera.prototype, "x", {
  2892. get: function() {
  2893. return this.view.x
  2894. },
  2895. set: function(a) {
  2896. this.view.x = a, this.bounds && this.checkBounds()
  2897. }
  2898. }), Object.defineProperty(b.Camera.prototype, "y", {
  2899. get: function() {
  2900. return this.view.y
  2901. },
  2902. set: function(a) {
  2903. this.view.y = a, this.bounds && this.checkBounds()
  2904. }
  2905. }), Object.defineProperty(b.Camera.prototype, "position", {
  2906. get: function() {
  2907. return this._position.set(this.view.centerX, this.view.centerY), this._position
  2908. },
  2909. set: function(a) {
  2910. "undefined" != typeof a.x && (this.view.x = a.x), "undefined" != typeof a.y && (this.view.y = a.y), this.bounds && this.checkBounds()
  2911. }
  2912. }), Object.defineProperty(b.Camera.prototype, "width", {
  2913. get: function() {
  2914. return this.view.width
  2915. },
  2916. set: function(a) {
  2917. this.view.width = a
  2918. }
  2919. }), Object.defineProperty(b.Camera.prototype, "height", {
  2920. get: function() {
  2921. return this.view.height
  2922. },
  2923. set: function(a) {
  2924. this.view.height = a
  2925. }
  2926. }), b.State = function() {
  2927. this.game = null, this.add = null, this.make = null, this.camera = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.sound = null, this.scale = null, this.stage = null, this.time = null, this.tweens = null, this.world = null, this.particles = null, this.physics = null, this.rnd = null
  2928. }, b.State.prototype = {
  2929. preload: function() {},
  2930. loadUpdate: function() {},
  2931. loadRender: function() {},
  2932. create: function() {},
  2933. update: function() {},
  2934. render: function() {},
  2935. resize: function() {},
  2936. paused: function() {},
  2937. pauseUpdate: function() {},
  2938. shutdown: function() {}
  2939. }, b.State.prototype.constructor = b.State, b.StateManager = function(a, b) {
  2940. 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
  2941. }, b.StateManager.prototype = {
  2942. boot: function() {
  2943. this.game.onPause.add(this.pause, this), this.game.onResume.add(this.resume, this), this.game.load.onLoadComplete.add(this.loadComplete, this), null !== this._pendingState && "string" != typeof this._pendingState && this.add("default", this._pendingState, !0)
  2944. },
  2945. add: function(a, c, d) {
  2946. "undefined" == typeof d && (d = !1);
  2947. var e;
  2948. return c instanceof b.State ? e = c : "object" == typeof c ? (e = c, e.game = this.game) : "function" == typeof c && (e = new c(this.game)), this.states[a] = e, d && (this.game.isBooted ? this.start(a) : this._pendingState = a), e
  2949. },
  2950. remove: function(a) {
  2951. this.current === a && (this.callbackContext = null, this.onInitCallback = null, this.onShutDownCallback = null, this.onPreloadCallback = null, this.onLoadRenderCallback = null, this.onLoadUpdateCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onResizeCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null), delete this.states[a]
  2952. },
  2953. start: function(a, b, c) {
  2954. "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)))
  2955. },
  2956. restart: function(a, b) {
  2957. "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))
  2958. },
  2959. dummy: function() {},
  2960. preUpdate: function() {
  2961. if (this._pendingState && this.game.isBooted) {
  2962. if (this.clearCurrentState(), this.setCurrentState(this._pendingState), this.current !== this._pendingState) return;
  2963. this._pendingState = null, this.onPreloadCallback ? (this.game.load.reset(), this.onPreloadCallback.call(this.callbackContext, this.game), 0 === this.game.load.totalQueuedFiles() && 0 === this.game.load.totalQueuedPacks() ? this.loadComplete() : this.game.load.start()) : this.loadComplete()
  2964. }
  2965. },
  2966. clearCurrentState: function() {
  2967. 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()))
  2968. },
  2969. checkState: function(a) {
  2970. if (this.states[a]) {
  2971. var b = !1;
  2972. return this.states[a].preload && (b = !0), this.states[a].create && (b = !0), this.states[a].update && (b = !0), this.states[a].render && (b = !0), b === !1 ? (console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render"), !1) : !0
  2973. }
  2974. return console.warn("Phaser.StateManager - No state found with the key: " + a), !1
  2975. },
  2976. link: function(a) {
  2977. 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
  2978. },
  2979. unlink: function(a) {
  2980. 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)
  2981. },
  2982. setCurrentState: function(a) {
  2983. 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 = a, this._created = !1, this.onInitCallback.apply(this.callbackContext, this._args), a === this._pendingState && (this._args = [])
  2984. },
  2985. getCurrentState: function() {
  2986. return this.states[this.current]
  2987. },
  2988. loadComplete: function() {
  2989. this._created === !1 && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0
  2990. },
  2991. pause: function() {
  2992. this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game)
  2993. },
  2994. resume: function() {
  2995. this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game)
  2996. },
  2997. update: function() {
  2998. this._created && this.onUpdateCallback ? this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2999. },
  3000. pauseUpdate: function() {
  3001. this._created && this.onPauseUpdateCallback ? this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  3002. },
  3003. preRender: function() {
  3004. this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game)
  3005. },
  3006. resize: function(a, b) {
  3007. this.onResizeCallback && this.onResizeCallback.call(this.callbackContext, a, b)
  3008. },
  3009. render: function() {
  3010. this._created && this.onRenderCallback ? (this.game.renderType === b.CANVAS && (this.game.context.save(), this.game.context.setTransform(1, 0, 0, 1, 0, 0)), this.onRenderCallback.call(this.callbackContext, this.game), this.game.renderType === b.CANVAS && this.game.context.restore()) : this.onLoadRenderCallback && this.onLoadRenderCallback.call(this.callbackContext, this.game)
  3011. },
  3012. destroy: function() {
  3013. 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
  3014. }
  3015. }, b.StateManager.prototype.constructor = b.StateManager, b.LinkedList = function() {
  3016. this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0
  3017. }, b.LinkedList.prototype = {
  3018. add: function(a) {
  3019. 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)
  3020. },
  3021. reset: function() {
  3022. this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0
  3023. },
  3024. remove: function(a) {
  3025. 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--)
  3026. },
  3027. callAll: function(a) {
  3028. if (this.first && this.last) {
  3029. var b = this.first;
  3030. do b && b[a] && b[a].call(b), b = b.next; while (b != this.last.next)
  3031. }
  3032. }
  3033. }, b.LinkedList.prototype.constructor = b.LinkedList, b.ArrayList = function() {
  3034. this.total = 0, this.position = 0, this.list = []
  3035. }, b.ArrayList.prototype = {
  3036. add: function(a) {
  3037. return this.exists(a) || (this.list.push(a), this.total++), a
  3038. },
  3039. getIndex: function(a) {
  3040. return this.list.indexOf(a)
  3041. },
  3042. exists: function(a) {
  3043. return this.list.indexOf(a) > -1
  3044. },
  3045. reset: function() {
  3046. this.list.length = 0, this.total = 0
  3047. },
  3048. remove: function(a) {
  3049. var b = this.list.indexOf(a);
  3050. return b > -1 ? (this.list.splice(b, 1), this.total--, a) : void 0
  3051. },
  3052. setAll: function(a, b) {
  3053. for (var c = this.list.length; c--;) this.list[c] && this.list[c][a] && (this.list[c][a] = b)
  3054. },
  3055. callAll: function(a) {
  3056. 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)
  3057. }
  3058. }, Object.defineProperty(b.ArrayList.prototype, "first", {
  3059. get: function() {
  3060. return this.position = 0, this.total > 0 ? this.list[0] : null
  3061. }
  3062. }), Object.defineProperty(b.ArrayList.prototype, "next", {
  3063. get: function() {
  3064. return this.position < this.total ? (this.position++, this.list[this.position]) : null
  3065. }
  3066. }), b.ArrayList.prototype.constructor = b.ArrayList, b.Signal = function() {
  3067. this._bindings = [], this._prevParams = null;
  3068. var a = this;
  3069. this.dispatch = function() {
  3070. b.Signal.prototype.dispatch.apply(a, arguments)
  3071. }
  3072. }, b.Signal.prototype = {
  3073. memorize: !1,
  3074. _shouldPropagate: !0,
  3075. active: !0,
  3076. validateListener: function(a, b) {
  3077. if ("function" != typeof a) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", b))
  3078. },
  3079. _registerListener: function(a, c, d, e) {
  3080. var f, g = this._indexOfListener(a, d);
  3081. if (-1 !== g) {
  3082. if (f = this._bindings[g], f.isOnce() !== c) throw new Error("You cannot add" + (c ? "" : "Once") + "() then add" + (c ? "Once" : "") + "() the same listener without removing the relationship first.")
  3083. } else f = new b.SignalBinding(this, a, c, d, e), this._addBinding(f);
  3084. return this.memorize && this._prevParams && f.execute(this._prevParams), f
  3085. },
  3086. _addBinding: function(a) {
  3087. var b = this._bindings.length;
  3088. do b--; while (this._bindings[b] && a._priority <= this._bindings[b]._priority);
  3089. this._bindings.splice(b + 1, 0, a)
  3090. },
  3091. _indexOfListener: function(a, b) {
  3092. for (var c, d = this._bindings.length; d--;)
  3093. if (c = this._bindings[d], c._listener === a && c.context === b) return d;
  3094. return -1
  3095. },
  3096. has: function(a, b) {
  3097. return -1 !== this._indexOfListener(a, b)
  3098. },
  3099. add: function(a, b, c) {
  3100. return this.validateListener(a, "add"), this._registerListener(a, !1, b, c)
  3101. },
  3102. addOnce: function(a, b, c) {
  3103. return this.validateListener(a, "addOnce"), this._registerListener(a, !0, b, c)
  3104. },
  3105. remove: function(a, b) {
  3106. this.validateListener(a, "remove");
  3107. var c = this._indexOfListener(a, b);
  3108. return -1 !== c && (this._bindings[c]._destroy(), this._bindings.splice(c, 1)), a
  3109. },
  3110. removeAll: function(a) {
  3111. "undefined" == typeof a && (a = null);
  3112. 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();
  3113. a || (this._bindings.length = 0)
  3114. },
  3115. getNumListeners: function() {
  3116. return this._bindings.length
  3117. },
  3118. halt: function() {
  3119. this._shouldPropagate = !1
  3120. },
  3121. dispatch: function() {
  3122. if (this.active) {
  3123. var a, b = Array.prototype.slice.call(arguments),
  3124. c = this._bindings.length;
  3125. if (this.memorize && (this._prevParams = b), c) {
  3126. a = this._bindings.slice(), this._shouldPropagate = !0;
  3127. do c--; while (a[c] && this._shouldPropagate && a[c].execute(b) !== !1)
  3128. }
  3129. }
  3130. },
  3131. forget: function() {
  3132. this._prevParams = null
  3133. },
  3134. dispose: function() {
  3135. this.removeAll(), delete this._bindings, delete this._prevParams
  3136. },
  3137. toString: function() {
  3138. return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"
  3139. }
  3140. }, b.Signal.prototype.constructor = b.Signal, b.SignalBinding = function(a, b, c, d, e) {
  3141. this._listener = b, this._isOnce = c, this.context = d, this._signal = a, this._priority = e || 0
  3142. }, b.SignalBinding.prototype = {
  3143. active: !0,
  3144. params: null,
  3145. execute: function(a) {
  3146. var b, c;
  3147. return this.active && this._listener && (c = this.params ? this.params.concat(a) : a, b = this._listener.apply(this.context, c), this._isOnce && this.detach()), b
  3148. },
  3149. detach: function() {
  3150. return this.isBound() ? this._signal.remove(this._listener, this.context) : null
  3151. },
  3152. isBound: function() {
  3153. return !!this._signal && !!this._listener
  3154. },
  3155. isOnce: function() {
  3156. return this._isOnce
  3157. },
  3158. getListener: function() {
  3159. return this._listener
  3160. },
  3161. getSignal: function() {
  3162. return this._signal
  3163. },
  3164. _destroy: function() {
  3165. delete this._signal, delete this._listener, delete this.context
  3166. },
  3167. toString: function() {
  3168. return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"
  3169. }
  3170. }, b.SignalBinding.prototype.constructor = b.SignalBinding, b.Filter = function(a, c, d) {
  3171. this.game = a, this.type = b.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.prevPoint = new b.Point;
  3172. var e = new Date;
  3173. if (this.uniforms = {
  3174. resolution: {
  3175. type: "2f",
  3176. value: {
  3177. x: 256,
  3178. y: 256
  3179. }
  3180. },
  3181. time: {
  3182. type: "1f",
  3183. value: 0
  3184. },
  3185. mouse: {
  3186. type: "2f",
  3187. value: {
  3188. x: 0,
  3189. y: 0
  3190. }
  3191. },
  3192. date: {
  3193. type: "4fv",
  3194. value: [e.getFullYear(), e.getMonth(), e.getDate(), 60 * e.getHours() * 60 + 60 * e.getMinutes() + e.getSeconds()]
  3195. },
  3196. sampleRate: {
  3197. type: "1f",
  3198. value: 44100
  3199. },
  3200. iChannel0: {
  3201. type: "sampler2D",
  3202. value: null,
  3203. textureData: {
  3204. repeat: !0
  3205. }
  3206. },
  3207. iChannel1: {
  3208. type: "sampler2D",
  3209. value: null,
  3210. textureData: {
  3211. repeat: !0
  3212. }
  3213. },
  3214. iChannel2: {
  3215. type: "sampler2D",
  3216. value: null,
  3217. textureData: {
  3218. repeat: !0
  3219. }
  3220. },
  3221. iChannel3: {
  3222. type: "sampler2D",
  3223. value: null,
  3224. textureData: {
  3225. repeat: !0
  3226. }
  3227. }
  3228. }, c)
  3229. for (var f in c) this.uniforms[f] = c[f];
  3230. this.fragmentSrc = d || []
  3231. }, b.Filter.prototype = {
  3232. init: function() {},
  3233. setResolution: function(a, b) {
  3234. this.uniforms.resolution.value.x = a, this.uniforms.resolution.value.y = b
  3235. },
  3236. update: function(a) {
  3237. if ("undefined" != typeof a) {
  3238. var b = a.x / this.game.width,
  3239. c = 1 - a.y / this.game.height;
  3240. (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))
  3241. }
  3242. this.uniforms.time.value = this.game.time.totalElapsedSeconds()
  3243. },
  3244. destroy: function() {
  3245. this.game = null
  3246. }
  3247. }, b.Filter.prototype.constructor = b.Filter, Object.defineProperty(b.Filter.prototype, "width", {
  3248. get: function() {
  3249. return this.uniforms.resolution.value.x
  3250. },
  3251. set: function(a) {
  3252. this.uniforms.resolution.value.x = a
  3253. }
  3254. }), Object.defineProperty(b.Filter.prototype, "height", {
  3255. get: function() {
  3256. return this.uniforms.resolution.value.y
  3257. },
  3258. set: function(a) {
  3259. this.uniforms.resolution.value.y = a
  3260. }
  3261. }), b.Plugin = function(a, b) {
  3262. "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
  3263. }, b.Plugin.prototype = {
  3264. preUpdate: function() {},
  3265. update: function() {},
  3266. render: function() {},
  3267. postRender: function() {},
  3268. destroy: function() {
  3269. this.game = null, this.parent = null, this.active = !1, this.visible = !1
  3270. }
  3271. }, b.Plugin.prototype.constructor = b.Plugin, b.PluginManager = function(a) {
  3272. this.game = a, this.plugins = [], this._len = 0, this._i = 0
  3273. }, b.PluginManager.prototype = {
  3274. add: function(a) {
  3275. var b = Array.prototype.splice.call(arguments, 1),
  3276. c = !1;
  3277. 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
  3278. },
  3279. remove: function(a) {
  3280. for (this._i = this._len; this._i--;)
  3281. if (this.plugins[this._i] === a) return a.destroy(), this.plugins.splice(this._i, 1), void this._len--
  3282. },
  3283. removeAll: function() {
  3284. for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
  3285. this.plugins.length = 0, this._len = 0
  3286. },
  3287. preUpdate: function() {
  3288. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate()
  3289. },
  3290. update: function() {
  3291. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update()
  3292. },
  3293. postUpdate: function() {
  3294. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate()
  3295. },
  3296. render: function() {
  3297. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render()
  3298. },
  3299. postRender: function() {
  3300. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender()
  3301. },
  3302. destroy: function() {
  3303. this.removeAll(), this.game = null
  3304. }
  3305. }, b.PluginManager.prototype.constructor = b.PluginManager, b.Stage = function(a) {
  3306. this.game = a, PIXI.Stage.call(this, 0), this.name = "_stage_root", this.interactive = !1, this.disableVisibilityChange = !1, this.exists = !0, this.currentRenderOrderID = 0, this._hiddenVar = "hidden", this._backgroundColor = 0, a.config && this.parseConfig(a.config)
  3307. }, b.Stage.prototype = Object.create(PIXI.Stage.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.parseConfig = function(a) {
  3308. a.disableVisibilityChange && (this.disableVisibilityChange = a.disableVisibilityChange), a.backgroundColor && (this.backgroundColor = a.backgroundColor)
  3309. }, b.Stage.prototype.boot = function() {
  3310. b.Canvas.getOffset(this.game.canvas, this.offset);
  3311. var a = this;
  3312. this._onChange = function(b) {
  3313. return a.visibilityChange(b)
  3314. }, b.Canvas.setUserSelect(this.game.canvas, "none"), b.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility()
  3315. }, b.Stage.prototype.preUpdate = function() {
  3316. this.currentRenderOrderID = 0;
  3317. for (var a = this.children.length, b = 0; a > b; b++) this.children[b].preUpdate()
  3318. }, b.Stage.prototype.update = function() {
  3319. for (var a = this.children.length; a--;) this.children[a].update()
  3320. }, b.Stage.prototype.postUpdate = function() {
  3321. if (this.game.world.camera.target) {
  3322. this.game.world.camera.target.postUpdate(), this.game.world.camera.update();
  3323. for (var a = this.children.length; a--;) this.children[a] !== this.game.world.camera.target && this.children[a].postUpdate()
  3324. } else {
  3325. this.game.world.camera.update();
  3326. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3327. }
  3328. }, b.Stage.prototype.checkVisibility = function() {
  3329. this._hiddenVar = void 0 !== document.webkitHidden ? "webkitvisibilitychange" : void 0 !== document.mozHidden ? "mozvisibilitychange" : void 0 !== document.msHidden ? "msvisibilitychange" : void 0 !== document.hidden ? "visibilitychange" : null, this._hiddenVar && document.addEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = this._onChange, window.onpageshow = this._onChange, window.onblur = this._onChange, window.onfocus = this._onChange;
  3330. var a = this;
  3331. this.game.device.cocoonJSApp && (CocoonJS.App.onSuspended.addEventListener(function() {
  3332. b.Stage.prototype.visibilityChange.call(a, {
  3333. type: "pause"
  3334. })
  3335. }), CocoonJS.App.onActivated.addEventListener(function() {
  3336. b.Stage.prototype.visibilityChange.call(a, {
  3337. type: "resume"
  3338. })
  3339. }))
  3340. }, b.Stage.prototype.visibilityChange = function(a) {
  3341. 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)))
  3342. }, b.Stage.prototype.setBackgroundColor = function(a) {
  3343. if ("string" == typeof a) {
  3344. var c = b.Color.hexToColor(a);
  3345. this._backgroundColor = b.Color.getColor(c.r, c.g, c.b)
  3346. } else {
  3347. var c = b.Color.getRGB(a);
  3348. this._backgroundColor = a
  3349. }
  3350. this.backgroundColorSplit = [c.r / 255, c.g / 255, c.b / 255], this.backgroundColorString = b.Color.RGBtoString(c.r, c.g, c.b, 255, "#")
  3351. }, b.Stage.prototype.destroy = function() {
  3352. this._hiddenVar && document.removeEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = null, window.onpageshow = null, window.onblur = null, window.onfocus = null
  3353. }, Object.defineProperty(b.Stage.prototype, "backgroundColor", {
  3354. get: function() {
  3355. return this._backgroundColor
  3356. },
  3357. set: function(a) {
  3358. this.game.transparent || this.setBackgroundColor(a)
  3359. }
  3360. }), Object.defineProperty(b.Stage.prototype, "smoothed", {
  3361. get: function() {
  3362. return !PIXI.scaleModes.LINEAR
  3363. },
  3364. set: function(a) {
  3365. PIXI.scaleModes.LINEAR = a ? 0 : 1
  3366. }
  3367. }), b.Group = function(a, c, d, e, f, g) {
  3368. "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1), "undefined" == typeof g && (g = b.Physics.ARCADE), this.game = a, "undefined" == typeof c && (c = a.world), this.name = d || "group", PIXI.DisplayObjectContainer.call(this), e ? this.game.stage.addChild(this) : c && c.addChild(this), this.z = 0, this.type = b.GROUP, this.alive = !0, this.exists = !0, this.ignoreDestroy = !1, this.classType = b.Sprite, this.scale = new b.Point(1, 1), this.cursor = null, this.cameraOffset = new b.Point, this.enableBody = f, this.enableBodyDebug = !1, this.physicsBodyType = g, this.onDestroy = new b.Signal, this._sortProperty = "z", this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0, 0]
  3369. }, b.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), b.Group.prototype.constructor = b.Group, b.Group.RETURN_NONE = 0, b.Group.RETURN_TOTAL = 1, b.Group.RETURN_CHILD = 2, b.Group.SORT_ASCENDING = -1, b.Group.SORT_DESCENDING = 1, b.Group.prototype.add = function(a, b) {
  3370. return "undefined" == typeof b && (b = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChild(a), a.z = this.children.length, !b && a.events && a.events.onAddedToGroup.dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  3371. }, b.Group.prototype.addMultiple = function(a, b) {
  3372. if (Array.isArray(a))
  3373. for (var c = 0; c < a.length; c++) this.add(a[c], b);
  3374. return a
  3375. }, b.Group.prototype.addAt = function(a, b, c) {
  3376. return "undefined" == typeof c && (c = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChildAt(a, b), this.updateZ(), !c && a.events && a.events.onAddedToGroup.dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  3377. }, b.Group.prototype.getAt = function(a) {
  3378. return 0 > a || a >= this.children.length ? -1 : this.getChildAt(a)
  3379. }, b.Group.prototype.create = function(a, b, c, d, e) {
  3380. "undefined" == typeof e && (e = !0);
  3381. var f = new this.classType(this.game, a, b, c, d);
  3382. return this.enableBody && this.game.physics.enable(f, this.physicsBodyType, this.enableBodyDebug), f.exists = e, f.visible = e, f.alive = e, this.addChild(f), f.z = this.children.length, f.events && f.events.onAddedToGroup.dispatch(f, this), null === this.cursor && (this.cursor = f), f
  3383. }, b.Group.prototype.createMultiple = function(a, b, c, d) {
  3384. "undefined" == typeof d && (d = !1);
  3385. for (var e = 0; a > e; e++) this.create(0, 0, b, c, d)
  3386. }, b.Group.prototype.updateZ = function() {
  3387. for (var a = this.children.length; a--;) this.children[a].z = a
  3388. }, b.Group.prototype.resetCursor = function(a) {
  3389. return "undefined" == typeof a && (a = 0), a > this.children.length - 1 && (a = 0), this.cursor ? (this._cache[8] = a, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  3390. }, b.Group.prototype.next = function() {
  3391. return this.cursor ? (this._cache[8] >= this.children.length - 1 ? this._cache[8] = 0 : this._cache[8] ++, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  3392. }, b.Group.prototype.previous = function() {
  3393. return this.cursor ? (0 === this._cache[8] ? this._cache[8] = this.children.length - 1 : this._cache[8] --, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  3394. }, b.Group.prototype.swap = function(a, b) {
  3395. this.swapChildren(a, b), this.updateZ()
  3396. }, b.Group.prototype.bringToTop = function(a) {
  3397. return a.parent === this && this.getIndex(a) < this.children.length && (this.remove(a, !1, !0), this.add(a, !0)), a
  3398. }, b.Group.prototype.sendToBack = function(a) {
  3399. return a.parent === this && this.getIndex(a) > 0 && (this.remove(a, !1, !0), this.addAt(a, 0, !0)), a
  3400. }, b.Group.prototype.moveUp = function(a) {
  3401. if (a.parent === this && this.getIndex(a) < this.children.length - 1) {
  3402. var b = this.getIndex(a),
  3403. c = this.getAt(b + 1);
  3404. c && this.swap(a, c)
  3405. }
  3406. return a
  3407. }, b.Group.prototype.moveDown = function(a) {
  3408. if (a.parent === this && this.getIndex(a) > 0) {
  3409. var b = this.getIndex(a),
  3410. c = this.getAt(b - 1);
  3411. c && this.swap(a, c)
  3412. }
  3413. return a
  3414. }, b.Group.prototype.xy = function(a, b, c) {
  3415. return 0 > a || a > this.children.length ? -1 : (this.getChildAt(a).x = b, void(this.getChildAt(a).y = c))
  3416. }, b.Group.prototype.reverse = function() {
  3417. this.children.reverse(), this.updateZ()
  3418. }, b.Group.prototype.getIndex = function(a) {
  3419. return this.children.indexOf(a)
  3420. }, b.Group.prototype.replace = function(a, c) {
  3421. var d = this.getIndex(a);
  3422. if (-1 !== d) {
  3423. void 0 !== c.parent && (c.events.onRemovedFromGroup.dispatch(c, this), c.parent.removeChild(c), c.parent instanceof b.Group && c.parent.updateZ());
  3424. var e = a;
  3425. return this.remove(e), this.addAt(c, d), e
  3426. }
  3427. }, b.Group.prototype.hasProperty = function(a, b) {
  3428. var c = b.length;
  3429. 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
  3430. }, b.Group.prototype.setProperty = function(a, b, c, d, e) {
  3431. if ("undefined" == typeof e && (e = !1), d = d || 0, !this.hasProperty(a, b) && (!e || d > 0)) return !1;
  3432. var f = b.length;
  3433. 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
  3434. }, b.Group.prototype.checkProperty = function(a, c, d, e) {
  3435. return "undefined" == typeof e && (e = !1), !b.Utils.getProperty(a, c) && e ? !1 : b.Utils.getProperty(a, c) !== d ? !1 : !0
  3436. }, b.Group.prototype.set = function(a, b, c, d, e, f, g) {
  3437. 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
  3438. }, b.Group.prototype.setAll = function(a, b, c, d, e, f) {
  3439. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof f && (f = !1), a = a.split("."), e = e || 0;
  3440. for (var g = 0, h = this.children.length; h > g; g++)(!c || c && this.children[g].alive) && (!d || d && this.children[g].visible) && this.setProperty(this.children[g], a, b, e, f)
  3441. }, b.Group.prototype.setAllChildren = function(a, c, d, e, f, g) {
  3442. "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), "undefined" == typeof g && (g = !1), f = f || 0;
  3443. for (var h = 0, i = this.children.length; i > h; h++)(!d || d && this.children[h].alive) && (!e || e && this.children[h].visible) && (this.children[h] instanceof b.Group ? this.children[h].setAllChildren(a, c, d, e, f, g) : this.setProperty(this.children[h], a.split("."), c, f, g))
  3444. }, b.Group.prototype.checkAll = function(a, b, c, d, e) {
  3445. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  3446. for (var f = 0, g = this.children.length; g > f; f++)
  3447. if ((!c || c && this.children[f].alive) && (!d || d && this.children[f].visible) && !this.checkProperty(this.children[f], a, b, e)) return !1;
  3448. return !0
  3449. }, b.Group.prototype.addAll = function(a, b, c, d) {
  3450. this.setAll(a, b, c, d, 1)
  3451. }, b.Group.prototype.subAll = function(a, b, c, d) {
  3452. this.setAll(a, b, c, d, 2)
  3453. }, b.Group.prototype.multiplyAll = function(a, b, c, d) {
  3454. this.setAll(a, b, c, d, 3)
  3455. }, b.Group.prototype.divideAll = function(a, b, c, d) {
  3456. this.setAll(a, b, c, d, 4)
  3457. }, b.Group.prototype.callAllExists = function(a, b) {
  3458. for (var c = Array.prototype.splice.call(arguments, 2), d = 0, e = this.children.length; e > d; d++) this.children[d].exists === b && this.children[d][a] && this.children[d][a].apply(this.children[d], c)
  3459. }, b.Group.prototype.callbackFromArray = function(a, b, c) {
  3460. if (1 == c) {
  3461. if (a[b[0]]) return a[b[0]]
  3462. } else if (2 == c) {
  3463. if (a[b[0]][b[1]]) return a[b[0]][b[1]]
  3464. } else if (3 == c) {
  3465. if (a[b[0]][b[1]][b[2]]) return a[b[0]][b[1]][b[2]]
  3466. } else if (4 == c) {
  3467. if (a[b[0]][b[1]][b[2]][b[3]]) return a[b[0]][b[1]][b[2]][b[3]]
  3468. } else if (a[b]) return a[b];
  3469. return !1
  3470. }, b.Group.prototype.callAll = function(a, b) {
  3471. if ("undefined" != typeof a) {
  3472. a = a.split(".");
  3473. var c = a.length;
  3474. if ("undefined" == typeof b || null === b || "" === b) b = null;
  3475. else if ("string" == typeof b) {
  3476. b = b.split(".");
  3477. var d = b.length
  3478. }
  3479. for (var e = Array.prototype.splice.call(arguments, 2), f = null, g = null, h = 0, i = this.children.length; i > h; h++) f = this.callbackFromArray(this.children[h], a, c), b && f ? (g = this.callbackFromArray(this.children[h], b, d), f && f.apply(g, e)) : f && f.apply(this.children[h], e)
  3480. }
  3481. }, b.Group.prototype.preUpdate = function() {
  3482. if (!this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  3483. for (var a = this.children.length; a--;) this.children[a].preUpdate();
  3484. return !0
  3485. }, b.Group.prototype.update = function() {
  3486. for (var a = this.children.length; a--;) this.children[a].update()
  3487. }, b.Group.prototype.postUpdate = function() {
  3488. 1 === this._cache[7] && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y);
  3489. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  3490. }, b.Group.prototype.filter = function(a, c) {
  3491. for (var d = -1, e = this.children.length, f = new b.ArrayList; ++d < e;) {
  3492. var g = this.children[d];
  3493. (!c || c && g.exists) && a(g, d, this.children) && f.add(g)
  3494. }
  3495. return f
  3496. }, b.Group.prototype.forEach = function(a, b, c) {
  3497. "undefined" == typeof c && (c = !1);
  3498. var d = Array.prototype.splice.call(arguments, 3);
  3499. d.unshift(null);
  3500. for (var e = 0, f = this.children.length; f > e; e++)(!c || c && this.children[e].exists) && (d[0] = this.children[e], a.apply(b, d))
  3501. }, b.Group.prototype.forEachExists = function(a, c) {
  3502. var d = Array.prototype.splice.call(arguments, 2);
  3503. d.unshift(null), this.iterate("exists", !0, b.Group.RETURN_TOTAL, a, c, d)
  3504. }, b.Group.prototype.forEachAlive = function(a, c) {
  3505. var d = Array.prototype.splice.call(arguments, 2);
  3506. d.unshift(null), this.iterate("alive", !0, b.Group.RETURN_TOTAL, a, c, d)
  3507. }, b.Group.prototype.forEachDead = function(a, c) {
  3508. var d = Array.prototype.splice.call(arguments, 2);
  3509. d.unshift(null), this.iterate("alive", !1, b.Group.RETURN_TOTAL, a, c, d)
  3510. }, b.Group.prototype.sort = function(a, c) {
  3511. this.children.length < 2 || ("undefined" == typeof a && (a = "z"), "undefined" == typeof c && (c = b.Group.SORT_ASCENDING), this._sortProperty = a, this.children.sort(c === b.Group.SORT_ASCENDING ? this.ascendingSortHandler.bind(this) : this.descendingSortHandler.bind(this)), this.updateZ())
  3512. }, b.Group.prototype.customSort = function(a, b) {
  3513. this.children.length < 2 || (this.children.sort(a.bind(b)), this.updateZ())
  3514. }, b.Group.prototype.ascendingSortHandler = function(a, b) {
  3515. return a[this._sortProperty] < b[this._sortProperty] ? -1 : a[this._sortProperty] > b[this._sortProperty] ? 1 : a.z < b.z ? -1 : 1
  3516. }, b.Group.prototype.descendingSortHandler = function(a, b) {
  3517. return a[this._sortProperty] < b[this._sortProperty] ? 1 : a[this._sortProperty] > b[this._sortProperty] ? -1 : 0
  3518. }, b.Group.prototype.iterate = function(a, c, d, e, f, g) {
  3519. if (d === b.Group.RETURN_TOTAL && 0 === this.children.length) return 0;
  3520. "undefined" == typeof e && (e = !1);
  3521. for (var h = 0, i = 0, j = this.children.length; j > i; i++)
  3522. if (this.children[i][a] === c && (h++, e && (g[0] = this.children[i], e.apply(f, g)), d === b.Group.RETURN_CHILD)) return this.children[i];
  3523. return d === b.Group.RETURN_TOTAL ? h : d === b.Group.RETURN_CHILD ? null : void 0
  3524. }, b.Group.prototype.getFirstExists = function(a) {
  3525. return "boolean" != typeof a && (a = !0), this.iterate("exists", a, b.Group.RETURN_CHILD)
  3526. }, b.Group.prototype.getFirstAlive = function() {
  3527. return this.iterate("alive", !0, b.Group.RETURN_CHILD)
  3528. }, b.Group.prototype.getFirstDead = function() {
  3529. return this.iterate("alive", !1, b.Group.RETURN_CHILD)
  3530. }, b.Group.prototype.getTop = function() {
  3531. return this.children.length > 0 ? this.children[this.children.length - 1] : void 0
  3532. }, b.Group.prototype.getBottom = function() {
  3533. return this.children.length > 0 ? this.children[0] : void 0
  3534. }, b.Group.prototype.countLiving = function() {
  3535. return this.iterate("alive", !0, b.Group.RETURN_TOTAL)
  3536. }, b.Group.prototype.countDead = function() {
  3537. return this.iterate("alive", !1, b.Group.RETURN_TOTAL)
  3538. }, b.Group.prototype.getRandom = function(a, b) {
  3539. return 0 === this.children.length ? null : (a = a || 0, b = b || this.children.length, this.game.math.getRandom(this.children, a, b))
  3540. }, b.Group.prototype.remove = function(a, b, c) {
  3541. if ("undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !1), 0 === this.children.length || -1 === this.children.indexOf(a)) return !1;
  3542. c || !a.events || a.destroyPhase || a.events.onRemovedFromGroup.dispatch(a, this);
  3543. var d = this.removeChild(a);
  3544. return this.updateZ(), this.cursor === a && this.next(), b && d && d.destroy(!0), !0
  3545. }, b.Group.prototype.removeAll = function(a, b) {
  3546. if ("undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), 0 !== this.children.length) {
  3547. do {
  3548. !b && this.children[0].events && this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
  3549. var c = this.removeChild(this.children[0]);
  3550. a && c && c.destroy(!0)
  3551. } while (this.children.length > 0);
  3552. this.cursor = null
  3553. }
  3554. }, b.Group.prototype.removeBetween = function(a, b, c, d) {
  3555. if ("undefined" == typeof b && (b = this.children.length - 1), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), 0 !== this.children.length) {
  3556. if (a > b || 0 > a || b > this.children.length) return !1;
  3557. for (var e = b; e >= a;) {
  3558. !d && this.children[e].events && this.children[e].events.onRemovedFromGroup.dispatch(this.children[e], this);
  3559. var f = this.removeChild(this.children[e]);
  3560. c && f && f.destroy(!0), this.cursor === this.children[e] && (this.cursor = null), e--
  3561. }
  3562. this.updateZ()
  3563. }
  3564. }, b.Group.prototype.destroy = function(a, b) {
  3565. 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))
  3566. }, Object.defineProperty(b.Group.prototype, "total", {
  3567. get: function() {
  3568. return this.iterate("exists", !0, b.Group.RETURN_TOTAL)
  3569. }
  3570. }), Object.defineProperty(b.Group.prototype, "length", {
  3571. get: function() {
  3572. return this.children.length
  3573. }
  3574. }), Object.defineProperty(b.Group.prototype, "angle", {
  3575. get: function() {
  3576. return b.Math.radToDeg(this.rotation)
  3577. },
  3578. set: function(a) {
  3579. this.rotation = b.Math.degToRad(a)
  3580. }
  3581. }), Object.defineProperty(b.Group.prototype, "fixedToCamera", {
  3582. get: function() {
  3583. return !!this._cache[7]
  3584. },
  3585. set: function(a) {
  3586. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  3587. }
  3588. }), b.World = function(a) {
  3589. b.Group.call(this, a, null, "__world", !1), this.bounds = new b.Rectangle(0, 0, a.width, a.height), this.camera = null, this._definedSize = !1, this._width = a.width, this._height = a.height
  3590. }, b.World.prototype = Object.create(b.Group.prototype), b.World.prototype.constructor = b.World, b.World.prototype.boot = function() {
  3591. this.camera = new b.Camera(this.game, 0, 0, 0, this.game.width, this.game.height), this.camera.displayObject = this, this.camera.scale = this.scale, this.game.camera = this.camera, this.game.stage.addChild(this)
  3592. }, b.World.prototype.setBounds = function(a, b, c, d) {
  3593. this._definedSize = !0, this._width = c, this._height = d, this.bounds.setTo(a, b, c, d), 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()
  3594. }, b.World.prototype.resize = function(a, b) {
  3595. 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()
  3596. }, b.World.prototype.shutdown = function() {
  3597. this.destroy(!0, !0)
  3598. }, b.World.prototype.wrap = function(a, b, c, d, e) {
  3599. "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))
  3600. }, Object.defineProperty(b.World.prototype, "width", {
  3601. get: function() {
  3602. return this.bounds.width
  3603. },
  3604. set: function(a) {
  3605. a < this.game.width && (a = this.game.width), this.bounds.width = a, this._width = a, this._definedSize = !0
  3606. }
  3607. }), Object.defineProperty(b.World.prototype, "height", {
  3608. get: function() {
  3609. return this.bounds.height
  3610. },
  3611. set: function(a) {
  3612. a < this.game.height && (a = this.game.height), this.bounds.height = a, this._height = a, this._definedSize = !0
  3613. }
  3614. }), Object.defineProperty(b.World.prototype, "centerX", {
  3615. get: function() {
  3616. return this.bounds.x + this.bounds.halfWidth
  3617. }
  3618. }), Object.defineProperty(b.World.prototype, "centerY", {
  3619. get: function() {
  3620. return this.bounds.y + this.bounds.halfHeight
  3621. }
  3622. }), Object.defineProperty(b.World.prototype, "randomX", {
  3623. get: function() {
  3624. 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)
  3625. }
  3626. }), Object.defineProperty(b.World.prototype, "randomY", {
  3627. get: function() {
  3628. 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)
  3629. }
  3630. }), b.FlexGrid = function(a, c, d) {
  3631. this.game = a.game, this.manager = a, this.width = c, this.height = d, this.boundsCustom = new b.Rectangle(0, 0, c, d), this.boundsFluid = new b.Rectangle(0, 0, c, d), this.boundsFull = new b.Rectangle(0, 0, c, d), this.boundsNone = new b.Rectangle(0, 0, c, d), this.positionCustom = new b.Point(0, 0), this.positionFluid = new b.Point(0, 0), this.positionFull = new b.Point(0, 0), this.positionNone = new b.Point(0, 0), this.scaleCustom = new b.Point(1, 1), this.scaleFluid = new b.Point(1, 1), this.scaleFluidInversed = new b.Point(1, 1), this.scaleFull = new b.Point(1, 1), this.scaleNone = new b.Point(1, 1), this.customWidth = 0, this.customHeight = 0, this.customOffsetX = 0, this.customOffsetY = 0, this.ratioH = c / d, this.ratioV = d / c, this.multiplier = 0, this.layers = []
  3632. }, b.FlexGrid.prototype = {
  3633. setSize: function(a, c) {
  3634. this.width = a, this.height = c, this.ratioH = a / c, this.ratioV = c / a, this.scaleNone = new b.Point(1, 1), this.boundsNone.width = this.width, this.boundsNone.height = this.height, this.refresh()
  3635. },
  3636. createCustomLayer: function(a, c, d, e) {
  3637. "undefined" == typeof e && (e = !0), this.customWidth = a, this.customHeight = c, this.boundsCustom.width = a, this.boundsCustom.height = c;
  3638. var f = new b.FlexLayer(this, this.positionCustom, this.boundsCustom, this.scaleCustom);
  3639. return e && this.game.world.add(f), this.layers.push(f), "undefined" != typeof d && null !== typeof d && f.addMultiple(d), f
  3640. },
  3641. createFluidLayer: function(a, c) {
  3642. "undefined" == typeof c && (c = !0);
  3643. var d = new b.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
  3644. return c && this.game.world.add(d), this.layers.push(d), "undefined" != typeof a && null !== typeof a && d.addMultiple(a), d
  3645. },
  3646. createFullLayer: function(a) {
  3647. var c = new b.FlexLayer(this, this.positionFull, this.boundsFull, this.scaleFluid);
  3648. return this.game.world.add(c), this.layers.push(c), "undefined" != typeof a && c.addMultiple(a), c
  3649. },
  3650. createFixedLayer: function(a) {
  3651. var c = new b.FlexLayer(this, this.positionNone, this.boundsNone, this.scaleNone);
  3652. return this.game.world.add(c), this.layers.push(c), "undefined" != typeof a && c.addMultiple(a), c
  3653. },
  3654. reset: function() {
  3655. 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))
  3656. },
  3657. onResize: function(a, b) {
  3658. this.refresh(a, b)
  3659. },
  3660. refresh: function() {
  3661. 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 = this.manager.width * this.scaleFluidInversed.x, this.boundsFull.height = 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)
  3662. },
  3663. debug: function() {
  3664. 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)
  3665. }
  3666. }, b.FlexGrid.prototype.constructor = b.FlexGrid, b.FlexLayer = function(a, c, d, e) {
  3667. b.Group.call(this, a.game, null, "__flexLayer" + a.game.rnd.uuid(), !1), this.manager = a.manager, this.grid = a, this.persist = !1, this.position = c, this.bounds = d, this.scale = e, this.topLeft = d.topLeft, this.topMiddle = new b.Point(d.halfWidth, 0), this.topRight = d.topRight, this.bottomLeft = d.bottomLeft, this.bottomMiddle = new b.Point(d.halfWidth, d.bottom), this.bottomRight = d.bottomRight
  3668. }, b.FlexLayer.prototype = Object.create(b.Group.prototype), b.FlexLayer.prototype.constructor = b.FlexLayer, b.FlexLayer.prototype.resize = function() {}, b.FlexLayer.prototype.debug = function() {
  3669. 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")
  3670. }, b.ScaleManager = function(a, c, d) {
  3671. this.game = a, this.grid = null, this.width = 0, this.height = 0, this.minWidth = null, this.maxWidth = null, this.minHeight = null, this.maxHeight = null, this.offset = new b.Point, this.forceLandscape = !1, this.forcePortrait = !1, this.incorrectOrientation = !1, this.pageAlignHorizontally = !1, this.pageAlignVertically = !1, this.maxIterations = 5, this.enterLandscape = new b.Signal, this.enterPortrait = new b.Signal, this.enterIncorrectOrientation = new b.Signal, this.leaveIncorrectOrientation = new b.Signal, this.fullScreenTarget = null, this.enterFullScreen = new b.Signal, this.leaveFullScreen = new b.Signal, this.orientation = 0, window.orientation ? this.orientation = window.orientation : window.outerWidth > window.outerHeight && (this.orientation = 90), this.scaleFactor = new b.Point(1, 1), this.scaleFactorInversed = new b.Point(1, 1), this.margin = new b.Point(0, 0), this.bounds = new b.Rectangle, this.aspectRatio = 0, this.sourceAspectRatio = 0, this.event = null, this.fullScreenScaleMode = b.ScaleManager.NO_SCALE, this.parentIsWindow = !1, this.parentNode = null, this.parentScaleFactor = new b.Point(1, 1), this.trackParentInterval = 2e3, this.onResize = null, this.onResizeContext = null, this._scaleMode = b.ScaleManager.NO_SCALE, this._width = 0, this._height = 0, this._check = null, this._nextParentCheck = 0, this._parentBounds = null, a.config && this.parseConfig(a.config), this.setupScale(c, d)
  3672. }, b.ScaleManager.EXACT_FIT = 0, b.ScaleManager.NO_SCALE = 1, b.ScaleManager.SHOW_ALL = 2, b.ScaleManager.RESIZE = 3, b.ScaleManager.prototype = {
  3673. parseConfig: function(a) {
  3674. a.scaleMode && (this.scaleMode = a.scaleMode), a.fullScreenScaleMode && (this.fullScreenScaleMode = a.fullScreenScaleMode), a.fullScreenTarget && (this.fullScreenTarget = a.fullScreenTarget)
  3675. },
  3676. setupScale: function(a, c) {
  3677. var d, e = new b.Rectangle;
  3678. "" !== this.game.parent && ("string" == typeof this.game.parent ? d = document.getElementById(this.game.parent) : "object" == typeof this.game.parent && 1 === this.game.parent.nodeType && (d = this.game.parent)), d ? (this.parentNode = d, this.parentIsWindow = !1, this._parentBounds = this.parentNode.getBoundingClientRect(), e.width = this._parentBounds.width, e.height = this._parentBounds.height, this.offset.set(this._parentBounds.left, this._parentBounds.top)) : (this.parentNode = null, this.parentIsWindow = !0, e.width = window.innerWidth, e.height = window.innerHeight);
  3679. var f = 0,
  3680. g = 0;
  3681. "number" == typeof a ? f = a : (this.parentScaleFactor.x = parseInt(a, 10) / 100, f = e.width * this.parentScaleFactor.x), "number" == typeof c ? g = c : (this.parentScaleFactor.y = parseInt(c, 10) / 100, g = e.height * this.parentScaleFactor.y), this.grid = new b.FlexGrid(this, f, g), this.updateDimensions(f, g, !1)
  3682. },
  3683. boot: function() {
  3684. this.fullScreenTarget = this.game.canvas;
  3685. var a = this;
  3686. this._checkOrientation = function(b) {
  3687. return a.checkOrientation(b)
  3688. }, this._checkResize = function(b) {
  3689. return a.checkResize(b)
  3690. }, this._fullScreenChange = function(b) {
  3691. return a.fullScreenChange(b)
  3692. }, window.addEventListener("orientationchange", this._checkOrientation, !1), window.addEventListener("resize", this._checkResize, !1), this.game.device.cocoonJS || (document.addEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.addEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.addEventListener("fullscreenchange", this._fullScreenChange, !1)), this.updateDimensions(this.width, this.height, !0), b.Canvas.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height)
  3693. },
  3694. setResizeCallback: function(a, b) {
  3695. this.onResize = a, this.onResizeContext = b
  3696. },
  3697. setMinMax: function(a, b, c, d) {
  3698. this.minWidth = a, this.minHeight = b, "undefined" != typeof c && (this.maxWidth = c), "undefined" != typeof d && (this.maxHeight = d)
  3699. },
  3700. preUpdate: function() {
  3701. this.game.time.now < this._nextParentCheck || (this.parentIsWindow || (b.Canvas.getOffset(this.game.canvas, this.offset), this._scaleMode === b.ScaleManager.RESIZE && (this._parentBounds = this.parentNode.getBoundingClientRect(), (this._parentBounds.width !== this.width || this._parentBounds.height !== this.height) && this.updateDimensions(this._parentBounds.width, this._parentBounds.height, !0))), this._nextParentCheck = this.game.time.now + this.trackParentInterval)
  3702. },
  3703. updateDimensions: function(a, b, c) {
  3704. 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.bounds.width = this.width, this.bounds.height = this.height, 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)), this.grid.onResize(a, b), this.onResize && this.onResize.call(this.onResizeContext, this.width, this.height), this.game.state.resize(a, b)
  3705. },
  3706. forceOrientation: function(a, b) {
  3707. "undefined" == typeof b && (b = !1), this.forceLandscape = a, this.forcePortrait = b
  3708. },
  3709. checkOrientationState: function() {
  3710. this.incorrectOrientation ? (this.forceLandscape && window.innerWidth > window.innerHeight || this.forcePortrait && window.innerHeight > window.innerWidth) && (this.incorrectOrientation = !1, this.leaveIncorrectOrientation.dispatch(), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh()) : (this.forceLandscape && window.innerWidth < window.innerHeight || this.forcePortrait && window.innerHeight < window.innerWidth) && (this.incorrectOrientation = !0, this.enterIncorrectOrientation.dispatch(), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh())
  3711. },
  3712. checkOrientation: function(a) {
  3713. this.event = a, this.orientation = window.orientation, this.isLandscape ? this.enterLandscape.dispatch(this.orientation, !0, !1) : this.enterPortrait.dispatch(this.orientation, !1, !0), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh()
  3714. },
  3715. checkResize: function(a) {
  3716. this.event = a;
  3717. var c = this.isLandscape;
  3718. this.orientation = window.outerWidth > window.outerHeight ? 90 : 0, c && this.isPortrait ? (this.enterPortrait.dispatch(this.orientation, !1, !0), this.forceLandscape ? this.enterIncorrectOrientation.dispatch() : this.forcePortrait && this.leaveIncorrectOrientation.dispatch()) : !c && this.isLandscape && (this.enterLandscape.dispatch(this.orientation, !0, !1), this.forceLandscape ? this.leaveIncorrectOrientation.dispatch() : this.forcePortrait && this.enterIncorrectOrientation.dispatch()), this._scaleMode === b.ScaleManager.RESIZE && this.parentIsWindow ? this.updateDimensions(window.innerWidth, window.innerHeight, !0) : (this._scaleMode === b.ScaleManager.EXACT_FIT || this._scaleMode === b.ScaleManager.SHOW_ALL) && (this.refresh(), this.onResize && this.onResize.call(this.onResizeContext, this.width, this.height)), this.checkOrientationState()
  3719. },
  3720. refresh: function() {
  3721. if (this.scaleMode !== b.ScaleManager.RESIZE && (this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (this.game.device.android && !this.game.device.chrome ? window.scrollTo(0, 1) : window.scrollTo(0, 0)), null === this._check && this.maxIterations > 0)) {
  3722. this._iterations = this.maxIterations;
  3723. var a = this;
  3724. this._check = window.setInterval(function() {
  3725. return a.setScreenSize()
  3726. }, 10), this.setScreenSize()
  3727. }
  3728. },
  3729. setScreenSize: function(a) {
  3730. this.scaleMode !== b.ScaleManager.RESIZE && ("undefined" == typeof a && (a = !1), this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (this.game.device.android && !this.game.device.chrome ? window.scrollTo(0, 1) : window.scrollTo(0, 0)), this._iterations--, (a || this._iterations < 0) && (document.documentElement.style.minHeight = window.innerHeight + "px", this.incorrectOrientation ? this.setMaximum() : this.isFullScreen ? this.fullScreenScaleMode === b.ScaleManager.EXACT_FIT ? this.setExactFit() : this.fullScreenScaleMode === b.ScaleManager.SHOW_ALL && this.setShowAll() : this.scaleMode === b.ScaleManager.EXACT_FIT ? this.setExactFit() : this.scaleMode === b.ScaleManager.SHOW_ALL && this.setShowAll(), this.setSize(), clearInterval(this._check), this._check = null))
  3731. },
  3732. setSize: function() {
  3733. this.incorrectOrientation || (this.maxWidth && this.width > this.maxWidth && (this.width = this.maxWidth), this.maxHeight && this.height > this.maxHeight && (this.height = this.maxHeight), this.minWidth && this.width < this.minWidth && (this.width = this.minWidth), this.minHeight && this.height < this.minHeight && (this.height = this.minHeight)), this.game.canvas.style.width = this.width + "px", this.game.canvas.style.height = this.height + "px", this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.pageAlignHorizontally && (this.width < window.innerWidth && !this.incorrectOrientation ? (this.margin.x = Math.round((window.innerWidth - this.width) / 2), this.game.canvas.style.marginLeft = this.margin.x + "px") : (this.margin.x = 0, this.game.canvas.style.marginLeft = "0px")), this.pageAlignVertically && (this.height < window.innerHeight && !this.incorrectOrientation ? (this.margin.y = Math.round((window.innerHeight - this.height) / 2), this.game.canvas.style.marginTop = this.margin.y + "px") : (this.margin.y = 0, this.game.canvas.style.marginTop = "0px")), b.Canvas.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.scaleFactorInversed.x = this.width / this.game.width, this.scaleFactorInversed.y = this.height / this.game.height, this.checkOrientationState()
  3734. },
  3735. reset: function(a) {
  3736. a && this.grid.reset()
  3737. },
  3738. setMaximum: function() {
  3739. this.width = window.innerWidth, this.height = window.innerHeight
  3740. },
  3741. setShowAll: function() {
  3742. var a = Math.min(window.innerHeight / this.game.height, window.innerWidth / this.game.width);
  3743. this.width = Math.round(this.game.width * a), this.height = Math.round(this.game.height * a)
  3744. },
  3745. setExactFit: function() {
  3746. var a = window.innerWidth,
  3747. b = window.innerHeight;
  3748. this.width = this.maxWidth && a > this.maxWidth ? this.maxWidth : a, this.height = this.maxHeight && b > this.maxHeight ? this.maxHeight : b
  3749. },
  3750. startFullScreen: function(a) {
  3751. !this.isFullScreen && this.game.device.fullscreen && ("undefined" != typeof a && this.game.renderType === b.CANVAS && (this.game.stage.smoothed = a), this._width = this.width, this._height = this.height, this.game.device.fullscreenKeyboard ? this.fullScreenTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT) : this.fullScreenTarget[this.game.device.requestFullscreen]())
  3752. },
  3753. stopFullScreen: function() {
  3754. document[this.game.device.cancelFullscreen]()
  3755. },
  3756. fullScreenChange: function(a) {
  3757. this.event = a, this.isFullScreen ? (this.fullScreenScaleMode === b.ScaleManager.EXACT_FIT ? (this.fullScreenTarget.style.width = "100%", this.fullScreenTarget.style.height = "100%", this.width = window.outerWidth, this.height = window.outerHeight, this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.checkResize()) : this.fullScreenScaleMode === b.ScaleManager.SHOW_ALL && (this.setShowAll(), this.refresh()), this.enterFullScreen.dispatch(this.width, this.height)) : (this.fullScreenTarget.style.width = this.game.width + "px", this.fullScreenTarget.style.height = this.game.height + "px", this.width = this._width, this.height = this._height, this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.leaveFullScreen.dispatch(this.width, this.height))
  3758. },
  3759. destroy: function() {
  3760. window.removeEventListener("orientationchange", this._checkOrientation, !1), window.removeEventListener("resize", this._checkResize, !1), this.game.device.cocoonJS || (document.removeEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("fullscreenchange", this._fullScreenChange, !1))
  3761. }
  3762. }, b.ScaleManager.prototype.constructor = b.ScaleManager, Object.defineProperty(b.ScaleManager.prototype, "scaleMode", {
  3763. get: function() {
  3764. return this._scaleMode
  3765. },
  3766. set: function(a) {
  3767. a !== this._scaleMode && (this._scaleMode = a)
  3768. }
  3769. }), Object.defineProperty(b.ScaleManager.prototype, "isFullScreen", {
  3770. get: function() {
  3771. return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement
  3772. }
  3773. }), Object.defineProperty(b.ScaleManager.prototype, "isPortrait", {
  3774. get: function() {
  3775. return 0 === this.orientation || 180 === this.orientation
  3776. }
  3777. }), Object.defineProperty(b.ScaleManager.prototype, "isLandscape", {
  3778. get: function() {
  3779. return 90 === this.orientation || -90 === this.orientation
  3780. }
  3781. }), b.Game = function(a, c, d, e, f, g, h, i) {
  3782. this.id = b.GAMES.push(this) - 1, this.config = null, this.physicsConfig = i, this.parent = "", this.width = 800, this.height = 600, this.transparent = !1, this.antialias = !0, this.preserveDrawingBuffer = !1, this.renderer = null, this.renderType = b.AUTO, this.state = null, this.isBooted = !1, this.isRunning = !1, this.raf = null, this.add = null, this.make = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.net = null, this.scale = null, this.sound = null, this.stage = null, this.time = null, this.tweens = null, this.world = null, this.physics = null, this.rnd = null, this.device = null, this.camera = null, this.canvas = null, this.context = null, this.debug = null, this.particles = null, this.stepping = !1, this.pendingStep = !1, this.stepCount = 0, this.onPause = null, this.onResume = null, this.onBlur = null, this.onFocus = null, this._paused = !1, this._codePaused = !1, this._width = 800, this._height = 600, 1 === arguments.length && "object" == typeof arguments[0] ? this.parseConfig(arguments[0]) : (this.config = {
  3783. enableDebug: !0
  3784. }, "undefined" != typeof a && (this._width = a), "undefined" != typeof c && (this._height = c), "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 b.RandomDataGenerator([(Date.now() * Math.random()).toString()]), this.state = new b.StateManager(this, f));
  3785. var j = this;
  3786. return this._onBoot = function() {
  3787. return j.boot()
  3788. }, "complete" === document.readyState || "interactive" === document.readyState ? window.setTimeout(this._onBoot, 0) : "undefined" != typeof window.cordova ? document.addEventListener("deviceready", this._onBoot, !1) : (document.addEventListener("DOMContentLoaded", this._onBoot, !1), window.addEventListener("load", this._onBoot, !1)), this
  3789. }, b.Game.prototype = {
  3790. parseConfig: function(a) {
  3791. 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.preserveDrawingBuffer && (this.preserveDrawingBuffer = a.preserveDrawingBuffer), a.physicsConfig && (this.physicsConfig = a.physicsConfig);
  3792. var c = [(Date.now() * Math.random()).toString()];
  3793. a.seed && (c = a.seed), this.rnd = new b.RandomDataGenerator(c);
  3794. var d = null;
  3795. a.state && (d = a.state), this.state = new b.StateManager(this, d)
  3796. },
  3797. boot: function() {
  3798. this.isBooted || (document.body ? (document.removeEventListener("DOMContentLoaded", this._onBoot), window.removeEventListener("load", this._onBoot), this.onPause = new b.Signal, this.onResume = new b.Signal, this.onBlur = new b.Signal, this.onFocus = new b.Signal, this.isBooted = !0, this.device = new b.Device(this), this.math = b.Math, this.scale = new b.ScaleManager(this, this._width, this._height), this.stage = new b.Stage(this), this.setUpRenderer(), this.device.checkFullScreenSupport(), this.world = new b.World(this), this.add = new b.GameObjectFactory(this), this.make = new b.GameObjectCreator(this), this.cache = new b.Cache(this), this.load = new b.Loader(this), this.time = new b.Time(this), this.tweens = new b.TweenManager(this), this.input = new b.Input(this), this.sound = new b.SoundManager(this), this.physics = new b.Physics(this, this.physicsConfig), this.particles = new b.Particles(this), this.plugins = new b.PluginManager(this), this.net = new b.Net(this), this.time.boot(), this.stage.boot(), this.world.boot(), this.scale.boot(), this.input.boot(), this.sound.boot(), this.state.boot(), this.config.enableDebug && (this.debug = new b.Utils.Debug(this), this.debug.boot()), this.showDebugHeader(), this.isRunning = !0, this.raf = this.config && this.config.forceSetTimeOut ? new b.RequestAnimationFrame(this, this.config.forceSetTimeOut) : new b.RequestAnimationFrame(this, !1), this.raf.start()) : window.setTimeout(this._onBoot, 20))
  3799. },
  3800. showDebugHeader: function() {
  3801. var a = b.VERSION,
  3802. c = "Canvas",
  3803. d = "HTML Audio",
  3804. e = 1;
  3805. if (this.renderType === b.WEBGL ? (c = "WebGL", e++) : this.renderType == b.HEADLESS && (c = "Headless"), this.device.webAudio && (d = "WebAudio", e++), this.device.chrome) {
  3806. for (var f = ["%c %c %c Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " %c %c http://www.play68.com %c %c ♥%c♥%c♥ ", "background: #7a66a3", "background: #625186", "color: #ffffff; background: #43375b;", "background: #625186", "background: #ccb9f2", "background: #625186"], g = 0; 3 > g; g++) f.push(e > g ? "color: #ff2424; background: #fff" : "color: #959595; background: #fff");
  3807. console.log.apply(console, f)
  3808. } else window.console && console.log("Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " | http://www.play68.com")
  3809. },
  3810. setUpRenderer: function() {
  3811. if (this.canvas = this.config.canvasID ? b.Canvas.create(this.width, this.height, this.config.canvasID) : b.Canvas.create(this.width, this.height), this.config.canvasStyle ? this.canvas.style = this.config.canvasStyle : this.canvas.style["-webkit-full-screen"] = "width: 100%; height: 100%", this.device.cocoonJS && (this.canvas.screencanvas = this.renderType === b.CANVAS ? !0 : !1), this.renderType === b.HEADLESS || this.renderType === b.CANVAS || this.renderType === b.AUTO && this.device.webGL === !1) {
  3812. if (!this.device.canvas) throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");
  3813. this.renderType === b.AUTO && (this.renderType = b.CANVAS), this.renderer = new PIXI.CanvasRenderer(this.width, this.height, {
  3814. view: this.canvas,
  3815. transparent: this.transparent,
  3816. resolution: 1,
  3817. clearBeforeRender: !0
  3818. }), this.context = this.renderer.context
  3819. } else this.renderType = b.WEBGL, this.renderer = new PIXI.WebGLRenderer(this.width, this.height, {
  3820. view: this.canvas,
  3821. transparent: this.transparent,
  3822. resolution: 1,
  3823. antialias: this.antialias,
  3824. preserveDrawingBuffer: this.preserveDrawingBuffer
  3825. }), this.context = null;
  3826. this.renderType !== b.HEADLESS && (this.stage.smoothed = this.antialias, b.Canvas.addToDOM(this.canvas, this.parent, !1), b.Canvas.setTouchAction(this.canvas))
  3827. },
  3828. update: function(a) {
  3829. this.time.update(a), this._paused || this.pendingStep ? (this.state.pauseUpdate(), this.config.enableDebug && this.debug.preUpdate()) : (this.stepping && (this.pendingStep = !0), this.scale.preUpdate(), this.config.enableDebug && this.debug.preUpdate(), this.physics.preUpdate(), this.state.preUpdate(), this.plugins.preUpdate(), this.stage.preUpdate(), this.state.update(), this.stage.update(), this.tweens.update(), this.sound.update(), this.input.update(), this.physics.update(), this.particles.update(), this.plugins.update(), this.stage.postUpdate(), this.plugins.postUpdate()), this.renderType != b.HEADLESS && (this.state.preRender(), this.renderer.render(this.stage), this.plugins.render(), this.state.render(), this.plugins.postRender(), this.device.cocoonJS && this.renderType === b.CANVAS && 1 === this.stage.currentRenderOrderID && this.context.fillRect(0, 0, 0, 0))
  3830. },
  3831. enableStep: function() {
  3832. this.stepping = !0, this.pendingStep = !1, this.stepCount = 0
  3833. },
  3834. disableStep: function() {
  3835. this.stepping = !1, this.pendingStep = !1
  3836. },
  3837. step: function() {
  3838. this.pendingStep = !1, this.stepCount++
  3839. },
  3840. destroy: function() {
  3841. 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, b.Canvas.removeFromDOM(this.canvas)
  3842. },
  3843. gamePaused: function(a) {
  3844. this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.setMute(), this.onPause.dispatch(a))
  3845. },
  3846. gameResumed: function(a) {
  3847. this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.unsetMute(), this.onResume.dispatch(a))
  3848. },
  3849. focusLoss: function(a) {
  3850. this.onBlur.dispatch(a), this.stage.disableVisibilityChange || this.gamePaused(a)
  3851. },
  3852. focusGain: function(a) {
  3853. this.onFocus.dispatch(a), this.stage.disableVisibilityChange || this.gameResumed(a)
  3854. }
  3855. }, b.Game.prototype.constructor = b.Game, Object.defineProperty(b.Game.prototype, "paused", {
  3856. get: function() {
  3857. return this._paused
  3858. },
  3859. set: function(a) {
  3860. 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)
  3861. }
  3862. }), b.Input = function(a) {
  3863. this.game = a, this.hitCanvas = null, this.hitContext = null, this.moveCallbacks = [], this.moveCallback = null, this.moveCallbackContext = this, this.pollRate = 0, this.disabled = !1, this.multiInputOverride = b.Input.MOUSE_TOUCH_COMBINE, this.position = null, this.speed = null, this.circle = null, this.scale = null, this.maxPointers = 10, this.currentPointers = 0, this.tapRate = 200, this.doubleTapRate = 300, this.holdRate = 2e3, this.justPressedRate = 200, this.justReleasedRate = 200, this.recordPointerHistory = !1, this.recordRate = 100, this.recordLimit = 100, this.pointer1 = null, this.pointer2 = null, this.pointer3 = null, this.pointer4 = null, this.pointer5 = null, this.pointer6 = null, this.pointer7 = null, this.pointer8 = null, this.pointer9 = null, this.pointer10 = null, this.activePointer = null, this.mousePointer = null, this.mouse = null, this.keyboard = null, this.touch = null, this.mspointer = null, this.gamepad = null, this.resetLocked = !1, this.onDown = null, this.onUp = null, this.onTap = null, this.onHold = null, this.minPriorityID = 0, this.interactiveItems = new b.ArrayList, this._localPoint = new b.Point, this._pollCounter = 0, this._oldPosition = null, this._x = 0, this._y = 0
  3864. }, b.Input.MOUSE_OVERRIDES_TOUCH = 0, b.Input.TOUCH_OVERRIDES_MOUSE = 1, b.Input.MOUSE_TOUCH_COMBINE = 2, b.Input.prototype = {
  3865. boot: function() {
  3866. this.mousePointer = new b.Pointer(this.game, 0), this.pointer1 = new b.Pointer(this.game, 1), this.pointer2 = new b.Pointer(this.game, 2), this.mouse = new b.Mouse(this.game), this.keyboard = new b.Keyboard(this.game), this.touch = new b.Touch(this.game), this.mspointer = new b.MSPointer(this.game), this.gamepad = new b.Gamepad(this.game), this.onDown = new b.Signal, this.onUp = new b.Signal, this.onTap = new b.Signal, this.onHold = new b.Signal, this.scale = new b.Point(1, 1), this.speed = new b.Point, this.position = new b.Point, this._oldPosition = new b.Point, this.circle = new b.Circle(0, 0, 44), this.activePointer = this.mousePointer, this.currentPointers = 0, this.hitCanvas = document.createElement("canvas"), this.hitCanvas.width = 1, this.hitCanvas.height = 1, this.hitContext = this.hitCanvas.getContext("2d"), this.mouse.start(), this.keyboard.start(), this.touch.start(), this.mspointer.start(), this.mousePointer.active = !0
  3867. },
  3868. destroy: function() {
  3869. this.mouse.stop(), this.keyboard.stop(), this.touch.stop(), this.mspointer.stop(), this.gamepad.stop(), this.moveCallbacks = []
  3870. },
  3871. addMoveCallback: function(a, b) {
  3872. return this.moveCallbacks.push({
  3873. callback: a,
  3874. context: b
  3875. }) - 1
  3876. },
  3877. deleteMoveCallback: function(a) {
  3878. this.moveCallbacks[a] && this.moveCallbacks.splice(a, 1)
  3879. },
  3880. addPointer: function() {
  3881. for (var a = 0, c = 10; c > 0; c--) null === this["pointer" + c] && (a = c);
  3882. return 0 === a ? (console.warn("You can only have 10 Pointer objects"), null) : (this["pointer" + a] = new b.Pointer(this.game, a), this["pointer" + a])
  3883. },
  3884. update: function() {
  3885. return this.keyboard.update(), this.pollRate > 0 && this._pollCounter < this.pollRate ? void this._pollCounter++ : (this.speed.x = this.position.x - this._oldPosition.x, this.speed.y = this.position.y - this._oldPosition.y, this._oldPosition.copyFrom(this.position), this.mousePointer.update(), this.gamepad.active && this.gamepad.update(), this.pointer1.update(), this.pointer2.update(), this.pointer3 && this.pointer3.update(), this.pointer4 && this.pointer4.update(), this.pointer5 && this.pointer5.update(), this.pointer6 && this.pointer6.update(), this.pointer7 && this.pointer7.update(), this.pointer8 && this.pointer8.update(), this.pointer9 && this.pointer9.update(), this.pointer10 && this.pointer10.update(), void(this._pollCounter = 0))
  3886. },
  3887. reset: function(a) {
  3888. if (this.game.isBooted && !this.resetLocked) {
  3889. "undefined" == typeof a && (a = !1), this.keyboard.reset(a), this.mousePointer.reset(), this.gamepad.reset();
  3890. for (var c = 1; 10 >= c; c++) this["pointer" + c] && this["pointer" + c].reset();
  3891. this.currentPointers = 0, "none" !== this.game.canvas.style.cursor && (this.game.canvas.style.cursor = "inherit"), a && (this.onDown.dispose(), this.onUp.dispose(), this.onTap.dispose(), this.onHold.dispose(), this.onDown = new b.Signal, this.onUp = new b.Signal, this.onTap = new b.Signal, this.onHold = new b.Signal, this.moveCallbacks = []), this._pollCounter = 0
  3892. }
  3893. },
  3894. resetSpeed: function(a, b) {
  3895. this._oldPosition.setTo(a, b), this.speed.setTo(0, 0)
  3896. },
  3897. startPointer: function(a) {
  3898. if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) return null;
  3899. if (this.pointer1.active === !1) return this.pointer1.start(a);
  3900. if (this.pointer2.active === !1) return this.pointer2.start(a);
  3901. for (var b = 3; 10 >= b; b++)
  3902. if (this["pointer" + b] && this["pointer" + b].active === !1) return this["pointer" + b].start(a);
  3903. return null
  3904. },
  3905. updatePointer: function(a) {
  3906. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.move(a);
  3907. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.move(a);
  3908. for (var b = 3; 10 >= b; b++)
  3909. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].move(a);
  3910. return null
  3911. },
  3912. stopPointer: function(a) {
  3913. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.stop(a);
  3914. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.stop(a);
  3915. for (var b = 3; 10 >= b; b++)
  3916. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].stop(a);
  3917. return null
  3918. },
  3919. getPointer: function(a) {
  3920. if (a = a || !1, this.pointer1.active == a) return this.pointer1;
  3921. if (this.pointer2.active == a) return this.pointer2;
  3922. for (var b = 3; 10 >= b; b++)
  3923. if (this["pointer" + b] && this["pointer" + b].active == a) return this["pointer" + b];
  3924. return null
  3925. },
  3926. getPointerFromIdentifier: function(a) {
  3927. if (this.pointer1.identifier === a) return this.pointer1;
  3928. if (this.pointer2.identifier === a) return this.pointer2;
  3929. for (var b = 3; 10 >= b; b++)
  3930. if (this["pointer" + b] && this["pointer" + b].identifier === a) return this["pointer" + b];
  3931. return null
  3932. },
  3933. getPointerFromId: function(a) {
  3934. if (this.pointer1.pointerId === a) return this.pointer1;
  3935. if (this.pointer2.pointerId === a) return this.pointer2;
  3936. for (var b = 3; 10 >= b; b++)
  3937. if (this["pointer" + b] && this["pointer" + b].pointerId === a) return this["pointer" + b];
  3938. return null
  3939. },
  3940. getLocalPosition: function(a, c, d) {
  3941. "undefined" == typeof d && (d = new b.Point);
  3942. var e = a.worldTransform,
  3943. f = 1 / (e.a * e.d + e.c * -e.b);
  3944. return d.setTo(e.d * f * c.x + -e.c * f * c.y + (e.ty * e.c - e.tx * e.d) * f, e.a * f * c.y + -e.b * f * c.x + (-e.ty * e.a + e.tx * e.b) * f)
  3945. },
  3946. hitTest: function(a, c, d) {
  3947. if (!a.worldVisible) return !1;
  3948. if (this.getLocalPosition(a, c, this._localPoint), d.copyFrom(this._localPoint), a.hitArea && a.hitArea.contains) return a.hitArea.contains(this._localPoint.x, this._localPoint.y);
  3949. if (a instanceof PIXI.Sprite) {
  3950. var e = a.texture.frame.width,
  3951. f = a.texture.frame.height,
  3952. g = -e * a.anchor.x;
  3953. if (this._localPoint.x >= g && this._localPoint.x < g + e) {
  3954. var h = -f * a.anchor.y;
  3955. if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
  3956. }
  3957. } else if (a instanceof b.TileSprite) {
  3958. var e = a.width,
  3959. f = a.height,
  3960. g = -e * a.anchor.x;
  3961. if (this._localPoint.x >= g && this._localPoint.x < g + e) {
  3962. var h = -f * a.anchor.y;
  3963. if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
  3964. }
  3965. } else if (a instanceof b.Graphics)
  3966. for (var i = 0; i < a.graphicsData.length; i++) {
  3967. var j = a.graphicsData[i];
  3968. if (j.fill && j.shape && j.shape.contains(this._localPoint.x, this._localPoint.y)) return !0
  3969. }
  3970. for (var i = 0, k = a.children.length; k > i; i++)
  3971. if (this.hitTest(a.children[i], c, d)) return !0;
  3972. return !1
  3973. }
  3974. }, b.Input.prototype.constructor = b.Input, Object.defineProperty(b.Input.prototype, "x", {
  3975. get: function() {
  3976. return this._x
  3977. },
  3978. set: function(a) {
  3979. this._x = Math.floor(a)
  3980. }
  3981. }), Object.defineProperty(b.Input.prototype, "y", {
  3982. get: function() {
  3983. return this._y
  3984. },
  3985. set: function(a) {
  3986. this._y = Math.floor(a)
  3987. }
  3988. }), Object.defineProperty(b.Input.prototype, "pollLocked", {
  3989. get: function() {
  3990. return this.pollRate > 0 && this._pollCounter < this.pollRate
  3991. }
  3992. }), Object.defineProperty(b.Input.prototype, "totalInactivePointers", {
  3993. get: function() {
  3994. return 10 - this.currentPointers
  3995. }
  3996. }), Object.defineProperty(b.Input.prototype, "totalActivePointers", {
  3997. get: function() {
  3998. this.currentPointers = 0;
  3999. for (var a = 1; 10 >= a; a++) this["pointer" + a] && this["pointer" + a].active && this.currentPointers++;
  4000. return this.currentPointers
  4001. }
  4002. }), Object.defineProperty(b.Input.prototype, "worldX", {
  4003. get: function() {
  4004. return this.game.camera.view.x + this.x
  4005. }
  4006. }), Object.defineProperty(b.Input.prototype, "worldY", {
  4007. get: function() {
  4008. return this.game.camera.view.y + this.y
  4009. }
  4010. }), b.Key = function(a, c) {
  4011. this.game = a, this.enabled = !0, this.event = null, this.isDown = !1, this.isUp = !0, this.altKey = !1, this.ctrlKey = !1, this.shiftKey = !1, this.timeDown = 0, this.duration = 0, this.timeUp = -2500, this.repeats = 0, this.keyCode = c, this.onDown = new b.Signal, this.onHoldCallback = null, this.onHoldContext = null, this.onUp = new b.Signal
  4012. }, b.Key.prototype = {
  4013. update: function() {
  4014. this.enabled && this.isDown && (this.duration = this.game.time.now - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this))
  4015. },
  4016. processKeyDown: function(a) {
  4017. this.enabled && (this.event = a, this.isDown || (this.altKey = a.altKey, this.ctrlKey = a.ctrlKey, this.shiftKey = a.shiftKey, this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0, this.onDown.dispatch(this)))
  4018. },
  4019. processKeyUp: function(a) {
  4020. this.enabled && (this.event = a, this.isUp || (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.duration = this.game.time.now - this.timeDown, this.onUp.dispatch(this)))
  4021. },
  4022. reset: function(a) {
  4023. "undefined" == typeof a && (a = !0), this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.duration = 0, this.enabled = !0, a && (this.onDown.removeAll(), this.onUp.removeAll(), this.onHoldCallback = null, this.onHoldContext = null)
  4024. },
  4025. justPressed: function(a) {
  4026. return "undefined" == typeof a && (a = 50), this.isDown && this.duration < a
  4027. },
  4028. justReleased: function(a) {
  4029. return "undefined" == typeof a && (a = 50), !this.isDown && this.game.time.now - this.timeUp < a
  4030. }
  4031. }, b.Key.prototype.constructor = b.Key, b.Keyboard = function(a) {
  4032. this.game = a, this.disabled = !1, this.event = null, this.pressEvent = null, this.callbackContext = this, this.onDownCallback = null, this.onPressCallback = null, this.onUpCallback = null, this._keys = [], this._capture = [], this._onKeyDown = null, this._onKeyPress = null, this._onKeyUp = null, this._i = 0, this._k = 0
  4033. }, b.Keyboard.prototype = {
  4034. addCallbacks: function(a, b, c, d) {
  4035. this.callbackContext = a, "undefined" != typeof b && (this.onDownCallback = b), "undefined" != typeof c && (this.onUpCallback = c), "undefined" != typeof d && (this.onPressCallback = d)
  4036. },
  4037. addKey: function(a) {
  4038. return this._keys[a] || (this._keys[a] = new b.Key(this.game, a), this.addKeyCapture(a)), this._keys[a]
  4039. },
  4040. removeKey: function(a) {
  4041. this._keys[a] && (this._keys[a] = null, this.removeKeyCapture(a))
  4042. },
  4043. createCursorKeys: function() {
  4044. return {
  4045. up: this.addKey(b.Keyboard.UP),
  4046. down: this.addKey(b.Keyboard.DOWN),
  4047. left: this.addKey(b.Keyboard.LEFT),
  4048. right: this.addKey(b.Keyboard.RIGHT)
  4049. }
  4050. },
  4051. start: function() {
  4052. if (!this.game.device.cocoonJS && null === this._onKeyDown) {
  4053. var a = this;
  4054. this._onKeyDown = function(b) {
  4055. return a.processKeyDown(b)
  4056. }, this._onKeyUp = function(b) {
  4057. return a.processKeyUp(b)
  4058. }, this._onKeyPress = function(b) {
  4059. return a.processKeyPress(b)
  4060. }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
  4061. }
  4062. },
  4063. stop: function() {
  4064. window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null
  4065. },
  4066. destroy: function() {
  4067. this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0
  4068. },
  4069. addKeyCapture: function(a) {
  4070. if ("object" == typeof a)
  4071. for (var b in a) this._capture[a[b]] = !0;
  4072. else this._capture[a] = !0
  4073. },
  4074. removeKeyCapture: function(a) {
  4075. delete this._capture[a]
  4076. },
  4077. clearCaptures: function() {
  4078. this._capture = {}
  4079. },
  4080. update: function() {
  4081. for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update()
  4082. },
  4083. processKeyDown: function(a) {
  4084. this.event = a, this.game.input.disabled || this.disabled || (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new b.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyDown(a), this._k = a.keyCode, this.onDownCallback && this.onDownCallback.call(this.callbackContext, a))
  4085. },
  4086. processKeyPress: function(a) {
  4087. this.pressEvent = a, this.game.input.disabled || this.disabled || this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(a.charCode), a)
  4088. },
  4089. processKeyUp: function(a) {
  4090. this.event = a, this.game.input.disabled || this.disabled || (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new b.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyUp(a), this.onUpCallback && this.onUpCallback.call(this.callbackContext, a))
  4091. },
  4092. reset: function(a) {
  4093. "undefined" == typeof a && (a = !0), this.event = null;
  4094. for (var b = this._keys.length; b--;) this._keys[b] && this._keys[b].reset(a)
  4095. },
  4096. justPressed: function(a, b) {
  4097. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justPressed(b) : !1
  4098. },
  4099. justReleased: function(a, b) {
  4100. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justReleased(b) : !1
  4101. },
  4102. isDown: function(a) {
  4103. return this._keys[a] ? this._keys[a].isDown : !1
  4104. }
  4105. }, Object.defineProperty(b.Keyboard.prototype, "lastChar", {
  4106. get: function() {
  4107. return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode)
  4108. }
  4109. }), Object.defineProperty(b.Keyboard.prototype, "lastKey", {
  4110. get: function() {
  4111. return this._keys[this._k]
  4112. }
  4113. }), b.Keyboard.prototype.constructor = b.Keyboard, b.Keyboard.A = "A".charCodeAt(0), b.Keyboard.B = "B".charCodeAt(0), b.Keyboard.C = "C".charCodeAt(0), b.Keyboard.D = "D".charCodeAt(0), b.Keyboard.E = "E".charCodeAt(0), b.Keyboard.F = "F".charCodeAt(0), b.Keyboard.G = "G".charCodeAt(0), b.Keyboard.H = "H".charCodeAt(0), b.Keyboard.I = "I".charCodeAt(0), b.Keyboard.J = "J".charCodeAt(0), b.Keyboard.K = "K".charCodeAt(0), b.Keyboard.L = "L".charCodeAt(0), b.Keyboard.M = "M".charCodeAt(0), b.Keyboard.N = "N".charCodeAt(0), b.Keyboard.O = "O".charCodeAt(0), b.Keyboard.P = "P".charCodeAt(0), b.Keyboard.Q = "Q".charCodeAt(0), b.Keyboard.R = "R".charCodeAt(0), b.Keyboard.S = "S".charCodeAt(0), b.Keyboard.T = "T".charCodeAt(0), b.Keyboard.U = "U".charCodeAt(0), b.Keyboard.V = "V".charCodeAt(0), b.Keyboard.W = "W".charCodeAt(0), b.Keyboard.X = "X".charCodeAt(0), b.Keyboard.Y = "Y".charCodeAt(0), b.Keyboard.Z = "Z".charCodeAt(0), b.Keyboard.ZERO = "0".charCodeAt(0), b.Keyboard.ONE = "1".charCodeAt(0), b.Keyboard.TWO = "2".charCodeAt(0), b.Keyboard.THREE = "3".charCodeAt(0), b.Keyboard.FOUR = "4".charCodeAt(0), b.Keyboard.FIVE = "5".charCodeAt(0), b.Keyboard.SIX = "6".charCodeAt(0), b.Keyboard.SEVEN = "7".charCodeAt(0), b.Keyboard.EIGHT = "8".charCodeAt(0), b.Keyboard.NINE = "9".charCodeAt(0), b.Keyboard.NUMPAD_0 = 96, b.Keyboard.NUMPAD_1 = 97, b.Keyboard.NUMPAD_2 = 98, b.Keyboard.NUMPAD_3 = 99, b.Keyboard.NUMPAD_4 = 100, b.Keyboard.NUMPAD_5 = 101, b.Keyboard.NUMPAD_6 = 102, b.Keyboard.NUMPAD_7 = 103, b.Keyboard.NUMPAD_8 = 104, b.Keyboard.NUMPAD_9 = 105, b.Keyboard.NUMPAD_MULTIPLY = 106, b.Keyboard.NUMPAD_ADD = 107, b.Keyboard.NUMPAD_ENTER = 108, b.Keyboard.NUMPAD_SUBTRACT = 109, b.Keyboard.NUMPAD_DECIMAL = 110, b.Keyboard.NUMPAD_DIVIDE = 111, b.Keyboard.F1 = 112, b.Keyboard.F2 = 113, b.Keyboard.F3 = 114, b.Keyboard.F4 = 115, b.Keyboard.F5 = 116, b.Keyboard.F6 = 117, b.Keyboard.F7 = 118, b.Keyboard.F8 = 119, b.Keyboard.F9 = 120, b.Keyboard.F10 = 121, b.Keyboard.F11 = 122, b.Keyboard.F12 = 123, b.Keyboard.F13 = 124, b.Keyboard.F14 = 125, b.Keyboard.F15 = 126, b.Keyboard.COLON = 186, b.Keyboard.EQUALS = 187, b.Keyboard.UNDERSCORE = 189, b.Keyboard.QUESTION_MARK = 191, b.Keyboard.TILDE = 192, b.Keyboard.OPEN_BRACKET = 219, b.Keyboard.BACKWARD_SLASH = 220, b.Keyboard.CLOSED_BRACKET = 221, b.Keyboard.QUOTES = 222, b.Keyboard.BACKSPACE = 8, b.Keyboard.TAB = 9, b.Keyboard.CLEAR = 12, b.Keyboard.ENTER = 13, b.Keyboard.SHIFT = 16, b.Keyboard.CONTROL = 17, b.Keyboard.ALT = 18, b.Keyboard.CAPS_LOCK = 20, b.Keyboard.ESC = 27, b.Keyboard.SPACEBAR = 32, b.Keyboard.PAGE_UP = 33, b.Keyboard.PAGE_DOWN = 34, b.Keyboard.END = 35, b.Keyboard.HOME = 36, b.Keyboard.LEFT = 37, b.Keyboard.UP = 38, b.Keyboard.RIGHT = 39, b.Keyboard.DOWN = 40, b.Keyboard.INSERT = 45, b.Keyboard.DELETE = 46, b.Keyboard.HELP = 47, b.Keyboard.NUM_LOCK = 144, b.Keyboard.PLUS = 43, b.Keyboard.MINUS = 45, b.Mouse = function(a) {
  4114. this.game = a, this.callbackContext = this.game, this.mouseDownCallback = null, this.mouseMoveCallback = null, this.mouseUpCallback = null, this.mouseOutCallback = null, this.mouseOverCallback = null, this.mouseWheelCallback = null, this.capture = !1, this.button = -1, this.wheelDelta = 0, this.disabled = !1, this.locked = !1, this.stopOnGameOut = !1, this.pointerLock = new b.Signal, this.event = null, this._onMouseDown = null, this._onMouseMove = null, this._onMouseUp = null, this._onMouseOut = null, this._onMouseOver = null, this._onMouseWheel = null
  4115. }, b.Mouse.NO_BUTTON = -1, b.Mouse.LEFT_BUTTON = 0, b.Mouse.MIDDLE_BUTTON = 1, b.Mouse.RIGHT_BUTTON = 2, b.Mouse.WHEEL_UP = 1, b.Mouse.WHEEL_DOWN = -1, b.Mouse.prototype = {
  4116. start: function() {
  4117. if ((!this.game.device.android || this.game.device.chrome !== !1) && null === this._onMouseDown) {
  4118. var a = this;
  4119. this._onMouseDown = function(b) {
  4120. return a.onMouseDown(b)
  4121. }, this._onMouseMove = function(b) {
  4122. return a.onMouseMove(b)
  4123. }, this._onMouseUp = function(b) {
  4124. return a.onMouseUp(b)
  4125. }, this._onMouseUpGlobal = function(b) {
  4126. return a.onMouseUpGlobal(b)
  4127. }, this._onMouseOut = function(b) {
  4128. return a.onMouseOut(b)
  4129. }, this._onMouseOver = function(b) {
  4130. return a.onMouseOver(b)
  4131. }, this._onMouseWheel = function(b) {
  4132. return a.onMouseWheel(b)
  4133. }, 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), this.game.canvas.addEventListener("mousewheel", this._onMouseWheel, !0), this.game.canvas.addEventListener("DOMMouseScroll", this._onMouseWheel, !0))
  4134. }
  4135. },
  4136. onMouseDown: function(a) {
  4137. this.event = a, this.capture && a.preventDefault(), this.button = a.button, this.mouseDownCallback && this.mouseDownCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a.identifier = 0, this.game.input.mousePointer.start(a))
  4138. },
  4139. onMouseMove: function(a) {
  4140. this.event = a, this.capture && a.preventDefault(), this.mouseMoveCallback && this.mouseMoveCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a.identifier = 0, this.game.input.mousePointer.move(a))
  4141. },
  4142. onMouseUp: function(a) {
  4143. this.event = a, this.capture && a.preventDefault(), this.button = b.Mouse.NO_BUTTON, this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a.identifier = 0, this.game.input.mousePointer.stop(a))
  4144. },
  4145. onMouseUpGlobal: function(a) {
  4146. this.game.input.mousePointer.withinGame || (this.button = b.Mouse.NO_BUTTON, this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, a), a.identifier = 0, this.game.input.mousePointer.stop(a))
  4147. },
  4148. onMouseOut: function(a) {
  4149. this.event = a, this.capture && a.preventDefault(), this.game.input.mousePointer.withinGame = !1, this.mouseOutCallback && this.mouseOutCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || this.stopOnGameOut && (a.identifier = 0, this.game.input.mousePointer.stop(a))
  4150. },
  4151. onMouseWheel: function(a) {
  4152. this.event = a, this.capture && a.preventDefault(), this.wheelDelta = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail)), this.mouseWheelCallback && this.mouseWheelCallback.call(this.callbackContext, a)
  4153. },
  4154. onMouseOver: function(a) {
  4155. this.event = a, this.capture && a.preventDefault(), this.game.input.mousePointer.withinGame = !0, this.mouseOverCallback && this.mouseOverCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled
  4156. },
  4157. requestPointerLock: function() {
  4158. if (this.game.device.pointerLock) {
  4159. var a = this.game.canvas;
  4160. a.requestPointerLock = a.requestPointerLock || a.mozRequestPointerLock || a.webkitRequestPointerLock, a.requestPointerLock();
  4161. var b = this;
  4162. this._pointerLockChange = function(a) {
  4163. return b.pointerLockChange(a)
  4164. }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  4165. }
  4166. },
  4167. pointerLockChange: function(a) {
  4168. var b = this.game.canvas;
  4169. 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))
  4170. },
  4171. releasePointerLock: function() {
  4172. 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)
  4173. },
  4174. stop: function() {
  4175. this.game.canvas.removeEventListener("mousedown", this._onMouseDown, !0), this.game.canvas.removeEventListener("mousemove", this._onMouseMove, !0), this.game.canvas.removeEventListener("mouseup", this._onMouseUp, !0), this.game.canvas.removeEventListener("mouseover", this._onMouseOver, !0), this.game.canvas.removeEventListener("mouseout", this._onMouseOut, !0), this.game.canvas.removeEventListener("mousewheel", this._onMouseWheel, !0), this.game.canvas.removeEventListener("DOMMouseScroll", this._onMouseWheel, !0), window.removeEventListener("mouseup", this._onMouseUpGlobal, !0), document.removeEventListener("pointerlockchange", this._pointerLockChange, !0), document.removeEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.removeEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  4176. }
  4177. }, b.Mouse.prototype.constructor = b.Mouse, b.MSPointer = function(a) {
  4178. this.game = a, this.callbackContext = this.game, this.disabled = !1, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null
  4179. }, b.MSPointer.prototype = {
  4180. start: function() {
  4181. if (null === this._onMSPointerDown) {
  4182. var a = this;
  4183. this.game.device.mspointer && (this._onMSPointerDown = function(b) {
  4184. return a.onPointerDown(b)
  4185. }, this._onMSPointerMove = function(b) {
  4186. return a.onPointerMove(b)
  4187. }, this._onMSPointerUp = function(b) {
  4188. return a.onPointerUp(b)
  4189. }, 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")
  4190. }
  4191. },
  4192. onPointerDown: function(a) {
  4193. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.startPointer(a))
  4194. },
  4195. onPointerMove: function(a) {
  4196. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.updatePointer(a))
  4197. },
  4198. onPointerUp: function(a) {
  4199. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.stopPointer(a))
  4200. },
  4201. stop: function() {
  4202. 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)
  4203. }
  4204. }, b.MSPointer.prototype.constructor = b.MSPointer, b.Pointer = function(a, c) {
  4205. this.game = a, this.id = c, this.type = b.POINTER, this.exists = !0, this.identifier = 0, this.pointerId = null, this.target = null, this.button = null, this._holdSent = !1, this._history = [], this._nextDrop = 0, this._stateReset = !1, this.withinGame = !1, this.clientX = -1, this.clientY = -1, this.pageX = -1, this.pageY = -1, this.screenX = -1, this.screenY = -1, this.rawMovementX = 0, this.rawMovementY = 0, this.movementX = 0, this.movementY = 0, this.x = -1, this.y = -1, this.isMouse = !1, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.timeUp = 0, this.previousTapTime = 0, this.totalTouches = 0, this.msSinceLastClick = Number.MAX_VALUE, this.targetObject = null, this.active = !1, this.dirty = !1, this.position = new b.Point, this.positionDown = new b.Point, this.positionUp = new b.Point, this.circle = new b.Circle(0, 0, 44), 0 === c && (this.isMouse = !0)
  4206. }, b.Pointer.prototype = {
  4207. start: function(a) {
  4208. 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.msSinceLastClick = this.game.time.now - this.timeDown, this.timeDown = this.game.time.now, this._holdSent = !1, this.move(a, !0), this.positionDown.setTo(this.x, this.y), (this.game.input.multiInputOverride === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.x = this.x, this.game.input.y = this.y, this.game.input.position.setTo(this.x, this.y), this.game.input.onDown.dispatch(this, a), this.game.input.resetSpeed(this.x, this.y)), this._stateReset = !1, this.totalTouches++, this.isMouse || this.game.input.currentPointers++, null !== this.targetObject && this.targetObject._touchedHandler(this), this
  4209. },
  4210. update: function() {
  4211. this.active && (this.dirty && (this.game.input.interactiveItems.total > 0 && this.processInteractiveObjects(!0), this.dirty = !1), this._holdSent === !1 && this.duration >= this.game.input.holdRate && ((this.game.input.multiInputOverride == b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride == b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && this.game.input.onHold.dispatch(this), this._holdSent = !0), this.game.input.recordPointerHistory && this.game.time.now >= this._nextDrop && (this._nextDrop = this.game.time.now + this.game.input.recordRate, this._history.push({
  4212. x: this.position.x,
  4213. y: this.position.y
  4214. }), this._history.length > this.game.input.recordLimit && this._history.shift()))
  4215. },
  4216. move: function(a, c) {
  4217. if (!this.game.input.pollLocked) {
  4218. if ("undefined" == typeof c && (c = !1), "undefined" != typeof a.button && (this.button = a.button), this.clientX = a.clientX, this.clientY = a.clientY, this.pageX = a.pageX, this.pageY = a.pageY, this.screenX = a.screenX, this.screenY = a.screenY, this.isMouse && this.game.input.mouse.locked && !c && (this.rawMovementX = a.movementX || a.mozMovementX || a.webkitMovementX || 0, this.rawMovementY = a.movementY || a.mozMovementY || a.webkitMovementY || 0, this.movementX += this.rawMovementX, this.movementY += this.rawMovementY), this.x = (this.pageX - this.game.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 === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.activePointer = this, this.game.input.x = this.x, this.game.input.y = this.y, this.game.input.position.setTo(this.game.input.x, this.game.input.y), this.game.input.circle.x = this.game.input.x, this.game.input.circle.y = this.game.input.y), this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY), this.game.paused) return this;
  4219. 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, c);
  4220. return null !== this.targetObject && this.targetObject.isDragged === !0 ? this.targetObject.update(this) === !1 && (this.targetObject = null) : this.game.input.interactiveItems.total > 0 && this.processInteractiveObjects(c), this
  4221. }
  4222. },
  4223. processInteractiveObjects: function(a) {
  4224. this.game.input.interactiveItems.setAll("checked", !1), this._highestRenderOrderID = Number.MAX_SAFE_INTEGER, this._highestRenderObject = null, this._highestInputPriorityID = -1;
  4225. var b = this.game.input.interactiveItems.first;
  4226. do b && b.validForInput(this._highestInputPriorityID, this._highestRenderOrderID, !1) && (b.checked = !0, (a && b.checkPointerDown(this, !0) || !a && b.checkPointerOver(this, !0)) && (this._highestRenderOrderID = b.sprite._cache[3], this._highestInputPriorityID = b.priorityID, this._highestRenderObject = b)), b = this.game.input.interactiveItems.next; while (null !== b);
  4227. var b = this.game.input.interactiveItems.first;
  4228. do b && !b.checked && b.validForInput(this._highestInputPriorityID, this._highestRenderOrderID, !0) && (a && b.checkPointerDown(this, !1) || !a && b.checkPointerOver(this, !1)) && (this._highestRenderOrderID = b.sprite._cache[3], this._highestInputPriorityID = b.priorityID, this._highestRenderObject = b), b = this.game.input.interactiveItems.next; while (null !== b);
  4229. return null === this._highestRenderObject ? this.targetObject && (this.targetObject._pointerOutHandler(this), this.targetObject = null) : null === this.targetObject ? (this.targetObject = this._highestRenderObject, this._highestRenderObject._pointerOverHandler(this)) : this.targetObject === this._highestRenderObject ? this._highestRenderObject.update(this) === !1 && (this.targetObject = null) : (this.targetObject._pointerOutHandler(this), this.targetObject = this._highestRenderObject, this.targetObject._pointerOverHandler(this)), null !== this.targetObject
  4230. },
  4231. leave: function(a) {
  4232. this.withinGame = !1, this.move(a, !1)
  4233. },
  4234. stop: function(a) {
  4235. return this._stateReset ? void a.preventDefault() : (this.timeUp = this.game.time.now, (this.game.input.multiInputOverride === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.onUp.dispatch(this, a), this.duration >= 0 && this.duration <= this.game.input.tapRate && (this.timeUp - this.previousTapTime < this.game.input.doubleTapRate ? this.game.input.onTap.dispatch(this, !0) : this.game.input.onTap.dispatch(this, !1), this.previousTapTime = this.timeUp)), this.id > 0 && (this.active = !1), this.withinGame = !1, this.isDown = !1, this.isUp = !0, this.pointerId = null, this.identifier = null, this.positionUp.setTo(this.x, this.y), this.isMouse === !1 && this.game.input.currentPointers--, this.game.input.interactiveItems.callAll("_releasedHandler", this), this.targetObject = null, this)
  4236. },
  4237. justPressed: function(a) {
  4238. return a = a || this.game.input.justPressedRate, this.isDown === !0 && this.timeDown + a > this.game.time.now
  4239. },
  4240. justReleased: function(a) {
  4241. return a = a || this.game.input.justReleasedRate, this.isUp === !0 && this.timeUp + a > this.game.time.now
  4242. },
  4243. reset: function() {
  4244. 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
  4245. },
  4246. resetMovement: function() {
  4247. this.movementX = 0, this.movementY = 0
  4248. }
  4249. }, b.Pointer.prototype.constructor = b.Pointer, Object.defineProperty(b.Pointer.prototype, "duration", {
  4250. get: function() {
  4251. return this.isUp ? -1 : this.game.time.now - this.timeDown
  4252. }
  4253. }), Object.defineProperty(b.Pointer.prototype, "worldX", {
  4254. get: function() {
  4255. return this.game.world.camera.x + this.x
  4256. }
  4257. }), Object.defineProperty(b.Pointer.prototype, "worldY", {
  4258. get: function() {
  4259. return this.game.world.camera.y + this.y
  4260. }
  4261. }), b.Touch = function(a) {
  4262. this.game = a, this.disabled = !1, this.callbackContext = this.game, this.touchStartCallback = null, this.touchMoveCallback = null, this.touchEndCallback = null, this.touchEnterCallback = null, this.touchLeaveCallback = null, this.touchCancelCallback = null, this.preventDefault = !0, this.event = null, this._onTouchStart = null, this._onTouchMove = null, this._onTouchEnd = null, this._onTouchEnter = null, this._onTouchLeave = null, this._onTouchCancel = null, this._onTouchMove = null
  4263. }, b.Touch.prototype = {
  4264. start: function() {
  4265. if (null === this._onTouchStart) {
  4266. var a = this;
  4267. this.game.device.touch && (this._onTouchStart = function(b) {
  4268. return a.onTouchStart(b)
  4269. }, this._onTouchMove = function(b) {
  4270. return a.onTouchMove(b)
  4271. }, this._onTouchEnd = function(b) {
  4272. return a.onTouchEnd(b)
  4273. }, this._onTouchEnter = function(b) {
  4274. return a.onTouchEnter(b)
  4275. }, this._onTouchLeave = function(b) {
  4276. return a.onTouchLeave(b)
  4277. }, this._onTouchCancel = function(b) {
  4278. return a.onTouchCancel(b)
  4279. }, 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)))
  4280. }
  4281. },
  4282. consumeDocumentTouches: function() {
  4283. this._documentTouchMove = function(a) {
  4284. a.preventDefault()
  4285. }, document.addEventListener("touchmove", this._documentTouchMove, !1)
  4286. },
  4287. onTouchStart: function(a) {
  4288. if (this.event = a, this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  4289. this.preventDefault && a.preventDefault();
  4290. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.startPointer(a.changedTouches[b])
  4291. }
  4292. },
  4293. onTouchCancel: function(a) {
  4294. if (this.event = a, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  4295. this.preventDefault && a.preventDefault();
  4296. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4297. }
  4298. },
  4299. onTouchEnter: function(a) {
  4300. this.event = a, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || this.preventDefault && a.preventDefault()
  4301. },
  4302. onTouchLeave: function(a) {
  4303. this.event = a, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault()
  4304. },
  4305. onTouchMove: function(a) {
  4306. this.event = a, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4307. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.updatePointer(a.changedTouches[b])
  4308. },
  4309. onTouchEnd: function(a) {
  4310. this.event = a, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  4311. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  4312. },
  4313. stop: function() {
  4314. 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))
  4315. }
  4316. }, b.Touch.prototype.constructor = b.Touch, b.Gamepad = function(a) {
  4317. this.game = a, this._gamepadIndexMap = {}, this._rawPads = [], this._active = !1, this.disabled = !1, this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || -1 != navigator.userAgent.indexOf("Firefox/") || !!navigator.getGamepads, this._prevRawGamepadTypes = [], this._prevTimestamps = [], this.callbackContext = this, this.onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null, this._ongamepadconnected = null, this._gamepaddisconnected = null, this._gamepads = [new b.SinglePad(a, this), new b.SinglePad(a, this), new b.SinglePad(a, this), new b.SinglePad(a, this)]
  4318. }, b.Gamepad.prototype = {
  4319. addCallbacks: function(a, b) {
  4320. "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)
  4321. },
  4322. start: function() {
  4323. if (!this._active) {
  4324. this._active = !0;
  4325. var a = this;
  4326. this._onGamepadConnected = function(b) {
  4327. return a.onGamepadConnected(b)
  4328. }, this._onGamepadDisconnected = function(b) {
  4329. return a.onGamepadDisconnected(b)
  4330. }, window.addEventListener("gamepadconnected", this._onGamepadConnected, !1), window.addEventListener("gamepaddisconnected", this._onGamepadDisconnected, !1)
  4331. }
  4332. },
  4333. onGamepadConnected: function(a) {
  4334. var b = a.gamepad;
  4335. this._rawPads.push(b), this._gamepads[b.index].connect(b)
  4336. },
  4337. onGamepadDisconnected: function(a) {
  4338. var b = a.gamepad;
  4339. for (var c in this._rawPads) this._rawPads[c].index === b.index && this._rawPads.splice(c, 1);
  4340. this._gamepads[b.index].disconnect()
  4341. },
  4342. update: function() {
  4343. this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus()
  4344. },
  4345. _pollGamepads: function() {
  4346. if (navigator.getGamepads) var a = navigator.getGamepads();
  4347. else if (navigator.webkitGetGamepads) var a = navigator.webkitGetGamepads();
  4348. else if (navigator.webkitGamepads) var a = navigator.webkitGamepads();
  4349. if (a) {
  4350. this._rawPads = [];
  4351. 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++);
  4352. if (b) {
  4353. for (var d, e = {
  4354. rawIndices: {},
  4355. padIndices: {}
  4356. }, f = 0; f < this._gamepads.length; f++)
  4357. if (d = this._gamepads[f], d.connected)
  4358. for (var g = 0; g < this._rawPads.length; g++) this._rawPads[g].index === d.index && (e.rawIndices[d.index] = !0, e.padIndices[f] = !0);
  4359. for (var h = 0; h < this._gamepads.length; h++)
  4360. if (d = this._gamepads[h], !e.padIndices[h]) {
  4361. this._rawPads.length < 1 && d.disconnect();
  4362. for (var i = 0; i < this._rawPads.length && !e.padIndices[h]; i++) {
  4363. var j = this._rawPads[i];
  4364. if (j) {
  4365. if (e.rawIndices[j.index]) {
  4366. d.disconnect();
  4367. continue
  4368. }
  4369. d.connect(j), e.rawIndices[j.index] = !0, e.padIndices[h] = !0
  4370. } else d.disconnect()
  4371. }
  4372. }
  4373. }
  4374. }
  4375. },
  4376. setDeadZones: function(a) {
  4377. for (var b = 0; b < this._gamepads.length; b++) this._gamepads[b].deadZone = a
  4378. },
  4379. stop: function() {
  4380. this._active = !1, window.removeEventListener("gamepadconnected", this._onGamepadConnected), window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnected)
  4381. },
  4382. reset: function() {
  4383. this.update();
  4384. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].reset()
  4385. },
  4386. justPressed: function(a, b) {
  4387. for (var c = 0; c < this._gamepads.length; c++)
  4388. if (this._gamepads[c].justPressed(a, b) === !0) return !0;
  4389. return !1
  4390. },
  4391. justReleased: function(a, b) {
  4392. for (var c = 0; c < this._gamepads.length; c++)
  4393. if (this._gamepads[c].justReleased(a, b) === !0) return !0;
  4394. return !1
  4395. },
  4396. isDown: function(a) {
  4397. for (var b = 0; b < this._gamepads.length; b++)
  4398. if (this._gamepads[b].isDown(a) === !0) return !0;
  4399. return !1
  4400. },
  4401. destroy: function() {
  4402. this.stop();
  4403. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].destroy()
  4404. }
  4405. }, b.Gamepad.prototype.constructor = b.Gamepad, Object.defineProperty(b.Gamepad.prototype, "active", {
  4406. get: function() {
  4407. return this._active
  4408. }
  4409. }), Object.defineProperty(b.Gamepad.prototype, "supported", {
  4410. get: function() {
  4411. return this._gamepadSupportAvailable
  4412. }
  4413. }), Object.defineProperty(b.Gamepad.prototype, "padsConnected", {
  4414. get: function() {
  4415. return this._rawPads.length
  4416. }
  4417. }), Object.defineProperty(b.Gamepad.prototype, "pad1", {
  4418. get: function() {
  4419. return this._gamepads[0]
  4420. }
  4421. }), Object.defineProperty(b.Gamepad.prototype, "pad2", {
  4422. get: function() {
  4423. return this._gamepads[1]
  4424. }
  4425. }), Object.defineProperty(b.Gamepad.prototype, "pad3", {
  4426. get: function() {
  4427. return this._gamepads[2]
  4428. }
  4429. }), Object.defineProperty(b.Gamepad.prototype, "pad4", {
  4430. get: function() {
  4431. return this._gamepads[3]
  4432. }
  4433. }), b.Gamepad.BUTTON_0 = 0, b.Gamepad.BUTTON_1 = 1, b.Gamepad.BUTTON_2 = 2, b.Gamepad.BUTTON_3 = 3, b.Gamepad.BUTTON_4 = 4, b.Gamepad.BUTTON_5 = 5, b.Gamepad.BUTTON_6 = 6, b.Gamepad.BUTTON_7 = 7, b.Gamepad.BUTTON_8 = 8, b.Gamepad.BUTTON_9 = 9, b.Gamepad.BUTTON_10 = 10, b.Gamepad.BUTTON_11 = 11, b.Gamepad.BUTTON_12 = 12, b.Gamepad.BUTTON_13 = 13, b.Gamepad.BUTTON_14 = 14, b.Gamepad.BUTTON_15 = 15, b.Gamepad.AXIS_0 = 0, b.Gamepad.AXIS_1 = 1, b.Gamepad.AXIS_2 = 2, b.Gamepad.AXIS_3 = 3, b.Gamepad.AXIS_4 = 4, b.Gamepad.AXIS_5 = 5, b.Gamepad.AXIS_6 = 6, b.Gamepad.AXIS_7 = 7, b.Gamepad.AXIS_8 = 8, b.Gamepad.AXIS_9 = 9, b.Gamepad.XBOX360_A = 0, b.Gamepad.XBOX360_B = 1, b.Gamepad.XBOX360_X = 2, b.Gamepad.XBOX360_Y = 3, b.Gamepad.XBOX360_LEFT_BUMPER = 4, b.Gamepad.XBOX360_RIGHT_BUMPER = 5, b.Gamepad.XBOX360_LEFT_TRIGGER = 6, b.Gamepad.XBOX360_RIGHT_TRIGGER = 7, b.Gamepad.XBOX360_BACK = 8, b.Gamepad.XBOX360_START = 9, b.Gamepad.XBOX360_STICK_LEFT_BUTTON = 10, b.Gamepad.XBOX360_STICK_RIGHT_BUTTON = 11, b.Gamepad.XBOX360_DPAD_LEFT = 14, b.Gamepad.XBOX360_DPAD_RIGHT = 15, b.Gamepad.XBOX360_DPAD_UP = 12, b.Gamepad.XBOX360_DPAD_DOWN = 13, b.Gamepad.XBOX360_STICK_LEFT_X = 0, b.Gamepad.XBOX360_STICK_LEFT_Y = 1, b.Gamepad.XBOX360_STICK_RIGHT_X = 2, b.Gamepad.XBOX360_STICK_RIGHT_Y = 3, b.Gamepad.PS3XC_X = 0, b.Gamepad.PS3XC_CIRCLE = 1, b.Gamepad.PS3XC_SQUARE = 2, b.Gamepad.PS3XC_TRIANGLE = 3, b.Gamepad.PS3XC_L1 = 4, b.Gamepad.PS3XC_R1 = 5, b.Gamepad.PS3XC_L2 = 6, b.Gamepad.PS3XC_R2 = 7, b.Gamepad.PS3XC_SELECT = 8, b.Gamepad.PS3XC_START = 9, b.Gamepad.PS3XC_STICK_LEFT_BUTTON = 10, b.Gamepad.PS3XC_STICK_RIGHT_BUTTON = 11, b.Gamepad.PS3XC_DPAD_UP = 12, b.Gamepad.PS3XC_DPAD_DOWN = 13, b.Gamepad.PS3XC_DPAD_LEFT = 14, b.Gamepad.PS3XC_DPAD_RIGHT = 15, b.Gamepad.PS3XC_STICK_LEFT_X = 0, b.Gamepad.PS3XC_STICK_LEFT_Y = 1, b.Gamepad.PS3XC_STICK_RIGHT_X = 2, b.Gamepad.PS3XC_STICK_RIGHT_Y = 3, b.SinglePad = function(a, b) {
  4434. 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
  4435. }, b.SinglePad.prototype = {
  4436. addCallbacks: function(a, b) {
  4437. "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)
  4438. },
  4439. getButton: function(a) {
  4440. return this._buttons[a] ? this._buttons[a] : null
  4441. },
  4442. pollStatus: function() {
  4443. if (!(!this.connected || this.game.input.disabled || this.game.input.gamepad.disabled || this._rawPad.timestamp && this._rawPad.timestamp === this._prevTimestamp)) {
  4444. for (var a = 0; a < this._buttonsLen; a++) {
  4445. var b = isNaN(this._rawPad.buttons[a]) ? this._rawPad.buttons[a].value : this._rawPad.buttons[a];
  4446. b !== this._buttons[a].value && (1 === b ? this.processButtonDown(a, b) : 0 === b ? this.processButtonUp(a, b) : this.processButtonFloat(a, b))
  4447. }
  4448. for (var c = 0; c < this._axesLen; c++) {
  4449. var d = this._rawPad.axes[c];
  4450. d > 0 && d > this.deadZone || 0 > d && d < -this.deadZone ? this.processAxisChange(c, d) : this.processAxisChange(c, 0)
  4451. }
  4452. this._prevTimestamp = this._rawPad.timestamp
  4453. }
  4454. },
  4455. connect: function(a) {
  4456. var c = !this.connected;
  4457. this.connected = !0, this.index = a.index, this._rawPad = a, this._buttons = [], this._buttonsLen = a.buttons.length, this._axes = [], this._axesLen = a.axes.length;
  4458. for (var d = 0; d < this._axesLen; d++) this._axes[d] = a.axes[d];
  4459. for (var e in a.buttons) e = parseInt(e, 10), this._buttons[e] = new b.GamepadButton(this, e);
  4460. c && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), c && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
  4461. },
  4462. disconnect: function() {
  4463. var a = this.connected,
  4464. b = this.index;
  4465. this.connected = !1, this.index = null, this._rawPad = void 0;
  4466. for (var c = 0; c < this._buttonsLen; c++) this._buttons[c].destroy();
  4467. 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)
  4468. },
  4469. destroy: function() {
  4470. this._rawPad = void 0;
  4471. for (var a = 0; a < this._buttonsLen; a++) this._buttons[a].destroy();
  4472. 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
  4473. },
  4474. processAxisChange: function(a, b) {
  4475. 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))
  4476. },
  4477. processButtonDown: function(a, b) {
  4478. 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)
  4479. },
  4480. processButtonUp: function(a, b) {
  4481. 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)
  4482. },
  4483. processButtonFloat: function(a, b) {
  4484. 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)
  4485. },
  4486. axis: function(a) {
  4487. return this._axes[a] ? this._axes[a] : !1
  4488. },
  4489. isDown: function(a) {
  4490. return this._buttons[a] ? this._buttons[a].isDown : !1
  4491. },
  4492. isUp: function(a) {
  4493. return this._buttons[a] ? this._buttons[a].isUp : !1
  4494. },
  4495. justReleased: function(a, b) {
  4496. return this._buttons[a] ? this._buttons[a].justReleased(b) : void 0
  4497. },
  4498. justPressed: function(a, b) {
  4499. return this._buttons[a] ? this._buttons[a].justPressed(b) : void 0
  4500. },
  4501. buttonValue: function(a) {
  4502. return this._buttons[a] ? this._buttons[a].value : null
  4503. },
  4504. reset: function() {
  4505. for (var a = 0; a < this._axes.length; a++) this._axes[a] = 0
  4506. }
  4507. }, b.SinglePad.prototype.constructor = b.SinglePad, b.GamepadButton = function(a, c) {
  4508. this.pad = a, this.game = a.game, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.duration = 0, this.timeUp = 0, this.repeats = 0, this.value = 0, this.buttonCode = c, this.onDown = new b.Signal, this.onUp = new b.Signal, this.onFloat = new b.Signal
  4509. }, b.GamepadButton.prototype = {
  4510. processButtonDown: function(a) {
  4511. this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0, this.value = a, this.onDown.dispatch(this, a)
  4512. },
  4513. processButtonUp: function(a) {
  4514. this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.value = a, this.onUp.dispatch(this, a)
  4515. },
  4516. processButtonFloat: function(a) {
  4517. this.value = a, this.onFloat.dispatch(this, a)
  4518. },
  4519. justPressed: function(a) {
  4520. return a = a || 250, this.isDown === !0 && this.timeDown + a > this.game.time.now
  4521. },
  4522. justReleased: function(a) {
  4523. return a = a || 250, this.isUp === !0 && this.timeUp + a > this.game.time.now
  4524. },
  4525. reset: function() {
  4526. this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0
  4527. },
  4528. destroy: function() {
  4529. this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.pad = null, this.game = null
  4530. }
  4531. }, b.GamepadButton.prototype.constructor = b.GamepadButton, b.InputHandler = function(a) {
  4532. 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._dragPhase = !1, this._wasEnabled = !1, this._tempPoint = new b.Point, this._pointerData = [], this._pointerData.push({
  4533. id: 0,
  4534. x: 0,
  4535. y: 0,
  4536. isDown: !1,
  4537. isUp: !1,
  4538. isOver: !1,
  4539. isOut: !1,
  4540. timeOver: 0,
  4541. timeOut: 0,
  4542. timeDown: 0,
  4543. timeUp: 0,
  4544. downDuration: 0,
  4545. isDragged: !1
  4546. })
  4547. }, b.InputHandler.prototype = {
  4548. start: function(a, c) {
  4549. if (a = a || 0, "undefined" == typeof c && (c = !1), this.enabled === !1) {
  4550. this.game.input.interactiveItems.add(this), this.useHandCursor = c, this.priorityID = a;
  4551. for (var d = 0; 10 > d; d++) this._pointerData[d] = {
  4552. id: d,
  4553. x: 0,
  4554. y: 0,
  4555. isDown: !1,
  4556. isUp: !1,
  4557. isOver: !1,
  4558. isOut: !1,
  4559. timeOver: 0,
  4560. timeOut: 0,
  4561. timeDown: 0,
  4562. timeUp: 0,
  4563. downDuration: 0,
  4564. isDragged: !1
  4565. };
  4566. this.snapOffset = new b.Point, this.enabled = !0, this._wasEnabled = !0, this.sprite.events && null === this.sprite.events.onInputOver && (this.sprite.events.onInputOver = new b.Signal, this.sprite.events.onInputOut = new b.Signal, this.sprite.events.onInputDown = new b.Signal, this.sprite.events.onInputUp = new b.Signal, this.sprite.events.onDragStart = new b.Signal, this.sprite.events.onDragStop = new b.Signal)
  4567. }
  4568. return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.flagged = !1, this.sprite
  4569. },
  4570. addedToGroup: function() {
  4571. this._dragPhase || this._wasEnabled && !this.enabled && this.start()
  4572. },
  4573. removedFromGroup: function() {
  4574. this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1)
  4575. },
  4576. reset: function() {
  4577. this.enabled = !1, this.flagged = !1;
  4578. for (var a = 0; 10 > a; a++) this._pointerData[a] = {
  4579. id: a,
  4580. x: 0,
  4581. y: 0,
  4582. isDown: !1,
  4583. isUp: !1,
  4584. isOver: !1,
  4585. isOut: !1,
  4586. timeOver: 0,
  4587. timeOut: 0,
  4588. timeDown: 0,
  4589. timeUp: 0,
  4590. downDuration: 0,
  4591. isDragged: !1
  4592. }
  4593. },
  4594. stop: function() {
  4595. this.enabled !== !1 && (this.enabled = !1, this.game.input.interactiveItems.remove(this))
  4596. },
  4597. destroy: function() {
  4598. 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)
  4599. },
  4600. validForInput: function(a, b, c) {
  4601. return "undefined" == typeof c && (c = !0), 0 === this.sprite.scale.x || 0 === this.sprite.scale.y || this.priorityID < this.game.input.minPriorityID ? !1 : (c || !this.pixelPerfectClick && !this.pixelPerfectOver) && (this.priorityID > a || this.priorityID === a && this.sprite._cache[3] < b) ? !0 : !1
  4602. },
  4603. isPixelPerfect: function() {
  4604. return this.pixelPerfectClick || this.pixelPerfectOver
  4605. },
  4606. pointerX: function(a) {
  4607. return a = a || 0, this._pointerData[a].x
  4608. },
  4609. pointerY: function(a) {
  4610. return a = a || 0, this._pointerData[a].y
  4611. },
  4612. pointerDown: function(a) {
  4613. return a = a || 0, this._pointerData[a].isDown
  4614. },
  4615. pointerUp: function(a) {
  4616. return a = a || 0, this._pointerData[a].isUp
  4617. },
  4618. pointerTimeDown: function(a) {
  4619. return a = a || 0, this._pointerData[a].timeDown
  4620. },
  4621. pointerTimeUp: function(a) {
  4622. return a = a || 0, this._pointerData[a].timeUp
  4623. },
  4624. pointerOver: function(a) {
  4625. if (this.enabled) {
  4626. if ("undefined" != typeof a) return this._pointerData[a].isOver;
  4627. for (var b = 0; 10 > b; b++)
  4628. if (this._pointerData[b].isOver) return !0
  4629. }
  4630. return !1
  4631. },
  4632. pointerOut: function(a) {
  4633. if (this.enabled) {
  4634. if ("undefined" != typeof a) return this._pointerData[a].isOut;
  4635. for (var b = 0; 10 > b; b++)
  4636. if (this._pointerData[b].isOut) return !0
  4637. }
  4638. return !1
  4639. },
  4640. pointerTimeOver: function(a) {
  4641. return a = a || 0, this._pointerData[a].timeOver
  4642. },
  4643. pointerTimeOut: function(a) {
  4644. return a = a || 0, this._pointerData[a].timeOut
  4645. },
  4646. pointerDragged: function(a) {
  4647. return a = a || 0, this._pointerData[a].isDragged
  4648. },
  4649. checkPointerDown: function(a, b) {
  4650. 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
  4651. },
  4652. checkPointerOver: function(a, b) {
  4653. 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
  4654. },
  4655. checkPixel: function(a, b, c) {
  4656. if (this.sprite.texture.baseTexture.source) {
  4657. if (null === a && null === b) {
  4658. this.game.input.getLocalPosition(this.sprite, c, this._tempPoint);
  4659. var a = this._tempPoint.x,
  4660. b = this._tempPoint.y
  4661. }
  4662. 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;
  4663. 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);
  4664. var d = this.game.input.hitContext.getImageData(0, 0, 1, 1);
  4665. if (d.data[3] >= this.pixelPerfectAlpha) return !0
  4666. }
  4667. return !1
  4668. },
  4669. update: function(a) {
  4670. 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
  4671. },
  4672. _pointerOverHandler: function(a) {
  4673. 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.now, this._pointerData[a.id].x = a.x - this.sprite.x, this._pointerData[a.id].y = a.y - this.sprite.y, this.useHandCursor && this._pointerData[a.id].isDragged === !1 && (this.game.canvas.style.cursor = "pointer", this._setHandCursor = !0), this.sprite && this.sprite.events && this.sprite.events.onInputOver.dispatch(this.sprite, a))
  4674. },
  4675. _pointerOutHandler: function(a) {
  4676. null !== this.sprite && (this._pointerData[a.id].isOver = !1, this._pointerData[a.id].isOut = !0, this._pointerData[a.id].timeOut = this.game.time.now, this.useHandCursor && this._pointerData[a.id].isDragged === !1 && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), this.sprite && this.sprite.events && this.sprite.events.onInputOut.dispatch(this.sprite, a))
  4677. },
  4678. _touchedHandler: function(a) {
  4679. if (null !== this.sprite) {
  4680. if (this._pointerData[a.id].isDown === !1 && this._pointerData[a.id].isOver === !0) {
  4681. if (this.pixelPerfectClick && !this.checkPixel(null, null, a)) return;
  4682. this._pointerData[a.id].isDown = !0, this._pointerData[a.id].isUp = !1, this._pointerData[a.id].timeDown = this.game.time.now, this.sprite && this.sprite.events && this.sprite.events.onInputDown.dispatch(this.sprite, a), a.dirty = !0, this.draggable && this.isDragged === !1 && this.startDrag(a), this.bringToTop && this.sprite.bringToTop()
  4683. }
  4684. return this.consumePointerEvent
  4685. }
  4686. },
  4687. _releasedHandler: function(a) {
  4688. null !== this.sprite && this._pointerData[a.id].isDown && a.isUp && (this._pointerData[a.id].isDown = !1, this._pointerData[a.id].isUp = !0, this._pointerData[a.id].timeUp = this.game.time.now, this._pointerData[a.id].downDuration = this._pointerData[a.id].timeUp - this._pointerData[a.id].timeDown, this.checkPointerOver(a) ? this.sprite && this.sprite.events && this.sprite.events.onInputUp.dispatch(this.sprite, a, !0) : (this.sprite && this.sprite.events && this.sprite.events.onInputUp.dispatch(this.sprite, a, !1), this.useHandCursor && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1)), a.dirty = !0, this.draggable && this.isDragged && this._draggedPointerID === a.id && this.stopDrag(a))
  4689. },
  4690. updateDrag: function(a) {
  4691. if (a.isUp) return this.stopDrag(a), !1;
  4692. var b = this.globalToLocalX(a.x) + this._dragPoint.x + this.dragOffset.x,
  4693. c = this.globalToLocalY(a.y) + this._dragPoint.y + this.dragOffset.y;
  4694. 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
  4695. },
  4696. justOver: function(a, b) {
  4697. return a = a || 0, b = b || 500, this._pointerData[a].isOver && this.overDuration(a) < b
  4698. },
  4699. justOut: function(a, b) {
  4700. return a = a || 0, b = b || 500, this._pointerData[a].isOut && this.game.time.now - this._pointerData[a].timeOut < b
  4701. },
  4702. justPressed: function(a, b) {
  4703. return a = a || 0, b = b || 500, this._pointerData[a].isDown && this.downDuration(a) < b
  4704. },
  4705. justReleased: function(a, b) {
  4706. return a = a || 0, b = b || 500, this._pointerData[a].isUp && this.game.time.now - this._pointerData[a].timeUp < b
  4707. },
  4708. overDuration: function(a) {
  4709. return a = a || 0, this._pointerData[a].isOver ? this.game.time.now - this._pointerData[a].timeOver : -1
  4710. },
  4711. downDuration: function(a) {
  4712. return a = a || 0, this._pointerData[a].isDown ? this.game.time.now - this._pointerData[a].timeDown : -1
  4713. },
  4714. enableDrag: function(a, c, d, e, f, g) {
  4715. "undefined" == typeof a && (a = !1), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = null), "undefined" == typeof g && (g = null), this._dragPoint = new b.Point, this.draggable = !0, this.bringToTop = c, this.dragOffset = new b.Point, this.dragFromCenter = a, this.pixelPerfectClick = d, this.pixelPerfectAlpha = e, f && (this.boundsRect = f), g && (this.boundsSprite = g)
  4716. },
  4717. disableDrag: function() {
  4718. if (this._pointerData)
  4719. for (var a = 0; 10 > a; a++) this._pointerData[a].isDragged = !1;
  4720. this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1
  4721. },
  4722. startDrag: function(a) {
  4723. 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);
  4724. else {
  4725. if (this.dragFromCenter) {
  4726. var b = this.sprite.getBounds();
  4727. this.sprite.x = this.globalToLocalX(a.x) + (this.sprite.x - b.centerX), this.sprite.y = this.globalToLocalY(a.y) + (this.sprite.y - b.centerY)
  4728. }
  4729. this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(a.x), this.sprite.y - this.globalToLocalY(a.y))
  4730. }
  4731. this.updateDrag(a), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.sprite.events.onDragStart.dispatch(this.sprite, a)
  4732. },
  4733. globalToLocalX: function(a) {
  4734. return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.x, a *= this.game.scale.grid.scaleFluidInversed.x), a
  4735. },
  4736. globalToLocalY: function(a) {
  4737. return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.y, a *= this.game.scale.grid.scaleFluidInversed.y), a
  4738. },
  4739. stopDrag: function(a) {
  4740. 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)
  4741. },
  4742. setDragLock: function(a, b) {
  4743. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), this.allowHorizontalDrag = a, this.allowVerticalDrag = b
  4744. },
  4745. enableSnap: function(a, b, c, d, e, f) {
  4746. "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
  4747. },
  4748. disableSnap: function() {
  4749. this.snapOnDrag = !1, this.snapOnRelease = !1
  4750. },
  4751. checkBoundsRect: function() {
  4752. 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.x < this.boundsRect.left ? this.sprite.x = this.boundsRect.x : this.sprite.x + this.sprite.width > this.boundsRect.right && (this.sprite.x = this.boundsRect.right - this.sprite.width), this.sprite.y < this.boundsRect.top ? this.sprite.y = this.boundsRect.top : this.sprite.y + this.sprite.height > this.boundsRect.bottom && (this.sprite.y = this.boundsRect.bottom - this.sprite.height))
  4753. },
  4754. checkBoundsSprite: function() {
  4755. this.sprite.fixedToCamera && this.boundsSprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsSprite.camerOffset.x ? this.sprite.cameraOffset.x = this.boundsSprite.camerOffset.x : this.sprite.cameraOffset.x + this.sprite.width > this.boundsSprite.camerOffset.x + this.boundsSprite.width && (this.sprite.cameraOffset.x = this.boundsSprite.camerOffset.x + this.boundsSprite.width - this.sprite.width), this.sprite.cameraOffset.y < this.boundsSprite.camerOffset.y ? this.sprite.cameraOffset.y = this.boundsSprite.camerOffset.y : this.sprite.cameraOffset.y + this.sprite.height > this.boundsSprite.camerOffset.y + this.boundsSprite.height && (this.sprite.cameraOffset.y = this.boundsSprite.camerOffset.y + this.boundsSprite.height - this.sprite.height)) : (this.sprite.x < this.boundsSprite.x ? this.sprite.x = this.boundsSprite.x : this.sprite.x + this.sprite.width > this.boundsSprite.x + this.boundsSprite.width && (this.sprite.x = this.boundsSprite.x + this.boundsSprite.width - this.sprite.width), this.sprite.y < this.boundsSprite.y ? this.sprite.y = this.boundsSprite.y : this.sprite.y + this.sprite.height > this.boundsSprite.y + this.boundsSprite.height && (this.sprite.y = this.boundsSprite.y + this.boundsSprite.height - this.sprite.height))
  4756. }
  4757. }, b.InputHandler.prototype.constructor = b.InputHandler, b.Events = function(a) {
  4758. this.parent = a, this.onAddedToGroup = new b.Signal, this.onRemovedFromGroup = new b.Signal, this.onDestroy = new b.Signal, this.onKilled = new b.Signal, this.onRevived = new b.Signal, this.onOutOfBounds = new b.Signal, this.onEnterBounds = new b.Signal, this.onInputOver = null, this.onInputOut = null, this.onInputDown = null, this.onInputUp = null, this.onDragStart = null, this.onDragStop = null, this.onAnimationStart = null, this.onAnimationComplete = null, this.onAnimationLoop = null
  4759. }, b.Events.prototype = {
  4760. destroy: function() {
  4761. this.parent = null, this.onDestroy.dispose(), this.onAddedToGroup.dispose(), this.onRemovedFromGroup.dispose(), this.onKilled.dispose(), this.onRevived.dispose(), this.onOutOfBounds.dispose(), this.onInputOver && (this.onInputOver.dispose(), this.onInputOut.dispose(), this.onInputDown.dispose(), this.onInputUp.dispose(), this.onDragStart.dispose(), this.onDragStop.dispose()), this.onAnimationStart && (this.onAnimationStart.dispose(), this.onAnimationComplete.dispose(), this.onAnimationLoop.dispose())
  4762. }
  4763. }, b.Events.prototype.constructor = b.Events, b.GameObjectFactory = function(a) {
  4764. this.game = a, this.world = this.game.world
  4765. }, b.GameObjectFactory.prototype = {
  4766. existing: function(a) {
  4767. return this.world.add(a)
  4768. },
  4769. image: function(a, c, d, e, f) {
  4770. return "undefined" == typeof f && (f = this.world), f.add(new b.Image(this.game, a, c, d, e))
  4771. },
  4772. sprite: function(a, b, c, d, e) {
  4773. return "undefined" == typeof e && (e = this.world), e.create(a, b, c, d)
  4774. },
  4775. tween: function(a) {
  4776. return this.game.tweens.create(a)
  4777. },
  4778. group: function(a, c, d, e, f) {
  4779. return new b.Group(this.game, a, c, d, e, f)
  4780. },
  4781. physicsGroup: function(a, c, d, e) {
  4782. return new b.Group(this.game, c, d, e, !0, a)
  4783. },
  4784. spriteBatch: function(a, c, d) {
  4785. return "undefined" == typeof a && (a = null), "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  4786. },
  4787. audio: function(a, b, c, d) {
  4788. return this.game.sound.add(a, b, c, d)
  4789. },
  4790. sound: function(a, b, c, d) {
  4791. return this.game.sound.add(a, b, c, d)
  4792. },
  4793. audioSprite: function(a) {
  4794. return this.game.sound.addSprite(a)
  4795. },
  4796. tileSprite: function(a, c, d, e, f, g, h) {
  4797. return "undefined" == typeof h && (h = this.world), h.add(new b.TileSprite(this.game, a, c, d, e, f, g))
  4798. },
  4799. rope: function(a, c, d, e, f, g) {
  4800. return "undefined" == typeof g && (g = this.world), g.add(new b.Rope(this.game, a, c, d, e, f))
  4801. },
  4802. text: function(a, c, d, e, f) {
  4803. return "undefined" == typeof f && (f = this.world), f.add(new b.Text(this.game, a, c, d, e))
  4804. },
  4805. button: function(a, c, d, e, f, g, h, i, j, k) {
  4806. return "undefined" == typeof k && (k = this.world), k.add(new b.Button(this.game, a, c, d, e, f, g, h, i, j))
  4807. },
  4808. graphics: function(a, c, d) {
  4809. return "undefined" == typeof d && (d = this.world), d.add(new b.Graphics(this.game, a, c))
  4810. },
  4811. emitter: function(a, c, d) {
  4812. return this.game.particles.add(new b.Particles.Arcade.Emitter(this.game, a, c, d))
  4813. },
  4814. retroFont: function(a, c, d, e, f, g, h, i, j) {
  4815. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  4816. },
  4817. bitmapText: function(a, c, d, e, f, g) {
  4818. return "undefined" == typeof g && (g = this.world), g.add(new b.BitmapText(this.game, a, c, d, e, f))
  4819. },
  4820. tilemap: function(a, c, d, e, f) {
  4821. return new b.Tilemap(this.game, a, c, d, e, f)
  4822. },
  4823. renderTexture: function(a, c, d, e) {
  4824. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  4825. var f = new b.RenderTexture(this.game, a, c, d);
  4826. return e && this.game.cache.addRenderTexture(d, f), f
  4827. },
  4828. bitmapData: function(a, c, d, e) {
  4829. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  4830. var f = new b.BitmapData(this.game, d, a, c);
  4831. return e && this.game.cache.addBitmapData(d, f), f
  4832. },
  4833. filter: function(a) {
  4834. var c = Array.prototype.splice.call(arguments, 1),
  4835. a = new b.Filter[a](this.game);
  4836. return a.init.apply(a, c), a
  4837. },
  4838. plugin: function(a) {
  4839. return this.game.plugins.add(a)
  4840. }
  4841. }, b.GameObjectFactory.prototype.constructor = b.GameObjectFactory, b.GameObjectCreator = function(a) {
  4842. this.game = a, this.world = this.game.world
  4843. }, b.GameObjectCreator.prototype = {
  4844. image: function(a, c, d, e) {
  4845. return new b.Image(this.game, a, c, d, e)
  4846. },
  4847. sprite: function(a, c, d, e) {
  4848. return new b.Sprite(this.game, a, c, d, e)
  4849. },
  4850. tween: function(a) {
  4851. return new b.Tween(a, this.game)
  4852. },
  4853. group: function(a, c, d, e, f) {
  4854. return new b.Group(this.game, null, c, d, e, f)
  4855. },
  4856. spriteBatch: function(a, c, d) {
  4857. return "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  4858. },
  4859. audio: function(a, b, c, d) {
  4860. return this.game.sound.add(a, b, c, d)
  4861. },
  4862. audioSprite: function(a) {
  4863. return this.game.sound.addSprite(a)
  4864. },
  4865. sound: function(a, b, c, d) {
  4866. return this.game.sound.add(a, b, c, d)
  4867. },
  4868. tileSprite: function(a, c, d, e, f, g) {
  4869. return new b.TileSprite(this.game, a, c, d, e, f, g)
  4870. },
  4871. rope: function(a, c, d, e, f) {
  4872. return new b.Rope(this.game, a, c, d, e, f)
  4873. },
  4874. text: function(a, c, d, e) {
  4875. return new b.Text(this.game, a, c, d, e)
  4876. },
  4877. button: function(a, c, d, e, f, g, h, i, j) {
  4878. return new b.Button(this.game, a, c, d, e, f, g, h, i, j)
  4879. },
  4880. graphics: function(a, c) {
  4881. return new b.Graphics(this.game, a, c)
  4882. },
  4883. emitter: function(a, c, d) {
  4884. return new b.Particles.Arcade.Emitter(this.game, a, c, d)
  4885. },
  4886. retroFont: function(a, c, d, e, f, g, h, i, j) {
  4887. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  4888. },
  4889. bitmapText: function(a, c, d, e, f) {
  4890. return new b.BitmapText(this.game, a, c, d, e, f)
  4891. },
  4892. tilemap: function(a, c, d, e, f) {
  4893. return new b.Tilemap(this.game, a, c, d, e, f)
  4894. },
  4895. renderTexture: function(a, c, d, e) {
  4896. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  4897. var f = new b.RenderTexture(this.game, a, c, d);
  4898. return e && this.game.cache.addRenderTexture(d, f), f
  4899. },
  4900. bitmapData: function(a, c, d, e) {
  4901. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  4902. var f = new b.BitmapData(this.game, d, a, c);
  4903. return e && this.game.cache.addBitmapData(d, f), f
  4904. },
  4905. filter: function(a) {
  4906. var c = Array.prototype.splice.call(arguments, 1),
  4907. a = new b.Filter[a](this.game);
  4908. return a.init.apply(a, c), a
  4909. }
  4910. }, b.GameObjectCreator.prototype.constructor = b.GameObjectCreator, b.BitmapData = function(a, c, d, e) {
  4911. "undefined" == typeof d && (d = 256), "undefined" == typeof e && (e = 256), this.game = a, this.key = c, this.width = d, this.height = e, this.canvas = b.Canvas.create(d, e, "", !0), this.context = this.canvas.getContext("2d"), this.ctx = this.context, this.imageData = this.context.getImageData(0, 0, d, e), this.data = this.imageData.data, this.pixels = null, this.imageData.data.buffer ? (this.buffer = this.imageData.data.buffer, this.pixels = new Uint32Array(this.buffer)) : window.ArrayBuffer ? (this.buffer = new ArrayBuffer(this.imageData.data.length), this.pixels = new Uint32Array(this.buffer)) : this.pixels = this.imageData.data, this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new b.Frame(0, 0, 0, d, e, "bitmapData", a.rnd.uuid()), this.texture.frame = this.textureFrame, this.type = b.BITMAPDATA, this.disableTextureUpload = !1, this.dirty = !1, this.cls = this.clear, this._image = null, this._pos = new b.Point, this._size = new b.Point, this._scale = new b.Point, this._rotate = 0, this._alpha = {
  4912. prev: 1,
  4913. current: 1
  4914. }, this._anchor = new b.Point, this._tempR = 0, this._tempG = 0, this._tempB = 0, this._circle = new b.Circle
  4915. }, b.BitmapData.prototype = {
  4916. add: function(a) {
  4917. if (Array.isArray(a))
  4918. for (var b = 0; b < a.length; b++) a[b].loadTexture && a[b].loadTexture(this);
  4919. else a.loadTexture(this);
  4920. return this
  4921. },
  4922. load: function(a) {
  4923. 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
  4924. },
  4925. clear: function() {
  4926. return this.context.clearRect(0, 0, this.width, this.height), this.dirty = !0, this
  4927. },
  4928. fill: function(a, b, c, d) {
  4929. 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
  4930. },
  4931. resize: function(a, b) {
  4932. 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
  4933. },
  4934. update: function(a, b, c, d) {
  4935. 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
  4936. },
  4937. processPixelRGB: function(a, c, d, e, f, g) {
  4938. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = this.width), "undefined" == typeof g && (g = this.height);
  4939. for (var h = d + f, i = e + g, j = b.Color.createColor(), k = {
  4940. r: 0,
  4941. g: 0,
  4942. b: 0,
  4943. a: 0
  4944. }, l = !1, m = e; i > m; m++)
  4945. for (var n = d; h > n; n++) b.Color.unpackPixel(this.getPixel32(n, m), j), k = a.call(c, j, n, m), k !== !1 && null !== k && void 0 !== k && (this.setPixel32(n, m, k.r, k.g, k.b, k.a, !1), l = !0);
  4946. return l && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
  4947. },
  4948. processPixel: function(a, b, c, d, e, f) {
  4949. "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = this.width), "undefined" == typeof f && (f = this.height);
  4950. for (var g = c + e, h = d + f, i = 0, j = 0, k = !1, l = d; h > l; l++)
  4951. 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);
  4952. return k && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
  4953. },
  4954. replaceRGB: function(a, c, d, e, f, g, h, i, j) {
  4955. var k = 0,
  4956. l = 0,
  4957. m = this.width,
  4958. n = this.height,
  4959. o = b.Color.packPixel(a, c, d, e);
  4960. void 0 !== j && j instanceof b.Rectangle && (k = j.x, l = j.y, m = j.width, n = j.height);
  4961. for (var p = 0; n > p; p++)
  4962. 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);
  4963. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  4964. },
  4965. setHSL: function(a, c, d, e) {
  4966. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof c || null === c) && (c = !1), ("undefined" == typeof d || null === d) && (d = !1), a || c || d) {
  4967. "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
  4968. for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  4969. for (var h = e.x; h < e.right; h++) b.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = a), c && (f.s = c), d && (f.l = d), b.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  4970. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  4971. }
  4972. },
  4973. shiftHSL: function(a, c, d, e) {
  4974. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof c || null === c) && (c = !1), ("undefined" == typeof d || null === d) && (d = !1), a || c || d) {
  4975. "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
  4976. for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  4977. for (var h = e.x; h < e.right; h++) b.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = this.game.math.wrap(f.h + a, 0, 1)), c && (f.s = this.game.math.limitValue(f.s + c, 0, 1)), d && (f.l = this.game.math.limitValue(f.l + d, 0, 1)), b.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  4978. return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
  4979. }
  4980. },
  4981. setPixel32: function(a, c, d, e, f, g, h) {
  4982. return "undefined" == typeof h && (h = !0), a >= 0 && a <= this.width && c >= 0 && c <= this.height && (this.pixels[c * this.width + a] = b.Device.LITTLE_ENDIAN ? g << 24 | f << 16 | e << 8 | d : d << 24 | e << 16 | f << 8 | g, h && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)), this
  4983. },
  4984. setPixel: function(a, b, c, d, e, f) {
  4985. return this.setPixel32(a, b, c, d, e, 255, f)
  4986. },
  4987. getPixel: function(a, c, d) {
  4988. d || (d = b.Color.createColor());
  4989. var e = ~~(a + c * this.width);
  4990. return e *= 4, d.r = this.data[e], d.g = this.data[++e], d.b = this.data[++e], d.a = this.data[++e], d
  4991. },
  4992. getPixel32: function(a, b) {
  4993. return a >= 0 && a <= this.width && b >= 0 && b <= this.height ? this.pixels[b * this.width + a] : void 0
  4994. },
  4995. getPixelRGB: function(a, c, d, e, f) {
  4996. return b.Color.unpackPixel(this.getPixel32(a, c), d, e, f)
  4997. },
  4998. getPixels: function(a) {
  4999. return this.context.getImageData(a.x, a.y, a.width, a.height)
  5000. },
  5001. getFirstPixel: function(a) {
  5002. "undefined" == typeof a && (a = 0);
  5003. var c = b.Color.createColor(),
  5004. d = 0,
  5005. e = 0,
  5006. f = 1,
  5007. g = !1;
  5008. 1 === a ? (f = -1, e = this.height) : 3 === a && (f = -1, d = this.width);
  5009. do b.Color.unpackPixel(this.getPixel32(d, e), c), 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 === c.a && !g);
  5010. return c.x = d, c.y = e, c
  5011. },
  5012. getBounds: function(a) {
  5013. return "undefined" == typeof a && (a = new b.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)
  5014. },
  5015. addToWorld: function(a, b, c, d, e, f) {
  5016. e = e || 1, f = f || 1;
  5017. var g = this.game.add.image(a, b, this);
  5018. return g.anchor.set(c, d), g.scale.set(e, f), g
  5019. },
  5020. copy: function(a, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) {
  5021. if (("undefined" == typeof a || null === a) && (a = this), this._image = a, a instanceof b.Sprite || a instanceof b.Image || a instanceof b.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, 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);
  5022. else {
  5023. if (this._pos.set(0), this._scale.set(1), this._anchor.set(0), this._rotate = 0, this._alpha.current = 1, a instanceof b.BitmapData) this._image = a.canvas;
  5024. else if ("string" == typeof a) {
  5025. if (a = this.game.cache.getImage(a), null === a) return;
  5026. this._image = a
  5027. }
  5028. this._size.set(this._image.width, this._image.height)
  5029. }
  5030. return ("undefined" == typeof c || null === c) && (c = 0), ("undefined" == typeof d || null === d) && (d = 0), e && (this._size.x = e), f && (this._size.y = f), ("undefined" == typeof g || null === g) && (g = c), ("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 + c, 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)
  5031. },
  5032. copyRect: function(a, b, c, d, e, f, g) {
  5033. 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)
  5034. },
  5035. draw: function(a, b, c, d, e, f, g) {
  5036. return this.copy(a, null, null, null, null, b, c, d, e, null, null, null, null, null, null, f, g)
  5037. },
  5038. shadow: function(a, b, c, d) {
  5039. "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)
  5040. },
  5041. alphaMask: function(a, b, c, d) {
  5042. 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
  5043. },
  5044. extract: function(a, b, c, d, e, f, g, h, i) {
  5045. 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) {
  5046. return f.r === b && f.g === c && f.b === d && a.setPixel32(j, k, g, h, i, e, !1), !1
  5047. }, this), a.context.putImageData(a.imageData, 0, 0), a.dirty = !0, a
  5048. },
  5049. rect: function(a, b, c, d, e) {
  5050. return "undefined" != typeof e && (this.context.fillStyle = e), this.context.fillRect(a, b, c, d), this
  5051. },
  5052. circle: function(a, b, c, d) {
  5053. 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
  5054. },
  5055. textureLine: function(a, c, d) {
  5056. if ("undefined" == typeof d && (d = "repeat-x"), "string" != typeof c || (c = this.game.cache.getImage(c))) {
  5057. var e = a.length;
  5058. return "no-repeat" === d && e > c.width && (e = c.width), this.context.fillStyle = this.context.createPattern(c, d), this._circle = new b.Circle(a.start.x, a.start.y, c.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, c.height), this.context.restore(), this.dirty = !0, this
  5059. }
  5060. },
  5061. render: function() {
  5062. return !this.disableTextureUpload && this.dirty && (this.baseTexture.dirty(), this.dirty = !1), this
  5063. },
  5064. blendReset: function() {
  5065. return this.context.globalCompositeOperation = "source-over", this
  5066. },
  5067. blendSourceOver: function() {
  5068. return this.context.globalCompositeOperation = "source-over", this
  5069. },
  5070. blendSourceIn: function() {
  5071. return this.context.globalCompositeOperation = "source-in", this
  5072. },
  5073. blendSourceOut: function() {
  5074. return this.context.globalCompositeOperation = "source-out", this
  5075. },
  5076. blendSourceAtop: function() {
  5077. return this.context.globalCompositeOperation = "source-atop", this
  5078. },
  5079. blendDestinationOver: function() {
  5080. return this.context.globalCompositeOperation = "destination-over", this
  5081. },
  5082. blendDestinationIn: function() {
  5083. return this.context.globalCompositeOperation = "destination-in", this
  5084. },
  5085. blendDestinationOut: function() {
  5086. return this.context.globalCompositeOperation = "destination-out", this
  5087. },
  5088. blendDestinationAtop: function() {
  5089. return this.context.globalCompositeOperation = "destination-atop", this
  5090. },
  5091. blendXor: function() {
  5092. return this.context.globalCompositeOperation = "xor", this
  5093. },
  5094. blendAdd: function() {
  5095. return this.context.globalCompositeOperation = "lighter", this
  5096. },
  5097. blendMultiply: function() {
  5098. return this.context.globalCompositeOperation = "multiply", this
  5099. },
  5100. blendScreen: function() {
  5101. return this.context.globalCompositeOperation = "screen", this
  5102. },
  5103. blendOverlay: function() {
  5104. return this.context.globalCompositeOperation = "overlay", this
  5105. },
  5106. blendDarken: function() {
  5107. return this.context.globalCompositeOperation = "darken", this
  5108. },
  5109. blendLighten: function() {
  5110. return this.context.globalCompositeOperation = "lighten", this
  5111. },
  5112. blendColorDodge: function() {
  5113. return this.context.globalCompositeOperation = "color-dodge", this
  5114. },
  5115. blendColorBurn: function() {
  5116. return this.context.globalCompositeOperation = "color-burn", this
  5117. },
  5118. blendHardLight: function() {
  5119. return this.context.globalCompositeOperation = "hard-light", this
  5120. },
  5121. blendSoftLight: function() {
  5122. return this.context.globalCompositeOperation = "soft-light", this
  5123. },
  5124. blendDifference: function() {
  5125. return this.context.globalCompositeOperation = "difference", this
  5126. },
  5127. blendExclusion: function() {
  5128. return this.context.globalCompositeOperation = "exclusion", this
  5129. },
  5130. blendHue: function() {
  5131. return this.context.globalCompositeOperation = "hue", this
  5132. },
  5133. blendSaturation: function() {
  5134. return this.context.globalCompositeOperation = "saturation", this
  5135. },
  5136. blendColor: function() {
  5137. return this.context.globalCompositeOperation = "color", this
  5138. },
  5139. blendLuminosity: function() {
  5140. return this.context.globalCompositeOperation = "luminosity", this
  5141. }
  5142. }, Object.defineProperty(b.BitmapData.prototype, "smoothed", {
  5143. get: function() {
  5144. b.Canvas.getSmoothingEnabled(this.context)
  5145. },
  5146. set: function(a) {
  5147. b.Canvas.setSmoothingEnabled(this.context, a)
  5148. }
  5149. }), b.BitmapData.getTransform = function(a, b, c, d, e, f) {
  5150. 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), {
  5151. sx: c,
  5152. sy: d,
  5153. scaleX: c,
  5154. scaleY: d,
  5155. skewX: e,
  5156. skewY: f,
  5157. translateX: a,
  5158. translateY: b,
  5159. tx: a,
  5160. ty: b
  5161. }
  5162. }, b.BitmapData.prototype.constructor = b.BitmapData, b.Sprite = function(a, c, d, e, f) {
  5163. c = c || 0, d = d || 0, e = e || null, f = f || null, this.game = a, this.name = "", this.type = b.SPRITE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = e, PIXI.Sprite.call(this, PIXI.TextureCache.__default), this.position.set(c, d), this.world = new b.Point(c, d), this.autoCull = !1, this.input = null, this.body = null, this.alive = !0, this.health = 1, this.lifespan = 0, this.checkWorldBounds = !1, this.outOfBoundsKill = !1, this.debug = !1, this.cameraOffset = new b.Point, this.cropRect = null, this._cache = [0, 0, 0, 0, 1, 0, 1, 0], this._crop = null, this._frame = null, this._bounds = new b.Rectangle, this.loadTexture(e, f)
  5164. }, b.Sprite.prototype = Object.create(PIXI.Sprite.prototype), b.Sprite.prototype.constructor = b.Sprite, b.Sprite.prototype.preUpdate = function() {
  5165. if (1 === this._cache[4] && this.exists) return this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.body && this.body.preUpdate(), this._cache[4] = 0, !1;
  5166. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  5167. if (this.lifespan > 0 && (this.lifespan -= this.game.time.elapsed, this.lifespan <= 0)) return this.kill(), !1;
  5168. if ((this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds)
  5169. if (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds)) this._cache[5] = 0, this.events.onEnterBounds.dispatch(this);
  5170. else if (0 === this._cache[5] && !this.game.world.bounds.intersects(this._bounds) && (this._cache[5] = 1, this.events.onOutOfBounds.dispatch(this), this.outOfBoundsKill)) return this.kill(), !1;
  5171. this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), this.animations.update(), this.body && this.body.preUpdate();
  5172. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5173. return !0
  5174. }, b.Sprite.prototype.update = function() {}, b.Sprite.prototype.postUpdate = function() {
  5175. this.key instanceof b.BitmapData && this.key.render(), this.exists && this.body && this.body.postUpdate(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  5176. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  5177. }, b.Sprite.prototype.loadTexture = function(a, c, d) {
  5178. c = c || 0, (d || "undefined" == typeof d) && this.animations.stop(), this.key = a;
  5179. var e = !0,
  5180. f = this.smoothed;
  5181. a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? (this.setTexture(a.texture), this.game.cache.getFrameData(a.key, b.Cache.BITMAPDATA) && (e = !this.animations.loadFrameData(this.game.cache.getFrameData(a.key, b.Cache.BITMAPDATA), c))) : a instanceof PIXI.Texture ? this.setTexture(a) : null === a || "undefined" == typeof a ? (this.key = "__default", this.setTexture(PIXI.TextureCache[this.key])) : "string" != typeof a || this.game.cache.checkImageKey(a) ? (this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])), e = !this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key])), this.texture.baseTexture.dirty(), e && (this._frame = b.Rectangle.clone(this.texture.frame)), f || (this.smoothed = !1)
  5182. }, b.Sprite.prototype.setFrame = function(a) {
  5183. 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 = {
  5184. x: a.spriteSourceSizeX,
  5185. y: a.spriteSourceSizeY,
  5186. width: a.sourceSizeW,
  5187. height: a.sourceSizeH
  5188. }, 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(), this.texture._updateUvs()
  5189. }, b.Sprite.prototype.resetFrame = function() {
  5190. this._frame && this.setFrame(this._frame)
  5191. }, b.Sprite.prototype.crop = function(a, c) {
  5192. "undefined" == typeof c && (c = !1), a ? (c && null !== this.cropRect ? this.cropRect.setTo(a.x, a.y, a.width, a.height) : this.cropRect = c && null === this.cropRect ? new b.Rectangle(a.x, a.y, a.width, a.height) : a, this.updateCrop()) : (this._crop = null, this.cropRect = null, this.resetFrame())
  5193. }, b.Sprite.prototype.updateCrop = function() {
  5194. if (this.cropRect) {
  5195. this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
  5196. var a = Math.max(this._frame.x, this._crop.x),
  5197. c = Math.max(this._frame.y, this._crop.y),
  5198. d = Math.min(this._frame.right, this._crop.right) - a,
  5199. e = Math.min(this._frame.bottom, this._crop.bottom) - c;
  5200. this.texture.crop.x = a, this.texture.crop.y = c, this.texture.crop.width = d, this.texture.crop.height = e, this.texture.frame.width = Math.min(d, this.cropRect.width), this.texture.frame.height = Math.min(e, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.texture._updateUvs()
  5201. }
  5202. }, b.Sprite.prototype.revive = function(a) {
  5203. return "undefined" == typeof a && (a = 1), this.alive = !0, this.exists = !0, this.visible = !0, this.health = a, this.events && this.events.onRevived.dispatch(this), this
  5204. }, b.Sprite.prototype.kill = function() {
  5205. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  5206. }, b.Sprite.prototype.destroy = function(a) {
  5207. if (null !== this.game && 1 !== this._cache[8]) {
  5208. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.events && this.events.onDestroy.dispatch(this), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.input && this.input.destroy(), this.animations && this.animations.destroy(), this.body && this.body.destroy(), this.events && this.events.destroy();
  5209. var c = this.children.length;
  5210. if (a)
  5211. for (; c--;) this.children[c].destroy(a);
  5212. else
  5213. for (; c--;) this.removeChild(this.children[c]);
  5214. this._crop && (this._crop = null), this._frame && (this._frame = null), this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5215. }
  5216. }, b.Sprite.prototype.damage = function(a) {
  5217. return this.alive && (this.health -= a, this.health <= 0 && this.kill()), this
  5218. }, b.Sprite.prototype.reset = function(a, b, c) {
  5219. return "undefined" == typeof c && (c = 1), this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.health = c, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this
  5220. }, b.Sprite.prototype.bringToTop = function() {
  5221. return this.parent && this.parent.bringToTop(this), this
  5222. }, b.Sprite.prototype.play = function(a, b, c, d) {
  5223. return this.animations ? this.animations.play(a, b, c, d) : void 0
  5224. }, b.Sprite.prototype.overlap = function(a) {
  5225. return b.Rectangle.intersects(this.getBounds(), a.getBounds())
  5226. }, Object.defineProperty(b.Sprite.prototype, "angle", {
  5227. get: function() {
  5228. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  5229. },
  5230. set: function(a) {
  5231. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  5232. }
  5233. }), Object.defineProperty(b.Sprite.prototype, "deltaX", {
  5234. get: function() {
  5235. return this.world.x - this._cache[0]
  5236. }
  5237. }), Object.defineProperty(b.Sprite.prototype, "deltaY", {
  5238. get: function() {
  5239. return this.world.y - this._cache[1]
  5240. }
  5241. }), Object.defineProperty(b.Sprite.prototype, "deltaZ", {
  5242. get: function() {
  5243. return this.rotation - this._cache[2]
  5244. }
  5245. }), Object.defineProperty(b.Sprite.prototype, "inWorld", {
  5246. get: function() {
  5247. return this.game.world.bounds.intersects(this.getBounds())
  5248. }
  5249. }), Object.defineProperty(b.Sprite.prototype, "inCamera", {
  5250. get: function() {
  5251. return this.game.world.camera.screenView.intersects(this.getBounds())
  5252. }
  5253. }), Object.defineProperty(b.Sprite.prototype, "frame", {
  5254. get: function() {
  5255. return this.animations.frame
  5256. },
  5257. set: function(a) {
  5258. this.animations.frame = a
  5259. }
  5260. }), Object.defineProperty(b.Sprite.prototype, "frameName", {
  5261. get: function() {
  5262. return this.animations.frameName
  5263. },
  5264. set: function(a) {
  5265. this.animations.frameName = a
  5266. }
  5267. }), Object.defineProperty(b.Sprite.prototype, "renderOrderID", {
  5268. get: function() {
  5269. return this._cache[3]
  5270. }
  5271. }), Object.defineProperty(b.Sprite.prototype, "inputEnabled", {
  5272. get: function() {
  5273. return this.input && this.input.enabled
  5274. },
  5275. set: function(a) {
  5276. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5277. }
  5278. }), Object.defineProperty(b.Sprite.prototype, "exists", {
  5279. get: function() {
  5280. return !!this._cache[6]
  5281. },
  5282. set: function(a) {
  5283. a ? (this._cache[6] = 1, this.body && this.body.type === b.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._cache[6] = 0, this.body && this.body.type === b.Physics.P2JS && this.body.removeFromWorld(), this.visible = !1)
  5284. }
  5285. }), Object.defineProperty(b.Sprite.prototype, "fixedToCamera", {
  5286. get: function() {
  5287. return !!this._cache[7]
  5288. },
  5289. set: function(a) {
  5290. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5291. }
  5292. }), Object.defineProperty(b.Sprite.prototype, "smoothed", {
  5293. get: function() {
  5294. return !this.texture.baseTexture.scaleMode
  5295. },
  5296. set: function(a) {
  5297. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  5298. }
  5299. }), Object.defineProperty(b.Sprite.prototype, "x", {
  5300. get: function() {
  5301. return this.position.x
  5302. },
  5303. set: function(a) {
  5304. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5305. }
  5306. }), Object.defineProperty(b.Sprite.prototype, "y", {
  5307. get: function() {
  5308. return this.position.y
  5309. },
  5310. set: function(a) {
  5311. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5312. }
  5313. }), Object.defineProperty(b.Sprite.prototype, "destroyPhase", {
  5314. get: function() {
  5315. return !!this._cache[8]
  5316. }
  5317. }), b.Image = function(a, c, d, e, f) {
  5318. c = c || 0, d = d || 0, e = e || null, f = f || null, this.game = a, this.exists = !0, this.name = "", this.type = b.IMAGE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = e, PIXI.Sprite.call(this, PIXI.TextureCache.__default), this.position.set(c, d), this.world = new b.Point(c, d), this.alive = !0, this.autoCull = !1, this.input = null, this.debug = !1, this.cameraOffset = new b.Point, this.cropRect = null, this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0], this._crop = null, this._frame = null, this._bounds = new b.Rectangle, this.loadTexture(e, f)
  5319. }, b.Image.prototype = Object.create(PIXI.Sprite.prototype), b.Image.prototype.constructor = b.Image, b.Image.prototype.preUpdate = function() {
  5320. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  5321. this.autoCull && (this._bounds.copyFrom(this.getBounds()), this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++);
  5322. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5323. return !0
  5324. }, b.Image.prototype.update = function() {}, b.Image.prototype.postUpdate = function() {
  5325. this.key instanceof b.BitmapData && this.key.render(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  5326. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  5327. }, b.Image.prototype.loadTexture = function(a, c) {
  5328. c = c || 0, this.key = a;
  5329. var d = !0,
  5330. e = this.smoothed;
  5331. a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? (this.setTexture(a.texture), this.game.cache.getFrameData(a.key, b.Cache.BITMAPDATA) && (d = !this.animations.loadFrameData(this.game.cache.getFrameData(a.key, b.Cache.BITMAPDATA), c))) : 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])), d = !this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key])), this.texture.baseTexture.dirty(), d && (this._frame = b.Rectangle.clone(this.texture.frame)), e || (this.smoothed = !1)
  5332. }, b.Image.prototype.setFrame = function(a) {
  5333. 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 = {
  5334. x: a.spriteSourceSizeX,
  5335. y: a.spriteSourceSizeY,
  5336. width: a.sourceSizeW,
  5337. height: a.sourceSizeH
  5338. }, 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(), this.texture._updateUvs()
  5339. }, b.Image.prototype.resetFrame = function() {
  5340. this._frame && this.setFrame(this._frame)
  5341. }, b.Image.prototype.crop = function(a, c) {
  5342. "undefined" == typeof c && (c = !1), a ? (c && null !== this.cropRect ? this.cropRect.setTo(a.x, a.y, a.width, a.height) : this.cropRect = c && null === this.cropRect ? new b.Rectangle(a.x, a.y, a.width, a.height) : a, this.updateCrop()) : (this._crop = null, this.cropRect = null, this.resetFrame())
  5343. }, b.Image.prototype.updateCrop = function() {
  5344. if (this.cropRect) {
  5345. this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
  5346. var a = Math.max(this._frame.x, this._crop.x),
  5347. c = Math.max(this._frame.y, this._crop.y),
  5348. d = Math.min(this._frame.right, this._crop.right) - a,
  5349. e = Math.min(this._frame.bottom, this._crop.bottom) - c;
  5350. this.texture.crop.x = a, this.texture.crop.y = c, this.texture.crop.width = d, this.texture.crop.height = e, this.texture.frame.width = Math.min(d, this.cropRect.width), this.texture.frame.height = Math.min(e, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.texture._updateUvs()
  5351. }
  5352. }, b.Image.prototype.revive = function() {
  5353. return this.alive = !0, this.exists = !0, this.visible = !0, this.events && this.events.onRevived.dispatch(this), this
  5354. }, b.Image.prototype.kill = function() {
  5355. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  5356. }, b.Image.prototype.destroy = function(a) {
  5357. if (null !== this.game && !this.destroyPhase) {
  5358. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.events && this.events.onDestroy.dispatch(this), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.events && this.events.destroy(), this.input && this.input.destroy(), this.animations && this.animations.destroy();
  5359. var c = this.children.length;
  5360. if (a)
  5361. for (; c--;) this.children[c].destroy(a);
  5362. else
  5363. for (; c--;) this.removeChild(this.children[c]);
  5364. this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5365. }
  5366. }, b.Image.prototype.reset = function(a, b) {
  5367. return this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this
  5368. }, b.Image.prototype.bringToTop = function() {
  5369. return this.parent && this.parent.bringToTop(this), this
  5370. }, Object.defineProperty(b.Image.prototype, "angle", {
  5371. get: function() {
  5372. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  5373. },
  5374. set: function(a) {
  5375. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  5376. }
  5377. }), Object.defineProperty(b.Image.prototype, "deltaX", {
  5378. get: function() {
  5379. return this.world.x - this._cache[0]
  5380. }
  5381. }), Object.defineProperty(b.Image.prototype, "deltaY", {
  5382. get: function() {
  5383. return this.world.y - this._cache[1]
  5384. }
  5385. }), Object.defineProperty(b.Image.prototype, "deltaZ", {
  5386. get: function() {
  5387. return this.rotation - this._cache[2]
  5388. }
  5389. }), Object.defineProperty(b.Image.prototype, "inWorld", {
  5390. get: function() {
  5391. return this.game.world.bounds.intersects(this.getBounds())
  5392. }
  5393. }), Object.defineProperty(b.Image.prototype, "inCamera", {
  5394. get: function() {
  5395. return this.game.world.camera.screenView.intersects(this.getBounds())
  5396. }
  5397. }), Object.defineProperty(b.Image.prototype, "frame", {
  5398. get: function() {
  5399. return this._frame
  5400. },
  5401. set: function(a) {
  5402. if (a !== this.frame) {
  5403. var b = this.game.cache.getFrameData(this.key);
  5404. b && a < b.total && b.getFrame(a) && (this.setTexture(PIXI.TextureCache[b.getFrame(a).uuid]), this._frame = a)
  5405. }
  5406. }
  5407. }), Object.defineProperty(b.Image.prototype, "frameName", {
  5408. get: function() {
  5409. return this._frameName
  5410. },
  5411. set: function(a) {
  5412. if (a !== this.frameName) {
  5413. var b = this.game.cache.getFrameData(this.key);
  5414. b && b.getFrameByName(a) && (this.setTexture(PIXI.TextureCache[b.getFrameByName(a).uuid]), this._frameName = a)
  5415. }
  5416. }
  5417. }), Object.defineProperty(b.Image.prototype, "renderOrderID", {
  5418. get: function() {
  5419. return this._cache[3]
  5420. }
  5421. }), Object.defineProperty(b.Image.prototype, "inputEnabled", {
  5422. get: function() {
  5423. return this.input && this.input.enabled
  5424. },
  5425. set: function(a) {
  5426. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5427. }
  5428. }), Object.defineProperty(b.Image.prototype, "fixedToCamera", {
  5429. get: function() {
  5430. return !!this._cache[7]
  5431. },
  5432. set: function(a) {
  5433. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5434. }
  5435. }), Object.defineProperty(b.Image.prototype, "smoothed", {
  5436. get: function() {
  5437. return !this.texture.baseTexture.scaleMode
  5438. },
  5439. set: function(a) {
  5440. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  5441. }
  5442. }), Object.defineProperty(b.Image.prototype, "destroyPhase", {
  5443. get: function() {
  5444. return !!this._cache[8]
  5445. }
  5446. }), b.TileSprite = function(a, c, d, e, f, g, h) {
  5447. c = c || 0, d = d || 0, e = e || 256, f = f || 256, g = g || null, h = h || null, this.game = a, this.name = "", this.type = b.TILESPRITE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = g, this._frame = 0, this._frameName = "", this._scroll = new b.Point, PIXI.TilingSprite.call(this, PIXI.TextureCache.__default, e, f), this.position.set(c, d), this.input = null, this.world = new b.Point(c, d), this.autoCull = !1, this.checkWorldBounds = !1, this.cameraOffset = new b.Point, this.body = null, this.alive = !0, this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0], this.loadTexture(g, h)
  5448. }, b.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), b.TileSprite.prototype.constructor = b.TileSprite, b.TileSprite.prototype.preUpdate = function() {
  5449. if (1 === this._cache[4] && this.exists) return this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.body && this.body.preUpdate(), this._cache[4] = 0, !1;
  5450. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  5451. (this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds && (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds) ? (this._cache[5] = 0, this.events.onEnterBounds.dispatch(this)) : 0 !== this._cache[5] || this.game.world.bounds.intersects(this._bounds) || (this._cache[5] = 1, this.events.onOutOfBounds.dispatch(this))), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), this.animations.update(), 0 !== this._scroll.x && (this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed), 0 !== this._scroll.y && (this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed), this.body && this.body.preUpdate();
  5452. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5453. return !0
  5454. }, b.TileSprite.prototype.update = function() {}, b.TileSprite.prototype.postUpdate = function() {
  5455. this.exists && this.body && this.body.postUpdate(), 1 === this._cache[7] && (this.position.x = this.game.camera.view.x + this.cameraOffset.x, this.position.y = this.game.camera.view.y + this.cameraOffset.y);
  5456. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  5457. }, b.TileSprite.prototype.autoScroll = function(a, b) {
  5458. this._scroll.set(a, b)
  5459. }, b.TileSprite.prototype.stopScroll = function() {
  5460. this._scroll.set(0, 0)
  5461. }, b.TileSprite.prototype.loadTexture = function(a, c) {
  5462. c = c || 0, this.key = a, a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? this.setTexture(a.texture) : a instanceof PIXI.Texture ? this.setTexture(a) : null === a || "undefined" == typeof a ? (this.key = "__default", this.setTexture(PIXI.TextureCache[this.key])) : "string" != typeof a || this.game.cache.checkImageKey(a) ? (this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])), this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key])), this.texture.baseTexture.dirty()
  5463. }, b.TileSprite.prototype.setFrame = function(a) {
  5464. 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 = {
  5465. x: a.spriteSourceSizeX,
  5466. y: a.spriteSourceSizeY,
  5467. width: a.sourceSizeW,
  5468. height: a.sourceSizeH
  5469. }, 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.texture._updateUvs()
  5470. }, b.TileSprite.prototype.destroy = function(a) {
  5471. if (null !== this.game && !this.destroyPhase) {
  5472. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.events && this.events.onDestroy.dispatch(this), this.filters && (this.filters = null), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.animations.destroy(), this.events.destroy();
  5473. var c = this.children.length;
  5474. if (a)
  5475. for (; c--;) this.children[c].destroy(a);
  5476. else
  5477. for (; c--;) this.removeChild(this.children[c]);
  5478. this.exists = !1, this.visible = !1, this.alive = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5479. }
  5480. }, b.TileSprite.prototype.play = function(a, b, c, d) {
  5481. return this.animations.play(a, b, c, d)
  5482. }, b.TileSprite.prototype.reset = function(a, b) {
  5483. return this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.tilePosition.x = 0, this.tilePosition.y = 0, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this
  5484. }, Object.defineProperty(b.TileSprite.prototype, "angle", {
  5485. get: function() {
  5486. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  5487. },
  5488. set: function(a) {
  5489. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  5490. }
  5491. }), Object.defineProperty(b.TileSprite.prototype, "frame", {
  5492. get: function() {
  5493. return this.animations.frame
  5494. },
  5495. set: function(a) {
  5496. a !== this.animations.frame && (this.animations.frame = a)
  5497. }
  5498. }), Object.defineProperty(b.TileSprite.prototype, "frameName", {
  5499. get: function() {
  5500. return this.animations.frameName
  5501. },
  5502. set: function(a) {
  5503. a !== this.animations.frameName && (this.animations.frameName = a)
  5504. }
  5505. }), Object.defineProperty(b.TileSprite.prototype, "fixedToCamera", {
  5506. get: function() {
  5507. return !!this._cache[7]
  5508. },
  5509. set: function(a) {
  5510. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5511. }
  5512. }), Object.defineProperty(b.TileSprite.prototype, "exists", {
  5513. get: function() {
  5514. return !!this._cache[6]
  5515. },
  5516. set: function(a) {
  5517. a ? (this._cache[6] = 1, this.body && this.body.type === b.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._cache[6] = 0, this.body && this.body.type === b.Physics.P2JS && (this.body.safeRemove = !0), this.visible = !1)
  5518. }
  5519. }), Object.defineProperty(b.TileSprite.prototype, "inputEnabled", {
  5520. get: function() {
  5521. return this.input && this.input.enabled
  5522. },
  5523. set: function(a) {
  5524. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5525. }
  5526. }), Object.defineProperty(b.TileSprite.prototype, "x", {
  5527. get: function() {
  5528. return this.position.x
  5529. },
  5530. set: function(a) {
  5531. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5532. }
  5533. }), Object.defineProperty(b.TileSprite.prototype, "y", {
  5534. get: function() {
  5535. return this.position.y
  5536. },
  5537. set: function(a) {
  5538. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5539. }
  5540. }), Object.defineProperty(b.TileSprite.prototype, "destroyPhase", {
  5541. get: function() {
  5542. return !!this._cache[8]
  5543. }
  5544. }), b.Rope = function(a, c, d, e, f, g) {
  5545. this.points = [], this.points = g, this._hasUpdateAnimation = !1, this._updateAnimationCallback = null, c = c || 0, d = d || 0, e = e || null, f = f || null, this.game = a, this.name = "", this.type = b.ROPE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = e, this._frame = 0, this._frameName = "", this._scroll = new b.Point, PIXI.Rope.call(this, e, this.points), this.position.set(c, d), this.input = null, this.world = new b.Point(c, d), this.autoCull = !1, this.checkWorldBounds = !1, this.cameraOffset = new b.Point, this.body = null, this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0], this.loadTexture(e, f)
  5546. }, b.Rope.prototype = Object.create(PIXI.Rope.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.preUpdate = function() {
  5547. if (1 === this._cache[4] && this.exists) return this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.body && this.body.preUpdate(), this._cache[4] = 0, !1;
  5548. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  5549. (this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds && (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds) ? (this._cache[5] = 0, this.events.onEnterBounds.dispatch(this)) : 0 !== this._cache[5] || this.game.world.bounds.intersects(this._bounds) || (this._cache[5] = 1, this.events.onOutOfBounds.dispatch(this))), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), this.animations.update(), 0 !== this._scroll.x && (this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed), 0 !== this._scroll.y && (this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed), this.body && this.body.preUpdate();
  5550. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5551. return !0
  5552. }, b.Rope.prototype.update = function() {
  5553. this._hasUpdateAnimation && this.updateAnimation.call(this)
  5554. }, b.Rope.prototype.postUpdate = function() {
  5555. this.exists && this.body && this.body.postUpdate(), 1 === this._cache[7] && (this.position.x = this.game.camera.view.x + this.cameraOffset.x, this.position.y = this.game.camera.view.y + this.cameraOffset.y);
  5556. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  5557. }, b.Rope.prototype.loadTexture = function(a, c) {
  5558. c = c || 0, this.key = a, a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? this.setTexture(a.texture) : a instanceof PIXI.Texture ? this.setTexture(a) : null === a || "undefined" == typeof a ? (this.key = "__default", this.setTexture(PIXI.TextureCache[this.key])) : "string" != typeof a || this.game.cache.checkImageKey(a) ? (this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])), this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key]))
  5559. }, b.Rope.prototype.setFrame = function(a) {
  5560. 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 = {
  5561. x: a.spriteSourceSizeX,
  5562. y: a.spriteSourceSizeY,
  5563. width: a.sourceSizeW,
  5564. height: a.sourceSizeH
  5565. }, 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.texture._updateUvs()
  5566. }, b.Rope.prototype.destroy = function(a) {
  5567. if (null !== this.game && !this.destroyPhase) {
  5568. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.events && this.events.onDestroy.dispatch(this), this.filters && (this.filters = null), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.animations.destroy(), this.events.destroy();
  5569. var c = this.children.length;
  5570. if (a)
  5571. for (; c--;) this.children[c].destroy(a);
  5572. else
  5573. for (; c--;) this.removeChild(this.children[c]);
  5574. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5575. }
  5576. }, b.Rope.prototype.play = function(a, b, c, d) {
  5577. return this.animations.play(a, b, c, d)
  5578. }, b.Rope.prototype.reset = function(a, b) {
  5579. return this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.tilePosition.x = 0, this.tilePosition.y = 0, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this
  5580. }, Object.defineProperty(b.Rope.prototype, "angle", {
  5581. get: function() {
  5582. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  5583. },
  5584. set: function(a) {
  5585. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  5586. }
  5587. }), Object.defineProperty(b.Rope.prototype, "frame", {
  5588. get: function() {
  5589. return this.animations.frame
  5590. },
  5591. set: function(a) {
  5592. a !== this.animations.frame && (this.animations.frame = a)
  5593. }
  5594. }), Object.defineProperty(b.Rope.prototype, "frameName", {
  5595. get: function() {
  5596. return this.animations.frameName
  5597. },
  5598. set: function(a) {
  5599. a !== this.animations.frameName && (this.animations.frameName = a)
  5600. }
  5601. }), Object.defineProperty(b.Rope.prototype, "fixedToCamera", {
  5602. get: function() {
  5603. return !!this._cache[7]
  5604. },
  5605. set: function(a) {
  5606. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5607. }
  5608. }), Object.defineProperty(b.Rope.prototype, "exists", {
  5609. get: function() {
  5610. return !!this._cache[6]
  5611. },
  5612. set: function(a) {
  5613. a ? (this._cache[6] = 1, this.body && this.body.type === b.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._cache[6] = 0, this.body && this.body.type === b.Physics.P2JS && (this.body.safeRemove = !0), this.visible = !1)
  5614. }
  5615. }), Object.defineProperty(b.Rope.prototype, "inputEnabled", {
  5616. get: function() {
  5617. return this.input && this.input.enabled
  5618. },
  5619. set: function(a) {
  5620. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5621. }
  5622. }), Object.defineProperty(b.Rope.prototype, "x", {
  5623. get: function() {
  5624. return this.position.x
  5625. },
  5626. set: function(a) {
  5627. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5628. }
  5629. }), Object.defineProperty(b.Rope.prototype, "y", {
  5630. get: function() {
  5631. return this.position.y
  5632. },
  5633. set: function(a) {
  5634. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  5635. }
  5636. }), Object.defineProperty(b.Rope.prototype, "updateAnimation", {
  5637. get: function() {
  5638. return this._updateAnimation
  5639. },
  5640. set: function(a) {
  5641. a && "function" == typeof a ? (this._hasUpdateAnimation = !0, this._updateAnimation = a) : (this._hasUpdateAnimation = !1, this._updateAnimation = null)
  5642. }
  5643. }), Object.defineProperty(b.Rope.prototype, "segments", {
  5644. get: function() {
  5645. for (var a, c, d, e, f, g, h, i, j = [], k = 0; k < this.points.length; k++) a = 4 * k, c = this.verticies[a], d = this.verticies[a + 1], e = this.verticies[a + 4], f = this.verticies[a + 3], g = b.Math.difference(c, e), h = b.Math.difference(d, f), c += this.world.x, d += this.world.y, i = new b.Rectangle(c, d, g, h), j.push(i);
  5646. return j
  5647. }
  5648. }), Object.defineProperty(b.Rope.prototype, "destroyPhase", {
  5649. get: function() {
  5650. return !!this._cache[8]
  5651. }
  5652. }), b.Text = function(a, c, d, e, f) {
  5653. c = c || 0, d = d || 0, e = e || " ", f = f || {}, e = 0 === e.length ? " " : e.toString(), this.game = a, this.exists = !0, this.name = "", this.type = b.TEXT, this.z = 0, this.world = new b.Point(c, d), this._text = e, this._font = "", this._fontSize = 32, this._fontWeight = "normal", this._lineSpacing = 0, this._charCount = 0, this.events = new b.Events(this), this.input = null, this.cameraOffset = new b.Point, this.colors = [], this.setStyle(f), PIXI.Text.call(this, e, this.style), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0], " " !== e && this.updateText()
  5654. }, b.Text.prototype = Object.create(PIXI.Text.prototype), b.Text.prototype.constructor = b.Text, b.Text.prototype.preUpdate = function() {
  5655. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  5656. this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++);
  5657. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  5658. return !0
  5659. }, b.Text.prototype.update = function() {}, b.Text.prototype.postUpdate = function() {
  5660. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  5661. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  5662. }, b.Text.prototype.destroy = function(a) {
  5663. if (null !== this.game && !this.destroyPhase) {
  5664. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.events && this.events.onDestroy.dispatch(this), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.texture.destroy(!0), this.canvas.parentNode ? this.canvas.parentNode.removeChild(this.canvas) : (this.canvas = null, this.context = null);
  5665. var c = this.children.length;
  5666. if (a)
  5667. for (; c--;) this.children[c].destroy(a);
  5668. else
  5669. for (; c--;) this.removeChild(this.children[c]);
  5670. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5671. }
  5672. }, b.Text.prototype.setShadow = function(a, b, c, d) {
  5673. this.style.shadowOffsetX = a || 0, this.style.shadowOffsetY = b || 0, this.style.shadowColor = c || "rgba(0,0,0,0)", this.style.shadowBlur = d || 0, this.dirty = !0
  5674. }, b.Text.prototype.setStyle = function(a) {
  5675. a = a || {}, a.font = a.font || "bold 20pt Arial", a.fill = a.fill || "black", a.align = a.align || "left", a.stroke = a.stroke || "black", a.strokeThickness = a.strokeThickness || 0, a.wordWrap = a.wordWrap || !1, a.wordWrapWidth = a.wordWrapWidth || 100, a.shadowOffsetX = a.shadowOffsetX || 0, a.shadowOffsetY = a.shadowOffsetY || 0, a.shadowColor = a.shadowColor || "rgba(0,0,0,0)", a.shadowBlur = a.shadowBlur || 0, this.style = a, this.dirty = !0
  5676. }, b.Text.prototype.updateText = function() {
  5677. this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
  5678. var a = this.text;
  5679. this.style.wordWrap && (a = this.runWordWrap(this.text));
  5680. for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
  5681. var g = this.context.measureText(b[f]).width;
  5682. c[f] = g, d = Math.max(d, g)
  5683. }
  5684. var h = d + this.style.strokeThickness;
  5685. this.canvas.width = (h + this.context.lineWidth) * this.resolution;
  5686. var i = e.fontSize + this.style.strokeThickness,
  5687. j = i * b.length;
  5688. 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.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";
  5689. var k, l;
  5690. for (this._charCount = 0, 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), l += this._lineSpacing, this.colors.length > 0 ? this.updateLine(b[f], k, l) : (this.style.stroke && this.style.strokeThickness && this.context.strokeText(b[f], k, l), this.style.fill && this.context.fillText(b[f], k, l));
  5691. this.updateTexture()
  5692. }, b.Text.prototype.updateLine = function(a, b, c) {
  5693. for (var d = 0; d < a.length; d++) {
  5694. var e = a[d];
  5695. 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++
  5696. }
  5697. }, b.Text.prototype.clearColors = function() {
  5698. this.colors = [], this.dirty = !0
  5699. }, b.Text.prototype.addColor = function(a, b) {
  5700. this.colors[b] = a, this.dirty = !0
  5701. }, b.Text.prototype.runWordWrap = function(a) {
  5702. for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
  5703. for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
  5704. var h = this.context.measureText(f[g]).width,
  5705. i = h + this.context.measureText(" ").width;
  5706. i > e ? (g > 0 && (b += "\n"), b += f[g] + " ", e = this.style.wordWrapWidth - h) : (e -= i, b += f[g] + " ")
  5707. }
  5708. d < c.length - 1 && (b += "\n")
  5709. }
  5710. return b
  5711. }, Object.defineProperty(b.Text.prototype, "angle", {
  5712. get: function() {
  5713. return b.Math.radToDeg(this.rotation)
  5714. },
  5715. set: function(a) {
  5716. this.rotation = b.Math.degToRad(a)
  5717. }
  5718. }), Object.defineProperty(b.Text.prototype, "text", {
  5719. get: function() {
  5720. return this._text
  5721. },
  5722. set: function(a) {
  5723. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0, this.parent && this.updateTransform())
  5724. }
  5725. }), Object.defineProperty(b.Text.prototype, "font", {
  5726. get: function() {
  5727. return this._font
  5728. },
  5729. set: function(a) {
  5730. a !== this._font && (this._font = a.trim(), this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.parent && this.updateTransform())
  5731. }
  5732. }), Object.defineProperty(b.Text.prototype, "fontSize", {
  5733. get: function() {
  5734. return this._fontSize
  5735. },
  5736. set: function(a) {
  5737. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.parent && this.updateTransform())
  5738. }
  5739. }), Object.defineProperty(b.Text.prototype, "fontWeight", {
  5740. get: function() {
  5741. return this._fontWeight
  5742. },
  5743. set: function(a) {
  5744. a !== this._fontWeight && (this._fontWeight = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.parent && this.updateTransform())
  5745. }
  5746. }), Object.defineProperty(b.Text.prototype, "fill", {
  5747. get: function() {
  5748. return this.style.fill
  5749. },
  5750. set: function(a) {
  5751. a !== this.style.fill && (this.style.fill = a, this.dirty = !0)
  5752. }
  5753. }), Object.defineProperty(b.Text.prototype, "align", {
  5754. get: function() {
  5755. return this.style.align
  5756. },
  5757. set: function(a) {
  5758. a !== this.style.align && (this.style.align = a, this.dirty = !0)
  5759. }
  5760. }), Object.defineProperty(b.Text.prototype, "stroke", {
  5761. get: function() {
  5762. return this.style.stroke
  5763. },
  5764. set: function(a) {
  5765. a !== this.style.stroke && (this.style.stroke = a, this.dirty = !0)
  5766. }
  5767. }), Object.defineProperty(b.Text.prototype, "strokeThickness", {
  5768. get: function() {
  5769. return this.style.strokeThickness
  5770. },
  5771. set: function(a) {
  5772. a !== this.style.strokeThickness && (this.style.strokeThickness = a, this.dirty = !0)
  5773. }
  5774. }), Object.defineProperty(b.Text.prototype, "wordWrap", {
  5775. get: function() {
  5776. return this.style.wordWrap
  5777. },
  5778. set: function(a) {
  5779. a !== this.style.wordWrap && (this.style.wordWrap = a, this.dirty = !0)
  5780. }
  5781. }), Object.defineProperty(b.Text.prototype, "wordWrapWidth", {
  5782. get: function() {
  5783. return this.style.wordWrapWidth
  5784. },
  5785. set: function(a) {
  5786. a !== this.style.wordWrapWidth && (this.style.wordWrapWidth = a, this.dirty = !0)
  5787. }
  5788. }), Object.defineProperty(b.Text.prototype, "lineSpacing", {
  5789. get: function() {
  5790. return this._lineSpacing
  5791. },
  5792. set: function(a) {
  5793. a !== this._lineSpacing && (this._lineSpacing = parseFloat(a), this.dirty = !0, this.parent && this.updateTransform())
  5794. }
  5795. }), Object.defineProperty(b.Text.prototype, "shadowOffsetX", {
  5796. get: function() {
  5797. return this.style.shadowOffsetX
  5798. },
  5799. set: function(a) {
  5800. a !== this.style.shadowOffsetX && (this.style.shadowOffsetX = a, this.dirty = !0)
  5801. }
  5802. }), Object.defineProperty(b.Text.prototype, "shadowOffsetY", {
  5803. get: function() {
  5804. return this.style.shadowOffsetY
  5805. },
  5806. set: function(a) {
  5807. a !== this.style.shadowOffsetY && (this.style.shadowOffsetY = a, this.dirty = !0)
  5808. }
  5809. }), Object.defineProperty(b.Text.prototype, "shadowColor", {
  5810. get: function() {
  5811. return this.style.shadowColor
  5812. },
  5813. set: function(a) {
  5814. a !== this.style.shadowColor && (this.style.shadowColor = a, this.dirty = !0)
  5815. }
  5816. }), Object.defineProperty(b.Text.prototype, "shadowBlur", {
  5817. get: function() {
  5818. return this.style.shadowBlur
  5819. },
  5820. set: function(a) {
  5821. a !== this.style.shadowBlur && (this.style.shadowBlur = a, this.dirty = !0)
  5822. }
  5823. }), Object.defineProperty(b.Text.prototype, "inputEnabled", {
  5824. get: function() {
  5825. return this.input && this.input.enabled
  5826. },
  5827. set: function(a) {
  5828. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5829. }
  5830. }), Object.defineProperty(b.Text.prototype, "fixedToCamera", {
  5831. get: function() {
  5832. return !!this._cache[7]
  5833. },
  5834. set: function(a) {
  5835. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5836. }
  5837. }), Object.defineProperty(b.Text.prototype, "destroyPhase", {
  5838. get: function() {
  5839. return !!this._cache[8]
  5840. }
  5841. }), b.BitmapText = function(a, c, d, e, f, g) {
  5842. c = c || 0, d = d || 0, e = e || "", f = f || "", g = g || 32, this.game = a, this.exists = !0, this.name = "", this.type = b.BITMAPTEXT, this.z = 0, this.world = new b.Point(c, d), this._text = f, this._font = e, this._fontSize = g, this._align = "left", this._tint = 16777215, this.events = new b.Events(this), this.input = null, this.cameraOffset = new b.Point, PIXI.BitmapText.call(this, f), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  5843. }, b.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setStyle = function() {
  5844. this.style = {
  5845. align: this._align
  5846. }, this.fontName = this._font, this.fontSize = this._fontSize, this.dirty = !0
  5847. }, b.BitmapText.prototype.preUpdate = function() {
  5848. return this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.exists && this.parent.exists ? (this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), !0) : (this.renderOrderID = -1, !1)
  5849. }, b.BitmapText.prototype.update = function() {}, b.BitmapText.prototype.postUpdate = function() {
  5850. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  5851. }, b.BitmapText.prototype.destroy = function(a) {
  5852. if (null !== this.game && !this.destroyPhase) {
  5853. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
  5854. var c = this.children.length;
  5855. if (a)
  5856. for (; c--;) this.children[c].destroy ? this.children[c].destroy(a) : this.removeChild(this.children[c]);
  5857. else
  5858. for (; c--;) this.removeChild(this.children[c]);
  5859. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  5860. }
  5861. }, Object.defineProperty(b.BitmapText.prototype, "align", {
  5862. get: function() {
  5863. return this._align
  5864. },
  5865. set: function(a) {
  5866. a !== this._align && (this._align = a, this.setStyle())
  5867. }
  5868. }), Object.defineProperty(b.BitmapText.prototype, "tint", {
  5869. get: function() {
  5870. return this._tint
  5871. },
  5872. set: function(a) {
  5873. a !== this._tint && (this._tint = a, this.dirty = !0)
  5874. }
  5875. }), Object.defineProperty(b.BitmapText.prototype, "angle", {
  5876. get: function() {
  5877. return b.Math.radToDeg(this.rotation)
  5878. },
  5879. set: function(a) {
  5880. this.rotation = b.Math.degToRad(a)
  5881. }
  5882. }), Object.defineProperty(b.BitmapText.prototype, "font", {
  5883. get: function() {
  5884. return this._font
  5885. },
  5886. set: function(a) {
  5887. a !== this._font && (this._font = a.trim(), this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  5888. }
  5889. }), Object.defineProperty(b.BitmapText.prototype, "fontSize", {
  5890. get: function() {
  5891. return this._fontSize
  5892. },
  5893. set: function(a) {
  5894. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  5895. }
  5896. }), Object.defineProperty(b.BitmapText.prototype, "text", {
  5897. get: function() {
  5898. return this._text
  5899. },
  5900. set: function(a) {
  5901. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0)
  5902. }
  5903. }), Object.defineProperty(b.BitmapText.prototype, "inputEnabled", {
  5904. get: function() {
  5905. return this.input && this.input.enabled
  5906. },
  5907. set: function(a) {
  5908. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  5909. }
  5910. }), Object.defineProperty(b.BitmapText.prototype, "fixedToCamera", {
  5911. get: function() {
  5912. return !!this._cache[7]
  5913. },
  5914. set: function(a) {
  5915. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  5916. }
  5917. }), Object.defineProperty(b.BitmapText.prototype, "destroyPhase", {
  5918. get: function() {
  5919. return !!this._cache[8]
  5920. }
  5921. }), b.Button = function(a, c, d, e, f, g, h, i, j, k) {
  5922. c = c || 0, d = d || 0, e = e || null, f = f || null, g = g || this, b.Image.call(this, a, c, d, e, i), this.type = b.BUTTON, this._onOverFrameName = null, this._onOutFrameName = null, this._onDownFrameName = null, this._onUpFrameName = null, this._onOverFrameID = null, this._onOutFrameID = null, this._onDownFrameID = null, this._onUpFrameID = null, this.onOverMouseOnly = !1, this.onOverSound = null, this.onOutSound = null, this.onDownSound = null, this.onUpSound = null, this.onOverSoundMarker = "", this.onOutSoundMarker = "", this.onDownSoundMarker = "", this.onUpSoundMarker = "", this.onInputOver = new b.Signal, this.onInputOut = new b.Signal, this.onInputDown = new b.Signal, this.onInputUp = new b.Signal, this.freezeFrames = !1, this.forceOut = !1, this.inputEnabled = !0, this.input.start(0, !0), this.setFrames(h, i, j, k), null !== f && this.onInputUp.add(f, g), this.events.onInputOver.add(this.onInputOverHandler, this), this.events.onInputOut.add(this.onInputOutHandler, this), this.events.onInputDown.add(this.onInputDownHandler, this), this.events.onInputUp.add(this.onInputUpHandler, this)
  5923. }, b.Button.prototype = Object.create(b.Image.prototype), b.Button.prototype.constructor = b.Button, b.Button.prototype.clearFrames = function() {
  5924. this._onOverFrameName = null, this._onOverFrameID = null, this._onOutFrameName = null, this._onOutFrameID = null, this._onDownFrameName = null, this._onDownFrameID = null, this._onUpFrameName = null, this._onUpFrameID = null
  5925. }, b.Button.prototype.setFrames = function(a, b, c, d) {
  5926. this.clearFrames(), null !== a && ("string" == typeof a ? (this._onOverFrameName = a, this.input.pointerOver() && (this.frameName = a)) : (this._onOverFrameID = a, this.input.pointerOver() && (this.frame = a))), null !== b && ("string" == typeof b ? (this._onOutFrameName = b, this.input.pointerOver() === !1 && (this.frameName = b)) : (this._onOutFrameID = b, this.input.pointerOver() === !1 && (this.frame = b))), null !== c && ("string" == typeof c ? (this._onDownFrameName = c, this.input.pointerDown() && (this.frameName = c)) : (this._onDownFrameID = c, this.input.pointerDown() && (this.frame = c))), null !== d && ("string" == typeof d ? (this._onUpFrameName = d, this.input.pointerUp() && (this.frameName = d)) : (this._onUpFrameID = d, this.input.pointerUp() && (this.frame = d)))
  5927. }, b.Button.prototype.setSounds = function(a, b, c, d, e, f, g, h) {
  5928. this.setOverSound(a, b), this.setOutSound(e, f), this.setDownSound(c, d), this.setUpSound(g, h)
  5929. }, b.Button.prototype.setOverSound = function(a, c) {
  5930. this.onOverSound = null, this.onOverSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onOverSound = a), "string" == typeof c && (this.onOverSoundMarker = c)
  5931. }, b.Button.prototype.setOutSound = function(a, c) {
  5932. this.onOutSound = null, this.onOutSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onOutSound = a), "string" == typeof c && (this.onOutSoundMarker = c)
  5933. }, b.Button.prototype.setDownSound = function(a, c) {
  5934. this.onDownSound = null, this.onDownSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onDownSound = a), "string" == typeof c && (this.onDownSoundMarker = c)
  5935. }, b.Button.prototype.setUpSound = function(a, c) {
  5936. this.onUpSound = null, this.onUpSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onUpSound = a), "string" == typeof c && (this.onUpSoundMarker = c)
  5937. }, b.Button.prototype.onInputOverHandler = function(a, b) {
  5938. b.justReleased() || (this.freezeFrames === !1 && this.setState(1), (!this.onOverMouseOnly || b.isMouse) && (this.onOverSound && this.onOverSound.play(this.onOverSoundMarker), this.onInputOver && this.onInputOver.dispatch(this, b)))
  5939. }, b.Button.prototype.onInputOutHandler = function(a, b) {
  5940. this.freezeFrames === !1 && this.setState(2), this.onOutSound && this.onOutSound.play(this.onOutSoundMarker), this.onInputOut && this.onInputOut.dispatch(this, b)
  5941. }, b.Button.prototype.onInputDownHandler = function(a, b) {
  5942. this.freezeFrames === !1 && this.setState(3), this.onDownSound && this.onDownSound.play(this.onDownSoundMarker), this.onInputDown && this.onInputDown.dispatch(this, b)
  5943. }, b.Button.prototype.onInputUpHandler = function(a, b, c) {
  5944. this.onUpSound && this.onUpSound.play(this.onUpSoundMarker), this.onInputUp && this.onInputUp.dispatch(this, b, c), this.freezeFrames || this.setState(this.forceOut ? 2 : null !== this._onUpFrameName || null !== this._onUpFrameID ? 4 : c ? 1 : 2)
  5945. }, b.Button.prototype.setState = function(a) {
  5946. 1 === a ? null != this._onOverFrameName ? this.frameName = this._onOverFrameName : null != this._onOverFrameID && (this.frame = this._onOverFrameID) : 2 === a ? null != this._onOutFrameName ? this.frameName = this._onOutFrameName : null != this._onOutFrameID && (this.frame = this._onOutFrameID) : 3 === a ? null != this._onDownFrameName ? this.frameName = this._onDownFrameName : null != this._onDownFrameID && (this.frame = this._onDownFrameID) : 4 === a && (null != this._onUpFrameName ? this.frameName = this._onUpFrameName : null != this._onUpFrameID && (this.frame = this._onUpFrameID))
  5947. }, b.Graphics = function(a, c, d) {
  5948. c = c || 0, d = d || 0, this.game = a, this.exists = !0, this.name = "", this.type = b.GRAPHICS, this.z = 0, this.world = new b.Point(c, d), this.cameraOffset = new b.Point, PIXI.Graphics.call(this), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  5949. }, b.Graphics.prototype = Object.create(PIXI.Graphics.prototype), b.Graphics.prototype.constructor = b.Graphics, b.Graphics.prototype.preUpdate = function() {
  5950. return this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.exists && this.parent.exists ? (this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), !0) : (this.renderOrderID = -1, !1)
  5951. }, b.Graphics.prototype.update = function() {}, b.Graphics.prototype.postUpdate = function() {
  5952. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  5953. }, b.Graphics.prototype.destroy = function(a) {
  5954. if (null !== this.game && !this.destroyPhase) {
  5955. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.clear(), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
  5956. var c = this.children.length;
  5957. if (a)
  5958. for (; c--;) this.children[c].destroy(a);
  5959. else
  5960. for (; c--;) this.removeChild(this.children[c]);
  5961. this.exists = !1, this.visible = !1, this.game = null, this._cache[8] = 0
  5962. }
  5963. }, b.Graphics.prototype.drawTriangle = function(a, c) {
  5964. "undefined" == typeof c && (c = !1);
  5965. var d = new b.Polygon(a);
  5966. if (c) {
  5967. var e = new b.Point(this.game.camera.x - a[0].x, this.game.camera.y - a[0].y),
  5968. f = new b.Point(a[1].x - a[0].x, a[1].y - a[0].y),
  5969. g = new b.Point(a[1].x - a[2].x, a[1].y - a[2].y),
  5970. h = g.cross(f);
  5971. e.dot(h) > 0 && this.drawPolygon(d)
  5972. } else this.drawPolygon(d)
  5973. }, b.Graphics.prototype.drawTriangles = function(a, c, d) {
  5974. "undefined" == typeof d && (d = !1);
  5975. var e, f = new b.Point,
  5976. g = new b.Point,
  5977. h = new b.Point,
  5978. i = [];
  5979. if (c)
  5980. if (a[0] instanceof b.Point)
  5981. for (e = 0; e < c.length / 3; e++) i.push(a[c[3 * e]]), i.push(a[c[3 * e + 1]]), i.push(a[c[3 * e + 2]]), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5982. else
  5983. for (e = 0; e < c.length; e++) f.x = a[2 * c[e]], f.y = a[2 * c[e] + 1], i.push(f.copyTo({})), 3 === i.length && (this.drawTriangle(i, d), i = []);
  5984. else if (a[0] instanceof b.Point)
  5985. for (e = 0; e < a.length / 3; e++) this.drawTriangle([a[3 * e], a[3 * e + 1], a[3 * e + 2]], d);
  5986. else
  5987. 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)
  5988. }, Object.defineProperty(b.Graphics.prototype, "angle", {
  5989. get: function() {
  5990. return b.Math.radToDeg(this.rotation)
  5991. },
  5992. set: function(a) {
  5993. this.rotation = b.Math.degToRad(a)
  5994. }
  5995. }), Object.defineProperty(b.Graphics.prototype, "fixedToCamera", {
  5996. get: function() {
  5997. return !!this._cache[7]
  5998. },
  5999. set: function(a) {
  6000. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  6001. }
  6002. }), Object.defineProperty(b.Graphics.prototype, "destroyPhase", {
  6003. get: function() {
  6004. return !!this._cache[8]
  6005. }
  6006. }), b.RenderTexture = function(a, c, d, e, f, g) {
  6007. "undefined" == typeof e && (e = ""), "undefined" == typeof f && (f = b.scaleModes.DEFAULT), "undefined" == typeof g && (g = 1), this.game = a, this.key = e, this.type = b.RENDERTEXTURE, this.matrix = new PIXI.Matrix, PIXI.RenderTexture.call(this, c, d, this.game.renderer, f, g), this.render = b.RenderTexture.prototype.render
  6008. }, b.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.renderXY = function(a, b, c, d) {
  6009. 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)
  6010. }, b.RenderTexture.prototype.render = function(a, b, c) {
  6011. 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)
  6012. }, b.SpriteBatch = function(a, c, d, e) {
  6013. ("undefined" == typeof c || null === c) && (c = a.world), PIXI.SpriteBatch.call(this), b.Group.call(this, a, c, d, e), this.type = b.SPRITEBATCH
  6014. }, b.SpriteBatch.prototype = b.Utils.extend(!0, b.SpriteBatch.prototype, b.Group.prototype, PIXI.SpriteBatch.prototype), b.SpriteBatch.prototype.constructor = b.SpriteBatch, b.RetroFont = function(a, c, d, e, f, g, h, i, j, k) {
  6015. if (!a.cache.checkImageKey(c)) return !1;
  6016. ("undefined" == typeof g || null === g) && (g = a.cache.getImage(c).width / d), this.characterWidth = d, this.characterHeight = e, this.characterSpacingX = h || 0, this.characterSpacingY = i || 0, this.characterPerRow = g, this.offsetX = j || 0, this.offsetY = k || 0, this.align = "left", this.multiLine = !1, this.autoUpperCase = !0, this.customSpacingX = 0, this.customSpacingY = 0, this.fixedWidth = 0, this.fontSet = a.cache.getImage(c), this._text = "", this.grabData = [], this.frameData = new b.FrameData;
  6017. for (var l = this.offsetX, m = this.offsetY, n = 0, o = 0; o < f.length; o++) {
  6018. var p = a.rnd.uuid(),
  6019. q = this.frameData.addFrame(new b.Frame(o, l, m, this.characterWidth, this.characterHeight, "", p));
  6020. this.grabData[f.charCodeAt(o)] = q.index, PIXI.TextureCache[p] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  6021. x: l,
  6022. y: m,
  6023. width: this.characterWidth,
  6024. height: this.characterHeight
  6025. }), n++, n == this.characterPerRow ? (n = 0, l = this.offsetX, m += this.characterHeight + this.characterSpacingY) : l += this.characterWidth + this.characterSpacingX
  6026. }
  6027. a.cache.updateFrameData(c, this.frameData), this.stamp = new b.Image(a, 0, 0, c, 0), b.RenderTexture.call(this, a, 100, 100, "", b.scaleModes.NEAREST), this.type = b.RETROFONT
  6028. }, b.RetroFont.prototype = Object.create(b.RenderTexture.prototype), b.RetroFont.prototype.constructor = b.RetroFont, b.RetroFont.ALIGN_LEFT = "left", b.RetroFont.ALIGN_RIGHT = "right", b.RetroFont.ALIGN_CENTER = "center", b.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", b.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ", b.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789", b.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789", b.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ", b.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39", b.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!", b.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789", b.RetroFont.prototype.setFixedWidth = function(a, b) {
  6029. "undefined" == typeof b && (b = "left"), this.fixedWidth = a, this.align = b
  6030. }, b.RetroFont.prototype.setText = function(a, b, c, d, e, f) {
  6031. 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)
  6032. }, b.RetroFont.prototype.buildRetroFontText = function() {
  6033. var a = 0,
  6034. c = 0;
  6035. if (this.clear(), this.multiLine) {
  6036. var d = this._text.split("\n");
  6037. 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);
  6038. for (var e = 0; e < d.length; e++) {
  6039. switch (this.align) {
  6040. case b.RetroFont.ALIGN_LEFT:
  6041. a = 0;
  6042. break;
  6043. case b.RetroFont.ALIGN_RIGHT:
  6044. a = this.width - d[e].length * (this.characterWidth + this.customSpacingX);
  6045. break;
  6046. case b.RetroFont.ALIGN_CENTER:
  6047. a = this.width / 2 - d[e].length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  6048. }
  6049. 0 > a && (a = 0), this.pasteLine(d[e], a, c, this.customSpacingX), c += this.characterHeight + this.customSpacingY
  6050. }
  6051. } else {
  6052. 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) {
  6053. case b.RetroFont.ALIGN_LEFT:
  6054. a = 0;
  6055. break;
  6056. case b.RetroFont.ALIGN_RIGHT:
  6057. a = this.width - this._text.length * (this.characterWidth + this.customSpacingX);
  6058. break;
  6059. case b.RetroFont.ALIGN_CENTER:
  6060. a = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  6061. }
  6062. this.textureBuffer.clear(), this.pasteLine(this._text, a, 0, this.customSpacingX)
  6063. }
  6064. }, b.RetroFont.prototype.pasteLine = function(a, c, d, e) {
  6065. for (var f = new b.Point, g = 0; g < a.length; g++)
  6066. if (" " == a.charAt(g)) c += this.characterWidth + e;
  6067. else if (this.grabData[a.charCodeAt(g)] >= 0 && (this.stamp.frame = this.grabData[a.charCodeAt(g)], f.set(c, d), this.render(this.stamp, f, !1), c += this.characterWidth + e, c > this.width)) break
  6068. }, b.RetroFont.prototype.getLongestLine = function() {
  6069. var a = 0;
  6070. if (this._text.length > 0)
  6071. for (var b = this._text.split("\n"), c = 0; c < b.length; c++) b[c].length > a && (a = b[c].length);
  6072. return a
  6073. }, b.RetroFont.prototype.removeUnsupportedCharacters = function(a) {
  6074. for (var b = "", c = 0; c < this._text.length; c++) {
  6075. var d = this._text[c],
  6076. e = d.charCodeAt(0);
  6077. (this.grabData[e] >= 0 || !a && "\n" === d) && (b = b.concat(d))
  6078. }
  6079. return b
  6080. }, b.RetroFont.prototype.updateOffset = function(a, b) {
  6081. if (this.offsetX !== a || this.offsetY !== b) {
  6082. 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;
  6083. this.buildRetroFontText()
  6084. }
  6085. }, Object.defineProperty(b.RetroFont.prototype, "text", {
  6086. get: function() {
  6087. return this._text
  6088. },
  6089. set: function(a) {
  6090. var b;
  6091. b = this.autoUpperCase ? a.toUpperCase() : a, b !== this._text && (this._text = b, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
  6092. }
  6093. }), Object.defineProperty(b.RetroFont.prototype, "smoothed", {
  6094. get: function() {
  6095. return this.stamp.smoothed
  6096. },
  6097. set: function(a) {
  6098. this.stamp.smoothed = a, this.buildRetroFontText()
  6099. }
  6100. }), b.Particle = function(a, c, d, e, f) {
  6101. b.Sprite.call(this, a, c, d, e, f), this.autoScale = !1, this.scaleData = null, this._s = 0, this.autoAlpha = !1, this.alphaData = null, this._a = 0
  6102. }, b.Particle.prototype = Object.create(b.Sprite.prototype), b.Particle.prototype.constructor = b.Particle, b.Particle.prototype.update = function() {
  6103. 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)
  6104. }, b.Particle.prototype.onEmit = function() {}, b.Particle.prototype.setAlphaData = function(a) {
  6105. this.alphaData = a, this._a = a.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0
  6106. }, b.Particle.prototype.setScaleData = function(a) {
  6107. this.scaleData = a, this._s = a.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0
  6108. }, b.Particle.prototype.reset = function(a, b, c) {
  6109. return "undefined" == typeof c && (c = 1), this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.health = c, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this.alpha = 1, this.scale.set(1), this.autoScale = !1, this.autoAlpha = !1, this
  6110. }, b.Canvas = {
  6111. create: function(a, b, c) {
  6112. a = a || 256, b = b || 256;
  6113. var d = document.createElement("canvas");
  6114. return "string" == typeof c && "" !== c && (d.id = c), d.width = a, d.height = b, d.style.display = "block", d
  6115. },
  6116. getOffset: function(a, c) {
  6117. c = c || new b.Point;
  6118. var d = a.getBoundingClientRect(),
  6119. e = a.clientTop || document.body.clientTop || 0,
  6120. f = a.clientLeft || document.body.clientLeft || 0,
  6121. g = 0,
  6122. h = 0;
  6123. return "CSS1Compat" === document.compatMode ? (g = window.pageYOffset || document.documentElement.scrollTop || a.scrollTop || 0, h = window.pageXOffset || document.documentElement.scrollLeft || a.scrollLeft || 0) : (g = window.pageYOffset || document.body.scrollTop || a.scrollTop || 0, h = window.pageXOffset || document.body.scrollLeft || a.scrollLeft || 0), c.x = d.left + h - f, c.y = d.top + g - e, c
  6124. },
  6125. getAspectRatio: function(a) {
  6126. return a.width / a.height
  6127. },
  6128. setBackgroundColor: function(a, b) {
  6129. return b = b || "rgb(0,0,0)", a.style.backgroundColor = b, a
  6130. },
  6131. setTouchAction: function(a, b) {
  6132. return b = b || "none", a.style.msTouchAction = b, a.style["ms-touch-action"] = b, a.style["touch-action"] = b, a
  6133. },
  6134. setUserSelect: function(a, b) {
  6135. 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
  6136. },
  6137. addToDOM: function(a, b, c) {
  6138. var d;
  6139. 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
  6140. },
  6141. removeFromDOM: function(a) {
  6142. a.parentNode && a.parentNode.removeChild(a)
  6143. },
  6144. setTransform: function(a, b, c, d, e, f, g) {
  6145. return a.setTransform(d, f, g, e, b, c), a
  6146. },
  6147. setSmoothingEnabled: function(a, b) {
  6148. return a.imageSmoothingEnabled = b, a.mozImageSmoothingEnabled = b, a.oImageSmoothingEnabled = b, a.webkitImageSmoothingEnabled = b, a.msImageSmoothingEnabled = b, a
  6149. },
  6150. getSmoothingEnabled: function(a) {
  6151. return a.imageSmoothingEnabled || a.mozImageSmoothingEnabled || a.oImageSmoothingEnabled || a.webkitImageSmoothingEnabled || a.msImageSmoothingEnabled
  6152. },
  6153. setImageRenderingCrisp: function(a) {
  6154. 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
  6155. },
  6156. setImageRenderingBicubic: function(a) {
  6157. return a.style["image-rendering"] = "auto", a.style.msInterpolationMode = "bicubic", a
  6158. }
  6159. }, b.Device = function(a) {
  6160. this.game = a, 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.file = !1, this.fileSystem = !1, this.localStorage = !1, this.webGL = !1, this.worker = !1, this.touch = !1, this.mspointer = !1, this.css3D = !1, this.pointerLock = !1, this.typedArray = !1, this.vibration = !1, this.getUserMedia = !1, this.quirksMode = !1, this.arora = !1, this.chrome = !1, this.epiphany = !1, this.firefox = !1, this.ie = !1, this.ieVersion = 0, this.trident = !1, this.tridentVersion = 0, this.mobileSafari = !1, this.midori = !1, this.opera = !1, this.safari = !1, this.webApp = !1, this.silk = !1, this.audioData = !1, this.webAudio = !1, this.ogg = !1, this.opus = !1, this.mp3 = !1, this.wav = !1, this.m4a = !1, this.webm = !1, this.iPhone = !1, this.iPhone4 = !1, this.iPad = !1, this.pixelRatio = 0, this.littleEndian = !1, this.support32bit = !1, this.fullscreen = !1, this.requestFullscreen = "", this.cancelFullscreen = "", this.fullscreenKeyboard = !1, this._checkOS(), this._checkAudio(), this._checkBrowser(), this._checkCSS3D(), this._checkDevice(), this._checkFeatures()
  6161. }, b.Device.LITTLE_ENDIAN = !1, b.Device.prototype = {
  6162. _checkOS: function() {
  6163. var a = navigator.userAgent;
  6164. /Playstation Vita/.test(a) ? this.vita = !0 : /Kindle/.test(a) || /\bKF[A-Z][A-Z]+/.test(a) || /Silk.*Mobile Safari/.test(a) ? this.kindle = !0 : /Android/.test(a) ? this.android = !0 : /CrOS/.test(a) ? this.chromeOS = !0 : /iP[ao]d|iPhone/i.test(a) ? this.iOS = !0 : /Linux/.test(a) ? this.linux = !0 : /Mac OS/.test(a) ? this.macOS = !0 : /Windows/.test(a) && (this.windows = !0, /Windows Phone/i.test(a) && (this.windowsPhone = !0)), (this.windows || this.macOS || this.linux && this.silk === !1 || this.chromeOS) && (this.desktop = !0), (this.windowsPhone || /Windows NT/i.test(a) && /Touch/i.test(a)) && (this.desktop = !1)
  6165. },
  6166. _checkFeatures: function() {
  6167. this.canvas = !!window.CanvasRenderingContext2D || this.cocoonJS;
  6168. try {
  6169. this.localStorage = !!localStorage.getItem
  6170. } catch (a) {
  6171. this.localStorage = !1
  6172. }
  6173. this.file = !!(window.File && window.FileReader && window.FileList && window.Blob), this.fileSystem = !!window.requestFileSystem, this.webGL = function() {
  6174. try {
  6175. var a = document.createElement("canvas");
  6176. return a.screencanvas = !1, !!window.WebGLRenderingContext && (a.getContext("webgl") || a.getContext("experimental-webgl"))
  6177. } catch (b) {
  6178. return !1
  6179. }
  6180. }(), this.webGL = null === this.webGL || this.webGL === !1 ? !1 : !0, this.worker = !!window.Worker, ("ontouchstart" in document.documentElement || window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1) && (this.touch = !0), (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) && (this.mspointer = !0), this.pointerLock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document, this.quirksMode = "CSS1Compat" === document.compatMode ? !1 : !0, this.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia)
  6181. },
  6182. checkFullScreenSupport: function() {
  6183. for (var a = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"], b = 0; b < a.length; b++)
  6184. if (this.game.canvas[a[b]]) {
  6185. this.fullscreen = !0, this.requestFullscreen = a[b];
  6186. break
  6187. }
  6188. var c = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
  6189. if (this.fullscreen)
  6190. for (var b = 0; b < c.length; b++)
  6191. if (document[c[b]]) {
  6192. this.cancelFullscreen = c[b];
  6193. break
  6194. }
  6195. window.Element && Element.ALLOW_KEYBOARD_INPUT && (this.fullscreenKeyboard = !0)
  6196. },
  6197. _checkBrowser: function() {
  6198. var a = navigator.userAgent;
  6199. if (/Arora/.test(a) ? this.arora = !0 : /Chrome/.test(a) ? this.chrome = !0 : /Epiphany/.test(a) ? this.epiphany = !0 : /Firefox/.test(a) ? this.firefox = !0 : /AppleWebKit/.test(a) && this.iOS ? this.mobileSafari = !0 : /MSIE(\d+\.\d+);/.test(a) ? (this.ie = !0, this.ieVersion = parseInt(RegExp.$1, 10)) : /Midori/.test(a) ? this.midori = !0 : /Opera/.test(a) ? this.opera = !0 : /Safari/.test(a) ? this.safari = !0 : /Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(a) && (this.ie = !0, this.trident = !0, this.tridentVersion = parseInt(RegExp.$1, 10), this.ieVersion = parseInt(RegExp.$3, 10)), /Silk/.test(a) && (this.silk = !0), navigator.standalone && (this.webApp = !0), "undefined" != typeof window.cordova && (this.cordova = !0), "undefined" != typeof process && "undefined" != typeof require && (this.node = !0), this.node) try {
  6200. this.nodeWebkit = "undefined" != typeof require("nw.gui")
  6201. } catch (b) {
  6202. this.nodeWebkit = !1
  6203. }
  6204. if (navigator.isCocoonJS && (this.cocoonJS = !0), this.cocoonJS) try {
  6205. this.cocoonJSApp = "undefined" != typeof CocoonJS
  6206. } catch (b) {
  6207. this.cocoonJSApp = !1
  6208. }
  6209. "undefined" != typeof window.ejecta && (this.ejecta = !0), /Crosswalk/.test(a) && (this.crosswalk = !0)
  6210. },
  6211. _checkAudio: function() {
  6212. this.audioData = !!window.Audio, this.webAudio = !(!window.webkitAudioContext && !window.AudioContext);
  6213. var a = document.createElement("audio"),
  6214. b = !1;
  6215. try {
  6216. (b = !!a.canPlayType) && (a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.ogg = !0), (a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, "") || a.canPlayType("audio/opus;").replace(/^no$/, "")) && (this.opus = !0), a.canPlayType("audio/mpeg;").replace(/^no$/, "") && (this.mp3 = !0), a.canPlayType('audio/wav; codecs="1"').replace(/^no$/, "") && (this.wav = !0), (a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/aac;").replace(/^no$/, "")) && (this.m4a = !0), a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "") && (this.webm = !0))
  6217. } catch (c) {}
  6218. },
  6219. _checkDevice: function() {
  6220. this.pixelRatio = window.devicePixelRatio || 1, this.iPhone = -1 != navigator.userAgent.toLowerCase().indexOf("iphone"), this.iPhone4 = 2 == this.pixelRatio && this.iPhone, this.iPad = -1 != navigator.userAgent.toLowerCase().indexOf("ipad"), this.typedArray = "undefined" != typeof Int8Array ? !0 : !1, "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array && "undefined" != typeof Uint32Array && (this.littleEndian = this._checkIsLittleEndian(), b.Device.LITTLE_ENDIAN = this.littleEndian), this.support32bit = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8ClampedArray && "undefined" != typeof Int32Array && null !== this.littleEndian && this._checkIsUint8ClampedImageData(), navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate, navigator.vibrate && (this.vibration = !0)
  6221. },
  6222. _checkIsLittleEndian: function() {
  6223. var a = new ArrayBuffer(4),
  6224. b = new Uint8Array(a),
  6225. c = new Uint32Array(a);
  6226. return b[0] = 161, b[1] = 178, b[2] = 195, b[3] = 212, 3569595041 == c[0] ? !0 : 2712847316 == c[0] ? !1 : null
  6227. },
  6228. _checkIsUint8ClampedImageData: function() {
  6229. if ("undefined" == typeof Uint8ClampedArray) return !1;
  6230. var a = document.createElement("canvas"),
  6231. b = a.getContext("2d");
  6232. if (!b) return !1;
  6233. var c = b.createImageData(1, 1);
  6234. return c.data instanceof Uint8ClampedArray
  6235. },
  6236. _checkCSS3D: function() {
  6237. var a, b = document.createElement("p"),
  6238. c = {
  6239. webkitTransform: "-webkit-transform",
  6240. OTransform: "-o-transform",
  6241. msTransform: "-ms-transform",
  6242. MozTransform: "-moz-transform",
  6243. transform: "transform"
  6244. };
  6245. document.body.insertBefore(b, null);
  6246. for (var d in c) void 0 !== b.style[d] && (b.style[d] = "translate3d(1px,1px,1px)", a = window.getComputedStyle(b).getPropertyValue(c[d]));
  6247. document.body.removeChild(b), this.css3D = void 0 !== a && a.length > 0 && "none" !== a
  6248. },
  6249. canPlayAudio: function(a) {
  6250. 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
  6251. },
  6252. isConsoleOpen: function() {
  6253. return window.console && window.console.firebug ? !0 : window.console && (console.profile(), console.profileEnd(), console.clear && console.clear(), console.profiles) ? console.profiles.length > 0 : !1
  6254. }
  6255. }, b.Device.prototype.constructor = b.Device, b.Device.isAndroidStockBrowser = function() {
  6256. var a = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
  6257. return a && a[1] < 537
  6258. }, b.RequestAnimationFrame = function(a, b) {
  6259. "undefined" == typeof b && (b = !1), this.game = a, this.isRunning = !1, this.forceSetTimeOut = b;
  6260. 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"];
  6261. this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
  6262. }, b.RequestAnimationFrame.prototype = {
  6263. start: function() {
  6264. this.isRunning = !0;
  6265. var a = this;
  6266. !window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() {
  6267. return a.updateSetTimeout()
  6268. }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(b) {
  6269. return a.updateRAF(b)
  6270. }, this._timeOutID = window.requestAnimationFrame(this._onLoop))
  6271. },
  6272. updateRAF: function() {
  6273. this.game.update(Date.now()), this._timeOutID = window.requestAnimationFrame(this._onLoop)
  6274. },
  6275. updateSetTimeout: function() {
  6276. this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)
  6277. },
  6278. stop: function() {
  6279. this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1
  6280. },
  6281. isSetTimeOut: function() {
  6282. return this._isSetTimeOut
  6283. },
  6284. isRAF: function() {
  6285. return this._isSetTimeOut === !1
  6286. }
  6287. }, b.RequestAnimationFrame.prototype.constructor = b.RequestAnimationFrame, b.Math = {
  6288. PI2: 2 * Math.PI,
  6289. fuzzyEqual: function(a, b, c) {
  6290. return "undefined" == typeof c && (c = 1e-4), Math.abs(a - b) < c
  6291. },
  6292. fuzzyLessThan: function(a, b, c) {
  6293. return "undefined" == typeof c && (c = 1e-4), b + c > a
  6294. },
  6295. fuzzyGreaterThan: function(a, b, c) {
  6296. return "undefined" == typeof c && (c = 1e-4), a > b - c
  6297. },
  6298. fuzzyCeil: function(a, b) {
  6299. return "undefined" == typeof b && (b = 1e-4), Math.ceil(a - b)
  6300. },
  6301. fuzzyFloor: function(a, b) {
  6302. return "undefined" == typeof b && (b = 1e-4), Math.floor(a + b)
  6303. },
  6304. average: function() {
  6305. for (var a = [], b = 0; b < arguments.length - 0; b++) a[b] = arguments[b + 0];
  6306. for (var c = 0, d = 0; d < a.length; d++) c += a[d];
  6307. return c / a.length
  6308. },
  6309. truncate: function(a) {
  6310. return a > 0 ? Math.floor(a) : Math.ceil(a)
  6311. },
  6312. shear: function(a) {
  6313. return a % 1
  6314. },
  6315. snapTo: function(a, b, c) {
  6316. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.round(a / b), c + a)
  6317. },
  6318. snapToFloor: function(a, b, c) {
  6319. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.floor(a / b), c + a)
  6320. },
  6321. snapToCeil: function(a, b, c) {
  6322. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.ceil(a / b), c + a)
  6323. },
  6324. snapToInArray: function(a, b, c) {
  6325. if ("undefined" == typeof c && (c = !0), c && b.sort(), a < b[0]) return b[0];
  6326. for (var d = 1; b[d] < a;) d++;
  6327. var e = b[d - 1],
  6328. f = d < b.length ? b[d] : Number.POSITIVE_INFINITY;
  6329. return a - e >= f - a ? f : e
  6330. },
  6331. roundTo: function(a, b, c) {
  6332. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6333. var d = Math.pow(c, -b);
  6334. return Math.round(a * d) / d
  6335. },
  6336. floorTo: function(a, b, c) {
  6337. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6338. var d = Math.pow(c, -b);
  6339. return Math.floor(a * d) / d
  6340. },
  6341. ceilTo: function(a, b, c) {
  6342. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  6343. var d = Math.pow(c, -b);
  6344. return Math.ceil(a * d) / d
  6345. },
  6346. interpolateFloat: function(a, b, c) {
  6347. return (b - a) * c + a
  6348. },
  6349. angleBetween: function(a, b, c, d) {
  6350. return Math.atan2(d - b, c - a)
  6351. },
  6352. angleBetweenY: function(a, b, c, d) {
  6353. return Math.atan2(c - a, d - b)
  6354. },
  6355. angleBetweenPoints: function(a, b) {
  6356. return Math.atan2(b.y - a.y, b.x - a.x)
  6357. },
  6358. angleBetweenPointsY: function(a, b) {
  6359. return Math.atan2(b.x - a.x, b.y - a.y)
  6360. },
  6361. reverseAngle: function(a) {
  6362. return this.normalizeAngle(a + Math.PI, !0)
  6363. },
  6364. normalizeAngle: function(a) {
  6365. return a %= 2 * Math.PI, a >= 0 ? a : a + 2 * Math.PI
  6366. },
  6367. normalizeLatitude: function(a) {
  6368. return Math.max(-90, Math.min(90, a))
  6369. },
  6370. normalizeLongitude: function(a) {
  6371. return a % 360 == 180 ? 180 : (a %= 360, -180 > a ? a + 360 : a > 180 ? a - 360 : a)
  6372. },
  6373. chanceRoll: function(a) {
  6374. return "undefined" == typeof a && (a = 50), 0 >= a ? !1 : a >= 100 ? !0 : 100 * Math.random() >= a ? !1 : !0
  6375. },
  6376. numberArray: function(a, b) {
  6377. for (var c = [], d = a; b >= d; d++) c.push(d);
  6378. return c
  6379. },
  6380. numberArrayStep: function(a, c, d) {
  6381. a = +a || 0;
  6382. var e = typeof c;
  6383. "number" !== e && "string" !== e || !d || d[c] !== a || (c = d = null), d = null == d ? 1 : +d || 0, null === c ? (c = a, a = 0) : c = +c || 0;
  6384. for (var f = -1, g = b.Math.max(b.Math.ceil((c - a) / (d || 1)), 0), h = new Array(g); ++f < g;) h[f] = a, a += d;
  6385. return h
  6386. },
  6387. maxAdd: function(a, b, c) {
  6388. return a += b, a > c && (a = c), a
  6389. },
  6390. minSub: function(a, b, c) {
  6391. return a -= b, c > a && (a = c), a
  6392. },
  6393. wrap: function(a, b, c) {
  6394. var d = c - b;
  6395. if (0 >= d) return 0;
  6396. var e = (a - b) % d;
  6397. return 0 > e && (e += d), e + b
  6398. },
  6399. wrapValue: function(a, b, c) {
  6400. var d;
  6401. return a = Math.abs(a), b = Math.abs(b), c = Math.abs(c), d = (a + b) % c
  6402. },
  6403. limitValue: function(a, b, c) {
  6404. return b > a ? b : a > c ? c : a
  6405. },
  6406. randomSign: function() {
  6407. return Math.random() > .5 ? 1 : -1
  6408. },
  6409. isOdd: function(a) {
  6410. return 1 & a
  6411. },
  6412. isEven: function(a) {
  6413. return 1 & a ? !1 : !0
  6414. },
  6415. min: function() {
  6416. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  6417. else var a = arguments;
  6418. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] < a[c] && (c = b);
  6419. return a[c]
  6420. },
  6421. max: function() {
  6422. if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
  6423. else var a = arguments;
  6424. for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] > a[c] && (c = b);
  6425. return a[c]
  6426. },
  6427. minProperty: function(a) {
  6428. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  6429. else var b = arguments.slice(1);
  6430. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] < b[d][a] && (d = c);
  6431. return b[d][a]
  6432. },
  6433. maxProperty: function(a) {
  6434. if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
  6435. else var b = arguments.slice(1);
  6436. for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] > b[d][a] && (d = c);
  6437. return b[d][a]
  6438. },
  6439. wrapAngle: function(a, b) {
  6440. var c = b ? Math.PI / 180 : 1;
  6441. return this.wrap(a, -180 * c, 180 * c)
  6442. },
  6443. angleLimit: function(a, b, c) {
  6444. var d = a;
  6445. return a > c ? d = c : b > a && (d = b), d
  6446. },
  6447. linearInterpolation: function(a, b) {
  6448. var c = a.length - 1,
  6449. d = c * b,
  6450. e = Math.floor(d);
  6451. 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)
  6452. },
  6453. bezierInterpolation: function(a, b) {
  6454. 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);
  6455. return c
  6456. },
  6457. catmullRomInterpolation: function(a, b) {
  6458. var c = a.length - 1,
  6459. d = c * b,
  6460. e = Math.floor(d);
  6461. 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)
  6462. },
  6463. linear: function(a, b, c) {
  6464. return (b - a) * c + a
  6465. },
  6466. bernstein: function(a, b) {
  6467. return this.factorial(a) / this.factorial(b) / this.factorial(a - b)
  6468. },
  6469. factorial: function(a) {
  6470. if (0 === a) return 1;
  6471. for (var b = a; --a;) b *= a;
  6472. return b
  6473. },
  6474. catmullRom: function(a, b, c, d, e) {
  6475. var f = .5 * (c - a),
  6476. g = .5 * (d - b),
  6477. h = e * e,
  6478. i = e * h;
  6479. return (2 * b - 2 * c + f + g) * i + (-3 * b + 3 * c - 2 * f - g) * h + f * e + b
  6480. },
  6481. difference: function(a, b) {
  6482. return Math.abs(a - b)
  6483. },
  6484. getRandom: function(a, b, c) {
  6485. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
  6486. var d = c;
  6487. if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) return a[b + Math.floor(Math.random() * d)]
  6488. }
  6489. return null
  6490. },
  6491. removeRandom: function(a, b, c) {
  6492. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
  6493. var d = c;
  6494. if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) {
  6495. var e = b + Math.floor(Math.random() * d),
  6496. f = a.splice(e, 1);
  6497. return f[0]
  6498. }
  6499. }
  6500. return null
  6501. },
  6502. floor: function(a) {
  6503. var b = 0 | a;
  6504. return a > 0 ? b : b != a ? b - 1 : b
  6505. },
  6506. ceil: function(a) {
  6507. var b = 0 | a;
  6508. return a > 0 && b != a ? b + 1 : b
  6509. },
  6510. sinCosGenerator: function(a, b, c, d) {
  6511. "undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1);
  6512. 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;
  6513. return {
  6514. sin: i,
  6515. cos: h,
  6516. length: a
  6517. }
  6518. },
  6519. shift: function(a) {
  6520. var b = a.shift();
  6521. return a.push(b), b
  6522. },
  6523. shuffleArray: function(a) {
  6524. for (var b = a.length - 1; b > 0; b--) {
  6525. var c = Math.floor(Math.random() * (b + 1)),
  6526. d = a[b];
  6527. a[b] = a[c], a[c] = d
  6528. }
  6529. return a
  6530. },
  6531. distance: function(a, b, c, d) {
  6532. var e = a - c,
  6533. f = b - d;
  6534. return Math.sqrt(e * e + f * f)
  6535. },
  6536. distancePow: function(a, b, c, d, e) {
  6537. return "undefined" == typeof e && (e = 2), Math.sqrt(Math.pow(c - a, e) + Math.pow(d - b, e))
  6538. },
  6539. distanceRounded: function(a, c, d, e) {
  6540. return Math.round(b.Math.distance(a, c, d, e))
  6541. },
  6542. clamp: function(a, b, c) {
  6543. return b > a ? b : a > c ? c : a
  6544. },
  6545. clampBottom: function(a, b) {
  6546. return b > a ? b : a
  6547. },
  6548. within: function(a, b, c) {
  6549. return Math.abs(a - b) <= c
  6550. },
  6551. mapLinear: function(a, b, c, d, e) {
  6552. return d + (a - b) * (e - d) / (c - b)
  6553. },
  6554. smoothstep: function(a, b, c) {
  6555. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * (3 - 2 * a)
  6556. },
  6557. smootherstep: function(a, b, c) {
  6558. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * a * (a * (6 * a - 15) + 10)
  6559. },
  6560. sign: function(a) {
  6561. return 0 > a ? -1 : a > 0 ? 1 : 0
  6562. },
  6563. percent: function(a, b, c) {
  6564. return "undefined" == typeof c && (c = 0), a > b || c > b ? 1 : c > a || c > a ? 0 : (a - c) / b
  6565. },
  6566. degToRad: function() {
  6567. var a = Math.PI / 180;
  6568. return function(b) {
  6569. return b * a
  6570. }
  6571. }(),
  6572. radToDeg: function() {
  6573. var a = 180 / Math.PI;
  6574. return function(b) {
  6575. return b * a
  6576. }
  6577. }()
  6578. }, b.RandomDataGenerator = function(a) {
  6579. "undefined" == typeof a && (a = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.sow(a)
  6580. }, b.RandomDataGenerator.prototype = {
  6581. rnd: function() {
  6582. var a = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c;
  6583. return this.c = 0 | a, this.s0 = this.s1, this.s1 = this.s2, this.s2 = a - this.c, this.s2
  6584. },
  6585. sow: function(a) {
  6586. "undefined" == typeof a && (a = []), this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1;
  6587. for (var b, c = 0; b = a[c++];) this.s0 -= this.hash(b), this.s0 += ~~(this.s0 < 0), this.s1 -= this.hash(b), this.s1 += ~~(this.s1 < 0), this.s2 -= this.hash(b), this.s2 += ~~(this.s2 < 0)
  6588. },
  6589. hash: function(a) {
  6590. var b, c, d;
  6591. 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;
  6592. return 2.3283064365386963e-10 * (d >>> 0)
  6593. },
  6594. integer: function() {
  6595. return 4294967296 * this.rnd.apply(this)
  6596. },
  6597. frac: function() {
  6598. return this.rnd.apply(this) + 1.1102230246251565e-16 * (2097152 * this.rnd.apply(this) | 0)
  6599. },
  6600. real: function() {
  6601. return this.integer() + this.frac()
  6602. },
  6603. integerInRange: function(a, b) {
  6604. return Math.floor(this.realInRange(0, b - a + 1) + a)
  6605. },
  6606. between: function(a, b) {
  6607. return this.integerInRange(a, b)
  6608. },
  6609. realInRange: function(a, b) {
  6610. return this.frac() * (b - a) + a
  6611. },
  6612. normal: function() {
  6613. return 1 - 2 * this.frac()
  6614. },
  6615. uuid: function() {
  6616. var a = "",
  6617. b = "";
  6618. for (b = a = ""; a++ < 36; b += ~a % 5 | 3 * a & 4 ? (15 ^ a ? 8 ^ this.frac() * (20 ^ a ? 16 : 4) : 4).toString(16) : "-");
  6619. return b
  6620. },
  6621. pick: function(a) {
  6622. return a[this.integerInRange(0, a.length - 1)]
  6623. },
  6624. weightedPick: function(a) {
  6625. return a[~~(Math.pow(this.frac(), 2) * (a.length - 1))]
  6626. },
  6627. timestamp: function(a, b) {
  6628. return this.realInRange(a || 9466848e5, b || 1577862e6)
  6629. },
  6630. angle: function() {
  6631. return this.integerInRange(-180, 180)
  6632. }
  6633. }, b.RandomDataGenerator.prototype.constructor = b.RandomDataGenerator, b.QuadTree = function(a, b, c, d, e, f, g) {
  6634. 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)
  6635. }, b.QuadTree.prototype = {
  6636. reset: function(a, b, c, d, e, f, g) {
  6637. this.maxObjects = e || 10, this.maxLevels = f || 4, this.level = g || 0, this.bounds = {
  6638. x: Math.round(a),
  6639. y: Math.round(b),
  6640. width: c,
  6641. height: d,
  6642. subWidth: Math.floor(c / 2),
  6643. subHeight: Math.floor(d / 2),
  6644. right: Math.round(a) + Math.floor(c / 2),
  6645. bottom: Math.round(b) + Math.floor(d / 2)
  6646. }, this.objects.length = 0, this.nodes.length = 0
  6647. },
  6648. populate: function(a) {
  6649. a.forEach(this.populateHandler, this, !0)
  6650. },
  6651. populateHandler: function(a) {
  6652. a.body && a.exists && this.insert(a.body)
  6653. },
  6654. split: function() {
  6655. this.nodes[0] = new b.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[1] = new b.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[2] = new b.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[3] = new b.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1)
  6656. },
  6657. insert: function(a) {
  6658. var b, c = 0;
  6659. if (null != this.nodes[0] && (b = this.getIndex(a), -1 !== b)) return void this.nodes[b].insert(a);
  6660. if (this.objects.push(a), this.objects.length > this.maxObjects && this.level < this.maxLevels)
  6661. 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++
  6662. },
  6663. getIndex: function(a) {
  6664. var b = -1;
  6665. 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
  6666. },
  6667. retrieve: function(a) {
  6668. if (a instanceof b.Rectangle) var c = this.objects,
  6669. d = this.getIndex(a);
  6670. else {
  6671. if (!a.body) return this._empty;
  6672. var c = this.objects,
  6673. d = this.getIndex(a.body)
  6674. }
  6675. return this.nodes[0] && (-1 !== d ? c = c.concat(this.nodes[d].retrieve(a)) : (c = c.concat(this.nodes[0].retrieve(a)), c = c.concat(this.nodes[1].retrieve(a)), c = c.concat(this.nodes[2].retrieve(a)), c = c.concat(this.nodes[3].retrieve(a)))), c
  6676. },
  6677. clear: function() {
  6678. this.objects.length = 0;
  6679. for (var a = this.nodes.length; a--;) this.nodes[a].clear(), this.nodes.splice(a, 1);
  6680. this.nodes.length = 0
  6681. }
  6682. }, b.QuadTree.prototype.constructor = b.QuadTree, b.Net = function(a) {
  6683. this.game = a
  6684. }, b.Net.prototype = {
  6685. getHostName: function() {
  6686. return window.location && window.location.hostname ? window.location.hostname : null
  6687. },
  6688. checkDomainName: function(a) {
  6689. return -1 !== window.location.hostname.indexOf(a)
  6690. },
  6691. updateQueryString: function(a, b, c, d) {
  6692. "undefined" == typeof c && (c = !1), ("undefined" == typeof d || "" === d) && (d = window.location.href);
  6693. var e = "",
  6694. f = new RegExp("([?|&])" + a + "=.*?(&|#|$)(.*)", "gi");
  6695. if (f.test(d)) e = "undefined" != typeof b && null !== b ? d.replace(f, "$1" + a + "=" + b + "$2$3") : d.replace(f, "$1$3").replace(/(&|\?)$/, "");
  6696. else if ("undefined" != typeof b && null !== b) {
  6697. var g = -1 !== d.indexOf("?") ? "&" : "?",
  6698. h = d.split("#");
  6699. d = h[0] + g + a + "=" + b, h[1] && (d += "#" + h[1]), e = d
  6700. } else e = d;
  6701. return c ? void(window.location.href = e) : e
  6702. },
  6703. getQueryString: function(a) {
  6704. "undefined" == typeof a && (a = "");
  6705. var b = {},
  6706. c = location.search.substring(1).split("&");
  6707. for (var d in c) {
  6708. var e = c[d].split("=");
  6709. if (e.length > 1) {
  6710. if (a && a == this.decodeURI(e[0])) return this.decodeURI(e[1]);
  6711. b[this.decodeURI(e[0])] = this.decodeURI(e[1])
  6712. }
  6713. }
  6714. return b
  6715. },
  6716. decodeURI: function(a) {
  6717. return decodeURIComponent(a.replace(/\+/g, " "))
  6718. }
  6719. }, b.Net.prototype.constructor = b.Net, b.TweenManager = function(a) {
  6720. this.game = a, this._tweens = [], this._add = [], this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this)
  6721. }, b.TweenManager.prototype = {
  6722. getAll: function() {
  6723. return this._tweens
  6724. },
  6725. removeAll: function() {
  6726. for (var a = 0; a < this._tweens.length; a++) this._tweens[a].pendingDelete = !0;
  6727. this._add = []
  6728. },
  6729. add: function(a) {
  6730. a._manager = this, this._add.push(a)
  6731. },
  6732. create: function(a) {
  6733. return new b.Tween(a, this.game, this)
  6734. },
  6735. remove: function(a) {
  6736. 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))
  6737. },
  6738. update: function() {
  6739. var a = this._add.length,
  6740. b = this._tweens.length;
  6741. if (0 === b && 0 === a) return !1;
  6742. for (var c = 0; b > c;) this._tweens[c].update(this.game.time.now) ? c++ : (this._tweens.splice(c, 1), b--);
  6743. return a > 0 && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
  6744. },
  6745. isTweening: function(a) {
  6746. return this._tweens.some(function(b) {
  6747. return b._object === a
  6748. })
  6749. },
  6750. _pauseAll: function() {
  6751. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._pause()
  6752. },
  6753. _resumeAll: function() {
  6754. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._resume()
  6755. },
  6756. pauseAll: function() {
  6757. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].pause()
  6758. },
  6759. resumeAll: function() {
  6760. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].resume(!0)
  6761. }
  6762. }, b.TweenManager.prototype.constructor = b.TweenManager, b.Tween = function(a, c, d) {
  6763. this._object = a, this.game = c, this._manager = d, this._valuesStart = {}, this._valuesEnd = {}, this._valuesStartRepeat = {}, this._duration = 1e3, this._repeat = 0, this._yoyo = !1, this._reversed = !1, this._delayTime = 0, this._startTime = null, this._easingFunction = b.Easing.Default, this._interpolationFunction = b.Math.linearInterpolation, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, this._paused = !1, this._pausedTime = 0, this._codePaused = !1, this.pendingDelete = !1, this.onStart = new b.Signal, this.onLoop = new b.Signal, this.onComplete = new b.Signal, this.isRunning = !1
  6764. }, b.Tween.prototype = {
  6765. to: function(a, b, c, d, e, f, g) {
  6766. b = b || 1e3, c = c || null, d = d || !1, e = e || 0, f = f || 0, g = g || !1, g && 0 === f && (f = 1);
  6767. var h;
  6768. return this._parent ? (h = this._manager.create(this._object), this._lastChild.chain(h), this._lastChild = h) : (h = this, this._parent = this, this._lastChild = this), h._repeat = f, h._duration = b, h._valuesEnd = a, null !== c && (h._easingFunction = c), e > 0 && (h._delayTime = e), h._yoyo = g, d ? this.start() : this
  6769. },
  6770. from: function(a, b, c, d, e, f, g) {
  6771. var h = {};
  6772. for (var i in a) h[i] = this._object[i], this._object[i] = a[i];
  6773. return this.to(h, b, c, d, e, f, g)
  6774. },
  6775. start: function() {
  6776. if (null !== this.game && null !== this._object) {
  6777. this._manager.add(this), this.isRunning = !0, this._onStartCallbackFired = !1, this._startTime = this.game.time.now + this._delayTime;
  6778. for (var a in this._valuesEnd) {
  6779. if (Array.isArray(this._valuesEnd[a])) {
  6780. if (0 === this._valuesEnd[a].length) continue;
  6781. this._valuesEnd[a] = [this._object[a]].concat(this._valuesEnd[a])
  6782. }
  6783. this._valuesStart[a] = this._object[a], Array.isArray(this._valuesStart[a]) || (this._valuesStart[a] *= 1), this._valuesStartRepeat[a] = this._valuesStart[a] || 0
  6784. }
  6785. return this
  6786. }
  6787. },
  6788. generateData: function(a, b) {
  6789. if (null === this.game || null === this._object) return null;
  6790. this._startTime = 0;
  6791. for (var c in this._valuesEnd) {
  6792. if (Array.isArray(this._valuesEnd[c])) {
  6793. if (0 === this._valuesEnd[c].length) continue;
  6794. this._valuesEnd[c] = [this._object[c]].concat(this._valuesEnd[c])
  6795. }
  6796. this._valuesStart[c] = this._object[c], Array.isArray(this._valuesStart[c]) || (this._valuesStart[c] *= 1), this._valuesStartRepeat[c] = this._valuesStart[c] || 0
  6797. }
  6798. for (var d = 0, e = Math.floor(a * (this._duration / 1e3)), f = this._duration / e, g = []; e--;) {
  6799. var c, h = (d - this._startTime) / this._duration;
  6800. h = h > 1 ? 1 : h;
  6801. var i = this._easingFunction(h),
  6802. j = {};
  6803. for (c in this._valuesEnd) {
  6804. var k = this._valuesStart[c] || 0,
  6805. l = this._valuesEnd[c];
  6806. l instanceof Array ? j[c] = this._interpolationFunction(l, i) : "string" == typeof l ? l = k + parseFloat(l, 10) : "number" == typeof l && (j[c] = k + (l - k) * i)
  6807. }
  6808. g.push(j), d += f
  6809. }
  6810. var j = {};
  6811. for (c in this._valuesEnd) j[c] = this._valuesEnd[c];
  6812. if (g.push(j), this._yoyo) {
  6813. var m = g.slice();
  6814. m.reverse(), g = g.concat(m)
  6815. }
  6816. return "undefined" != typeof b ? b = b.concat(g) : g
  6817. },
  6818. stop: function() {
  6819. return this.isRunning = !1, this._onUpdateCallback = null, this._manager.remove(this), this
  6820. },
  6821. delay: function(a) {
  6822. return this._delayTime = a, this
  6823. },
  6824. repeat: function(a) {
  6825. return this._repeat = a, this
  6826. },
  6827. yoyo: function(a) {
  6828. return this._yoyo = a, a && 0 === this._repeat && (this._repeat = 1), this
  6829. },
  6830. easing: function(a) {
  6831. return this._easingFunction = a, this
  6832. },
  6833. interpolation: function(a) {
  6834. return this._interpolationFunction = a, this
  6835. },
  6836. chain: function() {
  6837. return this._chainedTweens = arguments, this
  6838. },
  6839. loop: function() {
  6840. return this._lastChild.chain(this), this
  6841. },
  6842. onUpdateCallback: function(a, b) {
  6843. return this._onUpdateCallback = a, this._onUpdateCallbackContext = b, this
  6844. },
  6845. pause: function() {
  6846. this._codePaused = !0, this._paused = !0, this._pausedTime = this.game.time.now
  6847. },
  6848. _pause: function() {
  6849. this._codePaused || (this._paused = !0, this._pausedTime = this.game.time.now)
  6850. },
  6851. resume: function() {
  6852. this._paused && (this._paused = !1, this._codePaused = !1, this._startTime += this.game.time.now - this._pausedTime)
  6853. },
  6854. _resume: function() {
  6855. this._codePaused || (this._startTime += this.game.time.pauseDuration, this._paused = !1)
  6856. },
  6857. update: function(a) {
  6858. if (this.pendingDelete) return !1;
  6859. if (this._paused || a < this._startTime) return !0;
  6860. var b;
  6861. if (a < this._startTime) return !0;
  6862. this._onStartCallbackFired === !1 && (this.onStart.dispatch(this._object), this._onStartCallbackFired = !0);
  6863. var c = (a - this._startTime) / this._duration;
  6864. c = c > 1 ? 1 : c;
  6865. var d = this._easingFunction(c);
  6866. for (b in this._valuesEnd) {
  6867. var e = this._valuesStart[b] || 0,
  6868. f = this._valuesEnd[b];
  6869. f instanceof Array ? this._object[b] = this._interpolationFunction(f, d) : ("string" == typeof f && (f = e + parseFloat(f, 10)), "number" == typeof f && (this._object[b] = e + (f - e) * d))
  6870. }
  6871. if (null !== this._onUpdateCallback && (this._onUpdateCallback.call(this._onUpdateCallbackContext, this, d), !this.isRunning)) return !1;
  6872. if (1 == c) {
  6873. if (this._repeat > 0) {
  6874. isFinite(this._repeat) && this._repeat--;
  6875. for (b in this._valuesStartRepeat) {
  6876. if ("string" == typeof this._valuesEnd[b] && (this._valuesStartRepeat[b] = this._valuesStartRepeat[b] + parseFloat(this._valuesEnd[b], 10)), this._yoyo) {
  6877. var g = this._valuesStartRepeat[b];
  6878. this._valuesStartRepeat[b] = this._valuesEnd[b], this._valuesEnd[b] = g
  6879. }
  6880. this._valuesStart[b] = this._valuesStartRepeat[b]
  6881. }
  6882. return this._yoyo && (this._reversed = !this._reversed), this._startTime = a + this._delayTime, this.onLoop.dispatch(this._object), !0
  6883. }
  6884. this.isRunning = !1, this.onComplete.dispatch(this._object);
  6885. for (var h = 0, i = this._chainedTweens.length; i > h; h++) this._chainedTweens[h].start(a);
  6886. return !1
  6887. }
  6888. return !0
  6889. }
  6890. }, b.Tween.prototype.constructor = b.Tween, b.Easing = {
  6891. Linear: {
  6892. None: function(a) {
  6893. return a
  6894. }
  6895. },
  6896. Quadratic: {
  6897. In: function(a) {
  6898. return a * a
  6899. },
  6900. Out: function(a) {
  6901. return a * (2 - a)
  6902. },
  6903. InOut: function(a) {
  6904. return (a *= 2) < 1 ? .5 * a * a : -.5 * (--a * (a - 2) - 1)
  6905. }
  6906. },
  6907. Cubic: {
  6908. In: function(a) {
  6909. return a * a * a
  6910. },
  6911. Out: function(a) {
  6912. return --a * a * a + 1
  6913. },
  6914. InOut: function(a) {
  6915. return (a *= 2) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2)
  6916. }
  6917. },
  6918. Quartic: {
  6919. In: function(a) {
  6920. return a * a * a * a
  6921. },
  6922. Out: function(a) {
  6923. return 1 - --a * a * a * a
  6924. },
  6925. InOut: function(a) {
  6926. return (a *= 2) < 1 ? .5 * a * a * a * a : -.5 * ((a -= 2) * a * a * a - 2)
  6927. }
  6928. },
  6929. Quintic: {
  6930. In: function(a) {
  6931. return a * a * a * a * a
  6932. },
  6933. Out: function(a) {
  6934. return --a * a * a * a * a + 1
  6935. },
  6936. InOut: function(a) {
  6937. return (a *= 2) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2)
  6938. }
  6939. },
  6940. Sinusoidal: {
  6941. In: function(a) {
  6942. return 1 - Math.cos(a * Math.PI / 2)
  6943. },
  6944. Out: function(a) {
  6945. return Math.sin(a * Math.PI / 2)
  6946. },
  6947. InOut: function(a) {
  6948. return .5 * (1 - Math.cos(Math.PI * a))
  6949. }
  6950. },
  6951. Exponential: {
  6952. In: function(a) {
  6953. return 0 === a ? 0 : Math.pow(1024, a - 1)
  6954. },
  6955. Out: function(a) {
  6956. return 1 === a ? 1 : 1 - Math.pow(2, -10 * a)
  6957. },
  6958. InOut: function(a) {
  6959. return 0 === a ? 0 : 1 === a ? 1 : (a *= 2) < 1 ? .5 * Math.pow(1024, a - 1) : .5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  6960. }
  6961. },
  6962. Circular: {
  6963. In: function(a) {
  6964. return 1 - Math.sqrt(1 - a * a)
  6965. },
  6966. Out: function(a) {
  6967. return Math.sqrt(1 - --a * a)
  6968. },
  6969. InOut: function(a) {
  6970. return (a *= 2) < 1 ? -.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  6971. }
  6972. },
  6973. Elastic: {
  6974. In: function(a) {
  6975. var b, c = .1,
  6976. d = .4;
  6977. 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)))
  6978. },
  6979. Out: function(a) {
  6980. var b, c = .1,
  6981. d = .4;
  6982. 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)
  6983. },
  6984. InOut: function(a) {
  6985. var b, c = .1,
  6986. d = .4;
  6987. 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)
  6988. }
  6989. },
  6990. Back: {
  6991. In: function(a) {
  6992. var b = 1.70158;
  6993. return a * a * ((b + 1) * a - b)
  6994. },
  6995. Out: function(a) {
  6996. var b = 1.70158;
  6997. return --a * a * ((b + 1) * a + b) + 1
  6998. },
  6999. InOut: function(a) {
  7000. var b = 2.5949095;
  7001. return (a *= 2) < 1 ? .5 * a * a * ((b + 1) * a - b) : .5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
  7002. }
  7003. },
  7004. Bounce: {
  7005. In: function(a) {
  7006. return 1 - b.Easing.Bounce.Out(1 - a)
  7007. },
  7008. Out: function(a) {
  7009. 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
  7010. },
  7011. InOut: function(a) {
  7012. return .5 > a ? .5 * b.Easing.Bounce.In(2 * a) : .5 * b.Easing.Bounce.Out(2 * a - 1) + .5
  7013. }
  7014. }
  7015. }, b.Easing.Default = b.Easing.Linear.None, b.Time = function(a) {
  7016. this.game = a, this.time = 0, this.prevTime = 0, this.now = 0, this.elapsed = 0, this.pausedTime = 0, this.advancedTiming = !1, this.fps = 0, this.fpsMin = 1e3, this.fpsMax = 0, this.msMin = 1e3, this.msMax = 0, this.physicsElapsed = 0, this.deltaCap = 0, this.timeCap = 1 / 60 * 1e3, this.frames = 0, this.pauseDuration = 0, this.timeToCall = 0, this.lastTime = 0, this.events = new b.Timer(this.game, !1), this._started = 0, this._timeLastSecond = 0, this._pauseStarted = 0, this._justResumed = !1, this._timers = [], this._len = 0, this._i = 0
  7017. }, b.Time.prototype = {
  7018. boot: function() {
  7019. this._started = Date.now(), this.events.start()
  7020. },
  7021. add: function(a) {
  7022. return this._timers.push(a), a
  7023. },
  7024. create: function(a) {
  7025. "undefined" == typeof a && (a = !0);
  7026. var c = new b.Timer(this.game, a);
  7027. return this._timers.push(c), c
  7028. },
  7029. removeAll: function() {
  7030. for (var a = 0; a < this._timers.length; a++) this._timers[a].destroy();
  7031. this._timers = [], this.events.removeAll()
  7032. },
  7033. update: function(a) {
  7034. if (this.prevTime = this.now, this.now = a, this.timeToCall = this.game.math.max(0, 16 - (a - this.lastTime)), this.elapsed = this.now - this.time, this.elapsed > this.timeCap && (this.elapsed = this.timeCap), this.physicsElapsed = this.elapsed / 1e3 || 1 / 60, this.deltaCap > 0 && this.physicsElapsed > this.deltaCap && (this.physicsElapsed = this.deltaCap), this.advancedTiming && (this.msMin = this.game.math.min(this.msMin, this.elapsed), this.msMax = this.game.math.max(this.msMax, this.elapsed), this.frames++, this.now > this._timeLastSecond + 1e3 && (this.fps = Math.round(1e3 * this.frames / (this.now - this._timeLastSecond)), this.fpsMin = this.game.math.min(this.fpsMin, this.fps), this.fpsMax = this.game.math.max(this.fpsMax, this.fps), this._timeLastSecond = this.now, this.frames = 0)), this.time = this.now, this.lastTime = a + this.timeToCall, !this.game.paused)
  7035. for (this.events.update(this.now), this._i = 0, this._len = this._timers.length; this._i < this._len;) this._timers[this._i].update(this.now) ? this._i++ : (this._timers.splice(this._i, 1), this._len--)
  7036. },
  7037. gamePaused: function() {
  7038. this._pauseStarted = this.now, this.events.pause();
  7039. for (var a = this._timers.length; a--;) this._timers[a]._pause()
  7040. },
  7041. gameResumed: function() {
  7042. this.time = this.now = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume();
  7043. for (var a = this._timers.length; a--;) this._timers[a]._resume()
  7044. },
  7045. totalElapsedSeconds: function() {
  7046. return .001 * (this.now - this._started)
  7047. },
  7048. elapsedSince: function(a) {
  7049. return this.now - a
  7050. },
  7051. elapsedSecondsSince: function(a) {
  7052. return .001 * (this.now - a)
  7053. },
  7054. reset: function() {
  7055. this._started = this.now, this.removeAll()
  7056. }
  7057. }, b.Time.prototype.constructor = b.Time, b.Timer = function(a, c) {
  7058. "undefined" == typeof c && (c = !0), this.game = a, this.running = !1, this.autoDestroy = c, this.expired = !1, this.elapsed = 0, this.events = [], this.onComplete = new b.Signal, this.nextTick = 0, this.timeCap = 1e3, this.paused = !1, this._codePaused = !1, this._started = 0, this._pauseStarted = 0, this._pauseTotal = 0, this._now = Date.now(), this._len = 0, this._marked = 0, this._i = 0, this._diff = 0, this._newTick = 0
  7059. }, b.Timer.MINUTE = 6e4, b.Timer.SECOND = 1e3, b.Timer.HALF = 500, b.Timer.QUARTER = 250, b.Timer.prototype = {
  7060. create: function(a, c, d, e, f, g) {
  7061. a = Math.round(a);
  7062. var h = a;
  7063. h += 0 === this._now ? this.game.time.now : this._now;
  7064. var i = new b.TimerEvent(this, a, h, d, c, e, f, g);
  7065. return this.events.push(i), this.order(), this.expired = !1, i
  7066. },
  7067. add: function(a, b, c) {
  7068. return this.create(a, !1, 0, b, c, Array.prototype.splice.call(arguments, 3))
  7069. },
  7070. repeat: function(a, b, c, d) {
  7071. return this.create(a, !1, b, c, d, Array.prototype.splice.call(arguments, 4))
  7072. },
  7073. loop: function(a, b, c) {
  7074. return this.create(a, !0, 0, b, c, Array.prototype.splice.call(arguments, 3))
  7075. },
  7076. start: function(a) {
  7077. if (!this.running) {
  7078. this._started = this.game.time.now + (a || 0), this.running = !0;
  7079. for (var b = 0; b < this.events.length; b++) this.events[b].tick = this.events[b].delay + this._started
  7080. }
  7081. },
  7082. stop: function(a) {
  7083. this.running = !1, "undefined" == typeof a && (a = !0), a && (this.events.length = 0)
  7084. },
  7085. remove: function(a) {
  7086. for (var b = 0; b < this.events.length; b++)
  7087. if (this.events[b] === a) return this.events[b].pendingDelete = !0, !0;
  7088. return !1
  7089. },
  7090. order: function() {
  7091. this.events.length > 0 && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick)
  7092. },
  7093. sortHandler: function(a, b) {
  7094. return a.tick < b.tick ? -1 : a.tick > b.tick ? 1 : 0
  7095. },
  7096. clearPendingEvents: function() {
  7097. for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
  7098. this._len = this.events.length, this._i = 0
  7099. },
  7100. update: function(a) {
  7101. if (this.paused) return !0;
  7102. 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) {
  7103. for (; this._i < this._len && this.running && this._now >= this.events[this._i].tick;) this._newTick = this._now + this.events[this._i].delay - (this._now - this.events[this._i].tick), this._newTick < 0 && (this._newTick = this._now + this.events[this._i].delay), this.events[this._i].loop === !0 ? (this.events[this._i].tick = this._newTick, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)) : this.events[this._i].repeatCount > 0 ? (this.events[this._i].repeatCount--, this.events[this._i].tick = this._newTick, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)) : (this._marked++, this.events[this._i].pendingDelete = !0, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)), this._i++;
  7104. this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
  7105. }
  7106. return this.expired && this.autoDestroy ? !1 : !0
  7107. },
  7108. pause: function() {
  7109. this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.now, this.paused = !0))
  7110. },
  7111. _pause: function() {
  7112. !this.paused && this.running && (this._pauseStarted = this.game.time.now, this.paused = !0)
  7113. },
  7114. adjustEvents: function(a) {
  7115. for (var b = 0; b < this.events.length; b++)
  7116. if (!this.events[b].pendingDelete) {
  7117. var c = this.events[b].tick - a;
  7118. 0 > c && (c = 0), this.events[b].tick = this._now + c
  7119. }
  7120. var d = this.nextTick - a;
  7121. this.nextTick = 0 > d ? this._now : this._now + d
  7122. },
  7123. resume: function() {
  7124. if (this.paused) {
  7125. var a = this.game.time.now;
  7126. this._pauseTotal += a - this._now, this._now = a, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
  7127. }
  7128. },
  7129. _resume: function() {
  7130. this._codePaused || this.resume()
  7131. },
  7132. removeAll: function() {
  7133. this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0
  7134. },
  7135. destroy: function() {
  7136. this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0
  7137. }
  7138. }, Object.defineProperty(b.Timer.prototype, "next", {
  7139. get: function() {
  7140. return this.nextTick
  7141. }
  7142. }), Object.defineProperty(b.Timer.prototype, "duration", {
  7143. get: function() {
  7144. return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0
  7145. }
  7146. }), Object.defineProperty(b.Timer.prototype, "length", {
  7147. get: function() {
  7148. return this.events.length
  7149. }
  7150. }), Object.defineProperty(b.Timer.prototype, "ms", {
  7151. get: function() {
  7152. return this.running ? this._now - this._started - this._pauseTotal : 0
  7153. }
  7154. }), Object.defineProperty(b.Timer.prototype, "seconds", {
  7155. get: function() {
  7156. return this.running ? .001 * this.ms : 0
  7157. }
  7158. }), b.Timer.prototype.constructor = b.Timer, b.TimerEvent = function(a, b, c, d, e, f, g, h) {
  7159. 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
  7160. }, b.TimerEvent.prototype.constructor = b.TimerEvent, b.AnimationManager = function(a) {
  7161. 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 = []
  7162. }, b.AnimationManager.prototype = {
  7163. loadFrameData: function(a, b) {
  7164. if ("undefined" == typeof a) return !1;
  7165. if (this.isLoaded)
  7166. for (var c in this._anims) this._anims[c].updateFrameData(a);
  7167. 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
  7168. },
  7169. copyFrameData: function(a, b) {
  7170. if (this._frameData = a.clone(), this.isLoaded)
  7171. for (var c in this._anims) this._anims[c].updateFrameData(this._frameData);
  7172. return "undefined" == typeof b || null === b ? this.frame = 0 : "string" == typeof b ? this.frameName = b : this.frame = b, this.isLoaded = !0, !0
  7173. },
  7174. add: function(a, c, d, e, f) {
  7175. return c = c || [], d = d || 60, "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = c && "number" == typeof c[0] ? !0 : !1), null === this.sprite.events.onAnimationStart && (this.sprite.events.onAnimationStart = new b.Signal, this.sprite.events.onAnimationComplete = new b.Signal, this.sprite.events.onAnimationLoop = new b.Signal), this._outputFrames.length = 0, this._frameData.getFrameIndexes(c, f, this._outputFrames), this._anims[a] = new b.Animation(this.game, this.sprite, a, this._frameData, this._outputFrames, d, e), this.currentAnim = this._anims[a], this.currentFrame = this.currentAnim.currentFrame, this.sprite.__tilePattern && (this.sprite.__tilePattern = !1, this.tilingTexture = !1), this._anims[a]
  7176. },
  7177. validateFrames: function(a, b) {
  7178. "undefined" == typeof b && (b = !0);
  7179. for (var c = 0; c < a.length; c++)
  7180. if (b === !0) {
  7181. if (a[c] > this._frameData.total) return !1
  7182. } else if (this._frameData.checkFrameName(a[c]) === !1) return !1;
  7183. return !0
  7184. },
  7185. play: function(a, b, c, d) {
  7186. 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
  7187. },
  7188. stop: function(a, b) {
  7189. "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)
  7190. },
  7191. update: function() {
  7192. return this.updateIfVisible && !this.sprite.visible ? !1 : this.currentAnim && this.currentAnim.update() === !0 ? (this.currentFrame = this.currentAnim.currentFrame, !0) : !1
  7193. },
  7194. next: function(a) {
  7195. this.currentAnim && (this.currentAnim.next(a), this.currentFrame = this.currentAnim.currentFrame)
  7196. },
  7197. previous: function(a) {
  7198. this.currentAnim && (this.currentAnim.previous(a), this.currentFrame = this.currentAnim.currentFrame)
  7199. },
  7200. getAnimation: function(a) {
  7201. return "string" == typeof a && this._anims[a] ? this._anims[a] : null
  7202. },
  7203. refreshFrame: function() {
  7204. this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)
  7205. },
  7206. destroy: function() {
  7207. var a = null;
  7208. for (var a in this._anims) this._anims.hasOwnProperty(a) && this._anims[a].destroy();
  7209. this._anims = {}, this._frameData = null, this._frameIndex = 0, this.currentAnim = null, this.currentFrame = null
  7210. }
  7211. }, b.AnimationManager.prototype.constructor = b.AnimationManager, Object.defineProperty(b.AnimationManager.prototype, "frameData", {
  7212. get: function() {
  7213. return this._frameData
  7214. }
  7215. }), Object.defineProperty(b.AnimationManager.prototype, "frameTotal", {
  7216. get: function() {
  7217. return this._frameData.total
  7218. }
  7219. }), Object.defineProperty(b.AnimationManager.prototype, "paused", {
  7220. get: function() {
  7221. return this.currentAnim.isPaused
  7222. },
  7223. set: function(a) {
  7224. this.currentAnim.paused = a
  7225. }
  7226. }), Object.defineProperty(b.AnimationManager.prototype, "name", {
  7227. get: function() {
  7228. return this.currentAnim ? this.currentAnim.name : void 0
  7229. }
  7230. }), Object.defineProperty(b.AnimationManager.prototype, "frame", {
  7231. get: function() {
  7232. return this.currentFrame ? this._frameIndex : void 0
  7233. },
  7234. set: function(a) {
  7235. "number" == typeof a && null !== this._frameData.getFrame(a) && (this.currentFrame = this._frameData.getFrame(a), this.currentFrame && (this._frameIndex = a, this.sprite.setFrame(this.currentFrame), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)))
  7236. }
  7237. }), Object.defineProperty(b.AnimationManager.prototype, "frameName", {
  7238. get: function() {
  7239. return this.currentFrame ? this.currentFrame.name : void 0
  7240. },
  7241. set: function(a) {
  7242. "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)
  7243. }
  7244. }), b.Animation = function(a, c, d, e, f, g, h) {
  7245. "undefined" == typeof h && (h = !1), this.game = a, this._parent = c, this._frameData = e, this.name = d, this._frames = [], this._frames = this._frames.concat(f), this.delay = 1e3 / g, this.loop = h, this.loopCount = 0, this.killOnComplete = !1, this.isFinished = !1, this.isPlaying = !1, this.isPaused = !1, this._pauseStartTime = 0, this._frameIndex = 0, this._frameDiff = 0, this._frameSkip = 1, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.onStart = new b.Signal, this.onUpdate = null, this.onComplete = new b.Signal, this.onLoop = new b.Signal, this.game.onPause.add(this.onPause, this), this.game.onResume.add(this.onResume, this)
  7246. }, b.Animation.prototype = {
  7247. play: function(a, b, c) {
  7248. return "number" == typeof a && (this.delay = 1e3 / a), "boolean" == typeof b && (this.loop = b), "undefined" != typeof c && (this.killOnComplete = c), this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.now, this._timeNextFrame = this.game.time.now + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1), this._parent.events.onAnimationStart.dispatch(this._parent, this), this.onStart.dispatch(this._parent, this), this
  7249. },
  7250. restart: function() {
  7251. this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.now, this._timeNextFrame = this.game.time.now + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), this.onStart.dispatch(this._parent, this)
  7252. },
  7253. setFrame: function(a, b) {
  7254. var c;
  7255. if ("undefined" == typeof b && (b = !1), "string" == typeof a)
  7256. for (var d = 0; d < this._frames.length; d++) this._frameData.getFrame(this._frames[d]).name === a && (c = d);
  7257. else if ("number" == typeof a)
  7258. if (b) c = a;
  7259. else
  7260. for (var d = 0; d < this._frames.length; d++) this.frames[d] === c && (c = d);
  7261. c && (this._frameIndex = c - 1, this._timeNextFrame = this.game.time.now, this.update())
  7262. },
  7263. stop: function(a, b) {
  7264. "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))
  7265. },
  7266. onPause: function() {
  7267. this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.now)
  7268. },
  7269. onResume: function() {
  7270. this.isPlaying && (this._timeNextFrame = this.game.time.now + this._frameDiff)
  7271. },
  7272. update: function() {
  7273. return this.isPaused ? !1 : this.isPlaying && this.game.time.now >= this._timeNextFrame ? (this._frameSkip = 1, this._frameDiff = this.game.time.now - this._timeNextFrame, this._timeLastFrame = this.game.time.now, this._frameDiff > this.delay && (this._frameSkip = Math.floor(this._frameDiff / this.delay), this._frameDiff -= this._frameSkip * this.delay), this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff), this._frameIndex += this._frameSkip, this._frameIndex >= this._frames.length && (this.loop ? (this._frameIndex %= this._frames.length, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.loopCount++, this._parent.events.onAnimationLoop.dispatch(this._parent, this), this.onLoop.dispatch(this._parent, this)) : this.complete()), this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1), this.onUpdate && this.onUpdate.dispatch(this, this.currentFrame)), !0) : !1
  7274. },
  7275. next: function(a) {
  7276. "undefined" == typeof a && (a = 1);
  7277. var b = this._frameIndex + a;
  7278. b >= this._frames.length && (this.loop ? b %= this._frames.length : b = this._frames.length - 1), b !== this._frameIndex && (this._frameIndex = b, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1)), this.onUpdate && this.onUpdate.dispatch(this, this.currentFrame))
  7279. },
  7280. previous: function(a) {
  7281. "undefined" == typeof a && (a = 1);
  7282. var b = this._frameIndex - a;
  7283. 0 > b && (this.loop ? b = this._frames.length + b : b++), b !== this._frameIndex && (this._frameIndex = b, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1)), this.onUpdate && this.onUpdate.dispatch(this, this.currentFrame))
  7284. },
  7285. updateFrameData: function(a) {
  7286. this._frameData = a, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null
  7287. },
  7288. destroy: function() {
  7289. 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()
  7290. },
  7291. complete: function() {
  7292. 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()
  7293. }
  7294. }, b.Animation.prototype.constructor = b.Animation, Object.defineProperty(b.Animation.prototype, "paused", {
  7295. get: function() {
  7296. return this.isPaused
  7297. },
  7298. set: function(a) {
  7299. this.isPaused = a, a ? this._pauseStartTime = this.game.time.now : this.isPlaying && (this._timeNextFrame = this.game.time.now + this.delay)
  7300. }
  7301. }), Object.defineProperty(b.Animation.prototype, "frameTotal", {
  7302. get: function() {
  7303. return this._frames.length
  7304. }
  7305. }), Object.defineProperty(b.Animation.prototype, "frame", {
  7306. get: function() {
  7307. return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex
  7308. },
  7309. set: function(a) {
  7310. 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))
  7311. }
  7312. }), Object.defineProperty(b.Animation.prototype, "speed", {
  7313. get: function() {
  7314. return Math.round(1e3 / this.delay)
  7315. },
  7316. set: function(a) {
  7317. a >= 1 && (this.delay = 1e3 / a)
  7318. }
  7319. }), Object.defineProperty(b.Animation.prototype, "enableUpdate", {
  7320. get: function() {
  7321. return null !== this.onUpdate
  7322. },
  7323. set: function(a) {
  7324. a && null === this.onUpdate ? this.onUpdate = new b.Signal : a || null === this.onUpdate || (this.onUpdate.dispose(), this.onUpdate = null)
  7325. }
  7326. }), b.Animation.generateFrameNames = function(a, c, d, e, f) {
  7327. "undefined" == typeof e && (e = "");
  7328. var g = [],
  7329. h = "";
  7330. if (d > c)
  7331. for (var i = c; d >= i; i++) h = "number" == typeof f ? b.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  7332. else
  7333. for (var i = c; i >= d; i--) h = "number" == typeof f ? b.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  7334. return g
  7335. }, b.Frame = function(a, c, d, e, f, g, h) {
  7336. this.index = a, this.x = c, this.y = d, this.width = e, this.height = f, this.name = g, this.uuid = h, this.centerX = Math.floor(e / 2), this.centerY = Math.floor(f / 2), this.distance = b.Math.distance(0, 0, e, f), this.rotated = !1, this.rotationDirection = "cw", this.trimmed = !1, this.sourceSizeW = e, this.sourceSizeH = f, this.spriteSourceSizeX = 0, this.spriteSourceSizeY = 0, this.spriteSourceSizeW = 0, this.spriteSourceSizeH = 0, this.right = this.x + this.width, this.bottom = this.y + this.height
  7337. }, b.Frame.prototype = {
  7338. setTrim: function(a, b, c, d, e, f, g) {
  7339. 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)
  7340. },
  7341. clone: function() {
  7342. var a = new b.Frame(this.index, this.x, this.y, this.width, this.height, this.name, this.uuid);
  7343. for (var c in this) this.hasOwnProperty(c) && (a[c] = this[c]);
  7344. return a
  7345. },
  7346. getRect: function(a) {
  7347. return "undefined" == typeof a ? a = new b.Rectangle(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  7348. }
  7349. }, b.Frame.prototype.constructor = b.Frame, b.FrameData = function() {
  7350. this._frames = [], this._frameNames = []
  7351. }, b.FrameData.prototype = {
  7352. addFrame: function(a) {
  7353. return a.index = this._frames.length, this._frames.push(a), "" !== a.name && (this._frameNames[a.name] = a.index), a
  7354. },
  7355. getFrame: function(a) {
  7356. return a > this._frames.length && (a = 0), this._frames[a]
  7357. },
  7358. getFrameByName: function(a) {
  7359. return "number" == typeof this._frameNames[a] ? this._frames[this._frameNames[a]] : null
  7360. },
  7361. checkFrameName: function(a) {
  7362. return null == this._frameNames[a] ? !1 : !0
  7363. },
  7364. clone: function() {
  7365. for (var a = new b.FrameData, c = 0; c < this._frames.length; c++) a._frames.push(this._frames[c].clone());
  7366. for (var c = 0; c < this._frameNames.length; c++) a._frameNames.push(this._frameNames[c]);
  7367. return a
  7368. },
  7369. getFrameRange: function(a, b, c) {
  7370. "undefined" == typeof c && (c = []);
  7371. for (var d = a; b >= d; d++) c.push(this._frames[d]);
  7372. return c
  7373. },
  7374. getFrames: function(a, b, c) {
  7375. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  7376. for (var d = 0; d < this._frames.length; d++) c.push(this._frames[d]);
  7377. else
  7378. for (var d = 0, e = a.length; e > d; d++) c.push(b ? this.getFrame(a[d]) : this.getFrameByName(a[d]));
  7379. return c
  7380. },
  7381. getFrameIndexes: function(a, b, c) {
  7382. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  7383. for (var d = 0, e = this._frames.length; e > d; d++) c.push(this._frames[d].index);
  7384. else
  7385. 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);
  7386. return c
  7387. }
  7388. }, b.FrameData.prototype.constructor = b.FrameData, Object.defineProperty(b.FrameData.prototype, "total", {
  7389. get: function() {
  7390. return this._frames.length
  7391. }
  7392. }), b.AnimationParser = {
  7393. spriteSheet: function(a, c, d, e, f, g, h) {
  7394. var i = a.cache.getImage(c);
  7395. if (null == i) return null;
  7396. var j = i.width,
  7397. k = i.height;
  7398. 0 >= d && (d = Math.floor(-j / Math.min(-1, d))), 0 >= e && (e = Math.floor(-k / Math.min(-1, e)));
  7399. var l = Math.floor((j - g) / (d + h)),
  7400. m = Math.floor((k - g) / (e + h)),
  7401. n = l * m;
  7402. if (-1 !== f && (n = f), 0 === j || 0 === k || d > j || e > k || 0 === n) return console.warn("Phaser.AnimationParser.spriteSheet: '" + c + "'s width/height zero or width/height < given frameWidth/frameHeight"), null;
  7403. for (var o = new b.FrameData, p = g, q = g, r = 0; n > r; r++) {
  7404. var s = a.rnd.uuid();
  7405. o.addFrame(new b.Frame(r, p, q, d, e, "", s)), PIXI.TextureCache[s] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  7406. x: p,
  7407. y: q,
  7408. width: d,
  7409. height: e
  7410. }), p += d + h, p + d > j && (p = g, q += e + h)
  7411. }
  7412. return o
  7413. },
  7414. JSONData: function(a, c, d) {
  7415. if (!c.frames) return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"), void console.log(c);
  7416. for (var e, f = new b.FrameData, g = c.frames, h = 0; h < g.length; h++) {
  7417. var i = a.rnd.uuid();
  7418. e = f.addFrame(new b.Frame(h, g[h].frame.x, g[h].frame.y, g[h].frame.w, g[h].frame.h, g[h].filename, i)), PIXI.TextureCache[i] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  7419. x: g[h].frame.x,
  7420. y: g[h].frame.y,
  7421. width: g[h].frame.w,
  7422. height: g[h].frame.h
  7423. }), 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)
  7424. }
  7425. return f
  7426. },
  7427. JSONDataHash: function(a, c, d) {
  7428. if (!c.frames) return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"), void console.log(c);
  7429. var e, f = new b.FrameData,
  7430. g = c.frames,
  7431. h = 0;
  7432. for (var i in g) {
  7433. var j = a.rnd.uuid();
  7434. e = f.addFrame(new b.Frame(h, g[i].frame.x, g[i].frame.y, g[i].frame.w, g[i].frame.h, i, j)), PIXI.TextureCache[j] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  7435. x: g[i].frame.x,
  7436. y: g[i].frame.y,
  7437. width: g[i].frame.w,
  7438. height: g[i].frame.h
  7439. }), 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++
  7440. }
  7441. return f
  7442. },
  7443. XMLData: function(a, c, d) {
  7444. if (!c.getElementsByTagName("TextureAtlas")) return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
  7445. for (var e, f, g, h, i, j, k, l, m, n, o, p, q = new b.FrameData, r = c.getElementsByTagName("SubTexture"), s = 0; s < r.length; s++) f = a.rnd.uuid(), h = r[s].attributes, g = h.name.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 b.Frame(s, i, j, k, l, g, f)), PIXI.TextureCache[f] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  7446. x: i,
  7447. y: j,
  7448. width: k,
  7449. height: l
  7450. }), (null !== m || null !== n) && e.setTrim(!0, k, l, m, n, o, p);
  7451. return q
  7452. }
  7453. }, b.Cache = function(a) {
  7454. this.game = a, 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 b.Signal, this._cacheMap = [], this._cacheMap[b.Cache.CANVAS] = this._canvases, this._cacheMap[b.Cache.IMAGE] = this._images, this._cacheMap[b.Cache.TEXTURE] = this._textures, this._cacheMap[b.Cache.SOUND] = this._sounds, this._cacheMap[b.Cache.TEXT] = this._text, this._cacheMap[b.Cache.PHYSICS] = this._physics, this._cacheMap[b.Cache.TILEMAP] = this._tilemaps, this._cacheMap[b.Cache.BINARY] = this._binary, this._cacheMap[b.Cache.BITMAPDATA] = this._bitmapDatas, this._cacheMap[b.Cache.BITMAPFONT] = this._bitmapFont, this._cacheMap[b.Cache.JSON] = this._json, this._cacheMap[b.Cache.XML] = this._xml
  7455. }, b.Cache.CANVAS = 1, b.Cache.IMAGE = 2, b.Cache.TEXTURE = 3, b.Cache.SOUND = 4, b.Cache.TEXT = 5, b.Cache.PHYSICS = 6, b.Cache.TILEMAP = 7, b.Cache.BINARY = 8, b.Cache.BITMAPDATA = 9, b.Cache.BITMAPFONT = 10, b.Cache.JSON = 11, b.Cache.XML = 12, b.Cache.prototype = {
  7456. addCanvas: function(a, b, c) {
  7457. this._canvases[a] = {
  7458. canvas: b,
  7459. context: c
  7460. }
  7461. },
  7462. addBinary: function(a, b) {
  7463. this._binary[a] = b
  7464. },
  7465. addBitmapData: function(a, b, c) {
  7466. return b.key = a, this._bitmapDatas[a] = {
  7467. data: b,
  7468. frameData: c
  7469. }, b
  7470. },
  7471. addRenderTexture: function(a, c) {
  7472. var d = new b.Frame(0, 0, 0, c.width, c.height, "", "");
  7473. this._textures[a] = {
  7474. texture: c,
  7475. frame: d
  7476. }
  7477. },
  7478. addSpriteSheet: function(a, c, d, e, f, g, h, i) {
  7479. this._images[a] = {
  7480. url: c,
  7481. data: d,
  7482. frameWidth: e,
  7483. frameHeight: f,
  7484. margin: h,
  7485. spacing: i
  7486. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), this._images[a].frameData = b.AnimationParser.spriteSheet(this.game, a, e, f, g, h, i), this._urlMap[this._resolveUrl(c)] = this._images[a]
  7487. },
  7488. addTilemap: function(a, b, c, d) {
  7489. this._tilemaps[a] = {
  7490. url: b,
  7491. data: c,
  7492. format: d
  7493. }, this._urlMap[this._resolveUrl(b)] = this._tilemaps[a]
  7494. },
  7495. addTextureAtlas: function(a, c, d, e, f) {
  7496. this._images[a] = {
  7497. url: c,
  7498. data: d
  7499. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), f == b.Loader.TEXTURE_ATLAS_JSON_ARRAY ? this._images[a].frameData = b.AnimationParser.JSONData(this.game, e, a) : f == b.Loader.TEXTURE_ATLAS_JSON_HASH ? this._images[a].frameData = b.AnimationParser.JSONDataHash(this.game, e, a) : f == b.Loader.TEXTURE_ATLAS_XML_STARLING && (this._images[a].frameData = b.AnimationParser.XMLData(this.game, e, a)), this._urlMap[this._resolveUrl(c)] = this._images[a]
  7500. },
  7501. addBitmapFont: function(a, c, d, e, f, g) {
  7502. this._images[a] = {
  7503. url: c,
  7504. data: d
  7505. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), b.LoaderParser.bitmapFont(this.game, e, a, f, g), this._bitmapFont[a] = PIXI.BitmapText.fonts[a], this._urlMap[this._resolveUrl(c)] = this._bitmapFont[a]
  7506. },
  7507. addPhysicsData: function(a, b, c, d) {
  7508. this._physics[a] = {
  7509. url: b,
  7510. data: c,
  7511. format: d
  7512. }, this._urlMap[this._resolveUrl(b)] = this._physics[a]
  7513. },
  7514. addDefaultImage: function() {
  7515. var a = new Image;
  7516. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==", this._images.__default = {
  7517. url: null,
  7518. data: a
  7519. }, this._images.__default.frame = new b.Frame(0, 0, 0, 32, 32, "", ""), this._images.__default.frameData = new b.FrameData, this._images.__default.frameData.addFrame(new b.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)
  7520. },
  7521. addMissingImage: function() {
  7522. var a = new Image;
  7523. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==", this._images.__missing = {
  7524. url: null,
  7525. data: a
  7526. }, this._images.__missing.frame = new b.Frame(0, 0, 0, 32, 32, "", ""), this._images.__missing.frameData = new b.FrameData, this._images.__missing.frameData.addFrame(new b.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)
  7527. },
  7528. addText: function(a, b, c) {
  7529. this._text[a] = {
  7530. url: b,
  7531. data: c
  7532. }, this._urlMap[this._resolveUrl(b)] = this._text[a]
  7533. },
  7534. addJSON: function(a, b, c) {
  7535. this._json[a] = {
  7536. url: b,
  7537. data: c
  7538. }, this._urlMap[this._resolveUrl(b)] = this._json[a]
  7539. },
  7540. addXML: function(a, b, c) {
  7541. this._xml[a] = {
  7542. url: b,
  7543. data: c
  7544. }
  7545. },
  7546. addImage: function(a, c, d) {
  7547. this._images[a] = {
  7548. url: c,
  7549. data: d
  7550. }, this._images[a].frame = new b.Frame(0, 0, 0, d.width, d.height, a, this.game.rnd.uuid()), this._images[a].frameData = new b.FrameData, this._images[a].frameData.addFrame(new b.Frame(0, 0, 0, d.width, d.height, c, this.game.rnd.uuid())), PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), this._urlMap[this._resolveUrl(c)] = this._images[a]
  7551. },
  7552. addSound: function(a, b, c, d, e) {
  7553. d = d || !0, e = e || !1;
  7554. var f = !1;
  7555. e && (f = !0), this._sounds[a] = {
  7556. url: b,
  7557. data: c,
  7558. isDecoding: !1,
  7559. decoded: f,
  7560. webAudio: d,
  7561. audioTag: e,
  7562. locked: this.game.sound.touchLocked
  7563. }, this._urlMap[this._resolveUrl(b)] = this._sounds[a]
  7564. },
  7565. reloadSound: function(a) {
  7566. var b = this;
  7567. this._sounds[a] && (this._sounds[a].data.src = this._sounds[a].url, this._sounds[a].data.addEventListener("canplaythrough", function() {
  7568. return b.reloadSoundComplete(a)
  7569. }, !1), this._sounds[a].data.load())
  7570. },
  7571. reloadSoundComplete: function(a) {
  7572. this._sounds[a] && (this._sounds[a].locked = !1, this.onSoundUnlock.dispatch(a))
  7573. },
  7574. updateSound: function(a, b, c) {
  7575. this._sounds[a] && (this._sounds[a][b] = c)
  7576. },
  7577. decodedSound: function(a, b) {
  7578. this._sounds[a].data = b, this._sounds[a].decoded = !0, this._sounds[a].isDecoding = !1
  7579. },
  7580. getCanvas: function(a) {
  7581. return this._canvases[a] ? this._canvases[a].canvas : void console.warn('Phaser.Cache.getCanvas: Invalid key: "' + a + '"')
  7582. },
  7583. getBitmapData: function(a) {
  7584. return this._bitmapDatas[a] ? this._bitmapDatas[a].data : void console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + a + '"')
  7585. },
  7586. getBitmapFont: function(a) {
  7587. return this._bitmapFont[a] ? this._bitmapFont[a] : void console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + a + '"')
  7588. },
  7589. getPhysicsData: function(a, b, c) {
  7590. if ("undefined" == typeof b || null === b) {
  7591. if (this._physics[a]) return this._physics[a].data;
  7592. console.warn('Phaser.Cache.getPhysicsData: Invalid key: "' + a + '"')
  7593. } else if (this._physics[a] && this._physics[a].data[b]) {
  7594. var d = this._physics[a].data[b];
  7595. if (!d || !c) return d;
  7596. for (var e in d)
  7597. if (e = d[e], e.fixtureKey === c) return e;
  7598. console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "' + c + " in " + a + '"')
  7599. } else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + a + " / " + b + '"');
  7600. return null
  7601. },
  7602. checkKey: function(a, b) {
  7603. return this._cacheMap[a][b] ? !0 : !1
  7604. },
  7605. checkCanvasKey: function(a) {
  7606. return this.checkKey(b.Cache.CANVAS, a)
  7607. },
  7608. checkImageKey: function(a) {
  7609. return this.checkKey(b.Cache.IMAGE, a)
  7610. },
  7611. checkTextureKey: function(a) {
  7612. return this.checkKey(b.Cache.TEXTURE, a)
  7613. },
  7614. checkSoundKey: function(a) {
  7615. return this.checkKey(b.Cache.SOUND, a)
  7616. },
  7617. checkTextKey: function(a) {
  7618. return this.checkKey(b.Cache.TEXT, a)
  7619. },
  7620. checkPhysicsKey: function(a) {
  7621. return this.checkKey(b.Cache.PHYSICS, a)
  7622. },
  7623. checkTilemapKey: function(a) {
  7624. return this.checkKey(b.Cache.TILEMAP, a)
  7625. },
  7626. checkBinaryKey: function(a) {
  7627. return this.checkKey(b.Cache.BINARY, a)
  7628. },
  7629. checkBitmapDataKey: function(a) {
  7630. return this.checkKey(b.Cache.BITMAPDATA, a)
  7631. },
  7632. checkBitmapFontKey: function(a) {
  7633. return this.checkKey(b.Cache.BITMAPFONT, a)
  7634. },
  7635. checkJSONKey: function(a) {
  7636. return this.checkKey(b.Cache.JSON, a)
  7637. },
  7638. checkXMLKey: function(a) {
  7639. return this.checkKey(b.Cache.XML, a)
  7640. },
  7641. checkUrl: function(a) {
  7642. return this._urlMap[this._resolveUrl(a)] ? !0 : !1
  7643. },
  7644. getImage: function(a) {
  7645. return this._images[a] ? this._images[a].data : (console.warn('Phaser.Cache.getImage: Invalid key: "' + a + '"'), null)
  7646. },
  7647. getTilemapData: function(a) {
  7648. return this._tilemaps[a] ? this._tilemaps[a] : void console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + a + '"')
  7649. },
  7650. getFrameData: function(a, c) {
  7651. return "undefined" == typeof c && (c = b.Cache.IMAGE), this._cacheMap[c][a] ? this._cacheMap[c][a].frameData : null
  7652. },
  7653. updateFrameData: function(a, b) {
  7654. this._images[a] && (this._images[a].frameData = b)
  7655. },
  7656. getFrameByIndex: function(a, b) {
  7657. return this._images[a] ? this._images[a].frameData.getFrame(b) : null
  7658. },
  7659. getFrameByName: function(a, b) {
  7660. return this._images[a] ? this._images[a].frameData.getFrameByName(b) : null
  7661. },
  7662. getFrame: function(a) {
  7663. return this._images[a] ? this._images[a].frame : null
  7664. },
  7665. getTextureFrame: function(a) {
  7666. return this._textures[a] ? this._textures[a].frame : null
  7667. },
  7668. getTexture: function(a) {
  7669. return this._textures[a] ? this._textures[a] : void console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"')
  7670. },
  7671. getSound: function(a) {
  7672. return this._sounds[a] ? this._sounds[a] : void console.warn('Phaser.Cache.getSound: Invalid key: "' + a + '"')
  7673. },
  7674. getSoundData: function(a) {
  7675. return this._sounds[a] ? this._sounds[a].data : void console.warn('Phaser.Cache.getSoundData: Invalid key: "' + a + '"')
  7676. },
  7677. isSoundDecoded: function(a) {
  7678. return this._sounds[a] ? this._sounds[a].decoded : void 0
  7679. },
  7680. isSoundReady: function(a) {
  7681. return this._sounds[a] && this._sounds[a].decoded && this.game.sound.touchLocked === !1
  7682. },
  7683. getFrameCount: function(a) {
  7684. return this._images[a] ? this._images[a].frameData.total : 0
  7685. },
  7686. getText: function(a) {
  7687. return this._text[a] ? this._text[a].data : void console.warn('Phaser.Cache.getText: Invalid key: "' + a + '"')
  7688. },
  7689. getJSON: function(a) {
  7690. return this._json[a] ? this._json[a].data : void console.warn('Phaser.Cache.getJSON: Invalid key: "' + a + '"')
  7691. },
  7692. getXML: function(a) {
  7693. return this._xml[a] ? this._xml[a].data : void console.warn('Phaser.Cache.getXML: Invalid key: "' + a + '"')
  7694. },
  7695. getBinary: function(a) {
  7696. return this._binary[a] ? this._binary[a] : void console.warn('Phaser.Cache.getBinary: Invalid key: "' + a + '"')
  7697. },
  7698. getUrl: function(a) {
  7699. return this._urlMap[this._resolveUrl(a)] ? this._urlMap[this._resolveUrl(a)] : void console.warn('Phaser.Cache.getUrl: Invalid url: "' + a + '"')
  7700. },
  7701. getKeys: function(a) {
  7702. var c = null;
  7703. switch (a) {
  7704. case b.Cache.CANVAS:
  7705. c = this._canvases;
  7706. break;
  7707. case b.Cache.IMAGE:
  7708. c = this._images;
  7709. break;
  7710. case b.Cache.TEXTURE:
  7711. c = this._textures;
  7712. break;
  7713. case b.Cache.SOUND:
  7714. c = this._sounds;
  7715. break;
  7716. case b.Cache.TEXT:
  7717. c = this._text;
  7718. break;
  7719. case b.Cache.PHYSICS:
  7720. c = this._physics;
  7721. break;
  7722. case b.Cache.TILEMAP:
  7723. c = this._tilemaps;
  7724. break;
  7725. case b.Cache.BINARY:
  7726. c = this._binary;
  7727. break;
  7728. case b.Cache.BITMAPDATA:
  7729. c = this._bitmapDatas;
  7730. break;
  7731. case b.Cache.BITMAPFONT:
  7732. c = this._bitmapFont;
  7733. break;
  7734. case b.Cache.JSON:
  7735. c = this._json;
  7736. break;
  7737. case b.Cache.XML:
  7738. c = this._xml
  7739. }
  7740. if (c) {
  7741. var d = [];
  7742. for (var e in c) "__default" !== e && "__missing" !== e && d.push(e);
  7743. return d
  7744. }
  7745. },
  7746. removeCanvas: function(a) {
  7747. delete this._canvases[a]
  7748. },
  7749. removeImage: function(a, b) {
  7750. "undefined" == typeof b && (b = !0), delete this._images[a], b && PIXI.BaseTextureCache[a].destroy()
  7751. },
  7752. removeSound: function(a) {
  7753. delete this._sounds[a]
  7754. },
  7755. removeText: function(a) {
  7756. delete this._text[a]
  7757. },
  7758. removeJSON: function(a) {
  7759. delete this._json[a]
  7760. },
  7761. removeXML: function(a) {
  7762. delete this._xml[a]
  7763. },
  7764. removePhysics: function(a) {
  7765. delete this._physics[a]
  7766. },
  7767. removeTilemap: function(a) {
  7768. delete this._tilemaps[a]
  7769. },
  7770. removeBinary: function(a) {
  7771. delete this._binary[a]
  7772. },
  7773. removeBitmapData: function(a) {
  7774. delete this._bitmapDatas[a]
  7775. },
  7776. removeBitmapFont: function(a) {
  7777. delete this._bitmapFont[a]
  7778. },
  7779. _resolveUrl: function(a) {
  7780. return this._urlResolver.src = this.game.load.baseURL + a, this._urlTemp = this._urlResolver.src, this._urlResolver.src = "", this._urlTemp
  7781. },
  7782. destroy: function() {
  7783. for (var a in this._canvases) delete this._canvases[a];
  7784. for (var a in this._images) "__default" !== a && "__missing" !== a && delete this._images[a];
  7785. for (var a in this._sounds) delete this._sounds[a];
  7786. for (var a in this._text) delete this._text[a];
  7787. for (var a in this._json) delete this._json[a];
  7788. for (var a in this._xml) delete this._xml[a];
  7789. for (var a in this._textures) delete this._textures[a];
  7790. for (var a in this._physics) delete this._physics[a];
  7791. for (var a in this._tilemaps) delete this._tilemaps[a];
  7792. for (var a in this._binary) delete this._binary[a];
  7793. for (var a in this._bitmapDatas) delete this._bitmapDatas[a];
  7794. for (var a in this._bitmapFont) delete this._bitmapFont[a];
  7795. this._urlMap = null, this._urlResolver = null, this._urlTemp = null
  7796. }
  7797. }, b.Cache.prototype.constructor = b.Cache, b.Loader = function(a) {
  7798. this.game = a, this.isLoading = !1, this.hasLoaded = !1, this.progress = 0, this.progressFloat = 0, this.preloadSprite = null, this.crossOrigin = !1, this.baseURL = "", this.onLoadStart = new b.Signal, this.onFileStart = new b.Signal, this.onFileComplete = new b.Signal, this.onFileError = new b.Signal, this.onLoadComplete = new b.Signal, this.onPackComplete = new b.Signal, this.useXDomainRequest = 9 === this.game.device.ieVersion, this._packList = [], this._packIndex = 0, this._fileList = [], this._fileIndex = 0, this._progressChunk = 0, this._xhr = new XMLHttpRequest, this._ajax = null
  7799. }, b.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0, b.Loader.TEXTURE_ATLAS_JSON_HASH = 1, b.Loader.TEXTURE_ATLAS_XML_STARLING = 2, b.Loader.PHYSICS_LIME_CORONA_JSON = 3, b.Loader.PHYSICS_PHASER_JSON = 4, b.Loader.prototype = {
  7800. setPreloadSprite: function(a, c) {
  7801. c = c || 0, this.preloadSprite = {
  7802. sprite: a,
  7803. direction: c,
  7804. width: a.width,
  7805. height: a.height,
  7806. rect: null
  7807. }, this.preloadSprite.rect = 0 === c ? new b.Rectangle(0, 0, 1, a.height) : new b.Rectangle(0, 0, a.width, 1), a.crop(this.preloadSprite.rect), a.visible = !0
  7808. },
  7809. checkKeyExists: function(a, b) {
  7810. if (this._fileList.length > 0)
  7811. for (var c = 0; c < this._fileList.length; c++)
  7812. if (this._fileList[c].type === a && this._fileList[c].key === b) return !0;
  7813. return !1
  7814. },
  7815. getAssetIndex: function(a, b) {
  7816. if (this._fileList.length > 0)
  7817. for (var c = 0; c < this._fileList.length; c++)
  7818. if (this._fileList[c].type === a && this._fileList[c].key === b) return c;
  7819. return -1
  7820. },
  7821. getAsset: function(a, b) {
  7822. if (this._fileList.length > 0)
  7823. for (var c = 0; c < this._fileList.length; c++)
  7824. if (this._fileList[c].type === a && this._fileList[c].key === b) return {
  7825. index: c,
  7826. file: this._fileList[c]
  7827. };
  7828. return !1
  7829. },
  7830. reset: function() {
  7831. this.preloadSprite = null, this.isLoading = !1, this._packList.length = 0, this._packIndex = 0, this._fileList.length = 0, this._fileIndex = 0
  7832. },
  7833. addToFileList: function(a, b, c, d) {
  7834. var e = {
  7835. type: a,
  7836. key: b,
  7837. url: c,
  7838. data: null,
  7839. error: !1,
  7840. loaded: !1
  7841. };
  7842. if ("undefined" != typeof d)
  7843. for (var f in d) e[f] = d[f];
  7844. this.checkKeyExists(a, b) === !1 && this._fileList.push(e)
  7845. },
  7846. replaceInFileList: function(a, b, c, d) {
  7847. var e = {
  7848. type: a,
  7849. key: b,
  7850. url: c,
  7851. data: null,
  7852. error: !1,
  7853. loaded: !1
  7854. };
  7855. if ("undefined" != typeof d)
  7856. for (var f in d) e[f] = d[f];
  7857. var g = this.getAssetIndex(a, b); - 1 === g ? this._fileList.push(e) : this._fileList[g] = e
  7858. },
  7859. pack: function(a, b, c, d) {
  7860. return "undefined" == typeof b && (b = null), "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = this), null === b && null === c ? (console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."), this) : (c && "string" == typeof c && (c = JSON.parse(c)), this._packList.push({
  7861. key: a,
  7862. url: b,
  7863. data: c,
  7864. loaded: !1,
  7865. error: !1,
  7866. callbackContext: d
  7867. }), this)
  7868. },
  7869. image: function(a, b, c) {
  7870. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("image", a, b) : this.addToFileList("image", a, b), this
  7871. },
  7872. text: function(a, b, c) {
  7873. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("text", a, b) : this.addToFileList("text", a, b), this
  7874. },
  7875. json: function(a, b, c) {
  7876. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("json", a, b) : this.addToFileList("json", a, b), this
  7877. },
  7878. xml: function(a, b, c) {
  7879. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("xml", a, b) : this.addToFileList("xml", a, b), this
  7880. },
  7881. script: function(a, b, c, d) {
  7882. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("script", a, b, {
  7883. callback: c,
  7884. callbackContext: d
  7885. }), this
  7886. },
  7887. binary: function(a, b, c, d) {
  7888. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("binary", a, b, {
  7889. callback: c,
  7890. callbackContext: d
  7891. }), this
  7892. },
  7893. spritesheet: function(a, b, c, d, e, f, g) {
  7894. return "undefined" == typeof e && (e = -1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), this.addToFileList("spritesheet", a, b, {
  7895. frameWidth: c,
  7896. frameHeight: d,
  7897. frameMax: e,
  7898. margin: f,
  7899. spacing: g
  7900. }), this
  7901. },
  7902. audio: function(a, b, c) {
  7903. return "undefined" == typeof c && (c = !0), this.addToFileList("audio", a, b, {
  7904. buffer: null,
  7905. autoDecode: c
  7906. }), this
  7907. },
  7908. audiosprite: function(a, b, c) {
  7909. return this.audio(a, b), this.json(a + "-audioatlas", c), this
  7910. },
  7911. tilemap: function(a, c, d, e) {
  7912. if ("undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = b.Tilemap.CSV), null == c && null == d) return console.warn("Phaser.Loader.tilemap - Both url and data are null. One must be set."), this;
  7913. if (d) {
  7914. switch (e) {
  7915. case b.Tilemap.CSV:
  7916. break;
  7917. case b.Tilemap.TILED_JSON:
  7918. "string" == typeof d && (d = JSON.parse(d))
  7919. }
  7920. this.game.cache.addTilemap(a, null, d, e)
  7921. } else this.addToFileList("tilemap", a, c, {
  7922. format: e
  7923. });
  7924. return this
  7925. },
  7926. physics: function(a, c, d, e) {
  7927. return "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = b.Physics.LIME_CORONA_JSON), null == c && null == d ? (console.warn("Phaser.Loader.physics - Both url and data are null. One must be set."), this) : (d ? ("string" == typeof d && (d = JSON.parse(d)), this.game.cache.addPhysicsData(a, null, d, e)) : this.addToFileList("physics", a, c, {
  7928. format: e
  7929. }), this)
  7930. },
  7931. bitmapFont: function(a, b, c, d, e, f) {
  7932. 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, {
  7933. xmlURL: c,
  7934. xSpacing: e,
  7935. ySpacing: f
  7936. });
  7937. else if ("string" == typeof d) {
  7938. var g;
  7939. try {
  7940. if (window.DOMParser) {
  7941. var h = new DOMParser;
  7942. g = h.parseFromString(d, "text/xml")
  7943. } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(d)
  7944. } catch (i) {
  7945. g = void 0
  7946. }
  7947. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
  7948. this.addToFileList("bitmapfont", a, b, {
  7949. xmlURL: null,
  7950. xmlData: g,
  7951. xSpacing: e,
  7952. ySpacing: f
  7953. })
  7954. }
  7955. return this
  7956. },
  7957. atlasJSONArray: function(a, c, d, e) {
  7958. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_ARRAY)
  7959. },
  7960. atlasJSONHash: function(a, c, d, e) {
  7961. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_HASH)
  7962. },
  7963. atlasXML: function(a, c, d, e) {
  7964. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_XML_STARLING)
  7965. },
  7966. atlas: function(a, c, d, e, f) {
  7967. if ("undefined" == typeof d && (d = null), "undefined" == typeof e && (e = null), "undefined" == typeof f && (f = b.Loader.TEXTURE_ATLAS_JSON_ARRAY), d) this.addToFileList("textureatlas", a, c, {
  7968. atlasURL: d,
  7969. format: f
  7970. });
  7971. else {
  7972. switch (f) {
  7973. case b.Loader.TEXTURE_ATLAS_JSON_ARRAY:
  7974. "string" == typeof e && (e = JSON.parse(e));
  7975. break;
  7976. case b.Loader.TEXTURE_ATLAS_XML_STARLING:
  7977. if ("string" == typeof e) {
  7978. var g;
  7979. try {
  7980. if (window.DOMParser) {
  7981. var h = new DOMParser;
  7982. g = h.parseFromString(e, "text/xml")
  7983. } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(e)
  7984. } catch (i) {
  7985. g = void 0
  7986. }
  7987. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
  7988. e = g
  7989. }
  7990. }
  7991. this.addToFileList("textureatlas", a, c, {
  7992. atlasURL: null,
  7993. atlasData: e,
  7994. format: f
  7995. })
  7996. }
  7997. return this
  7998. },
  7999. removeFile: function(a, b) {
  8000. var c = this.getAsset(a, b);
  8001. c !== !1 && this._fileList.splice(c.index, 1)
  8002. },
  8003. removeAll: function() {
  8004. this._fileList.length = 0
  8005. },
  8006. start: function() {
  8007. this.isLoading || (this._packList.length > 0 ? (this._packIndex = 0, this.loadPack()) : this.beginLoad())
  8008. },
  8009. beginLoad: function() {
  8010. this.progress = 0, this.progressFloat = 0, this.hasLoaded = !1, this.isLoading = !0, this.onLoadStart.dispatch(this._fileList.length), this._fileList.length > 0 ? (this._fileIndex = 0, this._progressChunk = 100 / this._fileList.length, this.loadFile()) : (this.progress = 100, this.progressFloat = 100, this.hasLoaded = !0, this.isLoading = !1, this.onLoadComplete.dispatch())
  8011. },
  8012. loadPack: function() {
  8013. if (!this._packList[this._packIndex]) return void console.warn("Phaser.Loader loadPackList invalid index " + this._packIndex);
  8014. var a = this._packList[this._packIndex];
  8015. null !== a.data ? this.packLoadComplete(this._packIndex, !1) : this.xhrLoad(this._packIndex, this.baseURL + a.url, "text", "packLoadComplete", "packLoadError")
  8016. },
  8017. packLoadComplete: function(a, c) {
  8018. if ("undefined" == typeof c && (c = !0), !this._packList[a]) return void console.warn("Phaser.Loader packLoadComplete invalid index " + a);
  8019. var d = this._packList[a];
  8020. if (d.loaded = !0, c) var e = JSON.parse(this._xhr.responseText);
  8021. else var e = this._packList[a].data;
  8022. if (e[d.key])
  8023. for (var f, g = 0; g < e[d.key].length; g++) switch (f = e[d.key][g], f.type) {
  8024. case "image":
  8025. this.image(f.key, f.url, f.overwrite);
  8026. break;
  8027. case "text":
  8028. this.text(f.key, f.url, f.overwrite);
  8029. break;
  8030. case "json":
  8031. this.json(f.key, f.url, f.overwrite);
  8032. break;
  8033. case "xml":
  8034. this.xml(f.key, f.url, f.overwrite);
  8035. break;
  8036. case "script":
  8037. this.script(f.key, f.url, f.callback, d.callbackContext);
  8038. break;
  8039. case "binary":
  8040. this.binary(f.key, f.url, f.callback, d.callbackContext);
  8041. break;
  8042. case "spritesheet":
  8043. this.spritesheet(f.key, f.url, f.frameWidth, f.frameHeight, f.frameMax, f.margin, f.spacing);
  8044. break;
  8045. case "audio":
  8046. this.audio(f.key, f.urls, f.autoDecode);
  8047. break;
  8048. case "tilemap":
  8049. this.tilemap(f.key, f.url, f.data, b.Tilemap[f.format]);
  8050. break;
  8051. case "physics":
  8052. this.physics(f.key, f.url, f.data, b.Loader[f.format]);
  8053. break;
  8054. case "bitmapFont":
  8055. this.bitmapFont(f.key, f.textureURL, f.xmlURL, f.xmlData, f.xSpacing, f.ySpacing);
  8056. break;
  8057. case "atlasJSONArray":
  8058. this.atlasJSONArray(f.key, f.textureURL, f.atlasURL, f.atlasData);
  8059. break;
  8060. case "atlasJSONHash":
  8061. this.atlasJSONHash(f.key, f.textureURL, f.atlasURL, f.atlasData);
  8062. break;
  8063. case "atlasXML":
  8064. this.atlasXML(f.key, f.textureURL, f.atlasURL, f.atlasData);
  8065. break;
  8066. case "atlas":
  8067. this.atlas(f.key, f.textureURL, f.atlasURL, f.atlasData, b.Loader[f.format])
  8068. }
  8069. this.nextPack(a, !0)
  8070. },
  8071. packError: function(a) {
  8072. this._packList[a].loaded = !0, this._packList[a].error = !0, this.onFileError.dispatch(this._packList[a].key, this._packList[a]), console.warn("Phaser.Loader error loading pack file: " + this._packList[a].key + " from URL " + this._packList[a].url), this.nextPack(a, !1)
  8073. },
  8074. nextPack: function(a, b) {
  8075. this.onPackComplete.dispatch(this._packList[a].key, b, this.totalLoadedPacks(), this._packList.length), this._packIndex++, this._packIndex < this._packList.length ? this.loadPack() : this.beginLoad()
  8076. },
  8077. loadFile: function() {
  8078. if (!this._fileList[this._fileIndex]) return void console.warn("Phaser.Loader loadFile invalid index " + this._fileIndex);
  8079. var a = this._fileList[this._fileIndex],
  8080. c = this;
  8081. switch (this.onFileStart.dispatch(this.progress, a.key, a.url), a.type) {
  8082. case "image":
  8083. case "spritesheet":
  8084. case "textureatlas":
  8085. case "bitmapfont":
  8086. a.data = new Image, a.data.name = a.key, a.data.onload = function() {
  8087. return c.fileComplete(c._fileIndex)
  8088. }, a.data.onerror = function() {
  8089. return c.fileError(c._fileIndex)
  8090. }, this.crossOrigin && (a.data.crossOrigin = this.crossOrigin), a.data.src = this.baseURL + a.url;
  8091. break;
  8092. case "audio":
  8093. a.url = this.getAudioURL(a.url), null !== a.url ? this.game.sound.usingWebAudio ? this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError") : this.game.sound.usingAudioTag && (this.game.sound.touchLocked ? (a.data = new Audio, a.data.name = a.key, a.data.preload = "auto", a.data.src = this.baseURL + a.url, this.fileComplete(this._fileIndex)) : (a.data = new Audio, a.data.name = a.key, a.data.onerror = function() {
  8094. return c.fileError(c._fileIndex)
  8095. }, a.data.preload = "auto", a.data.src = this.baseURL + a.url, a.data.addEventListener("canplaythrough", function() {
  8096. b.GAMES[c.game.id].load.fileComplete(c._fileIndex)
  8097. }, !1), a.data.load())) : this.fileError(this._fileIndex);
  8098. break;
  8099. case "json":
  8100. this.useXDomainRequest && window.XDomainRequest ? (this._ajax = new window.XDomainRequest, this._ajax.timeout = 3e3, this._ajax.onerror = function() {
  8101. return c.dataLoadError(c._fileIndex)
  8102. }, this._ajax.ontimeout = function() {
  8103. return c.dataLoadError(c._fileIndex)
  8104. }, this._ajax.onprogress = function() {}, this._ajax.onload = function() {
  8105. return c.jsonLoadComplete(c._fileIndex)
  8106. }, this._ajax.open("GET", this.baseURL + a.url, !0), setTimeout(function() {
  8107. this._ajax.send()
  8108. }, 0)) : this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  8109. break;
  8110. case "xml":
  8111. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "xmlLoadComplete", "dataLoadError");
  8112. break;
  8113. case "tilemap":
  8114. if (a.format === b.Tilemap.TILED_JSON) this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  8115. else {
  8116. if (a.format !== b.Tilemap.CSV) throw new Error("Phaser.Loader. Invalid Tilemap format: " + a.format);
  8117. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "csvLoadComplete", "dataLoadError")
  8118. }
  8119. break;
  8120. case "text":
  8121. case "script":
  8122. case "physics":
  8123. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "fileComplete", "fileError");
  8124. break;
  8125. case "binary":
  8126. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError")
  8127. }
  8128. },
  8129. xhrLoad: function(a, b, c, d, e) {
  8130. this._xhr.open("GET", b, !0), this._xhr.responseType = c;
  8131. var f = this;
  8132. this._xhr.onload = function() {
  8133. return f[d](a)
  8134. }, this._xhr.onerror = function() {
  8135. return f[e](a)
  8136. }, this._xhr.send()
  8137. },
  8138. getAudioURL: function(a) {
  8139. var b;
  8140. "string" == typeof a && (a = [a]);
  8141. for (var c = 0; c < a.length; c++)
  8142. if (b = a[c].toLowerCase(), b = b.substr((Math.max(0, b.lastIndexOf(".")) || 1 / 0) + 1), b.indexOf("?") >= 0 && (b = b.substr(0, b.indexOf("?"))), this.game.device.canPlayAudio(b)) return a[c];
  8143. return null
  8144. },
  8145. fileError: function(a) {
  8146. this._fileList[a].loaded = !0, this._fileList[a].error = !0, this.onFileError.dispatch(this._fileList[a].key, this._fileList[a]), console.warn("Phaser.Loader error loading file: " + this._fileList[a].key + " from URL " + this._fileList[a].url), this.nextFile(a, !1)
  8147. },
  8148. fileComplete: function(a) {
  8149. if (!this._fileList[a]) return void console.warn("Phaser.Loader fileComplete invalid index " + a);
  8150. var c = this._fileList[a];
  8151. c.loaded = !0;
  8152. var d = !0;
  8153. switch (c.type) {
  8154. case "image":
  8155. this.game.cache.addImage(c.key, c.url, c.data);
  8156. break;
  8157. case "spritesheet":
  8158. this.game.cache.addSpriteSheet(c.key, c.url, c.data, c.frameWidth, c.frameHeight, c.frameMax, c.margin, c.spacing);
  8159. break;
  8160. case "textureatlas":
  8161. if (null == c.atlasURL) this.game.cache.addTextureAtlas(c.key, c.url, c.data, c.atlasData, c.format);
  8162. else if (d = !1, c.format == b.Loader.TEXTURE_ATLAS_JSON_ARRAY || c.format == b.Loader.TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "jsonLoadComplete", "dataLoadError");
  8163. else {
  8164. if (c.format != b.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + c.format);
  8165. this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "xmlLoadComplete", "dataLoadError")
  8166. }
  8167. break;
  8168. case "bitmapfont":
  8169. null == c.xmlURL ? this.game.cache.addBitmapFont(c.key, c.url, c.data, c.xmlData, c.xSpacing, c.ySpacing) : (d = !1, this.xhrLoad(this._fileIndex, this.baseURL + c.xmlURL, "text", "xmlLoadComplete", "dataLoadError"));
  8170. break;
  8171. case "audio":
  8172. if (this.game.sound.usingWebAudio) {
  8173. if (c.data = this._xhr.response, this.game.cache.addSound(c.key, c.url, c.data, !0, !1), c.autoDecode) {
  8174. var e = this,
  8175. f = c.key;
  8176. this.game.cache.updateSound(f, "isDecoding", !0), this.game.sound.context.decodeAudioData(c.data, function(a) {
  8177. a && (e.game.cache.decodedSound(f, a), e.game.sound.onSoundDecode.dispatch(f, e.game.cache.getSound(f)))
  8178. })
  8179. }
  8180. } else c.data.removeEventListener("canplaythrough", b.GAMES[this.game.id].load.fileComplete), this.game.cache.addSound(c.key, c.url, c.data, !1, !0);
  8181. break;
  8182. case "text":
  8183. c.data = this._xhr.responseText, this.game.cache.addText(c.key, c.url, c.data);
  8184. break;
  8185. case "physics":
  8186. var g = JSON.parse(this._xhr.responseText);
  8187. this.game.cache.addPhysicsData(c.key, c.url, g, c.format);
  8188. break;
  8189. case "script":
  8190. c.data = document.createElement("script"), c.data.language = "javascript", c.data.type = "text/javascript", c.data.defer = !1, c.data.text = this._xhr.responseText, document.head.appendChild(c.data), c.callback && (c.data = c.callback.call(c.callbackContext, c.key, this._xhr.responseText));
  8191. break;
  8192. case "binary":
  8193. c.data = c.callback ? c.callback.call(c.callbackContext, c.key, this._xhr.response) : this._xhr.response, this.game.cache.addBinary(c.key, c.data)
  8194. }
  8195. d && this.nextFile(a, !0)
  8196. },
  8197. jsonLoadComplete: function(a) {
  8198. if (!this._fileList[a]) return void console.warn("Phaser.Loader jsonLoadComplete invalid index " + a);
  8199. var b = this._fileList[a];
  8200. if (this._ajax && this._ajax.responseText) var c = JSON.parse(this._ajax.responseText);
  8201. else var c = JSON.parse(this._xhr.responseText);
  8202. b.loaded = !0, "tilemap" === b.type ? this.game.cache.addTilemap(b.key, b.url, c, b.format) : "json" === b.type ? this.game.cache.addJSON(b.key, b.url, c) : this.game.cache.addTextureAtlas(b.key, b.url, b.data, c, b.format), this.nextFile(a, !0)
  8203. },
  8204. csvLoadComplete: function(a) {
  8205. if (!this._fileList[a]) return void console.warn("Phaser.Loader csvLoadComplete invalid index " + a);
  8206. var b = this._fileList[a],
  8207. c = this._xhr.responseText;
  8208. b.loaded = !0, this.game.cache.addTilemap(b.key, b.url, c, b.format), this.nextFile(a, !0)
  8209. },
  8210. dataLoadError: function(a) {
  8211. var b = this._fileList[a];
  8212. b.loaded = !0, b.error = !0, console.warn("Phaser.Loader dataLoadError: " + b.key), this.nextFile(a, !0)
  8213. },
  8214. xmlLoadComplete: function(a) {
  8215. "" !== this._xhr.responseType && "text" !== this._xhr.responseType && (console.warn("Invalid XML Response Type", this._fileList[a]), console.warn(this._xhr));
  8216. var b, c = this._xhr.responseText;
  8217. try {
  8218. if (window.DOMParser) {
  8219. var d = new DOMParser;
  8220. b = d.parseFromString(c, "text/xml")
  8221. } else b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(c)
  8222. } catch (e) {
  8223. b = void 0
  8224. }
  8225. if (!b || !b.documentElement || b.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid XML given");
  8226. var f = this._fileList[a];
  8227. f.loaded = !0, "bitmapfont" === f.type ? this.game.cache.addBitmapFont(f.key, f.url, f.data, b, f.xSpacing, f.ySpacing) : "textureatlas" === f.type ? this.game.cache.addTextureAtlas(f.key, f.url, f.data, b, f.format) : "xml" === f.type && this.game.cache.addXML(f.key, f.url, b), this.nextFile(a, !0)
  8228. },
  8229. nextFile: function(a, b) {
  8230. this.progressFloat += this._progressChunk, this.progress = Math.round(this.progressFloat), this.progress > 100 && (this.progress = 100), null !== this.preloadSprite && (0 === this.preloadSprite.direction ? this.preloadSprite.rect.width = Math.floor(this.preloadSprite.width / 100 * this.progress) : this.preloadSprite.rect.height = Math.floor(this.preloadSprite.height / 100 * this.progress), this.preloadSprite.sprite.updateCrop()), this.onFileComplete.dispatch(this.progress, this._fileList[a].key, b, this.totalLoadedFiles(), this._fileList.length), this.totalQueuedFiles() > 0 ? (this._fileIndex++, this.loadFile()) : (this.hasLoaded = !0, this.isLoading = !1, this.removeAll(), this.onLoadComplete.dispatch())
  8231. },
  8232. totalLoadedFiles: function() {
  8233. for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded && a++;
  8234. return a
  8235. },
  8236. totalQueuedFiles: function() {
  8237. for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded === !1 && a++;
  8238. return a
  8239. },
  8240. totalLoadedPacks: function() {
  8241. for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded && a++;
  8242. return a
  8243. },
  8244. totalQueuedPacks: function() {
  8245. for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded === !1 && a++;
  8246. return a
  8247. }
  8248. }, b.Loader.prototype.constructor = b.Loader, b.LoaderParser = {
  8249. bitmapFont: function(a, b, c, d, e) {
  8250. var f = {},
  8251. g = b.getElementsByTagName("info")[0],
  8252. h = b.getElementsByTagName("common")[0];
  8253. f.font = g.getAttribute("face"), f.size = parseInt(g.getAttribute("size"), 10), f.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + e, f.chars = {};
  8254. for (var i = b.getElementsByTagName("char"), j = 0; j < i.length; j++) {
  8255. var k = parseInt(i[j].getAttribute("id"), 10),
  8256. 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));
  8257. f.chars[k] = {
  8258. xOffset: parseInt(i[j].getAttribute("xoffset"), 10),
  8259. yOffset: parseInt(i[j].getAttribute("yoffset"), 10),
  8260. xAdvance: parseInt(i[j].getAttribute("xadvance"), 10) + d,
  8261. kerning: {},
  8262. texture: PIXI.TextureCache[c] = new PIXI.Texture(PIXI.BaseTextureCache[c], l)
  8263. }
  8264. }
  8265. var m = b.getElementsByTagName("kerning");
  8266. for (j = 0; j < m.length; j++) {
  8267. var n = parseInt(m[j].getAttribute("first"), 10),
  8268. o = parseInt(m[j].getAttribute("second"), 10),
  8269. p = parseInt(m[j].getAttribute("amount"), 10);
  8270. f.chars[o].kerning[n] = p
  8271. }
  8272. PIXI.BitmapText.fonts[c] = f
  8273. }
  8274. }, b.AudioSprite = function(a, b) {
  8275. this.game = a, this.key = b, this.config = this.game.cache.getJSON(b + "-audioatlas"), this.autoplayKey = null, this.autoplay = !1, this.sounds = {};
  8276. for (var c in this.config.spritemap) {
  8277. var d = this.config.spritemap[c],
  8278. e = this.game.add.sound(this.key);
  8279. d.loop ? e.addMarker(c, d.start, d.end - d.start, null, !0) : e.addMarker(c, d.start, d.end - d.start, null, !1), this.sounds[c] = e
  8280. }
  8281. this.config.autoplay && (this.autoplayKey = this.config.autoplay, this.play(this.autoplayKey), this.autoplay = this.sounds[this.autoplayKey])
  8282. }, b.AudioSprite.prototype = {
  8283. play: function(a, b) {
  8284. return "undefined" == typeof b && (b = 1), this.sounds[a].play(a, null, b)
  8285. },
  8286. stop: function(a) {
  8287. if (a) this.sounds[a].stop();
  8288. else
  8289. for (var b in this.sounds) this.sounds[b].stop()
  8290. },
  8291. get: function(a) {
  8292. return this.sounds[a]
  8293. }
  8294. }, b.AudioSprite.prototype.constructor = b.AudioSprite, b.Sound = function(a, c, d, e, f) {
  8295. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = a.sound.connectToMaster), this.game = a, this.name = c, this.key = c, this.loop = e, this.volume = d, this.markers = {}, this.context = null, this.autoplay = !1, this.totalDuration = 0, this.startTime = 0, this.currentTime = 0, this.duration = 0, this.durationMS = 0, this.position = 0, this.stopTime = 0, this.paused = !1, this.pausedPosition = 0, this.pausedTime = 0, this.isPlaying = !1, this.currentMarker = "", this.pendingPlayback = !1, this.override = !1, this.allowMultiple = !1, this.usingWebAudio = this.game.sound.usingWebAudio, this.usingAudioTag = this.game.sound.usingAudioTag, this.externalNode = null, this.masterGainNode = null, this.gainNode = null, this.usingWebAudio ? (this.context = this.game.sound.context, this.masterGainNode = this.game.sound.masterGain, this.gainNode = "undefined" == typeof this.context.createGain ? this.context.createGainNode() : this.context.createGain(), this.gainNode.gain.value = d * this.game.sound.volume, f && this.gainNode.connect(this.masterGainNode)) : this.game.cache.getSound(c) && this.game.cache.isSoundReady(c) ? (this._sound = this.game.cache.getSoundData(c), this.totalDuration = 0, this._sound.duration && (this.totalDuration = this._sound.duration)) : this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this), this.onDecoded = new b.Signal, this.onPlay = new b.Signal, this.onPause = new b.Signal, this.onResume = new b.Signal, this.onLoop = new b.Signal, this.onStop = new b.Signal, this.onMute = new b.Signal, this.onMarkerComplete = new b.Signal, this.onFadeComplete = new b.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
  8296. }, b.Sound.prototype = {
  8297. soundHasUnlocked: function(a) {
  8298. a === this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration)
  8299. },
  8300. addMarker: function(a, b, c, d, e) {
  8301. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), this.markers[a] = {
  8302. name: a,
  8303. start: b,
  8304. stop: b + c,
  8305. volume: d,
  8306. duration: c,
  8307. durationMS: 1e3 * c,
  8308. loop: e
  8309. }
  8310. },
  8311. removeMarker: function(a) {
  8312. delete this.markers[a]
  8313. },
  8314. update: function() {
  8315. this.isDecoded && !this._onDecodedEventDispatched && (this.onDecoded.dispatch(this), this._onDecodedEventDispatched = !0), this.pendingPlayback && this.game.cache.isSoundReady(this.key) && (this.pendingPlayback = !1, this.play(this._tempMarker, this._tempPosition, this._tempVolume, this._tempLoop)), this.isPlaying && (this.currentTime = this.game.time.now - this.startTime, this.currentTime >= this.durationMS && (this.usingWebAudio ? this.loop ? (this.onLoop.dispatch(this), "" === this.currentMarker ? (this.currentTime = 0, this.startTime = this.game.time.now) : (this.onMarkerComplete.dispatch(this.currentMarker, this), this.play(this.currentMarker, 0, this.volume, !0, !0))) : this.stop() : this.loop ? (this.onLoop.dispatch(this), this.play(this.currentMarker, 0, this.volume, !0, !0)) : this.stop()))
  8316. },
  8317. play: function(a, b, c, d, e) {
  8318. if ("undefined" == typeof a && (a = ""), "undefined" == typeof e && (e = !0), this.isPlaying && !this.allowMultiple && !e && !this.override) return this;
  8319. if (this.isPlaying && !this.allowMultiple && (this.override || e) && (this.usingWebAudio ? "undefined" == typeof this._sound.stop ? this._sound.noteOff(0) : this._sound.stop(0) : this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0)), this.currentMarker = a, "" !== a) {
  8320. if (!this.markers[a]) return console.warn("Phaser.Sound.play: audio marker " + a + " doesn't exist"), this;
  8321. 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
  8322. } 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;
  8323. return this.usingWebAudio ? this.game.cache.isSoundDecoded(this.key) ? (null === this._buffer && (this._buffer = this.game.cache.getSoundData(this.key)), this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this._sound.connect(this.externalNode ? this.externalNode : this.gainNode), this.totalDuration = this._sound.buffer.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = 1e3 * this.totalDuration), this.loop && "" === a && (this._sound.loop = !0), "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, this.position, this.duration) : this._sound.start(0, this.position, this.duration), this.isPlaying = !0, this.startTime = this.game.time.now, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : (this.pendingPlayback = !0, this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding === !1 && this.game.sound.decode(this.key, this)) : this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked ? (this.game.cache.reloadSound(this.key), this.pendingPlayback = !0) : this._sound && (this.game.device.cocoonJS || 4 === this._sound.readyState) ? (this._sound.play(), this.totalDuration = this._sound.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = 1e3 * this.totalDuration), this._sound.currentTime = this.position, this._sound.muted = this._muted, this._sound.volume = this._muted ? 0 : this._volume, this.isPlaying = !0, this.startTime = this.game.time.now, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : this.pendingPlayback = !0, this
  8324. },
  8325. restart: function(a, b, c, d) {
  8326. a = a || "", b = b || 0, c = c || 1, "undefined" == typeof d && (d = !1), this.play(a, b, c, d, !0)
  8327. },
  8328. pause: function() {
  8329. this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.now, this.onPause.dispatch(this), this.stop())
  8330. },
  8331. resume: function() {
  8332. if (this.paused && this._sound) {
  8333. if (this.usingWebAudio) {
  8334. var a = this.position + this.pausedPosition / 1e3;
  8335. this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this._sound.connect(this.externalNode ? this.externalNode : this.gainNode), this.loop && (this._sound.loop = !0), "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, a, this.duration) : this._sound.start(0, a, this.duration)
  8336. } else this._sound.play();
  8337. this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.now - this.pausedTime, this.onResume.dispatch(this)
  8338. }
  8339. },
  8340. stop: function() {
  8341. if (this.isPlaying && this._sound)
  8342. if (this.usingWebAudio)
  8343. if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
  8344. else try {
  8345. this._sound.stop(0)
  8346. } catch (a) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
  8347. this.isPlaying = !1;
  8348. var b = this.currentMarker;
  8349. "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", this.paused || this.onStop.dispatch(this, b)
  8350. },
  8351. fadeIn: function(a, b) {
  8352. "undefined" == typeof b && (b = !1), this.paused || (this.play("", 0, 0, b), this.fadeTo(a, 1))
  8353. },
  8354. fadeOut: function(a) {
  8355. this.fadeTo(a, 0)
  8356. },
  8357. fadeTo: function(a, c) {
  8358. if (this.isPlaying && !this.paused && c !== this.volume) {
  8359. if ("undefined" == typeof a && (a = 1e3), "undefined" == typeof c) return void console.warn("Phaser.Sound.fadeTo: No Volume Specified.");
  8360. var d = this.game.add.tween(this).to({
  8361. volume: c
  8362. }, a, b.Easing.Linear.None, !0);
  8363. d.onComplete.add(this.fadeComplete, this)
  8364. }
  8365. },
  8366. fadeComplete: function() {
  8367. this.onFadeComplete.dispatch(this, this.volume), 0 === this.volume && this.stop()
  8368. },
  8369. destroy: function(a) {
  8370. "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())
  8371. }
  8372. }, b.Sound.prototype.constructor = b.Sound, Object.defineProperty(b.Sound.prototype, "isDecoding", {
  8373. get: function() {
  8374. return this.game.cache.getSound(this.key).isDecoding
  8375. }
  8376. }), Object.defineProperty(b.Sound.prototype, "isDecoded", {
  8377. get: function() {
  8378. return this.game.cache.isSoundDecoded(this.key)
  8379. }
  8380. }), Object.defineProperty(b.Sound.prototype, "mute", {
  8381. get: function() {
  8382. return this._muted || this.game.sound.mute
  8383. },
  8384. set: function(a) {
  8385. 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)
  8386. }
  8387. }), Object.defineProperty(b.Sound.prototype, "volume", {
  8388. get: function() {
  8389. return this._volume
  8390. },
  8391. set: function(a) {
  8392. 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)
  8393. }
  8394. }), b.SoundManager = function(a) {
  8395. this.game = a, this.onSoundDecode = new b.Signal, this._codeMuted = !1, this._muted = !1, this._unlockSource = null, this._volume = 1, this._sounds = [], this.context = null, this.usingWebAudio = !0, this.usingAudioTag = !1, this.noAudio = !1, this.connectToMaster = !0, this.touchLocked = !1, this.channels = 32
  8396. }, b.SoundManager.prototype = {
  8397. boot: function() {
  8398. 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) {
  8399. if (window.PhaserGlobal.disableAudio === !0) return this.usingWebAudio = !1, void(this.noAudio = !0);
  8400. if (window.PhaserGlobal.disableWebAudio === !0) return this.usingWebAudio = !1, this.usingAudioTag = !0, void(this.noAudio = !1)
  8401. }
  8402. if (window.AudioContext) try {
  8403. this.context = new window.AudioContext
  8404. } catch (a) {
  8405. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  8406. } else if (window.webkitAudioContext) try {
  8407. this.context = new window.webkitAudioContext
  8408. } catch (a) {
  8409. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  8410. }
  8411. 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))
  8412. },
  8413. unlock: function() {
  8414. if (this.touchLocked !== !1)
  8415. 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;
  8416. else {
  8417. var a = this.context.createBuffer(1, 1, 22050);
  8418. this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = a, this._unlockSource.connect(this.context.destination), this._unlockSource.noteOn(0)
  8419. }
  8420. },
  8421. stopAll: function() {
  8422. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].stop()
  8423. },
  8424. pauseAll: function() {
  8425. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].pause()
  8426. },
  8427. resumeAll: function() {
  8428. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].resume()
  8429. },
  8430. decode: function(a, b) {
  8431. b = b || null;
  8432. var c = this.game.cache.getSoundData(a);
  8433. if (c && this.game.cache.isSoundDecoded(a) === !1) {
  8434. this.game.cache.updateSound(a, "isDecoding", !0);
  8435. var d = this;
  8436. this.context.decodeAudioData(c, function(c) {
  8437. d.game.cache.decodedSound(a, c), b && d.onSoundDecode.dispatch(a, b)
  8438. })
  8439. }
  8440. },
  8441. update: function() {
  8442. 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);
  8443. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].update()
  8444. },
  8445. add: function(a, c, d, e) {
  8446. "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = this.connectToMaster);
  8447. var f = new b.Sound(this.game, a, c, d, e);
  8448. return this._sounds.push(f), f
  8449. },
  8450. addSprite: function(a) {
  8451. var c = new b.AudioSprite(this.game, a);
  8452. return c
  8453. },
  8454. remove: function(a) {
  8455. for (var b = this._sounds.length; b--;)
  8456. if (this._sounds[b] === a) return this._sounds[b].destroy(!1), this._sounds.splice(b, 1), !0;
  8457. return !1
  8458. },
  8459. removeByKey: function(a) {
  8460. 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++);
  8461. return c
  8462. },
  8463. play: function(a, b, c) {
  8464. var d = this.add(a, b, c);
  8465. return d.play(), d
  8466. },
  8467. setMute: function() {
  8468. if (!this._muted) {
  8469. this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
  8470. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !0)
  8471. }
  8472. },
  8473. unsetMute: function() {
  8474. if (this._muted && !this._codeMuted) {
  8475. this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
  8476. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !1)
  8477. }
  8478. },
  8479. destroy: function() {
  8480. this.stopAll();
  8481. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].destroy();
  8482. this._sounds = [], this.onSoundDecode.dispose()
  8483. }
  8484. }, b.SoundManager.prototype.constructor = b.SoundManager, Object.defineProperty(b.SoundManager.prototype, "mute", {
  8485. get: function() {
  8486. return this._muted
  8487. },
  8488. set: function(a) {
  8489. if (a = a || null) {
  8490. if (this._muted) return;
  8491. this._codeMuted = !0, this.setMute()
  8492. } else {
  8493. if (!this._muted) return;
  8494. this._codeMuted = !1, this.unsetMute()
  8495. }
  8496. }
  8497. }), Object.defineProperty(b.SoundManager.prototype, "volume", {
  8498. get: function() {
  8499. return this.usingWebAudio ? this.masterGain.gain.value : this._volume
  8500. },
  8501. set: function(a) {
  8502. if (this._volume = a, this.usingWebAudio) this.masterGain.gain.value = a;
  8503. else
  8504. for (var b = 0; b < this._sounds.length; b++) this._sounds[b].usingAudioTag && (this._sounds[b].volume = this._sounds[b].volume * a)
  8505. }
  8506. }), b.Utils.Debug = function(a) {
  8507. 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
  8508. }, b.Utils.Debug.prototype = {
  8509. boot: function() {
  8510. this.game.renderType === b.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 = b.Canvas.create(this.game.width, this.game.height, "", !0), this.context = this.canvas.getContext("2d"))
  8511. },
  8512. preUpdate: function() {
  8513. 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)
  8514. },
  8515. reset: function() {
  8516. this.context && this.context.clearRect(0, 0, this.game.width, this.game.height), this.sprite && this.bmd.clear()
  8517. },
  8518. start: function(a, b, c, d) {
  8519. "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
  8520. },
  8521. stop: function() {
  8522. this.context.restore(), this.context.globalAlpha = this.currentAlpha
  8523. },
  8524. line: function() {
  8525. 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;
  8526. this.currentY += this.lineHeight
  8527. },
  8528. soundInfo: function(a, b, c, d) {
  8529. 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()
  8530. },
  8531. cameraInfo: function(a, b, c, d) {
  8532. 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.stop()
  8533. },
  8534. timer: function(a, b, c, d) {
  8535. 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()
  8536. },
  8537. pointer: function(a, b, c, d, e) {
  8538. 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()))
  8539. },
  8540. spriteInputInfo: function(a, b, c, d) {
  8541. 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()
  8542. },
  8543. key: function(a, b, c, d) {
  8544. this.start(b, c, d, 150), this.line("Key:", a.keyCode, "isDown:", a.isDown), this.line("justPressed:", a.justPressed(), "justReleased:", a.justReleased()), this.line("Time Down:", a.timeDown.toFixed(0), "duration:", a.duration.toFixed(0)), this.stop()
  8545. },
  8546. inputInfo: function(a, b, c) {
  8547. 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()
  8548. },
  8549. spriteBounds: function(a, b, c) {
  8550. var d = a.getBounds();
  8551. d.x += this.game.camera.x, d.y += this.game.camera.y, this.rectangle(d, b, c)
  8552. },
  8553. ropeSegments: function(a, b, c) {
  8554. var d = a.segments;
  8555. d.forEach(function(a) {
  8556. this.rectangle(a, b, c)
  8557. }, this)
  8558. },
  8559. spriteInfo: function(a, b, c, d) {
  8560. this.start(b, c, d), this.line("Sprite: (" + a.width + " x " + a.height + ") anchor: " + a.anchor.x + " x " + a.anchor.y), this.line("x: " + a.x.toFixed(1) + " y: " + a.y.toFixed(1)), this.line("angle: " + a.angle.toFixed(1) + " rotation: " + a.rotation.toFixed(1)), this.line("visible: " + a.visible + " in camera: " + a.inCamera), this.stop()
  8561. },
  8562. spriteCoords: function(a, b, c, d) {
  8563. 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()
  8564. },
  8565. lineInfo: function(a, b, c, d) {
  8566. 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()
  8567. },
  8568. pixel: function(a, b, c, d) {
  8569. d = d || 2, this.start(), this.context.fillStyle = c, this.context.fillRect(a, b, d, d), this.stop()
  8570. },
  8571. geom: function(a, c, d, e) {
  8572. "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = 0), c = c || "rgba(0,255,0,0.4)", this.start(), this.context.fillStyle = c, this.context.strokeStyle = c, a instanceof b.Rectangle || 1 === e ? d ? this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height) : this.context.strokeRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height) : a instanceof b.Circle || 2 === e ? (this.context.beginPath(), this.context.arc(a.x - this.game.camera.x, a.y - this.game.camera.y, a.radius, 0, 2 * Math.PI, !1), this.context.closePath(), d ? this.context.fill() : this.context.stroke()) : a instanceof b.Point || 3 === e ? this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, 4, 4) : (a instanceof b.Line || 4 === e) && (this.context.lineWidth = 1, this.context.beginPath(), this.context.moveTo(a.start.x + .5 - this.game.camera.x, a.start.y + .5 - this.game.camera.y), this.context.lineTo(a.end.x + .5 - this.game.camera.x, a.end.y + .5 - this.game.camera.y), this.context.closePath(), this.context.stroke()), this.stop()
  8573. },
  8574. rectangle: function(a, b, c) {
  8575. "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()
  8576. },
  8577. text: function(a, b, c, d, e) {
  8578. 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()
  8579. },
  8580. quadTree: function(a, b) {
  8581. b = b || "rgba(255,0,0,0.3)", this.start();
  8582. var c = a.bounds;
  8583. if (0 === a.nodes.length) {
  8584. 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)";
  8585. 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)
  8586. } else
  8587. for (var d = 0; d < a.nodes.length; d++) this.quadTree(a.nodes[d]);
  8588. this.stop()
  8589. },
  8590. body: function(a, c, d) {
  8591. a.body && (this.start(), a.body.type === b.Physics.ARCADE ? b.Physics.Arcade.Body.render(this.context, a.body, c, d) : a.body.type === b.Physics.NINJA ? b.Physics.Ninja.Body.render(this.context, a.body, c, d) : a.body.type === b.Physics.BOX2D && b.Physics.Box2D.renderBody(this.context, a.body, c), this.stop())
  8592. },
  8593. bodyInfo: function(a, c, d, e) {
  8594. a.body && (this.start(c, d, e, 210), a.body.type === b.Physics.ARCADE ? b.Physics.Arcade.Body.renderBodyInfo(this, a.body) : a.body.type === b.Physics.BOX2D && this.game.physics.box2d.renderBodyInfo(this, a.body), this.stop())
  8595. },
  8596. box2dWorld: function() {
  8597. 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()
  8598. },
  8599. box2dBody: function(a, c) {
  8600. this.start(), b.Physics.Box2D.renderBody(this.context, a, c), this.stop()
  8601. }
  8602. }, b.Utils.Debug.prototype.constructor = b.Utils.Debug, b.Color = {
  8603. packPixel: function(a, c, d, e) {
  8604. return b.Device.LITTLE_ENDIAN ? (e << 24 | d << 16 | c << 8 | a) >>> 0 : (a << 24 | c << 16 | d << 8 | e) >>> 0
  8605. },
  8606. unpackPixel: function(a, c, d, e) {
  8607. return ("undefined" == typeof c || null === c) && (c = b.Color.createColor()), ("undefined" == typeof d || null === d) && (d = !1), ("undefined" == typeof e || null === e) && (e = !1), b.Device.LITTLE_ENDIAN ? (c.a = (4278190080 & a) >>> 24, c.b = (16711680 & a) >>> 16, c.g = (65280 & a) >>> 8, c.r = 255 & a) : (c.r = (4278190080 & a) >>> 24, c.g = (16711680 & a) >>> 16, c.b = (65280 & a) >>> 8, c.a = 255 & a), c.color = a, c.rgba = "rgba(" + c.r + "," + c.g + "," + c.b + "," + c.a / 255 + ")", d && b.Color.RGBtoHSL(c.r, c.g, c.b, c), e && b.Color.RGBtoHSV(c.r, c.g, c.b, c), c
  8608. },
  8609. fromRGBA: function(a, c) {
  8610. return c || (c = b.Color.createColor()), c.r = (4278190080 & a) >>> 24, c.g = (16711680 & a) >>> 16, c.b = (65280 & a) >>> 8, c.a = 255 & a, c.rgba = "rgba(" + c.r + "," + c.g + "," + c.b + "," + c.a + ")", c
  8611. },
  8612. toRGBA: function(a, b, c, d) {
  8613. return a << 24 | b << 16 | c << 8 | d
  8614. },
  8615. RGBtoHSL: function(a, c, d, e) {
  8616. e || (e = b.Color.createColor(a, c, d, 1)), a /= 255, c /= 255, d /= 255;
  8617. var f = Math.min(a, c, d),
  8618. g = Math.max(a, c, d);
  8619. if (e.h = 0, e.s = 0, e.l = (g + f) / 2, g !== f) {
  8620. var h = g - f;
  8621. e.s = e.l > .5 ? h / (2 - g - f) : h / (g + f), g === a ? e.h = (c - d) / h + (d > c ? 6 : 0) : g === c ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - c) / h + 4), e.h /= 6
  8622. }
  8623. return e
  8624. },
  8625. HSLtoRGB: function(a, c, d, e) {
  8626. if (e ? (e.r = d, e.g = d, e.b = d) : e = b.Color.createColor(d, d, d), 0 !== c) {
  8627. var f = .5 > d ? d * (1 + c) : d + c - d * c,
  8628. g = 2 * d - f;
  8629. e.r = b.Color.hueToColor(g, f, a + 1 / 3), e.g = b.Color.hueToColor(g, f, a), e.b = b.Color.hueToColor(g, f, a - 1 / 3)
  8630. }
  8631. return e.r = Math.floor(255 * e.r | 0), e.g = Math.floor(255 * e.g | 0), e.b = Math.floor(255 * e.b | 0), b.Color.updateColor(e), e
  8632. },
  8633. RGBtoHSV: function(a, c, d, e) {
  8634. e || (e = b.Color.createColor(a, c, d, 255)), a /= 255, c /= 255, d /= 255;
  8635. var f = Math.min(a, c, d),
  8636. g = Math.max(a, c, d),
  8637. h = g - f;
  8638. return e.h = 0, e.s = 0 === g ? 0 : h / g, e.v = g, g !== f && (g === a ? e.h = (c - d) / h + (d > c ? 6 : 0) : g === c ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - c) / h + 4), e.h /= 6), e
  8639. },
  8640. HSVtoRGB: function(a, c, d, e) {
  8641. "undefined" == typeof e && (e = b.Color.createColor(0, 0, 0, 1, a, c, 0, d));
  8642. var f, g, h, i = Math.floor(6 * a),
  8643. j = 6 * a - i,
  8644. k = d * (1 - c),
  8645. l = d * (1 - j * c),
  8646. m = d * (1 - (1 - j) * c);
  8647. switch (i % 6) {
  8648. case 0:
  8649. f = d, g = m, h = k;
  8650. break;
  8651. case 1:
  8652. f = l, g = d, h = k;
  8653. break;
  8654. case 2:
  8655. f = k, g = d, h = m;
  8656. break;
  8657. case 3:
  8658. f = k, g = l, h = d;
  8659. break;
  8660. case 4:
  8661. f = m, g = k, h = d;
  8662. break;
  8663. case 5:
  8664. f = d, g = k, h = l
  8665. }
  8666. return e.r = Math.floor(255 * f), e.g = Math.floor(255 * g), e.b = Math.floor(255 * h), b.Color.updateColor(e), e
  8667. },
  8668. hueToColor: function(a, b, c) {
  8669. 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
  8670. },
  8671. createColor: function(a, c, d, e, f, g, h, i) {
  8672. var j = {
  8673. r: a || 0,
  8674. g: c || 0,
  8675. b: d || 0,
  8676. a: e || 1,
  8677. h: f || 0,
  8678. s: g || 0,
  8679. l: h || 0,
  8680. v: i || 0,
  8681. color: 0,
  8682. color32: 0,
  8683. rgba: ""
  8684. };
  8685. return j.color = b.Color.getColor(j.r, j.g, j.b), j.color32 = b.Color.getColor32(j.a, j.r, j.g, j.b), b.Color.updateColor(j)
  8686. },
  8687. updateColor: function(a) {
  8688. return a.rgba = "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + a.a.toString() + ")", a
  8689. },
  8690. getColor32: function(a, b, c, d) {
  8691. return a << 24 | b << 16 | c << 8 | d
  8692. },
  8693. getColor: function(a, b, c) {
  8694. return a << 16 | b << 8 | c
  8695. },
  8696. RGBtoString: function(a, c, d, e, f) {
  8697. return "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = "#"), "#" === f ? "#" + ((1 << 24) + (a << 16) + (c << 8) + d).toString(16).slice(1) : "0x" + b.Color.componentToHex(e) + b.Color.componentToHex(a) + b.Color.componentToHex(c) + b.Color.componentToHex(d)
  8698. },
  8699. hexToRGB: function(a) {
  8700. var c = b.Color.hexToColor(a);
  8701. return c ? b.Color.getColor32(c.a, c.r, c.g, c.b) : void 0
  8702. },
  8703. hexToColor: function(a, c) {
  8704. a = a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function(a, b, c, d) {
  8705. return b + b + c + c + d + d
  8706. });
  8707. var d = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
  8708. if (d) {
  8709. var e = parseInt(d[1], 16),
  8710. f = parseInt(d[2], 16),
  8711. g = parseInt(d[3], 16);
  8712. c ? (c.r = e, c.g = f, c.b = g) : c = b.Color.createColor(e, f, g)
  8713. }
  8714. return c
  8715. },
  8716. webToColor: function(a, c) {
  8717. c || (c = b.Color.createColor());
  8718. var d = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/.exec(a);
  8719. return d && (c.r = parseInt(d[1], 10), c.g = parseInt(d[2], 10), c.b = parseInt(d[3], 10)), c
  8720. },
  8721. componentToHex: function(a) {
  8722. var b = a.toString(16);
  8723. return 1 == b.length ? "0" + b : b
  8724. },
  8725. HSVColorWheel: function(a, c) {
  8726. "undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1);
  8727. for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSVtoRGB(e / 359, a, c));
  8728. return d
  8729. },
  8730. HSLColorWheel: function(a, c) {
  8731. "undefined" == typeof a && (a = .5), "undefined" == typeof c && (c = .5);
  8732. for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSLtoRGB(e / 359, a, c));
  8733. return d
  8734. },
  8735. interpolateColor: function(a, c, d, e, f) {
  8736. "undefined" == typeof f && (f = 255);
  8737. var g = b.Color.getRGB(a),
  8738. h = b.Color.getRGB(c),
  8739. i = (h.red - g.red) * e / d + g.red,
  8740. j = (h.green - g.green) * e / d + g.green,
  8741. k = (h.blue - g.blue) * e / d + g.blue;
  8742. return b.Color.getColor32(f, i, j, k)
  8743. },
  8744. interpolateColorWithRGB: function(a, c, d, e, f, g) {
  8745. var h = b.Color.getRGB(a),
  8746. i = (c - h.red) * g / f + h.red,
  8747. j = (d - h.green) * g / f + h.green,
  8748. k = (e - h.blue) * g / f + h.blue;
  8749. return b.Color.getColor(i, j, k)
  8750. },
  8751. interpolateRGB: function(a, c, d, e, f, g, h, i) {
  8752. var j = (e - a) * i / h + a,
  8753. k = (f - c) * i / h + c,
  8754. l = (g - d) * i / h + d;
  8755. return b.Color.getColor(j, k, l)
  8756. },
  8757. getRandomColor: function(a, c, d) {
  8758. if ("undefined" == typeof a && (a = 0), "undefined" == typeof c && (c = 255), "undefined" == typeof d && (d = 255), c > 255 || a > c) return b.Color.getColor(255, 255, 255);
  8759. var e = a + Math.round(Math.random() * (c - a)),
  8760. f = a + Math.round(Math.random() * (c - a)),
  8761. g = a + Math.round(Math.random() * (c - a));
  8762. return b.Color.getColor32(d, e, f, g)
  8763. },
  8764. getRGB: function(a) {
  8765. return a > 16777215 ? {
  8766. alpha: a >>> 24,
  8767. red: a >> 16 & 255,
  8768. green: a >> 8 & 255,
  8769. blue: 255 & a,
  8770. a: a >>> 24,
  8771. r: a >> 16 & 255,
  8772. g: a >> 8 & 255,
  8773. b: 255 & a
  8774. } : {
  8775. alpha: 255,
  8776. red: a >> 16 & 255,
  8777. green: a >> 8 & 255,
  8778. blue: 255 & a,
  8779. a: 255,
  8780. r: a >> 16 & 255,
  8781. g: a >> 8 & 255,
  8782. b: 255 & a
  8783. }
  8784. },
  8785. getWebRGB: function(a) {
  8786. if ("object" == typeof a) return "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + (a.a / 255).toString() + ")";
  8787. var c = b.Color.getRGB(a);
  8788. return "rgba(" + c.r.toString() + "," + c.g.toString() + "," + c.b.toString() + "," + (c.a / 255).toString() + ")"
  8789. },
  8790. getAlpha: function(a) {
  8791. return a >>> 24
  8792. },
  8793. getAlphaFloat: function(a) {
  8794. return (a >>> 24) / 255
  8795. },
  8796. getRed: function(a) {
  8797. return a >> 16 & 255
  8798. },
  8799. getGreen: function(a) {
  8800. return a >> 8 & 255
  8801. },
  8802. getBlue: function(a) {
  8803. return 255 & a
  8804. }
  8805. }, b.Physics = function(a, b) {
  8806. 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()
  8807. }, b.Physics.ARCADE = 0, b.Physics.P2JS = 1, b.Physics.NINJA = 2, b.Physics.BOX2D = 3, b.Physics.CHIPMUNK = 4, b.Physics.prototype = {
  8808. parseConfig: function() {
  8809. this.config.hasOwnProperty("arcade") && this.config.arcade !== !0 || !b.Physics.hasOwnProperty("Arcade") || (this.arcade = new b.Physics.Arcade(this.game), this.game.time.deltaCap = .2), this.config.hasOwnProperty("ninja") && this.config.ninja === !0 && b.Physics.hasOwnProperty("Ninja") && (this.ninja = new b.Physics.Ninja(this.game)), this.config.hasOwnProperty("p2") && this.config.p2 === !0 && b.Physics.hasOwnProperty("P2") && (this.p2 = new b.Physics.P2(this.game, this.config)), this.config.hasOwnProperty("box2d") && this.config.box2d === !0 && b.Physics.hasOwnProperty("BOX2D") && (this.box2d = new b.Physics.BOX2D(this.game, this.config))
  8810. },
  8811. startSystem: function(a) {
  8812. if (a === b.Physics.ARCADE ? this.arcade = new b.Physics.Arcade(this.game) : a === b.Physics.P2JS && (this.p2 = new b.Physics.P2(this.game, this.config)), a === b.Physics.NINJA) this.ninja = new b.Physics.Ninja(this.game);
  8813. else if (a === b.Physics.BOX2D && null === this.box2d) this.box2d = new b.Physics.Box2D(this.game, this.config);
  8814. else if (a === b.Physics.CHIPMUNK && null === this.chipmunk) throw new Error("The Chipmunk physics system has not been implemented yet.")
  8815. },
  8816. enable: function(a, c, d) {
  8817. "undefined" == typeof c && (c = b.Physics.ARCADE), "undefined" == typeof d && (d = !1), c === b.Physics.ARCADE ? this.arcade.enable(a) : c === b.Physics.P2JS && this.p2 ? this.p2.enable(a, d) : c === b.Physics.NINJA && this.ninja ? this.ninja.enableAABB(a) : c === b.Physics.BOX2D && this.box2d && this.box2d.enable(a)
  8818. },
  8819. preUpdate: function() {
  8820. this.p2 && this.p2.preUpdate(), this.box2d && this.box2d.preUpdate()
  8821. },
  8822. update: function() {
  8823. this.p2 && this.p2.update(), this.box2d && this.box2d.update()
  8824. },
  8825. setBoundsToWorld: function() {
  8826. this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld(), this.box2d && this.box2d.setBoundsToWorld()
  8827. },
  8828. clear: function() {
  8829. this.p2 && this.p2.clear(), this.box2d && this.box2d.clear()
  8830. },
  8831. destroy: function() {
  8832. this.p2 && this.p2.destroy(), this.box2d && this.box2d.destroy(), this.arcade = null, this.ninja = null, this.p2 = null, this.box2d = null
  8833. }
  8834. }, b.Physics.prototype.constructor = b.Physics, b.Physics.Arcade = function(a) {
  8835. this.game = a, this.gravity = new b.Point, this.bounds = new b.Rectangle(0, 0, a.world.width, a.world.height), this.checkCollision = {
  8836. up: !0,
  8837. down: !0,
  8838. left: !0,
  8839. right: !0
  8840. }, this.maxObjects = 10, this.maxLevels = 4, this.OVERLAP_BIAS = 4, this.TILE_BIAS = 16, this.forceX = !1, this.skipQuadTree = !1, this.quadTree = new b.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this._overlap = 0, this._maxOverlap = 0, this._velocity1 = 0, this._velocity2 = 0, this._newVelocity1 = 0, this._newVelocity2 = 0, this._average = 0, this._mapData = [], this._result = !1, this._total = 0, this._angle = 0, this._dx = 0, this._dy = 0, this.setBoundsToWorld()
  8841. }, b.Physics.Arcade.prototype.constructor = b.Physics.Arcade, b.Physics.Arcade.prototype = {
  8842. setBounds: function(a, b, c, d) {
  8843. this.bounds.setTo(a, b, c, d)
  8844. },
  8845. setBoundsToWorld: function() {
  8846. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  8847. },
  8848. enable: function(a, c) {
  8849. "undefined" == typeof c && (c = !0);
  8850. var d = 1;
  8851. if (Array.isArray(a))
  8852. for (d = a.length; d--;) a[d] instanceof b.Group ? this.enable(a[d].children, c) : (this.enableBody(a[d]), c && a[d].hasOwnProperty("children") && a[d].children.length > 0 && this.enable(a[d], !0));
  8853. else a instanceof b.Group ? this.enable(a.children, c) : (this.enableBody(a), c && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, !0))
  8854. },
  8855. enableBody: function(a) {
  8856. a.hasOwnProperty("body") && null === a.body && (a.body = new b.Physics.Arcade.Body(a))
  8857. },
  8858. updateMotion: function(a) {
  8859. this._velocityDelta = this.computeVelocity(0, a, a.angularVelocity, a.angularAcceleration, a.angularDrag, a.maxAngular) - a.angularVelocity, a.angularVelocity += this._velocityDelta, a.rotation += a.angularVelocity * this.game.time.physicsElapsed, a.velocity.x = this.computeVelocity(1, a, a.velocity.x, a.acceleration.x, a.drag.x, a.maxVelocity.x), a.velocity.y = this.computeVelocity(2, a, a.velocity.y, a.acceleration.y, a.drag.y, a.maxVelocity.y)
  8860. },
  8861. computeVelocity: function(a, b, c, d, e, f) {
  8862. return f = f || 1e4, 1 == a && b.allowGravity ? c += (this.gravity.x + b.gravity.x) * this.game.time.physicsElapsed : 2 == a && b.allowGravity && (c += (this.gravity.y + b.gravity.y) * this.game.time.physicsElapsed), d ? c += d * this.game.time.physicsElapsed : e && (this._drag = e * this.game.time.physicsElapsed, c - this._drag > 0 ? c -= this._drag : c + this._drag < 0 ? c += this._drag : c = 0), c > f ? c = f : -f > c && (c = -f), c
  8863. },
  8864. overlap: function(a, b, c, d, e) {
  8865. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, !Array.isArray(a) && Array.isArray(b))
  8866. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !0);
  8867. else if (Array.isArray(a) && !Array.isArray(b))
  8868. for (var f = 0, g = a.length; g > f; f++) this.collideHandler(a[f], b, c, d, e, !0);
  8869. else if (Array.isArray(a) && Array.isArray(b))
  8870. for (var f = 0, g = a.length; g > f; f++)
  8871. for (var h = 0, i = b.length; i > h; h++) this.collideHandler(a[f], b[h], c, d, e, !0);
  8872. else this.collideHandler(a, b, c, d, e, !0);
  8873. return this._total > 0
  8874. },
  8875. collide: function(a, b, c, d, e) {
  8876. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, !Array.isArray(a) && Array.isArray(b))
  8877. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !1);
  8878. else if (Array.isArray(a) && !Array.isArray(b))
  8879. for (var f = 0, g = a.length; g > f; f++) this.collideHandler(a[f], b, c, d, e, !1);
  8880. else if (Array.isArray(a) && Array.isArray(b))
  8881. for (var f = 0, h = a.length; h > f; f++)
  8882. for (var i = 0, j = b.length; j > i; i++) this.collideHandler(a[f], b[i], c, d, e, !1);
  8883. else this.collideHandler(a, b, c, d, e, !1);
  8884. return this._total > 0
  8885. },
  8886. collideHandler: function(a, c, d, e, f, g) {
  8887. return "undefined" != typeof c || a.type !== b.GROUP && a.type !== b.EMITTER ? void(a && c && a.exists && c.exists && (a.type == b.SPRITE || a.type == b.TILESPRITE ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsSprite(a, c, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideSpriteVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideSpriteVsTilemapLayer(a, c, d, e, f) : a.type == b.GROUP ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsGroup(c, a, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideGroupVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, c, d, e, f) : a.type == b.TILEMAPLAYER ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsTilemapLayer(c, a, d, e, f) : (c.type == b.GROUP || c.type == b.EMITTER) && this.collideGroupVsTilemapLayer(c, a, d, e, f) : a.type == b.EMITTER && (c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsGroup(c, a, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideGroupVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, c, d, e, f)))) : void this.collideGroupVsSelf(a, d, e, f, g)
  8888. },
  8889. collideSpriteVsSprite: function(a, b, c, d, e, f) {
  8890. return a.body && b.body ? (this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++), !0) : !1
  8891. },
  8892. collideSpriteVsGroup: function(a, b, c, d, e, f) {
  8893. if (0 !== b.length && a.body)
  8894. if (a.body.skipQuadTree || this.skipQuadTree)
  8895. for (var g = 0, h = b.children.length; h > g; g++) b.children[g] && b.children[g].exists && this.collideSpriteVsSprite(a, b.children[g], c, d, e, f);
  8896. else {
  8897. this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(b), this._potentials = this.quadTree.retrieve(a);
  8898. for (var g = 0, h = this._potentials.length; h > g; g++) this.separate(a.body, this._potentials[g], d, e, f) && (c && c.call(e, a, this._potentials[g].sprite), this._total++)
  8899. }
  8900. },
  8901. collideGroupVsSelf: function(a, b, c, d, e) {
  8902. if (0 !== a.length)
  8903. for (var f = a.children.length, g = 0; f > g; g++)
  8904. for (var h = g + 1; f >= h; h++) a.children[g] && a.children[h] && a.children[g].exists && a.children[h].exists && this.collideSpriteVsSprite(a.children[g], a.children[h], b, c, d, e)
  8905. },
  8906. collideGroupVsGroup: function(a, c, d, e, f, g) {
  8907. if (0 !== a.length && 0 !== c.length)
  8908. for (var h = 0, i = a.children.length; i > h; h++) a.children[h].exists && (a.children[h].type === b.GROUP ? this.collideGroupVsGroup(a.children[h], c, d, e, f, g) : this.collideSpriteVsGroup(a.children[h], c, d, e, f, g))
  8909. },
  8910. collideSpriteVsTilemapLayer: function(a, b, c, d, e) {
  8911. if (a.body && (this._mapData = b.getTiles(a.body.position.x - a.body.tilePadding.x, a.body.position.y - a.body.tilePadding.y, a.body.width + a.body.tilePadding.x, a.body.height + a.body.tilePadding.y, !1, !1), 0 !== this._mapData.length))
  8912. for (var f = 0; f < this._mapData.length; f++) d ? d.call(e, a, this._mapData[f]) && this.separateTile(f, a.body, this._mapData[f]) && (this._total++, c && c.call(e, a, this._mapData[f])) : this.separateTile(f, a.body, this._mapData[f]) && (this._total++, c && c.call(e, a, this._mapData[f]))
  8913. },
  8914. collideGroupVsTilemapLayer: function(a, b, c, d, e) {
  8915. if (0 !== a.length)
  8916. for (var f = 0, g = a.children.length; g > f; f++) a.children[f].exists && this.collideSpriteVsTilemapLayer(a.children[f], b, c, d, e)
  8917. },
  8918. separate: function(a, b, c, d, e) {
  8919. return a.enable && b.enable && this.intersects(a, b) ? c && c.call(d, a.sprite, b.sprite) === !1 ? !1 : (this._result = this.forceX || Math.abs(this.gravity.y + a.gravity.y) < Math.abs(this.gravity.x + a.gravity.x) ? this.separateX(a, b, e) || this.separateY(a, b, e) : this.separateY(a, b, e) || this.separateX(a, b, e), e ? !0 : this._result) : !1
  8920. },
  8921. intersects: function(a, b) {
  8922. 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
  8923. },
  8924. separateX: function(a, b, c) {
  8925. return a.immovable && b.immovable ? !1 : (this._overlap = 0, this.intersects(a, b) && (this._maxOverlap = a.deltaAbsX() + b.deltaAbsX() + this.OVERLAP_BIAS, 0 === a.deltaX() && 0 === b.deltaX() ? (a.embedded = !0, b.embedded = !0) : a.deltaX() > b.deltaX() ? (this._overlap = a.right - b.x, this._overlap > this._maxOverlap || a.checkCollision.right === !1 || b.checkCollision.left === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.right = !0, b.touching.none = !1, b.touching.left = !0)) : a.deltaX() < b.deltaX() && (this._overlap = a.x - b.width - b.x, -this._overlap > this._maxOverlap || a.checkCollision.left === !1 || b.checkCollision.right === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.left = !0, b.touching.none = !1, b.touching.right = !0)), a.overlapX = this._overlap, b.overlapX = this._overlap, 0 !== this._overlap) ? c || a.customSeparateX || b.customSeparateX ? !0 : (this._velocity1 = a.velocity.x, this._velocity2 = b.velocity.x, a.immovable || b.immovable ? a.immovable ? b.immovable || (b.x += this._overlap, b.velocity.x = this._velocity1 - this._velocity2 * b.bounce.x) : (a.x = a.x - this._overlap, a.velocity.x = this._velocity2 - this._velocity1 * a.bounce.x) : (this._overlap *= .5, a.x = a.x - this._overlap, b.x += this._overlap, this._newVelocity1 = Math.sqrt(this._velocity2 * this._velocity2 * b.mass / a.mass) * (this._velocity2 > 0 ? 1 : -1), this._newVelocity2 = Math.sqrt(this._velocity1 * this._velocity1 * a.mass / b.mass) * (this._velocity1 > 0 ? 1 : -1), this._average = .5 * (this._newVelocity1 + this._newVelocity2), this._newVelocity1 -= this._average, this._newVelocity2 -= this._average, a.velocity.x = this._average + this._newVelocity1 * a.bounce.x, b.velocity.x = this._average + this._newVelocity2 * b.bounce.x), !0) : !1)
  8926. },
  8927. separateY: function(a, b, c) {
  8928. return a.immovable && b.immovable ? !1 : (this._overlap = 0, this.intersects(a, b) && (this._maxOverlap = a.deltaAbsY() + b.deltaAbsY() + this.OVERLAP_BIAS, 0 === a.deltaY() && 0 === b.deltaY() ? (a.embedded = !0, b.embedded = !0) : a.deltaY() > b.deltaY() ? (this._overlap = a.bottom - b.y, this._overlap > this._maxOverlap || a.checkCollision.down === !1 || b.checkCollision.up === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.down = !0, b.touching.none = !1, b.touching.up = !0)) : a.deltaY() < b.deltaY() && (this._overlap = a.y - b.bottom, -this._overlap > this._maxOverlap || a.checkCollision.up === !1 || b.checkCollision.down === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.up = !0, b.touching.none = !1, b.touching.down = !0)), a.overlapY = this._overlap, b.overlapY = this._overlap, 0 !== this._overlap) ? c || a.customSeparateY || b.customSeparateY ? !0 : (this._velocity1 = a.velocity.y, this._velocity2 = b.velocity.y, a.immovable || b.immovable ? a.immovable ? b.immovable || (b.y += this._overlap, b.velocity.y = this._velocity1 - this._velocity2 * b.bounce.y, a.moves && (b.x += a.x - a.prev.x)) : (a.y = a.y - this._overlap, a.velocity.y = this._velocity2 - this._velocity1 * a.bounce.y, b.moves && (a.x += b.x - b.prev.x)) : (this._overlap *= .5, a.y = a.y - this._overlap, b.y += this._overlap, this._newVelocity1 = Math.sqrt(this._velocity2 * this._velocity2 * b.mass / a.mass) * (this._velocity2 > 0 ? 1 : -1), this._newVelocity2 = Math.sqrt(this._velocity1 * this._velocity1 * a.mass / b.mass) * (this._velocity1 > 0 ? 1 : -1), this._average = .5 * (this._newVelocity1 + this._newVelocity2), this._newVelocity1 -= this._average, this._newVelocity2 -= this._average, a.velocity.y = this._average + this._newVelocity1 * a.bounce.y, b.velocity.y = this._average + this._newVelocity2 * b.bounce.y), !0) : !1)
  8929. },
  8930. separateTile: function(a, b, c) {
  8931. if (!b.enable || !c.intersects(b.position.x, b.position.y, b.right, b.bottom)) return !1;
  8932. if (c.collisionCallback && !c.collisionCallback.call(c.collisionCallbackContext, b.sprite, c)) return !1;
  8933. if (c.layer.callbacks[c.index] && !c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext, b.sprite, c)) return !1;
  8934. if (!(c.faceLeft || c.faceRight || c.faceTop || c.faceBottom)) return !1;
  8935. var d = 0,
  8936. e = 0,
  8937. f = 0,
  8938. g = 1;
  8939. 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) {
  8940. 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;
  8941. (c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c))
  8942. } else {
  8943. 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;
  8944. (c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c))
  8945. }
  8946. return 0 !== d || 0 !== e
  8947. },
  8948. tileCheckX: function(a, b) {
  8949. var c = 0;
  8950. return a.deltaX() < 0 && !a.blocked.left && b.collideRight && a.checkCollision.left ? b.faceRight && a.x < b.right && (c = a.x - b.right, c < -this.TILE_BIAS && (c = 0)) : a.deltaX() > 0 && !a.blocked.right && b.collideLeft && a.checkCollision.right && b.faceLeft && a.right > b.left && (c = a.right - b.left, c > this.TILE_BIAS && (c = 0)), 0 !== c && this.processTileSeparationX(a, c), c
  8951. },
  8952. tileCheckY: function(a, b) {
  8953. var c = 0;
  8954. return a.deltaY() < 0 && !a.blocked.up && b.collideDown && a.checkCollision.up ? b.faceBottom && a.y < b.bottom && (c = a.y - b.bottom, c < -this.TILE_BIAS && (c = 0)) : a.deltaY() > 0 && !a.blocked.down && b.collideUp && a.checkCollision.down && b.faceTop && a.bottom > b.top && (c = a.bottom - b.top, c > this.TILE_BIAS && (c = 0)), 0 !== c && this.processTileSeparationY(a, c), c
  8955. },
  8956. processTileSeparationX: function(a, b) {
  8957. 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
  8958. },
  8959. processTileSeparationY: function(a, b) {
  8960. 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
  8961. },
  8962. getObjectsUnderPointer: function(a, c, d, e) {
  8963. if (0 !== c.length && a.exists) {
  8964. this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(c);
  8965. var f = new b.Rectangle(a.x, a.y, 1, 1),
  8966. g = [];
  8967. this._potentials = this.quadTree.retrieve(f);
  8968. for (var h = 0, i = this._potentials.length; i > h; h++) this._potentials[h].hitTest(a.x, a.y) && (d && d.call(e, a, this._potentials[h].sprite), g.push(this._potentials[h].sprite));
  8969. return g
  8970. }
  8971. },
  8972. moveToObject: function(a, b, c, d) {
  8973. return "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 0), this._angle = Math.atan2(b.y - a.y, b.x - a.x), d > 0 && (c = this.distanceBetween(a, b) / (d / 1e3)), a.body.velocity.x = Math.cos(this._angle) * c, a.body.velocity.y = Math.sin(this._angle) * c, this._angle
  8974. },
  8975. moveToPointer: function(a, b, c, d) {
  8976. return "undefined" == typeof b && (b = 60), c = c || this.game.input.activePointer, "undefined" == typeof d && (d = 0), this._angle = this.angleToPointer(a, c), d > 0 && (b = this.distanceToPointer(a, c) / (d / 1e3)), a.body.velocity.x = Math.cos(this._angle) * b, a.body.velocity.y = Math.sin(this._angle) * b, this._angle
  8977. },
  8978. moveToXY: function(a, b, c, d, e) {
  8979. return "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 0), this._angle = Math.atan2(c - a.y, b - a.x), e > 0 && (d = this.distanceToXY(a, b, c) / (e / 1e3)), a.body.velocity.x = Math.cos(this._angle) * d, a.body.velocity.y = Math.sin(this._angle) * d, this._angle
  8980. },
  8981. velocityFromAngle: function(a, c, d) {
  8982. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(this.game.math.degToRad(a)) * c, Math.sin(this.game.math.degToRad(a)) * c)
  8983. },
  8984. velocityFromRotation: function(a, c, d) {
  8985. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  8986. },
  8987. accelerationFromRotation: function(a, c, d) {
  8988. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  8989. },
  8990. accelerateToObject: function(a, b, c, d, e) {
  8991. return "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3), this._angle = this.angleBetween(a, b), a.body.acceleration.setTo(Math.cos(this._angle) * c, Math.sin(this._angle) * c), a.body.maxVelocity.setTo(d, e), this._angle
  8992. },
  8993. accelerateToPointer: function(a, b, c, d, e) {
  8994. return "undefined" == typeof c && (c = 60), "undefined" == typeof b && (b = this.game.input.activePointer), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3), this._angle = this.angleToPointer(a, b), a.body.acceleration.setTo(Math.cos(this._angle) * c, Math.sin(this._angle) * c), a.body.maxVelocity.setTo(d, e), this._angle
  8995. },
  8996. accelerateToXY: function(a, b, c, d, e, f) {
  8997. return "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 1e3), "undefined" == typeof f && (f = 1e3), this._angle = this.angleToXY(a, b, c), a.body.acceleration.setTo(Math.cos(this._angle) * d, Math.sin(this._angle) * d), a.body.maxVelocity.setTo(e, f), this._angle
  8998. },
  8999. distanceBetween: function(a, b) {
  9000. return this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  9001. },
  9002. distanceToXY: function(a, b, c) {
  9003. return this._dx = a.x - b, this._dy = a.y - c, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  9004. },
  9005. distanceToPointer: function(a, b) {
  9006. return b = b || this.game.input.activePointer, this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  9007. },
  9008. angleBetween: function(a, b) {
  9009. return this._dx = b.x - a.x, this._dy = b.y - a.y, Math.atan2(this._dy, this._dx)
  9010. },
  9011. angleToXY: function(a, b, c) {
  9012. return this._dx = b - a.x, this._dy = c - a.y, Math.atan2(this._dy, this._dx)
  9013. },
  9014. angleToPointer: function(a, b) {
  9015. return b = b || this.game.input.activePointer, this._dx = b.worldX - a.x, this._dy = b.worldY - a.y, Math.atan2(this._dy, this._dx)
  9016. }
  9017. }, b.Physics.Arcade.Body = function(a) {
  9018. this.sprite = a, this.game = a.game, this.type = b.Physics.ARCADE, this.enable = !0, this.offset = new b.Point, this.position = new b.Point(a.x, a.y), this.prev = new b.Point(this.position.x, this.position.y), this.allowRotation = !0, this.rotation = a.rotation, this.preRotation = a.rotation, this.sourceWidth = a.texture.frame.width, this.sourceHeight = a.texture.frame.height, this.width = a.width, this.height = a.height, this.halfWidth = Math.abs(a.width / 2), this.halfHeight = Math.abs(a.height / 2), this.center = new b.Point(a.x + this.halfWidth, a.y + this.halfHeight), this.velocity = new b.Point, this.newVelocity = new b.Point(0, 0), this.deltaMax = new b.Point(0, 0), this.acceleration = new b.Point, this.drag = new b.Point, this.allowGravity = !0, this.gravity = new b.Point(0, 0), this.bounce = new b.Point, this.maxVelocity = new b.Point(1e4, 1e4), this.angularVelocity = 0, this.angularAcceleration = 0, this.angularDrag = 0, this.maxAngular = 1e3, this.mass = 1, this.angle = 0, this.speed = 0, this.facing = b.NONE, this.immovable = !1, this.moves = !0, this.customSeparateX = !1, this.customSeparateY = !1, this.overlapX = 0, this.overlapY = 0, this.embedded = !1, this.collideWorldBounds = !1, this.checkCollision = {
  9019. none: !1,
  9020. any: !0,
  9021. up: !0,
  9022. down: !0,
  9023. left: !0,
  9024. right: !0
  9025. }, this.touching = {
  9026. none: !0,
  9027. up: !1,
  9028. down: !1,
  9029. left: !1,
  9030. right: !1
  9031. }, this.wasTouching = {
  9032. none: !0,
  9033. up: !1,
  9034. down: !1,
  9035. left: !1,
  9036. right: !1
  9037. }, this.blocked = {
  9038. up: !1,
  9039. down: !1,
  9040. left: !1,
  9041. right: !1
  9042. }, this.tilePadding = new b.Point, this.phase = 0, this.skipQuadTree = !1, this._reset = !0, this._sx = a.scale.x, this._sy = a.scale.y, this._dx = 0, this._dy = 0
  9043. }, b.Physics.Arcade.Body.prototype = {
  9044. updateBounds: function() {
  9045. var a = Math.abs(this.sprite.scale.x),
  9046. b = Math.abs(this.sprite.scale.y);
  9047. (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)
  9048. },
  9049. preUpdate: function() {
  9050. this.enable && (this.phase = 1, this.wasTouching.none = this.touching.none, this.wasTouching.up = this.touching.up, this.wasTouching.down = this.touching.down, this.wasTouching.left = this.touching.left, this.wasTouching.right = this.touching.right, this.touching.none = !0, this.touching.up = !1, this.touching.down = !1, this.touching.left = !1, this.touching.right = !1, this.blocked.up = !1, this.blocked.down = !1, this.blocked.left = !1, this.blocked.right = !1, this.embedded = !1, this.updateBounds(), this.position.x = this.sprite.world.x - this.sprite.anchor.x * this.width + this.offset.x, this.position.y = this.sprite.world.y - this.sprite.anchor.y * this.height + this.offset.y, this.rotation = this.sprite.angle, this.preRotation = this.rotation, (this._reset || 1 === this.sprite._cache[4]) && (this.prev.x = this.position.x, this.prev.y = this.position.y), this.moves && (this.game.physics.arcade.updateMotion(this), this.newVelocity.set(this.velocity.x * this.game.time.physicsElapsed, this.velocity.y * this.game.time.physicsElapsed), this.position.x += this.newVelocity.x, this.position.y += this.newVelocity.y, (this.position.x !== this.prev.x || this.position.y !== this.prev.y) && (this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), this.angle = Math.atan2(this.velocity.y, this.velocity.x)), this.collideWorldBounds && this.checkWorldBounds()), this._dx = this.deltaX(), this._dy = this.deltaY(), this._reset = !1)
  9051. },
  9052. postUpdate: function() {
  9053. this.enable && 2 !== this.phase && (this.phase = 2, this.deltaX() < 0 ? this.facing = b.LEFT : this.deltaX() > 0 && (this.facing = b.RIGHT), this.deltaY() < 0 ? this.facing = b.UP : this.deltaY() > 0 && (this.facing = b.DOWN), this.moves && (this._dx = this.deltaX(), this._dy = this.deltaY(), 0 !== this.deltaMax.x && 0 !== this._dx && (this._dx < 0 && this._dx < -this.deltaMax.x ? this._dx = -this.deltaMax.x : this._dx > 0 && this._dx > this.deltaMax.x && (this._dx = this.deltaMax.x)), 0 !== this.deltaMax.y && 0 !== this._dy && (this._dy < 0 && this._dy < -this.deltaMax.y ? this._dy = -this.deltaMax.y : this._dy > 0 && this._dy > this.deltaMax.y && (this._dy = this.deltaMax.y)), this.sprite.x += this._dx, this.sprite.y += this._dy), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight), this.allowRotation && (this.sprite.angle += this.deltaZ()), this.prev.x = this.position.x, this.prev.y = this.position.y)
  9054. },
  9055. destroy: function() {
  9056. this.sprite.body = null, this.sprite = null
  9057. },
  9058. checkWorldBounds: function() {
  9059. 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)
  9060. },
  9061. setSize: function(a, b, c, d) {
  9062. "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)
  9063. },
  9064. reset: function(a, b) {
  9065. this.velocity.set(0), this.acceleration.set(0), this.angularVelocity = 0, this.angularAcceleration = 0, this.position.x = a - this.sprite.anchor.x * this.width + this.offset.x, this.position.y = b - this.sprite.anchor.y * this.height + this.offset.y, this.prev.x = this.position.x, this.prev.y = this.position.y, this.rotation = this.sprite.angle, this.preRotation = this.rotation, this._sx = this.sprite.scale.x, this._sy = this.sprite.scale.y, this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight)
  9066. },
  9067. hitTest: function(a, c) {
  9068. return b.Rectangle.contains(this, a, c)
  9069. },
  9070. onFloor: function() {
  9071. return this.blocked.down
  9072. },
  9073. onWall: function() {
  9074. return this.blocked.left || this.blocked.right
  9075. },
  9076. deltaAbsX: function() {
  9077. return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
  9078. },
  9079. deltaAbsY: function() {
  9080. return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
  9081. },
  9082. deltaX: function() {
  9083. return this.position.x - this.prev.x
  9084. },
  9085. deltaY: function() {
  9086. return this.position.y - this.prev.y
  9087. },
  9088. deltaZ: function() {
  9089. return this.rotation - this.preRotation
  9090. }
  9091. }, Object.defineProperty(b.Physics.Arcade.Body.prototype, "bottom", {
  9092. get: function() {
  9093. return this.position.y + this.height
  9094. }
  9095. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "right", {
  9096. get: function() {
  9097. return this.position.x + this.width
  9098. }
  9099. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "x", {
  9100. get: function() {
  9101. return this.position.x
  9102. },
  9103. set: function(a) {
  9104. this.position.x = a
  9105. }
  9106. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "y", {
  9107. get: function() {
  9108. return this.position.y
  9109. },
  9110. set: function(a) {
  9111. this.position.y = a
  9112. }
  9113. }), b.Physics.Arcade.Body.render = function(a, b, c, d) {
  9114. "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))
  9115. }, b.Physics.Arcade.Body.renderBodyInfo = function(a, b) {
  9116. 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)
  9117. }, b.Physics.Arcade.Body.prototype.constructor = b.Physics.Arcade.Body, b.Particles = function(a) {
  9118. this.game = a, this.emitters = {}, this.ID = 0
  9119. }, b.Particles.prototype = {
  9120. add: function(a) {
  9121. return this.emitters[a.name] = a, a
  9122. },
  9123. remove: function(a) {
  9124. delete this.emitters[a.name]
  9125. },
  9126. update: function() {
  9127. for (var a in this.emitters) this.emitters[a].exists && this.emitters[a].update()
  9128. }
  9129. }, b.Particles.prototype.constructor = b.Particles, b.Particles.Arcade = {}, b.Particles.Arcade.Emitter = function(a, c, d, e) {
  9130. this.maxParticles = e || 50, b.Group.call(this, a), this.name = "emitter" + this.game.particles.ID++, this.type = b.EMITTER, this.area = new b.Rectangle(c, d, 1, 1), this.minParticleSpeed = new b.Point(-100, -100), this.maxParticleSpeed = new b.Point(100, 100), this.minParticleScale = 1, this.maxParticleScale = 1, this.scaleData = null, this.minRotation = -360, this.maxRotation = 360, this.minParticleAlpha = 1, this.maxParticleAlpha = 1, this.alphaData = null, this.gravity = 100, this.particleClass = b.Particle, this.particleDrag = new b.Point, this.angularDrag = 0, this.frequency = 100, this.lifespan = 2e3, this.bounce = new b.Point, this.on = !1, this.particleAnchor = new b.Point(.5, .5), this.blendMode = b.blendModes.NORMAL, this.emitX = c, this.emitY = d, this.autoScale = !1, this.autoAlpha = !1, this.particleBringToTop = !1, this.particleSendToBack = !1, this._minParticleScale = new b.Point(1, 1), this._maxParticleScale = new b.Point(1, 1), this._quantity = 0, this._timer = 0, this._counter = 0, this._explode = !0, this._frames = null
  9131. }, b.Particles.Arcade.Emitter.prototype = Object.create(b.Group.prototype), b.Particles.Arcade.Emitter.prototype.constructor = b.Particles.Arcade.Emitter, b.Particles.Arcade.Emitter.prototype.update = function() {
  9132. if (this.on)
  9133. if (this._explode) {
  9134. this._counter = 0;
  9135. do this.emitParticle(), this._counter++; while (this._counter < this._quantity);
  9136. this.on = !1
  9137. } else this.game.time.now >= this._timer && (this.emitParticle(), this._counter++, this._quantity > 0 && this._counter >= this._quantity && (this.on = !1), this._timer = this.game.time.now + this.frequency);
  9138. for (var a = this.children.length; a--;) this.children[a].exists && this.children[a].update()
  9139. }, b.Particles.Arcade.Emitter.prototype.makeParticles = function(a, b, c, d, e) {
  9140. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.maxParticles), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  9141. var f, g = 0,
  9142. h = a,
  9143. i = b;
  9144. for (this._frames = b; c > g;) Array.isArray(a) && (h = this.game.rnd.pick(a)), Array.isArray(b) && (i = this.game.rnd.pick(b)), f = new this.particleClass(this.game, 0, 0, h, i), this.game.physics.arcade.enable(f, !1), d ? (f.body.checkCollision.any = !0, f.body.checkCollision.none = !1) : f.body.checkCollision.none = !0, f.body.collideWorldBounds = e, f.exists = !1, f.visible = !1, f.anchor.copyFrom(this.particleAnchor), this.add(f), g++;
  9145. return this
  9146. }, b.Particles.Arcade.Emitter.prototype.kill = function() {
  9147. this.on = !1, this.alive = !1, this.exists = !1
  9148. }, b.Particles.Arcade.Emitter.prototype.revive = function() {
  9149. this.alive = !0, this.exists = !0
  9150. }, b.Particles.Arcade.Emitter.prototype.explode = function(a, b) {
  9151. this.start(!0, a, 0, b, !1)
  9152. }, b.Particles.Arcade.Emitter.prototype.flow = function(a, b, c) {
  9153. this.start(!1, a, b, c, !0)
  9154. }, b.Particles.Arcade.Emitter.prototype.start = function(a, b, c, d, e) {
  9155. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = 0), ("undefined" == typeof c || null === c) && (c = 250), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = !1), this.revive(), this.visible = !0, this.on = !0, this._explode = a, this.lifespan = b, this.frequency = c, a || e ? this._quantity = d : this._quantity += d, this._counter = 0, this._timer = this.game.time.now + c
  9156. }, b.Particles.Arcade.Emitter.prototype.emitParticle = function() {
  9157. var a = this.getFirstExists(!1);
  9158. null !== a && (this.width > 1 || this.height > 1 ? a.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)) : a.reset(this.emitX, this.emitY), a.angle = 0, a.lifespan = this.lifespan, this.particleBringToTop ? this.bringToTop(a) : this.particleSendToBack && this.sendToBack(a), this.autoScale ? a.setScaleData(this.scaleData) : 1 !== this.minParticleScale || 1 !== this.maxParticleScale ? a.scale.set(this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale)) : (this._minParticleScale.x !== this._maxParticleScale.x || this._minParticleScale.y !== this._maxParticleScale.y) && a.scale.set(this.game.rnd.realInRange(this._minParticleScale.x, this._maxParticleScale.x), this.game.rnd.realInRange(this._minParticleScale.y, this._maxParticleScale.y)), a.frame = Array.isArray("object" === this._frames) ? this.game.rnd.pick(this._frames) : this._frames, this.autoAlpha ? a.setAlphaData(this.alphaData) : a.alpha = this.game.rnd.realInRange(this.minParticleAlpha, this.maxParticleAlpha), a.blendMode = this.blendMode, a.body.updateBounds(), a.body.bounce.setTo(this.bounce.x, this.bounce.y), a.body.velocity.x = this.game.rnd.integerInRange(this.minParticleSpeed.x, this.maxParticleSpeed.x), a.body.velocity.y = this.game.rnd.integerInRange(this.minParticleSpeed.y, this.maxParticleSpeed.y), a.body.angularVelocity = this.game.rnd.integerInRange(this.minRotation, this.maxRotation), a.body.gravity.y = this.gravity, a.body.drag.x = this.particleDrag.x, a.body.drag.y = this.particleDrag.y, a.body.angularDrag = this.angularDrag, a.onEmit())
  9159. }, b.Particles.Arcade.Emitter.prototype.setSize = function(a, b) {
  9160. this.area.width = a, this.area.height = b
  9161. }, b.Particles.Arcade.Emitter.prototype.setXSpeed = function(a, b) {
  9162. a = a || 0, b = b || 0, this.minParticleSpeed.x = a, this.maxParticleSpeed.x = b
  9163. }, b.Particles.Arcade.Emitter.prototype.setYSpeed = function(a, b) {
  9164. a = a || 0, b = b || 0, this.minParticleSpeed.y = a, this.maxParticleSpeed.y = b
  9165. }, b.Particles.Arcade.Emitter.prototype.setRotation = function(a, b) {
  9166. a = a || 0, b = b || 0, this.minRotation = a, this.maxRotation = b
  9167. }, b.Particles.Arcade.Emitter.prototype.setAlpha = function(a, c, d, e, f) {
  9168. if ("undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = b.Easing.Linear.None), "undefined" == typeof f && (f = !1), this.minParticleAlpha = a, this.maxParticleAlpha = c, this.autoAlpha = !1, d > 0 && a !== c) {
  9169. var g = {
  9170. v: a
  9171. },
  9172. h = this.game.make.tween(g).to({
  9173. v: c
  9174. }, d, e);
  9175. h.yoyo(f), this.alphaData = h.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0
  9176. }
  9177. }, b.Particles.Arcade.Emitter.prototype.setScale = function(a, c, d, e, f, g, h) {
  9178. if ("undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = 1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = b.Easing.Linear.None), "undefined" == typeof h && (h = !1), this.minParticleScale = 1, this.maxParticleScale = 1, this._minParticleScale.set(a, d), this._maxParticleScale.set(c, e), this.autoScale = !1, f > 0 && a !== c || d !== e) {
  9179. var i = {
  9180. x: a,
  9181. y: d
  9182. },
  9183. j = this.game.make.tween(i).to({
  9184. x: c,
  9185. y: e
  9186. }, f, g);
  9187. j.yoyo(h), this.scaleData = j.generateData(60), this.scaleData.reverse(), this.autoScale = !0
  9188. }
  9189. }, b.Particles.Arcade.Emitter.prototype.at = function(a) {
  9190. 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)
  9191. }, Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "width", {
  9192. get: function() {
  9193. return this.area.width
  9194. },
  9195. set: function(a) {
  9196. this.area.width = a
  9197. }
  9198. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "height", {
  9199. get: function() {
  9200. return this.area.height
  9201. },
  9202. set: function(a) {
  9203. this.area.height = a
  9204. }
  9205. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "x", {
  9206. get: function() {
  9207. return this.emitX
  9208. },
  9209. set: function(a) {
  9210. this.emitX = a
  9211. }
  9212. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "y", {
  9213. get: function() {
  9214. return this.emitY
  9215. },
  9216. set: function(a) {
  9217. this.emitY = a
  9218. }
  9219. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "left", {
  9220. get: function() {
  9221. return Math.floor(this.x - this.area.width / 2)
  9222. }
  9223. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "right", {
  9224. get: function() {
  9225. return Math.floor(this.x + this.area.width / 2)
  9226. }
  9227. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "top", {
  9228. get: function() {
  9229. return Math.floor(this.y - this.area.height / 2)
  9230. }
  9231. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "bottom", {
  9232. get: function() {
  9233. return Math.floor(this.y + this.area.height / 2)
  9234. }
  9235. }), b.Tile = function(a, b, c, d, e, f) {
  9236. this.layer = a, this.index = b, this.x = c, this.y = d, this.worldX = c * e, this.worldY = d * f, this.width = e, this.height = f, this.centerX = Math.abs(e / 2), this.centerY = Math.abs(f / 2), this.alpha = 1, this.properties = {}, this.scanned = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1, this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.collisionCallback = null, this.collisionCallbackContext = this
  9237. }, b.Tile.prototype = {
  9238. containsPoint: function(a, b) {
  9239. return !(a < this.worldX || b < this.worldY || a > this.right || b > this.bottom)
  9240. },
  9241. intersects: function(a, b, c, d) {
  9242. return c <= this.worldX ? !1 : d <= this.worldY ? !1 : a >= this.worldX + this.width ? !1 : b >= this.worldY + this.height ? !1 : !0
  9243. },
  9244. setCollisionCallback: function(a, b) {
  9245. this.collisionCallback = a, this.collisionCallbackContext = b
  9246. },
  9247. destroy: function() {
  9248. this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null
  9249. },
  9250. setCollision: function(a, b, c, d) {
  9251. this.collideLeft = a, this.collideRight = b, this.collideUp = c, this.collideDown = d, this.faceLeft = a, this.faceRight = b, this.faceTop = c, this.faceBottom = d
  9252. },
  9253. resetCollision: function() {
  9254. this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1
  9255. },
  9256. isInteresting: function(a, b) {
  9257. 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
  9258. },
  9259. copy: function(a) {
  9260. 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
  9261. }
  9262. }, b.Tile.prototype.constructor = b.Tile, Object.defineProperty(b.Tile.prototype, "collides", {
  9263. get: function() {
  9264. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown
  9265. }
  9266. }), Object.defineProperty(b.Tile.prototype, "canCollide", {
  9267. get: function() {
  9268. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback
  9269. }
  9270. }), Object.defineProperty(b.Tile.prototype, "left", {
  9271. get: function() {
  9272. return this.worldX
  9273. }
  9274. }), Object.defineProperty(b.Tile.prototype, "right", {
  9275. get: function() {
  9276. return this.worldX + this.width
  9277. }
  9278. }), Object.defineProperty(b.Tile.prototype, "top", {
  9279. get: function() {
  9280. return this.worldY
  9281. }
  9282. }), Object.defineProperty(b.Tile.prototype, "bottom", {
  9283. get: function() {
  9284. return this.worldY + this.height
  9285. }
  9286. }), b.Tilemap = function(a, c, d, e, f, g) {
  9287. this.game = a, this.key = c;
  9288. var h = b.TilemapParser.parse(this.game, c, d, e, f, g);
  9289. 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)
  9290. }, b.Tilemap.CSV = 0, b.Tilemap.TILED_JSON = 1, b.Tilemap.NORTH = 0, b.Tilemap.EAST = 1, b.Tilemap.SOUTH = 2, b.Tilemap.WEST = 3, b.Tilemap.prototype = {
  9291. create: function(a, b, c, d, e, f) {
  9292. 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)
  9293. },
  9294. setTileSize: function(a, b) {
  9295. this.tileWidth = a, this.tileHeight = b, this.widthInPixels = this.width * a, this.heightInPixels = this.height * b
  9296. },
  9297. addTilesetImage: function(a, c, d, e, f, g, h) {
  9298. if ("undefined" == typeof d && (d = this.tileWidth), "undefined" == typeof e && (e = this.tileHeight), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), "undefined" == typeof h && (h = 0), 0 === d && (d = 32), 0 === e && (e = 32), "undefined" == typeof c) {
  9299. if ("string" != typeof a) return null;
  9300. if (c = a, !this.game.cache.checkImageKey(c)) return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + c + '"'), null
  9301. }
  9302. if ("string" == typeof a && (a = this.getTilesetIndex(a), null === a && this.format === b.Tilemap.TILED_JSON)) return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + c + '"'), null;
  9303. if (this.tilesets[a]) return this.tilesets[a].setImage(this.game.cache.getImage(c)), this.tilesets[a];
  9304. var i = new b.Tileset(c, h, d, e, f, g, {});
  9305. i.setImage(this.game.cache.getImage(c)), this.tilesets.push(i);
  9306. 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++);
  9307. return i
  9308. },
  9309. createFromObjects: function(a, c, d, e, f, g, h, i, j) {
  9310. if ("undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = !1), "undefined" == typeof h && (h = this.game.world), "undefined" == typeof i && (i = b.Sprite), "undefined" == typeof j && (j = !0), !this.objects[a]) return void console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: " + a);
  9311. for (var k, l = 0, m = this.objects[a].length; m > l; l++)
  9312. if (this.objects[a][l].gid === c) {
  9313. k = new i(this.game, this.objects[a][l].x, this.objects[a][l].y, d, e), k.name = this.objects[a][l].name, k.visible = this.objects[a][l].visible, k.autoCull = g, k.exists = f, j && (k.y -= k.height), h.add(k);
  9314. for (var n in this.objects[a][l].properties) h.set(k, n, this.objects[a][l].properties[n], !1, !1, 0, !0)
  9315. }
  9316. },
  9317. createLayer: function(a, c, d, e) {
  9318. "undefined" == typeof c && (c = this.game.width), "undefined" == typeof d && (d = this.game.height), "undefined" == typeof e && (e = this.game.world);
  9319. var f = a;
  9320. return "string" == typeof a && (f = this.getLayerIndex(a)), null === f || f > this.layers.length ? void console.warn("Tilemap.createLayer: Invalid layer ID given: " + f) : e.add(new b.TilemapLayer(this.game, this, f, c, d))
  9321. },
  9322. createBlankLayer: function(a, c, d, e, f, g) {
  9323. if ("undefined" == typeof g && (g = this.game.world), null !== this.getLayerIndex(a)) return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists");
  9324. for (var h, i = {
  9325. name: a,
  9326. x: 0,
  9327. y: 0,
  9328. width: c,
  9329. height: d,
  9330. widthInPixels: c * e,
  9331. heightInPixels: d * f,
  9332. alpha: 1,
  9333. visible: !0,
  9334. properties: {},
  9335. indexes: [],
  9336. callbacks: [],
  9337. bodies: [],
  9338. data: null
  9339. }, j = [], k = 0; d > k; k++) {
  9340. h = [];
  9341. for (var l = 0; c > l; l++) h.push(new b.Tile(i, -1, l, k, e, f));
  9342. j.push(h)
  9343. }
  9344. i.data = j, this.layers.push(i), this.currentLayer = this.layers.length - 1;
  9345. var m = i.widthInPixels,
  9346. n = i.heightInPixels;
  9347. m > this.game.width && (m = this.game.width), n > this.game.height && (n = this.game.height);
  9348. var j = new b.TilemapLayer(this.game, this, this.layers.length - 1, m, n);
  9349. return j.name = a, g.add(j)
  9350. },
  9351. getIndex: function(a, b) {
  9352. for (var c = 0; c < a.length; c++)
  9353. if (a[c].name === b) return c;
  9354. return null
  9355. },
  9356. getLayerIndex: function(a) {
  9357. return this.getIndex(this.layers, a)
  9358. },
  9359. getTilesetIndex: function(a) {
  9360. return this.getIndex(this.tilesets, a)
  9361. },
  9362. getImageIndex: function(a) {
  9363. return this.getIndex(this.images, a)
  9364. },
  9365. getObjectIndex: function(a) {
  9366. return this.getIndex(this.objects, a)
  9367. },
  9368. setTileIndexCallback: function(a, b, c, d) {
  9369. if (d = this.getLayer(d), "number" == typeof a) this.layers[d].callbacks[a] = {
  9370. callback: b,
  9371. callbackContext: c
  9372. };
  9373. else
  9374. for (var e = 0, f = a.length; f > e; e++) this.layers[d].callbacks[a[e]] = {
  9375. callback: b,
  9376. callbackContext: c
  9377. }
  9378. },
  9379. setTileLocationCallback: function(a, b, c, d, e, f, g) {
  9380. if (g = this.getLayer(g), this.copy(a, b, c, d, g), !(this._results.length < 2))
  9381. for (var h = 1; h < this._results.length; h++) this._results[h].setCollisionCallback(e, f)
  9382. },
  9383. setCollision: function(a, b, c, d) {
  9384. 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);
  9385. for (var e = 0, f = a.length; f > e; e++) this.setCollisionByIndex(a[e], b, c, !1);
  9386. d && this.calculateFaces(c)
  9387. },
  9388. setCollisionBetween: function(a, b, c, d, e) {
  9389. if ("undefined" == typeof c && (c = !0), "undefined" == typeof e && (e = !0), d = this.getLayer(d), !(a > b)) {
  9390. for (var f = a; b >= f; f++) this.setCollisionByIndex(f, c, d, !1);
  9391. e && this.calculateFaces(d)
  9392. }
  9393. },
  9394. setCollisionByExclusion: function(a, b, c, d) {
  9395. "undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c);
  9396. for (var e = 0, f = this.tiles.length; f > e; e++) - 1 === a.indexOf(e) && this.setCollisionByIndex(e, b, c, !1);
  9397. d && this.calculateFaces(c)
  9398. },
  9399. setCollisionByIndex: function(a, b, c, d) {
  9400. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = this.currentLayer), "undefined" == typeof d && (d = !0), b) this.collideIndexes.push(a);
  9401. else {
  9402. var e = this.collideIndexes.indexOf(a);
  9403. e > -1 && this.collideIndexes.splice(e, 1)
  9404. }
  9405. for (var f = 0; f < this.layers[c].height; f++)
  9406. for (var g = 0; g < this.layers[c].width; g++) {
  9407. var h = this.layers[c].data[f][g];
  9408. 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)
  9409. }
  9410. return d && this.calculateFaces(c), c
  9411. },
  9412. getLayer: function(a) {
  9413. return "undefined" == typeof a ? a = this.currentLayer : "string" == typeof a ? a = this.getLayerIndex(a) : a instanceof b.TilemapLayer && (a = a.index), a
  9414. },
  9415. setPreventRecalculate: function(a) {
  9416. if (a === !0 && this.preventingRecalculate !== !0 && (this.preventingRecalculate = !0, this.needToRecalculate = {}), a === !1 && this.preventingRecalculate === !0) {
  9417. this.preventingRecalculate = !1;
  9418. for (var b in this.needToRecalculate) this.calculateFaces(b);
  9419. this.needToRecalculate = !1
  9420. }
  9421. },
  9422. calculateFaces: function(a) {
  9423. if (this.preventingRecalculate) return void(this.needToRecalculate[a] = !0);
  9424. for (var b = null, c = null, d = null, e = null, f = 0, g = this.layers[a].height; g > f; f++)
  9425. for (var h = 0, i = this.layers[a].width; i > h; h++) {
  9426. var j = this.layers[a].data[f][h];
  9427. 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))
  9428. }
  9429. },
  9430. getTileAbove: function(a, b, c) {
  9431. return c > 0 ? this.layers[a].data[c - 1][b] : null
  9432. },
  9433. getTileBelow: function(a, b, c) {
  9434. return c < this.layers[a].height - 1 ? this.layers[a].data[c + 1][b] : null
  9435. },
  9436. getTileLeft: function(a, b, c) {
  9437. return b > 0 ? this.layers[a].data[c][b - 1] : null
  9438. },
  9439. getTileRight: function(a, b, c) {
  9440. return b < this.layers[a].width - 1 ? this.layers[a].data[c][b + 1] : null
  9441. },
  9442. setLayer: function(a) {
  9443. a = this.getLayer(a), this.layers[a] && (this.currentLayer = a)
  9444. },
  9445. hasTile: function(a, b, c) {
  9446. return c = this.getLayer(c), this.layers[c].data[b][a].index > -1
  9447. },
  9448. removeTile: function(a, c, d) {
  9449. if (d = this.getLayer(d), a >= 0 && a < this.layers[d].width && c >= 0 && c < this.layers[d].height && this.hasTile(a, c, d)) {
  9450. var e = this.layers[d].data[c][a];
  9451. return this.layers[d].data[c][a] = new b.Tile(this.layers[d], -1, a, c, this.tileWidth, this.tileHeight), this.layers[d].dirty = !0, this.calculateFaces(d), e
  9452. }
  9453. },
  9454. removeTileWorldXY: function(a, b, c, d, e) {
  9455. 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)
  9456. },
  9457. putTile: function(a, c, d, e) {
  9458. if (null === a) return this.removeTile(c, d, e);
  9459. if (e = this.getLayer(e), c >= 0 && c < this.layers[e].width && d >= 0 && d < this.layers[e].height) {
  9460. var f;
  9461. return a instanceof b.Tile ? (f = a.index, this.hasTile(c, d, e) ? this.layers[e].data[d][c].copy(a) : this.layers[e].data[d][c] = new b.Tile(e, f, c, d, a.width, a.height)) : (f = a, this.hasTile(c, d, e) ? this.layers[e].data[d][c].index = f : this.layers[e].data[d][c] = new b.Tile(this.layers[e], f, c, d, this.tileWidth, this.tileHeight)), this.collideIndexes.indexOf(f) > -1 ? this.layers[e].data[d][c].setCollision(!0, !0, !0, !0) : this.layers[e].data[d][c].resetCollision(), this.layers[e].dirty = !0, this.calculateFaces(e), this.layers[e].data[d][c]
  9462. }
  9463. return null
  9464. },
  9465. putTileWorldXY: function(a, b, c, d, e, f) {
  9466. 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)
  9467. },
  9468. searchTileIndex: function(a, b, c, d) {
  9469. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), d = this.getLayer(d);
  9470. var e = 0;
  9471. if (c) {
  9472. for (var f = this.layers[d].height - 1; f >= 0; f--)
  9473. for (var g = this.layers[d].width - 1; g >= 0; g--)
  9474. if (this.layers[d].data[f][g].index === a) {
  9475. if (e === b) return this.layers[d].data[f][g];
  9476. e++
  9477. }
  9478. } else
  9479. for (var f = 0; f < this.layers[d].height; f++)
  9480. for (var g = 0; g < this.layers[d].width; g++)
  9481. if (this.layers[d].data[f][g].index === a) {
  9482. if (e === b) return this.layers[d].data[f][g];
  9483. e++
  9484. } return null
  9485. },
  9486. getTile: function(a, b, c, d) {
  9487. 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
  9488. },
  9489. getTileWorldXY: function(a, b, c, d, e) {
  9490. 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)
  9491. },
  9492. copy: function(a, b, c, d, e) {
  9493. if (e = this.getLayer(e), !this.layers[e]) return void(this._results.length = 0);
  9494. "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({
  9495. x: a,
  9496. y: b,
  9497. width: c,
  9498. height: d,
  9499. layer: e
  9500. });
  9501. for (var f = b; b + d > f; f++)
  9502. for (var g = a; a + c > g; g++) this._results.push(this.layers[e].data[f][g]);
  9503. return this._results
  9504. },
  9505. paste: function(a, b, c, d) {
  9506. if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), d = this.getLayer(d), c && !(c.length < 2)) {
  9507. for (var e = c[1].x - a, f = c[1].y - b, g = 1; g < c.length; g++) this.layers[d].data[f + c[g].y][e + c[g].x].copy(c[g]);
  9508. this.layers[d].dirty = !0, this.calculateFaces(d)
  9509. }
  9510. },
  9511. swap: function(a, b, c, d, e, f, g) {
  9512. 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))
  9513. },
  9514. swapHandler: function(a) {
  9515. a.index === this._tempA ? a.index = this._tempB : a.index === this._tempB && (a.index = this._tempA)
  9516. },
  9517. forEach: function(a, b, c, d, e, f, g) {
  9518. 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))
  9519. },
  9520. replace: function(a, b, c, d, e, f, g) {
  9521. if (g = this.getLayer(g), this.copy(c, d, e, f, g), !(this._results.length < 2)) {
  9522. for (var h = 1; h < this._results.length; h++) this._results[h].index === a && (this._results[h].index = b);
  9523. this.paste(c, d, this._results, g)
  9524. }
  9525. },
  9526. random: function(a, b, c, d, e) {
  9527. if (e = this.getLayer(e), this.copy(a, b, c, d, e), !(this._results.length < 2)) {
  9528. for (var f = [], g = 1; g < this._results.length; g++)
  9529. if (this._results[g].index) {
  9530. var h = this._results[g].index; - 1 === f.indexOf(h) && f.push(h)
  9531. }
  9532. for (var i = 1; i < this._results.length; i++) this._results[i].index = this.game.rnd.pick(f);
  9533. this.paste(a, b, this._results, e)
  9534. }
  9535. },
  9536. shuffle: function(a, c, d, e, f) {
  9537. if (f = this.getLayer(f), this.copy(a, c, d, e, f), !(this._results.length < 2)) {
  9538. for (var g = [], h = 1; h < this._results.length; h++) this._results[h].index && g.push(this._results[h].index);
  9539. b.Utils.shuffle(g);
  9540. for (var i = 1; i < this._results.length; i++) this._results[i].index = g[i - 1];
  9541. this.paste(a, c, this._results, f)
  9542. }
  9543. },
  9544. fill: function(a, b, c, d, e, f) {
  9545. if (f = this.getLayer(f), this.copy(b, c, d, e, f), !(this._results.length < 2)) {
  9546. for (var g = 1; g < this._results.length; g++) this._results[g].index = a;
  9547. this.paste(b, c, this._results, f)
  9548. }
  9549. },
  9550. removeAllLayers: function() {
  9551. this.layers.length = 0, this.currentLayer = 0
  9552. },
  9553. dump: function() {
  9554. for (var a = "", b = [""], c = 0; c < this.layers[this.currentLayer].height; c++) {
  9555. 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)");
  9556. a += "\n"
  9557. }
  9558. b[0] = a, console.log.apply(console, b)
  9559. },
  9560. destroy: function() {
  9561. this.removeAllLayers(), this.data = [], this.game = null
  9562. }
  9563. }, b.Tilemap.prototype.constructor = b.Tilemap, Object.defineProperty(b.Tilemap.prototype, "layer", {
  9564. get: function() {
  9565. return this.layers[this.currentLayer]
  9566. },
  9567. set: function(a) {
  9568. a !== this.currentLayer && this.setLayer(a)
  9569. }
  9570. }), b.TilemapLayer = function(a, c, d, e, f) {
  9571. this.game = a, this.map = c, this.index = d, this.layer = c.layers[d], this.canvas = b.Canvas.create(e, f, "", !0), this.context = this.canvas.getContext("2d"), this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new b.Frame(0, 0, 0, e, f, "tilemapLayer", a.rnd.uuid()), b.Image.call(this, this.game, 0, 0, this.texture, this.textureFrame), this.name = "", this.type = b.TILEMAPLAYER, this.fixedToCamera = !0, this.cameraOffset = new b.Point(0, 0), this.tileColor = "rgb(255, 255, 255)", this.debug = !1, this.debugAlpha = .5, this.debugColor = "rgba(0, 255, 0, 1)", this.debugFill = !1, this.debugFillColor = "rgba(0, 255, 0, 0.2)", this.debugCallbackColor = "rgba(255, 0, 0, 1)", this.scrollFactorX = 1, this.scrollFactorY = 1, this.dirty = !0, this.rayStepRate = 4, this.wrap = !1, this._mc = {
  9572. cw: c.tileWidth,
  9573. ch: c.tileHeight,
  9574. ga: 1,
  9575. dx: 0,
  9576. dy: 0,
  9577. dw: 0,
  9578. dh: 0,
  9579. tx: 0,
  9580. ty: 0,
  9581. tw: 0,
  9582. th: 0,
  9583. tl: 0,
  9584. maxX: 0,
  9585. maxY: 0,
  9586. startX: 0,
  9587. startY: 0,
  9588. x: 0,
  9589. y: 0,
  9590. prevX: 0,
  9591. prevY: 0
  9592. }, this._results = [], this.updateMax()
  9593. }, b.TilemapLayer.prototype = Object.create(b.Image.prototype), b.TilemapLayer.prototype.constructor = b.TilemapLayer, b.TilemapLayer.prototype.postUpdate = function() {
  9594. b.Image.prototype.postUpdate.call(this), this.scrollX = this.game.camera.x * this.scrollFactorX, this.scrollY = this.game.camera.y * this.scrollFactorY, this.render(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  9595. }, b.TilemapLayer.prototype.resizeWorld = function() {
  9596. this.game.world.setBounds(0, 0, this.layer.widthInPixels, this.layer.heightInPixels)
  9597. }, b.TilemapLayer.prototype._fixX = function(a) {
  9598. return 0 > a && (a = 0), 1 === this.scrollFactorX ? a : this._mc.x + (a - this._mc.x / this.scrollFactorX)
  9599. }, b.TilemapLayer.prototype._unfixX = function(a) {
  9600. return 1 === this.scrollFactorX ? a : this._mc.x / this.scrollFactorX + (a - this._mc.x)
  9601. }, b.TilemapLayer.prototype._fixY = function(a) {
  9602. return 0 > a && (a = 0), 1 === this.scrollFactorY ? a : this._mc.y + (a - this._mc.y / this.scrollFactorY)
  9603. }, b.TilemapLayer.prototype._unfixY = function(a) {
  9604. return 1 === this.scrollFactorY ? a : this._mc.y / this.scrollFactorY + (a - this._mc.y)
  9605. }, b.TilemapLayer.prototype.getTileX = function(a) {
  9606. return this.game.math.snapToFloor(this._fixX(a), this.map.tileWidth) / this.map.tileWidth
  9607. }, b.TilemapLayer.prototype.getTileY = function(a) {
  9608. return this.game.math.snapToFloor(this._fixY(a), this.map.tileHeight) / this.map.tileHeight
  9609. }, b.TilemapLayer.prototype.getTileXY = function(a, b, c) {
  9610. return c.x = this.getTileX(a), c.y = this.getTileY(b), c
  9611. }, b.TilemapLayer.prototype.getRayCastTiles = function(a, b, c, d) {
  9612. ("undefined" == typeof b || null === b) && (b = this.rayStepRate), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1);
  9613. var e = this.getTiles(a.x, a.y, a.width, a.height, c, d);
  9614. if (0 === e.length) return [];
  9615. for (var f = a.coordinatesOnLine(b), g = f.length, h = [], i = 0; i < e.length; i++)
  9616. for (var j = 0; g > j; j++)
  9617. if (e[i].containsPoint(f[j][0], f[j][1])) {
  9618. h.push(e[i]);
  9619. break
  9620. }
  9621. return h
  9622. }, b.TilemapLayer.prototype.getTiles = function(a, b, c, d, e, f) {
  9623. "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1), a = this._fixX(a), b = this._fixY(b), c > this.layer.widthInPixels && (c = this.layer.widthInPixels), d > this.layer.heightInPixels && (d = this.layer.heightInPixels), this._mc.tx = this.game.math.snapToFloor(a, this._mc.cw) / this._mc.cw, this._mc.ty = this.game.math.snapToFloor(b, this._mc.ch) / this._mc.ch, this._mc.tw = (this.game.math.snapToCeil(c, this._mc.cw) + this._mc.cw) / this._mc.cw, this._mc.th = (this.game.math.snapToCeil(d, this._mc.ch) + this._mc.ch) / this._mc.ch, this._results.length = 0;
  9624. for (var g = this._mc.ty; g < this._mc.ty + this._mc.th; g++)
  9625. for (var h = this._mc.tx; h < this._mc.tx + this._mc.tw; h++) this.layer.data[g] && this.layer.data[g][h] && (!e && !f || this.layer.data[g][h].isInteresting(e, f)) && this._results.push(this.layer.data[g][h]);
  9626. return this._results
  9627. }, b.TilemapLayer.prototype.updateMax = function() {
  9628. this._mc.maxX = this.game.math.ceil(this.canvas.width / this.map.tileWidth) + 1, this._mc.maxY = this.game.math.ceil(this.canvas.height / this.map.tileHeight) + 1, this.dirty = !0
  9629. }, b.TilemapLayer.prototype.render = function() {
  9630. if (this.layer.dirty && (this.dirty = !0), this.dirty && this.visible) {
  9631. this._mc.prevX = this._mc.dx, this._mc.prevY = this._mc.dy, this._mc.dx = -(this._mc.x - this._mc.startX * this.map.tileWidth), this._mc.dy = -(this._mc.y - this._mc.startY * this.map.tileHeight), this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.fillStyle = this.tileColor;
  9632. var a, b;
  9633. this.debug && (this.context.globalAlpha = this.debugAlpha);
  9634. for (var c = this._mc.startY, d = this._mc.startY + this._mc.maxY; d > c; c++) {
  9635. if (this._column = null, 0 > c && this.wrap ? this._column = this.layer.data[c + this.map.height] : c >= this.map.height && this.wrap ? this._column = this.layer.data[c - this.map.height] : this.layer.data[c] && (this._column = this.layer.data[c]), this._column)
  9636. for (var e = this._mc.startX, f = this._mc.startX + this._mc.maxX; f > e; e++) {
  9637. var a = null;
  9638. 0 > e && this.wrap ? a = this._column[e + this.map.width] : e >= this.map.width && this.wrap ? a = this._column[e - this.map.width] : this._column[e] && (a = this._column[e]), a && a.index > -1 && (b = this.map.tilesets[this.map.tiles[a.index][2]], this.debug === !1 && a.alpha !== this.context.globalAlpha && (this.context.globalAlpha = a.alpha), b.draw(this.context, Math.floor(this._mc.tx), Math.floor(this._mc.ty), a.index), a.debug && (this.context.fillStyle = "rgba(0, 255, 0, 0.4)", this.context.fillRect(Math.floor(this._mc.tx), Math.floor(this._mc.ty), this.map.tileWidth, this.map.tileHeight))), this._mc.tx += this.map.tileWidth
  9639. }
  9640. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  9641. }
  9642. return this.debug && (this.context.globalAlpha = 1, this.renderDebug()), this.texture._updateUvs(), this.dirty = !1, this.layer.dirty = !1, !0
  9643. }
  9644. }, b.TilemapLayer.prototype.renderDebug = function() {
  9645. this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.strokeStyle = this.debugColor, this.context.fillStyle = this.debugFillColor;
  9646. for (var a = this._mc.startY, b = this._mc.startY + this._mc.maxY; b > a; a++) {
  9647. if (this._column = null, 0 > a && this.wrap ? this._column = this.layer.data[a + this.map.height] : a >= this.map.height && this.wrap ? this._column = this.layer.data[a - this.map.height] : this.layer.data[a] && (this._column = this.layer.data[a]), this._column)
  9648. for (var c = this._mc.startX, d = this._mc.startX + this._mc.maxX; d > c; c++) {
  9649. var e = null;
  9650. 0 > c && this.wrap ? e = this._column[c + this.map.width] : c >= this.map.width && this.wrap ? e = this._column[c - this.map.width] : this._column[c] && (e = this._column[c]), e && (e.faceTop || e.faceBottom || e.faceLeft || e.faceRight) && (this._mc.tx = Math.floor(this._mc.tx), this.debugFill && this.context.fillRect(this._mc.tx, this._mc.ty, this._mc.cw, this._mc.ch), this.context.beginPath(), e.faceTop && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty)), e.faceBottom && (this.context.moveTo(this._mc.tx, this._mc.ty + this._mc.ch), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), e.faceLeft && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx, this._mc.ty + this._mc.ch)), e.faceRight && (this.context.moveTo(this._mc.tx + this._mc.cw, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), this.context.stroke()), this._mc.tx += this.map.tileWidth
  9651. }
  9652. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  9653. }
  9654. }, Object.defineProperty(b.TilemapLayer.prototype, "scrollX", {
  9655. get: function() {
  9656. return this._mc.x
  9657. },
  9658. set: function(a) {
  9659. a !== this._mc.x && (this._mc.x = a, this._mc.startX = this.game.math.floor(this._mc.x / this.map.tileWidth), this.dirty = !0)
  9660. }
  9661. }), Object.defineProperty(b.TilemapLayer.prototype, "scrollY", {
  9662. get: function() {
  9663. return this._mc.y
  9664. },
  9665. set: function(a) {
  9666. a !== this._mc.y && (this._mc.y = a, this._mc.startY = this.game.math.floor(this._mc.y / this.map.tileHeight), this.dirty = !0)
  9667. }
  9668. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionWidth", {
  9669. get: function() {
  9670. return this._mc.cw
  9671. },
  9672. set: function(a) {
  9673. this._mc.cw = a, this.dirty = !0
  9674. }
  9675. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionHeight", {
  9676. get: function() {
  9677. return this._mc.ch
  9678. },
  9679. set: function(a) {
  9680. this._mc.ch = a, this.dirty = !0
  9681. }
  9682. }), b.TilemapParser = {
  9683. parse: function(a, c, d, e, f, g) {
  9684. if ("undefined" == typeof d && (d = 32), "undefined" == typeof e && (e = 32), "undefined" == typeof f && (f = 10), "undefined" == typeof g && (g = 10), "undefined" == typeof c) return this.getEmptyData();
  9685. if (null === c) return this.getEmptyData(d, e, f, g);
  9686. var h = a.cache.getTilemapData(c);
  9687. if (h) {
  9688. if (h.format === b.Tilemap.CSV) return this.parseCSV(c, h.data, d, e);
  9689. if (!h.format || h.format === b.Tilemap.TILED_JSON) return this.parseTiledJSON(h.data)
  9690. } else console.warn("Phaser.TilemapParser.parse - No map data found for key " + c)
  9691. },
  9692. parseCSV: function(a, c, d, e) {
  9693. var f = this.getEmptyData();
  9694. c = c.trim();
  9695. for (var g = [], h = c.split("\n"), i = h.length, j = 0, k = 0; k < h.length; k++) {
  9696. g[k] = [];
  9697. for (var l = h[k].split(","), m = 0; m < l.length; m++) g[k][m] = new b.Tile(f.layers[0], parseInt(l[m], 10), m, k, d, e);
  9698. 0 === j && (j = l.length)
  9699. }
  9700. return f.format = b.Tilemap.CSV, f.name = a, f.width = j, f.height = i, f.tileWidth = d, f.tileHeight = e, f.widthInPixels = j * d, f.heightInPixels = i * e, f.layers[0].width = j, f.layers[0].height = i, f.layers[0].widthInPixels = f.widthInPixels, f.layers[0].heightInPixels = f.heightInPixels, f.layers[0].data = g, f
  9701. },
  9702. getEmptyData: function(a, b, c, d) {
  9703. var e = {};
  9704. 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;
  9705. var f = [],
  9706. g = {
  9707. name: "layer",
  9708. x: 0,
  9709. y: 0,
  9710. width: 0,
  9711. height: 0,
  9712. widthInPixels: 0,
  9713. heightInPixels: 0,
  9714. alpha: 1,
  9715. visible: !0,
  9716. properties: {},
  9717. indexes: [],
  9718. callbacks: [],
  9719. bodies: [],
  9720. data: []
  9721. };
  9722. return f.push(g), e.layers = f, e.images = [], e.objects = {}, e.collision = {}, e.tilesets = [], e.tiles = [], e
  9723. },
  9724. parseTiledJSON: function(a) {
  9725. function c(a, b) {
  9726. var c = {};
  9727. for (var d in b) {
  9728. var e = b[d];
  9729. c[e] = a[e]
  9730. }
  9731. return c
  9732. }
  9733. if ("orthogonal" !== a.orientation) return console.warn("TilemapParser.parseTiledJSON: Only orthogonal map types are supported in this version of Phaser"), null;
  9734. var d = {};
  9735. d.width = a.width, d.height = a.height, d.tileWidth = a.tilewidth, d.tileHeight = a.tileheight, d.orientation = a.orientation, d.format = b.Tilemap.TILED_JSON, d.version = a.version, d.properties = a.properties, d.widthInPixels = d.width * d.tileWidth, d.heightInPixels = d.height * d.tileHeight;
  9736. for (var e = [], f = 0; f < a.layers.length; f++)
  9737. if ("tilelayer" === a.layers[f].type) {
  9738. var g = {
  9739. name: a.layers[f].name,
  9740. x: a.layers[f].x,
  9741. y: a.layers[f].y,
  9742. width: a.layers[f].width,
  9743. height: a.layers[f].height,
  9744. widthInPixels: a.layers[f].width * a.tilewidth,
  9745. heightInPixels: a.layers[f].height * a.tileheight,
  9746. alpha: a.layers[f].opacity,
  9747. visible: a.layers[f].visible,
  9748. properties: {},
  9749. indexes: [],
  9750. callbacks: [],
  9751. bodies: []
  9752. };
  9753. a.layers[f].properties && (g.properties = a.layers[f].properties);
  9754. for (var h = 0, i = [], j = [], k = 0, l = a.layers[f].data.length; l > k; k++) i.push(a.layers[f].data[k] > 0 ? new b.Tile(g, a.layers[f].data[k], h, j.length, a.tilewidth, a.tileheight) : new b.Tile(g, -1, h, j.length, a.tilewidth, a.tileheight)), h++, h === a.layers[f].width && (j.push(i), h = 0, i = []);
  9755. g.data = j, e.push(g)
  9756. }
  9757. d.layers = e;
  9758. for (var m = [], f = 0; f < a.layers.length; f++)
  9759. if ("imagelayer" === a.layers[f].type) {
  9760. var n = {
  9761. name: a.layers[f].name,
  9762. image: a.layers[f].image,
  9763. x: a.layers[f].x,
  9764. y: a.layers[f].y,
  9765. alpha: a.layers[f].opacity,
  9766. visible: a.layers[f].visible,
  9767. properties: {}
  9768. };
  9769. a.layers[f].properties && (n.properties = a.layers[f].properties), m.push(n)
  9770. }
  9771. d.images = m;
  9772. for (var o = [], f = 0; f < a.tilesets.length; f++) {
  9773. var p = a.tilesets[f],
  9774. q = new b.Tileset(p.name, p.firstgid, p.tilewidth, p.tileheight, p.margin, p.spacing, p.properties);
  9775. p.tileproperties && (q.tileProperties = p.tileproperties), q.rows = Math.round((p.imageheight - p.margin) / (p.tileheight + p.spacing)), q.columns = Math.round((p.imagewidth - p.margin) / (p.tilewidth + p.spacing)), q.total = q.rows * q.columns, q.rows % 1 !== 0 || q.columns % 1 !== 0 ? console.warn("TileSet image dimensions do not match expected dimensions. Tileset width/height must be evenly divisible by Tilemap tile width/height.") : o.push(q)
  9776. }
  9777. d.tilesets = o;
  9778. for (var r = {}, s = {}, f = 0; f < a.layers.length; f++)
  9779. if ("objectgroup" === a.layers[f].type) {
  9780. r[a.layers[f].name] = [], s[a.layers[f].name] = [];
  9781. for (var t = 0, l = a.layers[f].objects.length; l > t; t++)
  9782. if (a.layers[f].objects[t].gid) {
  9783. var u = {
  9784. gid: a.layers[f].objects[t].gid,
  9785. name: a.layers[f].objects[t].name,
  9786. x: a.layers[f].objects[t].x,
  9787. y: a.layers[f].objects[t].y,
  9788. visible: a.layers[f].objects[t].visible,
  9789. properties: a.layers[f].objects[t].properties
  9790. };
  9791. r[a.layers[f].name].push(u)
  9792. } else if (a.layers[f].objects[t].polyline) {
  9793. var u = {
  9794. name: a.layers[f].objects[t].name,
  9795. type: a.layers[f].objects[t].type,
  9796. x: a.layers[f].objects[t].x,
  9797. y: a.layers[f].objects[t].y,
  9798. width: a.layers[f].objects[t].width,
  9799. height: a.layers[f].objects[t].height,
  9800. visible: a.layers[f].objects[t].visible,
  9801. properties: a.layers[f].objects[t].properties
  9802. };
  9803. u.polyline = [];
  9804. for (var v = 0; v < a.layers[f].objects[t].polyline.length; v++) u.polyline.push([a.layers[f].objects[t].polyline[v].x, a.layers[f].objects[t].polyline[v].y]);
  9805. s[a.layers[f].name].push(u), r[a.layers[f].name].push(u)
  9806. } else if (a.layers[f].objects[t].polygon) {
  9807. var u = c(a.layers[f].objects[t], ["name", "type", "x", "y", "visible", "properties"]);
  9808. u.polygon = [];
  9809. for (var v = 0; v < a.layers[f].objects[t].polygon.length; v++) u.polygon.push([a.layers[f].objects[t].polygon[v].x, a.layers[f].objects[t].polygon[v].y]);
  9810. r[a.layers[f].name].push(u)
  9811. } else if (a.layers[f].objects[t].ellipse) {
  9812. var u = c(a.layers[f].objects[t], ["name", "type", "ellipse", "x", "y", "width", "height", "visible", "properties"]);
  9813. r[a.layers[f].name].push(u)
  9814. } else {
  9815. var u = c(a.layers[f].objects[t], ["name", "type", "x", "y", "width", "height", "visible", "properties"]);
  9816. u.rectangle = !0, r[a.layers[f].name].push(u)
  9817. }
  9818. }
  9819. d.objects = r, d.collision = s, d.tiles = [];
  9820. for (var f = 0; f < d.tilesets.length; f++)
  9821. for (var p = d.tilesets[f], h = p.tileMargin, w = p.tileMargin, x = 0, y = 0, z = 0, k = p.firstgid; k < p.firstgid + p.total && (d.tiles[k] = [h, w, f], h += p.tileWidth + p.tileSpacing, x++, x !== p.total) && (y++, y !== p.columns || (h = p.tileMargin, w += p.tileHeight + p.tileSpacing, y = 0, z++, z !== p.rows)); k++);
  9822. var f, A, B, g, C, D, p;
  9823. for (f = 0; f < d.layers.length; f++)
  9824. for (g = d.layers[f], A = 0; A < g.data.length; A++)
  9825. for (i = g.data[A], B = 0; B < i.length; B++) C = i[B], C.index < 0 || (D = d.tiles[C.index][2], p = d.tilesets[D], p.tileProperties && p.tileProperties[C.index - p.firstgid] && (C.properties = p.tileProperties[C.index - p.firstgid]));
  9826. return d
  9827. }
  9828. }, b.Tileset = function(a, b, c, d, e, f, g) {
  9829. ("undefined" == typeof c || 0 >= c) && (c = 32), ("undefined" == typeof d || 0 >= d) && (d = 32), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = 0), this.name = a, this.firstgid = b, this.tileWidth = c, this.tileHeight = d, this.tileMargin = e, this.tileSpacing = f, this.properties = g, this.image = null, this.rows = 0, this.columns = 0, this.total = 0, this.drawCoords = []
  9830. }, b.Tileset.prototype = {
  9831. draw: function(a, b, c, d) {
  9832. this.image && this.drawCoords[d] && a.drawImage(this.image, this.drawCoords[d][0], this.drawCoords[d][1], this.tileWidth, this.tileHeight, b, c, this.tileWidth, this.tileHeight)
  9833. },
  9834. setImage: function(a) {
  9835. this.image = a, this.rows = Math.round((a.height - this.tileMargin) / (this.tileHeight + this.tileSpacing)), this.columns = Math.round((a.width - this.tileMargin) / (this.tileWidth + this.tileSpacing)), this.total = this.rows * this.columns, this.drawCoords.length = 0;
  9836. for (var b = this.tileMargin, c = this.tileMargin, d = this.firstgid, e = 0; e < this.rows; e++) {
  9837. for (var f = 0; f < this.columns; f++) this.drawCoords[d] = [b, c], b += this.tileWidth + this.tileSpacing, d++;
  9838. b = this.tileMargin, c += this.tileHeight + this.tileSpacing
  9839. }
  9840. },
  9841. setSpacing: function(a, b) {
  9842. this.tileMargin = a, this.tileSpacing = b, this.setImage(this.image)
  9843. }
  9844. }, b.Tileset.prototype.constructor = b.Tileset, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.Phaser = b) : "undefined" != typeof define && define.amd ? define("Phaser", function() {
  9845. return a.Phaser = b
  9846. }()) : a.Phaser = b
  9847. }.call(this), ! function(a) {
  9848. "object" == typeof exports ? module.exports = a() : "function" == typeof define && define.amd ? define("p2", function() {
  9849. return this.p2 = a()
  9850. }()) : "undefined" != typeof window ? window.p2 = a() : "undefined" != typeof global ? self.p2 = a() : "undefined" != typeof self && (self.p2 = a())
  9851. }(function() {
  9852. return function a(b, c, d) {
  9853. function e(g, h) {
  9854. if (!c[g]) {
  9855. if (!b[g]) {
  9856. var i = "function" == typeof require && require;
  9857. if (!h && i) return i(g, !0);
  9858. if (f) return f(g, !0);
  9859. throw new Error("Cannot find module '" + g + "'")
  9860. }
  9861. var j = c[g] = {
  9862. exports: {}
  9863. };
  9864. b[g][0].call(j.exports, function(a) {
  9865. var c = b[g][1][a];
  9866. return e(c ? c : a)
  9867. }, j, j.exports, a, b, c, d)
  9868. }
  9869. return c[g].exports
  9870. }
  9871. for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
  9872. return e
  9873. }({
  9874. 1: [function(a, b) {
  9875. a = function c(b, d, e) {
  9876. function f(h, i) {
  9877. if (!d[h]) {
  9878. if (!b[h]) {
  9879. var j = "function" == typeof a && a;
  9880. if (!i && j) return j(h, !0);
  9881. if (g) return g(h, !0);
  9882. throw new Error("Cannot find module '" + h + "'")
  9883. }
  9884. var k = d[h] = {
  9885. exports: {}
  9886. };
  9887. b[h][0].call(k.exports, function(a) {
  9888. var c = b[h][1][a];
  9889. return f(c ? c : a)
  9890. }, k, k.exports, c, b, d, e)
  9891. }
  9892. return d[h].exports
  9893. }
  9894. for (var g = "function" == typeof a && a, h = 0; h < e.length; h++) f(e[h]);
  9895. return f
  9896. }({
  9897. PcZj9L: [function(a, b, c) {
  9898. function d(a, b) {
  9899. var c = typeof a;
  9900. if ("base64" === b && "string" === c)
  9901. for (a = ib(a); a.length % 4 !== 0;) a += "=";
  9902. var e;
  9903. if ("number" === c) e = nb(a);
  9904. else if ("string" === c) e = d.byteLength(a, b);
  9905. else {
  9906. if ("object" !== c) throw new Error("First argument needs to be a number, array or string.");
  9907. e = nb(a.length)
  9908. }
  9909. var f = lb(new Cb(e));
  9910. if (d.isBuffer(a)) f.set(a);
  9911. else if (ob(a))
  9912. for (var g = 0; e > g; g++) f[g] = d.isBuffer(a) ? a.readUInt8(g) : a[g];
  9913. else "string" === c && f.write(a, 0, b);
  9914. return f
  9915. }
  9916. function e(a, b, c, e) {
  9917. c = Number(c) || 0;
  9918. var f = a.length - c;
  9919. e ? (e = Number(e), e > f && (e = f)) : e = f;
  9920. var g = b.length;
  9921. if (g % 2 !== 0) throw new Error("Invalid hex string");
  9922. e > g / 2 && (e = g / 2);
  9923. for (var h = 0; e > h; h++) {
  9924. var i = parseInt(b.substr(2 * h, 2), 16);
  9925. if (isNaN(i)) throw new Error("Invalid hex string");
  9926. a[c + h] = i
  9927. }
  9928. return d._charsWritten = 2 * h, h
  9929. }
  9930. function f(a, b, c, e) {
  9931. return d._charsWritten = tb(qb(b), a, c, e)
  9932. }
  9933. function g(a, b, c, e) {
  9934. return d._charsWritten = tb(rb(b), a, c, e)
  9935. }
  9936. function h(a, b, c, d) {
  9937. return g(a, b, c, d)
  9938. }
  9939. function i(a, b, c, e) {
  9940. return d._charsWritten = tb(sb(b), a, c, e)
  9941. }
  9942. function j(a, b, c, d) {
  9943. if (isFinite(b)) isFinite(c) || (d = c, c = void 0);
  9944. else {
  9945. var j = d;
  9946. d = b, b = c, c = j
  9947. }
  9948. b = Number(b) || 0;
  9949. var k = this.length - b;
  9950. switch (c ? (c = Number(c), c > k && (c = k)) : c = k, d = String(d || "utf8").toLowerCase()) {
  9951. case "hex":
  9952. return e(this, a, b, c);
  9953. case "utf8":
  9954. case "utf-8":
  9955. return f(this, a, b, c);
  9956. case "ascii":
  9957. return g(this, a, b, c);
  9958. case "binary":
  9959. return h(this, a, b, c);
  9960. case "base64":
  9961. return i(this, a, b, c);
  9962. default:
  9963. throw new Error("Unknown encoding")
  9964. }
  9965. }
  9966. function k(a, b, c) {
  9967. var d = this instanceof kb ? this._proxy : this;
  9968. if (a = String(a || "utf8").toLowerCase(), b = Number(b) || 0, c = void 0 !== c ? Number(c) : c = d.length, c === b) return "";
  9969. switch (a) {
  9970. case "hex":
  9971. return r(d, b, c);
  9972. case "utf8":
  9973. case "utf-8":
  9974. return o(d, b, c);
  9975. case "ascii":
  9976. return p(d, b, c);
  9977. case "binary":
  9978. return q(d, b, c);
  9979. case "base64":
  9980. return n(d, b, c);
  9981. default:
  9982. throw new Error("Unknown encoding")
  9983. }
  9984. }
  9985. function l() {
  9986. return {
  9987. type: "Buffer",
  9988. data: Array.prototype.slice.call(this, 0)
  9989. }
  9990. }
  9991. function m(a, b, c, d) {
  9992. var e = this;
  9993. if (c || (c = 0), d || 0 === d || (d = this.length), b || (b = 0), d !== c && 0 !== a.length && 0 !== e.length) {
  9994. if (c > d) throw new Error("sourceEnd < sourceStart");
  9995. if (0 > b || b >= a.length) throw new Error("targetStart out of bounds");
  9996. if (0 > c || c >= e.length) throw new Error("sourceStart out of bounds");
  9997. if (0 > d || d > e.length) throw new Error("sourceEnd out of bounds");
  9998. d > this.length && (d = this.length), a.length - b < d - c && (d = a.length - b + c);
  9999. for (var f = 0; d - c > f; f++) a[f + b] = this[f + c]
  10000. }
  10001. }
  10002. function n(b, c, d) {
  10003. var e = b.slice(c, d);
  10004. return a("base64-js").fromByteArray(e)
  10005. }
  10006. function o(a, b, c) {
  10007. for (var d = a.slice(b, c), e = "", f = "", g = 0; g < d.length;) d[g] <= 127 ? (e += ub(f) + String.fromCharCode(d[g]), f = "") : f += "%" + d[g].toString(16), g++;
  10008. return e + ub(f)
  10009. }
  10010. function p(a, b, c) {
  10011. for (var d = a.slice(b, c), e = "", f = 0; f < d.length; f++) e += String.fromCharCode(d[f]);
  10012. return e
  10013. }
  10014. function q(a, b, c) {
  10015. return p(a, b, c)
  10016. }
  10017. function r(a, b, c) {
  10018. var d = a.length;
  10019. (!b || 0 > b) && (b = 0), (!c || 0 > c || c > d) && (c = d);
  10020. for (var e = "", f = b; c > f; f++) e += pb(a[f]);
  10021. return e
  10022. }
  10023. function s(a, b) {
  10024. var c = this.length;
  10025. return a = mb(a, c, 0), b = mb(b, c, c), lb(this.subarray(a, b))
  10026. }
  10027. function t(a, b) {
  10028. var c = this;
  10029. return b || (yb(void 0 !== a && null !== a, "missing offset"), yb(a < c.length, "Trying to read beyond buffer length")), a >= c.length ? void 0 : c[a]
  10030. }
  10031. function u(a, b, c, d) {
  10032. d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(void 0 !== b && null !== b, "missing offset"), yb(b + 1 < a.length, "Trying to read beyond buffer length"));
  10033. var e = a.length;
  10034. if (!(b >= e)) {
  10035. if (b + 1 === e) {
  10036. var f = new Ab(new Bb(2));
  10037. return f.setUint8(0, a[e - 1]), f.getUint16(0, c)
  10038. }
  10039. return a._dataview.getUint16(b, c)
  10040. }
  10041. }
  10042. function v(a, b) {
  10043. return u(this, a, !0, b)
  10044. }
  10045. function w(a, b) {
  10046. return u(this, a, !1, b)
  10047. }
  10048. function x(a, b, c, d) {
  10049. d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(void 0 !== b && null !== b, "missing offset"), yb(b + 3 < a.length, "Trying to read beyond buffer length"));
  10050. var e = a.length;
  10051. if (!(b >= e)) {
  10052. if (b + 3 >= e) {
  10053. for (var f = new Ab(new Bb(4)), g = 0; e > g + b; g++) f.setUint8(g, a[g + b]);
  10054. return f.getUint32(0, c)
  10055. }
  10056. return a._dataview.getUint32(b, c)
  10057. }
  10058. }
  10059. function y(a, b) {
  10060. return x(this, a, !0, b)
  10061. }
  10062. function z(a, b) {
  10063. return x(this, a, !1, b)
  10064. }
  10065. function A(a, b) {
  10066. var c = this;
  10067. return b || (yb(void 0 !== a && null !== a, "missing offset"), yb(a < c.length, "Trying to read beyond buffer length")), a >= c.length ? void 0 : c._dataview.getInt8(a)
  10068. }
  10069. function B(a, b, c, d) {
  10070. d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(void 0 !== b && null !== b, "missing offset"), yb(b + 1 < a.length, "Trying to read beyond buffer length"));
  10071. var e = a.length;
  10072. if (!(b >= e)) {
  10073. if (b + 1 === e) {
  10074. var f = new Ab(new Bb(2));
  10075. return f.setUint8(0, a[e - 1]), f.getInt16(0, c)
  10076. }
  10077. return a._dataview.getInt16(b, c)
  10078. }
  10079. }
  10080. function C(a, b) {
  10081. return B(this, a, !0, b)
  10082. }
  10083. function D(a, b) {
  10084. return B(this, a, !1, b)
  10085. }
  10086. function E(a, b, c, d) {
  10087. d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(void 0 !== b && null !== b, "missing offset"), yb(b + 3 < a.length, "Trying to read beyond buffer length"));
  10088. var e = a.length;
  10089. if (!(b >= e)) {
  10090. if (b + 3 >= e) {
  10091. for (var f = new Ab(new Bb(4)), g = 0; e > g + b; g++) f.setUint8(g, a[g + b]);
  10092. return f.getInt32(0, c)
  10093. }
  10094. return a._dataview.getInt32(b, c)
  10095. }
  10096. }
  10097. function F(a, b) {
  10098. return E(this, a, !0, b)
  10099. }
  10100. function G(a, b) {
  10101. return E(this, a, !1, b)
  10102. }
  10103. function H(a, b, c, d) {
  10104. return d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(b + 3 < a.length, "Trying to read beyond buffer length")), a._dataview.getFloat32(b, c)
  10105. }
  10106. function I(a, b) {
  10107. return H(this, a, !0, b)
  10108. }
  10109. function J(a, b) {
  10110. return H(this, a, !1, b)
  10111. }
  10112. function K(a, b, c, d) {
  10113. return d || (yb("boolean" == typeof c, "missing or invalid endian"), yb(b + 7 < a.length, "Trying to read beyond buffer length")), a._dataview.getFloat64(b, c)
  10114. }
  10115. function L(a, b) {
  10116. return K(this, a, !0, b)
  10117. }
  10118. function M(a, b) {
  10119. return K(this, a, !1, b)
  10120. }
  10121. function N(a, b, c) {
  10122. var d = this;
  10123. c || (yb(void 0 !== a && null !== a, "missing value"), yb(void 0 !== b && null !== b, "missing offset"), yb(b < d.length, "trying to write beyond buffer length"), vb(a, 255)), b >= d.length || (d[b] = a)
  10124. }
  10125. function O(a, b, c, d, e) {
  10126. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 1 < a.length, "trying to write beyond buffer length"), vb(b, 65535));
  10127. var f = a.length;
  10128. if (!(c >= f))
  10129. if (c + 1 === f) {
  10130. var g = new Ab(new Bb(2));
  10131. g.setUint16(0, b, d), a[c] = g.getUint8(0)
  10132. } else a._dataview.setUint16(c, b, d)
  10133. }
  10134. function P(a, b, c) {
  10135. O(this, a, b, !0, c)
  10136. }
  10137. function Q(a, b, c) {
  10138. O(this, a, b, !1, c)
  10139. }
  10140. function R(a, b, c, d, e) {
  10141. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 3 < a.length, "trying to write beyond buffer length"), vb(b, 4294967295));
  10142. var f = a.length;
  10143. if (!(c >= f))
  10144. if (c + 3 >= f) {
  10145. var g = new Ab(new Bb(4));
  10146. g.setUint32(0, b, d);
  10147. for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
  10148. } else a._dataview.setUint32(c, b, d)
  10149. }
  10150. function S(a, b, c) {
  10151. R(this, a, b, !0, c)
  10152. }
  10153. function T(a, b, c) {
  10154. R(this, a, b, !1, c)
  10155. }
  10156. function U(a, b, c) {
  10157. var d = this;
  10158. c || (yb(void 0 !== a && null !== a, "missing value"), yb(void 0 !== b && null !== b, "missing offset"), yb(b < d.length, "Trying to write beyond buffer length"), wb(a, 127, -128)), b >= d.length || d._dataview.setInt8(b, a)
  10159. }
  10160. function V(a, b, c, d, e) {
  10161. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 1 < a.length, "Trying to write beyond buffer length"), wb(b, 32767, -32768));
  10162. var f = a.length;
  10163. if (!(c >= f))
  10164. if (c + 1 === f) {
  10165. var g = new Ab(new Bb(2));
  10166. g.setInt16(0, b, d), a[c] = g.getUint8(0)
  10167. } else a._dataview.setInt16(c, b, d)
  10168. }
  10169. function W(a, b, c) {
  10170. V(this, a, b, !0, c)
  10171. }
  10172. function X(a, b, c) {
  10173. V(this, a, b, !1, c)
  10174. }
  10175. function Y(a, b, c, d, e) {
  10176. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 3 < a.length, "Trying to write beyond buffer length"), wb(b, 2147483647, -2147483648));
  10177. var f = a.length;
  10178. if (!(c >= f))
  10179. if (c + 3 >= f) {
  10180. var g = new Ab(new Bb(4));
  10181. g.setInt32(0, b, d);
  10182. for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
  10183. } else a._dataview.setInt32(c, b, d)
  10184. }
  10185. function Z(a, b, c) {
  10186. Y(this, a, b, !0, c)
  10187. }
  10188. function $(a, b, c) {
  10189. Y(this, a, b, !1, c)
  10190. }
  10191. function _(a, b, c, d, e) {
  10192. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 3 < a.length, "Trying to write beyond buffer length"), xb(b, 3.4028234663852886e38, -3.4028234663852886e38));
  10193. var f = a.length;
  10194. if (!(c >= f))
  10195. if (c + 3 >= f) {
  10196. var g = new Ab(new Bb(4));
  10197. g.setFloat32(0, b, d);
  10198. for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
  10199. } else a._dataview.setFloat32(c, b, d)
  10200. }
  10201. function ab(a, b, c) {
  10202. _(this, a, b, !0, c)
  10203. }
  10204. function bb(a, b, c) {
  10205. _(this, a, b, !1, c)
  10206. }
  10207. function cb(a, b, c, d, e) {
  10208. e || (yb(void 0 !== b && null !== b, "missing value"), yb("boolean" == typeof d, "missing or invalid endian"), yb(void 0 !== c && null !== c, "missing offset"), yb(c + 7 < a.length, "Trying to write beyond buffer length"), xb(b, 1.7976931348623157e308, -1.7976931348623157e308));
  10209. var f = a.length;
  10210. if (!(c >= f))
  10211. if (c + 7 >= f) {
  10212. var g = new Ab(new Bb(8));
  10213. g.setFloat64(0, b, d);
  10214. for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
  10215. } else a._dataview.setFloat64(c, b, d)
  10216. }
  10217. function db(a, b, c) {
  10218. cb(this, a, b, !0, c)
  10219. }
  10220. function eb(a, b, c) {
  10221. cb(this, a, b, !1, c)
  10222. }
  10223. function fb(a, b, c) {
  10224. if (a || (a = 0), b || (b = 0), c || (c = this.length), "string" == typeof a && (a = a.charCodeAt(0)), "number" != typeof a || isNaN(a)) throw new Error("value is not a number");
  10225. if (b > c) throw new Error("end < start");
  10226. if (c !== b && 0 !== this.length) {
  10227. if (0 > b || b >= this.length) throw new Error("start out of bounds");
  10228. if (0 > c || c > this.length) throw new Error("end out of bounds");
  10229. for (var d = b; c > d; d++) this[d] = a
  10230. }
  10231. }
  10232. function gb() {
  10233. for (var a = [], b = this.length, d = 0; b > d; d++)
  10234. if (a[d] = pb(this[d]), d === c.INSPECT_MAX_BYTES) {
  10235. a[d + 1] = "...";
  10236. break
  10237. }
  10238. return "<Buffer " + a.join(" ") + ">"
  10239. }
  10240. function hb() {
  10241. return new d(this).buffer
  10242. }
  10243. function ib(a) {
  10244. return a.trim ? a.trim() : a.replace(/^\s+|\s+$/g, "")
  10245. }
  10246. function jb() {
  10247. var a = new Cb(0);
  10248. a.foo = function() {
  10249. return 42
  10250. };
  10251. try {
  10252. return 42 === a.foo()
  10253. } catch (b) {
  10254. return !1
  10255. }
  10256. }
  10257. function kb(a) {
  10258. this._arr = a, 0 !== a.byteLength && (this._dataview = new Ab(a.buffer, a.byteOffset, a.byteLength))
  10259. }
  10260. function lb(a) {
  10261. if (void 0 === Db && (Db = jb()), Db) return a.write = j, a.toString = k, a.toLocaleString = k, a.toJSON = l, a.copy = m, a.slice = s, a.readUInt8 = t, a.readUInt16LE = v, a.readUInt16BE = w, a.readUInt32LE = y, a.readUInt32BE = z, a.readInt8 = A, a.readInt16LE = C, a.readInt16BE = D, a.readInt32LE = F, a.readInt32BE = G, a.readFloatLE = I, a.readFloatBE = J, a.readDoubleLE = L, a.readDoubleBE = M, a.writeUInt8 = N, a.writeUInt16LE = P, a.writeUInt16BE = Q, a.writeUInt32LE = S, a.writeUInt32BE = T, a.writeInt8 = U, a.writeInt16LE = W, a.writeInt16BE = X, a.writeInt32LE = Z, a.writeInt32BE = $, a.writeFloatLE = ab, a.writeFloatBE = bb, a.writeDoubleLE = db, a.writeDoubleBE = eb, a.fill = fb, a.inspect = gb, a.toArrayBuffer = hb, a._isBuffer = !0, 0 !== a.byteLength && (a._dataview = new Ab(a.buffer, a.byteOffset, a.byteLength)), a;
  10262. var b = new kb(a),
  10263. c = new Proxy(b, Eb);
  10264. return b._proxy = c, c
  10265. }
  10266. function mb(a, b, c) {
  10267. return "number" != typeof a ? c : (a = ~~a, a >= b ? b : a >= 0 ? a : (a += b, a >= 0 ? a : 0))
  10268. }
  10269. function nb(a) {
  10270. return a = ~~Math.ceil(+a), 0 > a ? 0 : a
  10271. }
  10272. function ob(a) {
  10273. return Array.isArray(a) || d.isBuffer(a) || a && "object" == typeof a && "number" == typeof a.length
  10274. }
  10275. function pb(a) {
  10276. return 16 > a ? "0" + a.toString(16) : a.toString(16)
  10277. }
  10278. function qb(a) {
  10279. for (var b = [], c = 0; c < a.length; c++)
  10280. if (a.charCodeAt(c) <= 127) b.push(a.charCodeAt(c));
  10281. else
  10282. for (var d = encodeURIComponent(a.charAt(c)).substr(1).split("%"), e = 0; e < d.length; e++) b.push(parseInt(d[e], 16));
  10283. return b
  10284. }
  10285. function rb(a) {
  10286. for (var b = [], c = 0; c < a.length; c++) b.push(255 & a.charCodeAt(c));
  10287. return b
  10288. }
  10289. function sb(b) {
  10290. return a("base64-js").toByteArray(b)
  10291. }
  10292. function tb(a, b, c, d) {
  10293. for (var e = 0; d > e && !(e + c >= b.length || e >= a.length);) b[e + c] = a[e], e++;
  10294. return e
  10295. }
  10296. function ub(a) {
  10297. try {
  10298. return decodeURIComponent(a)
  10299. } catch (b) {
  10300. return String.fromCharCode(65533)
  10301. }
  10302. }
  10303. function vb(a, b) {
  10304. yb("number" == typeof a, "cannot write a non-number as a number"), yb(a >= 0, "specified a negative value for writing an unsigned value"), yb(b >= a, "value is larger than maximum value for type"), yb(Math.floor(a) === a, "value has a fractional component")
  10305. }
  10306. function wb(a, b, c) {
  10307. yb("number" == typeof a, "cannot write a non-number as a number"), yb(b >= a, "value larger than maximum allowed value"), yb(a >= c, "value smaller than minimum allowed value"), yb(Math.floor(a) === a, "value has a fractional component")
  10308. }
  10309. function xb(a, b, c) {
  10310. yb("number" == typeof a, "cannot write a non-number as a number"), yb(b >= a, "value larger than maximum allowed value"), yb(a >= c, "value smaller than minimum allowed value")
  10311. }
  10312. function yb(a, b) {
  10313. if (!a) throw new Error(b || "Failed assertion")
  10314. }
  10315. var zb = a("typedarray"),
  10316. Ab = "undefined" == typeof DataView ? zb.DataView : DataView,
  10317. Bb = "undefined" == typeof ArrayBuffer ? zb.ArrayBuffer : ArrayBuffer,
  10318. Cb = "undefined" == typeof Uint8Array ? zb.Uint8Array : Uint8Array;
  10319. c.Buffer = d, c.SlowBuffer = d, c.INSPECT_MAX_BYTES = 50, d.poolSize = 8192;
  10320. var Db;
  10321. d.isEncoding = function(a) {
  10322. switch ((a + "").toLowerCase()) {
  10323. case "hex":
  10324. case "utf8":
  10325. case "utf-8":
  10326. case "ascii":
  10327. case "binary":
  10328. case "base64":
  10329. case "ucs2":
  10330. case "ucs-2":
  10331. case "utf16le":
  10332. case "utf-16le":
  10333. case "raw":
  10334. return !0;
  10335. default:
  10336. return !1
  10337. }
  10338. }, d.isBuffer = function(a) {
  10339. return a && a._isBuffer
  10340. }, d.byteLength = function(a, b) {
  10341. switch (b || "utf8") {
  10342. case "hex":
  10343. return a.length / 2;
  10344. case "utf8":
  10345. case "utf-8":
  10346. return qb(a).length;
  10347. case "ascii":
  10348. case "binary":
  10349. return a.length;
  10350. case "base64":
  10351. return sb(a).length;
  10352. default:
  10353. throw new Error("Unknown encoding")
  10354. }
  10355. }, d.concat = function(a, b) {
  10356. if (!Array.isArray(a)) throw new Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");
  10357. var c, e;
  10358. if (0 === a.length) return new d(0);
  10359. if (1 === a.length) return a[0];
  10360. if ("number" != typeof b)
  10361. for (b = 0, c = 0; c < a.length; c++) e = a[c], b += e.length;
  10362. var f = new d(b),
  10363. g = 0;
  10364. for (c = 0; c < a.length; c++) e = a[c], e.copy(f, g), g += e.length;
  10365. return f
  10366. }, kb.prototype.write = j, kb.prototype.toString = k, kb.prototype.toLocaleString = k, kb.prototype.toJSON = l, kb.prototype.copy = m, kb.prototype.slice = s, kb.prototype.readUInt8 = t, kb.prototype.readUInt16LE = v, kb.prototype.readUInt16BE = w, kb.prototype.readUInt32LE = y, kb.prototype.readUInt32BE = z, kb.prototype.readInt8 = A, kb.prototype.readInt16LE = C, kb.prototype.readInt16BE = D, kb.prototype.readInt32LE = F, kb.prototype.readInt32BE = G, kb.prototype.readFloatLE = I, kb.prototype.readFloatBE = J, kb.prototype.readDoubleLE = L, kb.prototype.readDoubleBE = M, kb.prototype.writeUInt8 = N, kb.prototype.writeUInt16LE = P, kb.prototype.writeUInt16BE = Q, kb.prototype.writeUInt32LE = S, kb.prototype.writeUInt32BE = T, kb.prototype.writeInt8 = U, kb.prototype.writeInt16LE = W, kb.prototype.writeInt16BE = X, kb.prototype.writeInt32LE = Z, kb.prototype.writeInt32BE = $, kb.prototype.writeFloatLE = ab, kb.prototype.writeFloatBE = bb, kb.prototype.writeDoubleLE = db, kb.prototype.writeDoubleBE = eb, kb.prototype.fill = fb, kb.prototype.inspect = gb, kb.prototype.toArrayBuffer = hb, kb.prototype._isBuffer = !0, kb.prototype.subarray = function() {
  10367. return this._arr.subarray.apply(this._arr, arguments)
  10368. }, kb.prototype.set = function() {
  10369. return this._arr.set.apply(this._arr, arguments)
  10370. };
  10371. var Eb = {
  10372. get: function(a, b) {
  10373. return b in a ? a[b] : a._arr[b]
  10374. },
  10375. set: function(a, b, c) {
  10376. a._arr[b] = c
  10377. }
  10378. }
  10379. }, {
  10380. "base64-js": 3,
  10381. typedarray: 4
  10382. }],
  10383. "native-buffer-browserify": [function(a, b) {
  10384. b.exports = a("PcZj9L")
  10385. }, {}],
  10386. 3: [function(a, b) {
  10387. ! function() {
  10388. "use strict";
  10389. function a(a) {
  10390. var b, c, e, f, g, h;
  10391. if (a.length % 4 > 0) throw "Invalid string. Length must be a multiple of 4";
  10392. for (g = a.indexOf("="), g = g > 0 ? a.length - g : 0, h = [], e = g > 0 ? a.length - 4 : a.length, b = 0, c = 0; e > b; b += 4, c += 3) f = d.indexOf(a[b]) << 18 | d.indexOf(a[b + 1]) << 12 | d.indexOf(a[b + 2]) << 6 | d.indexOf(a[b + 3]), h.push((16711680 & f) >> 16), h.push((65280 & f) >> 8), h.push(255 & f);
  10393. return 2 === g ? (f = d.indexOf(a[b]) << 2 | d.indexOf(a[b + 1]) >> 4, h.push(255 & f)) : 1 === g && (f = d.indexOf(a[b]) << 10 | d.indexOf(a[b + 1]) << 4 | d.indexOf(a[b + 2]) >> 2, h.push(f >> 8 & 255), h.push(255 & f)), h
  10394. }
  10395. function c(a) {
  10396. function b(a) {
  10397. return d[a >> 18 & 63] + d[a >> 12 & 63] + d[a >> 6 & 63] + d[63 & a]
  10398. }
  10399. var c, e, f, g = a.length % 3,
  10400. h = "";
  10401. for (c = 0, f = a.length - g; f > c; c += 3) e = (a[c] << 16) + (a[c + 1] << 8) + a[c + 2], h += b(e);
  10402. switch (g) {
  10403. case 1:
  10404. e = a[a.length - 1], h += d[e >> 2], h += d[e << 4 & 63], h += "==";
  10405. break;
  10406. case 2:
  10407. e = (a[a.length - 2] << 8) + a[a.length - 1], h += d[e >> 10], h += d[e >> 4 & 63], h += d[e << 2 & 63], h += "="
  10408. }
  10409. return h
  10410. }
  10411. var d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  10412. b.exports.toByteArray = a, b.exports.fromByteArray = c
  10413. }()
  10414. }, {}],
  10415. 4: [function(a, b, c) {
  10416. function d(a) {
  10417. if (L && K) {
  10418. var b, c = L(a);
  10419. for (b = 0; b < c.length; b += 1) K(a, c[b], {
  10420. value: a[c[b]],
  10421. writable: !1,
  10422. enumerable: !1,
  10423. configurable: !1
  10424. })
  10425. }
  10426. }
  10427. function e(a) {
  10428. function b(b) {
  10429. K(a, b, {
  10430. get: function() {
  10431. return a._getter(b)
  10432. },
  10433. set: function(c) {
  10434. a._setter(b, c)
  10435. },
  10436. enumerable: !0,
  10437. configurable: !1
  10438. })
  10439. }
  10440. if (K) {
  10441. if (a.length > B) throw new RangeError("Array too large for polyfill");
  10442. var c;
  10443. for (c = 0; c < a.length; c += 1) b(c)
  10444. }
  10445. }
  10446. function f(a, b) {
  10447. var c = 32 - b;
  10448. return a << c >> c
  10449. }
  10450. function g(a, b) {
  10451. var c = 32 - b;
  10452. return a << c >>> c
  10453. }
  10454. function h(a) {
  10455. return [255 & a]
  10456. }
  10457. function i(a) {
  10458. return f(a[0], 8)
  10459. }
  10460. function j(a) {
  10461. return [255 & a]
  10462. }
  10463. function k(a) {
  10464. return g(a[0], 8)
  10465. }
  10466. function l(a) {
  10467. return a = J(Number(a)), [0 > a ? 0 : a > 255 ? 255 : 255 & a]
  10468. }
  10469. function m(a) {
  10470. return [a >> 8 & 255, 255 & a]
  10471. }
  10472. function n(a) {
  10473. return f(a[0] << 8 | a[1], 16)
  10474. }
  10475. function o(a) {
  10476. return [a >> 8 & 255, 255 & a]
  10477. }
  10478. function p(a) {
  10479. return g(a[0] << 8 | a[1], 16)
  10480. }
  10481. function q(a) {
  10482. return [a >> 24 & 255, a >> 16 & 255, a >> 8 & 255, 255 & a]
  10483. }
  10484. function r(a) {
  10485. return f(a[0] << 24 | a[1] << 16 | a[2] << 8 | a[3], 32)
  10486. }
  10487. function s(a) {
  10488. return [a >> 24 & 255, a >> 16 & 255, a >> 8 & 255, 255 & a]
  10489. }
  10490. function t(a) {
  10491. return g(a[0] << 24 | a[1] << 16 | a[2] << 8 | a[3], 32)
  10492. }
  10493. function u(a, b, c) {
  10494. function d(a) {
  10495. var b = F(a),
  10496. c = a - b;
  10497. return .5 > c ? b : c > .5 ? b + 1 : b % 2 ? b + 1 : b
  10498. }
  10499. var e, f, g, h, i, j, k, l = (1 << b - 1) - 1;
  10500. for (a !== a ? (f = (1 << b) - 1, g = I(2, c - 1), e = 0) : 1 / 0 === a || a === -1 / 0 ? (f = (1 << b) - 1, g = 0, e = 0 > a ? 1 : 0) : 0 === a ? (f = 0, g = 0, e = 1 / a === -1 / 0 ? 1 : 0) : (e = 0 > a, a = E(a), a >= I(2, 1 - l) ? (f = H(F(G(a) / D), 1023), g = d(a / I(2, f) * I(2, c)), g / I(2, c) >= 2 && (f += 1, g = 1), f > l ? (f = (1 << b) - 1, g = 0) : (f += l, g -= I(2, c))) : (f = 0, g = d(a / I(2, 1 - l - c)))), i = [], h = c; h; h -= 1) i.push(g % 2 ? 1 : 0), g = F(g / 2);
  10501. for (h = b; h; h -= 1) i.push(f % 2 ? 1 : 0), f = F(f / 2);
  10502. for (i.push(e ? 1 : 0), i.reverse(), j = i.join(""), k = []; j.length;) k.push(parseInt(j.substring(0, 8), 2)), j = j.substring(8);
  10503. return k
  10504. }
  10505. function v(a, b, c) {
  10506. var d, e, f, g, h, i, j, k, l = [];
  10507. for (d = a.length; d; d -= 1)
  10508. for (f = a[d - 1], e = 8; e; e -= 1) l.push(f % 2 ? 1 : 0), f >>= 1;
  10509. return l.reverse(), g = l.join(""), h = (1 << b - 1) - 1, i = parseInt(g.substring(0, 1), 2) ? -1 : 1, j = parseInt(g.substring(1, 1 + b), 2), k = parseInt(g.substring(1 + b), 2), j === (1 << b) - 1 ? 0 !== k ? 0 / 0 : 1 / 0 * i : j > 0 ? i * I(2, j - h) * (1 + k / I(2, c)) : 0 !== k ? i * I(2, -(h - 1)) * (k / I(2, c)) : 0 > i ? -0 : 0
  10510. }
  10511. function w(a) {
  10512. return v(a, 11, 52)
  10513. }
  10514. function x(a) {
  10515. return u(a, 11, 52)
  10516. }
  10517. function y(a) {
  10518. return v(a, 8, 23)
  10519. }
  10520. function z(a) {
  10521. return u(a, 8, 23)
  10522. }
  10523. var A = void 0,
  10524. B = 1e5,
  10525. C = function() {
  10526. var a = Object.prototype.toString,
  10527. b = Object.prototype.hasOwnProperty;
  10528. return {
  10529. Class: function(b) {
  10530. return a.call(b).replace(/^\[object *|\]$/g, "")
  10531. },
  10532. HasProperty: function(a, b) {
  10533. return b in a
  10534. },
  10535. HasOwnProperty: function(a, c) {
  10536. return b.call(a, c)
  10537. },
  10538. IsCallable: function(a) {
  10539. return "function" == typeof a
  10540. },
  10541. ToInt32: function(a) {
  10542. return a >> 0
  10543. },
  10544. ToUint32: function(a) {
  10545. return a >>> 0
  10546. }
  10547. }
  10548. }(),
  10549. D = Math.LN2,
  10550. E = Math.abs,
  10551. F = Math.floor,
  10552. G = Math.log,
  10553. H = Math.min,
  10554. I = Math.pow,
  10555. J = Math.round,
  10556. K = Object.defineProperty || function(a, b, c) {
  10557. if (!a === Object(a)) throw new TypeError("Object.defineProperty called on non-object");
  10558. return C.HasProperty(c, "get") && Object.prototype.__defineGetter__ && Object.prototype.__defineGetter__.call(a, b, c.get), C.HasProperty(c, "set") && Object.prototype.__defineSetter__ && Object.prototype.__defineSetter__.call(a, b, c.set), C.HasProperty(c, "value") && (a[b] = c.value), a
  10559. },
  10560. L = Object.getOwnPropertyNames || function(a) {
  10561. if (a !== Object(a)) throw new TypeError("Object.getOwnPropertyNames called on non-object");
  10562. var b, c = [];
  10563. for (b in a) C.HasOwnProperty(a, b) && c.push(b);
  10564. return c
  10565. };
  10566. ! function() {
  10567. function a(a, c, g) {
  10568. var h;
  10569. return h = function(a, c, f) {
  10570. var g, i, j, k;
  10571. if (arguments.length && "number" != typeof arguments[0])
  10572. if ("object" == typeof arguments[0] && arguments[0].constructor === h)
  10573. for (g = arguments[0], this.length = g.length, this.byteLength = this.length * this.BYTES_PER_ELEMENT, this.buffer = new b(this.byteLength), this.byteOffset = 0, j = 0; j < this.length; j += 1) this._setter(j, g._getter(j));
  10574. else if ("object" != typeof arguments[0] || (arguments[0] instanceof b || "ArrayBuffer" === C.Class(arguments[0]))) {
  10575. if ("object" != typeof arguments[0] || !(arguments[0] instanceof b || "ArrayBuffer" === C.Class(arguments[0]))) throw new TypeError("Unexpected argument type(s)");
  10576. if (this.buffer = a, this.byteOffset = C.ToUint32(c), this.byteOffset > this.buffer.byteLength) throw new RangeError("byteOffset out of range");
  10577. if (this.byteOffset % this.BYTES_PER_ELEMENT) throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");
  10578. if (arguments.length < 3) {
  10579. if (this.byteLength = this.buffer.byteLength - this.byteOffset, this.byteLength % this.BYTES_PER_ELEMENT) throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");
  10580. this.length = this.byteLength / this.BYTES_PER_ELEMENT
  10581. } else this.length = C.ToUint32(f), this.byteLength = this.length * this.BYTES_PER_ELEMENT;
  10582. if (this.byteOffset + this.byteLength > this.buffer.byteLength) throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")
  10583. } else
  10584. for (i = arguments[0], this.length = C.ToUint32(i.length), this.byteLength = this.length * this.BYTES_PER_ELEMENT, this.buffer = new b(this.byteLength), this.byteOffset = 0, j = 0; j < this.length; j += 1) k = i[j], this._setter(j, Number(k));
  10585. else {
  10586. if (this.length = C.ToInt32(arguments[0]), 0 > f) throw new RangeError("ArrayBufferView size is not a small enough positive integer");
  10587. this.byteLength = this.length * this.BYTES_PER_ELEMENT, this.buffer = new b(this.byteLength), this.byteOffset = 0
  10588. }
  10589. this.constructor = h, d(this), e(this)
  10590. }, h.prototype = new f, h.prototype.BYTES_PER_ELEMENT = a, h.prototype._pack = c, h.prototype._unpack = g, h.BYTES_PER_ELEMENT = a, h.prototype._getter = function(a) {
  10591. if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
  10592. if (a = C.ToUint32(a), a >= this.length) return A;
  10593. var b, c, d = [];
  10594. for (b = 0, c = this.byteOffset + a * this.BYTES_PER_ELEMENT; b < this.BYTES_PER_ELEMENT; b += 1, c += 1) d.push(this.buffer._bytes[c]);
  10595. return this._unpack(d)
  10596. }, h.prototype.get = h.prototype._getter, h.prototype._setter = function(a, b) {
  10597. if (arguments.length < 2) throw new SyntaxError("Not enough arguments");
  10598. if (a = C.ToUint32(a), a >= this.length) return A;
  10599. var c, d, e = this._pack(b);
  10600. for (c = 0, d = this.byteOffset + a * this.BYTES_PER_ELEMENT; c < this.BYTES_PER_ELEMENT; c += 1, d += 1) this.buffer._bytes[d] = e[c]
  10601. }, h.prototype.set = function() {
  10602. if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
  10603. var a, b, c, d, e, f, g, h, i, j;
  10604. if ("object" == typeof arguments[0] && arguments[0].constructor === this.constructor) {
  10605. if (a = arguments[0], c = C.ToUint32(arguments[1]), c + a.length > this.length) throw new RangeError("Offset plus length of array is out of range");
  10606. if (h = this.byteOffset + c * this.BYTES_PER_ELEMENT, i = a.length * this.BYTES_PER_ELEMENT, a.buffer === this.buffer) {
  10607. for (j = [], e = 0, f = a.byteOffset; i > e; e += 1, f += 1) j[e] = a.buffer._bytes[f];
  10608. for (e = 0, g = h; i > e; e += 1, g += 1) this.buffer._bytes[g] = j[e]
  10609. } else
  10610. for (e = 0, f = a.byteOffset, g = h; i > e; e += 1, f += 1, g += 1) this.buffer._bytes[g] = a.buffer._bytes[f]
  10611. } else {
  10612. if ("object" != typeof arguments[0] || "undefined" == typeof arguments[0].length) throw new TypeError("Unexpected argument type(s)");
  10613. if (b = arguments[0], d = C.ToUint32(b.length), c = C.ToUint32(arguments[1]), c + d > this.length) throw new RangeError("Offset plus length of array is out of range");
  10614. for (e = 0; d > e; e += 1) f = b[e], this._setter(c + e, Number(f))
  10615. }
  10616. }, h.prototype.subarray = function(a, b) {
  10617. function c(a, b, c) {
  10618. return b > a ? b : a > c ? c : a
  10619. }
  10620. a = C.ToInt32(a), b = C.ToInt32(b), arguments.length < 1 && (a = 0), arguments.length < 2 && (b = this.length), 0 > a && (a = this.length + a), 0 > b && (b = this.length + b), a = c(a, 0, this.length), b = c(b, 0, this.length);
  10621. var d = b - a;
  10622. return 0 > d && (d = 0), new this.constructor(this.buffer, this.byteOffset + a * this.BYTES_PER_ELEMENT, d)
  10623. }, h
  10624. }
  10625. var b = function(a) {
  10626. if (a = C.ToInt32(a), 0 > a) throw new RangeError("ArrayBuffer size is not a small enough positive integer");
  10627. this.byteLength = a, this._bytes = [], this._bytes.length = a;
  10628. var b;
  10629. for (b = 0; b < this.byteLength; b += 1) this._bytes[b] = 0;
  10630. d(this)
  10631. };
  10632. c.ArrayBuffer = c.ArrayBuffer || b;
  10633. var f = function() {},
  10634. g = a(1, h, i),
  10635. u = a(1, j, k),
  10636. v = a(1, l, k),
  10637. B = a(2, m, n),
  10638. D = a(2, o, p),
  10639. E = a(4, q, r),
  10640. F = a(4, s, t),
  10641. G = a(4, z, y),
  10642. H = a(8, x, w);
  10643. c.Int8Array = c.Int8Array || g, c.Uint8Array = c.Uint8Array || u, c.Uint8ClampedArray = c.Uint8ClampedArray || v, c.Int16Array = c.Int16Array || B, c.Uint16Array = c.Uint16Array || D, c.Int32Array = c.Int32Array || E, c.Uint32Array = c.Uint32Array || F, c.Float32Array = c.Float32Array || G, c.Float64Array = c.Float64Array || H
  10644. }(),
  10645. function() {
  10646. function a(a, b) {
  10647. return C.IsCallable(a.get) ? a.get(b) : a[b]
  10648. }
  10649. function b(b) {
  10650. return function(c, d) {
  10651. if (c = C.ToUint32(c), c + b.BYTES_PER_ELEMENT > this.byteLength) throw new RangeError("Array index out of range");
  10652. c += this.byteOffset;
  10653. var e, g = new Uint8Array(this.buffer, c, b.BYTES_PER_ELEMENT),
  10654. h = [];
  10655. for (e = 0; e < b.BYTES_PER_ELEMENT; e += 1) h.push(a(g, e));
  10656. return Boolean(d) === Boolean(f) && h.reverse(), a(new b(new Uint8Array(h).buffer), 0)
  10657. }
  10658. }
  10659. function e(b) {
  10660. return function(c, d, e) {
  10661. if (c = C.ToUint32(c), c + b.BYTES_PER_ELEMENT > this.byteLength) throw new RangeError("Array index out of range");
  10662. var g, h, i = new b([d]),
  10663. j = new Uint8Array(i.buffer),
  10664. k = [];
  10665. for (g = 0; g < b.BYTES_PER_ELEMENT; g += 1) k.push(a(j, g));
  10666. Boolean(e) === Boolean(f) && k.reverse(), h = new Uint8Array(this.buffer, c, b.BYTES_PER_ELEMENT), h.set(k)
  10667. }
  10668. }
  10669. var f = function() {
  10670. var b = new c.Uint16Array([4660]),
  10671. d = new c.Uint8Array(b.buffer);
  10672. return 18 === a(d, 0)
  10673. }(),
  10674. g = function(a, b, c) {
  10675. if (0 === arguments.length) a = new ArrayBuffer(0);
  10676. else if (!(a instanceof ArrayBuffer || "ArrayBuffer" === C.Class(a))) throw new TypeError("TypeError");
  10677. if (this.buffer = a || new ArrayBuffer(0), this.byteOffset = C.ToUint32(b), this.byteOffset > this.buffer.byteLength) throw new RangeError("byteOffset out of range");
  10678. if (this.byteLength = arguments.length < 3 ? this.buffer.byteLength - this.byteOffset : C.ToUint32(c), this.byteOffset + this.byteLength > this.buffer.byteLength) throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");
  10679. d(this)
  10680. };
  10681. g.prototype.getUint8 = b(c.Uint8Array), g.prototype.getInt8 = b(c.Int8Array), g.prototype.getUint16 = b(c.Uint16Array), g.prototype.getInt16 = b(c.Int16Array), g.prototype.getUint32 = b(c.Uint32Array), g.prototype.getInt32 = b(c.Int32Array), g.prototype.getFloat32 = b(c.Float32Array), g.prototype.getFloat64 = b(c.Float64Array), g.prototype.setUint8 = e(c.Uint8Array), g.prototype.setInt8 = e(c.Int8Array), g.prototype.setUint16 = e(c.Uint16Array), g.prototype.setInt16 = e(c.Int16Array), g.prototype.setUint32 = e(c.Uint32Array), g.prototype.setInt32 = e(c.Int32Array), g.prototype.setFloat32 = e(c.Float32Array), g.prototype.setFloat64 = e(c.Float64Array), c.DataView = c.DataView || g
  10682. }()
  10683. }, {}]
  10684. }, {}, []), b.exports = a("native-buffer-browserify").Buffer
  10685. }, {}],
  10686. 2: [function(a, b) {
  10687. var c = b.exports = {};
  10688. c.nextTick = function() {
  10689. var a = "undefined" != typeof window && window.setImmediate,
  10690. b = "undefined" != typeof window && window.postMessage && window.addEventListener;
  10691. if (a) return function(a) {
  10692. return window.setImmediate(a)
  10693. };
  10694. if (b) {
  10695. var c = [];
  10696. return window.addEventListener("message", function(a) {
  10697. if (a.source === window && "process-tick" === a.data && (a.stopPropagation(), c.length > 0)) {
  10698. var b = c.shift();
  10699. b()
  10700. }
  10701. }, !0),
  10702. function(a) {
  10703. c.push(a), window.postMessage("process-tick", "*")
  10704. }
  10705. }
  10706. return function(a) {
  10707. setTimeout(a, 0)
  10708. }
  10709. }(), c.title = "browser", c.browser = !0, c.env = {}, c.argv = [], c.binding = function() {
  10710. throw new Error("process.binding is not supported")
  10711. }, c.cwd = function() {
  10712. return "/"
  10713. }, c.chdir = function() {
  10714. throw new Error("process.chdir is not supported")
  10715. }
  10716. }, {}],
  10717. 3: [function(a, b) {
  10718. function c() {}
  10719. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Scalar"));
  10720. b.exports = c, c.lineInt = function(a, b, c) {
  10721. c = c || 0;
  10722. var e, f, g, h, i, j, k, l = [0, 0];
  10723. 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
  10724. }, c.segmentsIntersect = function(a, b, c, d) {
  10725. var e = b[0] - a[0],
  10726. f = b[1] - a[1],
  10727. g = d[0] - c[0],
  10728. h = d[1] - c[1];
  10729. if (g * f - h * e == 0) return !1;
  10730. var i = (e * (c[1] - a[1]) + f * (a[0] - c[0])) / (g * f - h * e),
  10731. j = (g * (a[1] - c[1]) + h * (c[0] - a[0])) / (h * e - g * f);
  10732. return i >= 0 && 1 >= i && j >= 0 && 1 >= j
  10733. }
  10734. }, {
  10735. "./Scalar": 6,
  10736. __browserify_Buffer: 1,
  10737. __browserify_process: 2
  10738. }],
  10739. 4: [function(a, b) {
  10740. function c() {}
  10741. a("__browserify_process"), a("__browserify_Buffer");
  10742. b.exports = c, c.area = function(a, b, c) {
  10743. return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])
  10744. }, c.left = function(a, b, d) {
  10745. return c.area(a, b, d) > 0
  10746. }, c.leftOn = function(a, b, d) {
  10747. return c.area(a, b, d) >= 0
  10748. }, c.right = function(a, b, d) {
  10749. return c.area(a, b, d) < 0
  10750. }, c.rightOn = function(a, b, d) {
  10751. return c.area(a, b, d) <= 0
  10752. };
  10753. var d = [],
  10754. e = [];
  10755. c.collinear = function(a, b, f, g) {
  10756. if (g) {
  10757. var h = d,
  10758. i = e;
  10759. h[0] = b[0] - a[0], h[1] = b[1] - a[1], i[0] = f[0] - b[0], i[1] = f[1] - b[1];
  10760. var j = h[0] * i[0] + h[1] * i[1],
  10761. k = Math.sqrt(h[0] * h[0] + h[1] * h[1]),
  10762. l = Math.sqrt(i[0] * i[0] + i[1] * i[1]),
  10763. m = Math.acos(j / (k * l));
  10764. return g > m
  10765. }
  10766. return 0 == c.area(a, b, f)
  10767. }, c.sqdist = function(a, b) {
  10768. var c = b[0] - a[0],
  10769. d = b[1] - a[1];
  10770. return c * c + d * d
  10771. }
  10772. }, {
  10773. __browserify_Buffer: 1,
  10774. __browserify_process: 2
  10775. }],
  10776. 5: [function(a, b) {
  10777. function c() {
  10778. this.vertices = []
  10779. }
  10780. function d(a, b, c, d, e) {
  10781. e = e || 0;
  10782. var f = b[1] - a[1],
  10783. h = a[0] - b[0],
  10784. i = f * a[0] + h * a[1],
  10785. j = d[1] - c[1],
  10786. k = c[0] - d[0],
  10787. l = j * c[0] + k * c[1],
  10788. m = f * k - j * h;
  10789. return g.eq(m, 0, e) ? [0, 0] : [(k * i - h * l) / m, (f * l - j * i) / m]
  10790. }
  10791. var e = (a("__browserify_process"), a("__browserify_Buffer"), a("./Line")),
  10792. f = a("./Point"),
  10793. g = a("./Scalar");
  10794. b.exports = c, c.prototype.at = function(a) {
  10795. var b = this.vertices,
  10796. c = b.length;
  10797. return b[0 > a ? a % c + c : a % c]
  10798. }, c.prototype.first = function() {
  10799. return this.vertices[0]
  10800. }, c.prototype.last = function() {
  10801. return this.vertices[this.vertices.length - 1]
  10802. }, c.prototype.clear = function() {
  10803. this.vertices.length = 0
  10804. }, c.prototype.append = function(a, b, c) {
  10805. if ("undefined" == typeof b) throw new Error("From is not given!");
  10806. if ("undefined" == typeof c) throw new Error("To is not given!");
  10807. if (b > c - 1) throw new Error("lol1");
  10808. if (c > a.vertices.length) throw new Error("lol2");
  10809. if (0 > b) throw new Error("lol3");
  10810. for (var d = b; c > d; d++) this.vertices.push(a.vertices[d])
  10811. }, c.prototype.makeCCW = function() {
  10812. 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);
  10813. f.left(this.at(a - 1), this.at(a), this.at(a + 1)) || this.reverse()
  10814. }, c.prototype.reverse = function() {
  10815. for (var a = [], b = 0, c = this.vertices.length; b !== c; b++) a.push(this.vertices.pop());
  10816. this.vertices = a
  10817. }, c.prototype.isReflex = function(a) {
  10818. return f.right(this.at(a - 1), this.at(a), this.at(a + 1))
  10819. };
  10820. var h = [],
  10821. i = [];
  10822. c.prototype.canSee = function(a, b) {
  10823. var c, d, g = h,
  10824. j = i;
  10825. 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;
  10826. d = f.sqdist(this.at(a), this.at(b));
  10827. for (var k = 0; k !== this.vertices.length; ++k)
  10828. 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;
  10829. return !0
  10830. }, c.prototype.copy = function(a, b, d) {
  10831. var e = d || new c;
  10832. if (e.clear(), b > a)
  10833. for (var f = a; b >= f; f++) e.vertices.push(this.vertices[f]);
  10834. else {
  10835. for (var f = 0; b >= f; f++) e.vertices.push(this.vertices[f]);
  10836. for (var f = a; f < this.vertices.length; f++) e.vertices.push(this.vertices[f])
  10837. }
  10838. return e
  10839. }, c.prototype.getCutEdges = function() {
  10840. for (var a = [], b = [], d = [], e = new c, f = Number.MAX_VALUE, g = 0; g < this.vertices.length; ++g)
  10841. if (this.isReflex(g))
  10842. for (var h = 0; h < this.vertices.length; ++h)
  10843. if (this.canSee(g, h)) {
  10844. b = this.copy(g, h, e).getCutEdges(), d = this.copy(h, g, e).getCutEdges();
  10845. for (var i = 0; i < d.length; i++) b.push(d[i]);
  10846. b.length < f && (a = b, f = b.length, a.push([this.at(g), this.at(h)]))
  10847. }
  10848. return a
  10849. }, c.prototype.decomp = function() {
  10850. var a = this.getCutEdges();
  10851. return a.length > 0 ? this.slice(a) : [this]
  10852. }, c.prototype.slice = function(a) {
  10853. if (0 == a.length) return [this];
  10854. if (a instanceof Array && a.length && a[0] instanceof Array && 2 == a[0].length && a[0][0] instanceof Array) {
  10855. for (var b = [this], c = 0; c < a.length; c++)
  10856. for (var d = a[c], e = 0; e < b.length; e++) {
  10857. var f = b[e],
  10858. g = f.slice(d);
  10859. if (g) {
  10860. b.splice(e, 1), b.push(g[0], g[1]);
  10861. break
  10862. }
  10863. }
  10864. return b
  10865. }
  10866. var d = a,
  10867. c = this.vertices.indexOf(d[0]),
  10868. e = this.vertices.indexOf(d[1]);
  10869. return -1 != c && -1 != e ? [this.copy(c, e), this.copy(e, c)] : !1
  10870. }, c.prototype.isSimple = function() {
  10871. for (var a = this.vertices, b = 0; b < a.length - 1; b++)
  10872. for (var c = 0; b - 1 > c; c++)
  10873. if (e.segmentsIntersect(a[b], a[b + 1], a[c], a[c + 1])) return !1;
  10874. for (var b = 1; b < a.length - 2; b++)
  10875. if (e.segmentsIntersect(a[0], a[a.length - 1], a[b], a[b + 1])) return !1;
  10876. return !0
  10877. }, c.prototype.quickDecomp = function(a, b, e, g, h, i) {
  10878. h = h || 100, i = i || 0, g = g || 25, a = "undefined" != typeof a ? a : [], b = b || [], e = e || [];
  10879. var j = [0, 0],
  10880. k = [0, 0],
  10881. l = [0, 0],
  10882. m = 0,
  10883. n = 0,
  10884. o = 0,
  10885. p = 0,
  10886. q = 0,
  10887. r = 0,
  10888. s = 0,
  10889. t = new c,
  10890. u = new c,
  10891. v = this,
  10892. w = this.vertices;
  10893. if (w.length < 3) return a;
  10894. if (i++, i > h) return console.warn("quickDecomp: max level (" + h + ") reached."), a;
  10895. for (var x = 0; x < this.vertices.length; ++x)
  10896. if (v.isReflex(x)) {
  10897. b.push(v.vertices[x]), m = n = Number.MAX_VALUE;
  10898. 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)));
  10899. 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));
  10900. else {
  10901. if (r > q && (q += this.vertices.length), p = Number.MAX_VALUE, r > q) return a;
  10902. 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));
  10903. 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))
  10904. }
  10905. 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
  10906. }
  10907. return a.push(this), a
  10908. }, c.prototype.removeCollinearPoints = function(a) {
  10909. 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++);
  10910. return b
  10911. }
  10912. }, {
  10913. "./Line": 3,
  10914. "./Point": 4,
  10915. "./Scalar": 6,
  10916. __browserify_Buffer: 1,
  10917. __browserify_process: 2
  10918. }],
  10919. 6: [function(a, b) {
  10920. function c() {}
  10921. a("__browserify_process"), a("__browserify_Buffer");
  10922. b.exports = c, c.eq = function(a, b, c) {
  10923. return c = c || 0, Math.abs(a - b) < c
  10924. }
  10925. }, {
  10926. __browserify_Buffer: 1,
  10927. __browserify_process: 2
  10928. }],
  10929. 7: [function(a, b) {
  10930. a("__browserify_process"), a("__browserify_Buffer");
  10931. b.exports = {
  10932. Polygon: a("./Polygon"),
  10933. Point: a("./Point")
  10934. }
  10935. }, {
  10936. "./Point": 4,
  10937. "./Polygon": 5,
  10938. __browserify_Buffer: 1,
  10939. __browserify_process: 2
  10940. }],
  10941. 8: [function(a, b) {
  10942. a("__browserify_process"), a("__browserify_Buffer");
  10943. b.exports = {
  10944. name: "p2",
  10945. version: "0.6.0",
  10946. description: "A JavaScript 2D physics engine.",
  10947. author: "www.play68.com",//"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
  10948. keywords: ["p2.js", "p2", "physics", "engine", "2d"],
  10949. main: "./src/p2.js",
  10950. engines: {
  10951. node: "*"
  10952. },
  10953. repository: {
  10954. type: "git",
  10955. url: "http://www.play68.com"
  10956. },
  10957. bugs: {
  10958. url: "http://www.play68.com"
  10959. },
  10960. licenses: [{
  10961. type: "MIT"
  10962. }],
  10963. devDependencies: {
  10964. grunt: "~0.4.0",
  10965. "grunt-contrib-jshint": "~0.9.2",
  10966. "grunt-contrib-nodeunit": "~0.1.2",
  10967. "grunt-contrib-uglify": "~0.4.0",
  10968. "grunt-contrib-watch": "~0.5.0",
  10969. "grunt-browserify": "~2.0.1",
  10970. "grunt-contrib-concat": "^0.4.0"
  10971. },
  10972. dependencies: {
  10973. "poly-decomp": "0.1.0"
  10974. }
  10975. }
  10976. }, {
  10977. __browserify_Buffer: 1,
  10978. __browserify_process: 2
  10979. }],
  10980. 9: [function(a, b) {
  10981. function c(a) {
  10982. 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)
  10983. } {
  10984. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"));
  10985. a("../utils/Utils")
  10986. }
  10987. b.exports = c;
  10988. var e = d.create();
  10989. c.prototype.setFromPoints = function(a, b, c, f) {
  10990. var g = this.lowerBound,
  10991. h = this.upperBound;
  10992. "number" != typeof c && (c = 0), 0 !== c ? d.rotate(g, a[0], c) : d.copy(g, a[0]), d.copy(h, g);
  10993. for (var i = Math.cos(c), j = Math.sin(c), k = 1; k < a.length; k++) {
  10994. var l = a[k];
  10995. if (0 !== c) {
  10996. var m = l[0],
  10997. n = l[1];
  10998. e[0] = i * m - j * n, e[1] = j * m + i * n, l = e
  10999. }
  11000. for (var o = 0; 2 > o; o++) l[o] > h[o] && (h[o] = l[o]), l[o] < g[o] && (g[o] = l[o])
  11001. }
  11002. 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)
  11003. }, c.prototype.copy = function(a) {
  11004. d.copy(this.lowerBound, a.lowerBound), d.copy(this.upperBound, a.upperBound)
  11005. }, c.prototype.extend = function(a) {
  11006. for (var b = 2; b--;) {
  11007. var c = a.lowerBound[b];
  11008. this.lowerBound[b] > c && (this.lowerBound[b] = c);
  11009. var d = a.upperBound[b];
  11010. this.upperBound[b] < d && (this.upperBound[b] = d)
  11011. }
  11012. }, c.prototype.overlaps = function(a) {
  11013. var b = this.lowerBound,
  11014. c = this.upperBound,
  11015. d = a.lowerBound,
  11016. e = a.upperBound;
  11017. 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])
  11018. }
  11019. }, {
  11020. "../math/vec2": 31,
  11021. "../utils/Utils": 50,
  11022. __browserify_Buffer: 1,
  11023. __browserify_process: 2
  11024. }],
  11025. 10: [function(a, b) {
  11026. function c(a) {
  11027. this.type = a, this.result = [], this.world = null, this.boundingVolumeType = c.AABB
  11028. }
  11029. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  11030. e = a("../objects/Body");
  11031. b.exports = c, c.AABB = 1, c.BOUNDING_CIRCLE = 2, c.prototype.setWorld = function(a) {
  11032. this.world = a
  11033. }, c.prototype.getCollisionPairs = function() {
  11034. throw new Error("getCollisionPairs must be implemented in a subclass!")
  11035. };
  11036. var f = d.create();
  11037. c.boundingRadiusCheck = function(a, b) {
  11038. d.sub(f, a.position, b.position);
  11039. var c = d.squaredLength(f),
  11040. e = a.boundingRadius + b.boundingRadius;
  11041. return e * e >= c
  11042. }, c.aabbCheck = function(a, b) {
  11043. return a.getAABB().overlaps(b.getAABB())
  11044. }, c.prototype.boundingVolumeCheck = function(a, b) {
  11045. var d;
  11046. switch (this.boundingVolumeType) {
  11047. case c.BOUNDING_CIRCLE:
  11048. d = c.boundingRadiusCheck(a, b);
  11049. break;
  11050. case c.AABB:
  11051. d = c.aabbCheck(a, b);
  11052. break;
  11053. default:
  11054. throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType)
  11055. }
  11056. return d
  11057. }, c.canCollide = function(a, b) {
  11058. 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
  11059. }, c.NAIVE = 1, c.SAP = 2
  11060. }, {
  11061. "../math/vec2": 31,
  11062. "../objects/Body": 32,
  11063. __browserify_Buffer: 1,
  11064. __browserify_process: 2
  11065. }],
  11066. 11: [function(a, b) {
  11067. function c(a) {
  11068. d.apply(this), a = e.defaults(a, {
  11069. xmin: -100,
  11070. xmax: 100,
  11071. ymin: -100,
  11072. ymax: 100,
  11073. nx: 10,
  11074. ny: 10
  11075. }), 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
  11076. }
  11077. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Particle"), a("../collision/Broadphase")),
  11078. e = (a("../math/vec2"), a("../utils/Utils"));
  11079. b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
  11080. 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([]);
  11081. for (var o = f / (j - h), p = g / (k - i), n = 0; n !== e; n++)
  11082. 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++)
  11083. for (var B = x; z >= B; B++) {
  11084. var C = A,
  11085. D = B,
  11086. E = C * (g - 1) + D;
  11087. E >= 0 && m > E && l[E].push(q)
  11088. }
  11089. for (var n = 0; n !== m; n++)
  11090. for (var F = l[n], A = 0, G = F.length; A !== G; A++)
  11091. for (var q = F[A], B = 0; B !== A; B++) {
  11092. var H = F[B];
  11093. d.canCollide(q, H) && this.boundingVolumeCheck(q, H) && b.push(q, H)
  11094. }
  11095. return b
  11096. }
  11097. }, {
  11098. "../collision/Broadphase": 10,
  11099. "../math/vec2": 31,
  11100. "../shapes/Circle": 38,
  11101. "../shapes/Particle": 42,
  11102. "../shapes/Plane": 43,
  11103. "../utils/Utils": 50,
  11104. __browserify_Buffer: 1,
  11105. __browserify_process: 2
  11106. }],
  11107. 12: [function(a, b) {
  11108. function c() {
  11109. d.call(this, d.NAIVE)
  11110. } {
  11111. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Shape"), a("../shapes/Particle"), a("../collision/Broadphase"));
  11112. a("../math/vec2")
  11113. }
  11114. b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
  11115. var b = a.bodies,
  11116. c = this.result;
  11117. c.length = 0;
  11118. for (var e = 0, f = b.length; e !== f; e++)
  11119. for (var g = b[e], h = 0; e > h; h++) {
  11120. var i = b[h];
  11121. d.canCollide(g, i) && this.boundingVolumeCheck(g, i) && c.push(g, i)
  11122. }
  11123. return c
  11124. }
  11125. }, {
  11126. "../collision/Broadphase": 10,
  11127. "../math/vec2": 31,
  11128. "../shapes/Circle": 38,
  11129. "../shapes/Particle": 42,
  11130. "../shapes/Plane": 43,
  11131. "../shapes/Shape": 45,
  11132. __browserify_Buffer: 1,
  11133. __browserify_process: 2
  11134. }],
  11135. 13: [function(a, b) {
  11136. function c() {
  11137. this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, this.slipForce = 10, this.frictionCoefficient = .3, this.surfaceVelocity = 0, this.reuseObjects = !0, this.reusableContactEquations = [], this.reusableFrictionEquations = [], this.restitution = 0, this.stiffness = l.DEFAULT_STIFFNESS, this.relaxation = l.DEFAULT_RELAXATION, this.frictionStiffness = l.DEFAULT_STIFFNESS, this.frictionRelaxation = l.DEFAULT_RELAXATION, this.enableFrictionReduction = !0, this.collidingBodiesLastStep = new k, this.contactSkinSize = .01
  11138. }
  11139. function d(a, b) {
  11140. 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)
  11141. }
  11142. function e(a, b, c, d) {
  11143. for (var e = R, i = S, j = T, k = U, l = a, m = b.vertices, n = null, o = 0; o !== m.length + 1; o++) {
  11144. var p = m[o % m.length],
  11145. q = m[(o + 1) % m.length];
  11146. 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);
  11147. var r = f.crossLength(j, k);
  11148. if (null === n && (n = r), 0 >= r * n) return !1;
  11149. n = r
  11150. }
  11151. return !0
  11152. }
  11153. var f = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  11154. g = f.sub,
  11155. h = f.add,
  11156. i = f.dot,
  11157. j = a("../utils/Utils"),
  11158. k = a("../utils/TupleDictionary"),
  11159. l = a("../equations/Equation"),
  11160. m = a("../equations/ContactEquation"),
  11161. n = a("../equations/FrictionEquation"),
  11162. o = a("../shapes/Circle"),
  11163. p = a("../shapes/Convex"),
  11164. q = a("../shapes/Shape"),
  11165. r = (a("../objects/Body"), a("../shapes/Rectangle"));
  11166. b.exports = c;
  11167. var s = f.fromValues(0, 1),
  11168. t = f.fromValues(0, 0),
  11169. u = f.fromValues(0, 0),
  11170. v = f.fromValues(0, 0),
  11171. w = f.fromValues(0, 0),
  11172. x = f.fromValues(0, 0),
  11173. y = f.fromValues(0, 0),
  11174. z = f.fromValues(0, 0),
  11175. A = f.fromValues(0, 0),
  11176. B = f.fromValues(0, 0),
  11177. C = f.fromValues(0, 0),
  11178. D = f.fromValues(0, 0),
  11179. E = f.fromValues(0, 0),
  11180. F = f.fromValues(0, 0),
  11181. G = f.fromValues(0, 0),
  11182. H = f.fromValues(0, 0),
  11183. I = f.fromValues(0, 0),
  11184. J = f.fromValues(0, 0),
  11185. K = f.fromValues(0, 0),
  11186. L = [];
  11187. c.prototype.collidedLastStep = function(a, b) {
  11188. var c = 0 | a.id,
  11189. d = 0 | b.id;
  11190. return !!this.collidingBodiesLastStep.get(c, d)
  11191. }, c.prototype.reset = function() {
  11192. this.collidingBodiesLastStep.reset();
  11193. for (var a = this.contactEquations, b = a.length; b--;) {
  11194. var c = a[b],
  11195. d = c.bodyA.id,
  11196. e = c.bodyB.id;
  11197. this.collidingBodiesLastStep.set(d, e, !0)
  11198. }
  11199. if (this.reuseObjects) {
  11200. var f = this.contactEquations,
  11201. g = this.frictionEquations,
  11202. h = this.reusableFrictionEquations,
  11203. i = this.reusableContactEquations;
  11204. j.appendArray(i, f), j.appendArray(h, g)
  11205. }
  11206. this.contactEquations.length = this.frictionEquations.length = 0
  11207. }, c.prototype.createContactEquation = function(a, b, c, d) {
  11208. var e = this.reusableContactEquations.length ? this.reusableContactEquations.pop() : new m(a, b);
  11209. return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.restitution = this.restitution, e.firstImpact = !this.collidedLastStep(a, b), e.stiffness = this.stiffness, e.relaxation = this.relaxation, e.needsUpdate = !0, e.enabled = !0, e.offset = this.contactSkinSize, e
  11210. }, c.prototype.createFrictionEquation = function(a, b, c, d) {
  11211. var e = this.reusableFrictionEquations.length ? this.reusableFrictionEquations.pop() : new n(a, b);
  11212. return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.setSlipForce(this.slipForce), e.frictionCoefficient = this.frictionCoefficient, e.relativeVelocity = this.surfaceVelocity, e.enabled = !0, e.needsUpdate = !0, e.stiffness = this.frictionStiffness, e.relaxation = this.frictionRelaxation, e.contactEquations.length = 0, e
  11213. }, c.prototype.createFrictionFromContact = function(a) {
  11214. var b = this.createFrictionEquation(a.bodyA, a.bodyB, a.shapeA, a.shapeB);
  11215. return f.copy(b.contactPointA, a.contactPointA), f.copy(b.contactPointB, a.contactPointB), f.rotate90cw(b.t, a.normalA), b.contactEquations.push(a), b
  11216. }, c.prototype.createFrictionFromAverage = function(a) {
  11217. if (!a) throw new Error("numContacts == 0!"); {
  11218. var b = this.contactEquations[this.contactEquations.length - 1],
  11219. c = this.createFrictionEquation(b.bodyA, b.bodyB, b.shapeA, b.shapeB),
  11220. d = b.bodyA;
  11221. b.bodyB
  11222. }
  11223. f.set(c.contactPointA, 0, 0), f.set(c.contactPointB, 0, 0), f.set(c.t, 0, 0);
  11224. 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);
  11225. var g = 1 / a;
  11226. 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
  11227. }, c.prototype[q.LINE | q.CONVEX] = c.prototype.convexLine = function(a, b, c, d, e, f, g, h, i) {
  11228. return i ? !1 : 0
  11229. }, c.prototype[q.LINE | q.RECTANGLE] = c.prototype.lineRectangle = function(a, b, c, d, e, f, g, h, i) {
  11230. return i ? !1 : 0
  11231. };
  11232. var M = new r(1, 1),
  11233. N = f.create();
  11234. 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) {
  11235. var l = N;
  11236. f.set(l, h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  11237. var m = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  11238. f.set(l, -h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
  11239. var n = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
  11240. if (k && (m || n)) return !0;
  11241. var o = M;
  11242. d(o, h);
  11243. var p = this.convexConvex(a, b, c, e, g, o, i, j, k);
  11244. return p + m + n
  11245. }, c.prototype[q.CAPSULE | q.LINE] = c.prototype.lineCapsule = function(a, b, c, d, e, f, g, h, i) {
  11246. return i ? !1 : 0
  11247. };
  11248. var O = f.create(),
  11249. P = f.create(),
  11250. Q = new r(1, 1);
  11251. c.prototype[q.CAPSULE | q.CAPSULE] = c.prototype.capsuleCapsule = function(a, b, c, e, g, h, i, j, k) {
  11252. for (var l, m = O, n = P, o = 0, p = 0; 2 > p; p++) {
  11253. f.set(m, (0 === p ? -1 : 1) * b.length / 2, 0), f.rotate(m, m, e), f.add(m, m, c);
  11254. for (var q = 0; 2 > q; q++) {
  11255. 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);
  11256. var r = this.circleCircle(a, b, m, e, g, h, n, j, k, b.radius, h.radius);
  11257. if (this.enableFrictionReduction && (this.enableFriction = l), k && r) return !0;
  11258. o += r
  11259. }
  11260. }
  11261. this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1);
  11262. var s = Q;
  11263. d(s, b);
  11264. var t = this.convexCapsule(a, s, c, e, g, h, i, j, k);
  11265. if (this.enableFrictionReduction && (this.enableFriction = l), k && t) return !0;
  11266. if (o += t, this.enableFrictionReduction) {
  11267. var l = this.enableFriction;
  11268. this.enableFriction = !1
  11269. }
  11270. d(s, h);
  11271. var u = this.convexCapsule(g, s, i, j, a, b, c, e, k);
  11272. return this.enableFrictionReduction && (this.enableFriction = l), k && u ? !0 : (o += u, this.enableFrictionReduction && o && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(o)), o)
  11273. }, c.prototype[q.LINE | q.LINE] = c.prototype.lineLine = function(a, b, c, d, e, f, g, h, i) {
  11274. return i ? !1 : 0
  11275. }, c.prototype[q.PLANE | q.LINE] = c.prototype.planeLine = function(a, b, c, d, e, j, k, l, m) {
  11276. var n = t,
  11277. o = u,
  11278. p = v,
  11279. q = w,
  11280. r = x,
  11281. C = y,
  11282. D = z,
  11283. E = A,
  11284. F = B,
  11285. G = L,
  11286. H = 0;
  11287. 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;
  11288. for (var I = 0; I < G.length; I++) {
  11289. var J = G[I];
  11290. g(D, J, c);
  11291. var K = i(D, E);
  11292. if (0 > K) {
  11293. if (m) return !0;
  11294. var M = this.createContactEquation(a, e, b, j);
  11295. 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))
  11296. }
  11297. }
  11298. return m ? !1 : (this.enableFrictionReduction || H && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(H)), H)
  11299. }, c.prototype[q.PARTICLE | q.CAPSULE] = c.prototype.particleCapsule = function(a, b, c, d, e, f, g, h, i) {
  11300. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius, 0)
  11301. }, c.prototype[q.CIRCLE | q.LINE] = c.prototype.circleLine = function(a, b, c, d, e, j, k, l, m, n, o) {
  11302. var n = n || 0,
  11303. o = "undefined" != typeof o ? o : b.radius,
  11304. p = t,
  11305. q = u,
  11306. r = v,
  11307. s = w,
  11308. H = x,
  11309. I = y,
  11310. J = z,
  11311. K = A,
  11312. M = B,
  11313. N = C,
  11314. O = D,
  11315. P = E,
  11316. Q = F,
  11317. R = G,
  11318. S = L;
  11319. 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);
  11320. var T = i(P, H);
  11321. g(s, K, k), g(Q, c, k);
  11322. var U = o + n;
  11323. if (Math.abs(T) < U) {
  11324. 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);
  11325. var V = i(J, r),
  11326. W = i(J, K),
  11327. X = i(J, M);
  11328. if (V > W && X > V) {
  11329. if (m) return !0;
  11330. var Y = this.createContactEquation(a, e, b, j);
  11331. 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
  11332. }
  11333. }
  11334. S[0] = K, S[1] = M;
  11335. for (var Z = 0; Z < S.length; Z++) {
  11336. var $ = S[Z];
  11337. if (g(P, $, c), f.squaredLength(P) < Math.pow(U, 2)) {
  11338. if (m) return !0;
  11339. var Y = this.createContactEquation(a, e, b, j);
  11340. 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
  11341. }
  11342. }
  11343. return 0
  11344. }, c.prototype[q.CIRCLE | q.CAPSULE] = c.prototype.circleCapsule = function(a, b, c, d, e, f, g, h, i) {
  11345. return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius)
  11346. }, 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) {
  11347. 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++) {
  11348. var O = M[N % M.length],
  11349. P = M[(N + 1) % M.length];
  11350. 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)) {
  11351. f.sub(E, o, B);
  11352. var Q = Math.abs(f.dot(E, s));
  11353. L > Q && (f.copy(J, B), L = Q, f.scale(A, s, Q), f.add(A, A, B), K = !0)
  11354. }
  11355. }
  11356. if (K) {
  11357. if (m) return !0;
  11358. var R = this.createContactEquation(a, i, b, j);
  11359. 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
  11360. }
  11361. if (n > 0)
  11362. for (var N = 0; N < M.length; N++) {
  11363. var S = M[N];
  11364. if (f.rotate(z, S, l), h(z, z, k), g(y, z, c), f.squaredLength(y) < Math.pow(n, 2)) {
  11365. if (m) return !0;
  11366. var R = this.createContactEquation(a, i, b, j);
  11367. 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
  11368. }
  11369. }
  11370. return 0
  11371. };
  11372. var R = f.create(),
  11373. S = f.create(),
  11374. T = f.create(),
  11375. U = f.create();
  11376. 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) {
  11377. var o = t,
  11378. p = u,
  11379. q = v,
  11380. r = w,
  11381. s = x,
  11382. A = y,
  11383. B = z,
  11384. D = C,
  11385. E = F,
  11386. G = J,
  11387. H = K,
  11388. I = Number.MAX_VALUE,
  11389. L = !1,
  11390. M = k.vertices;
  11391. if (!e(c, k, l, m)) return 0;
  11392. if (n) return !0;
  11393. for (var N = 0; N !== M.length + 1; N++) {
  11394. var O = M[N % M.length],
  11395. P = M[(N + 1) % M.length];
  11396. 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); {
  11397. i(D, s)
  11398. }
  11399. g(A, o, l), g(B, c, l), f.sub(G, o, c);
  11400. var Q = Math.abs(f.dot(G, s));
  11401. I > Q && (I = Q, f.scale(E, s, Q), f.add(E, E, c), f.copy(H, s), L = !0)
  11402. }
  11403. if (L) {
  11404. var R = this.createContactEquation(a, j, b, k);
  11405. 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
  11406. }
  11407. return 0
  11408. }, c.prototype[q.CIRCLE] = c.prototype.circleCircle = function(a, b, c, d, e, i, j, k, l, m, n) {
  11409. var o = t,
  11410. m = m || b.radius,
  11411. n = n || i.radius;
  11412. g(o, c, j);
  11413. var p = m + n;
  11414. if (f.squaredLength(o) > Math.pow(p, 2)) return 0;
  11415. if (l) return !0;
  11416. var q = this.createContactEquation(a, e, b, i);
  11417. 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
  11418. }, 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) {
  11419. var n = t,
  11420. o = u,
  11421. p = v,
  11422. q = 0;
  11423. f.rotate(o, s, d);
  11424. for (var r = 0; r !== j.vertices.length; r++) {
  11425. var w = j.vertices[r];
  11426. if (f.rotate(n, w, l), h(n, n, k), g(p, n, c), i(p, o) <= 0) {
  11427. if (m) return !0;
  11428. q++;
  11429. var x = this.createContactEquation(a, e, b, j);
  11430. g(p, n, c), f.copy(x.normalA, o);
  11431. var y = i(p, x.normalA);
  11432. 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))
  11433. }
  11434. }
  11435. return this.enableFrictionReduction && this.enableFriction && q && this.frictionEquations.push(this.createFrictionFromAverage(q)), q
  11436. }, c.prototype[q.PARTICLE | q.PLANE] = c.prototype.particlePlane = function(a, b, c, d, e, h, j, k, l) {
  11437. var m = t,
  11438. n = u;
  11439. k = k || 0, g(m, c, j), f.rotate(n, s, k);
  11440. var o = i(m, n);
  11441. if (o > 0) return 0;
  11442. if (l) return !0;
  11443. var p = this.createContactEquation(e, a, h, b);
  11444. 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
  11445. }, c.prototype[q.CIRCLE | q.PARTICLE] = c.prototype.circleParticle = function(a, b, c, d, e, i, j, k, l) {
  11446. var m = t;
  11447. if (g(m, j, c), f.squaredLength(m) > Math.pow(b.radius, 2)) return 0;
  11448. if (l) return !0;
  11449. var n = this.createContactEquation(a, e, b, i);
  11450. 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
  11451. }; {
  11452. var V = new o(1),
  11453. W = f.create(),
  11454. X = f.create();
  11455. f.create()
  11456. }
  11457. c.prototype[q.PLANE | q.CAPSULE] = c.prototype.planeCapsule = function(a, b, c, d, e, g, i, j, k) {
  11458. var l = W,
  11459. m = X,
  11460. n = V;
  11461. 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;
  11462. var o;
  11463. this.enableFrictionReduction && (o = this.enableFriction, this.enableFriction = !1);
  11464. var p = this.circlePlane(e, n, l, 0, a, b, c, d, k),
  11465. q = this.circlePlane(e, n, m, 0, a, b, c, d, k);
  11466. if (this.enableFrictionReduction && (this.enableFriction = o), k) return p || q;
  11467. var r = p + q;
  11468. return this.enableFrictionReduction && r && this.frictionEquations.push(this.createFrictionFromAverage(r)), r
  11469. }, c.prototype[q.CIRCLE | q.PLANE] = c.prototype.circlePlane = function(a, b, c, d, e, j, k, l, m) {
  11470. var n = a,
  11471. o = b,
  11472. p = c,
  11473. q = e,
  11474. r = k,
  11475. w = l;
  11476. w = w || 0;
  11477. var x = t,
  11478. y = u,
  11479. z = v;
  11480. g(x, p, r), f.rotate(y, s, w);
  11481. var A = i(y, x);
  11482. if (A > o.radius) return 0;
  11483. if (m) return !0;
  11484. var B = this.createContactEquation(q, n, j, b);
  11485. 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
  11486. }, 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) {
  11487. var p = t,
  11488. q = u,
  11489. r = v,
  11490. s = w,
  11491. y = x,
  11492. C = z,
  11493. D = A,
  11494. E = B,
  11495. F = 0,
  11496. o = "number" == typeof o ? o : 0,
  11497. G = c.findSeparatingAxis(b, d, e, k, l, m, p);
  11498. if (!G) return 0;
  11499. g(D, l, d), i(p, D) > 0 && f.scale(p, p, -1);
  11500. var H = c.getClosestEdge(b, e, p, !0),
  11501. I = c.getClosestEdge(k, m, p);
  11502. if (-1 === H || -1 === I) return 0;
  11503. for (var J = 0; 2 > J; J++) {
  11504. var K = H,
  11505. L = I,
  11506. M = b,
  11507. N = k,
  11508. O = d,
  11509. P = l,
  11510. Q = e,
  11511. R = m,
  11512. S = a,
  11513. T = j;
  11514. if (0 === J) {
  11515. var U;
  11516. 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
  11517. }
  11518. for (var V = L; L + 2 > V; V++) {
  11519. var W = N.vertices[(V + N.vertices.length) % N.vertices.length];
  11520. f.rotate(q, W, R), h(q, q, P);
  11521. for (var X = 0, Y = K - 1; K + 2 > Y; Y++) {
  11522. var Z = M.vertices[(Y + M.vertices.length) % M.vertices.length],
  11523. $ = M.vertices[(Y + 1 + M.vertices.length) % M.vertices.length];
  11524. 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);
  11525. var _ = i(E, D);
  11526. (Y === K && o >= _ || Y !== K && 0 >= _) && X++
  11527. }
  11528. if (X >= 3) {
  11529. if (n) return !0;
  11530. var ab = this.createContactEquation(S, T, M, N);
  11531. F++;
  11532. var Z = M.vertices[K % M.vertices.length],
  11533. $ = M.vertices[(K + 1) % M.vertices.length];
  11534. 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);
  11535. var _ = i(ab.normalA, D);
  11536. 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))
  11537. }
  11538. }
  11539. }
  11540. return this.enableFrictionReduction && this.enableFriction && F && this.frictionEquations.push(this.createFrictionFromAverage(F)), F
  11541. };
  11542. var Y = f.fromValues(0, 0);
  11543. c.projectConvexOntoAxis = function(a, b, c, d, e) {
  11544. var g, h, j = null,
  11545. k = null,
  11546. l = Y;
  11547. f.rotate(l, d, -c);
  11548. 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);
  11549. if (k > j) {
  11550. var n = k;
  11551. k = j, j = n
  11552. }
  11553. var o = i(b, d);
  11554. f.set(e, k + o, j + o)
  11555. };
  11556. var Z = f.fromValues(0, 0),
  11557. $ = f.fromValues(0, 0),
  11558. _ = f.fromValues(0, 0),
  11559. ab = f.fromValues(0, 0),
  11560. bb = f.fromValues(0, 0),
  11561. cb = f.fromValues(0, 0);
  11562. c.findSeparatingAxis = function(a, b, d, e, h, i, j) {
  11563. var k = null,
  11564. l = !1,
  11565. m = !1,
  11566. n = Z,
  11567. o = $,
  11568. p = _,
  11569. q = ab,
  11570. s = bb,
  11571. t = cb;
  11572. if (a instanceof r && e instanceof r)
  11573. for (var u = 0; 2 !== u; u++) {
  11574. var v = a,
  11575. w = d;
  11576. 1 === u && (v = e, w = i);
  11577. for (var x = 0; 2 !== x; x++) {
  11578. 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);
  11579. var y = s,
  11580. z = t,
  11581. A = !1;
  11582. s[0] > t[0] && (z = s, y = t, A = !0);
  11583. var B = z[0] - y[1];
  11584. l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
  11585. }
  11586. } else
  11587. for (var u = 0; 2 !== u; u++) {
  11588. var v = a,
  11589. w = d;
  11590. 1 === u && (v = e, w = i);
  11591. for (var x = 0; x !== v.vertices.length; x++) {
  11592. 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);
  11593. var y = s,
  11594. z = t,
  11595. A = !1;
  11596. s[0] > t[0] && (z = s, y = t, A = !0);
  11597. var B = z[0] - y[1];
  11598. l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
  11599. }
  11600. }
  11601. return m
  11602. };
  11603. var db = f.fromValues(0, 0),
  11604. eb = f.fromValues(0, 0),
  11605. fb = f.fromValues(0, 0);
  11606. c.getClosestEdge = function(a, b, c, d) {
  11607. var e = db,
  11608. h = eb,
  11609. j = fb;
  11610. f.rotate(e, c, -b), d && f.scale(e, e, -1);
  11611. for (var k = -1, l = a.vertices.length, m = -1, n = 0; n !== l; n++) {
  11612. g(h, a.vertices[(n + 1) % l], a.vertices[n % l]), f.rotate90cw(j, h), f.normalize(j, j);
  11613. var o = i(j, e);
  11614. (-1 === k || o > m) && (k = n % l, m = o)
  11615. }
  11616. return k
  11617. };
  11618. var gb = f.create(),
  11619. hb = f.create(),
  11620. ib = f.create(),
  11621. jb = f.create(),
  11622. kb = f.create(),
  11623. lb = f.create(),
  11624. mb = f.create();
  11625. c.prototype[q.CIRCLE | q.HEIGHTFIELD] = c.prototype.circleHeightfield = function(a, b, c, d, e, i, j, k, l, m) {
  11626. var n = i.data,
  11627. m = m || b.radius,
  11628. o = i.elementWidth,
  11629. p = hb,
  11630. q = gb,
  11631. r = kb,
  11632. s = mb,
  11633. t = lb,
  11634. u = ib,
  11635. v = jb,
  11636. w = Math.floor((c[0] - m - j[0]) / o),
  11637. x = Math.ceil((c[0] + m - j[0]) / o);
  11638. 0 > w && (w = 0), x >= n.length && (x = n.length - 1);
  11639. 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]);
  11640. if (c[1] - m > y) return l ? !1 : 0;
  11641. for (var B = !1, A = w; x > A; A++) {
  11642. 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);
  11643. var C = f.dot(p, t);
  11644. if (q[0] >= u[0] && q[0] < v[0] && 0 >= C) {
  11645. if (l) return !0;
  11646. B = !0, f.scale(p, t, -C), f.add(r, q, p), f.copy(s, t);
  11647. var D = this.createContactEquation(e, a, i, b);
  11648. 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))
  11649. }
  11650. }
  11651. if (B = !1, m > 0)
  11652. for (var A = w; x >= A; A++)
  11653. 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)) {
  11654. if (l) return !0;
  11655. B = !0;
  11656. var D = this.createContactEquation(e, a, i, b);
  11657. 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))
  11658. }
  11659. return B ? 1 : 0
  11660. };
  11661. var nb = f.create(),
  11662. ob = f.create(),
  11663. pb = f.create(),
  11664. qb = new p([f.create(), f.create(), f.create(), f.create()]);
  11665. 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) {
  11666. var k = g.data,
  11667. l = g.elementWidth,
  11668. m = nb,
  11669. n = ob,
  11670. o = pb,
  11671. p = qb,
  11672. q = Math.floor((a.aabb.lowerBound[0] - h[0]) / l),
  11673. r = Math.ceil((a.aabb.upperBound[0] - h[0]) / l);
  11674. 0 > q && (q = 0), r >= k.length && (r = k.length - 1);
  11675. 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]);
  11676. if (a.aabb.lowerBound[1] > s) return j ? !1 : 0;
  11677. for (var v = 0, u = q; r > u; u++) {
  11678. 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);
  11679. var w = 100;
  11680. 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)
  11681. }
  11682. return v
  11683. }
  11684. }, {
  11685. "../equations/ContactEquation": 22,
  11686. "../equations/Equation": 23,
  11687. "../equations/FrictionEquation": 24,
  11688. "../math/vec2": 31,
  11689. "../objects/Body": 32,
  11690. "../shapes/Circle": 38,
  11691. "../shapes/Convex": 39,
  11692. "../shapes/Rectangle": 44,
  11693. "../shapes/Shape": 45,
  11694. "../utils/TupleDictionary": 49,
  11695. "../utils/Utils": 50,
  11696. __browserify_Buffer: 1,
  11697. __browserify_process: 2
  11698. }],
  11699. 14: [function(a, b) {
  11700. function c() {
  11701. e.call(this, e.SAP), this.axisList = [], this.axisIndex = 0;
  11702. var a = this;
  11703. this._addBodyHandler = function(b) {
  11704. a.axisList.push(b.body)
  11705. }, this._removeBodyHandler = function(b) {
  11706. var c = a.axisList.indexOf(b.body); - 1 !== c && a.axisList.splice(c, 1)
  11707. }
  11708. }
  11709. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../utils/Utils")),
  11710. e = a("../collision/Broadphase");
  11711. b.exports = c, c.prototype = new e, c.prototype.setWorld = function(a) {
  11712. 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
  11713. }, c.sortAxisList = function(a, b) {
  11714. b = 0 | b;
  11715. for (var c = 1, d = a.length; d > c; c++) {
  11716. 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];
  11717. a[f + 1] = e
  11718. }
  11719. return a
  11720. }, c.prototype.getCollisionPairs = function() {
  11721. var a = this.axisList,
  11722. b = this.result,
  11723. d = this.axisIndex;
  11724. b.length = 0;
  11725. for (var f = a.length; f--;) {
  11726. var g = a[f];
  11727. g.aabbNeedsUpdate && g.updateAABB()
  11728. }
  11729. c.sortAxisList(a, d);
  11730. for (var h = 0, i = 0 | a.length; h !== i; h++)
  11731. for (var j = a[h], k = h + 1; i > k; k++) {
  11732. var l = a[k],
  11733. m = l.aabb.lowerBound[d] <= j.aabb.upperBound[d];
  11734. if (!m) break;
  11735. e.canCollide(j, l) && this.boundingVolumeCheck(j, l) && b.push(j, l)
  11736. }
  11737. return b
  11738. }
  11739. }, {
  11740. "../collision/Broadphase": 10,
  11741. "../utils/Utils": 50,
  11742. __browserify_Buffer: 1,
  11743. __browserify_process: 2
  11744. }],
  11745. 15: [function(a, b) {
  11746. function c(a, b, c, e) {
  11747. this.type = c, e = d.defaults(e, {
  11748. collideConnected: !0,
  11749. wakeUpBodies: !0
  11750. }), this.equations = [], this.bodyA = a, this.bodyB = b, this.collideConnected = e.collideConnected, e.wakeUpBodies && (a && a.wakeUp(), b && b.wakeUp())
  11751. }
  11752. a("__browserify_process"), a("__browserify_Buffer");
  11753. b.exports = c;
  11754. var d = a("../utils/Utils");
  11755. c.prototype.update = function() {
  11756. throw new Error("method update() not implmemented in this Constraint subclass!")
  11757. }, c.DISTANCE = 1, c.GEAR = 2, c.LOCK = 3, c.PRISMATIC = 4, c.REVOLUTE = 5, c.prototype.setStiffness = function(a) {
  11758. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11759. var d = b[c];
  11760. d.stiffness = a, d.needsUpdate = !0
  11761. }
  11762. }, c.prototype.setRelaxation = function(a) {
  11763. for (var b = this.equations, c = 0; c !== b.length; c++) {
  11764. var d = b[c];
  11765. d.relaxation = a, d.needsUpdate = !0
  11766. }
  11767. }
  11768. }, {
  11769. "../utils/Utils": 50,
  11770. __browserify_Buffer: 1,
  11771. __browserify_process: 2
  11772. }],
  11773. 16: [function(a, b) {
  11774. function c(a, b, c) {
  11775. c = g.defaults(c, {
  11776. localAnchorA: [0, 0],
  11777. localAnchorB: [0, 0]
  11778. }), 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]);
  11779. var h = this.localAnchorA,
  11780. i = this.localAnchorB;
  11781. if (this.distance = 0, "number" == typeof c.distance) this.distance = c.distance;
  11782. else {
  11783. var j = f.create(),
  11784. k = f.create(),
  11785. l = f.create();
  11786. 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)
  11787. }
  11788. var m;
  11789. m = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce;
  11790. var n = new e(a, b, -m, m);
  11791. this.equations = [n], this.maxForce = m;
  11792. var l = f.create(),
  11793. o = f.create(),
  11794. p = f.create(),
  11795. q = this;
  11796. n.computeGq = function() {
  11797. var a = this.bodyA,
  11798. b = this.bodyB,
  11799. c = a.position,
  11800. d = b.position;
  11801. 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
  11802. }, this.setMaxForce(m), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, this.lowerLimit = 0, this.position = 0
  11803. }
  11804. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
  11805. e = a("../equations/Equation"),
  11806. f = a("../math/vec2"),
  11807. g = a("../utils/Utils");
  11808. b.exports = c, c.prototype = new d;
  11809. var h = f.create(),
  11810. i = f.create(),
  11811. j = f.create();
  11812. c.prototype.update = function() {
  11813. var a = this.equations[0],
  11814. b = this.bodyA,
  11815. c = this.bodyB,
  11816. d = (this.distance, b.position),
  11817. e = c.position,
  11818. g = this.equations[0],
  11819. k = a.G;
  11820. 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);
  11821. var l = !1;
  11822. 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);
  11823. g.enabled = !0, f.normalize(h, h);
  11824. var m = f.crossLength(i, h),
  11825. n = f.crossLength(j, h);
  11826. k[0] = -h[0], k[1] = -h[1], k[2] = -m, k[3] = h[0], k[4] = h[1], k[5] = n
  11827. }, c.prototype.setMaxForce = function(a) {
  11828. var b = this.equations[0];
  11829. b.minForce = -a, b.maxForce = a
  11830. }, c.prototype.getMaxForce = function() {
  11831. var a = this.equations[0];
  11832. return a.maxForce
  11833. }
  11834. }, {
  11835. "../equations/Equation": 23,
  11836. "../math/vec2": 31,
  11837. "../utils/Utils": 50,
  11838. "./Constraint": 15,
  11839. __browserify_Buffer: 1,
  11840. __browserify_process: 2
  11841. }],
  11842. 17: [function(a, b) {
  11843. function c(a, b, c) {
  11844. 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)
  11845. } {
  11846. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
  11847. e = (a("../equations/Equation"), a("../equations/AngleLockEquation"));
  11848. a("../math/vec2")
  11849. }
  11850. b.exports = c, c.prototype = new d, c.prototype.update = function() {
  11851. var a = this.equations[0];
  11852. a.ratio !== this.ratio && a.setRatio(this.ratio), a.angle = this.angle
  11853. }, c.prototype.setMaxTorque = function(a) {
  11854. this.equations[0].setMaxTorque(a)
  11855. }, c.prototype.getMaxTorque = function() {
  11856. return this.equations[0].maxForce
  11857. }
  11858. }, {
  11859. "../equations/AngleLockEquation": 21,
  11860. "../equations/Equation": 23,
  11861. "../math/vec2": 31,
  11862. "./Constraint": 15,
  11863. __browserify_Buffer: 1,
  11864. __browserify_process: 2
  11865. }],
  11866. 18: [function(a, b) {
  11867. function c(a, b, c) {
  11868. c = c || {}, d.call(this, a, b, d.LOCK, c);
  11869. var g = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce,
  11870. h = (c.localAngleB || 0, new f(a, b, -g, g)),
  11871. i = new f(a, b, -g, g),
  11872. j = new f(a, b, -g, g),
  11873. k = e.create(),
  11874. l = e.create(),
  11875. m = this;
  11876. h.computeGq = function() {
  11877. return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[0]
  11878. }, i.computeGq = function() {
  11879. return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[1]
  11880. };
  11881. var n = e.create(),
  11882. o = e.create();
  11883. j.computeGq = function() {
  11884. 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)
  11885. }, 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)
  11886. }
  11887. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
  11888. e = a("../math/vec2"),
  11889. f = a("../equations/Equation");
  11890. b.exports = c, c.prototype = new d, c.prototype.setMaxForce = function(a) {
  11891. for (var b = this.equations, c = 0; c < this.equations.length; c++) b[c].maxForce = a, b[c].minForce = -a
  11892. }, c.prototype.getMaxForce = function() {
  11893. return this.equations[0].maxForce
  11894. };
  11895. var g = e.create(),
  11896. h = e.create(),
  11897. i = e.create(),
  11898. j = e.fromValues(1, 0),
  11899. k = e.fromValues(0, 1);
  11900. c.prototype.update = function() {
  11901. var a = this.equations[0],
  11902. b = this.equations[1],
  11903. c = this.equations[2],
  11904. d = this.bodyA,
  11905. f = this.bodyB;
  11906. 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)
  11907. }
  11908. }, {
  11909. "../equations/Equation": 23,
  11910. "../math/vec2": 31,
  11911. "./Constraint": 15,
  11912. __browserify_Buffer: 1,
  11913. __browserify_process: 2
  11914. }],
  11915. 19: [function(a, b) {
  11916. function c(a, b, c) {
  11917. c = c || {}, d.call(this, a, b, d.PRISMATIC, c);
  11918. var i = g.fromValues(0, 0),
  11919. j = g.fromValues(1, 0),
  11920. k = g.fromValues(0, 0);
  11921. 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;
  11922. var l = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE,
  11923. m = new f(a, b, -l, l),
  11924. n = new g.create,
  11925. o = new g.create,
  11926. p = new g.create,
  11927. q = new g.create;
  11928. if (m.computeGq = function() {
  11929. return g.dot(p, q)
  11930. }, m.updateJacobian = function() {
  11931. var c = this.G,
  11932. d = a.position,
  11933. e = b.position;
  11934. 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)
  11935. }, this.equations.push(m), !c.disableRotationalLock) {
  11936. var r = new h(a, b, -l, l);
  11937. this.equations.push(r)
  11938. }
  11939. 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; {
  11940. var s = this,
  11941. t = this.motorEquation;
  11942. t.computeGW
  11943. }
  11944. t.computeGq = function() {
  11945. return 0
  11946. }, t.computeGW = function() {
  11947. var a = this.G,
  11948. b = this.bodyA,
  11949. c = this.bodyB,
  11950. d = b.velocity,
  11951. e = c.velocity,
  11952. f = b.angularVelocity,
  11953. g = c.angularVelocity;
  11954. return this.gmult(a, d, f, e, g) + s.motorSpeed
  11955. }
  11956. }
  11957. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
  11958. e = a("../equations/ContactEquation"),
  11959. f = a("../equations/Equation"),
  11960. g = a("../math/vec2"),
  11961. h = a("../equations/RotationalLockEquation");
  11962. b.exports = c, c.prototype = new d;
  11963. var i = g.create(),
  11964. j = g.create(),
  11965. k = g.create(),
  11966. l = g.create(),
  11967. m = g.create(),
  11968. n = g.create();
  11969. c.prototype.update = function() {
  11970. var a = this.equations,
  11971. b = a[0],
  11972. c = this.upperLimit,
  11973. d = this.lowerLimit,
  11974. e = this.upperLimitEquation,
  11975. f = this.lowerLimitEquation,
  11976. h = this.bodyA,
  11977. o = this.bodyB,
  11978. p = this.localAxisA,
  11979. q = this.localAnchorA,
  11980. r = this.localAnchorB;
  11981. 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);
  11982. var s = this.position = g.dot(k, i) - g.dot(j, i);
  11983. if (this.motorEnabled) {
  11984. var t = this.motorEquation.G;
  11985. 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)
  11986. }
  11987. 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);
  11988. else {
  11989. var u = a.indexOf(e); - 1 !== u && a.splice(u, 1)
  11990. }
  11991. 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);
  11992. else {
  11993. var u = a.indexOf(f); - 1 !== u && a.splice(u, 1)
  11994. }
  11995. }, c.prototype.enableMotor = function() {
  11996. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  11997. }, c.prototype.disableMotor = function() {
  11998. if (this.motorEnabled) {
  11999. var a = this.equations.indexOf(this.motorEquation);
  12000. this.equations.splice(a, 1), this.motorEnabled = !1
  12001. }
  12002. }, c.prototype.setLimits = function(a, b) {
  12003. "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)
  12004. }
  12005. }, {
  12006. "../equations/ContactEquation": 22,
  12007. "../equations/Equation": 23,
  12008. "../equations/RotationalLockEquation": 25,
  12009. "../math/vec2": 31,
  12010. "./Constraint": 15,
  12011. __browserify_Buffer: 1,
  12012. __browserify_process: 2
  12013. }],
  12014. 20: [function(a, b) {
  12015. function c(a, b, c) {
  12016. c = c || {}, d.call(this, a, b, d.REVOLUTE, c);
  12017. var n = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE;
  12018. 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));
  12019. var o = this.equations = [new e(a, b, -n, n), new e(a, b, -n, n)],
  12020. p = o[0],
  12021. q = o[1],
  12022. r = this;
  12023. p.computeGq = function() {
  12024. 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)
  12025. }, q.computeGq = function() {
  12026. 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)
  12027. }, 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
  12028. }
  12029. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
  12030. e = a("../equations/Equation"),
  12031. f = a("../equations/RotationalVelocityEquation"),
  12032. g = a("../equations/RotationalLockEquation"),
  12033. h = a("../math/vec2");
  12034. b.exports = c;
  12035. var i = h.create(),
  12036. j = h.create(),
  12037. k = h.fromValues(1, 0),
  12038. l = h.fromValues(0, 1),
  12039. m = h.create();
  12040. c.prototype = new d, c.prototype.setLimits = function(a, b) {
  12041. "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)
  12042. }, c.prototype.update = function() {
  12043. var a = this.bodyA,
  12044. b = this.bodyB,
  12045. c = this.pivotA,
  12046. d = this.pivotB,
  12047. e = this.equations,
  12048. f = (e[0], e[1], e[0]),
  12049. g = e[1],
  12050. m = this.upperLimit,
  12051. n = this.lowerLimit,
  12052. o = this.upperLimitEquation,
  12053. p = this.lowerLimitEquation,
  12054. q = this.angle = b.angle - a.angle;
  12055. if (this.upperLimitEnabled && q > m) o.angle = m, -1 === e.indexOf(o) && e.push(o);
  12056. else {
  12057. var r = e.indexOf(o); - 1 !== r && e.splice(r, 1)
  12058. }
  12059. if (this.lowerLimitEnabled && n > q) p.angle = n, -1 === e.indexOf(p) && e.push(p);
  12060. else {
  12061. var r = e.indexOf(p); - 1 !== r && e.splice(r, 1)
  12062. }
  12063. 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)
  12064. }, c.prototype.enableMotor = function() {
  12065. this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
  12066. }, c.prototype.disableMotor = function() {
  12067. if (this.motorEnabled) {
  12068. var a = this.equations.indexOf(this.motorEquation);
  12069. this.equations.splice(a, 1), this.motorEnabled = !1
  12070. }
  12071. }, c.prototype.motorIsEnabled = function() {
  12072. return !!this.motorEnabled
  12073. }, c.prototype.setMotorSpeed = function(a) {
  12074. if (this.motorEnabled) {
  12075. var b = this.equations.indexOf(this.motorEquation);
  12076. this.equations[b].relativeVelocity = a
  12077. }
  12078. }, c.prototype.getMotorSpeed = function() {
  12079. return this.motorEnabled ? this.motorEquation.relativeVelocity : !1
  12080. }
  12081. }, {
  12082. "../equations/Equation": 23,
  12083. "../equations/RotationalLockEquation": 25,
  12084. "../equations/RotationalVelocityEquation": 26,
  12085. "../math/vec2": 31,
  12086. "./Constraint": 15,
  12087. __browserify_Buffer: 1,
  12088. __browserify_process: 2
  12089. }],
  12090. 21: [function(a, b) {
  12091. function c(a, b, c) {
  12092. 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)
  12093. } {
  12094. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation"));
  12095. a("../math/vec2")
  12096. }
  12097. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeGq = function() {
  12098. return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle
  12099. }, c.prototype.setRatio = function(a) {
  12100. var b = this.G;
  12101. b[2] = a, b[5] = -1, this.ratio = a
  12102. }, c.prototype.setMaxTorque = function(a) {
  12103. this.maxForce = a, this.minForce = -a
  12104. }
  12105. }, {
  12106. "../math/vec2": 31,
  12107. "./Equation": 23,
  12108. __browserify_Buffer: 1,
  12109. __browserify_process: 2
  12110. }],
  12111. 22: [function(a, b) {
  12112. function c(a, b) {
  12113. 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
  12114. }
  12115. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation")),
  12116. e = a("../math/vec2");
  12117. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  12118. var d = this.bodyA,
  12119. f = this.bodyB,
  12120. g = this.contactPointA,
  12121. h = this.contactPointB,
  12122. i = d.position,
  12123. j = f.position,
  12124. k = this.penetrationVec,
  12125. l = this.normalA,
  12126. m = this.G,
  12127. n = e.crossLength(g, l),
  12128. o = e.crossLength(h, l);
  12129. 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);
  12130. var p, q;
  12131. 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());
  12132. var r = this.computeGiMf(),
  12133. s = -q * a - p * b - c * r;
  12134. return s
  12135. }
  12136. }, {
  12137. "../math/vec2": 31,
  12138. "./Equation": 23,
  12139. __browserify_Buffer: 1,
  12140. __browserify_process: 2
  12141. }],
  12142. 23: [function(a, b) {
  12143. function c(a, b, d, f) {
  12144. 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);
  12145. for (var g = 0; 6 > g; g++) this.G[g] = 0;
  12146. 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
  12147. }
  12148. a("__browserify_process"), a("__browserify_Buffer");
  12149. b.exports = c; {
  12150. var d = a("../math/vec2"),
  12151. e = a("../utils/Utils");
  12152. a("../objects/Body")
  12153. }
  12154. c.prototype.constructor = c, c.DEFAULT_STIFFNESS = 1e6, c.DEFAULT_RELAXATION = 4, c.prototype.update = function() {
  12155. var a = this.stiffness,
  12156. b = this.relaxation,
  12157. c = this.timeStep;
  12158. 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
  12159. }, c.prototype.gmult = function(a, b, c, d, e) {
  12160. return a[0] * b[0] + a[1] * b[1] + a[2] * c + a[3] * d[0] + a[4] * d[1] + a[5] * e
  12161. }, c.prototype.computeB = function(a, b, c) {
  12162. var d = this.computeGW(),
  12163. e = this.computeGq(),
  12164. f = this.computeGiMf();
  12165. return -e * a - d * b - f * c
  12166. };
  12167. var f = d.create(),
  12168. g = d.create();
  12169. c.prototype.computeGq = function() {
  12170. var a = this.G,
  12171. b = this.bodyA,
  12172. c = this.bodyB,
  12173. d = (b.position, c.position, b.angle),
  12174. e = c.angle;
  12175. return this.gmult(a, f, d, g, e) + this.offset
  12176. }, c.prototype.computeGW = function() {
  12177. var a = this.G,
  12178. b = this.bodyA,
  12179. c = this.bodyB,
  12180. d = b.velocity,
  12181. e = c.velocity,
  12182. f = b.angularVelocity,
  12183. g = c.angularVelocity;
  12184. return this.gmult(a, d, f, e, g) + this.relativeVelocity
  12185. }, c.prototype.computeGWlambda = function() {
  12186. var a = this.G,
  12187. b = this.bodyA,
  12188. c = this.bodyB,
  12189. d = b.vlambda,
  12190. e = c.vlambda,
  12191. f = b.wlambda,
  12192. g = c.wlambda;
  12193. return this.gmult(a, d, f, e, g)
  12194. };
  12195. var h = d.create(),
  12196. i = d.create();
  12197. c.prototype.computeGiMf = function() {
  12198. var a = this.bodyA,
  12199. b = this.bodyB,
  12200. c = a.force,
  12201. e = a.angularForce,
  12202. f = b.force,
  12203. g = b.angularForce,
  12204. j = a.invMassSolve,
  12205. k = b.invMassSolve,
  12206. l = a.invInertiaSolve,
  12207. m = b.invInertiaSolve,
  12208. n = this.G;
  12209. return d.scale(h, c, j), d.scale(i, f, k), this.gmult(n, h, e * l, i, g * m)
  12210. }, c.prototype.computeGiMGt = function() {
  12211. var a = this.bodyA,
  12212. b = this.bodyB,
  12213. c = a.invMassSolve,
  12214. d = b.invMassSolve,
  12215. e = a.invInertiaSolve,
  12216. f = b.invInertiaSolve,
  12217. g = this.G;
  12218. 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
  12219. }; {
  12220. var j = d.create(),
  12221. k = d.create(),
  12222. l = d.create();
  12223. d.create(), d.create(), d.create()
  12224. }
  12225. c.prototype.addToWlambda = function(a) {
  12226. var b = this.bodyA,
  12227. c = this.bodyB,
  12228. e = j,
  12229. f = k,
  12230. g = l,
  12231. h = b.invMassSolve,
  12232. i = c.invMassSolve,
  12233. m = b.invInertiaSolve,
  12234. n = c.invInertiaSolve,
  12235. o = this.G;
  12236. 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
  12237. }, c.prototype.computeInvC = function(a) {
  12238. return 1 / (this.computeGiMGt() + a)
  12239. }
  12240. }, {
  12241. "../math/vec2": 31,
  12242. "../objects/Body": 32,
  12243. "../utils/Utils": 50,
  12244. __browserify_Buffer: 1,
  12245. __browserify_process: 2
  12246. }],
  12247. 24: [function(a, b) {
  12248. function c(a, b, c) {
  12249. 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
  12250. } {
  12251. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  12252. e = a("./Equation");
  12253. a("../utils/Utils")
  12254. }
  12255. b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setSlipForce = function(a) {
  12256. this.maxForce = a, this.minForce = -a
  12257. }, c.prototype.getSlipForce = function() {
  12258. return this.maxForce
  12259. }, c.prototype.computeB = function(a, b, c) {
  12260. var e = (this.bodyA, this.bodyB, this.contactPointA),
  12261. f = this.contactPointB,
  12262. g = this.t,
  12263. h = this.G;
  12264. 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);
  12265. var i = this.computeGW(),
  12266. j = this.computeGiMf(),
  12267. k = -i * b - c * j;
  12268. return k
  12269. }
  12270. }, {
  12271. "../math/vec2": 31,
  12272. "../utils/Utils": 50,
  12273. "./Equation": 23,
  12274. __browserify_Buffer: 1,
  12275. __browserify_process: 2
  12276. }],
  12277. 25: [function(a, b) {
  12278. function c(a, b, c) {
  12279. c = c || {}, d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0;
  12280. var e = this.G;
  12281. e[2] = 1, e[5] = -1
  12282. }
  12283. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation")),
  12284. e = a("../math/vec2");
  12285. b.exports = c, c.prototype = new d, c.prototype.constructor = c;
  12286. var f = e.create(),
  12287. g = e.create(),
  12288. h = e.fromValues(1, 0),
  12289. i = e.fromValues(0, 1);
  12290. c.prototype.computeGq = function() {
  12291. return e.rotate(f, h, this.bodyA.angle + this.angle), e.rotate(g, i, this.bodyB.angle), e.dot(f, g)
  12292. }
  12293. }, {
  12294. "../math/vec2": 31,
  12295. "./Equation": 23,
  12296. __browserify_Buffer: 1,
  12297. __browserify_process: 2
  12298. }],
  12299. 26: [function(a, b) {
  12300. function c(a, b) {
  12301. d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1
  12302. } {
  12303. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation"));
  12304. a("../math/vec2")
  12305. }
  12306. b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
  12307. var d = this.G;
  12308. d[2] = -1, d[5] = this.ratio;
  12309. var e = this.computeGiMf(),
  12310. f = this.computeGW(),
  12311. g = -f * b - c * e;
  12312. return g
  12313. }
  12314. }, {
  12315. "../math/vec2": 31,
  12316. "./Equation": 23,
  12317. __browserify_Buffer: 1,
  12318. __browserify_process: 2
  12319. }],
  12320. 27: [function(a, b) {
  12321. var c = (a("__browserify_process"), a("__browserify_Buffer"), function() {});
  12322. b.exports = c, c.prototype = {
  12323. constructor: c,
  12324. on: function(a, b, c) {
  12325. b.context = c || this, void 0 === this._listeners && (this._listeners = {});
  12326. var d = this._listeners;
  12327. return void 0 === d[a] && (d[a] = []), -1 === d[a].indexOf(b) && d[a].push(b), this
  12328. },
  12329. has: function(a, b) {
  12330. if (void 0 === this._listeners) return !1;
  12331. var c = this._listeners;
  12332. if (b) {
  12333. if (void 0 !== c[a] && -1 !== c[a].indexOf(b)) return !0
  12334. } else if (void 0 !== c[a]) return !0;
  12335. return !1
  12336. },
  12337. off: function(a, b) {
  12338. if (void 0 === this._listeners) return this;
  12339. var c = this._listeners,
  12340. d = c[a].indexOf(b);
  12341. return -1 !== d && c[a].splice(d, 1), this
  12342. },
  12343. emit: function(a) {
  12344. if (void 0 === this._listeners) return this;
  12345. var b = this._listeners,
  12346. c = b[a.type];
  12347. if (void 0 !== c) {
  12348. a.target = this;
  12349. for (var d = 0, e = c.length; e > d; d++) {
  12350. var f = c[d];
  12351. f.call(f.context, a)
  12352. }
  12353. }
  12354. return this
  12355. }
  12356. }
  12357. }, {
  12358. __browserify_Buffer: 1,
  12359. __browserify_process: 2
  12360. }],
  12361. 28: [function(a, b) {
  12362. function c(a, b, f) {
  12363. if (f = f || {}, !(a instanceof d && b instanceof d)) throw new Error("First two arguments must be Material instances.");
  12364. 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
  12365. }
  12366. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Material")),
  12367. e = a("../equations/Equation");
  12368. b.exports = c, c.idCounter = 0
  12369. }, {
  12370. "../equations/Equation": 23,
  12371. "./Material": 29,
  12372. __browserify_Buffer: 1,
  12373. __browserify_process: 2
  12374. }],
  12375. 29: [function(a, b) {
  12376. function c(a) {
  12377. this.id = a || c.idCounter++
  12378. }
  12379. a("__browserify_process"), a("__browserify_Buffer");
  12380. b.exports = c, c.idCounter = 0
  12381. }, {
  12382. __browserify_Buffer: 1,
  12383. __browserify_process: 2
  12384. }],
  12385. 30: [function(a, b) {
  12386. var c = (a("__browserify_process"), a("__browserify_Buffer"), {});
  12387. c.GetArea = function(a) {
  12388. if (a.length < 6) return 0;
  12389. 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]);
  12390. return c += (a[0] - a[b]) * (a[b + 1] + a[1]), .5 * -c
  12391. }, c.Triangulate = function(a) {
  12392. var b = a.length >> 1;
  12393. if (3 > b) return [];
  12394. for (var d = [], e = [], f = 0; b > f; f++) e.push(f);
  12395. for (var f = 0, g = b; g > 3;) {
  12396. var h = e[(f + 0) % g],
  12397. i = e[(f + 1) % g],
  12398. j = e[(f + 2) % g],
  12399. k = a[2 * h],
  12400. l = a[2 * h + 1],
  12401. m = a[2 * i],
  12402. n = a[2 * i + 1],
  12403. o = a[2 * j],
  12404. p = a[2 * j + 1],
  12405. q = !1;
  12406. if (c._convex(k, l, m, n, o, p)) {
  12407. q = !0;
  12408. for (var r = 0; g > r; r++) {
  12409. var s = e[r];
  12410. if (s != h && s != i && s != j && c._PointInTriangle(a[2 * s], a[2 * s + 1], k, l, m, n, o, p)) {
  12411. q = !1;
  12412. break
  12413. }
  12414. }
  12415. }
  12416. if (q) d.push(h, i, j), e.splice((f + 1) % g, 1), g--, f = 0;
  12417. else if (f++ > 3 * g) break
  12418. }
  12419. return d.push(e[0], e[1], e[2]), d
  12420. }, c._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  12421. var i = g - c,
  12422. j = h - d,
  12423. k = e - c,
  12424. l = f - d,
  12425. m = a - c,
  12426. n = b - d,
  12427. o = i * i + j * j,
  12428. p = i * k + j * l,
  12429. q = i * m + j * n,
  12430. r = k * k + l * l,
  12431. s = k * m + l * n,
  12432. t = 1 / (o * r - p * p),
  12433. u = (r * q - p * s) * t,
  12434. v = (o * s - p * q) * t;
  12435. return u >= 0 && v >= 0 && 1 > u + v
  12436. }, c._convex = function(a, b, c, d, e, f) {
  12437. return (b - d) * (e - c) + (c - a) * (f - d) >= 0
  12438. }, b.exports = c
  12439. }, {
  12440. __browserify_Buffer: 1,
  12441. __browserify_process: 2
  12442. }],
  12443. 31: [function(a, b) {
  12444. var c = (a("__browserify_process"), a("__browserify_Buffer"), b.exports = {}),
  12445. d = a("../utils/Utils");
  12446. c.crossLength = function(a, b) {
  12447. return a[0] * b[1] - a[1] * b[0]
  12448. }, c.crossVZ = function(a, b, d) {
  12449. return c.rotate(a, b, -Math.PI / 2), c.scale(a, a, d), a
  12450. }, c.crossZV = function(a, b, d) {
  12451. return c.rotate(a, d, Math.PI / 2), c.scale(a, a, b), a
  12452. }, c.rotate = function(a, b, c) {
  12453. if (0 !== c) {
  12454. var d = Math.cos(c),
  12455. e = Math.sin(c),
  12456. f = b[0],
  12457. g = b[1];
  12458. a[0] = d * f - e * g, a[1] = e * f + d * g
  12459. } else a[0] = b[0], a[1] = b[1]
  12460. }, c.rotate90cw = function(a, b) {
  12461. var c = b[0],
  12462. d = b[1];
  12463. a[0] = d, a[1] = -c
  12464. }, c.toLocalFrame = function(a, b, d, e) {
  12465. c.copy(a, b), c.sub(a, a, d), c.rotate(a, a, -e)
  12466. }, c.toGlobalFrame = function(a, b, d, e) {
  12467. c.copy(a, b), c.rotate(a, a, e), c.add(a, a, d)
  12468. }, c.centroid = function(a, b, d, e) {
  12469. return c.add(a, b, d), c.add(a, a, e), c.scale(a, a, 1 / 3), a
  12470. }, c.create = function() {
  12471. var a = new d.ARRAY_TYPE(2);
  12472. return a[0] = 0, a[1] = 0, a
  12473. }, c.clone = function(a) {
  12474. var b = new d.ARRAY_TYPE(2);
  12475. return b[0] = a[0], b[1] = a[1], b
  12476. }, c.fromValues = function(a, b) {
  12477. var c = new d.ARRAY_TYPE(2);
  12478. return c[0] = a, c[1] = b, c
  12479. }, c.copy = function(a, b) {
  12480. return a[0] = b[0], a[1] = b[1], a
  12481. }, c.set = function(a, b, c) {
  12482. return a[0] = b, a[1] = c, a
  12483. }, c.add = function(a, b, c) {
  12484. return a[0] = b[0] + c[0], a[1] = b[1] + c[1], a
  12485. }, c.subtract = function(a, b, c) {
  12486. return a[0] = b[0] - c[0], a[1] = b[1] - c[1], a
  12487. }, c.sub = c.subtract, c.multiply = function(a, b, c) {
  12488. return a[0] = b[0] * c[0], a[1] = b[1] * c[1], a
  12489. }, c.mul = c.multiply, c.divide = function(a, b, c) {
  12490. return a[0] = b[0] / c[0], a[1] = b[1] / c[1], a
  12491. }, c.div = c.divide, c.scale = function(a, b, c) {
  12492. return a[0] = b[0] * c, a[1] = b[1] * c, a
  12493. }, c.distance = function(a, b) {
  12494. var c = b[0] - a[0],
  12495. d = b[1] - a[1];
  12496. return Math.sqrt(c * c + d * d)
  12497. }, c.dist = c.distance, c.squaredDistance = function(a, b) {
  12498. var c = b[0] - a[0],
  12499. d = b[1] - a[1];
  12500. return c * c + d * d
  12501. }, c.sqrDist = c.squaredDistance, c.length = function(a) {
  12502. var b = a[0],
  12503. c = a[1];
  12504. return Math.sqrt(b * b + c * c)
  12505. }, c.len = c.length, c.squaredLength = function(a) {
  12506. var b = a[0],
  12507. c = a[1];
  12508. return b * b + c * c
  12509. }, c.sqrLen = c.squaredLength, c.negate = function(a, b) {
  12510. return a[0] = -b[0], a[1] = -b[1], a
  12511. }, c.normalize = function(a, b) {
  12512. var c = b[0],
  12513. d = b[1],
  12514. e = c * c + d * d;
  12515. return e > 0 && (e = 1 / Math.sqrt(e), a[0] = b[0] * e, a[1] = b[1] * e), a
  12516. }, c.dot = function(a, b) {
  12517. return a[0] * b[0] + a[1] * b[1]
  12518. }, c.str = function(a) {
  12519. return "vec2(" + a[0] + ", " + a[1] + ")"
  12520. }
  12521. }, {
  12522. "../utils/Utils": 50,
  12523. __browserify_Buffer: 1,
  12524. __browserify_process: 2
  12525. }],
  12526. 32: [function(a, b) {
  12527. function c(a) {
  12528. 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.timeLastSleepy = 0, this.concavePath = null, this._wakeUpAfterNarrowphase = !1, this.updateMassProperties()
  12529. }
  12530. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  12531. e = a("poly-decomp"),
  12532. f = a("../shapes/Convex"),
  12533. g = a("../collision/AABB"),
  12534. h = a("../events/EventEmitter");
  12535. b.exports = c, c.prototype = new h, c._idCounter = 0, c.prototype.updateSolveMassProperties = function() {
  12536. this.sleepState === c.SLEEPING || this.type === c.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia)
  12537. }, c.prototype.setDensity = function(a) {
  12538. var b = this.getArea();
  12539. this.mass = b * a, this.updateMassProperties()
  12540. }, c.prototype.getArea = function() {
  12541. for (var a = 0, b = 0; b < this.shapes.length; b++) a += this.shapes[b].area;
  12542. return a
  12543. }, c.prototype.getAABB = function() {
  12544. return this.aabbNeedsUpdate && this.updateAABB(), this.aabb
  12545. };
  12546. var i = new g,
  12547. j = d.create();
  12548. c.prototype.updateAABB = function() {
  12549. for (var a = this.shapes, b = this.shapeOffsets, c = this.shapeAngles, e = a.length, f = j, g = this.angle, h = 0; h !== e; h++) {
  12550. var k = a[h],
  12551. l = c[h] + g;
  12552. 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)
  12553. }
  12554. this.aabbNeedsUpdate = !1
  12555. }, c.prototype.updateBoundingRadius = function() {
  12556. for (var a = this.shapes, b = this.shapeOffsets, c = a.length, e = 0, f = 0; f !== c; f++) {
  12557. var g = a[f],
  12558. h = d.length(b[f]),
  12559. i = g.boundingRadius;
  12560. h + i > e && (e = h + i)
  12561. }
  12562. this.boundingRadius = e
  12563. }, c.prototype.addShape = function(a, b, c) {
  12564. 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
  12565. }, c.prototype.removeShape = function(a) {
  12566. var b = this.shapes.indexOf(a);
  12567. return -1 !== b ? (this.shapes.splice(b, 1), this.shapeOffsets.splice(b, 1), this.shapeAngles.splice(b, 1), this.aabbNeedsUpdate = !0, !0) : !1
  12568. }, c.prototype.updateMassProperties = function() {
  12569. 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;
  12570. else {
  12571. var a = this.shapes,
  12572. b = a.length,
  12573. e = this.mass / b,
  12574. f = 0;
  12575. if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0;
  12576. else {
  12577. for (var g = 0; b > g; g++) {
  12578. var h = a[g],
  12579. i = d.squaredLength(this.shapeOffsets[g]),
  12580. j = h.computeMomentOfInertia(e);
  12581. f += j + e * i
  12582. }
  12583. this.inertia = f, this.invInertia = f > 0 ? 1 / f : 0
  12584. }
  12585. this.invMass = 1 / this.mass
  12586. }
  12587. };
  12588. var k = d.create();
  12589. c.prototype.applyForce = function(a, b) {
  12590. var c = k;
  12591. d.sub(c, b, this.position), d.add(this.force, this.force, a);
  12592. var e = d.crossLength(c, a);
  12593. this.angularForce += e
  12594. }, c.prototype.toLocalFrame = function(a, b) {
  12595. d.toLocalFrame(a, b, this.position, this.angle)
  12596. }, c.prototype.toWorldFrame = function(a, b) {
  12597. d.toGlobalFrame(a, b, this.position, this.angle)
  12598. }, c.prototype.fromPolygon = function(a, b) {
  12599. b = b || {};
  12600. for (var c = this.shapes.length; c >= 0; --c) this.removeShape(this.shapes[c]);
  12601. var g = new e.Polygon;
  12602. if (g.vertices = a, g.makeCCW(), "number" == typeof b.removeCollinearPoints && g.removeCollinearPoints(b.removeCollinearPoints), "undefined" == typeof b.skipSimpleCheck && !g.isSimple()) return !1;
  12603. this.concavePath = g.vertices.slice(0);
  12604. for (var c = 0; c < this.concavePath.length; c++) {
  12605. var h = [0, 0];
  12606. d.copy(h, this.concavePath[c]), this.concavePath[c] = h
  12607. }
  12608. var i;
  12609. i = b.optimalDecomp ? g.decomp() : g.quickDecomp();
  12610. for (var j = d.create(), c = 0; c !== i.length; c++) {
  12611. for (var k = new f(i[c].vertices), l = 0; l !== k.vertices.length; l++) {
  12612. var h = k.vertices[l];
  12613. d.sub(h, h, k.centerOfMass)
  12614. }
  12615. d.scale(j, k.centerOfMass, 1), k.updateTriangles(), k.updateCenterOfMass(), k.updateBoundingRadius(), this.addShape(k, j)
  12616. }
  12617. return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0
  12618. };
  12619. var l = (d.fromValues(0, 0), d.fromValues(0, 0)),
  12620. m = d.fromValues(0, 0),
  12621. n = d.fromValues(0, 0);
  12622. c.prototype.adjustCenterOfMass = function() {
  12623. var a = l,
  12624. b = m,
  12625. c = n,
  12626. e = 0;
  12627. d.set(b, 0, 0);
  12628. for (var f = 0; f !== this.shapes.length; f++) {
  12629. var g = this.shapes[f],
  12630. h = this.shapeOffsets[f];
  12631. d.scale(a, h, g.area), d.add(b, b, a), e += g.area
  12632. }
  12633. d.scale(c, b, 1 / e);
  12634. for (var f = 0; f !== this.shapes.length; f++) {
  12635. var g = this.shapes[f],
  12636. h = this.shapeOffsets[f];
  12637. h || (h = this.shapeOffsets[f] = d.create()), d.sub(h, h, c)
  12638. }
  12639. d.add(this.position, this.position, c);
  12640. for (var f = 0; this.concavePath && f < this.concavePath.length; f++) d.sub(this.concavePath[f], this.concavePath[f], c);
  12641. this.updateMassProperties(), this.updateBoundingRadius()
  12642. }, c.prototype.setZeroForce = function() {
  12643. d.set(this.force, 0, 0), this.angularForce = 0
  12644. }, c.prototype.resetConstraintVelocity = function() {
  12645. var a = this,
  12646. b = a.vlambda;
  12647. d.set(b, 0, 0), a.wlambda = 0
  12648. }, c.prototype.addConstraintVelocity = function() {
  12649. var a = this,
  12650. b = a.velocity;
  12651. d.add(b, b, a.vlambda), a.angularVelocity += a.wlambda
  12652. }, c.prototype.applyDamping = function(a) {
  12653. if (this.type === c.DYNAMIC) {
  12654. var b = this.velocity;
  12655. d.scale(b, b, Math.pow(1 - this.damping, a)), this.angularVelocity *= Math.pow(1 - this.angularDamping, a)
  12656. }
  12657. }, c.prototype.wakeUp = function() {
  12658. var a = this.sleepState;
  12659. this.sleepState = c.AWAKE, this.idleTime = 0, a !== c.AWAKE && this.emit(c.wakeUpEvent)
  12660. }, c.prototype.sleep = function() {
  12661. 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)
  12662. }, c.prototype.sleepTick = function(a, b, e) {
  12663. if (this.allowSleep && this.type !== c.SLEEPING) {
  12664. this.wantsToSleep = !1;
  12665. var f = (this.sleepState, d.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2)),
  12666. g = Math.pow(this.sleepSpeedLimit, 2);
  12667. 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())
  12668. }
  12669. }, c.prototype.getVelocityFromPosition = function(a, b) {
  12670. return a = a || d.create(), d.sub(a, this.position, this.previousPosition), d.scale(a, a, 1 / b), a
  12671. }, c.prototype.getAngularVelocityFromPosition = function(a) {
  12672. return (this.angle - this.previousAngle) / a
  12673. }, c.prototype.overlaps = function(a) {
  12674. return this.world.overlapKeeper.bodiesAreOverlapping(this, a)
  12675. }, c.sleepyEvent = {
  12676. type: "sleepy"
  12677. }, c.sleepEvent = {
  12678. type: "sleep"
  12679. }, c.wakeUpEvent = {
  12680. type: "wakeup"
  12681. }, c.DYNAMIC = 1, c.STATIC = 2, c.KINEMATIC = 4, c.AWAKE = 0, c.SLEEPY = 1, c.SLEEPING = 2
  12682. }, {
  12683. "../collision/AABB": 9,
  12684. "../events/EventEmitter": 27,
  12685. "../math/vec2": 31,
  12686. "../shapes/Convex": 39,
  12687. __browserify_Buffer: 1,
  12688. __browserify_process: 2,
  12689. "poly-decomp": 7
  12690. }],
  12691. 33: [function(a, b) {
  12692. function c(a, b, c) {
  12693. 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);
  12694. var f = d.create(),
  12695. g = d.create();
  12696. this.getWorldAnchorA(f), this.getWorldAnchorB(g);
  12697. var h = d.distance(f, g);
  12698. this.restLength = "number" == typeof c.restLength ? c.restLength : h
  12699. } {
  12700. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  12701. e = a("./Spring");
  12702. a("../utils/Utils")
  12703. }
  12704. b.exports = c, c.prototype = new e, c.prototype.setWorldAnchorA = function(a) {
  12705. this.bodyA.toLocalFrame(this.localAnchorA, a)
  12706. }, c.prototype.setWorldAnchorB = function(a) {
  12707. this.bodyB.toLocalFrame(this.localAnchorB, a)
  12708. }, c.prototype.getWorldAnchorA = function(a) {
  12709. this.bodyA.toWorldFrame(a, this.localAnchorA)
  12710. }, c.prototype.getWorldAnchorB = function(a) {
  12711. this.bodyB.toWorldFrame(a, this.localAnchorB)
  12712. };
  12713. var f = d.create(),
  12714. g = d.create(),
  12715. h = d.create(),
  12716. i = d.create(),
  12717. j = d.create(),
  12718. k = d.create(),
  12719. l = d.create(),
  12720. m = d.create(),
  12721. n = d.create();
  12722. c.prototype.applyForce = function() {
  12723. var a = this.stiffness,
  12724. b = this.damping,
  12725. c = this.restLength,
  12726. e = this.bodyA,
  12727. o = this.bodyB,
  12728. p = f,
  12729. q = g,
  12730. r = h,
  12731. s = i,
  12732. t = n,
  12733. u = j,
  12734. v = k,
  12735. w = l,
  12736. x = m;
  12737. this.getWorldAnchorA(u), this.getWorldAnchorB(v), d.sub(w, u, e.position), d.sub(x, v, o.position), d.sub(p, v, u);
  12738. var y = d.len(p);
  12739. 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);
  12740. var z = d.crossLength(w, s),
  12741. A = d.crossLength(x, s);
  12742. e.angularForce -= z, o.angularForce += A
  12743. }
  12744. }, {
  12745. "../math/vec2": 31,
  12746. "../utils/Utils": 50,
  12747. "./Spring": 35,
  12748. __browserify_Buffer: 1,
  12749. __browserify_process: 2
  12750. }],
  12751. 34: [function(a, b) {
  12752. function c(a, b, c) {
  12753. c = c || {}, d.call(this, a, b, c), this.restAngle = "number" == typeof c.restAngle ? c.restAngle : b.angle - a.angle
  12754. }
  12755. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("./Spring"));
  12756. b.exports = c, c.prototype = new d, c.prototype.applyForce = function() {
  12757. var a = this.stiffness,
  12758. b = this.damping,
  12759. c = this.restAngle,
  12760. d = this.bodyA,
  12761. e = this.bodyB,
  12762. f = e.angle - d.angle,
  12763. g = e.angularVelocity - d.angularVelocity,
  12764. h = -a * (f - c) - b * g * 0;
  12765. d.angularForce -= h, e.angularForce += h
  12766. }
  12767. }, {
  12768. "../math/vec2": 31,
  12769. "./Spring": 35,
  12770. __browserify_Buffer: 1,
  12771. __browserify_process: 2
  12772. }],
  12773. 35: [function(a, b) {
  12774. function c(a, b, c) {
  12775. c = d.defaults(c, {
  12776. stiffness: 100,
  12777. damping: 1
  12778. }), this.stiffness = c.stiffness, this.damping = c.damping, this.bodyA = a, this.bodyB = b
  12779. }
  12780. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("../utils/Utils"));
  12781. b.exports = c, c.prototype.applyForce = function() {}
  12782. }, {
  12783. "../math/vec2": 31,
  12784. "../utils/Utils": 50,
  12785. __browserify_Buffer: 1,
  12786. __browserify_process: 2
  12787. }],
  12788. 36: [function(a, b) {
  12789. a("__browserify_process"), a("__browserify_Buffer");
  12790. b.exports = {
  12791. AABB: a("./collision/AABB"),
  12792. AngleLockEquation: a("./equations/AngleLockEquation"),
  12793. Body: a("./objects/Body"),
  12794. Broadphase: a("./collision/Broadphase"),
  12795. Capsule: a("./shapes/Capsule"),
  12796. Circle: a("./shapes/Circle"),
  12797. Constraint: a("./constraints/Constraint"),
  12798. ContactEquation: a("./equations/ContactEquation"),
  12799. ContactMaterial: a("./material/ContactMaterial"),
  12800. Convex: a("./shapes/Convex"),
  12801. DistanceConstraint: a("./constraints/DistanceConstraint"),
  12802. Equation: a("./equations/Equation"),
  12803. EventEmitter: a("./events/EventEmitter"),
  12804. FrictionEquation: a("./equations/FrictionEquation"),
  12805. GearConstraint: a("./constraints/GearConstraint"),
  12806. GridBroadphase: a("./collision/GridBroadphase"),
  12807. GSSolver: a("./solver/GSSolver"),
  12808. Heightfield: a("./shapes/Heightfield"),
  12809. Line: a("./shapes/Line"),
  12810. LockConstraint: a("./constraints/LockConstraint"),
  12811. Material: a("./material/Material"),
  12812. Narrowphase: a("./collision/Narrowphase"),
  12813. NaiveBroadphase: a("./collision/NaiveBroadphase"),
  12814. Particle: a("./shapes/Particle"),
  12815. Plane: a("./shapes/Plane"),
  12816. RevoluteConstraint: a("./constraints/RevoluteConstraint"),
  12817. PrismaticConstraint: a("./constraints/PrismaticConstraint"),
  12818. Rectangle: a("./shapes/Rectangle"),
  12819. RotationalVelocityEquation: a("./equations/RotationalVelocityEquation"),
  12820. SAPBroadphase: a("./collision/SAPBroadphase"),
  12821. Shape: a("./shapes/Shape"),
  12822. Solver: a("./solver/Solver"),
  12823. Spring: a("./objects/Spring"),
  12824. LinearSpring: a("./objects/LinearSpring"),
  12825. RotationalSpring: a("./objects/RotationalSpring"),
  12826. Utils: a("./utils/Utils"),
  12827. World: a("./world/World"),
  12828. vec2: a("./math/vec2"),
  12829. version: a("../package.json").version
  12830. }
  12831. }, {
  12832. "../package.json": 8,
  12833. "./collision/AABB": 9,
  12834. "./collision/Broadphase": 10,
  12835. "./collision/GridBroadphase": 11,
  12836. "./collision/NaiveBroadphase": 12,
  12837. "./collision/Narrowphase": 13,
  12838. "./collision/SAPBroadphase": 14,
  12839. "./constraints/Constraint": 15,
  12840. "./constraints/DistanceConstraint": 16,
  12841. "./constraints/GearConstraint": 17,
  12842. "./constraints/LockConstraint": 18,
  12843. "./constraints/PrismaticConstraint": 19,
  12844. "./constraints/RevoluteConstraint": 20,
  12845. "./equations/AngleLockEquation": 21,
  12846. "./equations/ContactEquation": 22,
  12847. "./equations/Equation": 23,
  12848. "./equations/FrictionEquation": 24,
  12849. "./equations/RotationalVelocityEquation": 26,
  12850. "./events/EventEmitter": 27,
  12851. "./material/ContactMaterial": 28,
  12852. "./material/Material": 29,
  12853. "./math/vec2": 31,
  12854. "./objects/Body": 32,
  12855. "./objects/LinearSpring": 33,
  12856. "./objects/RotationalSpring": 34,
  12857. "./objects/Spring": 35,
  12858. "./shapes/Capsule": 37,
  12859. "./shapes/Circle": 38,
  12860. "./shapes/Convex": 39,
  12861. "./shapes/Heightfield": 40,
  12862. "./shapes/Line": 41,
  12863. "./shapes/Particle": 42,
  12864. "./shapes/Plane": 43,
  12865. "./shapes/Rectangle": 44,
  12866. "./shapes/Shape": 45,
  12867. "./solver/GSSolver": 46,
  12868. "./solver/Solver": 47,
  12869. "./utils/Utils": 50,
  12870. "./world/World": 54,
  12871. __browserify_Buffer: 1,
  12872. __browserify_process: 2
  12873. }],
  12874. 37: [function(a, b) {
  12875. function c(a, b) {
  12876. this.length = a || 1, this.radius = b || 1, d.call(this, d.CAPSULE)
  12877. }
  12878. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  12879. e = a("../math/vec2");
  12880. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  12881. var b = this.radius,
  12882. c = this.length + b,
  12883. d = 2 * b;
  12884. return a * (d * d + c * c) / 12
  12885. }, c.prototype.updateBoundingRadius = function() {
  12886. this.boundingRadius = this.radius + this.length / 2
  12887. }, c.prototype.updateArea = function() {
  12888. this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length
  12889. };
  12890. var f = e.create();
  12891. c.prototype.computeAABB = function(a, b, c) {
  12892. var d = this.radius;
  12893. 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)
  12894. }
  12895. }, {
  12896. "../math/vec2": 31,
  12897. "./Shape": 45,
  12898. __browserify_Buffer: 1,
  12899. __browserify_process: 2
  12900. }],
  12901. 38: [function(a, b) {
  12902. function c(a) {
  12903. this.radius = a || 1, d.call(this, d.CIRCLE)
  12904. }
  12905. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  12906. e = a("../math/vec2");
  12907. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  12908. var b = this.radius;
  12909. return a * b * b / 2
  12910. }, c.prototype.updateBoundingRadius = function() {
  12911. this.boundingRadius = this.radius
  12912. }, c.prototype.updateArea = function() {
  12913. this.area = Math.PI * this.radius * this.radius
  12914. }, c.prototype.computeAABB = function(a, b) {
  12915. var c = this.radius;
  12916. 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))
  12917. }
  12918. }, {
  12919. "../math/vec2": 31,
  12920. "./Shape": 45,
  12921. __browserify_Buffer: 1,
  12922. __browserify_process: 2
  12923. }],
  12924. 39: [function(a, b) {
  12925. function c(a, b) {
  12926. this.vertices = [], this.axes = [];
  12927. for (var c = 0; c < a.length; c++) {
  12928. var f = e.create();
  12929. e.copy(f, a[c]), this.vertices.push(f)
  12930. }
  12931. if (b)
  12932. for (var c = 0; c < b.length; c++) {
  12933. var g = e.create();
  12934. e.copy(g, b[c]), this.axes.push(g)
  12935. } else
  12936. for (var c = 0; c < a.length; c++) {
  12937. var h = a[c],
  12938. i = a[(c + 1) % a.length],
  12939. j = e.create();
  12940. e.sub(j, i, h), e.rotate90cw(j, j), e.normalize(j, j), this.axes.push(j)
  12941. }
  12942. 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.")
  12943. } {
  12944. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  12945. e = a("../math/vec2"),
  12946. f = a("../math/polyk");
  12947. a("poly-decomp")
  12948. }
  12949. b.exports = c, c.prototype = new d;
  12950. var g = e.create(),
  12951. h = e.create();
  12952. c.prototype.projectOntoLocalAxis = function(a, b) {
  12953. 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);
  12954. if (h > f) {
  12955. var j = h;
  12956. h = f, f = j
  12957. }
  12958. e.set(b, h, f)
  12959. }, c.prototype.projectOntoWorldAxis = function(a, b, c, d) {
  12960. var f = h;
  12961. this.projectOntoLocalAxis(a, d), 0 !== c ? e.rotate(f, a, c) : f = a;
  12962. var g = e.dot(b, f);
  12963. e.set(d, d[0] + g, d[1] + g)
  12964. }, c.prototype.updateTriangles = function() {
  12965. this.triangles.length = 0;
  12966. for (var a = [], b = 0; b < this.vertices.length; b++) {
  12967. var c = this.vertices[b];
  12968. a.push(c[0], c[1])
  12969. }
  12970. for (var d = f.Triangulate(a), b = 0; b < d.length; b += 3) {
  12971. var e = d[b],
  12972. g = d[b + 1],
  12973. h = d[b + 2];
  12974. this.triangles.push([e, g, h])
  12975. }
  12976. }; {
  12977. var i = e.create(),
  12978. j = e.create(),
  12979. k = e.create(),
  12980. l = e.create(),
  12981. m = e.create();
  12982. e.create(), e.create(), e.create(), e.create()
  12983. }
  12984. c.prototype.updateCenterOfMass = function() {
  12985. var a = this.triangles,
  12986. b = this.vertices,
  12987. d = this.centerOfMass,
  12988. f = i,
  12989. g = k,
  12990. h = l,
  12991. n = m,
  12992. o = j;
  12993. e.set(d, 0, 0);
  12994. for (var p = 0, q = 0; q !== a.length; q++) {
  12995. var r = a[q],
  12996. g = b[r[0]],
  12997. h = b[r[1]],
  12998. n = b[r[2]];
  12999. e.centroid(f, g, h, n);
  13000. var s = c.triangleArea(g, h, n);
  13001. p += s, e.scale(o, f, s), e.add(d, d, o)
  13002. }
  13003. e.scale(d, d, 1 / p)
  13004. }, c.prototype.computeMomentOfInertia = function(a) {
  13005. for (var b = 0, c = 0, d = this.vertices.length, f = d - 1, g = 0; d > g; f = g, g++) {
  13006. var h = this.vertices[f],
  13007. i = this.vertices[g],
  13008. j = Math.abs(e.crossLength(h, i)),
  13009. k = e.dot(i, i) + e.dot(i, h) + e.dot(h, h);
  13010. b += j * k, c += j
  13011. }
  13012. return a / 6 * (b / c)
  13013. }, c.prototype.updateBoundingRadius = function() {
  13014. for (var a = this.vertices, b = 0, c = 0; c !== a.length; c++) {
  13015. var d = e.squaredLength(a[c]);
  13016. d > b && (b = d)
  13017. }
  13018. this.boundingRadius = Math.sqrt(b)
  13019. }, c.triangleArea = function(a, b, c) {
  13020. return .5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]))
  13021. }, c.prototype.updateArea = function() {
  13022. this.updateTriangles(), this.area = 0;
  13023. for (var a = this.triangles, b = this.vertices, d = 0; d !== a.length; d++) {
  13024. var e = a[d],
  13025. f = b[e[0]],
  13026. g = b[e[1]],
  13027. h = b[e[2]],
  13028. i = c.triangleArea(f, g, h);
  13029. this.area += i
  13030. }
  13031. }, c.prototype.computeAABB = function(a, b, c) {
  13032. a.setFromPoints(this.vertices, b, c, 0)
  13033. }
  13034. }, {
  13035. "../math/polyk": 30,
  13036. "../math/vec2": 31,
  13037. "./Shape": 45,
  13038. __browserify_Buffer: 1,
  13039. __browserify_process: 2,
  13040. "poly-decomp": 7
  13041. }],
  13042. 40: [function(a, b) {
  13043. function c(a, b) {
  13044. if (b = e.defaults(b, {
  13045. maxValue: null,
  13046. minValue: null,
  13047. elementWidth: .1
  13048. }), null === b.minValue || null === b.maxValue) {
  13049. b.maxValue = a[0], b.minValue = a[0];
  13050. for (var c = 0; c !== a.length; c++) {
  13051. var f = a[c];
  13052. f > b.maxValue && (b.maxValue = f), f < b.minValue && (b.minValue = f)
  13053. }
  13054. }
  13055. this.data = a, this.maxValue = b.maxValue, this.minValue = b.minValue, this.elementWidth = b.elementWidth, d.call(this, d.HEIGHTFIELD)
  13056. }
  13057. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  13058. e = (a("../math/vec2"), a("../utils/Utils"));
  13059. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  13060. return Number.MAX_VALUE
  13061. }, c.prototype.updateBoundingRadius = function() {
  13062. this.boundingRadius = Number.MAX_VALUE
  13063. }, c.prototype.updateArea = function() {
  13064. for (var a = this.data, b = 0, c = 0; c < a.length - 1; c++) b += (a[c] + a[c + 1]) / 2 * this.elementWidth;
  13065. this.area = b
  13066. }, c.prototype.computeAABB = function(a, b) {
  13067. 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
  13068. }
  13069. }, {
  13070. "../math/vec2": 31,
  13071. "../utils/Utils": 50,
  13072. "./Shape": 45,
  13073. __browserify_Buffer: 1,
  13074. __browserify_process: 2
  13075. }],
  13076. 41: [function(a, b) {
  13077. function c(a) {
  13078. this.length = a || 1, d.call(this, d.LINE)
  13079. }
  13080. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  13081. e = a("../math/vec2");
  13082. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
  13083. return a * Math.pow(this.length, 2) / 12
  13084. }, c.prototype.updateBoundingRadius = function() {
  13085. this.boundingRadius = this.length / 2
  13086. };
  13087. var f = [e.create(), e.create()];
  13088. c.prototype.computeAABB = function(a, b, c) {
  13089. var d = this.length / 2;
  13090. e.set(f[0], -d, 0), e.set(f[1], d, 0), a.setFromPoints(f, b, c, 0)
  13091. }
  13092. }, {
  13093. "../math/vec2": 31,
  13094. "./Shape": 45,
  13095. __browserify_Buffer: 1,
  13096. __browserify_process: 2
  13097. }],
  13098. 42: [function(a, b) {
  13099. function c() {
  13100. d.call(this, d.PARTICLE)
  13101. }
  13102. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  13103. e = a("../math/vec2");
  13104. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  13105. return 0
  13106. }, c.prototype.updateBoundingRadius = function() {
  13107. this.boundingRadius = 0
  13108. }, c.prototype.computeAABB = function(a, b) {
  13109. e.copy(a.lowerBound, b), e.copy(a.upperBound, b)
  13110. }
  13111. }, {
  13112. "../math/vec2": 31,
  13113. "./Shape": 45,
  13114. __browserify_Buffer: 1,
  13115. __browserify_process: 2
  13116. }],
  13117. 43: [function(a, b) {
  13118. function c() {
  13119. d.call(this, d.PLANE)
  13120. } {
  13121. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
  13122. e = a("../math/vec2");
  13123. a("../utils/Utils")
  13124. }
  13125. b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
  13126. return 0
  13127. }, c.prototype.updateBoundingRadius = function() {
  13128. this.boundingRadius = Number.MAX_VALUE
  13129. }, c.prototype.computeAABB = function(a, b, c) {
  13130. var d = 0,
  13131. f = e.set;
  13132. "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)
  13133. }, c.prototype.updateArea = function() {
  13134. this.area = Number.MAX_VALUE
  13135. }
  13136. }, {
  13137. "../math/vec2": 31,
  13138. "../utils/Utils": 50,
  13139. "./Shape": 45,
  13140. __browserify_Buffer: 1,
  13141. __browserify_process: 2
  13142. }],
  13143. 44: [function(a, b) {
  13144. function c(a, b) {
  13145. this.width = a || 1, this.height = b || 1;
  13146. 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)],
  13147. g = [d.fromValues(1, 0), d.fromValues(0, 1)];
  13148. f.call(this, c, g), this.type = e.RECTANGLE
  13149. }
  13150. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  13151. e = a("./Shape"),
  13152. f = a("./Convex");
  13153. b.exports = c, c.prototype = new f([]), c.prototype.computeMomentOfInertia = function(a) {
  13154. var b = this.width,
  13155. c = this.height;
  13156. return a * (c * c + b * b) / 12
  13157. }, c.prototype.updateBoundingRadius = function() {
  13158. var a = this.width,
  13159. b = this.height;
  13160. this.boundingRadius = Math.sqrt(a * a + b * b) / 2
  13161. };
  13162. d.create(), d.create(), d.create(), d.create();
  13163. c.prototype.computeAABB = function(a, b, c) {
  13164. a.setFromPoints(this.vertices, b, c, 0)
  13165. }, c.prototype.updateArea = function() {
  13166. this.area = this.width * this.height
  13167. }
  13168. }, {
  13169. "../math/vec2": 31,
  13170. "./Convex": 39,
  13171. "./Shape": 45,
  13172. __browserify_Buffer: 1,
  13173. __browserify_process: 2
  13174. }],
  13175. 45: [function(a, b) {
  13176. function c(a) {
  13177. this.type = a, this.id = c.idCounter++, this.boundingRadius = 0, this.collisionGroup = 1, this.collisionMask = 1, a && this.updateBoundingRadius(), this.material = null, this.area = 0, this.sensor = !1, this.updateArea()
  13178. }
  13179. a("__browserify_process"), a("__browserify_Buffer");
  13180. 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() {
  13181. throw new Error("Shape.computeMomentOfInertia is not implemented in this Shape...")
  13182. }, c.prototype.updateBoundingRadius = function() {
  13183. throw new Error("Shape.updateBoundingRadius is not implemented in this Shape...")
  13184. }, c.prototype.updateArea = function() {}, c.prototype.computeAABB = function() {}
  13185. }, {
  13186. __browserify_Buffer: 1,
  13187. __browserify_process: 2
  13188. }],
  13189. 46: [function(a, b) {
  13190. function c(a) {
  13191. 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
  13192. }
  13193. function d(a) {
  13194. for (var b = a.length; b--;) a[b] = 0
  13195. }
  13196. var e = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
  13197. f = a("./Solver"),
  13198. g = a("../utils/Utils"),
  13199. h = a("../equations/FrictionEquation");
  13200. b.exports = c, c.prototype = new f, c.prototype.solve = function(a, b) {
  13201. this.sortEquations();
  13202. var f = 0,
  13203. i = this.iterations,
  13204. j = this.frictionIterations,
  13205. k = this.equations,
  13206. l = k.length,
  13207. m = Math.pow(this.tolerance * l, 2),
  13208. n = b.bodies,
  13209. o = b.bodies.length,
  13210. p = (e.add, e.set, this.useZeroRHS),
  13211. q = this.lambda;
  13212. if (this.usedIterations = 0, l)
  13213. for (var r = 0; r !== o; r++) {
  13214. var s = n[r];
  13215. s.updateSolveMassProperties()
  13216. }
  13217. 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);
  13218. for (var t = this.invCs, u = this.Bs, q = this.lambda, r = 0; r !== k.length; r++) {
  13219. var v = k[r];
  13220. (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)
  13221. }
  13222. var v, w, r, x;
  13223. if (0 !== l) {
  13224. for (r = 0; r !== o; r++) {
  13225. var s = n[r];
  13226. s.resetConstraintVelocity()
  13227. }
  13228. if (j) {
  13229. for (f = 0; f !== j; f++) {
  13230. for (w = 0, x = 0; x !== l; x++) {
  13231. v = k[x];
  13232. var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
  13233. w += Math.abs(y)
  13234. }
  13235. if (this.usedIterations++, m >= w * w) break
  13236. }
  13237. for (c.updateMultipliers(k, q, 1 / a), x = 0; x !== l; x++) {
  13238. var z = k[x];
  13239. if (z instanceof h) {
  13240. for (var A = 0, B = 0; B !== z.contactEquations.length; B++) A += z.contactEquations[B].multiplier;
  13241. A *= z.frictionCoefficient / z.contactEquations.length, z.maxForce = A, z.minForce = -A
  13242. }
  13243. }
  13244. }
  13245. for (f = 0; f !== i; f++) {
  13246. for (w = 0, x = 0; x !== l; x++) {
  13247. v = k[x];
  13248. var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
  13249. w += Math.abs(y)
  13250. }
  13251. if (this.usedIterations++, m >= w * w) break
  13252. }
  13253. for (r = 0; r !== o; r++) n[r].addConstraintVelocity();
  13254. c.updateMultipliers(k, q, 1 / a)
  13255. }
  13256. }, c.updateMultipliers = function(a, b, c) {
  13257. for (var d = a.length; d--;) a[d].multiplier = b[d] * c
  13258. }, c.iterateEquation = function(a, b, c, d, e, f, g, h) {
  13259. var i = d[a],
  13260. j = e[a],
  13261. k = f[a],
  13262. l = b.computeGWlambda(),
  13263. m = b.maxForce,
  13264. n = b.minForce;
  13265. g && (i = 0);
  13266. var o = j * (i - l - c * k),
  13267. p = k + o;
  13268. return n * h > p ? o = n * h - k : p > m * h && (o = m * h - k), f[a] += o, b.addToWlambda(o), o
  13269. }
  13270. }, {
  13271. "../equations/FrictionEquation": 24,
  13272. "../math/vec2": 31,
  13273. "../utils/Utils": 50,
  13274. "./Solver": 47,
  13275. __browserify_Buffer: 1,
  13276. __browserify_process: 2
  13277. }],
  13278. 47: [function(a, b) {
  13279. function c(a, b) {
  13280. a = a || {}, d.call(this), this.type = b, this.equations = [], this.equationSortFunction = a.equationSortFunction || !1
  13281. }
  13282. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../utils/Utils"), a("../events/EventEmitter"));
  13283. b.exports = c, c.prototype = new d, c.prototype.solve = function() {
  13284. throw new Error("Solver.solve should be implemented by subclasses!")
  13285. };
  13286. var e = {
  13287. bodies: []
  13288. };
  13289. c.prototype.solveIsland = function(a, b) {
  13290. this.removeAllEquations(), b.equations.length && (this.addEquations(b.equations), e.bodies.length = 0, b.getBodies(e.bodies), e.bodies.length && this.solve(a, e))
  13291. }, c.prototype.sortEquations = function() {
  13292. this.equationSortFunction && this.equations.sort(this.equationSortFunction)
  13293. }, c.prototype.addEquation = function(a) {
  13294. a.enabled && this.equations.push(a)
  13295. }, c.prototype.addEquations = function(a) {
  13296. for (var b = 0, c = a.length; b !== c; b++) {
  13297. var d = a[b];
  13298. d.enabled && this.equations.push(d)
  13299. }
  13300. }, c.prototype.removeEquation = function(a) {
  13301. var b = this.equations.indexOf(a); - 1 !== b && this.equations.splice(b, 1)
  13302. }, c.prototype.removeAllEquations = function() {
  13303. this.equations.length = 0
  13304. }, c.GS = 1, c.ISLAND = 2
  13305. }, {
  13306. "../events/EventEmitter": 27,
  13307. "../utils/Utils": 50,
  13308. __browserify_Buffer: 1,
  13309. __browserify_process: 2
  13310. }],
  13311. 48: [function(a, b) {
  13312. function c() {
  13313. this.overlappingShapesLastState = new e, this.overlappingShapesCurrentState = new e, this.recordPool = [], this.tmpDict = new e, this.tmpArray1 = []
  13314. }
  13315. function d(a, b, c, d) {
  13316. this.shapeA = b, this.shapeB = d, this.bodyA = a, this.bodyB = c
  13317. } {
  13318. var e = (a("__browserify_process"), a("__browserify_Buffer"), a("./TupleDictionary"));
  13319. a("./Utils")
  13320. }
  13321. b.exports = c, c.prototype.tick = function() {
  13322. for (var a = this.overlappingShapesLastState, b = this.overlappingShapesCurrentState, c = a.keys.length; c--;) {
  13323. var d = a.keys[c],
  13324. e = a.getByKey(d),
  13325. f = b.getByKey(d);
  13326. e && !f && this.recordPool.push(e)
  13327. }
  13328. a.reset(), a.copy(b), b.reset()
  13329. }, c.prototype.setOverlapping = function(a, b, c, e) {
  13330. var f = (this.overlappingShapesLastState, this.overlappingShapesCurrentState);
  13331. if (!f.get(b.id, e.id)) {
  13332. var g;
  13333. 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)
  13334. }
  13335. }, c.prototype.getNewOverlaps = function(a) {
  13336. return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, a)
  13337. }, c.prototype.getEndOverlaps = function(a) {
  13338. return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, a)
  13339. }, c.prototype.bodiesAreOverlapping = function(a, b) {
  13340. for (var c = this.overlappingShapesCurrentState, d = c.keys.length; d--;) {
  13341. var e = c.keys[d],
  13342. f = c.data[e];
  13343. if (f.bodyA === a && f.bodyB === b || f.bodyA === b && f.bodyB === a) return !0
  13344. }
  13345. return !1
  13346. }, c.prototype.getDiff = function(a, b, c) {
  13347. var c = c || [],
  13348. d = a,
  13349. e = b;
  13350. c.length = 0;
  13351. for (var f = e.keys.length; f--;) {
  13352. var g = e.keys[f],
  13353. h = e.data[g];
  13354. if (!h) throw new Error("Key " + g + " had no data!");
  13355. var i = d.data[g];
  13356. i || c.push(h)
  13357. }
  13358. return c
  13359. }, c.prototype.isNewOverlap = function(a, b) {
  13360. var c = 0 | a.id,
  13361. d = 0 | b.id,
  13362. e = this.overlappingShapesLastState,
  13363. f = this.overlappingShapesCurrentState;
  13364. return !e.get(c, d) && !!f.get(c, d)
  13365. }, c.prototype.getNewBodyOverlaps = function(a) {
  13366. this.tmpArray1.length = 0;
  13367. var b = this.getNewOverlaps(this.tmpArray1);
  13368. return this.getBodyDiff(b, a)
  13369. }, c.prototype.getEndBodyOverlaps = function(a) {
  13370. this.tmpArray1.length = 0;
  13371. var b = this.getEndOverlaps(this.tmpArray1);
  13372. return this.getBodyDiff(b, a)
  13373. }, c.prototype.getBodyDiff = function(a, b) {
  13374. b = b || [];
  13375. for (var c = this.tmpDict, d = a.length; d--;) {
  13376. var e = a[d];
  13377. c.set(0 | e.bodyA.id, 0 | e.bodyB.id, e)
  13378. }
  13379. for (d = c.keys.length; d--;) {
  13380. var e = c.getByKey(c.keys[d]);
  13381. e && b.push(e.bodyA, e.bodyB)
  13382. }
  13383. return c.reset(), b
  13384. }, d.prototype.set = function(a, b, c, e) {
  13385. d.call(this, a, b, c, e)
  13386. }
  13387. }, {
  13388. "./TupleDictionary": 49,
  13389. "./Utils": 50,
  13390. __browserify_Buffer: 1,
  13391. __browserify_process: 2
  13392. }],
  13393. 49: [function(a, b) {
  13394. function c() {
  13395. this.data = {}, this.keys = []
  13396. }
  13397. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Utils"));
  13398. b.exports = c, c.prototype.getKey = function(a, b) {
  13399. 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)
  13400. }, c.prototype.getByKey = function(a) {
  13401. return a = 0 | a, this.data[a]
  13402. }, c.prototype.get = function(a, b) {
  13403. return this.data[this.getKey(a, b)]
  13404. }, c.prototype.set = function(a, b, c) {
  13405. if (!c) throw new Error("No data!");
  13406. var d = this.getKey(a, b);
  13407. return this.data[d] || this.keys.push(d), this.data[d] = c, d
  13408. }, c.prototype.reset = function() {
  13409. for (var a = this.data, b = this.keys, c = b.length; c--;) delete a[b[c]];
  13410. b.length = 0
  13411. }, c.prototype.copy = function(a) {
  13412. this.reset(), d.appendArray(this.keys, a.keys);
  13413. for (var b = a.keys.length; b--;) {
  13414. var c = a.keys[b];
  13415. this.data[c] = a.data[c]
  13416. }
  13417. }
  13418. }, {
  13419. "./Utils": 50,
  13420. __browserify_Buffer: 1,
  13421. __browserify_process: 2
  13422. }],
  13423. 50: [function(a, b) {
  13424. function c() {}
  13425. a("__browserify_process"), a("__browserify_Buffer");
  13426. b.exports = c, c.appendArray = function(a, b) {
  13427. if (b.length < 15e4) a.push.apply(a, b);
  13428. else
  13429. for (var c = 0, d = b.length; c !== d; ++c) a.push(b[c])
  13430. }, c.splice = function(a, b, c) {
  13431. c = c || 1;
  13432. for (var d = b, e = a.length - c; e > d; d++) a[d] = a[d + c];
  13433. a.length = e
  13434. }, c.ARRAY_TYPE = window.Float32Array || Array, c.extend = function(a, b) {
  13435. for (var c in b) a[c] = b[c]
  13436. }, c.defaults = function(a, b) {
  13437. a = a || {};
  13438. for (var c in b) c in a || (a[c] = b[c]);
  13439. return a
  13440. }
  13441. }, {
  13442. __browserify_Buffer: 1,
  13443. __browserify_process: 2
  13444. }],
  13445. 51: [function(a, b) {
  13446. function c() {
  13447. this.equations = [], this.bodies = []
  13448. }
  13449. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../objects/Body"));
  13450. b.exports = c, c.prototype.reset = function() {
  13451. this.equations.length = this.bodies.length = 0
  13452. };
  13453. var e = [];
  13454. c.prototype.getBodies = function(a) {
  13455. var b = a || [],
  13456. c = this.equations;
  13457. e.length = 0;
  13458. for (var d = 0; d !== c.length; d++) {
  13459. 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))
  13460. }
  13461. return b
  13462. }, c.prototype.wantsToSleep = function() {
  13463. for (var a = 0; a < this.bodies.length; a++) {
  13464. var b = this.bodies[a];
  13465. if (b.type === d.DYNAMIC && !b.wantsToSleep) return !1
  13466. }
  13467. return !0
  13468. }, c.prototype.sleep = function() {
  13469. for (var a = 0; a < this.bodies.length; a++) {
  13470. var b = this.bodies[a];
  13471. b.sleep()
  13472. }
  13473. return !0
  13474. }
  13475. }, {
  13476. "../objects/Body": 32,
  13477. __browserify_Buffer: 1,
  13478. __browserify_process: 2
  13479. }],
  13480. 52: [function(a, b) {
  13481. function c() {
  13482. this._nodePool = [], this._islandPool = [], this.equations = [], this.islands = [], this.nodes = [], this.queue = []
  13483. }
  13484. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("./Island")),
  13485. e = a("./IslandNode"),
  13486. f = a("../objects/Body");
  13487. b.exports = c, c.getUnvisitedNode = function(a) {
  13488. for (var b = a.length, c = 0; c !== b; c++) {
  13489. var d = a[c];
  13490. if (!d.visited && d.body.type === f.DYNAMIC) return d
  13491. }
  13492. return !1
  13493. }, c.prototype.visit = function(a, b, c) {
  13494. b.push(a.body);
  13495. for (var d = a.equations.length, e = 0; e !== d; e++) {
  13496. var f = a.equations[e]; - 1 === c.indexOf(f) && c.push(f)
  13497. }
  13498. }, c.prototype.bfs = function(a, b, d) {
  13499. var e = this.queue;
  13500. for (e.length = 0, e.push(a), a.visited = !0, this.visit(a, b, d); e.length;)
  13501. 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)
  13502. }, c.prototype.split = function(a) {
  13503. for (var b = a.bodies, f = this.nodes, g = this.equations; f.length;) this._nodePool.push(f.pop());
  13504. for (var h = 0; h !== b.length; h++)
  13505. if (this._nodePool.length) {
  13506. var i = this._nodePool.pop();
  13507. i.reset(), i.body = b[h], f.push(i)
  13508. } else f.push(new e(b[h]));
  13509. for (var j = 0; j !== g.length; j++) {
  13510. var k = g[j],
  13511. h = b.indexOf(k.bodyA),
  13512. l = b.indexOf(k.bodyB),
  13513. m = f[h],
  13514. n = f[l];
  13515. m.neighbors.push(n), n.neighbors.push(m), m.equations.push(k), n.equations.push(k)
  13516. }
  13517. for (var o = this.islands; o.length;) {
  13518. var p = o.pop();
  13519. p.reset(), this._islandPool.push(p)
  13520. }
  13521. for (var q; q = c.getUnvisitedNode(f);) {
  13522. var p = this._islandPool.length ? this._islandPool.pop() : new d;
  13523. this.bfs(q, p.bodies, p.equations), o.push(p)
  13524. }
  13525. return o
  13526. }
  13527. }, {
  13528. "../math/vec2": 31,
  13529. "../objects/Body": 32,
  13530. "./Island": 51,
  13531. "./IslandNode": 53,
  13532. __browserify_Buffer: 1,
  13533. __browserify_process: 2
  13534. }],
  13535. 53: [function(a, b) {
  13536. function c(a) {
  13537. this.body = a, this.neighbors = [], this.equations = [], this.visited = !1
  13538. }
  13539. a("__browserify_process"), a("__browserify_Buffer");
  13540. b.exports = c, c.prototype.reset = function() {
  13541. this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null
  13542. }
  13543. }, {
  13544. __browserify_Buffer: 1,
  13545. __browserify_process: 2
  13546. }],
  13547. 54: [function(a, b) {
  13548. function c(a) {
  13549. k.apply(this), a = a || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], this.solver = a.solver || new d, this.narrowphase = new p(this), this.islandManager = new s, this.gravity = e.fromValues(0, -9.78), a.gravity && e.copy(this.gravity, a.gravity), this.frictionGravity = e.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, this.useFrictionGravityOnZeroGravity = !0, this.doProfiling = a.doProfiling || !1, this.lastStepTime = 0, this.broadphase = a.broadphase || new o, this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new m, this.defaultContactMaterial = new n(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 = {
  13550. type: "postStep"
  13551. }, this.addBodyEvent = {
  13552. type: "addBody",
  13553. body: null
  13554. }, this.removeBodyEvent = {
  13555. type: "removeBody",
  13556. body: null
  13557. }, this.addSpringEvent = {
  13558. type: "addSpring",
  13559. spring: null
  13560. }, this.impactEvent = {
  13561. type: "impact",
  13562. bodyA: null,
  13563. bodyB: null,
  13564. shapeA: null,
  13565. shapeB: null,
  13566. contactEquation: null
  13567. }, this.postBroadphaseEvent = {
  13568. type: "postBroadphase",
  13569. pairs: null
  13570. }, this.sleepMode = c.NO_SLEEPING, this.beginContactEvent = {
  13571. type: "beginContact",
  13572. shapeA: null,
  13573. shapeB: null,
  13574. bodyA: null,
  13575. bodyB: null,
  13576. contactEquations: []
  13577. }, this.endContactEvent = {
  13578. type: "endContact",
  13579. shapeA: null,
  13580. shapeB: null,
  13581. bodyA: null,
  13582. bodyB: null
  13583. }, this.preSolveEvent = {
  13584. type: "preSolve",
  13585. contactEquations: null,
  13586. frictionEquations: null
  13587. }, this.overlappingShapesLastState = {
  13588. keys: []
  13589. }, this.overlappingShapesCurrentState = {
  13590. keys: []
  13591. }, this.overlapKeeper = new r
  13592. } {
  13593. var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../solver/GSSolver")),
  13594. e = (a("../solver/Solver"), a("../collision/NaiveBroadphase"), a("../math/vec2")),
  13595. f = a("../shapes/Circle"),
  13596. g = (a("../shapes/Rectangle"), a("../shapes/Convex")),
  13597. h = (a("../shapes/Line"), a("../shapes/Plane")),
  13598. i = a("../shapes/Capsule"),
  13599. j = a("../shapes/Particle"),
  13600. k = a("../events/EventEmitter"),
  13601. l = a("../objects/Body"),
  13602. m = (a("../shapes/Shape"), a("../objects/LinearSpring"), a("../material/Material")),
  13603. n = a("../material/ContactMaterial"),
  13604. o = (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")),
  13605. p = a("../collision/Narrowphase"),
  13606. q = a("../utils/Utils"),
  13607. r = a("../utils/OverlapKeeper"),
  13608. s = a("./IslandManager");
  13609. a("../objects/RotationalSpring")
  13610. }
  13611. if (b.exports = c, "undefined" == typeof performance && (performance = {}), !performance.now) {
  13612. var t = Date.now();
  13613. performance.timing && performance.timing.navigationStart && (t = performance.timing.navigationStart), performance.now = function() {
  13614. return Date.now() - t
  13615. }
  13616. }
  13617. c.prototype = new Object(k.prototype), c.NO_SLEEPING = 1, c.BODY_SLEEPING = 2, c.ISLAND_SLEEPING = 4, c.prototype.addConstraint = function(a) {
  13618. this.constraints.push(a)
  13619. }, c.prototype.addContactMaterial = function(a) {
  13620. this.contactMaterials.push(a)
  13621. }, c.prototype.removeContactMaterial = function(a) {
  13622. var b = this.contactMaterials.indexOf(a); - 1 !== b && q.splice(this.contactMaterials, b, 1)
  13623. }, c.prototype.getContactMaterial = function(a, b) {
  13624. for (var c = this.contactMaterials, d = 0, e = c.length; d !== e; d++) {
  13625. var f = c[d];
  13626. if (f.materialA.id === a.id && f.materialB.id === b.id || f.materialA.id === b.id && f.materialB.id === a.id) return f
  13627. }
  13628. return !1
  13629. }, c.prototype.removeConstraint = function(a) {
  13630. var b = this.constraints.indexOf(a); - 1 !== b && q.splice(this.constraints, b, 1)
  13631. };
  13632. var u = (e.create(), e.create(), e.create(), e.create(), e.create(), e.create(), e.create()),
  13633. v = e.fromValues(0, 0),
  13634. w = e.fromValues(0, 0),
  13635. x = (e.fromValues(0, 0), e.fromValues(0, 0));
  13636. c.prototype.step = function(a, b, c) {
  13637. if (c = c || 10, b = b || 0, 0 === b) this.internalStep(a), this.time += a;
  13638. else {
  13639. var d = Math.floor((this.time + b) / a) - Math.floor(this.time / a);
  13640. d = Math.min(d, c);
  13641. for (var f = performance.now(), g = 0; g !== d && (this.internalStep(a), !(performance.now() - f > 1e3 * a)); g++);
  13642. this.time += b;
  13643. for (var h = this.time % a, i = h / a, j = 0; j !== this.bodies.length; j++) {
  13644. var k = this.bodies[j];
  13645. k.type !== l.STATIC && k.sleepState !== l.SLEEPING ? (e.sub(x, k.position, k.previousPosition), e.scale(x, x, i), e.add(k.interpolatedPosition, k.position, x), k.interpolatedAngle = k.angle + (k.angle - k.previousAngle) * i) : (e.copy(k.interpolatedPosition, k.position), k.interpolatedAngle = k.angle)
  13646. }
  13647. }
  13648. };
  13649. var y = [];
  13650. c.prototype.internalStep = function(a) {
  13651. this.stepping = !0;
  13652. var b, d, f = this,
  13653. g = this.doProfiling,
  13654. h = this.springs.length,
  13655. i = this.springs,
  13656. j = this.bodies,
  13657. k = this.gravity,
  13658. m = this.solver,
  13659. n = this.bodies.length,
  13660. o = this.broadphase,
  13661. p = this.narrowphase,
  13662. r = this.constraints,
  13663. s = u,
  13664. t = (e.scale, e.add),
  13665. v = (e.rotate, this.islandManager);
  13666. if (this.overlapKeeper.tick(), this.lastTimeStep = a, g && (b = performance.now()), this.useWorldGravityAsFrictionGravity) {
  13667. var w = e.length(this.gravity);
  13668. 0 === w && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = w)
  13669. }
  13670. if (this.applyGravity)
  13671. for (var x = 0; x !== n; x++) {
  13672. var z = j[x],
  13673. A = z.force;
  13674. z.type === l.DYNAMIC && z.sleepState !== l.SLEEPING && (e.scale(s, k, z.mass * z.gravityScale), t(A, A, s))
  13675. }
  13676. if (this.applySpringForces)
  13677. for (var x = 0; x !== h; x++) {
  13678. var B = i[x];
  13679. B.applyForce()
  13680. }
  13681. if (this.applyDamping)
  13682. for (var x = 0; x !== n; x++) {
  13683. var z = j[x];
  13684. z.type === l.DYNAMIC && z.applyDamping(a)
  13685. }
  13686. for (var C = o.getCollisionPairs(this), D = this.disabledBodyCollisionPairs, x = D.length - 2; x >= 0; x -= 2)
  13687. 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);
  13688. var F = r.length;
  13689. for (x = 0; x !== F; x++) {
  13690. var G = r[x];
  13691. if (!G.collideConnected)
  13692. 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)
  13693. }
  13694. this.postBroadphaseEvent.pairs = C, this.emit(this.postBroadphaseEvent), p.reset(this);
  13695. for (var x = 0, H = C.length; x !== H; x += 2)
  13696. for (var I = C[x], J = C[x + 1], K = 0, L = I.shapes.length; K !== L; K++)
  13697. for (var M = I.shapes[K], N = I.shapeOffsets[K], O = I.shapeAngles[K], P = 0, Q = J.shapes.length; P !== Q; P++) {
  13698. var R = J.shapes[P],
  13699. S = J.shapeOffsets[P],
  13700. T = J.shapeAngles[P],
  13701. U = this.defaultContactMaterial;
  13702. if (M.material && R.material) {
  13703. var V = this.getContactMaterial(M.material, R.material);
  13704. V && (U = V)
  13705. }
  13706. this.runNarrowphase(p, I, M, N, O, J, R, S, T, U, this.frictionGravity)
  13707. }
  13708. for (var x = 0; x !== n; x++) {
  13709. var W = j[x];
  13710. W._wakeUpAfterNarrowphase && (W.wakeUp(), W._wakeUpAfterNarrowphase = !1)
  13711. }
  13712. if (this.has("endContact")) {
  13713. this.overlapKeeper.getEndOverlaps(y);
  13714. for (var X = this.endContactEvent, P = y.length; P--;) {
  13715. var Y = y[P];
  13716. X.shapeA = Y.shapeA, X.shapeB = Y.shapeB, X.bodyA = Y.bodyA, X.bodyB = Y.bodyB, this.emit(X)
  13717. }
  13718. }
  13719. var Z = this.preSolveEvent;
  13720. Z.contactEquations = p.contactEquations, Z.frictionEquations = p.frictionEquations, this.emit(Z);
  13721. var F = r.length;
  13722. for (x = 0; x !== F; x++) r[x].update();
  13723. if (p.contactEquations.length || p.frictionEquations.length || r.length)
  13724. if (this.islandSplit) {
  13725. for (v.equations.length = 0, q.appendArray(v.equations, p.contactEquations), q.appendArray(v.equations, p.frictionEquations), x = 0; x !== F; x++) q.appendArray(v.equations, r[x].equations);
  13726. v.split(this);
  13727. for (var x = 0; x !== v.islands.length; x++) {
  13728. var $ = v.islands[x];
  13729. $.equations.length && m.solveIsland(a, $)
  13730. }
  13731. } else {
  13732. for (m.addEquations(p.contactEquations), m.addEquations(p.frictionEquations), x = 0; x !== F; x++) m.addEquations(r[x].equations);
  13733. this.solveConstraints && m.solve(a, this), m.removeAllEquations()
  13734. }
  13735. for (var x = 0; x !== n; x++) {
  13736. var W = j[x];
  13737. W.sleepState !== l.SLEEPING && W.type !== l.STATIC && c.integrateBody(W, a)
  13738. }
  13739. for (var x = 0; x !== n; x++) j[x].setZeroForce();
  13740. if (g && (d = performance.now(), f.lastStepTime = d - b), this.emitImpactEvent && this.has("impact"))
  13741. for (var _ = this.impactEvent, x = 0; x !== p.contactEquations.length; x++) {
  13742. var ab = p.contactEquations[x];
  13743. ab.firstImpact && (_.bodyA = ab.bodyA, _.bodyB = ab.bodyB, _.shapeA = ab.shapeA, _.shapeB = ab.shapeB, _.contactEquation = ab, this.emit(_))
  13744. }
  13745. if (this.sleepMode === c.BODY_SLEEPING)
  13746. for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !1, a);
  13747. else if (this.sleepMode === c.ISLAND_SLEEPING && this.islandSplit) {
  13748. for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !0, a);
  13749. for (var x = 0; x < this.islandManager.islands.length; x++) {
  13750. var $ = this.islandManager.islands[x];
  13751. $.wantsToSleep() && $.sleep()
  13752. }
  13753. }
  13754. if (this.stepping = !1, this.bodiesToBeRemoved.length) {
  13755. for (var x = 0; x !== this.bodiesToBeRemoved.length; x++) this.removeBody(this.bodiesToBeRemoved[x]);
  13756. this.bodiesToBeRemoved.length = 0
  13757. }
  13758. this.emit(this.postStepEvent)
  13759. };
  13760. var z = e.create(),
  13761. A = e.create();
  13762. c.integrateBody = function(a, b) {
  13763. var c = a.invMass,
  13764. d = a.force,
  13765. f = a.position,
  13766. g = a.velocity;
  13767. e.copy(a.previousPosition, a.position), a.previousAngle = a.angle, a.fixedRotation || (a.angularVelocity += a.angularForce * a.invInertia * b, a.angle += a.angularVelocity * b), e.scale(z, d, b * c), e.add(g, z, g), e.scale(A, g, b), e.add(f, f, A), a.aabbNeedsUpdate = !0
  13768. }, c.prototype.runNarrowphase = function(a, b, c, d, f, g, h, i, j, k, m) {
  13769. if (0 !== (c.collisionGroup & h.collisionMask) && 0 !== (h.collisionGroup & c.collisionMask)) {
  13770. e.rotate(v, d, b.angle), e.rotate(w, i, g.angle), e.add(v, v, b.position), e.add(w, w, g.position);
  13771. var n = f + b.angle,
  13772. o = j + g.angle;
  13773. a.enableFriction = k.friction > 0, a.frictionCoefficient = k.friction;
  13774. var p;
  13775. p = b.type === l.STATIC || b.type === l.KINEMATIC ? g.mass : g.type === l.STATIC || g.type === l.KINEMATIC ? b.mass : b.mass * g.mass / (b.mass + g.mass), a.slipForce = k.friction * m * 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;
  13776. var q = a[c.type | h.type],
  13777. r = 0;
  13778. if (q) {
  13779. var s = c.sensor || h.sensor,
  13780. t = a.frictionEquations.length;
  13781. r = c.type < h.type ? q.call(a, b, c, v, n, g, h, w, o, s) : q.call(a, g, h, w, o, b, c, v, n, s);
  13782. var u = a.frictionEquations.length - t;
  13783. if (r) {
  13784. if (b.allowSleep && b.type === l.DYNAMIC && b.sleepState === l.SLEEPING && g.sleepState === l.AWAKE && g.type !== l.STATIC) {
  13785. var x = e.squaredLength(g.velocity) + Math.pow(g.angularVelocity, 2),
  13786. y = Math.pow(g.sleepSpeedLimit, 2);
  13787. x >= 2 * y && (b._wakeUpAfterNarrowphase = !0)
  13788. }
  13789. if (g.allowSleep && g.type === l.DYNAMIC && g.sleepState === l.SLEEPING && b.sleepState === l.AWAKE && b.type !== l.STATIC) {
  13790. var z = e.squaredLength(b.velocity) + Math.pow(b.angularVelocity, 2),
  13791. A = Math.pow(b.sleepSpeedLimit, 2);
  13792. z >= 2 * A && (g._wakeUpAfterNarrowphase = !0)
  13793. }
  13794. if (this.overlapKeeper.setOverlapping(b, c, g, h), this.has("beginContact") && this.overlapKeeper.isNewOverlap(c, h)) {
  13795. var B = this.beginContactEvent;
  13796. if (B.shapeA = c, B.shapeB = h, B.bodyA = b, B.bodyB = g, B.contactEquations.length = 0, "number" == typeof r)
  13797. for (var C = a.contactEquations.length - r; C < a.contactEquations.length; C++) B.contactEquations.push(a.contactEquations[C]);
  13798. this.emit(B)
  13799. }
  13800. if ("number" == typeof r && u > 1)
  13801. for (var C = a.frictionEquations.length - u; C < a.frictionEquations.length; C++) {
  13802. var D = a.frictionEquations[C];
  13803. D.setSlipForce(D.getSlipForce() / u)
  13804. }
  13805. }
  13806. }
  13807. }
  13808. }, c.prototype.addSpring = function(a) {
  13809. this.springs.push(a), this.addSpringEvent.spring = a, this.emit(this.addSpringEvent)
  13810. }, c.prototype.removeSpring = function(a) {
  13811. var b = this.springs.indexOf(a); - 1 !== b && q.splice(this.springs, b, 1)
  13812. }, c.prototype.addBody = function(a) {
  13813. -1 === this.bodies.indexOf(a) && (this.bodies.push(a), a.world = this, this.addBodyEvent.body = a, this.emit(this.addBodyEvent))
  13814. }, c.prototype.removeBody = function(a) {
  13815. if (this.stepping) this.bodiesToBeRemoved.push(a);
  13816. else {
  13817. a.world = null;
  13818. var b = this.bodies.indexOf(a); - 1 !== b && (q.splice(this.bodies, b, 1), this.removeBodyEvent.body = a, a.resetConstraintVelocity(), this.emit(this.removeBodyEvent))
  13819. }
  13820. }, c.prototype.getBodyById = function(a) {
  13821. for (var b = this.bodies, c = 0; c < b.length; c++) {
  13822. var d = b[c];
  13823. if (d.id === a) return d
  13824. }
  13825. return !1
  13826. }, c.prototype.disableBodyCollision = function(a, b) {
  13827. this.disabledBodyCollisionPairs.push(a, b)
  13828. }, c.prototype.enableBodyCollision = function(a, b) {
  13829. for (var c = this.disabledBodyCollisionPairs, d = 0; d < c.length; d += 2)
  13830. if (c[d] === a && c[d + 1] === b || c[d + 1] === a && c[d] === b) return void c.splice(d, 2)
  13831. }, c.prototype.clear = function() {
  13832. this.time = 0, this.fixedStepTime = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
  13833. for (var a = this.constraints, b = a.length - 1; b >= 0; b--) this.removeConstraint(a[b]);
  13834. for (var d = this.bodies, b = d.length - 1; b >= 0; b--) this.removeBody(d[b]);
  13835. for (var e = this.springs, b = e.length - 1; b >= 0; b--) this.removeSpring(e[b]);
  13836. for (var f = this.contactMaterials, b = f.length - 1; b >= 0; b--) this.removeContactMaterial(f[b]);
  13837. c.apply(this)
  13838. }, c.prototype.clone = function() {
  13839. var a = new c;
  13840. return a.fromJSON(this.toJSON()), a
  13841. };
  13842. var B = e.create(),
  13843. C = e.fromValues(0, 0),
  13844. D = e.fromValues(0, 0);
  13845. c.prototype.hitTest = function(a, b, c) {
  13846. c = c || 0;
  13847. var d = new l({
  13848. position: a
  13849. }),
  13850. k = new j,
  13851. m = a,
  13852. n = 0,
  13853. o = B,
  13854. p = C,
  13855. q = D;
  13856. d.addShape(k);
  13857. for (var r = this.narrowphase, s = [], t = 0, u = b.length; t !== u; t++)
  13858. for (var v = b[t], w = 0, x = v.shapes.length; w !== x; w++) {
  13859. var y = v.shapes[w],
  13860. z = v.shapeOffsets[w] || p,
  13861. A = v.shapeAngles[w] || 0;
  13862. e.rotate(o, z, v.angle), e.add(o, o, v.position);
  13863. var E = A + v.angle;
  13864. (y instanceof f && r.circleParticle(v, y, o, E, d, k, m, n, !0) || y instanceof g && r.particleConvex(d, k, m, n, v, y, o, E, !0) || y instanceof h && r.particlePlane(d, k, m, n, v, y, o, E, !0) || y instanceof i && r.particleCapsule(d, k, m, n, v, y, o, E, !0) || y instanceof j && e.squaredLength(e.sub(q, o, a)) < c * c) && s.push(v)
  13865. }
  13866. return s
  13867. }, c.prototype.setGlobalEquationParameters = function(a) {
  13868. a = a || {};
  13869. for (var b = 0; b !== this.constraints.length; b++)
  13870. for (var c = this.constraints[b], d = 0; d !== c.equations.length; d++) {
  13871. var e = c.equations[d];
  13872. "undefined" != typeof a.stiffness && (e.stiffness = a.stiffness), "undefined" != typeof a.relaxation && (e.relaxation = a.relaxation), e.needsUpdate = !0
  13873. }
  13874. for (var b = 0; b !== this.contactMaterials.length; b++) {
  13875. var c = this.contactMaterials[b];
  13876. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13877. }
  13878. var c = this.defaultContactMaterial;
  13879. "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
  13880. }, c.prototype.setGlobalStiffness = function(a) {
  13881. this.setGlobalEquationParameters({
  13882. stiffness: a
  13883. })
  13884. }, c.prototype.setGlobalRelaxation = function(a) {
  13885. this.setGlobalEquationParameters({
  13886. relaxation: a
  13887. })
  13888. }
  13889. }, {
  13890. "../../package.json": 8,
  13891. "../collision/Broadphase": 10,
  13892. "../collision/NaiveBroadphase": 12,
  13893. "../collision/Narrowphase": 13,
  13894. "../collision/SAPBroadphase": 14,
  13895. "../constraints/Constraint": 15,
  13896. "../constraints/DistanceConstraint": 16,
  13897. "../constraints/GearConstraint": 17,
  13898. "../constraints/LockConstraint": 18,
  13899. "../constraints/PrismaticConstraint": 19,
  13900. "../constraints/RevoluteConstraint": 20,
  13901. "../events/EventEmitter": 27,
  13902. "../material/ContactMaterial": 28,
  13903. "../material/Material": 29,
  13904. "../math/vec2": 31,
  13905. "../objects/Body": 32,
  13906. "../objects/LinearSpring": 33,
  13907. "../objects/RotationalSpring": 34,
  13908. "../shapes/Capsule": 37,
  13909. "../shapes/Circle": 38,
  13910. "../shapes/Convex": 39,
  13911. "../shapes/Line": 41,
  13912. "../shapes/Particle": 42,
  13913. "../shapes/Plane": 43,
  13914. "../shapes/Rectangle": 44,
  13915. "../shapes/Shape": 45,
  13916. "../solver/GSSolver": 46,
  13917. "../solver/Solver": 47,
  13918. "../utils/OverlapKeeper": 48,
  13919. "../utils/Utils": 50,
  13920. "./IslandManager": 52,
  13921. __browserify_Buffer: 1,
  13922. __browserify_process: 2
  13923. }]
  13924. }, {}, [36])(36)
  13925. }), p2.Body.prototype.parent = null, p2.Spring.prototype.parent = null, Phaser.Physics.P2 = function(a, b) {
  13926. this.game = a, "undefined" != typeof b && b.hasOwnProperty("gravity") && b.hasOwnProperty("broadphase") || (b = {
  13927. gravity: [0, 0],
  13928. broadphase: new p2.SAPBroadphase
  13929. }), 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 Phaser.Physics.P2.InversePointProxy(this, this.world.gravity), this.walls = {
  13930. left: null,
  13931. right: null,
  13932. top: null,
  13933. bottom: null
  13934. }, this.onBodyAdded = new Phaser.Signal, this.onBodyRemoved = new Phaser.Signal, this.onSpringAdded = new Phaser.Signal, this.onSpringRemoved = new Phaser.Signal, this.onConstraintAdded = new Phaser.Signal, this.onConstraintRemoved = new Phaser.Signal, this.onContactMaterialAdded = new Phaser.Signal, this.onContactMaterialRemoved = new Phaser.Signal, this.postBroadphaseCallback = null, this.callbackContext = null, this.onBeginContact = new Phaser.Signal, this.onEndContact = new Phaser.Signal, b.hasOwnProperty("mpx") && b.hasOwnProperty("pxm") && b.hasOwnProperty("mpxi") && b.hasOwnProperty("pxmi") && (this.mpx = b.mpx, this.mpxi = b.mpxi, this.pxm = b.pxm, this.pxmi = b.pxmi), this.world.on("beginContact", this.beginContactHandler, this), this.world.on("endContact", this.endContactHandler, this), this.collisionGroups = [], this.nothingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2147483648), this.boundsCollidesWith = [], this._toRemove = [], this._collisionGroupID = 2, this.setBoundsToWorld(!0, !0, !0, !0, !1)
  13935. }, Phaser.Physics.P2.prototype = {
  13936. removeBodyNextStep: function(a) {
  13937. this._toRemove.push(a)
  13938. },
  13939. preUpdate: function() {
  13940. for (var a = this._toRemove.length; a--;) this.removeBody(this._toRemove[a]);
  13941. this._toRemove.length = 0
  13942. },
  13943. enable: function(a, b, c) {
  13944. "undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !0);
  13945. var d = 1;
  13946. if (Array.isArray(a))
  13947. for (d = a.length; d--;) a[d] instanceof Phaser.Group ? this.enable(a[d].children, b, c) : (this.enableBody(a[d], b), c && a[d].hasOwnProperty("children") && a[d].children.length > 0 && this.enable(a[d], b, !0));
  13948. else a instanceof Phaser.Group ? this.enable(a.children, b, c) : (this.enableBody(a, b), c && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, b, !0))
  13949. },
  13950. enableBody: function(a, b) {
  13951. a.hasOwnProperty("body") && null === a.body && (a.body = new Phaser.Physics.P2.Body(this.game, a, a.x, a.y, 1), a.body.debug = b, a.anchor.set(.5))
  13952. },
  13953. setImpactEvents: function(a) {
  13954. a ? this.world.on("impact", this.impactHandler, this) : this.world.off("impact", this.impactHandler, this)
  13955. },
  13956. setPostBroadphaseCallback: function(a, b) {
  13957. this.postBroadphaseCallback = a, this.callbackContext = b, null !== a ? this.world.on("postBroadphase", this.postBroadphaseHandler, this) : this.world.off("postBroadphase", this.postBroadphaseHandler, this)
  13958. },
  13959. postBroadphaseHandler: function(a) {
  13960. var b = a.pairs.length;
  13961. if (this.postBroadphaseCallback && b > 0)
  13962. for (; 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)
  13963. },
  13964. impactHandler: function(a) {
  13965. if (a.bodyA.parent && a.bodyB.parent) {
  13966. var b = a.bodyA.parent,
  13967. c = a.bodyB.parent;
  13968. 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)
  13969. }
  13970. },
  13971. beginContactHandler: function(a) {
  13972. 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)
  13973. },
  13974. endContactHandler: function(a) {
  13975. 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)
  13976. },
  13977. setBoundsToWorld: function(a, b, c, d, e) {
  13978. 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)
  13979. },
  13980. setWorldMaterial: function(a, b, c, d, e) {
  13981. "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)
  13982. },
  13983. updateBoundsCollisionGroup: function(a) {
  13984. var b = this.everythingCollisionGroup.mask;
  13985. "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)
  13986. },
  13987. setBounds: function(a, b, c, d, e, f, g, h, i) {
  13988. "undefined" == typeof e && (e = !0), "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = !0), "undefined" == typeof h && (h = !0), "undefined" == typeof i && (i = !0), this.walls.left && this.world.removeBody(this.walls.left), this.walls.right && this.world.removeBody(this.walls.right), this.walls.top && this.world.removeBody(this.walls.top), this.walls.bottom && this.world.removeBody(this.walls.bottom), e && (this.walls.left = new p2.Body({
  13989. mass: 0,
  13990. position: [this.pxmi(a), this.pxmi(b)],
  13991. angle: 1.5707963267948966
  13992. }), 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({
  13993. mass: 0,
  13994. position: [this.pxmi(a + c), this.pxmi(b)],
  13995. angle: -1.5707963267948966
  13996. }), 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({
  13997. mass: 0,
  13998. position: [this.pxmi(a), this.pxmi(b)],
  13999. angle: -3.141592653589793
  14000. }), 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({
  14001. mass: 0,
  14002. position: [this.pxmi(a), this.pxmi(b + d)]
  14003. }), this.walls.bottom.addShape(new p2.Plane), i && (this.walls.bottom.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.bottom))
  14004. },
  14005. pause: function() {
  14006. this.paused = !0
  14007. },
  14008. resume: function() {
  14009. this.paused = !1
  14010. },
  14011. update: function() {
  14012. this.paused || this.world.step(this.useElapsedTime ? this.game.time.physicsElapsed : this.frameRate)
  14013. },
  14014. clear: function() {
  14015. this.world.clear(), this.world.off("beginContact", this.beginContactHandler, this), this.world.off("endContact", this.endContactHandler, this), this.postBroadphaseCallback = null, this.callbackContext = null, this.impactCallback = null, this.collisionGroups = [], this._toRemove = [], this._collisionGroupID = 2, this.boundsCollidesWith = []
  14016. },
  14017. destroy: function() {
  14018. this.clear(), this.game = null
  14019. },
  14020. addBody: function(a) {
  14021. return a.data.world ? !1 : (this.world.addBody(a.data), this.onBodyAdded.dispatch(a), !0)
  14022. },
  14023. removeBody: function(a) {
  14024. return a.data.world == this.world && (this.world.removeBody(a.data), this.onBodyRemoved.dispatch(a)), a
  14025. },
  14026. addSpring: function(a) {
  14027. return this.world.addSpring(a instanceof Phaser.Physics.P2.Spring || a instanceof Phaser.Physics.P2.RotationalSpring ? a.data : a), this.onSpringAdded.dispatch(a), a
  14028. },
  14029. removeSpring: function(a) {
  14030. return this.world.removeSpring(a instanceof Phaser.Physics.P2.Spring || a instanceof Phaser.Physics.P2.RotationalSpring ? a.data : a), this.onSpringRemoved.dispatch(a), a
  14031. },
  14032. createDistanceConstraint: function(a, b, c, d, e, f) {
  14033. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.DistanceConstraint(this, a, b, c, d, e, f)) : void console.warn("Cannot create Constraint, invalid body objects given")
  14034. },
  14035. createGearConstraint: function(a, b, c, d) {
  14036. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.GearConstraint(this, a, b, c, d)) : void console.warn("Cannot create Constraint, invalid body objects given")
  14037. },
  14038. createRevoluteConstraint: function(a, b, c, d, e, f) {
  14039. return a = this.getBody(a), c = this.getBody(c), a && c ? this.addConstraint(new Phaser.Physics.P2.RevoluteConstraint(this, a, b, c, d, e, f)) : void console.warn("Cannot create Constraint, invalid body objects given")
  14040. },
  14041. createLockConstraint: function(a, b, c, d, e) {
  14042. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.LockConstraint(this, a, b, c, d, e)) : void console.warn("Cannot create Constraint, invalid body objects given")
  14043. },
  14044. createPrismaticConstraint: function(a, b, c, d, e, f, g) {
  14045. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addConstraint(new Phaser.Physics.P2.PrismaticConstraint(this, a, b, c, d, e, f, g)) : void console.warn("Cannot create Constraint, invalid body objects given")
  14046. },
  14047. addConstraint: function(a) {
  14048. return this.world.addConstraint(a), this.onConstraintAdded.dispatch(a), a
  14049. },
  14050. removeConstraint: function(a) {
  14051. return this.world.removeConstraint(a), this.onConstraintRemoved.dispatch(a), a
  14052. },
  14053. addContactMaterial: function(a) {
  14054. return this.world.addContactMaterial(a), this.onContactMaterialAdded.dispatch(a), a
  14055. },
  14056. removeContactMaterial: function(a) {
  14057. return this.world.removeContactMaterial(a), this.onContactMaterialRemoved.dispatch(a), a
  14058. },
  14059. getContactMaterial: function(a, b) {
  14060. return this.world.getContactMaterial(a, b)
  14061. },
  14062. setMaterial: function(a, b) {
  14063. for (var c = b.length; c--;) b[c].setMaterial(a)
  14064. },
  14065. createMaterial: function(a, b) {
  14066. a = a || "";
  14067. var c = new Phaser.Physics.P2.Material(a);
  14068. return this.materials.push(c), "undefined" != typeof b && b.setMaterial(c), c
  14069. },
  14070. createContactMaterial: function(a, b, c) {
  14071. "undefined" == typeof a && (a = this.createMaterial()), "undefined" == typeof b && (b = this.createMaterial());
  14072. var d = new Phaser.Physics.P2.ContactMaterial(a, b, c);
  14073. return this.addContactMaterial(d)
  14074. },
  14075. getBodies: function() {
  14076. for (var a = [], b = this.world.bodies.length; b--;) a.push(this.world.bodies[b].parent);
  14077. return a
  14078. },
  14079. getBody: function(a) {
  14080. return a instanceof p2.Body ? a : a instanceof Phaser.Physics.P2.Body ? a.data : a.body && a.body.type === Phaser.Physics.P2JS ? a.body.data : null
  14081. },
  14082. getSprings: function() {
  14083. for (var a = [], b = this.world.springs.length; b--;) a.push(this.world.springs[b].parent);
  14084. return a
  14085. },
  14086. getConstraints: function() {
  14087. for (var a = [], b = this.world.constraints.length; b--;) a.push(this.world.constraints[b].parent);
  14088. return a
  14089. },
  14090. hitTest: function(a, b, c, d) {
  14091. "undefined" == typeof b && (b = this.world.bodies), "undefined" == typeof c && (c = 5), "undefined" == typeof d && (d = !1);
  14092. for (var e = [this.pxmi(a.x), this.pxmi(a.y)], f = [], g = b.length; g--;) b[g] instanceof Phaser.Physics.P2.Body && (!d || b[g].data.type !== p2.Body.STATIC) ? f.push(b[g].data) : b[g] instanceof p2.Body && b[g].parent && (!d || b[g].type !== p2.Body.STATIC) ? f.push(b[g]) : b[g] instanceof Phaser.Sprite && b[g].hasOwnProperty("body") && (!d || b[g].body.data.type !== p2.Body.STATIC) && f.push(b[g].body.data);
  14093. return this.world.hitTest(e, f, c)
  14094. },
  14095. toJSON: function() {
  14096. return this.world.toJSON()
  14097. },
  14098. createCollisionGroup: function(a) {
  14099. var b = Math.pow(2, this._collisionGroupID);
  14100. 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++;
  14101. var c = new Phaser.Physics.P2.CollisionGroup(b);
  14102. return this.collisionGroups.push(c), a && this.setCollisionGroup(a, c), c
  14103. },
  14104. setCollisionGroup: function(a, b) {
  14105. if (a instanceof Phaser.Group)
  14106. for (var c = 0; c < a.total; c++) a.children[c].body && a.children[c].body.type === Phaser.Physics.P2JS && a.children[c].body.setCollisionGroup(b);
  14107. else a.body.setCollisionGroup(b)
  14108. },
  14109. createSpring: function(a, b, c, d, e, f, g, h, i) {
  14110. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addSpring(new Phaser.Physics.P2.Spring(this, a, b, c, d, e, f, g, h, i)) : void console.warn("Cannot create Spring, invalid body objects given")
  14111. },
  14112. createRotationalSpring: function(a, b, c, d, e) {
  14113. return a = this.getBody(a), b = this.getBody(b), a && b ? this.addSpring(new Phaser.Physics.P2.RotationalSpring(this, a, b, c, d, e)) : void console.warn("Cannot create Rotational Spring, invalid body objects given")
  14114. },
  14115. createBody: function(a, b, c, d, e, f) {
  14116. "undefined" == typeof d && (d = !1);
  14117. var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
  14118. if (f) {
  14119. var h = g.addPolygon(e, f);
  14120. if (!h) return !1
  14121. }
  14122. return d && this.world.addBody(g.data), g
  14123. },
  14124. createParticle: function(a, b, c, d, e, f) {
  14125. "undefined" == typeof d && (d = !1);
  14126. var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
  14127. if (f) {
  14128. var h = g.addPolygon(e, f);
  14129. if (!h) return !1
  14130. }
  14131. return d && this.world.addBody(g.data), g
  14132. },
  14133. convertCollisionObjects: function(a, b, c) {
  14134. "undefined" == typeof c && (c = !0);
  14135. for (var d = [], e = 0, f = a.collision[b].length; f > e; e++) {
  14136. var g = a.collision[b][e],
  14137. h = this.createBody(g.x, g.y, 0, c, {}, g.polyline);
  14138. h && d.push(h)
  14139. }
  14140. return d
  14141. },
  14142. clearTilemapLayerBodies: function(a, b) {
  14143. b = a.getLayer(b);
  14144. for (var c = a.layers[b].bodies.length; c--;) a.layers[b].bodies[c].destroy();
  14145. a.layers[b].bodies.length = 0
  14146. },
  14147. convertTilemap: function(a, b, c, d) {
  14148. b = a.getLayer(b), "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !0), this.clearTilemapLayerBodies(a, b);
  14149. for (var e = 0, f = 0, g = 0, h = 0, i = a.layers[b].height; i > h; h++) {
  14150. e = 0;
  14151. for (var j = 0, k = a.layers[b].width; k > j; j++) {
  14152. var l = a.layers[b].data[h][j];
  14153. if (l && l.index > -1 && l.collides)
  14154. if (d) {
  14155. var m = a.getTileRight(b, j, h);
  14156. if (0 === e && (f = l.x * l.width, g = l.y * l.height, e = l.width), m && m.collides) e += l.width;
  14157. else {
  14158. var n = this.createBody(f, g, 0, !1);
  14159. n.addRectangle(e, l.height, e / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n), e = 0
  14160. }
  14161. } else {
  14162. var n = this.createBody(l.x * l.width, l.y * l.height, 0, !1);
  14163. n.addRectangle(l.width, l.height, l.width / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n)
  14164. }
  14165. }
  14166. }
  14167. return a.layers[b].bodies
  14168. },
  14169. mpx: function(a) {
  14170. return a *= 20
  14171. },
  14172. pxm: function(a) {
  14173. return .05 * a
  14174. },
  14175. mpxi: function(a) {
  14176. return a *= -20
  14177. },
  14178. pxmi: function(a) {
  14179. return a * -.05
  14180. }
  14181. }, Object.defineProperty(Phaser.Physics.P2.prototype, "friction", {
  14182. get: function() {
  14183. return this.world.defaultContactMaterial.friction
  14184. },
  14185. set: function(a) {
  14186. this.world.defaultContactMaterial.friction = a
  14187. }
  14188. }), Object.defineProperty(Phaser.Physics.P2.prototype, "restitution", {
  14189. get: function() {
  14190. return this.world.defaultContactMaterial.restitution
  14191. },
  14192. set: function(a) {
  14193. this.world.defaultContactMaterial.restitution = a
  14194. }
  14195. }), Object.defineProperty(Phaser.Physics.P2.prototype, "contactMaterial", {
  14196. get: function() {
  14197. return this.world.defaultContactMaterial
  14198. },
  14199. set: function(a) {
  14200. this.world.defaultContactMaterial = a
  14201. }
  14202. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", {
  14203. get: function() {
  14204. return this.world.applySpringForces
  14205. },
  14206. set: function(a) {
  14207. this.world.applySpringForces = a
  14208. }
  14209. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", {
  14210. get: function() {
  14211. return this.world.applyDamping
  14212. },
  14213. set: function(a) {
  14214. this.world.applyDamping = a
  14215. }
  14216. }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", {
  14217. get: function() {
  14218. return this.world.applyGravity
  14219. },
  14220. set: function(a) {
  14221. this.world.applyGravity = a
  14222. }
  14223. }), Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", {
  14224. get: function() {
  14225. return this.world.solveConstraints
  14226. },
  14227. set: function(a) {
  14228. this.world.solveConstraints = a
  14229. }
  14230. }), Object.defineProperty(Phaser.Physics.P2.prototype, "time", {
  14231. get: function() {
  14232. return this.world.time
  14233. }
  14234. }), Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", {
  14235. get: function() {
  14236. return this.world.emitImpactEvent
  14237. },
  14238. set: function(a) {
  14239. this.world.emitImpactEvent = a
  14240. }
  14241. }), Object.defineProperty(Phaser.Physics.P2.prototype, "sleepMode", {
  14242. get: function() {
  14243. return this.world.sleepMode
  14244. },
  14245. set: function(a) {
  14246. this.world.sleepMode = a
  14247. }
  14248. }), Object.defineProperty(Phaser.Physics.P2.prototype, "total", {
  14249. get: function() {
  14250. return this.world.bodies.length
  14251. }
  14252. }), Phaser.Physics.P2.FixtureList = function(a) {
  14253. Array.isArray(a) || (a = [a]), this.rawList = a, this.init(), this.parse(this.rawList)
  14254. }, Phaser.Physics.P2.FixtureList.prototype = {
  14255. init: function() {
  14256. this.namedFixtures = {}, this.groupedFixtures = [], this.allFixtures = []
  14257. },
  14258. setCategory: function(a, b) {
  14259. var c = function(b) {
  14260. b.collisionGroup = a
  14261. };
  14262. this.getFixtures(b).forEach(c)
  14263. },
  14264. setMask: function(a, b) {
  14265. var c = function(b) {
  14266. b.collisionMask = a
  14267. };
  14268. this.getFixtures(b).forEach(c)
  14269. },
  14270. setSensor: function(a, b) {
  14271. var c = function(b) {
  14272. b.sensor = a
  14273. };
  14274. this.getFixtures(b).forEach(c)
  14275. },
  14276. setMaterial: function(a, b) {
  14277. var c = function(b) {
  14278. b.material = a
  14279. };
  14280. this.getFixtures(b).forEach(c)
  14281. },
  14282. getFixtures: function(a) {
  14283. var b = [];
  14284. if (a) {
  14285. a instanceof Array || (a = [a]);
  14286. var c = this;
  14287. return a.forEach(function(a) {
  14288. c.namedFixtures[a] && b.push(c.namedFixtures[a])
  14289. }), this.flatten(b)
  14290. }
  14291. return this.allFixtures
  14292. },
  14293. getFixtureByKey: function(a) {
  14294. return this.namedFixtures[a]
  14295. },
  14296. getGroup: function(a) {
  14297. return this.groupedFixtures[a]
  14298. },
  14299. parse: function() {
  14300. var a, b, c, d;
  14301. c = this.rawList, d = [];
  14302. 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))
  14303. },
  14304. flatten: function(a) {
  14305. var b, c;
  14306. return b = [], c = arguments.callee, a.forEach(function(a) {
  14307. return Array.prototype.push.apply(b, Array.isArray(a) ? c(a) : [a])
  14308. }), b
  14309. }
  14310. }, Phaser.Physics.P2.PointProxy = function(a, b) {
  14311. this.world = a, this.destination = b
  14312. }, Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProxy, Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
  14313. get: function() {
  14314. return this.world.mpx(this.destination[0])
  14315. },
  14316. set: function(a) {
  14317. this.destination[0] = this.world.pxm(a)
  14318. }
  14319. }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
  14320. get: function() {
  14321. return this.world.mpx(this.destination[1])
  14322. },
  14323. set: function(a) {
  14324. this.destination[1] = this.world.pxm(a)
  14325. }
  14326. }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "mx", {
  14327. get: function() {
  14328. return this.destination[0]
  14329. },
  14330. set: function(a) {
  14331. this.destination[0] = a
  14332. }
  14333. }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "my", {
  14334. get: function() {
  14335. return this.destination[1]
  14336. },
  14337. set: function(a) {
  14338. this.destination[1] = a
  14339. }
  14340. }), Phaser.Physics.P2.InversePointProxy = function(a, b) {
  14341. this.world = a, this.destination = b
  14342. }, Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.InversePointProxy, Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
  14343. get: function() {
  14344. return this.world.mpxi(this.destination[0])
  14345. },
  14346. set: function(a) {
  14347. this.destination[0] = this.world.pxmi(a)
  14348. }
  14349. }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
  14350. get: function() {
  14351. return this.world.mpxi(this.destination[1])
  14352. },
  14353. set: function(a) {
  14354. this.destination[1] = this.world.pxmi(a)
  14355. }
  14356. }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "mx", {
  14357. get: function() {
  14358. return this.destination[0]
  14359. },
  14360. set: function(a) {
  14361. this.destination[0] = -a
  14362. }
  14363. }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "my", {
  14364. get: function() {
  14365. return this.destination[1]
  14366. },
  14367. set: function(a) {
  14368. this.destination[1] = -a
  14369. }
  14370. }), Phaser.Physics.P2.Body = function(a, b, c, d, e) {
  14371. b = b || null, c = c || 0, d = d || 0, "undefined" == typeof e && (e = 1), this.game = a, this.world = a.physics.p2, this.sprite = b, this.type = Phaser.Physics.P2JS, this.offset = new Phaser.Point, this.data = new p2.Body({
  14372. position: [this.world.pxmi(c), this.world.pxmi(d)],
  14373. mass: e
  14374. }), this.data.parent = this, this.velocity = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.velocity), this.force = new Phaser.Physics.P2.InversePointProxy(this.world, this.data.force), this.gravity = new Phaser.Point, this.onBeginContact = new Phaser.Signal, this.onEndContact = new Phaser.Signal, this.collidesWith = [], this.removeNextStep = !1, this.debugBody = null, this._collideWorldBounds = !0, this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, b && (this.setRectangleFromSprite(b), b.exists && this.game.physics.p2.addBody(this))
  14375. }, Phaser.Physics.P2.Body.prototype = {
  14376. createBodyCallback: function(a, b, c) {
  14377. var d = -1;
  14378. 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))
  14379. },
  14380. createGroupCallback: function(a, b, c) {
  14381. null === b ? (delete this._groupCallbacks[a.mask], delete this._groupCallbacksContext[a.mask]) : (this._groupCallbacks[a.mask] = b, this._groupCallbackContext[a.mask] = c)
  14382. },
  14383. getCollisionMask: function() {
  14384. var a = 0;
  14385. this._collideWorldBounds && (a = this.game.physics.p2.boundsCollisionGroup.mask);
  14386. for (var b = 0; b < this.collidesWith.length; b++) a |= this.collidesWith[b].mask;
  14387. return a
  14388. },
  14389. updateCollisionMask: function(a) {
  14390. var b = this.getCollisionMask();
  14391. if ("undefined" == typeof a)
  14392. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].collisionMask = b;
  14393. else a.collisionMask = b
  14394. },
  14395. setCollisionGroup: function(a, b) {
  14396. var c = this.getCollisionMask();
  14397. if ("undefined" == typeof b)
  14398. for (var d = this.data.shapes.length - 1; d >= 0; d--) this.data.shapes[d].collisionGroup = a.mask, this.data.shapes[d].collisionMask = c;
  14399. else b.collisionGroup = a.mask, b.collisionMask = c
  14400. },
  14401. clearCollision: function(a, b, c) {
  14402. if ("undefined" == typeof c)
  14403. 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);
  14404. else a && (c.collisionGroup = null), b && (c.collisionMask = null);
  14405. a && (this.collidesWith.length = 0)
  14406. },
  14407. collides: function(a, b, c, d) {
  14408. if (Array.isArray(a))
  14409. 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));
  14410. else -1 === this.collidesWith.indexOf(a) && (this.collidesWith.push(a), b && this.createGroupCallback(a, b, c));
  14411. var f = this.getCollisionMask();
  14412. if ("undefined" == typeof d)
  14413. for (var e = this.data.shapes.length - 1; e >= 0; e--) this.data.shapes[e].collisionMask = f;
  14414. else d.collisionMask = f
  14415. },
  14416. adjustCenterOfMass: function() {
  14417. this.data.adjustCenterOfMass()
  14418. },
  14419. applyDamping: function(a) {
  14420. this.data.applyDamping(a)
  14421. },
  14422. applyForce: function(a, b, c) {
  14423. this.data.applyForce(a, [this.world.pxmi(b), this.world.pxmi(c)])
  14424. },
  14425. setZeroForce: function() {
  14426. this.data.setZeroForce()
  14427. },
  14428. setZeroRotation: function() {
  14429. this.data.angularVelocity = 0
  14430. },
  14431. setZeroVelocity: function() {
  14432. this.data.velocity[0] = 0, this.data.velocity[1] = 0
  14433. },
  14434. setZeroDamping: function() {
  14435. this.data.damping = 0, this.data.angularDamping = 0
  14436. },
  14437. toLocalFrame: function(a, b) {
  14438. return this.data.toLocalFrame(a, b)
  14439. },
  14440. toWorldFrame: function(a, b) {
  14441. return this.data.toWorldFrame(a, b)
  14442. },
  14443. rotateLeft: function(a) {
  14444. this.data.angularVelocity = this.world.pxm(-a)
  14445. },
  14446. rotateRight: function(a) {
  14447. this.data.angularVelocity = this.world.pxm(a)
  14448. },
  14449. moveForward: function(a) {
  14450. var b = this.world.pxmi(-a),
  14451. c = this.data.angle + Math.PI / 2;
  14452. this.data.velocity[0] = b * Math.cos(c), this.data.velocity[1] = b * Math.sin(c)
  14453. },
  14454. moveBackward: function(a) {
  14455. var b = this.world.pxmi(-a),
  14456. c = this.data.angle + Math.PI / 2;
  14457. this.data.velocity[0] = -(b * Math.cos(c)), this.data.velocity[1] = -(b * Math.sin(c))
  14458. },
  14459. thrust: function(a) {
  14460. var b = this.world.pxmi(-a),
  14461. c = this.data.angle + Math.PI / 2;
  14462. this.data.force[0] += b * Math.cos(c), this.data.force[1] += b * Math.sin(c)
  14463. },
  14464. reverse: function(a) {
  14465. var b = this.world.pxmi(-a),
  14466. c = this.data.angle + Math.PI / 2;
  14467. this.data.force[0] -= b * Math.cos(c), this.data.force[1] -= b * Math.sin(c)
  14468. },
  14469. moveLeft: function(a) {
  14470. this.data.velocity[0] = this.world.pxmi(-a)
  14471. },
  14472. moveRight: function(a) {
  14473. this.data.velocity[0] = this.world.pxmi(a)
  14474. },
  14475. moveUp: function(a) {
  14476. this.data.velocity[1] = this.world.pxmi(-a)
  14477. },
  14478. moveDown: function(a) {
  14479. this.data.velocity[1] = this.world.pxmi(a)
  14480. },
  14481. preUpdate: function() {
  14482. this.removeNextStep && (this.removeFromWorld(), this.removeNextStep = !1)
  14483. },
  14484. postUpdate: function() {
  14485. 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)
  14486. },
  14487. reset: function(a, b, c, d) {
  14488. "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
  14489. },
  14490. addToWorld: function() {
  14491. if (this.game.physics.p2._toRemove)
  14492. 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);
  14493. this.data.world !== this.game.physics.p2.world && this.game.physics.p2.addBody(this)
  14494. },
  14495. removeFromWorld: function() {
  14496. this.data.world === this.game.physics.p2.world && this.game.physics.p2.removeBodyNextStep(this)
  14497. },
  14498. destroy: function() {
  14499. this.removeFromWorld(), this.clearShapes(), this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this.debugBody && this.debugBody.destroy(), this.debugBody = null, this.sprite.body = null, this.sprite = null
  14500. },
  14501. clearShapes: function() {
  14502. for (var a = this.data.shapes.length; a--;) this.data.removeShape(this.data.shapes[a]);
  14503. this.shapeChanged()
  14504. },
  14505. addShape: function(a, b, c, d) {
  14506. 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
  14507. },
  14508. addCircle: function(a, b, c, d) {
  14509. var e = new p2.Circle(this.world.pxm(a));
  14510. return this.addShape(e, b, c, d)
  14511. },
  14512. addRectangle: function(a, b, c, d, e) {
  14513. var f = new p2.Rectangle(this.world.pxm(a), this.world.pxm(b));
  14514. return this.addShape(f, c, d, e)
  14515. },
  14516. addPlane: function(a, b, c) {
  14517. var d = new p2.Plane;
  14518. return this.addShape(d, a, b, c)
  14519. },
  14520. addParticle: function(a, b, c) {
  14521. var d = new p2.Particle;
  14522. return this.addShape(d, a, b, c)
  14523. },
  14524. addLine: function(a, b, c, d) {
  14525. var e = new p2.Line(this.world.pxm(a));
  14526. return this.addShape(e, b, c, d)
  14527. },
  14528. addCapsule: function(a, b, c, d, e) {
  14529. var f = new p2.Capsule(this.world.pxm(a), this.world.pxm(b));
  14530. return this.addShape(f, c, d, e)
  14531. },
  14532. addPolygon: function(a, b) {
  14533. a = a || {}, Array.isArray(b) || (b = Array.prototype.slice.call(arguments, 1));
  14534. var c = [];
  14535. if (1 === b.length && Array.isArray(b[0])) c = b[0].slice(0);
  14536. else if (Array.isArray(b[0])) c = b.slice();
  14537. else if ("number" == typeof b[0])
  14538. for (var d = 0, e = b.length; e > d; d += 2) c.push([b[d], b[d + 1]]);
  14539. var f = c.length - 1;
  14540. c[f][0] === c[0][0] && c[f][1] === c[0][1] && c.pop();
  14541. 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]);
  14542. var h = this.data.fromPolygon(c, a);
  14543. return this.shapeChanged(), h
  14544. },
  14545. removeShape: function(a) {
  14546. var b = this.data.removeShape(a);
  14547. return this.shapeChanged(), b
  14548. },
  14549. setCircle: function(a, b, c, d) {
  14550. return this.clearShapes(), this.addCircle(a, b, c, d)
  14551. },
  14552. setRectangle: function(a, b, c, d, e) {
  14553. return "undefined" == typeof a && (a = 16), "undefined" == typeof b && (b = 16), this.clearShapes(), this.addRectangle(a, b, c, d, e)
  14554. },
  14555. setRectangleFromSprite: function(a) {
  14556. return "undefined" == typeof a && (a = this.sprite), this.clearShapes(), this.addRectangle(a.width, a.height, 0, 0, a.rotation)
  14557. },
  14558. setMaterial: function(a, b) {
  14559. if ("undefined" == typeof b)
  14560. for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].material = a;
  14561. else b.material = a
  14562. },
  14563. shapeChanged: function() {
  14564. this.debugBody && this.debugBody.draw()
  14565. },
  14566. addPhaserPolygon: function(a, b) {
  14567. for (var c = this.game.cache.getPhysicsData(a, b), d = [], e = 0; e < c.length; e++) {
  14568. var f = c[e],
  14569. g = this.addFixture(f);
  14570. d[f.filter.group] = d[f.filter.group] || [], d[f.filter.group] = d[f.filter.group].concat(g), f.fixtureKey && (d[f.fixtureKey] = g)
  14571. }
  14572. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), d
  14573. },
  14574. addFixture: function(a) {
  14575. var b = [];
  14576. if (a.circle) {
  14577. var c = new p2.Circle(this.world.pxm(a.circle.radius));
  14578. c.collisionGroup = a.filter.categoryBits, c.collisionMask = a.filter.maskBits, c.sensor = a.isSensor;
  14579. var d = p2.vec2.create();
  14580. 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)
  14581. } else
  14582. for (var e = a.polygons, f = p2.vec2.create(), g = 0; g < e.length; g++) {
  14583. 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])]);
  14584. for (var c = new p2.Convex(i), k = 0; k !== c.vertices.length; k++) {
  14585. var l = c.vertices[k];
  14586. p2.vec2.sub(l, l, c.centerOfMass)
  14587. }
  14588. 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)
  14589. }
  14590. return b
  14591. },
  14592. loadPolygon: function(a, b) {
  14593. for (var c = this.game.cache.getPhysicsData(a, b), d = p2.vec2.create(), e = 0; e < c.length; e++) {
  14594. 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])]);
  14595. for (var h = new p2.Convex(f), i = 0; i !== h.vertices.length; i++) {
  14596. var j = h.vertices[i];
  14597. p2.vec2.sub(j, j, h.centerOfMass)
  14598. }
  14599. 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)
  14600. }
  14601. return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), !0
  14602. }
  14603. }, Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body, Phaser.Physics.P2.Body.DYNAMIC = 1, Phaser.Physics.P2.Body.STATIC = 2, Phaser.Physics.P2.Body.KINEMATIC = 4, Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
  14604. get: function() {
  14605. return this.data.type === Phaser.Physics.P2.Body.STATIC
  14606. },
  14607. set: function(a) {
  14608. a && this.data.type !== Phaser.Physics.P2.Body.STATIC ? (this.data.type = Phaser.Physics.P2.Body.STATIC, this.mass = 0) : a || this.data.type !== Phaser.Physics.P2.Body.STATIC || (this.data.type = Phaser.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1))
  14609. }
  14610. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
  14611. get: function() {
  14612. return this.data.type === Phaser.Physics.P2.Body.DYNAMIC
  14613. },
  14614. set: function(a) {
  14615. a && this.data.type !== Phaser.Physics.P2.Body.DYNAMIC ? (this.data.type = Phaser.Physics.P2.Body.DYNAMIC, 0 === this.mass && (this.mass = 1)) : a || this.data.type !== Phaser.Physics.P2.Body.DYNAMIC || (this.data.type = Phaser.Physics.P2.Body.STATIC, this.mass = 0)
  14616. }
  14617. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
  14618. get: function() {
  14619. return this.data.type === Phaser.Physics.P2.Body.KINEMATIC
  14620. },
  14621. set: function(a) {
  14622. a && this.data.type !== Phaser.Physics.P2.Body.KINEMATIC ? (this.data.type = Phaser.Physics.P2.Body.KINEMATIC, this.mass = 4) : a || this.data.type !== Phaser.Physics.P2.Body.KINEMATIC || (this.data.type = Phaser.Physics.P2.Body.STATIC, this.mass = 0)
  14623. }
  14624. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
  14625. get: function() {
  14626. return this.data.allowSleep
  14627. },
  14628. set: function(a) {
  14629. a !== this.data.allowSleep && (this.data.allowSleep = a)
  14630. }
  14631. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angle", {
  14632. get: function() {
  14633. return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.data.angle))
  14634. },
  14635. set: function(a) {
  14636. this.data.angle = Phaser.Math.degToRad(Phaser.Math.wrapAngle(a))
  14637. }
  14638. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
  14639. get: function() {
  14640. return this.data.angularDamping
  14641. },
  14642. set: function(a) {
  14643. this.data.angularDamping = a
  14644. }
  14645. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
  14646. get: function() {
  14647. return this.data.angularForce
  14648. },
  14649. set: function(a) {
  14650. this.data.angularForce = a
  14651. }
  14652. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
  14653. get: function() {
  14654. return this.data.angularVelocity
  14655. },
  14656. set: function(a) {
  14657. this.data.angularVelocity = a
  14658. }
  14659. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
  14660. get: function() {
  14661. return this.data.damping
  14662. },
  14663. set: function(a) {
  14664. this.data.damping = a
  14665. }
  14666. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
  14667. get: function() {
  14668. return this.data.fixedRotation
  14669. },
  14670. set: function(a) {
  14671. a !== this.data.fixedRotation && (this.data.fixedRotation = a)
  14672. }
  14673. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
  14674. get: function() {
  14675. return this.data.inertia
  14676. },
  14677. set: function(a) {
  14678. this.data.inertia = a
  14679. }
  14680. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
  14681. get: function() {
  14682. return this.data.mass
  14683. },
  14684. set: function(a) {
  14685. a !== this.data.mass && (this.data.mass = a, this.data.updateMassProperties())
  14686. }
  14687. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
  14688. get: function() {
  14689. return this.data.type
  14690. },
  14691. set: function(a) {
  14692. a !== this.data.type && (this.data.type = a)
  14693. }
  14694. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "rotation", {
  14695. get: function() {
  14696. return this.data.angle
  14697. },
  14698. set: function(a) {
  14699. this.data.angle = a
  14700. }
  14701. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
  14702. get: function() {
  14703. return this.data.sleepSpeedLimit
  14704. },
  14705. set: function(a) {
  14706. this.data.sleepSpeedLimit = a
  14707. }
  14708. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
  14709. get: function() {
  14710. return this.world.mpxi(this.data.position[0])
  14711. },
  14712. set: function(a) {
  14713. this.data.position[0] = this.world.pxmi(a)
  14714. }
  14715. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
  14716. get: function() {
  14717. return this.world.mpxi(this.data.position[1])
  14718. },
  14719. set: function(a) {
  14720. this.data.position[1] = this.world.pxmi(a)
  14721. }
  14722. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
  14723. get: function() {
  14724. return this.data.id
  14725. }
  14726. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
  14727. get: function() {
  14728. return null !== this.debugBody
  14729. },
  14730. set: function(a) {
  14731. a && !this.debugBody ? this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data) : !a && this.debugBody && (this.debugBody.destroy(), this.debugBody = null)
  14732. }
  14733. }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "collideWorldBounds", {
  14734. get: function() {
  14735. return this._collideWorldBounds
  14736. },
  14737. set: function(a) {
  14738. a && !this._collideWorldBounds ? (this._collideWorldBounds = !0, this.updateCollisionMask()) : !a && this._collideWorldBounds && (this._collideWorldBounds = !1, this.updateCollisionMask())
  14739. }
  14740. }), Phaser.Physics.P2.BodyDebug = function(a, b, c) {
  14741. Phaser.Group.call(this, a);
  14742. var d = {
  14743. pixelsPerLengthUnit: 20,
  14744. debugPolygons: !1,
  14745. lineWidth: 1,
  14746. alpha: .5
  14747. };
  14748. this.settings = Phaser.Utils.extend(d, c), this.ppu = this.settings.pixelsPerLengthUnit, this.ppu = -1 * this.ppu, this.body = b, this.canvas = new Phaser.Graphics(a), this.canvas.alpha = this.settings.alpha, this.add(this.canvas), this.draw()
  14749. }, Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype), Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug, Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
  14750. update: function() {
  14751. this.updateSpriteTransform()
  14752. },
  14753. updateSpriteTransform: function() {
  14754. return this.position.x = this.body.position[0] * this.ppu, this.position.y = this.body.position[1] * this.ppu, this.rotation = this.body.angle
  14755. },
  14756. draw: function() {
  14757. var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o;
  14758. 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) {
  14759. var p = h.shapes.length;
  14760. for (d = 0; d !== p;) {
  14761. 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);
  14762. else if (b instanceof p2.Convex) {
  14763. 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]);
  14764. this.drawConvex(j, l, b.triangles, f, c, g, this.settings.debugPolygons, [i[0] * this.ppu, -i[1] * this.ppu])
  14765. } else b instanceof p2.Plane ? this.drawPlane(j, i[0] * this.ppu, -i[1] * this.ppu, c, f, 5 * g, 10 * g, 10 * g, 100 * this.ppu, a) : b instanceof p2.Line ? this.drawLine(j, b.length * this.ppu, f, g) : b instanceof p2.Rectangle && this.drawRectangle(j, i[0] * this.ppu, -i[1] * this.ppu, a, b.width * this.ppu, b.height * this.ppu, f, c, g);
  14766. d++
  14767. }
  14768. }
  14769. },
  14770. drawRectangle: function(a, b, c, d, e, f, g, h, i) {
  14771. "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)
  14772. },
  14773. drawCircle: function(a, b, c, d, e, f, g) {
  14774. "undefined" == typeof g && (g = 1), "undefined" == typeof f && (f = 16777215), a.lineStyle(g, 0, 1), a.beginFill(f, 1), a.drawCircle(b, c, -e), a.endFill(), a.moveTo(b, c), a.lineTo(b + e * Math.cos(-d), c + e * Math.sin(-d))
  14775. },
  14776. drawLine: function(a, b, c, d) {
  14777. "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)
  14778. },
  14779. drawConvex: function(a, b, c, d, e, f, g, h) {
  14780. var i, j, k, l, m, n, o, p, q, r, s;
  14781. if ("undefined" == typeof f && (f = 1), "undefined" == typeof d && (d = 0), g) {
  14782. 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++;
  14783. return a.lineStyle(f, 0, 1), a.drawCircle(h[0], h[1], 2 * f)
  14784. }
  14785. 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++;
  14786. 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
  14787. },
  14788. drawPath: function(a, b, c, d, e) {
  14789. var f, g, h, i, j, k, l, m, n, o, p, q, r;
  14790. 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++;
  14791. "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]))
  14792. },
  14793. drawPlane: function(a, b, c, d, e, f, g, h, i, j) {
  14794. var k, l, m;
  14795. "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)
  14796. },
  14797. randomPastelHex: function() {
  14798. var a, b, c, d;
  14799. 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)
  14800. },
  14801. rgbToHex: function(a, b, c) {
  14802. return this.componentToHex(a) + this.componentToHex(b) + this.componentToHex(c)
  14803. },
  14804. componentToHex: function(a) {
  14805. var b;
  14806. return b = a.toString(16), 2 === b.len ? b : b + "0"
  14807. }
  14808. }), Phaser.Physics.P2.Spring = function(a, b, c, d, e, f, g, h, i, j) {
  14809. 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);
  14810. var k = {
  14811. restLength: d,
  14812. stiffness: e,
  14813. damping: f
  14814. };
  14815. "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
  14816. }, Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring, Phaser.Physics.P2.RotationalSpring = function(a, b, c, d, e, f) {
  14817. 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));
  14818. var g = {
  14819. restAngle: d,
  14820. stiffness: e,
  14821. damping: f
  14822. };
  14823. this.data = new p2.RotationalSpring(b, c, g), this.data.parent = this
  14824. }, Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring, Phaser.Physics.P2.Material = function(a) {
  14825. this.name = a, p2.Material.call(this)
  14826. }, Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype), Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material, Phaser.Physics.P2.ContactMaterial = function(a, b, c) {
  14827. p2.ContactMaterial.call(this, a, b, c)
  14828. }, Phaser.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype), Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial, Phaser.Physics.P2.CollisionGroup = function(a) {
  14829. this.mask = a
  14830. }, Phaser.Physics.P2.DistanceConstraint = function(a, b, c, d, e, f, g) {
  14831. "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])];
  14832. var h = {
  14833. distance: d,
  14834. localAnchorA: e,
  14835. localAnchorB: f,
  14836. maxForce: g
  14837. };
  14838. p2.DistanceConstraint.call(this, b, c, h)
  14839. }, Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype), Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint, Phaser.Physics.P2.GearConstraint = function(a, b, c, d, e) {
  14840. "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 1), this.game = a.game, this.world = a;
  14841. var f = {
  14842. angle: d,
  14843. ratio: e
  14844. };
  14845. p2.GearConstraint.call(this, b, c, f)
  14846. }, Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype), Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint, Phaser.Physics.P2.LockConstraint = function(a, b, c, d, e, f) {
  14847. "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])];
  14848. var g = {
  14849. localOffsetB: d,
  14850. localAngleB: e,
  14851. maxForce: f
  14852. };
  14853. p2.LockConstraint.call(this, b, c, g)
  14854. }, Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype), Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint, Phaser.Physics.P2.PrismaticConstraint = function(a, b, c, d, e, f, g, h) {
  14855. "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])];
  14856. var i = {
  14857. localAnchorA: e,
  14858. localAnchorB: f,
  14859. localAxisA: g,
  14860. maxForce: h,
  14861. disableRotationalLock: !d
  14862. };
  14863. p2.PrismaticConstraint.call(this, b, c, i)
  14864. }, Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype), Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint, Phaser.Physics.P2.RevoluteConstraint = function(a, b, c, d, e, f, g) {
  14865. "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])]);
  14866. var h = {
  14867. worldPivot: g,
  14868. localPivotA: c,
  14869. localPivotB: e,
  14870. maxForce: f
  14871. };
  14872. p2.RevoluteConstraint.call(this, b, d, h)
  14873. }, Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype), Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
  14874. (function() {
  14875. 'use strict';
  14876. var isCommonjs = typeof module !== 'undefined' && module.exports;
  14877. var adInterstitialProvider = 'none';
  14878. var adBannerProvider = 'none';
  14879. var adInterstitialProviderDefault = 'none';
  14880. var adBannerProviderDefault = 'none';
  14881. var responseObj = null;
  14882. var adserver = {
  14883. readServerResponse: function(obj) {
  14884. responseObj = obj;
  14885. if (obj.banner) {
  14886. if (obj.banner.provider == 'self') {
  14887. adBannerProvider = 'self'
  14888. } else if (obj.banner.provider) {
  14889. adBannerProvider = obj.banner.provider
  14890. } else {
  14891. adBannerProvider = 'leadbolt'
  14892. }
  14893. } else {
  14894. adBannerProvider = adBannerProviderDefault
  14895. }
  14896. if (obj.interstitial) {
  14897. if (obj.interstitial.provider == 'self') {
  14898. adInterstitialProvider = 'self'
  14899. } else if (obj.interstitial.provider) {
  14900. adInterstitialProvider = obj.interstitial.provider
  14901. } else {
  14902. adInterstitialProvider = 'leadbolt'
  14903. }
  14904. } else {
  14905. adInterstitialProvider = adInterstitialProviderDefault
  14906. }
  14907. },
  14908. initialize: function(onready, onerror, gameID) {
  14909. var params = '';
  14910. if (gameID === undefined) {
  14911. params = ''
  14912. } else {
  14913. params = '?g=' + gameID.toString()
  14914. }
  14915. var req = new XMLHttpRequest();
  14916. req.open('GET', '#' + params, true); /*Paste your ad link here*/
  14917. req.timeout = 3000;
  14918. req.onload = function() {
  14919. if (req.readyState == 4 && req.status == 200) {
  14920. adserver.readServerResponse(JSON.parse(req.responseText));
  14921. onready.call()
  14922. } else {
  14923. onerror.call()
  14924. }
  14925. };
  14926. req.ontimeout = onerror;
  14927. req.onerror = onerror;
  14928. req.onabort = onerror;
  14929. req.send()
  14930. }
  14931. };
  14932. Object.defineProperties(adserver, {
  14933. interstitialProvider: {
  14934. get: function() {
  14935. return adInterstitialProvider
  14936. }
  14937. },
  14938. bannerProvider: {
  14939. get: function() {
  14940. return adBannerProvider
  14941. }
  14942. },
  14943. responseObject: {
  14944. get: function() {
  14945. return responseObj
  14946. }
  14947. }
  14948. });
  14949. if (isCommonjs) {
  14950. module.exports = adserver
  14951. } else {
  14952. window.adserver = adserver
  14953. }
  14954. })();
  14955. (function() {
  14956. 'use strict';
  14957. var isCommonjs = typeof module !== 'undefined' && module.exports;
  14958. var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
  14959. var fn = (function() {
  14960. var val;
  14961. var valLength;
  14962. var fnMap = [
  14963. ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
  14964. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  14965. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  14966. ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
  14967. ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']
  14968. ];
  14969. var i = 0;
  14970. var l = fnMap.length;
  14971. var ret = {};
  14972. for (; i < l; i++) {
  14973. val = fnMap[i];
  14974. if (val && val[1] in document) {
  14975. for (i = 0, valLength = val.length; i < valLength; i++) {
  14976. ret[fnMap[0][i]] = val[i]
  14977. }
  14978. return ret
  14979. }
  14980. }
  14981. return false
  14982. })();
  14983. var screenfull = {
  14984. request: function(elem) {
  14985. var request = fn.requestFullscreen;
  14986. elem = elem || document.documentElement;
  14987. if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
  14988. elem[request]()
  14989. } else {
  14990. elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT)
  14991. }
  14992. },
  14993. exit: function() {
  14994. document[fn.exitFullscreen]()
  14995. },
  14996. toggle: function(elem) {
  14997. if (this.isFullscreen) {
  14998. this.exit()
  14999. } else {
  15000. this.request(elem)
  15001. }
  15002. },
  15003. onchange: function() {},
  15004. onerror: function() {},
  15005. raw: fn
  15006. };
  15007. if (!fn) {
  15008. if (isCommonjs) {
  15009. module.exports = false
  15010. } else {
  15011. window.screenfull = false
  15012. }
  15013. return
  15014. }
  15015. Object.defineProperties(screenfull, {
  15016. isFullscreen: {
  15017. get: function() {
  15018. return !!document[fn.fullscreenElement]
  15019. }
  15020. },
  15021. element: {
  15022. enumerable: true,
  15023. get: function() {
  15024. return document[fn.fullscreenElement]
  15025. }
  15026. },
  15027. enabled: {
  15028. enumerable: true,
  15029. get: function() {
  15030. return !!document[fn.fullscreenEnabled]
  15031. }
  15032. }
  15033. });
  15034. document.addEventListener(fn.fullscreenchange, function(e) {
  15035. screenfull.onchange.call(screenfull, e)
  15036. });
  15037. document.addEventListener(fn.fullscreenerror, function(e) {
  15038. screenfull.onerror.call(screenfull, e)
  15039. });
  15040. if (isCommonjs) {
  15041. module.exports = screenfull
  15042. } else {
  15043. window.screenfull = screenfull
  15044. }
  15045. })();
  15046. (function() {
  15047. var BasicGame = {};
  15048. var GC = {};
  15049. GC.totalLevels = 27;
  15050. GC.FullScreenEnabled = false;
  15051. GC.playSound = true;
  15052. GC.soundDisabled = false;
  15053. BasicGame.stateFirst = 'state_menu';
  15054. BasicGame.loadPreTextured = true;
  15055. BasicGame.previewMode = false;
  15056. BasicGame.showSponsor = false;
  15057. BasicGame.winStarsCurrent = 0;
  15058. BasicGame.winStarsPrevious = 0;
  15059. BasicGame.debug = false;
  15060. BasicGame.debugPhysics = false;
  15061. BasicGame.currentLevel = 0;
  15062. BasicGame.Levels = new Array(GC.totalLevels);
  15063. BasicGame.LevelStarShots = new Array(GC.totalLevels);
  15064. BasicGame.LevelStars = [];
  15065. BasicGame.LevelsOpen = [];
  15066. BasicGame.sndMenuLoop = null;
  15067. BasicGame.sndGameLoop = null;
  15068. BasicGame.linkAppStore = 'http://www.play68.com'//'http://www.yiv.com';
  15069. BasicGame.linkAndroid = 'http://www.play68.com'//'http://www.yiv.com';
  15070. BasicGame.linkWinPhone = 'http://www.play68.com'//'http://www.yiv.com';
  15071. BasicGame.linkDownloadPage = 'http://www.play68.com'//'http://www.yiv.com';
  15072. function btnDownloadsPressed() {
  15073. _czc.push(["_trackEvent","小虎回家","更多游戏","","",""]);
  15074. if(document.referrer)
  15075. Play68.goHome();
  15076. else
  15077. play68_goHome();
  15078. // if (game.device.desktop) {
  15079. // window.open(BasicGame.linkDownloadPage, '_blank')
  15080. // } else if (this.game.device.android) {
  15081. // window.open(BasicGame.linkAndroid)
  15082. // } else if (this.game.device.iOS) {
  15083. // window.open(BasicGame.linkDownloadPage, '_blank')
  15084. // } else if (this.game.device.windowsPhone) {
  15085. // window.open(BasicGame.linkWinPhone)
  15086. // } else {
  15087. // window.open(BasicGame.linkWinPhone, '_blank')
  15088. // }
  15089. };
  15090. BasicGame.saveGame = function() {
  15091. if (typeof(Storage) !== "undefined") {
  15092. try {
  15093. var levelStars = [],totalLevelStars=0;
  15094. var i = 0;
  15095. for (i = 0; i < GC.totalLevels; i++) {
  15096. levelStars[i] = BasicGame.LevelStars[i]
  15097. if(i<(BasicGame.currentLevel+1))
  15098. totalLevelStars+=BasicGame.LevelStars[i];
  15099. }
  15100. window.localStorage.removeItem('foxystars');
  15101. window.localStorage.setItem('foxystars', levelStars);
  15102. var levelsOpen = [];
  15103. for (i = 0; i < GC.totalLevels; i++) {
  15104. levelsOpen[i] = BasicGame.LevelsOpen[i]
  15105. }
  15106. window.localStorage.removeItem('foxylevels');
  15107. window.localStorage.setItem('foxylevels', levelsOpen)
  15108. updateShare(BasicGame.currentLevel+1,totalLevelStars);
  15109. Play68.setRankingLevelScoreDesc(BasicGame.currentLevel+1,totalLevelStars);
  15110. console.log(BasicGame.currentLevel+1,totalLevelStars)
  15111. } catch (err) {}
  15112. }
  15113. };
  15114. BasicGame.loadGame = function() {
  15115. if (typeof(Storage) !== "undefined") {
  15116. try {
  15117. var levelStars = window.localStorage.getItem('foxystars');
  15118. var i = 0;
  15119. if (levelStars) {
  15120. levelStars = levelStars.split(',');
  15121. for (i = 0; i < GC.totalLevels; i++) {
  15122. BasicGame.LevelStars[i] = parseInt(levelStars[i], 10)
  15123. }
  15124. } else {
  15125. for (i = 0; i < GC.totalLevels; i++) {
  15126. BasicGame.LevelStars[i] = 0
  15127. }
  15128. }
  15129. var levelsOpen = window.localStorage.getItem('foxylevels');
  15130. if (levelsOpen) {
  15131. levelsOpen = levelsOpen.split(',');
  15132. for (i = 0; i < GC.totalLevels; i++) {
  15133. BasicGame.LevelsOpen[i] = parseInt(levelsOpen[i], 10)
  15134. }
  15135. } else {
  15136. BasicGame.LevelsOpen[0] = 1;
  15137. for (i = 1; i < GC.totalLevels; i++) {
  15138. BasicGame.LevelsOpen[i] = 0
  15139. }
  15140. }
  15141. } catch (err) {
  15142. for (var i = 0; i < GC.totalLevels; i++) {
  15143. BasicGame.LevelStars[i] = 0
  15144. }
  15145. BasicGame.LevelsOpen[0] = 1;
  15146. for (i = 1; i < GC.totalLevels; i++) {
  15147. BasicGame.LevelsOpen[i] = 0
  15148. }
  15149. }
  15150. } else {
  15151. for (var i = 0; i < GC.totalLevels; i++) {
  15152. BasicGame.LevelStars[i] = 0
  15153. }
  15154. BasicGame.LevelsOpen[0] = 1;
  15155. for (i = 1; i < GC.totalLevels; i++) {
  15156. BasicGame.LevelsOpen[i] = 0
  15157. }
  15158. }
  15159. };
  15160. BasicGame.clearAllData = function() {
  15161. BasicGame.LevelStars[0] = 0;
  15162. BasicGame.LevelsOpen[0] = 1;
  15163. for (var i = 1; i < GC.totalLevels; i++) {
  15164. BasicGame.LevelsOpen[i] = BasicGame.LevelStars[i] = 0
  15165. }
  15166. BasicGame.saveGame()
  15167. };
  15168. BasicGame.openAllLevels = function() {
  15169. for (var i = 0; i < GC.totalLevels; i++) {
  15170. BasicGame.LevelsOpen[i] = 1
  15171. }
  15172. BasicGame.saveGame()
  15173. };
  15174. var desiredOrientation = 'portrait';
  15175. var orientationGoodAtFirst = false;
  15176. var orientReload = false;
  15177. var noMoreReload = false;
  15178. BasicGame.StateBoot = function() {};
  15179. BasicGame.StateBoot.prototype = {
  15180. preload: function() {
  15181. BasicGame.loadGame();
  15182. this.game.load.bitmapFont('grobold_loading', 'assets/fonts/grobold_loading_0.png', 'assets/fonts/grobold_loading.fnt');
  15183. this.game.load.atlas('atlas_preloader', 'assets/graphics/preloader_assets.png', 'assets/graphics/preloader_assets.json');
  15184. this.game.load.onLoadComplete.addOnce(this.loadingCompleted, this);
  15185. this.bootBd = this.make.bitmapData(this.game.width - 30, 10);
  15186. this.bootBd.addToWorld(15, this.game.height / 2 - 5);
  15187. this.bootBd.context.fillStyle = '#383838';
  15188. GC.FullScreenEnabled = (this.game.device.desktop && screenfull.enabled);
  15189. if (GC.FullScreenEnabled) {
  15190. document.addEventListener(screenfull.raw.fullscreenchange, screenFullResize)
  15191. }
  15192. this.setupScaling();
  15193. if (BasicGame.debug) {
  15194. this.game.add.plugin(Phaser.Plugin.Debug)
  15195. }
  15196. this.world.setBounds(-200, -200, this.game.width + 400, this.game.height + 400);
  15197. this.world.camera.position.x = 0;
  15198. this.world.camera.position.y = 0;
  15199. this.game.physics.startSystem(Phaser.Physics.P2JS)
  15200. },
  15201. create: function() {
  15202. //initAds()
  15203. },
  15204. update: function() {
  15205. if (this.load.progress > 0) {
  15206. this.bootBd.context.fillRect(0, 0, this.bootBd.width * (this.load.progress / 100), 10);
  15207. this.bootBd.dirty = true
  15208. }
  15209. },
  15210. setupScaling: function() {
  15211. if (this.game.device.desktop) {
  15212. this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
  15213. this.scale.pageAlignHorizontally = true;
  15214. this.scale.pageAlignVertically = true;
  15215. this.scale.setScreenSize();
  15216. this.scale.refresh()
  15217. } else {
  15218. if (desiredOrientation == 'landscape') {
  15219. if (window.innerWidth > window.innerHeight) {
  15220. orientationGoodAtFirst = true
  15221. }
  15222. } else if (desiredOrientation == 'portrait') {
  15223. if (window.innerWidth < window.innerHeight) {
  15224. orientationGoodAtFirst = true
  15225. }
  15226. }
  15227. this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
  15228. this.scale.pageAlignHorizontally = true;
  15229. this.scale.pageAlignVertically = true;
  15230. this.scale.forceOrientation(false, true);
  15231. this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);
  15232. this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);
  15233. this.scale.setScreenSize();
  15234. this.scale.refresh()
  15235. }
  15236. },
  15237. enterIncorrectOrientation: function() {
  15238. if (!orientationGoodAtFirst && (this.game.state.current == 'state_boot' || this.game.state.current == 'state_preload') && !this.game.device.desktop) {
  15239. orientReload = true
  15240. }
  15241. if (desiredOrientation == 'landscape' && window.innerWidth > window.innerHeight) {
  15242. return
  15243. } else if (desiredOrientation == 'portrait' && window.innerWidth < window.innerHeight) {
  15244. return
  15245. }
  15246. BasicGame.orientated = false;
  15247. this.game.paused = true;
  15248. document.getElementById('orientation').style.display = 'block'
  15249. },
  15250. leaveIncorrectOrientation: function() {
  15251. if (!orientationGoodAtFirst && !noMoreReload && orientReload && (this.game.state.current == 'state_boot' || this.game.state.current == 'state_preload')) {
  15252. noMoreReload = true;
  15253. orientReload = false;
  15254. location.reload()
  15255. }
  15256. BasicGame.orientated = true;
  15257. this.game.paused = false;
  15258. document.getElementById('orientation').style.display = 'none'
  15259. },
  15260. loadingCompleted: function() {
  15261. this.bootBd.context.fillRect(0, 0, this.bootBd.width * (this.load.progress / 100), 10);
  15262. this.bootBd.dirty = true;
  15263. this.game.state.start('state_preload')
  15264. }
  15265. };
  15266. BasicGame.StatePreload = function() {};
  15267. BasicGame.StatePreload.prototype = {
  15268. preload: function() {
  15269. showBannerAd();
  15270. this.prevLoadPercent = 0;
  15271. this.imgBd = this.add.image(0, 0, 'atlas_preloader', 'preloader_background');
  15272. this.style = {
  15273. font: "65px Arial",
  15274. fill: "#ff0044",
  15275. align: "center"
  15276. };
  15277. this.txtPercent = this.game.add.bitmapText(100, this.game.height / 2 - 45, 'grobold_loading', 'LOADING...');
  15278. this.txtPercent.x = this.world.centerX - this.txtPercent.textWidth / 2;
  15279. this.btnDown = null;
  15280. if (this.game.device.desktop) {
  15281. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15282. } else if (this.game.device.android) {
  15283. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
  15284. } else if (this.game.device.iOS) {
  15285. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15286. } else if (this.game.device.windowsPhone) {
  15287. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
  15288. } else {
  15289. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15290. }
  15291. this.btnDown.anchor.setTo(0.5, 0.5);
  15292. this.btnDown.scale.set(1.5, 1.5);
  15293. if (this.game.device.desktop) {
  15294. this.btnDown.input.useHandCursor = true
  15295. }
  15296. this.imgPreload = this.make.sprite(0, 0, 'atlas_preloader', 'preload_image');
  15297. this.imgPreloadBD = this.make.bitmapData(this.imgPreload.width / 2, this.imgPreload.height);
  15298. this.imgPreloadBD.addToWorld(this.world.centerX, this.game.height / 2 - 95, 0.5, 1);
  15299. this.copyArea = new Phaser.Rectangle(this.imgPreload.width / 2, 0, this.imgPreload.width / 2, this.imgPreload.height);
  15300. this.imgPreloadBD.copyRect(this.imgPreload, this.copyArea, 0, 0);
  15301. this.game.load.atlas('atlas_menu', 'assets/graphics/menu_assets.png', 'assets/graphics/menu_assets.json');
  15302. this.game.load.atlas('atlas_game', 'assets/graphics/game_assets.png', 'assets/graphics/game_assets.json');
  15303. this.game.load.atlas('atlas_intermenu', 'assets/graphics/intermenu_assets.png', 'assets/graphics/intermenu_assets.json');
  15304. this.game.load.bitmapFont('grobold', 'assets/fonts/grobold_0.png', 'assets/fonts/grobold.fnt');
  15305. this.game.load.tilemap('level_000', 'assets/levels/level_000.json', null, Phaser.Tilemap.TILED_JSON);
  15306. this.game.load.tilemap('level_001', 'assets/levels/level_001.json', null, Phaser.Tilemap.TILED_JSON);
  15307. this.game.load.tilemap('level_002', 'assets/levels/level_002.json', null, Phaser.Tilemap.TILED_JSON);
  15308. this.game.load.tilemap('level_003', 'assets/levels/level_003.json', null, Phaser.Tilemap.TILED_JSON);
  15309. this.game.load.tilemap('level_004', 'assets/levels/level_004.json', null, Phaser.Tilemap.TILED_JSON);
  15310. this.game.load.tilemap('level_005', 'assets/levels/level_005.json', null, Phaser.Tilemap.TILED_JSON);
  15311. this.game.load.tilemap('level_006', 'assets/levels/level_006.json', null, Phaser.Tilemap.TILED_JSON);
  15312. this.game.load.tilemap('level_007', 'assets/levels/level_007.json', null, Phaser.Tilemap.TILED_JSON);
  15313. this.game.load.tilemap('level_008', 'assets/levels/level_008.json', null, Phaser.Tilemap.TILED_JSON);
  15314. this.game.load.tilemap('level_009', 'assets/levels/level_009.json', null, Phaser.Tilemap.TILED_JSON);
  15315. this.game.load.tilemap('level_010', 'assets/levels/level_010.json', null, Phaser.Tilemap.TILED_JSON);
  15316. this.game.load.tilemap('level_011', 'assets/levels/level_011.json', null, Phaser.Tilemap.TILED_JSON);
  15317. this.game.load.tilemap('level_012', 'assets/levels/level_012.json', null, Phaser.Tilemap.TILED_JSON);
  15318. this.game.load.tilemap('level_013', 'assets/levels/level_013.json', null, Phaser.Tilemap.TILED_JSON);
  15319. this.game.load.tilemap('level_014', 'assets/levels/level_014.json', null, Phaser.Tilemap.TILED_JSON);
  15320. this.game.load.tilemap('level_015', 'assets/levels/level_015.json', null, Phaser.Tilemap.TILED_JSON);
  15321. this.game.load.tilemap('level_016', 'assets/levels/level_016.json', null, Phaser.Tilemap.TILED_JSON);
  15322. this.game.load.tilemap('level_017', 'assets/levels/level_017.json', null, Phaser.Tilemap.TILED_JSON);
  15323. this.game.load.tilemap('level_018', 'assets/levels/level_018.json', null, Phaser.Tilemap.TILED_JSON);
  15324. this.game.load.tilemap('level_019', 'assets/levels/level_019.json', null, Phaser.Tilemap.TILED_JSON);
  15325. this.game.load.tilemap('level_020', 'assets/levels/level_020.json', null, Phaser.Tilemap.TILED_JSON);
  15326. this.game.load.tilemap('level_021', 'assets/levels/level_021.json', null, Phaser.Tilemap.TILED_JSON);
  15327. this.game.load.tilemap('level_022', 'assets/levels/level_022.json', null, Phaser.Tilemap.TILED_JSON);
  15328. this.game.load.tilemap('level_023', 'assets/levels/level_023.json', null, Phaser.Tilemap.TILED_JSON);
  15329. this.game.load.tilemap('level_024', 'assets/levels/level_024.json', null, Phaser.Tilemap.TILED_JSON);
  15330. this.game.load.tilemap('level_025', 'assets/levels/level_025.json', null, Phaser.Tilemap.TILED_JSON);
  15331. this.game.load.tilemap('level_026', 'assets/levels/level_026.json', null, Phaser.Tilemap.TILED_JSON);
  15332. var dec = true;
  15333. this.game.load.audio('sndMenuLoop', ['assets/sounds/menu_loop.mp3', 'assets/sounds/menu_loop.ogg']);
  15334. this.game.load.audio('sndGameLoop', ['assets/sounds/game_loop.mp3', 'assets/sounds/game_loop.ogg']);
  15335. this.game.load.audio('sndButtonClick', ['assets/sounds/button_click.mp3', 'assets/sounds/button_click.ogg']);
  15336. this.game.load.audio('sndLevelFail', ['assets/sounds/level_fail.mp3', 'assets/sounds/level_fail.ogg']);
  15337. this.game.load.audio('sndLevelWin', ['assets/sounds/level_win.mp3', 'assets/sounds/level_win.ogg']);
  15338. this.game.load.audio('sndObjectRemove', ['assets/sounds/object_remove.mp3', 'assets/sounds/object_remove.ogg']);
  15339. this.game.load.audio('sndWinStar1', ['assets/sounds/win_star_1.mp3', 'assets/sounds/win_star_1.ogg']);
  15340. this.game.load.audio('sndWinStar2', ['assets/sounds/win_star_2.mp3', 'assets/sounds/win_star_2.ogg']);
  15341. this.game.load.audio('sndWinStar3', ['assets/sounds/win_star_3.mp3', 'assets/sounds/win_star_3.ogg']);
  15342. this.game.load.onFileComplete.add(this.oneFileCompleted, this);
  15343. this.game.load.onLoadComplete.addOnce(this.loadingCompleted, this)
  15344. },
  15345. btnSponsorImgPressed: function() {
  15346. sponsorLinkOpen()
  15347. },
  15348. create: function() {},
  15349. update: function() {
  15350. if (this.prevLoadPercent != this.game.load.progress) {
  15351. this.updatePreloadImage();
  15352. this.prevLoadPercent = this.game.load.progress
  15353. }
  15354. },
  15355. oneFileCompleted: function() {
  15356. if (arguments[1].indexOf('level_') >= 0) {
  15357. var num = parseInt(arguments[1].substring(6), 10);
  15358. var level = this.make.tilemap(arguments[1]);
  15359. BasicGame.Levels[num] = level;
  15360. if (level.properties.star_1 && level.properties.star_2 && level.properties.star_3) {
  15361. BasicGame.LevelStarShots[num] = [parseInt(level.properties.star_3, 10), parseInt(level.properties.star_2, 10), parseInt(level.properties.star_1, 10)]
  15362. } else {
  15363. BasicGame.LevelStarShots[num] = [1, 2, 3]
  15364. }
  15365. }
  15366. this.txtPercent.text = this.load.progress + ' %';
  15367. this.txtPercent.updateText();
  15368. this.txtPercent.x = this.world.centerX - this.txtPercent.textWidth / 2;
  15369. this.updatePreloadImage()
  15370. },
  15371. loadingCompleted: function() {
  15372. BasicGame.sndMenuLoop = new Phaser.Sound(this.game, 'sndMenuLoop', 1, true);
  15373. BasicGame.sndGameLoop = new Phaser.Sound(this.game, 'sndGameLoop', 1, true);
  15374. this.txtPercent.destroy();
  15375. var btnPlayGroup = this.add.group();
  15376. var btnPlay = this.make.button(0, 0, 'atlas_preloader', function() {
  15377. this.btnPlayClicked(false)
  15378. }, this, 'btn_preloader_play', 'btn_preloader_play', 'btn_preloader_play');
  15379. btnPlayGroup.add(btnPlay);
  15380. var btnPlayMutedGroup = this.add.group();
  15381. var btnPlayMuted = this.make.button(0, 0, 'atlas_preloader', function() {
  15382. this.btnPlayClicked(true)
  15383. }, this, 'btn_preloader_play_muted', 'btn_preloader_play_muted', 'btn_preloader_play_muted');
  15384. btnPlayMutedGroup.add(btnPlayMuted);
  15385. btnPlayGroup.x = this.world.centerX - 125;
  15386. btnPlayGroup.y = this.game.height + 100;
  15387. btnPlayMutedGroup.x = this.world.centerX - 125;
  15388. btnPlayMutedGroup.y = this.game.height + 200;
  15389. if (this.game.device.desktop) {
  15390. btnPlay.input.useHandCursor = true;
  15391. btnPlayMuted.input.useHandCursor = true
  15392. }
  15393. var tweenBtnPlay = this.game.add.tween(btnPlayGroup).to({
  15394. y: this.game.height - 200
  15395. }, 700, Phaser.Easing.Cubic.Out, true).start();
  15396. var tweenBtnPlayMuted = this.game.add.tween(btnPlayMutedGroup).to({
  15397. y: this.game.height - 120
  15398. }, 900, Phaser.Easing.Cubic.Out, true).start();
  15399. this.updatePreloadImage()
  15400. },
  15401. updatePreloadImage: function() {
  15402. this.copyArea.x = 0;
  15403. this.copyArea.y = this.imgPreload.height - (this.game.load.progress / 100) * this.imgPreload.height;
  15404. this.copyArea.height = this.imgPreload.height - this.copyArea.y;
  15405. this.imgPreloadBD.copyRect(this.imgPreload, this.copyArea, 0, this.copyArea.y)
  15406. },
  15407. btnPlayClicked: function(muted) {
  15408. if (this.game.device.windowsPhone) {
  15409. GC.soundDisabled = true
  15410. }
  15411. this.game.sound.mute = muted;
  15412. GC.playSound = !muted;
  15413. this.state.start(BasicGame.stateFirst)
  15414. },
  15415. loadTimerCompleted: function() {},
  15416. shutdown: function() {
  15417. this.imgPreload = null;
  15418. this.imgPreloadBD = null;
  15419. this.copyArea = null;
  15420. this.btnPlay = null;
  15421. this.btnPLayMuted = null;
  15422. this.game = null;
  15423. this.add = null;
  15424. this.make = null;
  15425. this.camera = null;
  15426. this.cache = null;
  15427. this.input = null;
  15428. this.load = null;
  15429. this.math = null;
  15430. this.sound = null;
  15431. this.scale = null;
  15432. this.state = null;
  15433. this.stage = null;
  15434. this.time = null;
  15435. this.tweens = null;
  15436. this.world = null;
  15437. this.particles = null;
  15438. this.rnd = null;
  15439. this.physics = null
  15440. }
  15441. };
  15442. BasicGame.StateMenu = function() {};
  15443. BasicGame.StateMenu.prototype = {
  15444. initVars: function(game) {
  15445. this.game = game;
  15446. this.currentChapter = 0;
  15447. this.totalChapters = Math.ceil(GC.totalLevels / 9);
  15448. this.pnlInfoIn = false;
  15449. this.pressable = false
  15450. },
  15451. preload: function() {
  15452. this.pressable = true;
  15453. this.pnlInfoIn = false;
  15454. this.soundOnImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_sound_on'];
  15455. this.soundOffImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_sound_off'];
  15456. this.fullscreenEnterImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_fullscreen_enter'];
  15457. this.fullscreenLeaveImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_fullscreen_leave']
  15458. },
  15459. create: function() {
  15460. showBannerAd();
  15461. if (GC.FullScreenEnabled) {
  15462. if (!this.game.device.desktop) {
  15463. this.input.touch.preventDefault = false
  15464. }
  15465. if (this.game.canvas.addEventListener) {
  15466. document.getElementById('gameContainer').addEventListener('click', menuClickedFullscreenCheck, false)
  15467. } else {
  15468. document.getElementById('gameContainer').attachEvent('onclick', menuClickedFullscreenCheck)
  15469. }
  15470. }
  15471. if (!BasicGame.sndMenuLoop.isPlaying) {
  15472. BasicGame.sndMenuLoop.play('', 0, (GC.playSound ? 1 : 0), true)
  15473. }
  15474. this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
  15475. this.imgBg = this.game.add.sprite(0, 0, 'atlas_menu', 'menu_background');
  15476. this.tileCloud = this.game.add.tileSprite(0, 50, this.game.width, 85, 'atlas_menu', 'cloud');
  15477. this.tileCloud.autoScroll(-15, 0);
  15478. this.imgLogo = this.game.add.sprite(this.game.world.centerX, 200, 'atlas_menu', 'main_logo');
  15479. this.imgLogo.anchor.setTo(0.5, 1);
  15480. this.btnPlay = this.game.add.button(this.game.world.centerX, 340, 'atlas_menu', this.btnPlayClicked, this, 'btn_play', 'btn_play', 'btn_play');
  15481. this.btnPlay.anchor.setTo(0.5, 0.5);
  15482. this.btnSound = this.game.add.button(15, this.game.height - 55, 'atlas_menu', this.btnSoundClicked, this, 'btn_sound_on', 'btn_sound_on', 'btn_sound_on');
  15483. this.btnSound.anchor.setTo(0.5, 0.5);
  15484. this.btnSound.x += this.btnSound.width / 2;
  15485. this.btnSound.y -= this.btnSound.height / 2;
  15486. if (this.game.sound.mute) {
  15487. this.btnSound.frame = this.soundOffImage
  15488. }
  15489. this.btnInfo = this.game.add.button(this.game.world.centerX, this.game.height - 55, 'atlas_menu', this.btnInfoClicked, this, 'btn_info', 'btn_info', 'btn_info');
  15490. this.btnInfo.anchor.setTo(0.5, 0.5);
  15491. this.btnInfo.y -= this.btnInfo.height / 2;
  15492. if (GC.FullScreenEnabled) {
  15493. this.btnFullscreen = this.game.add.button(this.game.width - 15, this.game.height - 55, 'atlas_menu', this.btnFullscreenPressed, this, 'btn_fullscreen_enter', 'btn_fullscreen_enter', 'btn_fullscreen_enter');
  15494. this.btnFullscreen.anchor.setTo(0.5, 0.5);
  15495. this.btnFullscreen.x -= this.btnFullscreen.width / 2;
  15496. this.btnFullscreen.y -= this.btnFullscreen.height / 2;
  15497. if (this.scale.isFullscreen) {
  15498. this.btnFullscreen.frame = this.fullscreenLeaveImage
  15499. }
  15500. } else {
  15501. this.btnInfo.x = this.game.width - this.btnInfo.width / 2 - 15
  15502. }
  15503. this.btnDown = null;
  15504. if (this.game.device.desktop) {
  15505. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15506. } else if (this.game.device.android) {
  15507. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
  15508. } else if (this.game.device.iOS) {
  15509. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15510. } else if (this.game.device.windowsPhone) {
  15511. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
  15512. } else {
  15513. this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  15514. }
  15515. this.btnDown.anchor.setTo(0.5, 0.5);
  15516. this.blackBg = this.make.tileSprite(0, 0, this.game.width, this.game.height, 'atlas_menu', 'black_bg');
  15517. this.pnlInfo = this.make.sprite(0, 0, 'atlas_menu', 'panel_info');
  15518. this.pnlInfo.anchor.setTo(0.5, 0.5);
  15519. this.pnlInfo.alpha = 0;
  15520. this.pnlInfo.x = this.world.centerX;
  15521. this.input.onTap.add(this.tappedCallback, this);
  15522. this.imgLogo.scale.setTo(0.4, 0.4);
  15523. this.imgLogo.visible = false;
  15524. this.btnPlay.y = this.game.height + 150;
  15525. this.btnSound.y = this.game.height + 100;
  15526. this.btnInfo.y = this.game.height + 100;
  15527. this.btnDown.y = this.game.height + 100;
  15528. if (GC.FullScreenEnabled) {
  15529. this.btnFullscreen.y = this.game.height + 100
  15530. }
  15531. if (this.game.device.desktop) {
  15532. this.btnPlay.input.useHandCursor = true;
  15533. this.btnInfo.input.useHandCursor = true;
  15534. this.btnSound.input.useHandCursor = true;
  15535. if (GC.FullScreenEnabled) {
  15536. this.btnFullscreen.input.useHandCursor = true
  15537. }
  15538. this.btnDown.input.useHandCursor = true
  15539. }
  15540. if (BasicGame.previewMode) {
  15541. var tomb = [78, 79, 84, 32, 70, 79, 82, 32, 80, 85, 66, 76, 73, 67, 32, 85, 83, 69, 33];
  15542. var vizjel = '';
  15543. for (var z = tomb.length - 1; z >= 0; z--) {
  15544. vizjel = String.fromCharCode(tomb[z]) + vizjel
  15545. }
  15546. var v = this.add.bitmapText(3, 3, 'grobold', vizjel);
  15547. v.alpha = 0.35;
  15548. v.fontSize = 24
  15549. }
  15550. this.game.world.alpha = 0;
  15551. this.tweenFadeIn = this.game.add.tween(this.game.world).to({
  15552. alpha: 1
  15553. }, 500, Phaser.Easing.Quadratic.In, true);
  15554. this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
  15555. this.tweenFadeIn.start()
  15556. },
  15557. btnSponsorImgPressed: function() {
  15558. if (this.pressable) {
  15559. sponsorLinkOpen()
  15560. }
  15561. },
  15562. fadeInCompleted: function() {
  15563. this.pressable = true;
  15564. this.game.time.events.add(Phaser.Timer.SECOND / 3, this.beginMenuInAnimation, this)
  15565. },
  15566. beginMenuInAnimation: function() {
  15567. this.imgLogo.visible = true;
  15568. this.tweenLogo = this.game.add.tween(this.imgLogo.scale).to({
  15569. x: 1,
  15570. y: 1
  15571. }, 400, Phaser.Easing.Back.Out, true);
  15572. this.tweenLogo.onComplete.addOnce(this.tweenLogoInCompleted, this);
  15573. this.tweenLogo.start()
  15574. },
  15575. tweenLogoInCompleted: function() {
  15576. this.tweenBtnPlay = this.game.add.tween(this.btnPlay).to({
  15577. y: 350
  15578. }, 400, Phaser.Easing.Cubic.Out, true);
  15579. this.tweenBtnPlay.onComplete.addOnce(this.tweenBtnPlayCompleted, this);
  15580. this.tweenBtnPlay.start()
  15581. },
  15582. tweenBtnPlayCompleted: function() {
  15583. this.tweenBtnSound = this.game.add.tween(this.btnSound).to({
  15584. y: this.game.height - 55 - this.btnSound.height / 2
  15585. }, 350, Phaser.Easing.Cubic.Out, true);
  15586. this.tweenBtnInfo = this.game.add.tween(this.btnInfo).to({
  15587. y: this.game.height - 55 - this.btnInfo.height / 2
  15588. }, 350, Phaser.Easing.Cubic.Out, true);
  15589. this.tweenBtnDown = this.game.add.tween(this.btnDown).to({
  15590. y: this.game.height / 2 + 150
  15591. }, 350, Phaser.Easing.Cubic.Out, true);
  15592. if (GC.FullScreenEnabled) {
  15593. this.tweenBtnFullscreen = this.game.add.tween(this.btnFullscreen).to({
  15594. y: this.game.height - 50 - this.btnFullscreen.height / 2
  15595. }, 350, Phaser.Easing.Cubic.Out, true)
  15596. }
  15597. },
  15598. update: function() {},
  15599. tappedCallback: function() {
  15600. this.removeInfoPanel()
  15601. },
  15602. removeInfoPanel: function() {
  15603. if (this.pnlInfoIn) {
  15604. this.btnDown.visible = true;
  15605. this.world.remove(this.blackBg);
  15606. this.pnlInfoIn = false;
  15607. this.add.tween(this.pnlInfo).to({
  15608. y: this.world.centerY + 50
  15609. }, 200, Phaser.Easing.Quadratic.In, true).onComplete.addOnce(this.removeInfoPanelCompleted, this);
  15610. this.add.tween(this.pnlInfo).to({
  15611. alpha: 0
  15612. }, 200, Phaser.Easing.Quadratic.In, true)
  15613. }
  15614. },
  15615. removeInfoPanelCompleted: function() {
  15616. this.world.remove(this.pnlInfo, false, true);
  15617. this.pnlInfoIn = false;
  15618. this.pressable = true
  15619. },
  15620. btnInfoClicked: function() {
  15621. if (this.pressable) {
  15622. if (!GC.soundDisabled) {
  15623. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15624. }
  15625. this.btnDown.visible = false;
  15626. this.add.tween(this.btnInfo.scale).to({
  15627. x: 1.2,
  15628. y: 0.8
  15629. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15630. this.world.add(this.blackBg);
  15631. this.pnlInfoIn = true;
  15632. this.pressable = false;
  15633. this.world.add(this.pnlInfo);
  15634. this.pnlInfo.alpha = 0;
  15635. this.pnlInfo.y = this.world.centerY + 50;
  15636. this.add.tween(this.pnlInfo).to({
  15637. y: this.world.centerY
  15638. }, 300, Phaser.Easing.Quadratic.Out, true);
  15639. this.add.tween(this.pnlInfo).to({
  15640. alpha: 1
  15641. }, 300, Phaser.Easing.Quadratic.Out, true)
  15642. }
  15643. },
  15644. btnFullscreenPressed: function() {
  15645. if (!this.pressable) {
  15646. return
  15647. }
  15648. if (!GC.soundDisabled) {
  15649. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15650. }
  15651. },
  15652. refreshFullscreenUi: function() {
  15653. if (GC.FullScreenEnabled) {
  15654. if (screenfull.isFullscreen) {
  15655. this.btnFullscreen.frame = this.fullscreenLeaveImage
  15656. } else {
  15657. this.btnFullscreen.frame = this.fullscreenEnterImage
  15658. }
  15659. }
  15660. },
  15661. btnPlayClicked: function() {
  15662. if (this.pressable) {
  15663. if (!GC.soundDisabled) {
  15664. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15665. }
  15666. this.add.tween(this.btnPlay.scale).to({
  15667. x: 1.2,
  15668. y: 0.8
  15669. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15670. this.pressable = false;
  15671. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  15672. alpha: 0
  15673. }, 700, Phaser.Easing.Quadratic.Out, true);
  15674. this.tweenFadeOut.onComplete.addOnce(this.fadeOutToLevelSelect, this);
  15675. this.tweenFadeOut.start()
  15676. }
  15677. },
  15678. btnSoundClicked: function() {
  15679. if (!this.pressable) {
  15680. return
  15681. }
  15682. if (!GC.soundDisabled) {
  15683. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15684. }
  15685. this.btnSound.scale.x = this.btnSound.scale.y = 1;
  15686. this.add.tween(this.btnSound.scale).to({
  15687. x: 1.2,
  15688. y: 0.8
  15689. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15690. this.game.sound.mute = !this.game.sound.mute;
  15691. GC.playSound = !this.game.sound.mute;
  15692. if (this.game.sound.mute) {
  15693. this.btnSound.frame = this.soundOffImage
  15694. } else {
  15695. this.btnSound.frame = this.soundOnImage
  15696. }
  15697. if (BasicGame.sndMenuLoop.isPlaying) {
  15698. BasicGame.sndMenuLoop.volume = (GC.playSound ? 1 : 0)
  15699. }
  15700. if (BasicGame.sndGameLoop.isPlaying) {
  15701. BasicGame.sndGameLoop.volume = (GC.playSound ? 1 : 0)
  15702. }
  15703. },
  15704. fadeOutToLevelSelect: function() {
  15705. this.game.state.start('state_level_select')
  15706. },
  15707. shutdown: function() {
  15708. if (GC.FullScreenEnabled) {
  15709. if (this.game.canvas.addEventListener) {
  15710. document.getElementById('gameContainer').removeEventListener('click', menuClickedFullscreenCheck)
  15711. } else {
  15712. document.getElementById('gameContainer').detachEvent('onclick', menuClickedFullscreenCheck)
  15713. }
  15714. }
  15715. this.soundClick.destroy(true);
  15716. this.btnPlay = null;
  15717. this.btnInfo = null;
  15718. this.pnlInfo = null;
  15719. this.btnSound = null;
  15720. this.imgBg = null;
  15721. this.imgLogo = null
  15722. }
  15723. };
  15724. BasicGame.StateLevelSelect = function() {};
  15725. BasicGame.StateLevelSelect.prototype = {
  15726. initVars: function(game) {
  15727. this.game = game;
  15728. this.currentChapter = 0;
  15729. this.totalChapters = Math.ceil(GC.totalLevels / 9);
  15730. this.pressable = false
  15731. },
  15732. preload: function() {},
  15733. create: function() {
  15734. hideBannerAd();
  15735. if (!BasicGame.sndMenuLoop.isPlaying) {
  15736. BasicGame.sndMenuLoop.play('', 0, (GC.playSound ? 1 : 0), true)
  15737. }
  15738. if (BasicGame.sndGameLoop.isPlaying) {
  15739. BasicGame.sndGameLoop.stop()
  15740. }
  15741. this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
  15742. this.pressable = false;
  15743. this.currentChapter = Math.floor(BasicGame.currentLevel / 9);
  15744. this.imgBg = this.game.add.sprite(0, 0, 'atlas_menu', 'menu_background');
  15745. this.tileCloud = this.game.add.tileSprite(0, 50, this.game.width, 85, 'atlas_menu', 'cloud');
  15746. this.tileCloud.autoScroll(-15, 0);
  15747. this.groupLogo = this.add.group();
  15748. this.imgLogo = this.game.make.sprite(0, 0, 'atlas_menu', 'level_select_logo');
  15749. this.txtLogo = this.make.bitmapText(0, 0, 'grobold', '选择关卡');
  15750. this.txtLogo.scale.setTo(1.3, 1.3);
  15751. this.txtLogo.x = this.imgLogo.width / 2 - this.txtLogo.width / 2;
  15752. this.txtLogo.y = 5;
  15753. this.groupLogo.add(this.imgLogo);
  15754. this.groupLogo.add(this.txtLogo);
  15755. this.groupLogo.x = this.game.width / 2 - this.imgLogo.width / 2;
  15756. this.groupLogo.y = 50;
  15757. this.btnBack = this.game.add.button(this.world.centerX, this.game.height - 20, 'atlas_menu', this.btnBackClicked, this, 'btn_home', 'btn_home', 'btn_home');
  15758. this.btnBack.anchor.setTo(0.5, 0.5);
  15759. this.btnBack.y -= this.btnBack.height / 2;
  15760. this.btnPreviousChapter = this.game.add.button(20, this.game.height - 30, 'atlas_menu', this.btnPreviousChapterPressed, this, 'btn_chapter_previous', 'btn_chapter_previous', 'btn_chapter_previous');
  15761. this.btnPreviousChapter.anchor.setTo(0.5, 0.5);
  15762. this.btnPreviousChapter.x += this.btnPreviousChapter.width / 2;
  15763. this.btnPreviousChapter.y -= this.btnPreviousChapter.height / 2;
  15764. this.btnNextChapter = this.game.add.button(this.game.width - 30, this.game.height - 20, 'atlas_menu', this.btnNextChapterPressed, this, 'btn_chapter_next', 'btn_chapter_next', 'btn_chapter_next');
  15765. this.btnNextChapter.anchor.setTo(0.5, 0.5);
  15766. this.btnNextChapter.x -= this.btnNextChapter.width / 2;
  15767. this.btnNextChapter.y -= this.btnNextChapter.height / 2;
  15768. this.btnGroupAll = this.add.group();
  15769. this.btnsLevel = [];
  15770. var count = 0;
  15771. var btn;
  15772. var txt;
  15773. var st1;
  15774. var st2;
  15775. var st3;
  15776. var closedSign;
  15777. var currLevel = 0;
  15778. for (var i = 0; i < 3; i++) {
  15779. for (var j = 0; j < 3; j++) {
  15780. if (count < GC.totalLevels) {
  15781. currLevel = (this.currentChapter * 9) + count;
  15782. this.btnsLevel[count] = this.add.group();
  15783. btn = this.make.button(0, 0, 'atlas_menu', this.btnLevelClicked, this, 'btn_level', 'btn_level', 'btn_level');
  15784. if (this.game.device.desktop) {
  15785. btn.input.useHandCursor = true
  15786. }
  15787. btn.anchor.setTo(0.5, 0.5);
  15788. btn.x += btn.width / 2;
  15789. btn.y += btn.height / 2;
  15790. btn.name = count.toString();
  15791. txt = this.make.bitmapText(10, 7, 'grobold', (currLevel + 1).toString());
  15792. txt.x = btn.width / 2 - txt.textWidth / 2;
  15793. st1 = this.make.image(5, 40, 'atlas_menu', 'star_levelselect');
  15794. st2 = this.make.image(27, 40, 'atlas_menu', 'star_levelselect');
  15795. st3 = this.make.image(49, 40, 'atlas_menu', 'star_levelselect');
  15796. closedSign = this.make.image(0, 0, 'atlas_menu', 'btn_level_disabled_overlay');
  15797. closedSign.anchor.setTo(0.5, 0.5);
  15798. closedSign.x += closedSign.width / 2;
  15799. closedSign.y += closedSign.height / 2;
  15800. this.btnsLevel[count].add(btn);
  15801. this.btnsLevel[count].add(st1);
  15802. this.btnsLevel[count].add(st2);
  15803. this.btnsLevel[count].add(st3);
  15804. this.btnsLevel[count].add(txt);
  15805. this.btnsLevel[count].add(closedSign);
  15806. this.btnsLevel[count].x = 75 + j * 123;
  15807. this.btnsLevel[count].y = 175 + i * 125;
  15808. this.btnGroupAll.add(this.btnsLevel[count]);
  15809. if (currLevel >= GC.totalLevels) {
  15810. this.btnsLevel[count].visible = false
  15811. } else {
  15812. if (BasicGame.LevelsOpen[currLevel] == 1) {
  15813. closedSign.visible = false
  15814. }
  15815. st1.visible = st2.visible = st3.visible = false;
  15816. switch (BasicGame.LevelStars[currLevel]) {
  15817. case 1:
  15818. st1.visible = true;
  15819. break;
  15820. case 2:
  15821. st1.visible = st2.visible = true;
  15822. break;
  15823. case 3:
  15824. st1.visible = st2.visible = st3.visible = true;
  15825. break
  15826. }
  15827. }
  15828. }
  15829. count++
  15830. }
  15831. }
  15832. this.checkChaptering();
  15833. if (BasicGame.previewMode) {
  15834. this.btnOpenAll = this.add.button(0, 0, 'atlas_menu', this.btnOpenAllPressed, this, 'btn_open_all', 'btn_open_all', 'btn_open_all');
  15835. this.btnClearAll = this.add.button(this.game.width, 0, 'atlas_menu', this.btnClearAllPressed, this, 'btn_clear_all', 'btn_clear_all', 'btn_clear_all');
  15836. this.btnClearAll.anchor.setTo(1, 0)
  15837. }
  15838. this.btnGroupAll.x = 0;
  15839. this.btnGroupAll.y = this.game.height + 100;
  15840. this.groupLogo.y = -100;
  15841. this.btnBack.y = this.game.height + 150;
  15842. this.btnPreviousChapter.y = this.game.height + 150;
  15843. this.btnNextChapter.y = this.game.height + 150;
  15844. if (this.game.device.desktop) {
  15845. this.btnPreviousChapter.input.useHandCursor = true;
  15846. this.btnNextChapter.input.useHandCursor = true;
  15847. this.btnBack.input.useHandCursor = true
  15848. }
  15849. this.game.world.alpha = 0;
  15850. this.tweenFadeIn = this.game.add.tween(this.game.world).to({
  15851. alpha: 1
  15852. }, 500, Phaser.Easing.Quadratic.In, true);
  15853. this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
  15854. this.tweenFadeIn.start()
  15855. },
  15856. btnOpenAllPressed: function() {
  15857. if (!this.pressable) {
  15858. return
  15859. }
  15860. BasicGame.openAllLevels();
  15861. this.checkChaptering();
  15862. this.checkLevelButtonsChapter()
  15863. },
  15864. btnClearAllPressed: function() {
  15865. if (!this.pressable) {
  15866. return
  15867. }
  15868. BasicGame.clearAllData();
  15869. this.checkChaptering();
  15870. this.checkLevelButtonsChapter()
  15871. },
  15872. btnLevelClicked: function(button) {
  15873. var currLevel = (this.currentChapter * 9 + parseInt(button.name, 10));
  15874. if (this.pressable && BasicGame.LevelsOpen[currLevel] == 1) {
  15875. if (!GC.soundDisabled) {
  15876. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15877. }
  15878. this.add.tween(button.scale).to({
  15879. x: 1.2,
  15880. y: 0.8
  15881. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15882. this.pressable = false;
  15883. BasicGame.currentLevel = currLevel;
  15884. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  15885. alpha: 0
  15886. }, 500, Phaser.Easing.Quadratic.Out, true);
  15887. this.tweenFadeOut.onComplete.addOnce(this.fadeOutToGame, this);
  15888. this.tweenFadeOut.start()
  15889. }
  15890. },
  15891. fadeInCompleted: function() {
  15892. this.game.time.events.add(Phaser.Timer.SECOND / 2, this.beginLogoInAnimation, this)
  15893. },
  15894. beginLogoInAnimation: function() {
  15895. this.tweenLogo = this.game.add.tween(this.groupLogo).to({
  15896. y: 50
  15897. }, 300, Phaser.Easing.Back.Out, true);
  15898. this.tweenLogo.onComplete.addOnce(this.tweenLevelButtons, this);
  15899. this.tweenLogo.start()
  15900. },
  15901. tweenLevelButtons: function() {
  15902. this.tweenLevelIn = this.game.add.tween(this.btnGroupAll).to({
  15903. y: 0
  15904. }, 500, Phaser.Easing.Cubic.Out, true, 100);
  15905. this.tweenLevelIn.onComplete.addOnce(this.tweenMenuButtons, this)
  15906. },
  15907. tweenMenuButtons: function() {
  15908. this.tweenBtnBack = this.game.add.tween(this.btnBack).to({
  15909. y: this.game.height - 20 - this.btnBack.height / 2
  15910. }, 350, Phaser.Easing.Cubic.Out, true);
  15911. this.tweenBtnPreviousChapter = this.game.add.tween(this.btnPreviousChapter).to({
  15912. y: this.game.height - 20 - this.btnPreviousChapter.height / 2
  15913. }, 350, Phaser.Easing.Cubic.Out, true);
  15914. this.tweenBtnNextChapter = this.game.add.tween(this.btnNextChapter).to({
  15915. y: this.game.height - 20 - this.btnNextChapter.height / 2
  15916. }, 350, Phaser.Easing.Cubic.Out, true);
  15917. this.pressable = true
  15918. },
  15919. update: function() {},
  15920. btnPreviousChapterPressed: function() {
  15921. if (this.pressable) {
  15922. if (!GC.soundDisabled) {
  15923. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15924. }
  15925. this.add.tween(this.btnPreviousChapter.scale).to({
  15926. x: 1.2,
  15927. y: 0.8
  15928. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15929. this.pressable = false;
  15930. this.currentChapter--;
  15931. this.checkChaptering();
  15932. this.tweenOutLevelButtons('right')
  15933. }
  15934. },
  15935. btnNextChapterPressed: function() {
  15936. if (this.pressable) {
  15937. if (!GC.soundDisabled) {
  15938. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  15939. }
  15940. this.add.tween(this.btnNextChapter.scale).to({
  15941. x: 1.2,
  15942. y: 0.8
  15943. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  15944. this.pressable = false;
  15945. this.currentChapter++;
  15946. this.checkChaptering();
  15947. this.tweenOutLevelButtons('left')
  15948. }
  15949. },
  15950. tweenOutLevelButtons: function(direction) {
  15951. var xAdd = (direction == 'left' ? -this.game.width - 200 : this.game.width + 200);
  15952. this.add.tween(this.btnGroupAll).to({
  15953. x: xAdd
  15954. }, 500, Phaser.Easing.Cubic.In, true).onComplete.addOnce(function() {
  15955. this.tweenInLevelButtons(direction)
  15956. }, this)
  15957. },
  15958. tweenInLevelButtons: function(direction) {
  15959. this.checkLevelButtonsChapter();
  15960. this.btnGroupAll.x = (direction == 'left' ? this.game.width + 200 : -this.game.width - 200);
  15961. this.add.tween(this.btnGroupAll).to({
  15962. x: 0
  15963. }, 500, Phaser.Easing.Cubic.Out, true).onComplete.addOnce(this.enablePressing, this)
  15964. },
  15965. enablePressing: function() {
  15966. this.pressable = true
  15967. },
  15968. checkChaptering: function() {
  15969. if (this.currentChapter < 0) {
  15970. this.currentChapter = 0
  15971. }
  15972. if (this.currentChapter > this.totalChapters - 1) {
  15973. this.currentChapter = this.totalChapters - 1
  15974. }
  15975. if (this.currentChapter == 0) {
  15976. this.btnPreviousChapter.visible = false
  15977. } else {
  15978. this.btnPreviousChapter.visible = true
  15979. }
  15980. if (this.currentChapter == this.totalChapters - 1) {
  15981. this.btnNextChapter.visible = false
  15982. } else {
  15983. this.btnNextChapter.visible = true
  15984. }
  15985. },
  15986. checkLevelButtonsChapter: function() {
  15987. var count = 0;
  15988. var elem;
  15989. var st1;
  15990. var st2;
  15991. var st3;
  15992. var closedSign;
  15993. var currLevel = 0;
  15994. for (var i = 0; i < 3; i++) {
  15995. for (var j = 0; j < 3; j++) {
  15996. currLevel = (this.currentChapter * 9) + count;
  15997. if (currLevel < GC.totalLevels) {
  15998. this.btnsLevel[count].visible = true;
  15999. elem = this.btnsLevel[count].getAt(4);
  16000. elem.text = (currLevel + 1).toString();
  16001. elem.updateText();
  16002. elem.x = 84 / 2 - elem.textWidth / 2;
  16003. st1 = this.btnsLevel[count].getAt(1);
  16004. st2 = this.btnsLevel[count].getAt(2);
  16005. st3 = this.btnsLevel[count].getAt(3);
  16006. closedSign = this.btnsLevel[count].getAt(5);
  16007. st1.visible = st2.visible = st3.visible = false;
  16008. switch (BasicGame.LevelStars[currLevel]) {
  16009. case 1:
  16010. st1.visible = true;
  16011. break;
  16012. case 2:
  16013. st1.visible = st2.visible = true;
  16014. break;
  16015. case 3:
  16016. st1.visible = st2.visible = st3.visible = true;
  16017. break
  16018. }
  16019. closedSign.visible = (BasicGame.LevelsOpen[currLevel] == 0 ? true : false)
  16020. } else {
  16021. this.btnsLevel[count].visible = false
  16022. }
  16023. count++
  16024. }
  16025. }
  16026. },
  16027. btnBackClicked: function() {
  16028. if (this.pressable) {
  16029. if (!GC.soundDisabled) {
  16030. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16031. }
  16032. this.add.tween(this.btnBack.scale).to({
  16033. x: 1.2,
  16034. y: 0.8
  16035. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  16036. this.pressable = false;
  16037. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  16038. alpha: 0
  16039. }, 500, Phaser.Easing.Quadratic.Out, true);
  16040. this.tweenFadeOut.onComplete.addOnce(this.fadeOutToMenu, this);
  16041. this.tweenFadeOut.start()
  16042. }
  16043. },
  16044. fadeOutToGame: function() {
  16045. this.game.state.start('state_game')
  16046. },
  16047. fadeOutToMenu: function() {
  16048. this.game.state.start('state_menu')
  16049. },
  16050. shutdown: function() {
  16051. this.soundClick.destroy(true);
  16052. this.btnGroupAll.destroy(true, false);
  16053. this.btnBack = null;
  16054. this.btnPreviousChapter = null;
  16055. this.btnNextChapter = null;
  16056. this.imgBg = null;
  16057. this.imgLogo = null
  16058. }
  16059. };
  16060. BasicGame.StateGame = function() {};
  16061. BasicGame.StateGame.prototype = {
  16062. initVars: function(game) {
  16063. this.game = game;
  16064. this.currentMap = null
  16065. },
  16066. preload: function() {
  16067. this.pressable = false;
  16068. this.paused = false;
  16069. this.fadeOutState = 'state_menu';
  16070. this.currentMap = null;
  16071. this.currentLevel = 0;
  16072. this.objectsWood = [];
  16073. this.objectsStone = [];
  16074. this.objectsGood = [];
  16075. this.objectsBad = [];
  16076. this.objectsGoal = [];
  16077. this.tutorialSpot = null;
  16078. this.tutorialFinger = null;
  16079. this.tutorialTween = null;
  16080. this.objectRemoveCount = 0;
  16081. this.pivotJointNameList = [];
  16082. this.levelAtlas = 'atlas_game';
  16083. this.levelAtlasPrefix = 'l_'
  16084. },
  16085. create: function() {
  16086. showBannerAd();
  16087. this.levelAtlas = 'atlas_game';
  16088. this.levelAtlasPrefix = 'l_' + String(BasicGame.currentLevel) + '_';
  16089. if (BasicGame.sndMenuLoop.isPlaying) {
  16090. BasicGame.sndMenuLoop.stop()
  16091. }
  16092. if (!BasicGame.sndGameLoop.isPlaying) {
  16093. BasicGame.sndGameLoop.play('', 0, (GC.playSound ? 1 : 0), true)
  16094. }
  16095. this.currentLevel = BasicGame.currentLevel;
  16096. BasicGame.winStarsPrevious = BasicGame.LevelStars[this.currentLevel];
  16097. this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
  16098. this.soundWin = this.game.add.audio('sndLevelWin', 1, false);
  16099. this.soundFail = this.game.add.audio('sndLevelFail', 1, false);
  16100. this.soundObjectRemove = this.game.add.audio('sndObjectRemove', 1, false);
  16101. this.game.physics.startSystem(Phaser.Physics.P2JS);
  16102. this.game.physics.p2.gravity.y = 300;
  16103. this.game.physics.p2.world.defaultContactMaterial.friction = 1;
  16104. this.imgBg = this.game.add.image(0, 0, this.levelAtlas, 'game_background');
  16105. this.tileCloud = this.game.add.tileSprite(0, 90, this.game.width, 85, this.levelAtlas, 'cloud');
  16106. this.tileCloud.autoScroll(-15, 0);
  16107. this.ground = this.game.add.sprite(0, 200, this.levelAtlas, 'ground');
  16108. this.game.physics.p2.enable([this.ground], false);
  16109. this.ground.body.static = true;
  16110. this.ground.body.clearShapes();
  16111. this.ground.body.addPolygon({
  16112. optimalDecomp: false,
  16113. skipSimpleCheck: true,
  16114. removeCollinearPoints: false
  16115. }, [
  16116. [0, 0],
  16117. [630, 0],
  16118. [630, 80],
  16119. [0, 80]
  16120. ]);
  16121. this.ground.body.x = this.world.centerX;
  16122. this.ground.body.y = this.game.height - this.ground.height / 2;
  16123. this.loadLevel(BasicGame.currentLevel);
  16124. this.btnPause = this.game.add.button(this.game.width - 20, 45, this.levelAtlas, this.btnPausePressed, this, 'btn_pause', 'btn_pause', 'btn_pause');
  16125. this.btnPause.anchor.setTo(1, 0);
  16126. this.btnRestart = this.game.add.button(20, 45, this.levelAtlas, this.btnRestartPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
  16127. this.btnRestart.anchor.setTo(0, 0);
  16128. this.imgStarUi3 = this.add.image(0, this.game.height - 80 - 22, this.levelAtlas, 'star_ui_1');
  16129. this.imgStarUi2 = this.add.image(0, this.imgStarUi3.y - 22, this.levelAtlas, 'star_ui_2');
  16130. this.imgStarUi1 = this.add.image(0, this.imgStarUi2.y - 22, this.levelAtlas, 'star_ui_3');
  16131. var strStarsEarn = BasicGame.LevelStarShots[this.currentLevel][0] + '\n' + BasicGame.LevelStarShots[this.currentLevel][1] + '\n' + BasicGame.LevelStarShots[this.currentLevel][2];
  16132. this.txtStarsEarn = this.game.add.bitmapText(this.imgStarUi1.x + this.imgStarUi1.width, this.imgStarUi1.y, 'grobold', strStarsEarn);
  16133. this.txtStarsEarn.scale.setTo(0.65, 0.65);
  16134. this.txtStarsEarn.align = 'left';
  16135. if (BasicGame.previewMode) {
  16136. var tomb = [78, 79, 84, 32, 70, 79, 82, 32, 80, 85, 66, 76, 73, 67, 32, 85, 83, 69, 33];
  16137. var vizjel = '';
  16138. for (var z = tomb.length - 1; z >= 0; z--) {
  16139. vizjel = String.fromCharCode(tomb[z]) + vizjel
  16140. }
  16141. var v = this.add.bitmapText(3, 3, 'grobold', vizjel);
  16142. v.alpha = 0.35;
  16143. v.fontSize = 24
  16144. }
  16145. this.txtLevel = this.game.add.bitmapText(this.game.width / 2, 10, 'grobold', '关卡: ' + (BasicGame.currentLevel + 1).toString());
  16146. this.txtLevel.x -= (this.txtLevel.textWidth / 2);
  16147. if (this.game.device.desktop) {
  16148. var btnDown = this.add.button(this.game.width / 2, this.game.height - 10, this.levelAtlas, btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download');
  16149. btnDown.anchor.setTo(0.5, 1);
  16150. btnDown.input.useHandCursor = true
  16151. }
  16152. if (this.game.device.desktop) {
  16153. this.btnPause.input.useHandCursor = true;
  16154. this.btnRestart.input.useHandCursor = true;
  16155. }
  16156. this.pnlPause = new BasicGame.PanelPause(this.game, 0, 0, this.unpause, this);
  16157. this.pnlPause.visible = false;
  16158. this.game.world.alpha = 0;
  16159. this.tweenFadeIn = this.game.add.tween(this.game.world).to({
  16160. alpha: 1
  16161. }, 500, Phaser.Easing.Quadratic.In, true);
  16162. this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
  16163. this.tweenFadeIn.start();
  16164. this.game.input.onDown.add(this.tappedCallback, this);
  16165. this.physics.p2.onBeginContact.add(this.bodiesCollide, this)
  16166. },
  16167. btnSponsorImgPressed: function() {
  16168. if (this.pressable) {
  16169. sponsorLinkOpen()
  16170. }
  16171. },
  16172. removeGood: function(bodyGood) {
  16173. for (var j = this.objectsGood.length - 1; j >= 0; j--) {
  16174. if (this.objectsGood[j].body.id == bodyGood.id) {
  16175. splice1(this.objectsGood, j);
  16176. break
  16177. }
  16178. }
  16179. bodyGood.parent.sprite.destroy()
  16180. },
  16181. bodiesCollide: function(bodyA, bodyB, shapeA, shapeB, contactEquations) {
  16182. var i = 0;
  16183. for (i = this.objectsGood.length - 1; i >= 0; i--) {
  16184. if (this.objectsGood[i].body.id == bodyA.id) {
  16185. if (this.solveForGood(bodyA, bodyB)) {
  16186. this.removeGood(bodyA);
  16187. if (this.objectsGood.length == 0) {
  16188. this.levelWin()
  16189. }
  16190. }
  16191. return
  16192. }
  16193. }
  16194. for (i = this.objectsBad.length - 1; i >= 0; i--) {
  16195. if (this.objectsBad[i].body.id == bodyA.id) {
  16196. this.solveForBad(bodyA, bodyB);
  16197. return
  16198. }
  16199. }
  16200. for (i = this.objectsGoal.length - 1; i >= 0; i--) {
  16201. if (this.objectsGoal[i].body.id == bodyA.id) {
  16202. this.solveForGoal(bodyA, bodyB);
  16203. return
  16204. }
  16205. }
  16206. },
  16207. solveForGood: function(bodyGood, bodyOther) {
  16208. if (!this.pressable) {
  16209. return
  16210. }
  16211. var i = 0;
  16212. for (i = this.objectsBad.length - 1; i >= 0; i--) {
  16213. if (this.objectsBad[i].body.id == bodyOther.id) {
  16214. if (bodyGood.parent.sprite.frameName.indexOf('circle') > 0) {
  16215. bodyGood.parent.sprite.frameName = 'good_circle_lose'
  16216. } else {
  16217. bodyGood.parent.sprite.frameName = 'good_rect_lose'
  16218. }
  16219. this.levelLose();
  16220. return false
  16221. }
  16222. }
  16223. for (i = this.objectsGoal.length - 1; i >= 0; i--) {
  16224. if (this.objectsGoal[i].body.id == bodyOther.id) {
  16225. bodyOther.parent.sprite.animations.play('filled');
  16226. return true
  16227. }
  16228. }
  16229. return false
  16230. },
  16231. solveForBad: function(bodyBad, bodyOther) {
  16232. if (!this.pressable) {
  16233. return
  16234. }
  16235. var i = 0;
  16236. for (i = this.objectsGood.length - 1; i >= 0; i--) {
  16237. if (this.objectsGood[i].body.id == bodyOther.id) {
  16238. if (bodyOther.parent.sprite.frameName.indexOf('circle') > 0) {
  16239. bodyOther.parent.sprite.frameName = 'good_circle_lose'
  16240. } else {
  16241. bodyOther.parent.sprite.frameName = 'good_rect_lose'
  16242. }
  16243. this.levelLose();
  16244. return
  16245. }
  16246. }
  16247. for (i = this.objectsGoal.length - 1; i >= 0; i--) {
  16248. if (this.objectsGoal[i].body.id == bodyOther.id) {
  16249. this.levelLose();
  16250. return
  16251. }
  16252. }
  16253. },
  16254. solveForGoal: function(bodyGoal, bodyOther) {
  16255. if (!this.pressable) {
  16256. return
  16257. }
  16258. var i = 0;
  16259. for (i = this.objectsGood.length - 1; i >= 0; i--) {
  16260. if (this.objectsGood[i].body.id == bodyOther.id) {
  16261. bodyGoal.parent.sprite.animations.play('filled');
  16262. this.removeGood(bodyOther);
  16263. if (this.objectsGood.length == 0) {
  16264. this.levelWin()
  16265. }
  16266. return
  16267. }
  16268. }
  16269. for (i = this.objectsBad.length - 1; i >= 0; i--) {
  16270. if (this.objectsBad[i].body.id == bodyOther.id) {
  16271. this.levelLose();
  16272. return
  16273. }
  16274. }
  16275. },
  16276. tappedCallback: function(pointer) {
  16277. if (!this.pressable || this.paused || this.objectsWood.length <= 0) {
  16278. return
  16279. }
  16280. var bodies = this.physics.p2.hitTest(pointer.position, this.objectsWood);
  16281. if (bodies.length > 0) {
  16282. for (var j = this.objectsWood.length - 1; j >= 0; j--) {
  16283. if (this.objectsWood[j].body.id == bodies[0].id) {
  16284. splice1(this.objectsWood, j);
  16285. this.objectRemoveCount++;
  16286. var strStarsEarnable = '';
  16287. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][0]) {
  16288. this.imgStarUi1.visible = false
  16289. } else {
  16290. strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][0] - this.objectRemoveCount)
  16291. }
  16292. strStarsEarnable += '\n';
  16293. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][1]) {
  16294. this.imgStarUi2.visible = false
  16295. } else {
  16296. strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][1] - this.objectRemoveCount)
  16297. }
  16298. strStarsEarnable += '\n';
  16299. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][2]) {
  16300. this.imgStarUi3.visible = false
  16301. } else {
  16302. strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][2] - this.objectRemoveCount)
  16303. }
  16304. this.txtStarsEarn.text = strStarsEarnable;
  16305. if (this.tutorialFinger != null) {
  16306. this.tutorialFinger.destroy();
  16307. this.tutorialFinger = null
  16308. }
  16309. if (this.tutorialSpot != null) {
  16310. this.tutorialSpot.destroy();
  16311. this.tutorialSpot = null
  16312. }
  16313. if (this.tutorialTween != null) {
  16314. this.tutorialTween.stop();
  16315. this.tutorialTween = null
  16316. }
  16317. if (!GC.soundDisabled) {
  16318. this.soundObjectRemove.play('', 0, (GC.playSound ? 1 : 0), false)
  16319. }
  16320. break
  16321. }
  16322. }
  16323. var indexOfJoint = this.pivotJointNameList.indexOf(bodies[0].parent.sprite.name);
  16324. if (indexOfJoint >= 0) {
  16325. this.removeWitnName(bodies[0].parent.sprite.name + '_pivot');
  16326. splice1(this.pivotJointNameList, indexOfJoint)
  16327. }
  16328. bodies[0].parent.sprite.destroy()
  16329. }
  16330. },
  16331. removeWitnName: function(name) {
  16332. for (var i = this.world.children.length - 1; i >= 0; i--) {
  16333. if (this.world.children[i].name == name) {
  16334. this.world.children[i].destroy();
  16335. return
  16336. }
  16337. }
  16338. },
  16339. setPaused: function(value) {
  16340. this.paused = value;
  16341. this.physics.p2.paused = this.paused
  16342. },
  16343. loadLevel: function(levelNum) {
  16344. if (BasicGame.Levels[levelNum] == undefined) {
  16345. return
  16346. }
  16347. this.currentMap = BasicGame.Levels[levelNum];
  16348. var obj;
  16349. var b;
  16350. var spr;
  16351. var i = 0;
  16352. var j = 0;
  16353. for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
  16354. obj = this.currentMap.objects['objects'][i];
  16355. if (obj.type == 'goal') {
  16356. spr = this.addGoalObject(obj);
  16357. this.objectsGoal[this.objectsGoal.length] = spr
  16358. }
  16359. }
  16360. for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
  16361. obj = this.currentMap.objects['objects'][i];
  16362. spr = null;
  16363. if (obj.type == 'good') {
  16364. spr = this.addGoodObject(obj);
  16365. this.objectsGood[this.objectsGood.length] = spr
  16366. } else if (obj.type == 'bad') {
  16367. spr = this.addBadObject(obj);
  16368. this.objectsBad[this.objectsBad.length] = spr
  16369. } else if (obj.type == 'wood') {
  16370. spr = this.addWoodObject(obj);
  16371. this.objectsWood[this.objectsWood.length] = spr
  16372. } else if (obj.type == 'stone') {
  16373. spr = this.addStoneObject(obj);
  16374. this.objectsStone[this.objectsStone.length] = spr
  16375. }
  16376. if (spr == null) {
  16377. continue
  16378. }
  16379. if (obj.name) {
  16380. spr.name = obj.name
  16381. }
  16382. if (obj.properties) {
  16383. if (obj.properties.offsetX) spr.body.x += Number(obj.properties.offsetX);
  16384. if (obj.properties.offsetY) spr.body.y += Number(obj.properties.offsetY);
  16385. if (obj.properties.rotation) spr.body.angle = Number(obj.properties.rotation);
  16386. spr.body.data.updateAABB()
  16387. }
  16388. }
  16389. spr = null;
  16390. for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
  16391. obj = this.currentMap.objects['objects'][i];
  16392. if (obj.type == 'tutorial') {
  16393. if (obj.name == 'pointer') {
  16394. this.tutorialSpot = this.add.sprite(obj.x + 10, obj.y, this.levelAtlas, 'tutorial_spot');
  16395. this.tutorialSpot.anchor.setTo(0.5, 0.5);
  16396. this.tutorialSpot.alpha = 0;
  16397. spr = this.add.sprite(obj.x + 20, obj.y + 75, this.levelAtlas, 'tutorial_pointer');
  16398. this.tutorialFinger = spr;
  16399. spr.angle = -20;
  16400. spr.name = String(obj.x - 20);
  16401. this.tutorialTween = this.add.tween(spr).to({
  16402. x: obj.x - 20,
  16403. y: obj.y
  16404. }, 1500, Phaser.Easing.Quadratic.Out, true, 0, Number.MAX_VALUE, true);
  16405. this.tutorialTween.onLoop.add(this.tutorialFingerFinished, this)
  16406. } else {
  16407. spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'tutorial_' + obj.name);
  16408. spr.anchor.setTo(0.5, 0.5)
  16409. }
  16410. } else if (obj.type == 'pivot_joint') {
  16411. if (obj.properties.object == '' || obj.properties.object == undefined) {
  16412. continue
  16413. }
  16414. for (j = this.world.children.length - 1; j >= 0; j--) {
  16415. if (obj.properties.object == this.world.children[j].name) {
  16416. this.addPivotJointToSprite(obj, this.world.children[j]);
  16417. break
  16418. }
  16419. }
  16420. }
  16421. }
  16422. },
  16423. addPivotJointToSprite: function(obj, spr) {
  16424. var sprPivot = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'pivot_joint');
  16425. sprPivot.anchor.setTo(0.5, 0.5);
  16426. sprPivot.name = spr.name + '_pivot';
  16427. this.physics.p2.enableBody(sprPivot, BasicGame.debugPhysics);
  16428. sprPivot.body.mass = 1;
  16429. sprPivot.body.static = true;
  16430. sprPivot.body.x = obj.x;
  16431. sprPivot.body.y = obj.y;
  16432. var physicsPos = [this.physics.p2.pxmi(obj.x), this.physics.p2.pxmi(obj.y)];
  16433. var localPointInBody = [0, 0];
  16434. spr.body.toLocalFrame(localPointInBody, physicsPos);
  16435. var constraint = this.game.physics.p2.createRevoluteConstraint(sprPivot, [0, 0], spr.body, [this.physics.p2.mpxi(localPointInBody[0]), this.physics.p2.mpxi(localPointInBody[1])]);
  16436. constraint.collideConnected = false;
  16437. this.pivotJointNameList[this.pivotJointNameList.length] = spr.name;
  16438. if (obj.properties.motor) {
  16439. constraint.enableMotor();
  16440. constraint.setMotorSpeed(parseFloat(obj.properties.motor))
  16441. }
  16442. },
  16443. tutorialFingerFinished: function() {
  16444. if (String(arguments[0].x) == arguments[0].name) {
  16445. if (this.tutorialSpot != null) {
  16446. this.tutorialSpot.alpha = 1;
  16447. this.tutorialSpot.scale.x = this.tutorialSpot.scale.y = 0.6;
  16448. this.add.tween(this.tutorialSpot.scale).to({
  16449. x: 1.5,
  16450. y: 1.5
  16451. }, 700, Phaser.Easing.Cubic.Out, true, 0, 0, false);
  16452. this.add.tween(this.tutorialSpot).to({
  16453. alpha: 0
  16454. }, 1000, Phaser.Easing.Cubic.Out, true, 0, 0, false)
  16455. }
  16456. }
  16457. },
  16458. addGoodObject: function(obj) {
  16459. var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, (obj.rectangle ? 'good_rect_normal' : 'good_circle_normal'));
  16460. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16461. if (obj.rectangle) {
  16462. spr.body.setRectangle(50, 50, 25, 25)
  16463. } else {
  16464. spr.body.setCircle(25, 25, 25)
  16465. }
  16466. spr.body.mass = spr.body.data.shapes[0].area;
  16467. if (obj.properties.static) {
  16468. spr.body.static = true
  16469. } else {
  16470. spr.body.dynamic = true;
  16471. spr.body.data.updateAABB()
  16472. }
  16473. spr.body.x = obj.x;
  16474. spr.body.y = obj.y;
  16475. spr.body.adjustCenterOfMass();
  16476. if (BasicGame.debugPhysics) {
  16477. spr.body.debug = true
  16478. }
  16479. if (BasicGame.debugPhysics) {
  16480. spr.body.debugBody.draw()
  16481. }
  16482. spr.body.velocity.x = spr.body.velocity.y = 0;
  16483. return spr
  16484. },
  16485. addBadObject: function(obj) {
  16486. var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, (obj.rectangle ? 'bad_rect_normal' : 'bad_circle_normal'));
  16487. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16488. if (obj.rectangle) {
  16489. spr.body.setRectangle(50, 50, 25, 25);
  16490. spr.animations.add('lose', ['bad_rect_normal', 'bad_rect_lose'], 8, true, false)
  16491. } else {
  16492. spr.body.setCircle(25, 25, 25);
  16493. spr.animations.add('lose', ['bad_circle_normal', 'bad_circle_lose'], 8, true, false)
  16494. }
  16495. spr.body.mass = spr.body.data.shapes[0].area;
  16496. if (obj.properties.static) {
  16497. spr.body.static = true;
  16498. spr.body.data.updateAABB()
  16499. } else {
  16500. spr.body.dynamic = true
  16501. }
  16502. spr.body.x = obj.x;
  16503. spr.body.y = obj.y;
  16504. spr.body.adjustCenterOfMass();
  16505. if (BasicGame.debugPhysics) {
  16506. spr.body.debug = true
  16507. }
  16508. if (BasicGame.debugPhysics) {
  16509. spr.body.debugBody.draw()
  16510. }
  16511. spr.body.velocity.x = spr.body.velocity.y = 0;
  16512. return spr
  16513. },
  16514. addGoalObject: function(obj) {
  16515. var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'goal_normal');
  16516. spr.animations.add('filled', ['goal_filled_0', 'goal_filled_1', 'goal_filled_0'], 2, true, false);
  16517. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16518. spr.body.setCircle(10, 35, 55);
  16519. spr.body.data.shapes[0].sensor = true;
  16520. spr.body.mass = 10;
  16521. spr.body.static = true;
  16522. spr.body.x = obj.x;
  16523. spr.body.y = obj.y;
  16524. spr.body.adjustCenterOfMass();
  16525. spr.anchor.setTo(0.5, 0.91);
  16526. if (BasicGame.debugPhysics) {
  16527. spr.body.debug = true
  16528. }
  16529. if (BasicGame.debugPhysics) {
  16530. spr.body.debugBody.draw()
  16531. }
  16532. spr.body.velocity.x = spr.body.velocity.y = 0;
  16533. return spr
  16534. },
  16535. addStoneObject: function(obj) {
  16536. var spr;
  16537. if (obj.rectangle) {
  16538. spr = this.tempCreateRectSprite(obj, '#808080')
  16539. } else if (obj.ellipse) {
  16540. spr = this.tempCreateCircleSprite(obj, '#808080')
  16541. } else if (obj.polygon) {
  16542. spr = this.tempCreatePolygonSprite(obj, '#808080')
  16543. }
  16544. spr.body.mass = spr.body.data.shapes[0].area * 2.5;
  16545. if (obj.properties.static) {
  16546. spr.body.static = true
  16547. } else {
  16548. spr.body.dynamic = true;
  16549. spr.body.data.updateAABB()
  16550. }
  16551. if (BasicGame.debugPhysics) {
  16552. spr.body.debug = true
  16553. }
  16554. if (BasicGame.debugPhysics) {
  16555. spr.body.debugBody.draw()
  16556. }
  16557. spr.body.velocity.x = spr.body.velocity.y = 0;
  16558. return spr
  16559. },
  16560. addWoodObject: function(obj) {
  16561. var spr;
  16562. if (obj.rectangle) {
  16563. spr = this.tempCreateRectSprite(obj, '#7F3300')
  16564. } else if (obj.ellipse) {
  16565. spr = this.tempCreateCircleSprite(obj, '#7F3300')
  16566. } else if (obj.polygon) {
  16567. spr = this.tempCreatePolygonSprite(obj, '#7F3300')
  16568. }
  16569. spr.body.mass = spr.body.data.shapes[0].area * 0.7;
  16570. if (obj.properties.static) {
  16571. spr.body.static = true
  16572. } else {
  16573. spr.body.dynamic = true;
  16574. spr.body.data.updateAABB()
  16575. }
  16576. if (BasicGame.debugPhysics) {
  16577. spr.body.debug = true
  16578. }
  16579. if (BasicGame.debugPhysics) {
  16580. spr.body.debugBody.draw()
  16581. }
  16582. spr.body.velocity.x = spr.body.velocity.y = 0;
  16583. return spr
  16584. },
  16585. tempCreatePolygonSprite: function(obj, color) {
  16586. var polys = [];
  16587. var len = obj.polygon.length;
  16588. for (var j = 0; j < len; j++) {
  16589. polys[j] = [obj.polygon[j][0], obj.polygon[j][1]]
  16590. }
  16591. var spr;
  16592. if (BasicGame.loadPreTextured) {
  16593. spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, this.levelAtlasPrefix + obj.name)
  16594. } else {
  16595. var spr = this.add.sprite(obj.x, obj.x)
  16596. }
  16597. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16598. spr.body.addPolygon({
  16599. optimalDecomp: false,
  16600. skipSimpleCheck: true,
  16601. removeCollinearPoints: false
  16602. }, polys);
  16603. spr.body.mass = 10;
  16604. spr.body.adjustCenterOfMass();
  16605. spr.body.data.updateAABB();
  16606. spr.body.data.updateBoundingRadius();
  16607. var points = spr.body.data.shapes[0].vertices;
  16608. var shapeWidth = Math.abs(this.physics.p2.mpxi(spr.body.data.aabb.lowerBound[0]) - this.physics.p2.mpxi(spr.body.data.aabb.upperBound[0]));
  16609. var shapeHeight = Math.abs(this.physics.p2.mpxi(spr.body.data.aabb.lowerBound[1]) - this.physics.p2.mpxi(spr.body.data.aabb.upperBound[1]));
  16610. if (!BasicGame.loadPreTextured) {
  16611. var renderTarget = new Phaser.BitmapData(this, 'scenery' + this.levelAtlasPrefix + obj.name, shapeWidth, shapeHeight)
  16612. }
  16613. var minXP = Number.MAX_VALUE,
  16614. minYP = Number.MAX_VALUE;
  16615. for (j = points.length - 1; j >= 0; j--) {
  16616. minXP = this.math.min(minXP, this.physics.p2.mpxi(points[j][0]));
  16617. minYP = this.math.min(minYP, this.physics.p2.mpxi(points[j][1]))
  16618. }
  16619. var offsetX = (shapeWidth / 2) + minXP;
  16620. var offsetY = (shapeHeight / 2) + minYP;
  16621. if (!BasicGame.loadPreTextured) {
  16622. renderTarget.ctx.translate(-offsetX, -offsetY);
  16623. renderTarget.ctx.fillStyle = color;
  16624. renderTarget.ctx.beginPath();
  16625. renderTarget.ctx.moveTo((this.physics.p2.mpxi(points[0][0]) + shapeWidth * 0.5), (this.physics.p2.mpxi(points[0][1]) + shapeHeight * 0.5));
  16626. for (j = 1; j < points.length; j++) {
  16627. renderTarget.ctx.lineTo((this.physics.p2.mpxi(points[j][0]) + shapeWidth * 0.5), (this.physics.p2.mpxi(points[j][1]) + shapeHeight * 0.5))
  16628. }
  16629. renderTarget.ctx.closePath();
  16630. renderTarget.ctx.fill();
  16631. spr.loadTexture(renderTarget)
  16632. }
  16633. spr.anchor.setTo(0.5 - (offsetX / shapeWidth), 0.5 - (offsetY / shapeHeight));
  16634. spr.body.x = obj.x - minXP;
  16635. spr.body.y = obj.y - minYP;
  16636. return spr
  16637. },
  16638. tempCreateRectSprite: function(obj, color) {
  16639. if (BasicGame.loadPreTextured) {
  16640. var spr = this.add.sprite(obj.x, obj.x, this.levelAtlas, this.levelAtlasPrefix + obj.name)
  16641. } else {
  16642. var spr = this.add.sprite(obj.x, obj.x)
  16643. }
  16644. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16645. if (!BasicGame.loadPreTextured) {
  16646. var b = this.make.bitmapData(obj.width, obj.height);
  16647. b.ctx.fillStyle = color;
  16648. b.rect(0, 0, obj.width, obj.height);
  16649. spr.loadTexture(b)
  16650. }
  16651. spr.body.setRectangle(obj.width, obj.height, obj.width / 2, obj.height / 2);
  16652. spr.body.adjustCenterOfMass();
  16653. spr.body.x = obj.x + obj.width / 2;
  16654. spr.body.y = obj.y + obj.height / 2;
  16655. return spr
  16656. },
  16657. tempCreateCircleSprite: function(obj, color) {
  16658. if (BasicGame.loadPreTextured) {
  16659. var spr = this.add.sprite(obj.x, obj.x, this.levelAtlas, this.levelAtlasPrefix + obj.name)
  16660. } else {
  16661. var spr = this.add.sprite(obj.x, obj.x)
  16662. }
  16663. this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
  16664. if (!BasicGame.loadPreTextured) {
  16665. var b = this.make.bitmapData(obj.width, obj.width);
  16666. b.ctx.fillStyle = color;
  16667. b.circle(obj.width / 2, obj.width / 2, obj.width / 2);
  16668. spr.loadTexture(b)
  16669. }
  16670. spr.body.setCircle(obj.width / 2, obj.width / 2, obj.width / 2);
  16671. spr.body.adjustCenterOfMass();
  16672. spr.body.x = obj.x + obj.width / 2;
  16673. spr.body.y = obj.y + obj.width / 2;
  16674. return spr
  16675. },
  16676. fadeInCompleted: function() {
  16677. this.pressable = true
  16678. },
  16679. update: function() {
  16680. if (!this.game.paused) {
  16681. for (var i = this.objectsGood.length - 1; i >= 0; i--) {
  16682. if (!this.objectsGood[i].inCamera) {
  16683. if (this.objectsGood[i].y > 0) {
  16684. this.levelLose();
  16685. break
  16686. }
  16687. }
  16688. }
  16689. }
  16690. },
  16691. levelWin: function() {
  16692. if (this.pressable) {
  16693. if (BasicGame.sndGameLoop.isPlaying) {
  16694. BasicGame.sndGameLoop.stop()
  16695. }
  16696. if (!GC.soundDisabled) {
  16697. this.soundWin.play('', 0, (GC.playSound ? 1 : 0), false)
  16698. }
  16699. BasicGame.winStarsCurrent = 3;
  16700. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][0]) {
  16701. BasicGame.winStarsCurrent = 2
  16702. }
  16703. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][1]) {
  16704. BasicGame.winStarsCurrent = 1
  16705. }
  16706. if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][2]) {
  16707. BasicGame.winStarsCurrent = 0
  16708. }
  16709. BasicGame.LevelStars[BasicGame.currentLevel] = (BasicGame.winStarsCurrent > BasicGame.winStarsPrevious ? BasicGame.winStarsCurrent : BasicGame.winStarsPrevious);
  16710. if (BasicGame.currentLevel < GC.totalLevels - 1) {
  16711. BasicGame.LevelsOpen[BasicGame.currentLevel + 1] = 1
  16712. }
  16713. BasicGame.saveGame();
  16714. this.pressable = false;
  16715. this.fadeOutState = 'state_win_panel';
  16716. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  16717. alpha: 0
  16718. }, 300, Phaser.Easing.Quadratic.Out, true, 1300);
  16719. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  16720. this.tweenFadeOut.start()
  16721. }
  16722. },
  16723. levelLose: function() {
  16724. if (this.pressable) {
  16725. if (BasicGame.sndGameLoop.isPlaying) {
  16726. BasicGame.sndGameLoop.stop()
  16727. }
  16728. if (!GC.soundDisabled) {
  16729. this.soundFail.play('', 0, (GC.playSound ? 1 : 0), false)
  16730. }
  16731. for (var j = this.objectsBad.length - 1; j >= 0; j--) {
  16732. this.objectsBad[j].animations.play('lose')
  16733. }
  16734. this.pressable = false;
  16735. this.fadeOutState = 'state_lose_panel';
  16736. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  16737. alpha: 0
  16738. }, 300, Phaser.Easing.Quadratic.Out, true, 1300);
  16739. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  16740. this.tweenFadeOut.start()
  16741. }
  16742. },
  16743. btnPausePressed: function() {
  16744. if (this.pressable) {
  16745. if (!GC.soundDisabled) {
  16746. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16747. }
  16748. this.setPaused(true);
  16749. this.pressable = false;
  16750. this.world.add(this.pnlPause);
  16751. this.pnlPause.visible = true
  16752. }
  16753. },
  16754. btnRestartPressed: function() {
  16755. if (this.pressable) {
  16756. this.pressable = false;
  16757. this.game.state.restart(true)
  16758. }
  16759. },
  16760. unpause: function() {
  16761. this.setPaused(false);
  16762. this.pressable = true
  16763. },
  16764. fadeOutCompleted: function() {
  16765. this.game.state.start(this.fadeOutState)
  16766. },
  16767. shutdown: function() {
  16768. this.soundClick.destroy(true);
  16769. this.soundWin.destroy(true);
  16770. this.soundFail.destroy(true);
  16771. this.btnPlay = null;
  16772. if (this.pnlPause != null) {
  16773. this.pnlPause.destroy(true);
  16774. this.pnlPause = null
  16775. }
  16776. }
  16777. };
  16778. BasicGame.PanelPause = function(game, x, y, closeCallback, closeCallbackContext) {
  16779. this.callbackClose = closeCallback;
  16780. this.callbackCloseContext = closeCallbackContext;
  16781. this.soundOnImage = game.cache._images['atlas_intermenu'].frameData._frameNames['btn_sound_on'];
  16782. this.soundOffImage = game.cache._images['atlas_intermenu'].frameData._frameNames['btn_sound_off'];
  16783. this.soundClick = new Phaser.Sound(game, 'sndButtonClick', 1, false);
  16784. Phaser.TileSprite.call(this, game, x, y, game.width, game.height, 'atlas_intermenu', 'black_bg');
  16785. var sprOverlay = new Phaser.Sprite(this.game, this.game.width / 2, 0, 'atlas_intermenu', 'pause_overlay');
  16786. sprOverlay.anchor.set(0.5, 0);
  16787. this.addChild(sprOverlay);
  16788. this.btnResume = new Phaser.Button(this.game, this.game.width / 2, this.game.height / 2 - 40, 'atlas_intermenu', this.btnResumePressed, this, 'btn_next_large', 'btn_next_large', 'btn_next_large');
  16789. this.btnResume.anchor.set(0.5, 0);
  16790. this.addChild(this.btnResume);
  16791. this.btnRetry = new Phaser.Button(this.game, 20, this.game.height - 85, 'atlas_intermenu', this.btnRetryPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
  16792. this.btnRetry.anchor.set(0, 1);
  16793. this.addChild(this.btnRetry);
  16794. this.btnHome = new Phaser.Button(this.game, this.game.width / 2 - 60, this.game.height - 85, 'atlas_intermenu', this.btnHomePressed, this, 'btn_home', 'btn_home', 'btn_home');
  16795. this.btnHome.anchor.set(0.5, 1);
  16796. this.addChild(this.btnHome);
  16797. this.btnSound = new Phaser.Button(this.game, this.game.width / 2 + 60, this.game.height - 85, 'atlas_intermenu', this.btnSoundClicked, this, 'btn_sound_on', 'btn_sound_on', 'btn_sound_on');
  16798. this.btnSound.anchor.setTo(0.5, 0.5);
  16799. this.btnSound.y -= this.btnSound.height / 2;
  16800. this.addChild(this.btnSound);
  16801. if (this.game.sound.mute) {
  16802. this.btnSound.frame = this.soundOffImage
  16803. }
  16804. this.btnGames = new Phaser.Button(this.game, this.game.width - 20, this.game.height - 85, 'atlas_intermenu', this.btnGamesPressed, this, 'btn_games', 'btn_games', 'btn_games');
  16805. this.btnGames.anchor.set(0.5, 0.5);
  16806. this.btnGames.x -= this.btnGames.width / 2;
  16807. this.btnGames.y -= this.btnGames.height / 2;
  16808. this.addChild(this.btnGames);
  16809. if (this.game.device.desktop) {
  16810. this.btnResume.input.useHandCursor = true;
  16811. this.btnRetry.input.useHandCursor = true;
  16812. this.btnHome.input.useHandCursor = true;
  16813. this.btnSound.input.useHandCursor = true;
  16814. this.btnGames.input.useHandCursor = true;
  16815. }
  16816. };
  16817. BasicGame.PanelPause.prototype = Object.create(Phaser.TileSprite.prototype);
  16818. BasicGame.PanelPause.prototype.constructor = BasicGame.PanelPause;
  16819. BasicGame.PanelPause.prototype.btnResumePressed = function() {
  16820. if (this.callbackClose) {
  16821. this.callbackClose.call(this.callbackCloseContext)
  16822. }
  16823. this.game.world.remove(this, false);
  16824. this.visible = false
  16825. };
  16826. BasicGame.PanelPause.prototype.btnSponsorImgPressed = function() {
  16827. sponsorLinkOpen()
  16828. };
  16829. BasicGame.PanelPause.prototype.btnSoundClicked = function() {
  16830. if (!GC.soundDisabled) {
  16831. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16832. }
  16833. this.btnSound.scale.x = this.btnSound.scale.y = 1;
  16834. this.game.add.tween(this.btnSound.scale).to({
  16835. x: 1.2,
  16836. y: 0.8
  16837. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  16838. this.game.sound.mute = !this.game.sound.mute;
  16839. if (this.game.sound.mute) {
  16840. this.btnSound.frame = this.soundOffImage
  16841. } else {
  16842. this.btnSound.frame = this.soundOnImage
  16843. }
  16844. if (BasicGame.sndMenuLoop.isPlaying) {
  16845. BasicGame.sndMenuLoop.volume = (GC.playSound ? 1 : 0)
  16846. }
  16847. if (BasicGame.sndGameLoop.isPlaying) {
  16848. BasicGame.sndGameLoop.volume = (GC.playSound ? 1 : 0)
  16849. }
  16850. };
  16851. BasicGame.PanelPause.prototype.btnHomePressed = function() {
  16852. if (!GC.soundDisabled) {
  16853. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16854. }
  16855. this.game.add.tween(this.btnHome.scale).to({
  16856. x: 1.2,
  16857. y: 0.8
  16858. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  16859. this.game.state.start('state_level_select');
  16860. this.game.world.remove(this, true);
  16861. this.visible = false
  16862. };
  16863. BasicGame.PanelPause.prototype.btnRetryPressed = function() {
  16864. if (!GC.soundDisabled) {
  16865. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16866. }
  16867. this.game.state.restart(true)
  16868. };
  16869. BasicGame.PanelPause.prototype.btnGamesPressed = function() {
  16870. if (!GC.soundDisabled) {
  16871. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  16872. }
  16873. this.btnGames.scale.x = this.btnGames.scale.y = 1;
  16874. this.game.add.tween(this.btnGames.scale).to({
  16875. x: 1.2,
  16876. y: 0.8
  16877. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  16878. sponsorLinkOpen()
  16879. };
  16880. BasicGame.StateWinPanel = function() {};
  16881. BasicGame.StateWinPanel.prototype = {
  16882. initVars: function() {
  16883. this.pressable = false;
  16884. this.fadeOutState = 'state_game';
  16885. this.animateStarCount = 0;
  16886. this.tweenObj = null
  16887. },
  16888. create: function() {
  16889. adProcess();
  16890. if (BasicGame.sndGameLoop.isPlaying) {
  16891. BasicGame.sndGameLoop.stop()
  16892. }
  16893. this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
  16894. this.soundWin1 = this.game.add.audio('sndWinStar1', 1, false);
  16895. this.soundWin2 = this.game.add.audio('sndWinStar2', 1, false);
  16896. this.soundWin3 = this.game.add.audio('sndWinStar3', 1, false);
  16897. this.pressable = false;
  16898. this.fadeOutState = 'state_game';
  16899. this.imgBg = this.add.image(0, 0, 'atlas_intermenu', 'pause_menu_background');
  16900. this.imgOverlay = this.add.image(this.game.width / 2, 15, 'atlas_intermenu', 'win_overlay');
  16901. this.imgOverlay.anchor.set(0.5, 0);
  16902. this.imgStar1 = this.make.image(138 - this.imgOverlay.width / 2, 85 + 105 * 2, 'atlas_intermenu', 'win_star_1');
  16903. this.imgStar2 = this.make.image(246 - this.imgOverlay.width / 2, 85 + 105 * 2, 'atlas_intermenu', 'win_star_2');
  16904. this.imgStar3 = this.make.image(192 - this.imgOverlay.width / 2, 39 + 155 * 2, 'atlas_intermenu', 'win_star_3');
  16905. this.imgStar1.anchor.x = 1;
  16906. this.imgStar2.anchor.x = 0;
  16907. this.imgStar3.anchor.x = 0.5;
  16908. this.imgStar1.anchor.y = this.imgStar2.anchor.y = this.imgStar3.anchor.y = 2;
  16909. this.imgOverlay.addChild(this.imgStar1);
  16910. this.imgOverlay.addChild(this.imgStar2);
  16911. this.imgOverlay.addChild(this.imgStar3);
  16912. this.imgStar1.name = 'star_1';
  16913. this.imgStar2.name = 'star_2';
  16914. this.imgStar3.name = 'star_3';
  16915. this.imgStar1.visible = this.imgStar2.visible = this.imgStar3.visible = false;
  16916. if (BasicGame.winStarsPrevious == 3) {
  16917. this.imgStar1.visible = this.imgStar2.visible = this.imgStar3.visible = true
  16918. } else if (BasicGame.winStarsPrevious == 2) {
  16919. this.imgStar1.visible = this.imgStar2.visible = true;
  16920. this.imgStar3.scale.set(2, 2)
  16921. } else if (BasicGame.winStarsPrevious == 1) {
  16922. this.imgStar1.visible = true;
  16923. this.imgStar2.scale.set(2, 2);
  16924. this.imgStar3.scale.set(2, 2)
  16925. } else {
  16926. this.imgStar1.scale.set(2, 2);
  16927. this.imgStar2.scale.set(2, 2);
  16928. this.imgStar3.scale.set(2, 2)
  16929. }
  16930. this.animateStarCount = BasicGame.winStarsCurrent - BasicGame.winStarsPrevious;
  16931. this.animateStarCount = Math.max(0, Math.min(3, this.animateStarCount));
  16932. this.btnNext = this.add.button(this.game.width / 2, this.game.height / 2 + 15, 'atlas_intermenu', this.btnNextPressed, this, 'btn_next_large', 'btn_next_large', 'btn_next_large');
  16933. this.btnNext.anchor.setTo(0.5, 0.5);
  16934. this.btnRestart = this.add.button(50, this.game.height - 60, 'atlas_intermenu', this.btnRestartPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
  16935. this.btnRestart.anchor.setTo(0.5, 0.5);
  16936. this.btnRestart.x += this.btnRestart.width / 2;
  16937. this.btnRestart.y -= this.btnRestart.height / 2;
  16938. this.btnHome = this.add.button(this.game.width / 2, this.game.height - 60, 'atlas_intermenu', this.btnHomePressed, this, 'btn_home', 'btn_home', 'btn_home');
  16939. this.btnHome.anchor.setTo(0.5, 0.5);
  16940. this.btnHome.y -= this.btnHome.height / 2;
  16941. this.btnGames = this.add.button(this.game.width - 50, this.game.height - 60, 'atlas_intermenu', this.btnGamesPressed, this, 'btn_games', 'btn_games', 'btn_games');
  16942. this.btnGames.anchor.setTo(0.5, 0.5);
  16943. this.btnGames.x -= this.btnGames.width / 2;
  16944. this.btnGames.y -= this.btnGames.height / 2;
  16945. var btnDown = null;
  16946. if (this.game.device.desktop) {
  16947. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  16948. } else if (this.game.device.android) {
  16949. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
  16950. } else if (this.game.device.iOS) {
  16951. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  16952. } else if (this.game.device.windowsPhone) {
  16953. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
  16954. } else {
  16955. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  16956. }
  16957. btnDown.anchor.setTo(0.5, 0);
  16958. btnDown.scale.setTo(1.3, 1.3);
  16959. if (this.game.device.desktop) {
  16960. this.btnNext.input.useHandCursor = true;
  16961. this.btnRestart.input.useHandCursor = true;
  16962. this.btnHome.input.useHandCursor = true;
  16963. this.btnGames.input.useHandCursor = true;
  16964. btnDown.input.useHandCursor = true;
  16965. }
  16966. this.game.world.alpha = 0;
  16967. this.tweenFadeIn = this.game.add.tween(this.game.world).to({
  16968. alpha: 1
  16969. }, 300, Phaser.Easing.Quadratic.In, true);
  16970. this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
  16971. this.tweenFadeIn.start()
  16972. },
  16973. btnSponsorImgPressed: function() {
  16974. if (this.pressable) {
  16975. sponsorLinkOpen()
  16976. }
  16977. },
  16978. fadeInCompleted: function() {
  16979. this.pressable = true;
  16980. this.animateNextStar()
  16981. },
  16982. animateNextStar: function() {
  16983. if (this.animateStarCount > 0) {
  16984. BasicGame.winStarsPrevious += 1;
  16985. this.animateStarCount -= 1;
  16986. if (BasicGame.winStarsPrevious == 1) {
  16987. this.tweenObj = this.imgStar1
  16988. } else if (BasicGame.winStarsPrevious == 2) {
  16989. this.tweenObj = this.imgStar2
  16990. } else if (BasicGame.winStarsPrevious == 3) {
  16991. this.tweenObj = this.imgStar3
  16992. }
  16993. this.tweenObj.visible = true;
  16994. this.add.tween(this.tweenObj.scale).to({
  16995. x: 1,
  16996. y: 1
  16997. }, 400, Phaser.Easing.Cubic.In, true).onComplete.addOnce(this.shakeCamera, this);
  16998. this.game.time.events.add(Phaser.Timer.SECOND / 5, this.middleAnimateStar, this)
  16999. }
  17000. },
  17001. middleAnimateStar: function() {
  17002. if (this.tweenObj != null && GC.playSound) {
  17003. if (this.tweenObj.name == 'star_1') {
  17004. if (!GC.soundDisabled) {
  17005. this.soundWin1.play('', 0, (GC.playSound ? 1 : 0), false)
  17006. }
  17007. } else if (this.tweenObj.name == 'star_2') {
  17008. if (!GC.soundDisabled) {
  17009. this.soundWin2.play('', 0, (GC.playSound ? 1 : 0), false)
  17010. }
  17011. } else if (this.tweenObj.name == 'star_3') {
  17012. if (!GC.soundDisabled) {
  17013. this.soundWin3.play('', 0, (GC.playSound ? 1 : 0), false)
  17014. }
  17015. }
  17016. }
  17017. },
  17018. shakeCamera: function() {
  17019. this.world.camera.x += 5;
  17020. this.world.camera.y += 5;
  17021. this.animateNextStar()
  17022. },
  17023. update: function() {
  17024. this.world.camera.x *= 0.9;
  17025. this.world.camera.y *= 0.9
  17026. },
  17027. shutdown: function() {
  17028. this.soundClick.destroy(true);
  17029. this.soundWin1.destroy(true);
  17030. this.soundWin2.destroy(true);
  17031. this.soundWin3.destroy(true);
  17032. this.world.camera.x = 0;
  17033. this.world.camera.y = 0;
  17034. if (BasicGame.winStarsCurrent > BasicGame.winStarsPrevious) {
  17035. BasicGame.winStarsPrevious = BasicGame.winStarsCurrent
  17036. }
  17037. this.imgOverlay = null;
  17038. this.btnNext = null;
  17039. this.btnRestart = null;
  17040. this.btnHome = null;
  17041. this.btnGames = null
  17042. },
  17043. btnNextPressed: function() {
  17044. if (this.pressable) {
  17045. if (!GC.soundDisabled) {
  17046. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17047. }
  17048. this.add.tween(this.btnNext.scale).to({
  17049. x: 1.2,
  17050. y: 0.8
  17051. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17052. this.pressable = false;
  17053. if (BasicGame.currentLevel >= GC.totalLevels - 1) {
  17054. this.fadeOutState = 'state_level_select'
  17055. } else {
  17056. this.fadeOutState = 'state_game';
  17057. BasicGame.currentLevel += 1
  17058. }
  17059. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  17060. alpha: 0
  17061. }, 400, Phaser.Easing.Quadratic.Out, true);
  17062. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  17063. this.tweenFadeOut.start()
  17064. }
  17065. },
  17066. btnRestartPressed: function() {
  17067. if (this.pressable) {
  17068. if (!GC.soundDisabled) {
  17069. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17070. }
  17071. this.add.tween(this.btnRestart.scale).to({
  17072. x: 1.2,
  17073. y: 0.8
  17074. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17075. this.pressable = false;
  17076. this.fadeOutState = 'state_game';
  17077. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  17078. alpha: 0
  17079. }, 400, Phaser.Easing.Quadratic.Out, true);
  17080. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  17081. this.tweenFadeOut.start()
  17082. }
  17083. },
  17084. btnHomePressed: function() {
  17085. if (this.pressable) {
  17086. if (!GC.soundDisabled) {
  17087. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17088. }
  17089. this.add.tween(this.btnHome.scale).to({
  17090. x: 1.2,
  17091. y: 0.8
  17092. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17093. this.pressable = false;
  17094. this.fadeOutState = 'state_level_select';
  17095. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  17096. alpha: 0
  17097. }, 400, Phaser.Easing.Quadratic.Out, true);
  17098. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  17099. this.tweenFadeOut.start()
  17100. }
  17101. },
  17102. btnGamesPressed: function() {
  17103. if (!GC.soundDisabled) {
  17104. this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17105. }
  17106. this.btnGames.scale.x = 1;
  17107. this.btnGames.scale.y = 1;
  17108. this.add.tween(this.btnGames.scale).to({
  17109. x: 1.2,
  17110. y: 0.8
  17111. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17112. sponsorLinkOpen()
  17113. },
  17114. fadeOutCompleted: function() {
  17115. this.game.state.start(this.fadeOutState)
  17116. }
  17117. };
  17118. BasicGame.StateLosePanel = function() {};
  17119. BasicGame.StateLosePanel.prototype = {
  17120. initVars: function() {},
  17121. create: function() {
  17122. adProcess();
  17123. this.sndButtonClick = this.game.add.audio('sndButtonClick', 1, false);
  17124. if (BasicGame.sndGameLoop.isPlaying) {
  17125. BasicGame.sndGameLoop.stop()
  17126. }
  17127. this.pressable = false;
  17128. this.fadeOutState = 'state_game';
  17129. this.imgBg = this.add.image(0, 0, 'atlas_intermenu', 'pause_menu_background');
  17130. this.imgOverlay = this.add.image(this.game.width / 2, 15, 'atlas_intermenu', 'lose_overlay');
  17131. this.imgOverlay.anchor.set(0.5, 0);
  17132. this.btnRetry = this.add.button(this.game.width / 2, this.game.height / 2 + 15, 'atlas_intermenu', this.btnRetryPressed, this, 'btn_retry_large', 'btn_retry_large', 'btn_retry_large');
  17133. this.btnRetry.anchor.setTo(0.5, 0.5);
  17134. this.btnHome = this.add.button(this.game.width / 2 - 15, this.game.height - 60, 'atlas_intermenu', this.btnHomePressed, this, 'btn_home', 'btn_home', 'btn_home');
  17135. this.btnHome.anchor.setTo(0.5, 0.5);
  17136. this.btnHome.x -= this.btnHome.width / 2;
  17137. this.btnHome.y -= this.btnHome.height / 2;
  17138. this.btnGames = this.add.button(this.game.width / 2 + 15, this.game.height - 60, 'atlas_intermenu', this.btnGamesPressed, this, 'btn_games', 'btn_games', 'btn_games');
  17139. this.btnGames.anchor.setTo(0.5, 0.5);
  17140. this.btnGames.x += this.btnGames.width / 2;
  17141. this.btnGames.y -= this.btnGames.height / 2;
  17142. var btnDown = null;
  17143. if (this.game.device.desktop) {
  17144. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  17145. } else if (this.game.device.android) {
  17146. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
  17147. } else if (this.game.device.iOS) {
  17148. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  17149. } else if (this.game.device.windowsPhone) {
  17150. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
  17151. } else {
  17152. btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
  17153. }
  17154. btnDown.anchor.setTo(0.5, 0);
  17155. btnDown.scale.setTo(1.3, 1.3);
  17156. if (this.game.device.desktop) {
  17157. this.btnRetry.input.useHandCursor = true;
  17158. this.btnHome.input.useHandCursor = true;
  17159. this.btnGames.input.useHandCursor = true;
  17160. btnDown.input.useHandCursor = true
  17161. }
  17162. this.game.world.alpha = 0;
  17163. this.tweenFadeIn = this.game.add.tween(this.game.world).to({
  17164. alpha: 1
  17165. }, 300, Phaser.Easing.Quadratic.In, true);
  17166. this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
  17167. this.tweenFadeIn.start()
  17168. },
  17169. btnSponsorImgPressed: function() {
  17170. if (this.pressable) {
  17171. sponsorLinkOpen()
  17172. }
  17173. },
  17174. fadeInCompleted: function() {
  17175. this.pressable = true
  17176. },
  17177. update: function() {},
  17178. shutdown: function() {},
  17179. btnRetryPressed: function() {
  17180. if (this.pressable) {
  17181. if (!GC.soundDisabled) {
  17182. this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17183. }
  17184. this.add.tween(this.btnRetry.scale).to({
  17185. x: 1.2,
  17186. y: 0.8
  17187. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17188. this.pressable = false;
  17189. this.fadeOutState = 'state_game';
  17190. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  17191. alpha: 0
  17192. }, 400, Phaser.Easing.Quadratic.Out, true);
  17193. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  17194. this.tweenFadeOut.start()
  17195. }
  17196. },
  17197. btnHomePressed: function() {
  17198. if (this.pressable) {
  17199. if (!GC.soundDisabled) {
  17200. this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17201. }
  17202. this.add.tween(this.btnHome.scale).to({
  17203. x: 1.2,
  17204. y: 0.8
  17205. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17206. this.pressable = false;
  17207. this.fadeOutState = 'state_level_select';
  17208. this.tweenFadeOut = this.game.add.tween(this.game.world).to({
  17209. alpha: 0
  17210. }, 400, Phaser.Easing.Quadratic.Out, true);
  17211. this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
  17212. this.tweenFadeOut.start()
  17213. }
  17214. },
  17215. btnGamesPressed: function() {
  17216. if (!GC.soundDisabled) {
  17217. this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
  17218. }
  17219. this.btnGames.scale.x = 1;
  17220. this.btnGames.scale.y = 1;
  17221. this.add.tween(this.btnGames.scale).to({
  17222. x: 1.2,
  17223. y: 0.8
  17224. }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
  17225. sponsorLinkOpen()
  17226. },
  17227. fadeOutCompleted: function() {
  17228. this.game.state.start(this.fadeOutState)
  17229. },
  17230. shutdown: function() {
  17231. this.sndButtonClick.destroy(true)
  17232. }
  17233. };
  17234. function splice1(a, i) {
  17235. var l = a.length;
  17236. if (l) {
  17237. while (i < l) {
  17238. a[i++] = a[i]
  17239. }--a.length
  17240. }
  17241. };
  17242. var screenFullResize = function() {
  17243. game.scale.setShowAll();
  17244. if (game.state.current == 'state_menu') {
  17245. var s = game.state.getCurrentState();
  17246. s.refreshFullscreenUi()
  17247. }
  17248. };
  17249. function menuClickedFullscreenCheck() {
  17250. if (screenfull.enabled) {
  17251. if (game.state.current == 'state_menu') {
  17252. var s = game.state.getCurrentState();
  17253. var p = game.input.activePointer.position;
  17254. var b = s.btnFullscreen;
  17255. var oX = b.anchor.x * b.width;
  17256. var oY = b.anchor.y * b.height;
  17257. if (!s.pressable || !(p.x > b.x - oX && p.x < b.x + b.width - oX && p.y > b.y - oY && p.y < b.y + b.height - oY)) {
  17258. return
  17259. }
  17260. }
  17261. if (screenfull.isFullscreen) {
  17262. screenfull.exit()
  17263. } else {
  17264. screenfull.request()
  17265. }
  17266. }
  17267. };
  17268. function sponsorLinkOpen() {
  17269. _czc.push(["_trackEvent","小虎回家","更多游戏","","",""]);
  17270. if(document.referrer)
  17271. Play68.goHome();
  17272. else
  17273. play68_goHome();
  17274. //window.open(BasicGame.linkDownloadPage, '_blank')
  17275. };
  17276. var adScaleX = 0.8;
  17277. var adScaleY = 0.8;
  17278. var adsAvailable = true;
  17279. function initAds() {
  17280. adserver.initialize(adServerSuccess, adServerFail, '');
  17281. if (game.device.desktop) {
  17282. adsAvailable = false;
  17283. return
  17284. }
  17285. var btnClose = document.getElementById('ad_close_button');
  17286. btnClose.onclick = function() {
  17287. hideInterstitialAd()
  17288. };
  17289. var bannerDiv = document.getElementById('banner_container');
  17290. if (!bannerDiv) {
  17291. return
  17292. }
  17293. bannerDiv.style.position = 'absolute';
  17294. bannerDiv.style.bottom = '0';
  17295. bannerDiv.style.msTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
  17296. bannerDiv.style.msTransformOrigin = '50% 100%';
  17297. bannerDiv.style.webkitTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
  17298. bannerDiv.style.webkitTransformOrigin = '50% 100%';
  17299. bannerDiv.style.OTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
  17300. bannerDiv.style.OTransformOrigin = '50% 100%';
  17301. bannerDiv.style.MozTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
  17302. bannerDiv.style.MozTransformOrigin = '70% 100%';
  17303. bannerDiv.style.transform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
  17304. bannerDiv.style.transformOrigin = '50% 100%'
  17305. };
  17306. function adServerSuccess() {
  17307. if (adserver.responseObject != null) {
  17308. var o = adserver.responseObject;
  17309. if (o.interstitial.provider == 'self') {
  17310. var img = new Image();
  17311. img.onload = adImageLoaded;
  17312. img.src = o.interstitial.src;
  17313. adSelfUrl = o.interstitial.url;
  17314. var container = document.createElement('div');
  17315. container.id = 'self_inter_container';
  17316. container.style.display = 'none';
  17317. container.style.position = 'absolute';
  17318. container.style.top = '0';
  17319. container.style.textAlign = 'center';
  17320. var btnClose = document.createElement('div');
  17321. btnClose.id = 'self_ad_close_button';
  17322. btnClose.style.position = 'absolute';
  17323. btnClose.style.left = '10px';
  17324. btnClose.style.top = '50px';
  17325. btnClose.onclick = hideSelfInterstitialAd;
  17326. var imgClose = document.createElement('img');
  17327. imgClose.src = 'assets/close_button.png';
  17328. btnClose.appendChild(imgClose);
  17329. container.appendChild(btnClose);
  17330. document.body.appendChild(container)
  17331. }
  17332. }
  17333. };
  17334. function adServerFail() {};
  17335. var adSelfUrl = '#'; /*ad server URL or main website URL paste here*/
  17336. function adImageLoaded(e) {
  17337. adSelfAvailable = true;
  17338. var container = document.getElementById('self_inter_container');
  17339. if (!container) {
  17340. return
  17341. }
  17342. var screenAR = document.body.clientWidth / document.body.clientHeight;
  17343. var imgAR = e.target.width / e.target.height;
  17344. if (screenAR > imgAR) {
  17345. e.target.style.height = (document.body.clientHeight - 5) + 'px';
  17346. e.target.style.width = 'auto'
  17347. } else {
  17348. e.target.style.width = (document.body.clientWidth - 5) + 'px';
  17349. e.target.style.height = 'auto'
  17350. }
  17351. container.insertBefore(e.target, container.childNodes[container.childNodes.length - 1]);
  17352. e.target.onclick = selfInterstitialAdClicked;
  17353. };
  17354. var adCounter = 2;
  17355. var adSelfAvailable = false;
  17356. var adSwap = true;
  17357. function adProcess() {
  17358. adCounter += 1;
  17359. if (adCounter > 3) {
  17360. adCounter = 0;
  17361. if (adSelfAvailable) {
  17362. if (adSwap) {
  17363. showSelfInterstitialAd()
  17364. } else {
  17365. showInterstitialAd()
  17366. }
  17367. adSwap = !adSwap
  17368. } else {
  17369. showInterstitialAd()
  17370. }
  17371. }
  17372. };
  17373. function showInterstitialAd() {
  17374. if (!adsAvailable) {
  17375. return
  17376. }
  17377. var container = document.getElementById('interstitial_container');
  17378. if (!container) {
  17379. return
  17380. }
  17381. container.style.display = 'block';
  17382. var bgContainer = document.getElementById('interstitial_bg');
  17383. bgContainer.style.display = 'block';
  17384. bgContainer.style.width = window.innerWidth.toString() + 'px';
  17385. bgContainer.style.height = window.innerHeight.toString() + 'px';
  17386. bgContainer.style.fontSize = '50px';
  17387. bgContainer.style.textAlign = 'center';
  17388. bgContainer.style.color = '#EFEFEF';
  17389. var sf = 1;
  17390. if (game) {
  17391. if (game.scale) {
  17392. sf = Math.min(game.scale.scaleFactor.x, game.scale.scaleFactor.y)
  17393. }
  17394. }
  17395. sf = (1 / sf);
  17396. var ad_close_button = document.getElementById('ad_close_button');
  17397. if (!ad_close_button) {
  17398. return
  17399. }
  17400. ad_close_button.style.msTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17401. ad_close_button.style.msTransformOrigin = '0% 0%';
  17402. ad_close_button.style.webkitTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17403. ad_close_button.style.webkitTransformOrigin = '0% 0%';
  17404. ad_close_button.style.OTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17405. ad_close_button.style.OTransformOrigin = '0% 0%';
  17406. ad_close_button.style.MozTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17407. ad_close_button.style.MozTransformOrigin = '0% 0%';
  17408. ad_close_button.style.transform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17409. ad_close_button.style.transformOrigin = '0% 0%'
  17410. };
  17411. function showSelfInterstitialAd() {
  17412. if (!adSelfAvailable) {
  17413. return
  17414. }
  17415. var container = document.getElementById('self_inter_container');
  17416. if (!container) {
  17417. return
  17418. }
  17419. var img = container.childNodes[0];
  17420. if (!img) {
  17421. return
  17422. }
  17423. var screenAR = document.body.clientWidth / document.body.clientHeight;
  17424. var imgAR = img.width / img.height;
  17425. if (screenAR > imgAR) {
  17426. img.style.height = (document.body.clientHeight - 5) + 'px';
  17427. img.style.width = 'auto'
  17428. } else {
  17429. img.style.width = (document.body.clientWidth - 5) + 'px';
  17430. img.style.height = 'auto'
  17431. }
  17432. container.style.display = 'block';
  17433. container.style.left = '50%';
  17434. container.style.top = '50%';
  17435. container.style.msTransform = 'translate(-50%, -50%)';
  17436. container.style.webkitTransform = 'translate(-50%, -50%)';
  17437. container.style.OTransform = 'translate(-50%, -50%)';
  17438. container.style.MozTransform = 'translate(-50%, -50%)';
  17439. container.style.transform = 'translate(-50%, -50%)';
  17440. var sf = 1;
  17441. if (game) {
  17442. if (game.scale) {
  17443. sf = Math.min(game.scale.scaleFactor.x, game.scale.scaleFactor.y)
  17444. }
  17445. }
  17446. sf = (1 / sf);
  17447. var ad_close_button = document.getElementById('self_ad_close_button');
  17448. if (!ad_close_button) {
  17449. return
  17450. }
  17451. ad_close_button.style.msTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17452. ad_close_button.style.msTransformOrigin = '0% 0%';
  17453. ad_close_button.style.webkitTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17454. ad_close_button.style.webkitTransformOrigin = '0% 0%';
  17455. ad_close_button.style.OTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17456. ad_close_button.style.OTransformOrigin = '0% 0%';
  17457. ad_close_button.style.MozTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17458. ad_close_button.style.MozTransformOrigin = '0% 0%';
  17459. ad_close_button.style.transform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
  17460. ad_close_button.style.transformOrigin = '0% 0%'
  17461. };
  17462. function selfInterstitialAdClicked() {
  17463. if (adSelfUrl != '') {
  17464. window.open(adSelfUrl, '_blank')
  17465. }
  17466. };
  17467. function hideSelfInterstitialAd() {
  17468. if (!adSelfAvailable) {
  17469. return
  17470. }
  17471. var container = document.getElementById('self_inter_container');
  17472. if (!container) {
  17473. return
  17474. }
  17475. container.style.display = 'none'
  17476. };
  17477. function showBannerAd() {
  17478. if (!adsAvailable) {
  17479. return
  17480. }
  17481. var container = document.getElementById('banner_container');
  17482. if (!container) {
  17483. return
  17484. }
  17485. container.style.display = 'block'
  17486. };
  17487. function hideInterstitialAd() {
  17488. if (!adsAvailable) {
  17489. return
  17490. }
  17491. var container = document.getElementById('interstitial_container');
  17492. if (!container) {
  17493. return
  17494. }
  17495. container.style.display = 'none';
  17496. var bgContainer = document.getElementById('interstitial_bg');
  17497. bgContainer.style.display = 'none'
  17498. };
  17499. function scaleBannerAd(x, y) {
  17500. if (!adsAvailable) {
  17501. return
  17502. }
  17503. var container = document.getElementById('banner_container');
  17504. if (!container) {
  17505. return
  17506. }
  17507. container.style.transform = 'scale(' + x + ', ' + y + ')';
  17508. container.style.transformOrigin = '50% 100%'
  17509. };
  17510. function hideBannerAd() {
  17511. if (!adsAvailable) {
  17512. return
  17513. }
  17514. var container = document.getElementById('banner_container');
  17515. if (!container) {
  17516. return
  17517. }
  17518. container.style.display = 'none'
  17519. };
  17520. var game;
  17521. window.onload = function() {
  17522. game = new Phaser.Game(480, 690, Phaser.AUTO, 'gameContainer');
  17523. game.state.add('state_boot', BasicGame.StateBoot);
  17524. game.state.add('state_preload', BasicGame.StatePreload);
  17525. game.state.add('state_menu', BasicGame.StateMenu);
  17526. game.state.add('state_level_select', BasicGame.StateLevelSelect);
  17527. game.state.add('state_game', BasicGame.StateGame);
  17528. game.state.add('state_win_panel', BasicGame.StateWinPanel);
  17529. game.state.add('state_lose_panel', BasicGame.StateLosePanel);
  17530. BasicGame.StateMenu.prototype.initVars(game);
  17531. BasicGame.StateLevelSelect.prototype.initVars(game);
  17532. BasicGame.StateGame.prototype.initVars(game);
  17533. game.state.start('state_boot')
  17534. }
  17535. })();