123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658 |
- (function() {
- var a = this,
- b = b || {};
- b.WEBGL_RENDERER = 0, b.CANVAS_RENDERER = 1, b.VERSION = "v2.0.0", b.blendModes = {
- NORMAL: 0,
- ADD: 1,
- MULTIPLY: 2,
- SCREEN: 3,
- OVERLAY: 4,
- DARKEN: 5,
- LIGHTEN: 6,
- COLOR_DODGE: 7,
- COLOR_BURN: 8,
- HARD_LIGHT: 9,
- SOFT_LIGHT: 10,
- DIFFERENCE: 11,
- EXCLUSION: 12,
- HUE: 13,
- SATURATION: 14,
- COLOR: 15,
- LUMINOSITY: 16
- }, b.scaleModes = {
- DEFAULT: 0,
- LINEAR: 0,
- NEAREST: 1
- }, 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 = {
- view: null,
- transparent: !1,
- antialias: !1,
- preserveDrawingBuffer: !1,
- resolution: 1,
- clearBeforeRender: !0
- }, b.sayHello = function(a) {
- if (!b.dontSayHello) {
- if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) {
- 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"];
- console.log.apply(console, c)
- } else window.console && console.log("Pixi.js " + b.VERSION + " - http://www.play68.com/");
- b.dontSayHello = !0
- }
- }, b.Polygon = function(a) {
- if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
- for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
- a = c
- }
- this.closed = !0, this.points = a
- }, b.Polygon.prototype.clone = function() {
- var a = this.points.slice();
- return new b.Polygon(a)
- }, b.Polygon.prototype.contains = function(a, b) {
- for (var c = !1, d = this.points.length / 2, e = 0, f = d - 1; d > e; f = e++) {
- var g = this.points[2 * e],
- h = this.points[2 * e + 1],
- i = this.points[2 * f],
- j = this.points[2 * f + 1],
- k = h > b != j > b && (i - g) * (b - h) / (j - h) + g > a;
- k && (c = !c)
- }
- return c
- }, b.Polygon.prototype.constructor = b.Polygon, b.Matrix = function() {
- this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0
- }, b.Matrix.prototype.fromArray = function(a) {
- this.a = a[0], this.b = a[1], this.c = a[3], this.d = a[4], this.tx = a[2], this.ty = a[5]
- }, b.Matrix.prototype.toArray = function(a) {
- this.array || (this.array = new b.Float32Array(9));
- var c = this.array;
- 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
- }, b.Matrix.prototype.apply = function(a, c) {
- 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
- }, b.Matrix.prototype.applyInverse = function(a, c) {
- c = c || new b.Point;
- var d = 1 / (this.a * this.d + this.c * -this.b);
- 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
- }, b.Matrix.prototype.translate = function(a, b) {
- return this.tx += a, this.ty += b, this
- }, b.Matrix.prototype.scale = function(a, b) {
- return this.a *= a, this.d *= b, this.c *= a, this.b *= b, this.tx *= a, this.ty *= b, this
- }, b.Matrix.prototype.rotate = function(a) {
- var b = Math.cos(a),
- c = Math.sin(a),
- d = this.a,
- e = this.c,
- f = this.tx;
- 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
- }, b.Matrix.prototype.append = function(a) {
- var b = this.a,
- c = this.b,
- d = this.c,
- e = this.d;
- 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
- }, b.Matrix.prototype.identity = function() {
- return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this
- }, b.identityMatrix = new b.Matrix, b.DisplayObject = function() {
- 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
- }, b.DisplayObject.prototype.constructor = b.DisplayObject, Object.defineProperty(b.DisplayObject.prototype, "interactive", {
- get: function() {
- return this._interactive
- },
- set: function(a) {
- this._interactive = a, this.stage && (this.stage.dirty = !0)
- }
- }), Object.defineProperty(b.DisplayObject.prototype, "worldVisible", {
- get: function() {
- var a = this;
- do {
- if (!a.visible) return !1;
- a = a.parent
- } while (a);
- return !0
- }
- }), Object.defineProperty(b.DisplayObject.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(a) {
- this._mask && (this._mask.isMask = !1), this._mask = a, this._mask && (this._mask.isMask = !0)
- }
- }), Object.defineProperty(b.DisplayObject.prototype, "filters", {
- get: function() {
- return this._filters
- },
- set: function(a) {
- if (a) {
- for (var b = [], c = 0; c < a.length; c++)
- for (var d = a[c].passes, e = 0; e < d.length; e++) b.push(d[e]);
- this._filterBlock = {
- target: this,
- filterPasses: b
- }
- }
- this._filters = a
- }
- }), Object.defineProperty(b.DisplayObject.prototype, "cacheAsBitmap", {
- get: function() {
- return this._cacheAsBitmap
- },
- set: function(a) {
- this._cacheAsBitmap !== a && (a ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = a)
- }
- }), b.DisplayObject.prototype.updateTransform = function() {
- var a, c, d, e, f, g, h = this.parent.worldTransform,
- i = this.worldTransform;
- 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
- }, b.DisplayObject.prototype.getBounds = function(a) {
- return a = a, b.EmptyRectangle
- }, b.DisplayObject.prototype.getLocalBounds = function() {
- return this.getBounds(b.identityMatrix)
- }, b.DisplayObject.prototype.setStageReference = function(a) {
- this.stage = a, this._interactive && (this.stage.dirty = !0)
- }, b.DisplayObject.prototype.generateTexture = function(a, c, d) {
- var e = this.getLocalBounds(),
- f = new b.RenderTexture(0 | e.width, 0 | e.height, d, c, a);
- return b.DisplayObject._tempMatrix.tx = -e.x, b.DisplayObject._tempMatrix.ty = -e.y, f.render(this, b.DisplayObject._tempMatrix), f
- }, b.DisplayObject.prototype.updateCache = function() {
- this._generateCachedSprite()
- }, b.DisplayObject.prototype.toGlobal = function(a) {
- return this.updateTransform(), this.worldTransform.apply(a)
- }, b.DisplayObject.prototype.toLocal = function(a, b) {
- return b && (a = b.toGlobal(a)), this.updateTransform(), this.worldTransform.applyInverse(a)
- }, b.DisplayObject.prototype._renderCachedSprite = function(a) {
- this._cachedSprite.worldAlpha = this.worldAlpha, a.gl ? b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a) : b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a)
- }, b.DisplayObject.prototype._generateCachedSprite = function() {
- this._cacheAsBitmap = !1;
- var a = this.getLocalBounds();
- if (this._cachedSprite) this._cachedSprite.texture.resize(0 | a.width, 0 | a.height);
- else {
- var c = new b.RenderTexture(0 | a.width, 0 | a.height);
- this._cachedSprite = new b.Sprite(c), this._cachedSprite.worldTransform = this.worldTransform
- }
- var d = this._filters;
- 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
- }, b.DisplayObject.prototype._destroyCachedSprite = function() {
- this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null)
- }, b.DisplayObject.prototype._renderWebGL = function(a) {
- a = a
- }, b.DisplayObject.prototype._renderCanvas = function(a) {
- a = a
- }, b.DisplayObject._tempMatrix = new b.Matrix, Object.defineProperty(b.DisplayObject.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(a) {
- this.position.x = a
- }
- }), Object.defineProperty(b.DisplayObject.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(a) {
- this.position.y = a
- }
- }), b.DisplayObjectContainer = function() {
- b.DisplayObject.call(this), this.children = []
- }, b.DisplayObjectContainer.prototype = Object.create(b.DisplayObject.prototype), b.DisplayObjectContainer.prototype.constructor = b.DisplayObjectContainer, Object.defineProperty(b.DisplayObjectContainer.prototype, "width", {
- get: function() {
- return this.scale.x * this.getLocalBounds().width
- },
- set: function(a) {
- var b = this.getLocalBounds().width;
- this.scale.x = 0 !== b ? a / (b / this.scale.x) : 1, this._width = a
- }
- }), Object.defineProperty(b.DisplayObjectContainer.prototype, "height", {
- get: function() {
- return this.scale.y * this.getLocalBounds().height
- },
- set: function(a) {
- var b = this.getLocalBounds().height;
- this.scale.y = 0 !== b ? a / (b / this.scale.y) : 1, this._height = a
- }
- }), b.DisplayObjectContainer.prototype.addChild = function(a) {
- return this.addChildAt(a, this.children.length)
- }, b.DisplayObjectContainer.prototype.addChildAt = function(a, b) {
- 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;
- throw new Error(a + "addChildAt: The index " + b + " supplied is out of bounds " + this.children.length)
- }, b.DisplayObjectContainer.prototype.swapChildren = function(a, b) {
- if (a !== b) {
- var c = this.getChildIndex(a),
- d = this.getChildIndex(b);
- if (0 > c || 0 > d) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
- this.children[c] = b, this.children[d] = a
- }
- }, b.DisplayObjectContainer.prototype.getChildIndex = function(a) {
- var b = this.children.indexOf(a);
- if (-1 === b) throw new Error("The supplied DisplayObject must be a child of the caller");
- return b
- }, b.DisplayObjectContainer.prototype.setChildIndex = function(a, b) {
- if (0 > b || b >= this.children.length) throw new Error("The supplied index is out of bounds");
- var c = this.getChildIndex(a);
- this.children.splice(c, 1), this.children.splice(b, 0, a)
- }, b.DisplayObjectContainer.prototype.getChildAt = function(a) {
- 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");
- return this.children[a]
- }, b.DisplayObjectContainer.prototype.removeChild = function(a) {
- var b = this.children.indexOf(a);
- if (-1 !== b) return this.removeChildAt(b)
- }, b.DisplayObjectContainer.prototype.removeChildAt = function(a) {
- var b = this.getChildAt(a);
- return this.stage && b.removeStageReference(), b.parent = void 0, this.children.splice(a, 1), b
- }, b.DisplayObjectContainer.prototype.removeChildren = function(a, b) {
- var c = a || 0,
- d = "number" == typeof b ? b : this.children.length,
- e = d - c;
- if (e > 0 && d >= e) {
- for (var f = this.children.splice(c, e), g = 0; g < f.length; g++) {
- var h = f[g];
- this.stage && h.removeStageReference(), h.parent = void 0
- }
- return f
- }
- if (0 === e && 0 === this.children.length) return [];
- throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")
- }, b.DisplayObjectContainer.prototype.updateTransform = function() {
- if (this.visible && (b.DisplayObject.prototype.updateTransform.call(this), !this._cacheAsBitmap))
- for (var a = 0, c = this.children.length; c > a; a++) this.children[a].updateTransform()
- }, b.DisplayObjectContainer.prototype.getBounds = function() {
- if (0 === this.children.length) return b.EmptyRectangle;
- 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++) {
- var l = this.children[j];
- 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)
- }
- if (!i) return b.EmptyRectangle;
- var m = this._bounds;
- return m.x = e, m.y = f, m.width = g - e, m.height = h - f, m
- }, b.DisplayObjectContainer.prototype.getLocalBounds = function() {
- var a = this.worldTransform;
- this.worldTransform = b.identityMatrix;
- for (var c = 0, d = this.children.length; d > c; c++) this.children[c].updateTransform();
- var e = this.getBounds();
- return this.worldTransform = a, e
- }, b.DisplayObjectContainer.prototype.setStageReference = function(a) {
- this.stage = a, this._interactive && (this.stage.dirty = !0);
- for (var b = 0, c = this.children.length; c > b; b++) {
- var d = this.children[b];
- d.setStageReference(a)
- }
- }, b.DisplayObjectContainer.prototype.removeStageReference = function() {
- for (var a = 0, b = this.children.length; b > a; a++) {
- var c = this.children[a];
- c.removeStageReference()
- }
- this._interactive && (this.stage.dirty = !0), this.stage = null
- }, b.DisplayObjectContainer.prototype._renderWebGL = function(a) {
- if (this.visible && !(this.alpha <= 0)) {
- if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
- var b, c;
- if (this._mask || this._filters) {
- 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);
- a.spriteBatch.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), a.spriteBatch.start()
- } else
- for (b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
- }
- }, b.DisplayObjectContainer.prototype._renderCanvas = function(a) {
- if (this.visible !== !1 && 0 !== this.alpha) {
- if (this._cacheAsBitmap) return void this._renderCachedSprite(a);
- this._mask && a.maskManager.pushMask(this._mask, a);
- for (var b = 0, c = this.children.length; c > b; b++) {
- var d = this.children[b];
- d._renderCanvas(a)
- }
- this._mask && a.maskManager.popMask(a)
- }
- }, b.Sprite = function(a) {
- 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
- }, b.Sprite.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Sprite.prototype.constructor = b.Sprite, Object.defineProperty(b.Sprite.prototype, "width", {
- get: function() {
- return this.scale.x * this.texture.frame.width
- },
- set: function(a) {
- this.scale.x = a / this.texture.frame.width, this._width = a
- }
- }), Object.defineProperty(b.Sprite.prototype, "height", {
- get: function() {
- return this.scale.y * this.texture.frame.height
- },
- set: function(a) {
- this.scale.y = a / this.texture.frame.height, this._height = a
- }
- }), b.Sprite.prototype.setTexture = function(a) {
- this.texture = a, this.cachedTint = 16777215
- }, b.Sprite.prototype.onTextureUpdate = function() {
- this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height)
- }, b.Sprite.prototype.getBounds = function(a) {
- var b = this.texture.frame.width,
- c = this.texture.frame.height,
- d = b * (1 - this.anchor.x),
- e = b * -this.anchor.x,
- f = c * (1 - this.anchor.y),
- g = c * -this.anchor.y,
- h = a || this.worldTransform,
- i = h.a,
- j = h.c,
- k = h.b,
- l = h.d,
- m = h.tx,
- n = h.ty,
- o = i * e + k * g + m,
- p = l * g + j * e + n,
- q = i * d + k * g + m,
- r = l * g + j * d + n,
- s = i * d + k * f + m,
- t = l * f + j * d + n,
- u = i * e + k * f + m,
- v = l * f + j * e + n,
- w = -1 / 0,
- x = -1 / 0,
- y = 1 / 0,
- z = 1 / 0;
- 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;
- var A = this._bounds;
- return A.x = y, A.width = w - y, A.y = z, A.height = x - z, this._currentBounds = A, A
- }, b.Sprite.prototype._renderWebGL = function(a) {
- if (this.visible && !(this.alpha <= 0)) {
- var b, c;
- if (this._mask || this._filters) {
- var d = a.spriteBatch;
- 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);
- d.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), d.start()
- } else
- for (a.spriteBatch.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
- }
- }, b.Sprite.prototype._renderCanvas = function(a) {
- if (!(this.visible === !1 || 0 === this.alpha || this.texture.crop.width <= 0 || this.texture.crop.height <= 0)) {
- 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) {
- var c = this.texture.baseTexture.resolution / a.resolution;
- 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);
- var d = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width,
- e = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
- 16777215 !== this.tint ? (this.cachedTint !== this.tint && (this.cachedTint = this.tint, this.tintedTexture = b.CanvasTinter.getTintedTexture(this, this.tint)), a.context.drawImage(this.tintedTexture, 0, 0, this.texture.crop.width, this.texture.crop.height, 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)
- }
- for (var f = 0, g = this.children.length; g > f; f++) this.children[f]._renderCanvas(a);
- this._mask && a.maskManager.popMask(a)
- }
- }, b.Sprite.fromFrame = function(a) {
- var c = b.TextureCache[a];
- if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache' + this);
- return new b.Sprite(c)
- }, b.Sprite.fromImage = function(a, c, d) {
- var e = b.Texture.fromImage(a, c, d);
- return new b.Sprite(e)
- }, b.SpriteBatch = function(a) {
- b.DisplayObjectContainer.call(this), this.textureThing = a, this.ready = !1
- }, b.SpriteBatch.prototype = Object.create(b.DisplayObjectContainer.prototype), b.SpriteBatch.prototype.constructor = b.SpriteBatch, b.SpriteBatch.prototype.initWebGL = function(a) {
- this.fastSpriteBatch = new b.WebGLFastSpriteBatch(a), this.ready = !0
- }, b.SpriteBatch.prototype.updateTransform = function() {
- b.DisplayObject.prototype.updateTransform.call(this)
- }, b.SpriteBatch.prototype._renderWebGL = function(a) {
- !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())
- }, b.SpriteBatch.prototype._renderCanvas = function(a) {
- if (this.visible && !(this.alpha <= 0) && this.children.length) {
- var c = a.context;
- c.globalAlpha = this.worldAlpha, b.DisplayObject.prototype.updateTransform.call(this);
- for (var d = this.worldTransform, e = !0, f = 0; f < this.children.length; f++) {
- var g = this.children[f];
- if (g.visible) {
- var h = g.texture,
- i = h.frame;
- 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);
- else {
- e || (e = !0), b.DisplayObject.prototype.updateTransform.call(g);
- var j = g.worldTransform;
- 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)
- }
- }
- }
- }
- }, b.FilterBlock = function() {
- this.visible = !0, this.renderable = !0
- }, b.FilterBlock.prototype.constructor = b.FilterBlock, b.Text = function(a, c) {
- 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)
- }, b.Text.prototype = Object.create(b.Sprite.prototype), b.Text.prototype.constructor = b.Text, Object.defineProperty(b.Text.prototype, "width", {
- get: function() {
- return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width
- },
- set: function(a) {
- this.scale.x = a / this.texture.frame.width, this._width = a
- }
- }), Object.defineProperty(b.Text.prototype, "height", {
- get: function() {
- return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height
- },
- set: function(a) {
- this.scale.y = a / this.texture.frame.height, this._height = a
- }
- }), b.Text.prototype.setStyle = function(a) {
- 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
- }, b.Text.prototype.setText = function(a) {
- this.text = a.toString() || " ", this.dirty = !0
- }, b.Text.prototype.updateText = function() {
- this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
- var a = this.text;
- this.style.wordWrap && (a = this.wordWrap(this.text));
- for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
- var g = this.context.measureText(b[f]).width;
- c[f] = g, d = Math.max(d, g)
- }
- var h = d + this.style.strokeThickness;
- this.style.dropShadow && (h += this.style.dropShadowDistance), this.canvas.width = (h + this.context.lineWidth) * this.resolution;
- var i = e.fontSize + this.style.strokeThickness,
- j = i * b.length;
- 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";
- var k, l;
- if (this.style.dropShadow) {
- this.context.fillStyle = this.style.dropShadowColor;
- var m = Math.sin(this.style.dropShadowAngle) * this.style.dropShadowDistance,
- n = Math.cos(this.style.dropShadowAngle) * this.style.dropShadowDistance;
- 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)
- }
- 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);
- this.updateTexture()
- }, b.Text.prototype.updateTexture = function() {
- 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()
- }, b.Text.prototype._renderWebGL = function(a) {
- this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderWebGL.call(this, a)
- }, b.Text.prototype._renderCanvas = function(a) {
- this.dirty && (this.resolution = a.resolution, this.updateText(), this.dirty = !1), b.Sprite.prototype._renderCanvas.call(this, a)
- }, b.Text.prototype.determineFontProperties = function(a) {
- var c = b.Text.fontPropertiesCache[a];
- if (!c) {
- c = {};
- var d = b.Text.fontPropertiesCanvas,
- e = b.Text.fontPropertiesContext;
- e.font = a;
- var f = Math.ceil(e.measureText("|Mq").width),
- g = Math.ceil(e.measureText("M").width),
- h = 2 * g;
- 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);
- var i, j, k = e.getImageData(0, 0, f, h).data,
- l = k.length,
- m = 4 * f,
- n = 0,
- o = !1;
- for (i = 0; g > i; i++) {
- for (j = 0; m > j; j += 4)
- if (255 !== k[n + j]) {
- o = !0;
- break
- }
- if (o) break;
- n += m
- }
- for (c.ascent = g - i, n = l - m, o = !1, i = h; i > g; i--) {
- for (j = 0; m > j; j += 4)
- if (255 !== k[n + j]) {
- o = !0;
- break
- }
- if (o) break;
- n -= m
- }
- c.descent = i - g, c.fontSize = c.ascent + c.descent, b.Text.fontPropertiesCache[a] = c
- }
- return c
- }, b.Text.prototype.wordWrap = function(a) {
- for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
- for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
- var h = this.context.measureText(f[g]).width,
- i = h + this.context.measureText(" ").width;
- 0 === g || i > e ? (g > 0 && (b += "\n"), b += f[g], e = this.style.wordWrapWidth - h) : (e -= i, b += " " + f[g])
- }
- d < c.length - 1 && (b += "\n")
- }
- return b
- }, b.Text.prototype.destroy = function(a) {
- this.context = null, this.canvas = null, this.texture.destroy(void 0 === a ? !0 : a)
- }, b.Text.fontPropertiesCache = {}, b.Text.fontPropertiesCanvas = document.createElement("canvas"), b.Text.fontPropertiesContext = b.Text.fontPropertiesCanvas.getContext("2d"), b.BitmapText = function(a, c) {
- b.DisplayObjectContainer.call(this), this.textWidth = 0, this.textHeight = 0, this._pool = [], this.setText(a), this.setStyle(c), this.updateText(), this.dirty = !1
- }, b.BitmapText.prototype = Object.create(b.DisplayObjectContainer.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setText = function(a) {
- this.text = a || " ", this.dirty = !0
- }, b.BitmapText.prototype.setStyle = function(a) {
- a = a || {}, a.align = a.align || "left", this.style = a;
- var c = a.font.split(" ");
- 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
- }, b.BitmapText.prototype.updateText = function() {
- 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++) {
- var k = this.text.charCodeAt(j);
- 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;
- else {
- var l = a.chars[k];
- l && (d && l.kerning[d] && (c.x += l.kerning[d]), e.push({
- texture: l.texture,
- line: h,
- charCode: k,
- position: new b.Point(c.x + l.xOffset, c.y + l.yOffset)
- }), c.x += l.xAdvance, d = k)
- }
- }
- g.push(c.x), f = Math.max(f, c.x);
- var m = [];
- for (j = 0; h >= j; j++) {
- var n = 0;
- "right" === this.style.align ? n = f - g[j] : "center" === this.style.align && (n = (f - g[j]) / 2), m.push(n)
- }
- var o = this.children.length,
- p = e.length,
- q = this.tint || 16777215;
- for (j = 0; p > j; j++) {
- var r = o > j ? this.children[j] : this._pool.pop();
- r ? r.setTexture(e[j].texture) : r = new b.Sprite(e[j].texture), r.position.x = (e[j].position.x + m[e[j].line]) * i, r.position.y = e[j].position.y * i, r.scale.x = r.scale.y = i, r.tint = q, r.parent || this.addChild(r)
- }
- for (; this.children.length > p;) {
- var s = this.getChildAt(this.children.length - 1);
- this._pool.push(s), this.removeChild(s)
- }
- this.textWidth = f * i, this.textHeight = (c.y + a.lineHeight) * i
- }, b.BitmapText.prototype.updateTransform = function() {
- this.dirty && (this.updateText(), this.dirty = !1), b.DisplayObjectContainer.prototype.updateTransform.call(this)
- }, b.BitmapText.fonts = {}, b.Stage = function(a) {
- 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)
- }, b.Stage.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.setInteractionDelegate = function(a) {
- this.interactionManager.setTargetDomElement(a)
- }, b.Stage.prototype.updateTransform = function() {
- this.worldAlpha = 1;
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].updateTransform();
- this.dirty && (this.dirty = !1, this.interactionManager.dirty = !0), this.interactive && this.interactionManager.update()
- }, b.Stage.prototype.setBackgroundColor = function(a) {
- this.backgroundColor = a || 0, this.backgroundColorSplit = b.hex2rgb(this.backgroundColor);
- var c = this.backgroundColor.toString(16);
- c = "000000".substr(0, 6 - c.length) + c, this.backgroundColorString = "#" + c
- }, b.Stage.prototype.getMousePosition = function() {
- return this.interactionManager.mouse.global
- },
- function(a) {
- 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"];
- a.requestAnimationFrame || (a.requestAnimationFrame = function(c) {
- var d = (new Date).getTime(),
- e = Math.max(0, 16 - (d - b)),
- f = a.setTimeout(function() {
- c(d + e)
- }, e);
- return b = d + e, f
- }), a.cancelAnimationFrame || (a.cancelAnimationFrame = function(a) {
- clearTimeout(a)
- }), a.requestAnimFrame = a.requestAnimationFrame
- }(this), b.hex2rgb = function(a) {
- return [(a >> 16 & 255) / 255, (a >> 8 & 255) / 255, (255 & a) / 255]
- }, b.rgb2hex = function(a) {
- return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
- }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
- return function(a) {
- function b() {
- for (var d = arguments.length, f = new Array(d); d--;) f[d] = arguments[d];
- return f = e.concat(f), c.apply(this instanceof b ? this : a, f)
- }
- var c = this,
- d = arguments.length - 1,
- e = [];
- if (d > 0)
- for (e.length = d; d--;) e[d] = arguments[d + 1];
- if ("function" != typeof c) throw new TypeError;
- return b.prototype = function f(a) {
- return a && (f.prototype = a), this instanceof f ? void 0 : new f
- }(c.prototype), b
- }
- }()), b.AjaxRequest = function() {
- var a = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Microsoft.XMLHTTP"];
- if (!window.ActiveXObject) return window.XMLHttpRequest ? new window.XMLHttpRequest : !1;
- for (var b = 0; b < a.length; b++) try {
- return new window.ActiveXObject(a[b])
- } catch (c) {}
- }, b.canUseNewCanvasBlendModes = function() {
- if ("undefined" == typeof document) return !1;
- var a = document.createElement("canvas");
- a.width = 1, a.height = 1;
- var b = a.getContext("2d");
- 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]
- }, b.getNextPowerOfTwo = function(a) {
- if (a > 0 && 0 === (a & a - 1)) return a;
- for (var b = 1; a > b;) b <<= 1;
- return b
- }, b.EventTarget = {
- call: function(a) {
- a && (a = a.prototype || a, b.EventTarget.mixin(a))
- },
- mixin: function(a) {
- a.listeners = function(a) {
- return this._listeners = this._listeners || {}, this._listeners[a] ? this._listeners[a].slice() : []
- }, a.emit = a.dispatchEvent = function(a, c) {
- 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]) {
- var d, e = this._listeners[a],
- f = e.length,
- g = e[0];
- for (d = 0; f > d; g = e[++d])
- if (g.call(this, c), c.stoppedImmediate) return this;
- if (c.stopped) return this
- }
- return this.parent && this.parent.emit && this.parent.emit.call(this.parent, a, c), this
- }, a.on = a.addEventListener = function(a, b) {
- return this._listeners = this._listeners || {}, (this._listeners[a] = this._listeners[a] || []).push(b), this
- }, a.once = function(a, b) {
- function c() {
- b.apply(d.off(a, c), arguments)
- }
- this._listeners = this._listeners || {};
- var d = this;
- return c._originalHandler = b, this.on(a, c)
- }, a.off = a.removeEventListener = function(a, b) {
- if (this._listeners = this._listeners || {}, !this._listeners[a]) return this;
- for (var c = this._listeners[a], d = b ? c.length : 0; d-- > 0;)(c[d] === b || c[d]._originalHandler === b) && c.splice(d, 1);
- return 0 === c.length && delete this._listeners[a], this
- }, a.removeAllListeners = function(a) {
- return this._listeners = this._listeners || {}, this._listeners[a] ? (delete this._listeners[a], this) : this
- }
- }
- }, b.Event = function(a, b, c) {
- 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()
- }, b.Event.prototype.stopPropagation = function() {
- this.stopped = !0
- }, b.Event.prototype.stopImmediatePropagation = function() {
- this.stoppedImmediate = !0
- }, b.PolyK = {}, b.PolyK.Triangulate = function(a) {
- var c = !0,
- d = a.length >> 1;
- if (3 > d) return [];
- for (var e = [], f = [], g = 0; d > g; g++) f.push(g);
- g = 0;
- for (var h = d; h > 3;) {
- var i = f[(g + 0) % h],
- j = f[(g + 1) % h],
- k = f[(g + 2) % h],
- l = a[2 * i],
- m = a[2 * i + 1],
- n = a[2 * j],
- o = a[2 * j + 1],
- p = a[2 * k],
- q = a[2 * k + 1],
- r = !1;
- if (b.PolyK._convex(l, m, n, o, p, q, c)) {
- r = !0;
- for (var s = 0; h > s; s++) {
- var t = f[s];
- if (t !== i && t !== j && t !== k && b.PolyK._PointInTriangle(a[2 * t], a[2 * t + 1], l, m, n, o, p, q)) {
- r = !1;
- break
- }
- }
- }
- if (r) e.push(i, j, k), f.splice((g + 1) % h, 1), h--, g = 0;
- else if (g++ > 3 * h) {
- if (!c) return window.console.log("PIXI Warning: shape too complex to fill"), [];
- for (e = [], f = [], g = 0; d > g; g++) f.push(g);
- g = 0, h = d, c = !1
- }
- }
- return e.push(f[0], f[1], f[2]), e
- }, b.PolyK._PointInTriangle = function(a, b, c, d, e, f, g, h) {
- var i = g - c,
- j = h - d,
- k = e - c,
- l = f - d,
- m = a - c,
- n = b - d,
- o = i * i + j * j,
- p = i * k + j * l,
- q = i * m + j * n,
- r = k * k + l * l,
- s = k * m + l * n,
- t = 1 / (o * r - p * p),
- u = (r * q - p * s) * t,
- v = (o * s - p * q) * t;
- return u >= 0 && v >= 0 && 1 > u + v
- }, b.PolyK._convex = function(a, b, c, d, e, f, g) {
- return (b - d) * (e - c) + (c - a) * (f - d) >= 0 === g
- }, b.initDefaultShaders = function() {}, b.CompileVertexShader = function(a, c) {
- return b._CompileShader(a, c, a.VERTEX_SHADER)
- }, b.CompileFragmentShader = function(a, c) {
- return b._CompileShader(a, c, a.FRAGMENT_SHADER)
- }, b._CompileShader = function(a, b, c) {
- var d = b.join("\n"),
- e = a.createShader(c);
- return a.shaderSource(e, d), a.compileShader(e), a.getShaderParameter(e, a.COMPILE_STATUS) ? e : (window.console.log(a.getShaderInfoLog(e)), null)
- }, b.compileProgram = function(a, c, d) {
- var e = b.CompileFragmentShader(a, d),
- f = b.CompileVertexShader(a, c),
- g = a.createProgram();
- 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
- }, b.PixiShader = function(a) {
- 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()
- }, b.PixiShader.prototype.constructor = b.PixiShader, b.PixiShader.prototype.init = function() {
- var a = this.gl,
- c = b.compileProgram(a, this.vertexSrc || b.PixiShader.defaultVertexSrc, this.fragmentSrc);
- 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];
- for (var d in this.uniforms) this.uniforms[d].uniformLocation = a.getUniformLocation(c, d);
- this.initUniforms(), this.program = c
- }, b.PixiShader.prototype.initUniforms = function() {
- this.textureCount = 1;
- var a, b = this.gl;
- for (var c in this.uniforms) {
- a = this.uniforms[c];
- var d = a.type;
- "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)
- }
- }, b.PixiShader.prototype.initSampler2D = function(a) {
- if (a.value && a.value.baseTexture && a.value.baseTexture.hasLoaded) {
- var b = this.gl;
- if (b.activeTexture(b["TEXTURE" + this.textureCount]), b.bindTexture(b.TEXTURE_2D, a.value.baseTexture._glTextures[b.id]), a.textureData) {
- var c = a.textureData,
- d = c.magFilter ? c.magFilter : b.LINEAR,
- e = c.minFilter ? c.minFilter : b.LINEAR,
- f = c.wrapS ? c.wrapS : b.CLAMP_TO_EDGE,
- g = c.wrapT ? c.wrapT : b.CLAMP_TO_EDGE,
- h = c.luminance ? b.LUMINANCE : b.RGBA;
- if (c.repeat && (f = b.REPEAT, g = b.REPEAT), b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL, !!c.flipY), c.width) {
- var i = c.width ? c.width : 512,
- j = c.height ? c.height : 2,
- k = c.border ? c.border : 0;
- b.texImage2D(b.TEXTURE_2D, 0, h, i, j, k, h, b.UNSIGNED_BYTE, null)
- } else b.texImage2D(b.TEXTURE_2D, 0, h, b.RGBA, b.UNSIGNED_BYTE, a.value.baseTexture.source);
- b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, d), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, e), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, f), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, g)
- }
- b.uniform1i(a.uniformLocation, this.textureCount), a._init = !0, this.textureCount++
- }
- }, b.PixiShader.prototype.syncUniforms = function() {
- this.textureCount = 1;
- var a, c = this.gl;
- 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))
- }, b.PixiShader.prototype.destroy = function() {
- this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
- }, 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) {
- 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()
- }, b.PixiFastShader.prototype.constructor = b.PixiFastShader, b.PixiFastShader.prototype.init = function() {
- var a = this.gl,
- c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
- 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
- }, b.PixiFastShader.prototype.destroy = function() {
- this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
- }, b.StripShader = function(a) {
- 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()
- }, b.StripShader.prototype.constructor = b.StripShader, b.StripShader.prototype.init = function() {
- var a = this.gl,
- c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
- 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
- }, b.StripShader.prototype.destroy = function() {
- this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
- }, b.PrimitiveShader = function(a) {
- 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()
- }, b.PrimitiveShader.prototype.constructor = b.PrimitiveShader, b.PrimitiveShader.prototype.init = function() {
- var a = this.gl,
- c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
- 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
- }, b.PrimitiveShader.prototype.destroy = function() {
- this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
- }, b.ComplexPrimitiveShader = function(a) {
- 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()
- }, b.ComplexPrimitiveShader.prototype.constructor = b.ComplexPrimitiveShader, b.ComplexPrimitiveShader.prototype.init = function() {
- var a = this.gl,
- c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
- 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
- }, b.ComplexPrimitiveShader.prototype.destroy = function() {
- this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
- }, b.WebGLGraphics = function() {}, b.WebGLGraphics.renderGraphics = function(a, c) {
- var d, e = c.gl,
- f = c.projection,
- g = c.offset,
- h = c.shaderManager.primitiveShader;
- a.dirty && b.WebGLGraphics.updateGraphics(a, e);
- 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))
- }, b.WebGLGraphics.updateGraphics = function(a, c) {
- var d = a._webGL[c.id];
- d || (d = a._webGL[c.id] = {
- lastIndex: 0,
- data: [],
- gl: c
- }), a.dirty = !1;
- var e;
- if (a.clearDirty) {
- for (a.clearDirty = !1, e = 0; e < d.data.length; e++) {
- var f = d.data[e];
- f.reset(), b.WebGLGraphics.graphicsDataPool.push(f)
- }
- d.data = [], d.lastIndex = 0
- }
- var g;
- for (e = d.lastIndex; e < a.graphicsData.length; e++) {
- var h = a.graphicsData[e];
- 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++
- }
- for (e = 0; e < d.data.length; e++) g = d.data[e], g.dirty && g.upload()
- }, b.WebGLGraphics.switchMode = function(a, c) {
- var d;
- 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
- }, b.WebGLGraphics.buildRectangle = function(a, c) {
- var d = a.shape,
- e = d.x,
- f = d.y,
- g = d.width,
- h = d.height;
- if (a.fill) {
- var i = b.hex2rgb(a.fillColor),
- j = a.fillAlpha,
- k = i[0] * j,
- l = i[1] * j,
- m = i[2] * j,
- n = c.points,
- o = c.indices,
- p = n.length / 6;
- n.push(e, f), n.push(k, l, m, j), n.push(e + g, f), n.push(k, l, m, j), n.push(e, f + h), n.push(k, l, m, j), n.push(e + g, f + h), n.push(k, l, m, j), o.push(p, p, p + 1, p + 2, p + 3, p + 3)
- }
- if (a.lineWidth) {
- var q = a.points;
- a.points = [e, f, e + g, f, e + g, f + h, e, f + h, e, f], b.WebGLGraphics.buildLine(a, c), a.points = q
- }
- }, b.WebGLGraphics.buildRoundedRectangle = function(a, c) {
- var d = a.shape.points,
- e = d[0],
- f = d[1],
- g = d[2],
- h = d[3],
- i = d[4],
- j = [];
- 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) {
- var k = b.hex2rgb(a.fillColor),
- l = a.fillAlpha,
- m = k[0] * l,
- n = k[1] * l,
- o = k[2] * l,
- p = c.points,
- q = c.indices,
- r = p.length / 6,
- s = b.PolyK.Triangulate(j),
- t = 0;
- 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);
- for (t = 0; t < j.length; t++) p.push(j[t], j[++t], m, n, o, l)
- }
- if (a.lineWidth) {
- var u = a.points;
- a.points = j, b.WebGLGraphics.buildLine(a, c), a.points = u
- }
- }, b.WebGLGraphics.quadraticBezierCurve = function(a, b, c, d, e, f) {
- function g(a, b, c) {
- var d = b - a;
- return a + d * c
- }
- 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);
- return o
- }, b.WebGLGraphics.buildCircle = function(a, c) {
- var d, e, f = a.shape,
- g = f.x,
- h = f.y;
- a.type === b.Graphics.CIRC ? (d = f.radius, e = f.radius) : (d = f.width, e = f.height);
- var i = 40,
- j = 2 * Math.PI / i,
- k = 0;
- if (a.fill) {
- var l = b.hex2rgb(a.fillColor),
- m = a.fillAlpha,
- n = l[0] * m,
- o = l[1] * m,
- p = l[2] * m,
- q = c.points,
- r = c.indices,
- s = q.length / 6;
- 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++);
- r.push(s - 1)
- }
- if (a.lineWidth) {
- var t = a.points;
- for (a.points = [], k = 0; i + 1 > k; k++) a.points.push(g + Math.sin(j * k) * d, h + Math.cos(j * k) * e);
- b.WebGLGraphics.buildLine(a, c), a.points = t
- }
- }, b.WebGLGraphics.buildLine = function(a, c) {
- var d = 0,
- e = a.points;
- if (0 !== e.length) {
- if (a.lineWidth % 2)
- for (d = 0; d < e.length; d++) e[d] += .5;
- var f = new b.Point(e[0], e[1]),
- g = new b.Point(e[e.length - 2], e[e.length - 1]);
- if (f.x === g.x && f.y === g.y) {
- e = e.slice(), e.pop(), e.pop(), g = new b.Point(e[e.length - 2], e[e.length - 1]);
- var h = g.x + .5 * (f.x - g.x),
- i = g.y + .5 * (f.y - g.y);
- e.unshift(h, i), e.push(h, i)
- }
- 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,
- H = c.indices,
- I = e.length / 2,
- J = e.length,
- K = G.length / 6,
- L = a.lineWidth / 2,
- M = b.hex2rgb(a.lineColor),
- N = a.lineAlpha,
- O = M[0] * N,
- P = M[1] * N,
- Q = M[2] * N;
- 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)));
- 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++);
- H.push(K - 1)
- }
- }, b.WebGLGraphics.buildComplexPoly = function(a, c) {
- var d = a.points.slice();
- if (!(d.length < 6)) {
- var e = c.indices;
- c.points = d, c.alpha = a.fillAlpha, c.color = b.hex2rgb(a.fillColor);
- 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;
- d.push(h, j, i, j, i, k, h, k);
- var m = d.length / 2;
- for (l = 0; m > l; l++) e.push(l)
- }
- }, b.WebGLGraphics.buildPoly = function(a, c) {
- var d = a.points;
- if (!(d.length < 6)) {
- var e = c.points,
- f = c.indices,
- g = d.length / 2,
- h = b.hex2rgb(a.fillColor),
- i = a.fillAlpha,
- j = h[0] * i,
- k = h[1] * i,
- l = h[2] * i,
- m = b.PolyK.Triangulate(d),
- n = e.length / 6,
- o = 0;
- 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);
- for (o = 0; g > o; o++) e.push(d[2 * o], d[2 * o + 1], j, k, l, i)
- }
- }, b.WebGLGraphics.graphicsDataPool = [], b.WebGLGraphicsData = function(a) {
- 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
- }, b.WebGLGraphicsData.prototype.reset = function() {
- this.points = [], this.indices = [], this.lastIndex = 0
- }, b.WebGLGraphicsData.prototype.upload = function() {
- var a = this.gl;
- 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
- }, b.glContexts = [], b.WebGLRenderer = function(a, c, d) {
- if (d)
- for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
- else d = b.defaultRenderOptions;
- 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 = {
- alpha: this.transparent,
- antialias: d.antialias,
- premultipliedAlpha: this.transparent && "notMultiplied" !== this.transparent,
- stencil: !0,
- preserveDrawingBuffer: d.preserveDrawingBuffer
- }, 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()
- }, b.WebGLRenderer.prototype.constructor = b.WebGLRenderer, b.WebGLRenderer.prototype.initContext = function() {
- var a = this.view.getContext("webgl", this._contextOptions) || this.view.getContext("experimental-webgl", this._contextOptions);
- if (this.gl = a, !a) throw new Error("This browser does not support webGL. Try using the canvas renderer");
- 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)
- }, b.WebGLRenderer.prototype.render = function(a) {
- if (!this.contextLost) {
- this.__stage !== a && (a.interactive && a.interactionManager.removeEvents(), this.__stage = a), a.updateTransform();
- var b = this.gl;
- 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)
- }
- }, b.WebGLRenderer.prototype.renderDisplayObject = function(a, c, d) {
- 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()
- }, b.WebGLRenderer.prototype.resize = function(a, b) {
- 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
- }, b.WebGLRenderer.prototype.updateTexture = function(a) {
- if (a.hasLoaded) {
- var c = this.gl;
- 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]
- }
- }, b.WebGLRenderer.prototype.handleContextLost = function(a) {
- a.preventDefault(), this.contextLost = !0
- }, b.WebGLRenderer.prototype.handleContextRestored = function() {
- this.initContext();
- for (var a in b.TextureCache) {
- var c = b.TextureCache[a].baseTexture;
- c._glTextures = []
- }
- this.contextLost = !1
- }, b.WebGLRenderer.prototype.destroy = function() {
- 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
- }, b.WebGLRenderer.prototype.mapBlendModes = function() {
- var a = this.gl;
- 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])
- }, b.WebGLRenderer.glContextId = 0, b.WebGLBlendModeManager = function() {
- this.currentBlendMode = 99999
- }, b.WebGLBlendModeManager.prototype.constructor = b.WebGLBlendModeManager, b.WebGLBlendModeManager.prototype.setContext = function(a) {
- this.gl = a
- }, b.WebGLBlendModeManager.prototype.setBlendMode = function(a) {
- if (this.currentBlendMode === a) return !1;
- this.currentBlendMode = a;
- var c = b.blendModesWebGL[this.currentBlendMode];
- return this.gl.blendFunc(c[0], c[1]), !0
- }, b.WebGLBlendModeManager.prototype.destroy = function() {
- this.gl = null
- }, b.WebGLMaskManager = function() {}, b.WebGLMaskManager.prototype.constructor = b.WebGLMaskManager, b.WebGLMaskManager.prototype.setContext = function(a) {
- this.gl = a
- }, b.WebGLMaskManager.prototype.pushMask = function(a, c) {
- var d = c.gl;
- a.dirty && b.WebGLGraphics.updateGraphics(a, d), a._webGL[d.id].data.length && c.stencilManager.pushStencil(a, a._webGL[d.id].data[0], c)
- }, b.WebGLMaskManager.prototype.popMask = function(a, b) {
- var c = this.gl;
- b.stencilManager.popStencil(a, a._webGL[c.id].data[0], b)
- }, b.WebGLMaskManager.prototype.destroy = function() {
- this.gl = null
- }, b.WebGLStencilManager = function() {
- this.stencilStack = [], this.reverse = !0, this.count = 0
- }, b.WebGLStencilManager.prototype.setContext = function(a) {
- this.gl = a
- }, b.WebGLStencilManager.prototype.pushStencil = function(a, b, c) {
- var d = this.gl;
- 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);
- var e = this.count;
- d.colorMask(!1, !1, !1, !1), d.stencilFunc(d.ALWAYS, 0, 255), d.stencilOp(d.KEEP, d.KEEP, d.INVERT), 1 === b.mode ? (d.drawElements(d.TRIANGLE_FAN, b.indices.length - 4, d.UNSIGNED_SHORT, 0), this.reverse ? (d.stencilFunc(d.EQUAL, 255 - e, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)) : (d.stencilFunc(d.EQUAL, e, 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)), d.drawElements(d.TRIANGLE_FAN, 4, d.UNSIGNED_SHORT, 2 * (b.indices.length - 4)), this.reverse ? d.stencilFunc(d.EQUAL, 255 - (e + 1), 255) : d.stencilFunc(d.EQUAL, e + 1, 255), this.reverse = !this.reverse) : (this.reverse ? (d.stencilFunc(d.EQUAL, e, 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)) : (d.stencilFunc(d.EQUAL, 255 - e, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)), d.drawElements(d.TRIANGLE_STRIP, b.indices.length, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e + 1, 255) : d.stencilFunc(d.EQUAL, 255 - (e + 1), 255)), d.colorMask(!0, !0, !0, !0), d.stencilOp(d.KEEP, d.KEEP, d.KEEP), this.count++
- }, b.WebGLStencilManager.prototype.bindGraphics = function(a, c, d) {
- this._currentGraphics = a;
- var e, f = this.gl,
- g = d.projection,
- h = d.offset;
- 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))
- }, b.WebGLStencilManager.prototype.popStencil = function(a, b, c) {
- var d = this.gl;
- if (this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length) d.disable(d.STENCIL_TEST);
- else {
- var e = this.count;
- this.bindGraphics(a, b, c), d.colorMask(!1, !1, !1, !1), 1 === b.mode ? (this.reverse = !this.reverse, this.reverse ? (d.stencilFunc(d.EQUAL, 255 - (e + 1), 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)) : (d.stencilFunc(d.EQUAL, e + 1, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)), d.drawElements(d.TRIANGLE_FAN, 4, d.UNSIGNED_SHORT, 2 * (b.indices.length - 4)), d.stencilFunc(d.ALWAYS, 0, 255), d.stencilOp(d.KEEP, d.KEEP, d.INVERT), d.drawElements(d.TRIANGLE_FAN, b.indices.length - 4, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e, 255) : d.stencilFunc(d.EQUAL, 255 - e, 255)) : (this.reverse ? (d.stencilFunc(d.EQUAL, e + 1, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)) : (d.stencilFunc(d.EQUAL, 255 - (e + 1), 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)), d.drawElements(d.TRIANGLE_STRIP, b.indices.length, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e, 255) : d.stencilFunc(d.EQUAL, 255 - e, 255)), d.colorMask(!0, !0, !0, !0), d.stencilOp(d.KEEP, d.KEEP, d.KEEP)
- }
- }, b.WebGLStencilManager.prototype.destroy = function() {
- this.stencilStack = null, this.gl = null
- }, b.WebGLShaderManager = function() {
- this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [];
- for (var a = 0; a < this.maxAttibs; a++) this.attribState[a] = !1;
- this.stack = []
- }, b.WebGLShaderManager.prototype.constructor = b.WebGLShaderManager, b.WebGLShaderManager.prototype.setContext = function(a) {
- 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)
- }, b.WebGLShaderManager.prototype.setAttribs = function(a) {
- var b;
- for (b = 0; b < this.tempAttribState.length; b++) this.tempAttribState[b] = !1;
- for (b = 0; b < a.length; b++) {
- var c = a[b];
- this.tempAttribState[c] = !0
- }
- var d = this.gl;
- 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))
- }, b.WebGLShaderManager.prototype.setShader = function(a) {
- return this._currentId === a._UID ? !1 : (this._currentId = a._UID, this.currentShader = a, this.gl.useProgram(a.program), this.setAttribs(a.attributes), !0)
- }, b.WebGLShaderManager.prototype.destroy = function() {
- this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.complexPrimitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null
- }, b.WebGLSpriteBatch = function() {
- this.vertSize = 6, this.size = 2e3;
- var a = 4 * this.size * this.vertSize,
- c = 6 * this.size;
- this.vertices = new Float32Array(a), this.indices = new Uint16Array(c), this.lastIndexCount = 0;
- 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;
- 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 ;", "}"])
- }, b.WebGLSpriteBatch.prototype.setContext = function(a) {
- 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;
- var c = new b.PixiShader(a);
- c.fragmentSrc = this.defaultShader.fragmentSrc, c.uniforms = {}, c.init(), this.defaultShader.shaders[a.id] = c
- }, b.WebGLSpriteBatch.prototype.begin = function(a) {
- this.renderSession = a, this.shader = this.renderSession.shaderManager.defaultShader, this.start()
- }, b.WebGLSpriteBatch.prototype.end = function() {
- this.flush()
- }, b.WebGLSpriteBatch.prototype.render = function(a) {
- var b = a.texture;
- this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = b.baseTexture);
- var c = b._uvs;
- if (c) {
- var d, e, f, g, h = a.worldAlpha,
- i = a.tint,
- j = this.vertices,
- k = a.anchor.x,
- l = a.anchor.y;
- if (b.trim) {
- var m = b.trim;
- e = m.x - k * m.width, d = e + b.crop.width, g = m.y - l * m.height, f = g + b.crop.height
- } else d = b.frame.width * (1 - k), e = b.frame.width * -k, f = b.frame.height * (1 - l), g = b.frame.height * -l;
- var n = 4 * this.currentBatchSize * this.vertSize,
- o = b.baseTexture.resolution,
- p = a.worldTransform,
- q = p.a / o,
- r = p.b / o,
- s = p.c / o,
- t = p.d / o,
- u = p.tx,
- v = p.ty;
- 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
- }
- }, b.WebGLSpriteBatch.prototype.renderTilingSprite = function(a) {
- var c = a.tilingTexture;
- this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = c.baseTexture), a._uvs || (a._uvs = new b.TextureUvs);
- var d = a._uvs;
- a.tilePosition.x %= c.baseTexture.width * a.tileScaleOffset.x, a.tilePosition.y %= c.baseTexture.height * a.tileScaleOffset.y;
- var e = a.tilePosition.x / (c.baseTexture.width * a.tileScaleOffset.x),
- f = a.tilePosition.y / (c.baseTexture.height * a.tileScaleOffset.y),
- g = a.width / c.baseTexture.width / (a.tileScale.x * a.tileScaleOffset.x),
- h = a.height / c.baseTexture.height / (a.tileScale.y * a.tileScaleOffset.y);
- d.x0 = 0 - e, d.y0 = 0 - f, d.x1 = 1 * g - e, d.y1 = 0 - f, d.x2 = 1 * g - e, d.y2 = 1 * h - f, d.x3 = 0 - e, d.y3 = 1 * h - f;
- var i = a.worldAlpha,
- j = a.tint,
- k = this.vertices,
- l = a.width,
- m = a.height,
- n = a.anchor.x,
- o = a.anchor.y,
- p = l * (1 - n),
- q = l * -n,
- r = m * (1 - o),
- s = m * -o,
- t = 4 * this.currentBatchSize * this.vertSize,
- u = c.baseTexture.resolution,
- v = a.worldTransform,
- w = v.a / u,
- x = v.b / u,
- y = v.c / u,
- z = v.d / u,
- A = v.tx,
- B = v.ty;
- 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
- }, b.WebGLSpriteBatch.prototype.flush = function() {
- if (0 !== this.currentBatchSize) {
- var a, c = this.gl;
- if (this.dirty) {
- 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];
- var d = 4 * this.vertSize;
- 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)
- }
- if (this.currentBatchSize > .5 * this.size) c.bufferSubData(c.ARRAY_BUFFER, 0, this.vertices);
- else {
- var e = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
- c.bufferSubData(c.ARRAY_BUFFER, 0, e)
- }
- 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++) {
- 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)) {
- 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();
- var s = this.renderSession.projection;
- c.uniform2f(a.projectionVector, s.x, s.y);
- var t = this.renderSession.offset;
- c.uniform2f(a.offsetVector, t.x, t.y)
- }
- j++
- }
- this.renderBatch(l, j, k), this.currentBatchSize = 0
- }
- }, b.WebGLSpriteBatch.prototype.renderBatch = function(a, b, c) {
- if (0 !== b) {
- var d = this.gl;
- 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++
- }
- }, b.WebGLSpriteBatch.prototype.stop = function() {
- this.flush(), this.dirty = !0
- }, b.WebGLSpriteBatch.prototype.start = function() {
- this.dirty = !0
- }, b.WebGLSpriteBatch.prototype.destroy = function() {
- this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null
- }, b.WebGLFastSpriteBatch = function(a) {
- this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize;
- var b = 4 * this.size * this.vertSize,
- c = 6 * this.maxSize;
- this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.vertexBuffer = null, this.indexBuffer = null, this.lastIndexCount = 0;
- 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;
- this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(a)
- }, b.WebGLFastSpriteBatch.prototype.constructor = b.WebGLFastSpriteBatch, b.WebGLFastSpriteBatch.prototype.setContext = function(a) {
- 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)
- }, b.WebGLFastSpriteBatch.prototype.begin = function(a, b) {
- this.renderSession = b, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = a.worldTransform.toArray(!0), this.start()
- }, b.WebGLFastSpriteBatch.prototype.end = function() {
- this.flush()
- }, b.WebGLFastSpriteBatch.prototype.render = function(a) {
- var b = a.children,
- c = b[0];
- if (c.texture._uvs) {
- this.currentBaseTexture = c.texture.baseTexture, c.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(c.blendMode));
- for (var d = 0, e = b.length; e > d; d++) this.renderSprite(b[d]);
- this.flush()
- }
- }, b.WebGLFastSpriteBatch.prototype.renderSprite = function(a) {
- if (a.visible && (a.texture.baseTexture === this.currentBaseTexture || (this.flush(), this.currentBaseTexture = a.texture.baseTexture, a.texture._uvs))) {
- var b, c, d, e, f, g, h, i, j = this.vertices;
- if (b = a.texture._uvs, c = a.texture.frame.width, d = a.texture.frame.height, a.texture.trim) {
- var k = a.texture.trim;
- 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
- } 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;
- 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()
- }
- }, b.WebGLFastSpriteBatch.prototype.flush = function() {
- if (0 !== this.currentBatchSize) {
- var a = this.gl;
- 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);
- else {
- var b = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
- a.bufferSubData(a.ARRAY_BUFFER, 0, b)
- }
- a.drawElements(a.TRIANGLES, 6 * this.currentBatchSize, a.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++
- }
- }, b.WebGLFastSpriteBatch.prototype.stop = function() {
- this.flush()
- }, b.WebGLFastSpriteBatch.prototype.start = function() {
- var a = this.gl;
- a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
- var b = this.renderSession.projection;
- a.uniform2f(this.shader.projectionVector, b.x, b.y), a.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix);
- var c = 4 * this.vertSize;
- a.vertexAttribPointer(this.shader.aVertexPosition, 2, a.FLOAT, !1, c, 0), a.vertexAttribPointer(this.shader.aPositionCoord, 2, a.FLOAT, !1, c, 8), a.vertexAttribPointer(this.shader.aScale, 2, a.FLOAT, !1, c, 16), a.vertexAttribPointer(this.shader.aRotation, 1, a.FLOAT, !1, c, 24), a.vertexAttribPointer(this.shader.aTextureCoord, 2, a.FLOAT, !1, c, 28), a.vertexAttribPointer(this.shader.colorAttribute, 1, a.FLOAT, !1, c, 36)
- }, b.WebGLFilterManager = function() {
- this.filterStack = [], this.offsetX = 0, this.offsetY = 0
- }, b.WebGLFilterManager.prototype.constructor = b.WebGLFilterManager, b.WebGLFilterManager.prototype.setContext = function(a) {
- this.gl = a, this.texturePool = [], this.initShaderBuffers()
- }, b.WebGLFilterManager.prototype.begin = function(a, b) {
- this.renderSession = a, this.defaultShader = a.shaderManager.defaultShader;
- var c = this.renderSession.projection;
- this.width = 2 * c.x, this.height = 2 * -c.y, this.buffer = b
- }, b.WebGLFilterManager.prototype.pushFilter = function(a) {
- var c = this.gl,
- d = this.renderSession.projection,
- e = this.renderSession.offset;
- a._filterArea = a.target.filterArea || a.target.getBounds(), this.filterStack.push(a);
- var f = a.filterPasses[0];
- this.offsetX += a._filterArea.x, this.offsetY += a._filterArea.y;
- var g = this.texturePool.pop();
- g ? g.resize(this.width, this.height) : g = new b.FilterTexture(this.gl, this.width, this.height), c.bindTexture(c.TEXTURE_2D, g.texture);
- var h = a._filterArea,
- i = f.padding;
- h.x -= i, h.y -= i, h.width += 2 * i, h.height += 2 * i, h.x < 0 && (h.x = 0), h.width > this.width && (h.width = this.width), h.y < 0 && (h.y = 0), h.height > this.height && (h.height = this.height), c.bindFramebuffer(c.FRAMEBUFFER, g.frameBuffer), c.viewport(0, 0, h.width, h.height), d.x = h.width / 2, d.y = -h.height / 2, e.x = -h.x, e.y = -h.y, c.colorMask(!0, !0, !0, !0), c.clearColor(0, 0, 0, 0), c.clear(c.COLOR_BUFFER_BIT), a._glFilterTexture = g
- }, b.WebGLFilterManager.prototype.popFilter = function() {
- var a = this.gl,
- c = this.filterStack.pop(),
- d = c._filterArea,
- e = c._glFilterTexture,
- f = this.renderSession.projection,
- g = this.renderSession.offset;
- if (c.filterPasses.length > 1) {
- 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);
- var h = e,
- i = this.texturePool.pop();
- i || (i = new b.FilterTexture(this.gl, this.width, this.height)), i.resize(this.width, this.height), a.bindFramebuffer(a.FRAMEBUFFER, i.frameBuffer), a.clear(a.COLOR_BUFFER_BIT), a.disable(a.BLEND);
- for (var j = 0; j < c.filterPasses.length - 1; j++) {
- var k = c.filterPasses[j];
- a.bindFramebuffer(a.FRAMEBUFFER, i.frameBuffer), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, h.texture), this.applyFilterPass(k, d, d.width, d.height);
- var l = h;
- h = i, i = l
- }
- a.enable(a.BLEND), e = h, this.texturePool.push(i)
- }
- var m = c.filterPasses[c.filterPasses.length - 1];
- this.offsetX -= d.x, this.offsetY -= d.y;
- var n = this.width,
- o = this.height,
- p = 0,
- q = 0,
- r = this.buffer;
- if (0 === this.filterStack.length) a.colorMask(!0, !0, !0, !0);
- else {
- var s = this.filterStack[this.filterStack.length - 1];
- d = s._filterArea, n = d.width, o = d.height, p = d.x, q = d.y, r = s._glFilterTexture.frameBuffer
- }
- f.x = n / 2, f.y = -o / 2, g.x = p, g.y = q, d = c._filterArea;
- var t = d.x - p,
- u = d.y - q;
- a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = t, this.vertexArray[1] = u + d.height, this.vertexArray[2] = t + d.width, this.vertexArray[3] = u + d.height, this.vertexArray[4] = t, this.vertexArray[5] = u, this.vertexArray[6] = t + d.width, this.vertexArray[7] = u, a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertexArray), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = d.width / this.width, this.uvArray[5] = d.height / this.height, this.uvArray[6] = d.width / this.width, this.uvArray[7] = d.height / this.height, a.bufferSubData(a.ARRAY_BUFFER, 0, this.uvArray), a.viewport(0, 0, n, o), a.bindFramebuffer(a.FRAMEBUFFER, r), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, e.texture), this.applyFilterPass(m, d, n, o), this.texturePool.push(e), c._glFilterTexture = null
- }, b.WebGLFilterManager.prototype.applyFilterPass = function(a, c, d, e) {
- var f = this.gl,
- g = a.shaders[f.id];
- 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++
- }, b.WebGLFilterManager.prototype.initShaderBuffers = function() {
- var a = this.gl;
- 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)
- }, b.WebGLFilterManager.prototype.destroy = function() {
- var a = this.gl;
- this.filterStack = null, this.offsetX = 0, this.offsetY = 0;
- for (var b = 0; b < this.texturePool.length; b++) this.texturePool[b].destroy();
- this.texturePool = null, a.deleteBuffer(this.vertexBuffer), a.deleteBuffer(this.uvBuffer), a.deleteBuffer(this.colorBuffer), a.deleteBuffer(this.indexBuffer)
- }, b.FilterTexture = function(a, c, d, e) {
- 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)
- }, b.FilterTexture.prototype.constructor = b.FilterTexture, b.FilterTexture.prototype.clear = function() {
- var a = this.gl;
- a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT)
- }, b.FilterTexture.prototype.resize = function(a, b) {
- if (this.width !== a || this.height !== b) {
- this.width = a, this.height = b;
- var c = this.gl;
- 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)
- }
- }, b.FilterTexture.prototype.destroy = function() {
- var a = this.gl;
- a.deleteFramebuffer(this.frameBuffer), a.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
- }, b.CanvasBuffer = function(a, b) {
- 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
- }, b.CanvasBuffer.prototype.constructor = b.CanvasBuffer, b.CanvasBuffer.prototype.clear = function() {
- this.context.clearRect(0, 0, this.width, this.height)
- }, b.CanvasBuffer.prototype.resize = function(a, b) {
- this.width = this.canvas.width = a, this.height = this.canvas.height = b
- }, b.CanvasMaskManager = function() {}, b.CanvasMaskManager.prototype.constructor = b.CanvasMaskManager, b.CanvasMaskManager.prototype.pushMask = function(a, c) {
- var d = c.context;
- d.save();
- var e = a.alpha,
- f = a.worldTransform,
- g = c.resolution;
- 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
- }, b.CanvasMaskManager.prototype.popMask = function(a) {
- a.context.restore()
- }, b.CanvasTinter = function() {}, b.CanvasTinter.getTintedTexture = function(a, c) {
- var d = a.texture;
- c = b.CanvasTinter.roundColor(c);
- var e = "#" + ("00000" + (0 | c).toString(16)).substr(-6);
- if (d.tintCache = d.tintCache || {}, d.tintCache[e]) return d.tintCache[e];
- var f = b.CanvasTinter.canvas || document.createElement("canvas");
- if (b.CanvasTinter.tintMethod(d, c, f), b.CanvasTinter.convertTintToImage) {
- var g = new Image;
- g.src = f.toDataURL(), d.tintCache[e] = g
- } else d.tintCache[e] = f, b.CanvasTinter.canvas = null;
- return f
- }, b.CanvasTinter.tintWithMultiply = function(a, b, c) {
- var d = c.getContext("2d"),
- e = a.crop;
- 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)
- }, b.CanvasTinter.tintWithOverlay = function(a, b, c) {
- var d = c.getContext("2d"),
- e = a.crop;
- 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)
- }, b.CanvasTinter.tintWithPerPixel = function(a, c, d) {
- var e = d.getContext("2d"),
- f = a.crop;
- 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);
- 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;
- e.putImageData(k, 0, 0)
- }, b.CanvasTinter.roundColor = function(a) {
- var c = b.CanvasTinter.cacheStepsPerColorChannel,
- d = b.hex2rgb(a);
- 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)
- }, 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) {
- if (d)
- for (var e in b.defaultRenderOptions) "undefined" == typeof d[e] && (d[e] = b.defaultRenderOptions[e]);
- else d = b.defaultRenderOptions;
- 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", {
- alpha: this.transparent
- }), 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 = {
- context: this.context,
- maskManager: this.maskManager,
- scaleMode: null,
- smoothProperty: null,
- roundPixels: !1
- }, 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")
- }, b.CanvasRenderer.prototype.constructor = b.CanvasRenderer, b.CanvasRenderer.prototype.render = function(a) {
- 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)))
- }, b.CanvasRenderer.prototype.destroy = function(a) {
- "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
- }, b.CanvasRenderer.prototype.resize = function(a, b) {
- 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"
- }, b.CanvasRenderer.prototype.renderDisplayObject = function(a, b) {
- this.renderSession.context = b || this.context, this.renderSession.resolution = this.resolution, a._renderCanvas(this.renderSession)
- }, b.CanvasRenderer.prototype.mapBlendModes = function() {
- 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"))
- }, b.CanvasGraphics = function() {}, b.CanvasGraphics.renderGraphics = function(a, c) {
- for (var d = a.worldAlpha, e = "", f = 0; f < a.graphicsData.length; f++) {
- var g = a.graphicsData[f],
- h = g.shape;
- if (c.strokeStyle = e = "#" + ("00000" + (0 | g.lineColor).toString(16)).substr(-6), c.lineWidth = g.lineWidth, g.type === b.Graphics.POLY) {
- c.beginPath();
- var i = h.points;
- c.moveTo(i[0], i[1]);
- for (var j = 1; j < i.length / 2; j++) c.lineTo(i[2 * j], i[2 * j + 1]);
- 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())
- } 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));
- 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());
- else if (g.type === b.Graphics.ELIP) {
- var k = 2 * h.width,
- l = 2 * h.height,
- m = h.x - k / 2,
- n = h.y - l / 2;
- c.beginPath();
- var o = .5522848,
- p = k / 2 * o,
- q = l / 2 * o,
- r = m + k,
- s = n + l,
- t = m + k / 2,
- u = n + l / 2;
- c.moveTo(m, u), c.bezierCurveTo(m, u - q, t - p, n, t, n), c.bezierCurveTo(t + p, n, r, u - q, r, u), c.bezierCurveTo(r, u + q, t + p, s, t, s), c.bezierCurveTo(t - p, s, m, u + q, m, u), c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())
- } else if (g.type === b.Graphics.RREC) {
- var v = h.points,
- w = v[0],
- x = v[1],
- y = v[2],
- z = v[3],
- A = v[4],
- B = Math.min(y, z) / 2 | 0;
- 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())
- }
- }
- }, b.CanvasGraphics.renderGraphicsMask = function(a, c) {
- var d = a.graphicsData.length;
- if (0 !== d) {
- d > 1 && (d = 1, window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));
- for (var e = 0; 1 > e; e++) {
- var f = a.graphicsData[e],
- g = f.shape;
- if (f.type === b.Graphics.POLY) {
- c.beginPath();
- var h = g.points;
- c.moveTo(h[0], h[1]);
- for (var i = 1; i < h.length / 2; i++) c.lineTo(h[2 * i], h[2 * i + 1]);
- h[0] === h[h.length - 2] && h[1] === h[h.length - 1] && c.closePath()
- } else if (f.type === b.Graphics.RECT) c.beginPath(), c.rect(g.x, g.y, g.width, g.height), c.closePath();
- else if (f.type === b.Graphics.CIRC) c.beginPath(), c.arc(g.x, g.y, g.radius, 0, 2 * Math.PI), c.closePath();
- else if (f.type === b.Graphics.ELIP) {
- var j = 2 * g.width,
- k = 2 * g.height,
- l = g.x - j / 2,
- m = g.y - k / 2;
- c.beginPath();
- var n = .5522848,
- o = j / 2 * n,
- p = k / 2 * n,
- q = l + j,
- r = m + k,
- s = l + j / 2,
- t = m + k / 2;
- c.moveTo(l, t), c.bezierCurveTo(l, t - p, s - o, m, s, m), c.bezierCurveTo(s + o, m, q, t - p, q, t), c.bezierCurveTo(q, t + p, s + o, r, s, r), c.bezierCurveTo(s - o, r, l, t + p, l, t), c.closePath()
- } else if (f.type === b.Graphics.RREC) {
- var u = g.points,
- v = u[0],
- w = u[1],
- x = u[2],
- y = u[3],
- z = u[4],
- A = Math.min(x, y) / 2 | 0;
- 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()
- }
- }
- }
- }, b.Strip = function(a) {
- 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
- }, b.Strip.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Strip.prototype.constructor = b.Strip, b.Strip.prototype._renderWebGL = function(a) {
- !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())
- }, b.Strip.prototype._initWebGL = function(a) {
- var b = a.gl;
- 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)
- }, b.Strip.prototype._renderStrip = function(a) {
- var b = a.gl,
- c = a.projection,
- d = a.offset,
- e = a.shaderManager.stripShader;
- 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)
- }, b.Strip.prototype._renderCanvas = function(a) {
- var b = a.context,
- c = this.worldTransform;
- 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);
- var d = this,
- e = d.verticies,
- f = d.uvs,
- g = e.length / 2;
- this.count++;
- for (var h = 0; g - 2 > h; h++) {
- var i = 2 * h,
- j = e[i],
- k = e[i + 2],
- l = e[i + 4],
- m = e[i + 1],
- n = e[i + 3],
- o = e[i + 5];
- if (this.padding > 0) {
- var p = (j + k + l) / 3,
- q = (m + n + o) / 3,
- r = j - p,
- s = m - q,
- t = Math.sqrt(r * r + s * s);
- j = p + r / t * (t + 3), m = q + s / t * (t + 3), r = k - p, s = n - q, t = Math.sqrt(r * r + s * s), k = p + r / t * (t + 3), n = q + s / t * (t + 3), r = l - p, s = o - q, t = Math.sqrt(r * r + s * s), l = p + r / t * (t + 3), o = q + s / t * (t + 3)
- }
- var u = f[i] * d.texture.width,
- v = f[i + 2] * d.texture.width,
- w = f[i + 4] * d.texture.width,
- x = f[i + 1] * d.texture.height,
- y = f[i + 3] * d.texture.height,
- z = f[i + 5] * d.texture.height;
- b.save(), b.beginPath(), b.moveTo(j, m), b.lineTo(k, n), b.lineTo(l, o), b.closePath(), b.clip();
- var A = u * y + x * w + v * z - y * w - x * v - u * z,
- B = j * y + x * l + k * z - y * l - x * k - j * z,
- C = u * k + j * w + v * l - k * w - j * v - u * l,
- D = u * y * l + x * k * w + j * v * z - j * y * w - x * v * l - u * k * z,
- E = m * y + x * o + n * z - y * o - x * n - m * z,
- F = u * n + m * w + v * o - n * w - m * v - u * o,
- G = u * y * o + x * n * w + m * v * z - m * y * w - x * v * o - u * n * z;
- b.transform(B / A, E / A, C / A, F / A, D / A, G / A), b.drawImage(d.texture.baseTexture.source, 0, 0), b.restore()
- }
- }, b.Strip.prototype.renderStripFlat = function(a) {
- var b = this.context,
- c = a.verticies,
- d = c.length / 2;
- this.count++, b.beginPath();
- for (var e = 1; d - 2 > e; e++) {
- var f = 2 * e,
- g = c[f],
- h = c[f + 2],
- i = c[f + 4],
- j = c[f + 1],
- k = c[f + 3],
- l = c[f + 5];
- b.moveTo(g, j), b.lineTo(h, k), b.lineTo(i, l)
- }
- b.fillStyle = "#FF0000", b.fill(), b.closePath()
- }, b.Strip.prototype.onTextureUpdate = function() {
- this.updateFrame = !0
- }, b.Rope = function(a, c) {
- 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()
- }, b.Rope.prototype = Object.create(b.Strip.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.refresh = function() {
- var a = this.points;
- if (!(a.length < 1)) {
- var b = this.uvs,
- c = a[0],
- d = this.indices,
- e = this.colors;
- this.count -= .2, b[0] = 0, b[1] = 0, b[2] = 0, b[3] = 1, e[0] = 1, e[1] = 1, d[0] = 0, d[1] = 1;
- 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
- }
- }, b.Rope.prototype.updateTransform = function() {
- var a = this.points;
- if (!(a.length < 1)) {
- var c, d = a[0],
- e = {
- x: 0,
- y: 0
- };
- this.count -= .2;
- 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;
- b.DisplayObjectContainer.prototype.updateTransform.call(this)
- }
- }, b.Rope.prototype.setTexture = function(a) {
- this.texture = a
- }, b.TilingSprite = function(a, c, d) {
- 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
- }, b.TilingSprite.prototype = Object.create(b.Sprite.prototype), b.TilingSprite.prototype.constructor = b.TilingSprite, Object.defineProperty(b.TilingSprite.prototype, "width", {
- get: function() {
- return this._width
- },
- set: function(a) {
- this._width = a
- }
- }), Object.defineProperty(b.TilingSprite.prototype, "height", {
- get: function() {
- return this._height
- },
- set: function(a) {
- this._height = a
- }
- }), b.TilingSprite.prototype.setTexture = function(a) {
- this.texture !== a && (this.texture = a, this.refreshTexture = !0, this.cachedTint = 16777215)
- }, b.TilingSprite.prototype._renderWebGL = function(a) {
- if (this.visible !== !1 && 0 !== this.alpha) {
- var c, d;
- 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);
- a.spriteBatch.stop(), this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this._mask, a), a.spriteBatch.start()
- }
- }, b.TilingSprite.prototype._renderCanvas = function(a) {
- if (this.visible !== !1 && 0 !== this.alpha) {
- var c = a.context;
- this._mask && a.maskManager.pushMask(this._mask, c), c.globalAlpha = this.worldAlpha;
- var d, e, f = this.worldTransform,
- g = a.resolution;
- 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) {
- if (this.generateTilingTexture(!1), !this.tilingTexture) return;
- this.__tilePattern = c.createPattern(this.tilingTexture.baseTexture.source, "repeat")
- }
- this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]);
- var h = this.tilePosition,
- i = this.tileScale;
- 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)
- }
- }, b.TilingSprite.prototype.getBounds = function() {
- var a = this._width,
- b = this._height,
- c = a * (1 - this.anchor.x),
- d = a * -this.anchor.x,
- e = b * (1 - this.anchor.y),
- f = b * -this.anchor.y,
- g = this.worldTransform,
- h = g.a,
- i = g.c,
- j = g.b,
- k = g.d,
- l = g.tx,
- m = g.ty,
- n = h * d + j * f + l,
- o = k * f + i * d + m,
- p = h * c + j * f + l,
- q = k * f + i * c + m,
- r = h * c + j * e + l,
- s = k * e + i * c + m,
- t = h * d + j * e + l,
- u = k * e + i * d + m,
- v = -1 / 0,
- w = -1 / 0,
- x = 1 / 0,
- y = 1 / 0;
- 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;
- var z = this._bounds;
- return z.x = x, z.width = v - x, z.y = y, z.height = w - y, this._currentBounds = z, z
- }, b.TilingSprite.prototype.onTextureUpdate = function() {}, b.TilingSprite.prototype.generateTilingTexture = function(a) {
- if (this.texture.baseTexture.hasLoaded) {
- var c, d, e = this.originalTexture || this.texture,
- f = e.frame,
- g = f.width !== e.baseTexture.width || f.height !== e.baseTexture.height,
- h = !1;
- 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) {
- var i;
- 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
- } else this.tilingTexture && this.tilingTexture.isTiling && this.tilingTexture.destroy(!0), this.tileScaleOffset.x = 1, this.tileScaleOffset.y = 1, this.tilingTexture = e;
- this.refreshTexture = !1, this.originalTexture = this.texture, this.texture = this.tilingTexture, this.tilingTexture.baseTexture._powerOf2 = !0
- }
- }, b.BaseTextureCache = {}, b.BaseTextureCacheIdGenerator = 0, b.BaseTexture = function(a, c) {
- 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) {
- 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();
- else {
- var d = this;
- this.source.onload = function() {
- d.hasLoaded = !0, d.width = d.source.naturalWidth || d.source.width, d.height = d.source.naturalHeight || d.source.height, d.dirty(), d.dispatchEvent({
- type: "loaded",
- content: d
- })
- }, this.source.onerror = function() {
- d.dispatchEvent({
- type: "error",
- content: d
- })
- }
- }
- this.imageUrl = null, this._powerOf2 = !1
- }
- }, b.BaseTexture.prototype.constructor = b.BaseTexture, b.EventTarget.mixin(b.BaseTexture.prototype), b.BaseTexture.prototype.destroy = function() {
- 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;
- for (var a = this._glTextures.length - 1; a >= 0; a--) {
- var c = this._glTextures[a],
- d = b.glContexts[a];
- d && c && d.deleteTexture(c)
- }
- this._glTextures.length = 0
- }, b.BaseTexture.prototype.updateSourceImage = function(a) {
- this.hasLoaded = !1, this.source.src = null, this.source.src = a
- }, b.BaseTexture.prototype.dirty = function() {
- for (var a = 0; a < this._glTextures.length; a++) this._dirty[a] = !0
- }, b.BaseTexture.fromImage = function(a, c, d) {
- var e = b.BaseTextureCache[a];
- if (void 0 === c && -1 === a.indexOf("data:") && (c = !0), !e) {
- var f = new Image;
- 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)
- }
- return e
- }, b.BaseTexture.fromCanvas = function(a, c) {
- a._pixiId || (a._pixiId = "canvas_" + b.TextureCacheIdGenerator++);
- var d = b.BaseTextureCache[a._pixiId];
- return d || (d = new b.BaseTexture(a, c), b.BaseTextureCache[a._pixiId] = d), d
- }, b.TextureCache = {}, b.FrameCache = {}, b.TextureCacheIdGenerator = 0, b.Texture = function(a, c, d, e) {
- 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))
- }, b.Texture.prototype.constructor = b.Texture, b.EventTarget.mixin(b.Texture.prototype), b.Texture.prototype.onBaseTextureLoaded = function() {
- var a = this.baseTexture;
- a.removeEventListener("loaded", this.onLoaded), this.noFrame && (this.frame = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(this.frame), this.dispatchEvent({
- type: "update",
- content: this
- })
- }, b.Texture.prototype.destroy = function(a) {
- a && this.baseTexture.destroy(), this.valid = !1
- }, b.Texture.prototype.setFrame = function(a) {
- 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);
- 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()
- }, b.Texture.prototype._updateUvs = function() {
- this._uvs || (this._uvs = new b.TextureUvs);
- var a = this.crop,
- c = this.baseTexture.width,
- d = this.baseTexture.height;
- this._uvs.x0 = a.x / c, this._uvs.y0 = a.y / d, this._uvs.x1 = (a.x + a.width) / c, this._uvs.y1 = a.y / d, this._uvs.x2 = (a.x + a.width) / c, this._uvs.y2 = (a.y + a.height) / d, this._uvs.x3 = a.x / c, this._uvs.y3 = (a.y + a.height) / d
- }, b.Texture.fromImage = function(a, c, d) {
- var e = b.TextureCache[a];
- return e || (e = new b.Texture(b.BaseTexture.fromImage(a, c, d)), b.TextureCache[a] = e), e
- }, b.Texture.fromFrame = function(a) {
- var c = b.TextureCache[a];
- if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache ');
- return c
- }, b.Texture.fromCanvas = function(a, c) {
- var d = b.BaseTexture.fromCanvas(a, c);
- return new b.Texture(d)
- }, b.Texture.addTextureToCache = function(a, c) {
- b.TextureCache[c] = a
- }, b.Texture.removeTextureFromCache = function(a) {
- var c = b.TextureCache[a];
- return delete b.TextureCache[a], delete b.BaseTextureCache[a], c
- }, b.TextureUvs = function() {
- this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0
- }, b.RenderTexture = function(a, c, d, e, f) {
- 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) {
- var g = this.renderer.gl;
- 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)
- } else this.render = this.renderCanvas, this.textureBuffer = new b.CanvasBuffer(this.width * this.resolution, this.height * this.resolution), this.baseTexture.source = this.textureBuffer.canvas;
- this.valid = !0, this._updateUvs()
- }, b.RenderTexture.prototype = Object.create(b.Texture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.resize = function(a, c, d) {
- (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))
- }, b.RenderTexture.prototype.clear = function() {
- this.valid && (this.renderer.type === b.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear())
- }, b.RenderTexture.prototype.renderWebGL = function(a, b, c) {
- if (this.valid) {
- var d = a.worldTransform;
- d.identity(), d.translate(0, 2 * this.projection.y), b && d.append(b), d.scale(1, -1), a.worldAlpha = 1;
- for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
- var h = this.renderer.gl;
- 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
- }
- }, b.RenderTexture.prototype.renderCanvas = function(a, b, c) {
- if (this.valid) {
- var d = a.worldTransform;
- d.identity(), b && d.append(b);
- for (var e = a.children, f = 0, g = e.length; g > f; f++) e[f].updateTransform();
- c && this.textureBuffer.clear();
- var h = this.textureBuffer.context,
- i = this.renderer.resolution;
- this.renderer.resolution = this.resolution, this.renderer.renderDisplayObject(a, h), this.renderer.resolution = i
- }
- }, b.RenderTexture.prototype.getImage = function() {
- var a = new Image;
- return a.src = this.getBase64(), a
- }, b.RenderTexture.prototype.getBase64 = function() {
- return this.getCanvas().toDataURL()
- }, b.RenderTexture.prototype.getCanvas = function() {
- if (this.renderer.type === b.WEBGL_RENDERER) {
- var a = this.renderer.gl,
- c = this.textureBuffer.width,
- d = this.textureBuffer.height,
- e = new Uint8Array(4 * c * d);
- a.bindFramebuffer(a.FRAMEBUFFER, this.textureBuffer.frameBuffer), a.readPixels(0, 0, c, d, a.RGBA, a.UNSIGNED_BYTE, e), a.bindFramebuffer(a.FRAMEBUFFER, null);
- 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) {
- var j = e[i + 3];
- h[i] = e[i] * j, h[i + 1] = e[i + 1] * j, h[i + 2] = e[i + 2] * j, h[i + 3] = j
- }
- return f.context.putImageData(g, 0, 0), f.canvas
- }
- return this.textureBuffer.canvas
- }, b.RenderTexture.tempMatrix = new b.Matrix, b.AbstractFilter = function(a, b) {
- this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = b || {}, this.fragmentSrc = a || []
- }, b.AbstractFilter.prototype.constructor = b.AbstractFilter, b.AbstractFilter.prototype.syncUniforms = function() {
- for (var a = 0, b = this.shaders.length; b > a; a++) this.shaders[a].dirty = !0
- }, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.PIXI = b) : "undefined" != typeof define && define.amd ? define("PIXI", function() {
- return a.PIXI = b
- }()) : a.PIXI = b
- }).call(this),
- function() {
- var a = this,
- b = b || {
- VERSION: "2.1.3",
- GAMES: [],
- AUTO: 0,
- CANVAS: 1,
- WEBGL: 2,
- HEADLESS: 3,
- NONE: 0,
- LEFT: 1,
- RIGHT: 2,
- UP: 3,
- DOWN: 4,
- SPRITE: 0,
- BUTTON: 1,
- IMAGE: 2,
- GRAPHICS: 3,
- TEXT: 4,
- TILESPRITE: 5,
- BITMAPTEXT: 6,
- GROUP: 7,
- RENDERTEXTURE: 8,
- TILEMAP: 9,
- TILEMAPLAYER: 10,
- EMITTER: 11,
- POLYGON: 12,
- BITMAPDATA: 13,
- CANVAS_FILTER: 14,
- WEBGL_FILTER: 15,
- ELLIPSE: 16,
- SPRITEBATCH: 17,
- RETROFONT: 18,
- POINTER: 19,
- ROPE: 20,
- blendModes: {
- NORMAL: 0,
- ADD: 1,
- MULTIPLY: 2,
- SCREEN: 3,
- OVERLAY: 4,
- DARKEN: 5,
- LIGHTEN: 6,
- COLOR_DODGE: 7,
- COLOR_BURN: 8,
- HARD_LIGHT: 9,
- SOFT_LIGHT: 10,
- DIFFERENCE: 11,
- EXCLUSION: 12,
- HUE: 13,
- SATURATION: 14,
- COLOR: 15,
- LUMINOSITY: 16
- },
- scaleModes: {
- DEFAULT: 0,
- LINEAR: 0,
- NEAREST: 1
- }
- };
- if (PIXI.InteractionManager = PIXI.InteractionManager || function() {}, PIXI.dontSayHello = !0, b.Utils = {
- getProperty: function(a, b) {
- 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++;
- return a ? a[d] : null
- },
- setProperty: function(a, b, c) {
- 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++;
- return a && (a[e] = c), a
- },
- transposeArray: function(a) {
- for (var b = new Array(a[0].length), c = 0; c < a[0].length; c++) {
- b[c] = new Array(a.length - 1);
- for (var d = a.length - 1; d > -1; d--) b[c][d] = a[d][c]
- }
- return b
- },
- rotateArray: function(a, c) {
- if ("string" != typeof c && (c = (c % 360 + 360) % 360), 90 === c || -270 === c || "rotateLeft" === c) a = b.Utils.transposeArray(a), a = a.reverse();
- else if (-90 === c || 270 === c || "rotateRight" === c) a = a.reverse(), a = b.Utils.transposeArray(a);
- else if (180 === Math.abs(c) || "rotate180" === c) {
- for (var d = 0; d < a.length; d++) a[d].reverse();
- a = a.reverse()
- }
- return a
- },
- parseDimension: function(a, b) {
- var c = 0,
- d = 0;
- 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
- },
- shuffle: function(a) {
- for (var b = a.length - 1; b > 0; b--) {
- var c = Math.floor(Math.random() * (b + 1)),
- d = a[b];
- a[b] = a[c], a[c] = d
- }
- return a
- },
- pad: function(a, b, c, d) {
- if ("undefined" == typeof b) var b = 0;
- if ("undefined" == typeof c) var c = " ";
- if ("undefined" == typeof d) var d = 3;
- var e = 0;
- if (b + 1 >= a.length) switch (d) {
- case 1:
- a = new Array(b + 1 - a.length).join(c) + a;
- break;
- case 3:
- var f = Math.ceil((e = b - a.length) / 2),
- g = e - f;
- a = new Array(g + 1).join(c) + a + new Array(f + 1).join(c);
- break;
- default:
- a += new Array(b + 1 - a.length).join(c)
- }
- return a
- },
- isPlainObject: function(a) {
- if ("object" != typeof a || a.nodeType || a === a.window) return !1;
- try {
- if (a.constructor && !{}.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) return !1
- } catch (b) {
- return !1
- }
- return !0
- },
- extend: function() {
- var a, c, d, e, f, g, h = arguments[0] || {},
- i = 1,
- j = arguments.length,
- k = !1;
- for ("boolean" == typeof h && (k = h, h = arguments[1] || {}, i = 2), j === i && (h = this, --i); j > i; i++)
- if (null != (a = arguments[i]))
- 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));
- return h
- },
- mixin: function(a, c) {
- if (!a || "object" != typeof a) return c;
- for (var d in a) {
- var e = a[d];
- if (!e.childNodes && !e.cloneNode) {
- var f = typeof a[d];
- c[d] = a[d] && "object" === f ? typeof c[d] === f ? b.Utils.mixin(a[d], c[d]) : b.Utils.mixin(a[d], new e.constructor) : a[d]
- }
- }
- return c
- }
- }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
- var a = Array.prototype.slice;
- return function(b) {
- function c() {
- var f = e.concat(a.call(arguments));
- d.apply(this instanceof c ? this : b, f)
- }
- var d = this,
- e = a.call(arguments, 1);
- if ("function" != typeof d) throw new TypeError;
- return c.prototype = function f(a) {
- return a && (f.prototype = a), this instanceof f ? void 0 : new f
- }(d.prototype), c
- }
- }()), Array.isArray || (Array.isArray = function(a) {
- return "[object Array]" == Object.prototype.toString.call(a)
- }), Array.prototype.forEach || (Array.prototype.forEach = function(a) {
- "use strict";
- if (void 0 === this || null === this) throw new TypeError;
- var b = Object(this),
- c = b.length >>> 0;
- if ("function" != typeof a) throw new TypeError;
- 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)
- }), "function" != typeof window.Uint32Array && "object" != typeof window.Uint32Array) {
- var c = function(a) {
- var b = new Array;
- window[a] = function(a) {
- if ("number" == typeof a) {
- Array.call(this, a), this.length = a;
- for (var b = 0; b < this.length; b++) this[b] = 0
- } else {
- Array.call(this, a.length), this.length = a.length;
- for (var b = 0; b < this.length; b++) this[b] = a[b]
- }
- }, window[a].prototype = b, window[a].constructor = window[a]
- };
- c("Uint32Array"), c("Int16Array")
- }
- window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), b.Circle = function(a, b, c) {
- 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
- }, b.Circle.prototype = {
- type: null,
- circumference: function() {
- return 2 * Math.PI * this._radius
- },
- getBounds: function() {
- return new b.Rectangle(this.x - this.radius, this.y - this.radius, 2 * this.radius, 2 * this.radius)
- },
- setTo: function(a, b, c) {
- return this.x = a, this.y = b, this._diameter = c, this._radius = .5 * c, this
- },
- copyFrom: function(a) {
- return this.setTo(a.x, a.y, a.diameter)
- },
- copyTo: function(a) {
- return a.x = this.x, a.y = this.y, a.diameter = this._diameter, a
- },
- distance: function(a, c) {
- 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)
- },
- clone: function(a) {
- 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
- },
- contains: function(a, c) {
- return b.Circle.contains(this, a, c)
- },
- circumferencePoint: function(a, c, d) {
- return b.Circle.circumferencePoint(this, a, c, d)
- },
- offset: function(a, b) {
- return this.x += a, this.y += b, this
- },
- offsetPoint: function(a) {
- return this.offset(a.x, a.y)
- },
- toString: function() {
- return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"
- }
- }, b.Circle.prototype.constructor = b.Circle, Object.defineProperty(b.Circle.prototype, "diameter", {
- get: function() {
- return this._diameter
- },
- set: function(a) {
- a > 0 && (this._diameter = a, this._radius = .5 * a)
- }
- }), Object.defineProperty(b.Circle.prototype, "radius", {
- get: function() {
- return this._radius
- },
- set: function(a) {
- a > 0 && (this._radius = a, this._diameter = 2 * a)
- }
- }), Object.defineProperty(b.Circle.prototype, "left", {
- get: function() {
- return this.x - this._radius
- },
- set: function(a) {
- a > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - a
- }
- }), Object.defineProperty(b.Circle.prototype, "right", {
- get: function() {
- return this.x + this._radius
- },
- set: function(a) {
- a < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.x
- }
- }), Object.defineProperty(b.Circle.prototype, "top", {
- get: function() {
- return this.y - this._radius
- },
- set: function(a) {
- a > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - a
- }
- }), Object.defineProperty(b.Circle.prototype, "bottom", {
- get: function() {
- return this.y + this._radius
- },
- set: function(a) {
- a < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.y
- }
- }), Object.defineProperty(b.Circle.prototype, "area", {
- get: function() {
- return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
- }
- }), Object.defineProperty(b.Circle.prototype, "empty", {
- get: function() {
- return 0 === this._diameter
- },
- set: function(a) {
- a === !0 && this.setTo(0, 0, 0)
- }
- }), b.Circle.contains = function(a, b, c) {
- if (a.radius > 0 && b >= a.left && b <= a.right && c >= a.top && c <= a.bottom) {
- var d = (a.x - b) * (a.x - b),
- e = (a.y - c) * (a.y - c);
- return d + e <= a.radius * a.radius
- }
- return !1
- }, b.Circle.equals = function(a, b) {
- return a.x == b.x && a.y == b.y && a.diameter == b.diameter
- }, b.Circle.intersects = function(a, c) {
- return b.Math.distance(a.x, a.y, c.x, c.y) <= a.radius + c.radius
- }, b.Circle.circumferencePoint = function(a, c, d, e) {
- 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
- }, b.Circle.intersectsRectangle = function(a, b) {
- var c = Math.abs(a.x - b.x - b.halfWidth),
- d = b.halfWidth + a.radius;
- if (c > d) return !1;
- var e = Math.abs(a.y - b.y - b.halfHeight),
- f = b.halfHeight + a.radius;
- if (e > f) return !1;
- if (c <= b.halfWidth || e <= b.halfHeight) return !0;
- var g = c - b.halfWidth,
- h = e - b.halfHeight,
- i = g * g,
- j = h * h,
- k = a.radius * a.radius;
- return k >= i + j
- }, PIXI.Circle = b.Circle, b.Point = function(a, b) {
- a = a || 0, b = b || 0, this.x = a, this.y = b
- }, b.Point.prototype = {
- copyFrom: function(a) {
- return this.setTo(a.x, a.y)
- },
- invert: function() {
- return this.setTo(this.y, this.x)
- },
- setTo: function(a, b) {
- return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
- },
- set: function(a, b) {
- return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
- },
- add: function(a, b) {
- return this.x += a, this.y += b, this
- },
- subtract: function(a, b) {
- return this.x -= a, this.y -= b, this
- },
- multiply: function(a, b) {
- return this.x *= a, this.y *= b, this
- },
- divide: function(a, b) {
- return this.x /= a, this.y /= b, this
- },
- clampX: function(a, c) {
- return this.x = b.Math.clamp(this.x, a, c), this
- },
- clampY: function(a, c) {
- return this.y = b.Math.clamp(this.y, a, c), this
- },
- clamp: function(a, c) {
- return this.x = b.Math.clamp(this.x, a, c), this.y = b.Math.clamp(this.y, a, c), this
- },
- clone: function(a) {
- return "undefined" == typeof a || null === a ? a = new b.Point(this.x, this.y) : a.setTo(this.x, this.y), a
- },
- copyTo: function(a) {
- return a.x = this.x, a.y = this.y, a
- },
- distance: function(a, c) {
- return b.Point.distance(this, a, c)
- },
- equals: function(a) {
- return a.x === this.x && a.y === this.y
- },
- angle: function(a, c) {
- 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)
- },
- angleSq: function(a) {
- return this.subtract(a).angle(a.subtract(this))
- },
- rotate: function(a, c, d, e, f) {
- return b.Point.rotate(this, a, c, d, e, f)
- },
- getMagnitude: function() {
- return Math.sqrt(this.x * this.x + this.y * this.y)
- },
- getMagnitudeSq: function() {
- return this.x * this.x + this.y * this.y
- },
- setMagnitude: function(a) {
- return this.normalize().multiply(a, a)
- },
- normalize: function() {
- if (!this.isZero()) {
- var a = this.getMagnitude();
- this.x /= a, this.y /= a
- }
- return this
- },
- isZero: function() {
- return 0 === this.x && 0 === this.y
- },
- dot: function(a) {
- return this.x * a.x + this.y * a.y
- },
- cross: function(a) {
- return this.x * a.y - this.y * a.x
- },
- perp: function() {
- return this.setTo(-this.y, this.x)
- },
- rperp: function() {
- return this.setTo(this.y, -this.x)
- },
- normalRightHand: function() {
- return this.setTo(-1 * this.y, this.x)
- },
- toString: function() {
- return "[{Point (x=" + this.x + " y=" + this.y + ")}]"
- }
- }, b.Point.prototype.constructor = b.Point, b.Point.add = function(a, c, d) {
- return "undefined" == typeof d && (d = new b.Point), d.x = a.x + c.x, d.y = a.y + c.y, d
- }, b.Point.subtract = function(a, c, d) {
- return "undefined" == typeof d && (d = new b.Point), d.x = a.x - c.x, d.y = a.y - c.y, d
- }, b.Point.multiply = function(a, c, d) {
- return "undefined" == typeof d && (d = new b.Point), d.x = a.x * c.x, d.y = a.y * c.y, d
- }, b.Point.divide = function(a, c, d) {
- return "undefined" == typeof d && (d = new b.Point), d.x = a.x / c.x, d.y = a.y / c.y, d
- }, b.Point.equals = function(a, b) {
- return a.x === b.x && a.y === b.y
- }, b.Point.angle = function(a, b) {
- return Math.atan2(a.y - b.y, a.x - b.x)
- }, b.Point.angleSq = function(a, b) {
- return a.subtract(b).angle(b.subtract(a))
- }, b.Point.negative = function(a, c) {
- return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.x, -a.y)
- }, b.Point.multiplyAdd = function(a, c, d, e) {
- return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + c.x * d, a.y + c.y * d)
- }, b.Point.interpolate = function(a, c, d, e) {
- return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + (c.x - a.x) * d, a.y + (c.y - a.y) * d)
- }, b.Point.perp = function(a, c) {
- return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.y, a.x)
- }, b.Point.rperp = function(a, c) {
- return "undefined" == typeof c && (c = new b.Point), c.setTo(a.y, -a.x)
- }, b.Point.distance = function(a, c, d) {
- 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)
- }, b.Point.project = function(a, c, d) {
- "undefined" == typeof d && (d = new b.Point);
- var e = a.dot(c) / c.getMagnitudeSq();
- return 0 !== e && d.setTo(e * c.x, e * c.y), d
- }, b.Point.projectUnit = function(a, c, d) {
- "undefined" == typeof d && (d = new b.Point);
- var e = a.dot(c);
- return 0 !== e && d.setTo(e * c.x, e * c.y), d
- }, b.Point.normalRightHand = function(a, c) {
- return "undefined" == typeof c && (c = new b.Point), c.setTo(-1 * a.y, a.x)
- }, b.Point.normalize = function(a, c) {
- "undefined" == typeof c && (c = new b.Point);
- var d = a.getMagnitude();
- return 0 !== d && c.setTo(a.x / d, a.y / d), c
- }, b.Point.rotate = function(a, c, d, e, f, g) {
- 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)));
- var h = e + Math.atan2(a.y - d, a.x - c);
- return a.setTo(c + g * Math.cos(h), d + g * Math.sin(h))
- }, b.Point.centroid = function(a, c) {
- 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");
- var d = a.length;
- if (1 > d) throw new Error("Phaser.Point. Parameter 'points' array must not be empty");
- if (1 === d) return c.copyFrom(a[0]), c;
- for (var e = 0; d > e; e++) b.Point.add(c, a[e], c);
- return c.divide(d, d), c
- }, b.Point.parse = function(a, c, d) {
- c = c || "x", d = d || "y";
- var e = new b.Point;
- return a[c] && (e.x = parseInt(a[c], 10)), a[d] && (e.y = parseInt(a[d], 10)), e
- }, PIXI.Point = b.Point, b.Rectangle = function(a, b, c, d) {
- a = a || 0, b = b || 0, c = c || 0, d = d || 0, this.x = a, this.y = b, this.width = c, this.height = d
- }, b.Rectangle.prototype = {
- offset: function(a, b) {
- return this.x += a, this.y += b, this
- },
- offsetPoint: function(a) {
- return this.offset(a.x, a.y)
- },
- setTo: function(a, b, c, d) {
- return this.x = a, this.y = b, this.width = c, this.height = d, this
- },
- scale: function(a, b) {
- return "undefined" == typeof b && (b = a), this.width *= a, this.height *= b, this
- },
- centerOn: function(a, b) {
- return this.centerX = a, this.centerY = b, this
- },
- floor: function() {
- this.x = Math.floor(this.x), this.y = Math.floor(this.y)
- },
- floorAll: function() {
- this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height)
- },
- copyFrom: function(a) {
- return this.setTo(a.x, a.y, a.width, a.height)
- },
- copyTo: function(a) {
- return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
- },
- inflate: function(a, c) {
- return b.Rectangle.inflate(this, a, c)
- },
- size: function(a) {
- return b.Rectangle.size(this, a)
- },
- clone: function(a) {
- return b.Rectangle.clone(this, a)
- },
- contains: function(a, c) {
- return b.Rectangle.contains(this, a, c)
- },
- containsRect: function(a) {
- return b.Rectangle.containsRect(a, this)
- },
- equals: function(a) {
- return b.Rectangle.equals(this, a)
- },
- intersection: function(a, c) {
- return b.Rectangle.intersection(this, a, c)
- },
- intersects: function(a, c) {
- return b.Rectangle.intersects(this, a, c)
- },
- intersectsRaw: function(a, c, d, e, f) {
- return b.Rectangle.intersectsRaw(this, a, c, d, e, f)
- },
- union: function(a, c) {
- return b.Rectangle.union(this, a, c)
- },
- toString: function() {
- return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"
- }
- }, Object.defineProperty(b.Rectangle.prototype, "halfWidth", {
- get: function() {
- return Math.round(this.width / 2)
- }
- }), Object.defineProperty(b.Rectangle.prototype, "halfHeight", {
- get: function() {
- return Math.round(this.height / 2)
- }
- }), Object.defineProperty(b.Rectangle.prototype, "bottom", {
- get: function() {
- return this.y + this.height
- },
- set: function(a) {
- this.height = a <= this.y ? 0 : a - this.y
- }
- }), Object.defineProperty(b.Rectangle.prototype, "bottomRight", {
- get: function() {
- return new b.Point(this.right, this.bottom)
- },
- set: function(a) {
- this.right = a.x, this.bottom = a.y
- }
- }), Object.defineProperty(b.Rectangle.prototype, "left", {
- get: function() {
- return this.x
- },
- set: function(a) {
- this.width = a >= this.right ? 0 : this.right - a, this.x = a
- }
- }), Object.defineProperty(b.Rectangle.prototype, "right", {
- get: function() {
- return this.x + this.width
- },
- set: function(a) {
- this.width = a <= this.x ? 0 : a - this.x
- }
- }), Object.defineProperty(b.Rectangle.prototype, "volume", {
- get: function() {
- return this.width * this.height
- }
- }), Object.defineProperty(b.Rectangle.prototype, "perimeter", {
- get: function() {
- return 2 * this.width + 2 * this.height
- }
- }), Object.defineProperty(b.Rectangle.prototype, "centerX", {
- get: function() {
- return this.x + this.halfWidth
- },
- set: function(a) {
- this.x = a - this.halfWidth
- }
- }), Object.defineProperty(b.Rectangle.prototype, "centerY", {
- get: function() {
- return this.y + this.halfHeight
- },
- set: function(a) {
- this.y = a - this.halfHeight
- }
- }), Object.defineProperty(b.Rectangle.prototype, "randomX", {
- get: function() {
- return this.x + Math.random() * this.width
- }
- }), Object.defineProperty(b.Rectangle.prototype, "randomY", {
- get: function() {
- return this.y + Math.random() * this.height
- }
- }), Object.defineProperty(b.Rectangle.prototype, "top", {
- get: function() {
- return this.y
- },
- set: function(a) {
- a >= this.bottom ? (this.height = 0, this.y = a) : this.height = this.bottom - a
- }
- }), Object.defineProperty(b.Rectangle.prototype, "topLeft", {
- get: function() {
- return new b.Point(this.x, this.y)
- },
- set: function(a) {
- this.x = a.x, this.y = a.y
- }
- }), Object.defineProperty(b.Rectangle.prototype, "topRight", {
- get: function() {
- return new b.Point(this.x + this.width, this.y)
- },
- set: function(a) {
- this.right = a.x, this.y = a.y
- }
- }), Object.defineProperty(b.Rectangle.prototype, "empty", {
- get: function() {
- return !this.width || !this.height
- },
- set: function(a) {
- a === !0 && this.setTo(0, 0, 0, 0)
- }
- }), b.Rectangle.prototype.constructor = b.Rectangle, b.Rectangle.inflate = function(a, b, c) {
- return a.x -= b, a.width += 2 * b, a.y -= c, a.height += 2 * c, a
- }, b.Rectangle.inflatePoint = function(a, c) {
- return b.Rectangle.inflate(a, c.x, c.y)
- }, b.Rectangle.size = function(a, c) {
- return "undefined" == typeof c || null === c ? c = new b.Point(a.width, a.height) : c.setTo(a.width, a.height), c
- }, b.Rectangle.clone = function(a, c) {
- 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
- }, b.Rectangle.contains = function(a, b, c) {
- return a.width <= 0 || a.height <= 0 ? !1 : b >= a.x && b < a.right && c >= a.y && c < a.bottom
- }, b.Rectangle.containsRaw = function(a, b, c, d, e, f) {
- return e >= a && a + c > e && f >= b && b + d > f
- }, b.Rectangle.containsPoint = function(a, c) {
- return b.Rectangle.contains(a, c.x, c.y)
- }, b.Rectangle.containsRect = function(a, b) {
- return a.volume > b.volume ? !1 : a.x >= b.x && a.y >= b.y && a.right < b.right && a.bottom < b.bottom
- }, b.Rectangle.equals = function(a, b) {
- return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
- }, b.Rectangle.intersection = function(a, c, d) {
- 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
- }, b.Rectangle.intersects = function(a, b) {
- 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)
- }, b.Rectangle.intersectsRaw = function(a, b, c, d, e, f) {
- return "undefined" == typeof f && (f = 0), !(b > a.right + f || c < a.left - f || d > a.bottom + f || e < a.top - f)
- }, b.Rectangle.union = function(a, c, d) {
- 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))
- }, b.Rectangle.aabb = function(a, c) {
- "undefined" == typeof c && (c = new b.Rectangle);
- var d = Number.MIN_VALUE,
- e = Number.MAX_VALUE,
- f = Number.MIN_VALUE,
- g = Number.MAX_VALUE;
- return a.forEach(function(a) {
- a.x > d && (d = a.x), a.x < e && (e = a.x), a.y > f && (f = a.y), a.y < g && (g = a.y)
- }), c.setTo(e, g, d - e, f - g), c
- }, PIXI.Rectangle = b.Rectangle, PIXI.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Line = function(a, c, d, e) {
- 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)
- }, b.Line.prototype = {
- setTo: function(a, b, c, d) {
- return this.start.setTo(a, b), this.end.setTo(c, d), this
- },
- fromSprite: function(a, b, c) {
- 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)
- },
- intersects: function(a, c, d) {
- return b.Line.intersectsPoints(this.start, this.end, a.start, a.end, c, d)
- },
- pointOnLine: function(a, b) {
- return (a - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (b - this.start.y)
- },
- pointOnSegment: function(a, b) {
- var c = Math.min(this.start.x, this.end.x),
- d = Math.max(this.start.x, this.end.x),
- e = Math.min(this.start.y, this.end.y),
- f = Math.max(this.start.y, this.end.y);
- return this.pointOnLine(a, b) && a >= c && d >= a && b >= e && f >= b
- },
- coordinatesOnLine: function(a, b) {
- "undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = []);
- var c = Math.round(this.start.x),
- d = Math.round(this.start.y),
- e = Math.round(this.end.x),
- f = Math.round(this.end.y),
- g = Math.abs(e - c),
- h = Math.abs(f - d),
- i = e > c ? 1 : -1,
- j = f > d ? 1 : -1,
- k = g - h;
- b.push([c, d]);
- for (var l = 1; c != e || d != f;) {
- var m = k << 1;
- m > -h && (k -= h, c += i), g > m && (k += g, d += j), l % a === 0 && b.push([c, d]), l++
- }
- return b
- },
- clone: function(a) {
- 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
- }
- }, Object.defineProperty(b.Line.prototype, "length", {
- get: function() {
- 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))
- }
- }), Object.defineProperty(b.Line.prototype, "angle", {
- get: function() {
- return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x)
- }
- }), Object.defineProperty(b.Line.prototype, "slope", {
- get: function() {
- return (this.end.y - this.start.y) / (this.end.x - this.start.x)
- }
- }), Object.defineProperty(b.Line.prototype, "perpSlope", {
- get: function() {
- return -((this.end.x - this.start.x) / (this.end.y - this.start.y))
- }
- }), Object.defineProperty(b.Line.prototype, "x", {
- get: function() {
- return Math.min(this.start.x, this.end.x)
- }
- }), Object.defineProperty(b.Line.prototype, "y", {
- get: function() {
- return Math.min(this.start.y, this.end.y)
- }
- }), Object.defineProperty(b.Line.prototype, "left", {
- get: function() {
- return Math.min(this.start.x, this.end.x)
- }
- }), Object.defineProperty(b.Line.prototype, "right", {
- get: function() {
- return Math.max(this.start.x, this.end.x)
- }
- }), Object.defineProperty(b.Line.prototype, "top", {
- get: function() {
- return Math.min(this.start.y, this.end.y)
- }
- }), Object.defineProperty(b.Line.prototype, "bottom", {
- get: function() {
- return Math.max(this.start.y, this.end.y)
- }
- }), Object.defineProperty(b.Line.prototype, "width", {
- get: function() {
- return Math.abs(this.start.x - this.end.x)
- }
- }), Object.defineProperty(b.Line.prototype, "height", {
- get: function() {
- return Math.abs(this.start.y - this.end.y)
- }
- }), b.Line.intersectsPoints = function(a, c, d, e, f, g) {
- "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = new b.Point);
- var h = c.y - a.y,
- i = e.y - d.y,
- j = a.x - c.x,
- k = d.x - e.x,
- l = c.x * a.y - a.x * c.y,
- m = e.x * d.y - d.x * e.y,
- n = h * k - i * j;
- if (0 === n) return null;
- if (g.x = (j * m - k * l) / n, g.y = (i * l - h * m) / n, f) {
- var o = (e.y - d.y) * (c.x - a.x) - (e.x - d.x) * (c.y - a.y),
- p = ((e.x - d.x) * (a.y - d.y) - (e.y - d.y) * (a.x - d.x)) / o,
- q = ((c.x - a.x) * (a.y - d.y) - (c.y - a.y) * (a.x - d.x)) / o;
- return p >= 0 && 1 >= p && q >= 0 && 1 >= q ? g : null
- }
- return g
- }, b.Line.intersects = function(a, c, d, e) {
- return b.Line.intersectsPoints(a.start, a.end, c.start, c.end, d, e)
- }, b.Ellipse = function(a, c, d, e) {
- 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
- }, b.Ellipse.prototype = {
- setTo: function(a, b, c, d) {
- return this.x = a, this.y = b, this.width = c, this.height = d, this
- },
- getBounds: function() {
- return new b.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height)
- },
- copyFrom: function(a) {
- return this.setTo(a.x, a.y, a.width, a.height)
- },
- copyTo: function(a) {
- return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
- },
- clone: function(a) {
- 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
- },
- contains: function(a, c) {
- return b.Ellipse.contains(this, a, c)
- },
- toString: function() {
- return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"
- }
- }, b.Ellipse.prototype.constructor = b.Ellipse, Object.defineProperty(b.Ellipse.prototype, "left", {
- get: function() {
- return this.x
- },
- set: function(a) {
- this.x = a
- }
- }), Object.defineProperty(b.Ellipse.prototype, "right", {
- get: function() {
- return this.x + this.width
- },
- set: function(a) {
- this.width = a < this.x ? 0 : this.x + a
- }
- }), Object.defineProperty(b.Ellipse.prototype, "top", {
- get: function() {
- return this.y
- },
- set: function(a) {
- this.y = a
- }
- }), Object.defineProperty(b.Ellipse.prototype, "bottom", {
- get: function() {
- return this.y + this.height
- },
- set: function(a) {
- this.height = a < this.y ? 0 : this.y + a
- }
- }), Object.defineProperty(b.Ellipse.prototype, "empty", {
- get: function() {
- return 0 === this.width || 0 === this.height
- },
- set: function(a) {
- a === !0 && this.setTo(0, 0, 0, 0)
- }
- }), b.Ellipse.contains = function(a, b, c) {
- if (a.width <= 0 || a.height <= 0) return !1;
- var d = (b - a.x) / a.width - .5,
- e = (c - a.y) / a.height - .5;
- return d *= d, e *= e, .25 > d + e
- }, b.Ellipse.prototype.getBounds = function() {
- return new b.Rectangle(this.x, this.y, this.width, this.height)
- }, PIXI.Ellipse = b.Ellipse, b.Polygon = function(a) {
- if (this.type = b.POLYGON, a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
- for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
- a = c
- }
- this.points = a, this.closed = !0
- }, b.Polygon.prototype = {
- clone: function(a) {
- var c = this.points.slice();
- return "undefined" == typeof a || null === a ? a = new b.Polygon(c) : a.setTo(c), a
- },
- contains: function(a, b) {
- for (var c = !1, d = this.points.length / 2, e = 0, f = d - 1; d > e; f = e++) {
- var g = this.points[2 * e].x,
- h = this.points[2 * e + 1].y,
- i = this.points[2 * f].x,
- j = this.points[2 * f + 1].y,
- k = h > b != j > b && (i - g) * (b - h) / (j - h) + g > a;
- k && (c = !c)
- }
- return c
- },
- setTo: function(a) {
- if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), a[0] instanceof b.Point) {
- for (var c = [], d = 0, e = a.length; e > d; d++) c.push(a[d].x, a[d].y);
- a = c
- }
- return this.points = a, this
- }
- }, b.Polygon.prototype.constructor = b.Polygon, Object.defineProperty(b.Polygon.prototype, "points", {
- get: function() {
- return this._points
- },
- set: function(a) {
- if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
- for (var c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
- a = c
- }
- this._points = a
- }
- }), Object.defineProperty(b.Polygon.prototype, "area", {
- get: function() {
- var a, b, c, d, e, f = Number.MAX_VALUE,
- g = 0;
- for (e = 0; e < this.points.length; e++) this.points[e].y < f && (f = this.points[e].y);
- 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;
- return g
- }
- }), PIXI.Graphics = function() {
- 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
- }, PIXI.Graphics.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), PIXI.Graphics.prototype.constructor = PIXI.Graphics, Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", {
- get: function() {
- return this._cacheAsBitmap
- },
- set: function(a) {
- this._cacheAsBitmap = a, this._cacheAsBitmap ? this._generateCachedSprite() : (this.destroyCachedSprite(), this.dirty = !0)
- }
- }), PIXI.Graphics.prototype.lineStyle = function(a, b, c) {
- if (this.lineWidth = a || 0, this.lineColor = b || 0, this.lineAlpha = arguments.length < 3 ? 1 : c, this.currentPath) {
- if (this.currentPath.shape.points.length) return this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))), this;
- this.currentPath.lineWidth = this.lineWidth, this.currentPath.lineColor = this.lineColor, this.currentPath.lineAlpha = this.lineAlpha
- }
- return this
- }, PIXI.Graphics.prototype.moveTo = function(a, b) {
- return this.drawShape(new PIXI.Polygon([a, b])), this
- }, PIXI.Graphics.prototype.lineTo = function(a, b) {
- return this.currentPath.shape.points.push(a, b), this.dirty = !0, this
- }, PIXI.Graphics.prototype.quadraticCurveTo = function(a, b, c, d) {
- this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
- var e, f, g = 20,
- h = this.currentPath.shape.points;
- 0 === h.length && this.moveTo(0, 0);
- 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);
- return this.dirty = !0, this
- }, PIXI.Graphics.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
- this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
- 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);
- return this.dirty = !0, this
- }, PIXI.Graphics.prototype.arcTo = function(a, b, c, d, e) {
- 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);
- var f = this.currentPath,
- g = f[f.length - 2],
- h = f[f.length - 1],
- i = h - b,
- j = g - a,
- k = d - b,
- l = c - a,
- m = Math.abs(i * l - j * k);
- if (1e-8 > m || 0 === e) f.push(a, b);
- else {
- var n = i * i + j * j,
- o = k * k + l * l,
- p = i * k + j * l,
- q = e * Math.sqrt(n) / m,
- r = e * Math.sqrt(o) / m,
- s = q * p / n,
- t = r * p / o,
- u = q * l + r * j,
- v = q * k + r * i,
- w = j * (r + s),
- x = i * (r + s),
- y = l * (q + t),
- z = k * (q + t),
- A = Math.atan2(x - v, w - u),
- B = Math.atan2(z - v, y - u);
- this.arc(u + a, v + b, e, A, B, j * k > l * i)
- }
- return this.dirty = !0, this
- }, PIXI.Graphics.prototype.arc = function(a, b, c, d, e, f) {
- var g = a + Math.cos(d) * c,
- h = b + Math.sin(d) * c,
- i = this.currentPath.shape.points;
- 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;
- !f && d >= e ? e += 2 * Math.PI : f && e >= d && (d += 2 * Math.PI);
- var j = f ? -1 * (d - e) : e - d,
- k = Math.abs(j) / (2 * Math.PI) * 40;
- if (0 === j) return this;
- 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++) {
- var s = r + q * r,
- t = l + d + m * s,
- u = Math.cos(t),
- v = -Math.sin(t);
- i.push((n * u + o * v) * c + a, (n * -v + o * u) * c + b)
- }
- return this.dirty = !0, this
- }, PIXI.Graphics.prototype.beginFill = function(a, b) {
- 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
- }, PIXI.Graphics.prototype.endFill = function() {
- return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this
- }, PIXI.Graphics.prototype.drawRect = function(a, b, c, d) {
- return this.drawShape(new PIXI.Rectangle(a, b, c, d)), this
- }, PIXI.Graphics.prototype.drawRoundedRect = function(a, b, c, d, e) {
- return this.drawShape({
- points: [a, b, c, d, e],
- type: PIXI.Graphics.RREC
- }), this
- }, PIXI.Graphics.prototype.drawCircle = function(a, b, c) {
- return this.drawShape(new PIXI.Circle(a, b, c)), this
- }, PIXI.Graphics.prototype.drawEllipse = function(a, b, c, d) {
- return this.drawShape(new PIXI.Ellipse(a, b, c, d)), this
- }, PIXI.Graphics.prototype.drawPolygon = function(a) {
- return a instanceof Array || (a = Array.prototype.slice.call(arguments)), this.drawShape(new PIXI.Polygon(a)), this
- }, PIXI.Graphics.prototype.clear = function() {
- return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this.clearDirty = !0, this.graphicsData = [], this
- }, PIXI.Graphics.prototype.generateTexture = function(a, b) {
- a = a || 1;
- var c = this.getBounds(),
- d = new PIXI.CanvasBuffer(c.width * a, c.height * a),
- e = PIXI.Texture.fromCanvas(d.canvas, b);
- return e.baseTexture.resolution = a, d.context.scale(a, a), d.context.translate(-c.x, -c.y), PIXI.CanvasGraphics.renderGraphics(this, d.context), e
- }, PIXI.Graphics.prototype._renderWebGL = function(a) {
- if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
- 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);
- if (a.spriteBatch.stop(), a.blendModeManager.setBlendMode(this.blendMode), this._mask && a.maskManager.pushMask(this._mask, a), this._filters && a.filterManager.pushFilter(this._filterBlock), this.blendMode !== a.spriteBatch.currentBlendMode) {
- a.spriteBatch.currentBlendMode = this.blendMode;
- var b = PIXI.blendModesWebGL[a.spriteBatch.currentBlendMode];
- a.spriteBatch.gl.blendFunc(b[0], b[1])
- }
- if (this.webGLDirty && (this.dirty = !0, this.webGLDirty = !1), PIXI.WebGLGraphics.renderGraphics(this, a), this.children.length) {
- a.spriteBatch.start();
- for (var c = 0, d = this.children.length; d > c; c++) this.children[c]._renderWebGL(a);
- a.spriteBatch.stop()
- }
- this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this.mask, a), a.drawCount++, a.spriteBatch.start()
- }
- }, PIXI.Graphics.prototype._renderCanvas = function(a) {
- if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
- 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);
- var b = a.context,
- c = this.worldTransform;
- this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, b.globalCompositeOperation = PIXI.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a);
- var d = a.resolution;
- 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);
- for (var e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
- this._mask && a.maskManager.popMask(a)
- }
- }, PIXI.Graphics.prototype.getBounds = function(a) {
- this.dirty && (this.updateBounds(), this.webGLDirty = !0, this.cachedSpriteDirty = !0, this.dirty = !1);
- var b = this._bounds,
- c = b.x,
- d = b.width + b.x,
- e = b.y,
- f = b.height + b.y,
- g = a || this.worldTransform,
- h = g.a,
- i = g.c,
- j = g.b,
- k = g.d,
- l = g.tx,
- m = g.ty,
- n = h * d + j * f + l,
- o = k * f + i * d + m,
- p = h * c + j * f + l,
- q = k * f + i * c + m,
- r = h * c + j * e + l,
- s = k * e + i * c + m,
- t = h * d + j * e + l,
- u = k * e + i * d + m,
- v = n,
- w = o,
- x = n,
- y = o;
- 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
- }, PIXI.Graphics.prototype.updateBounds = function() {
- var a = 1 / 0,
- b = -1 / 0,
- c = 1 / 0,
- d = -1 / 0;
- if (this.graphicsData.length)
- for (var e, f, g, h, i, j, k = 0; k < this.graphicsData.length; k++) {
- var l = this.graphicsData[k],
- m = l.type,
- n = l.lineWidth;
- 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;
- 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;
- 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;
- else {
- f = e.points;
- 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
- }
- } else a = 0, b = 0, c = 0, d = 0;
- var p = this.boundsPadding,
- q = this._bounds;
- q.x = a - p, q.width = b - a + 2 * p, q.y = c - p, q.height = d - c + 2 * p
- }, PIXI.Graphics.prototype._generateCachedSprite = function() {
- var a = this.getLocalBounds();
- if (this._cachedSprite) this._cachedSprite.buffer.resize(a.width, a.height);
- else {
- var b = new PIXI.CanvasBuffer(a.width, a.height),
- c = PIXI.Texture.fromCanvas(b.canvas);
- this._cachedSprite = new PIXI.Sprite(c), this._cachedSprite.buffer = b, this._cachedSprite.worldTransform = this.worldTransform
- }
- this._cachedSprite.anchor.x = -(a.x / a.width), this._cachedSprite.anchor.y = -(a.y / a.height), this._cachedSprite.buffer.context.translate(-a.x, -a.y), this.worldAlpha = 1, PIXI.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context), this._cachedSprite.alpha = this.alpha
- }, PIXI.Graphics.prototype.updateCachedSpriteTexture = function() {
- var a = this._cachedSprite,
- b = a.texture,
- c = a.buffer.canvas;
- 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()
- }, PIXI.Graphics.prototype.destroyCachedSprite = function() {
- this._cachedSprite.texture.destroy(!0), this._cachedSprite = null
- }, PIXI.Graphics.prototype.drawShape = function(a) {
- this.currentPath && this.currentPath.shape.points.length <= 2 && this.graphicsData.pop(), this.currentPath = null;
- var b = new PIXI.GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, a);
- return this.graphicsData.push(b), b.type === PIXI.Graphics.POLY && (b.shape.closed = this.filling, this.currentPath = b), this.dirty = !0, b
- }, PIXI.GraphicsData = function(a, b, c, d, e, f, g) {
- 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
- }, 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) {
- 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 = {
- x: !1,
- y: !1
- }, this.target = null, this._edge = 0, this._position = new b.Point, this.displayObject = null, this.scale = null, this._targetPosition = new b.Point
- }, b.Camera.FOLLOW_LOCKON = 0, b.Camera.FOLLOW_PLATFORMER = 1, b.Camera.FOLLOW_TOPDOWN = 2, b.Camera.FOLLOW_TOPDOWN_TIGHT = 3, b.Camera.prototype = {
- follow: function(a, c) {
- "undefined" == typeof c && (c = b.Camera.FOLLOW_LOCKON), this.target = a;
- var d;
- switch (c) {
- case b.Camera.FOLLOW_PLATFORMER:
- var e = this.width / 8,
- f = this.height / 3;
- this.deadzone = new b.Rectangle((this.width - e) / 2, (this.height - f) / 2 - .25 * f, e, f);
- break;
- case b.Camera.FOLLOW_TOPDOWN:
- d = Math.max(this.width, this.height) / 4, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
- break;
- case b.Camera.FOLLOW_TOPDOWN_TIGHT:
- d = Math.max(this.width, this.height) / 8, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
- break;
- case b.Camera.FOLLOW_LOCKON:
- this.deadzone = null;
- break;
- default:
- this.deadzone = null
- }
- },
- unfollow: function() {
- this.target = null
- },
- focusOn: function(a) {
- this.setPosition(Math.round(a.x - this.view.halfWidth), Math.round(a.y - this.view.halfHeight))
- },
- focusOnXY: function(a, b) {
- this.setPosition(Math.round(a - this.view.halfWidth), Math.round(b - this.view.halfHeight))
- },
- update: function() {
- 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
- },
- updateTarget: function() {
- 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)
- },
- setBoundsToWorld: function() {
- 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)
- },
- checkBounds: function() {
- 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)
- },
- setPosition: function(a, b) {
- this.view.x = a, this.view.y = b, this.bounds && this.checkBounds()
- },
- setSize: function(a, b) {
- this.view.width = a, this.view.height = b
- },
- reset: function() {
- this.target = null, this.view.x = 0, this.view.y = 0
- }
- }, b.Camera.prototype.constructor = b.Camera, Object.defineProperty(b.Camera.prototype, "x", {
- get: function() {
- return this.view.x
- },
- set: function(a) {
- this.view.x = a, this.bounds && this.checkBounds()
- }
- }), Object.defineProperty(b.Camera.prototype, "y", {
- get: function() {
- return this.view.y
- },
- set: function(a) {
- this.view.y = a, this.bounds && this.checkBounds()
- }
- }), Object.defineProperty(b.Camera.prototype, "position", {
- get: function() {
- return this._position.set(this.view.centerX, this.view.centerY), this._position
- },
- set: function(a) {
- "undefined" != typeof a.x && (this.view.x = a.x), "undefined" != typeof a.y && (this.view.y = a.y), this.bounds && this.checkBounds()
- }
- }), Object.defineProperty(b.Camera.prototype, "width", {
- get: function() {
- return this.view.width
- },
- set: function(a) {
- this.view.width = a
- }
- }), Object.defineProperty(b.Camera.prototype, "height", {
- get: function() {
- return this.view.height
- },
- set: function(a) {
- this.view.height = a
- }
- }), b.State = function() {
- 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
- }, b.State.prototype = {
- preload: function() {},
- loadUpdate: function() {},
- loadRender: function() {},
- create: function() {},
- update: function() {},
- render: function() {},
- resize: function() {},
- paused: function() {},
- pauseUpdate: function() {},
- shutdown: function() {}
- }, b.State.prototype.constructor = b.State, b.StateManager = function(a, b) {
- 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
- }, b.StateManager.prototype = {
- boot: function() {
- 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)
- },
- add: function(a, c, d) {
- "undefined" == typeof d && (d = !1);
- var e;
- 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
- },
- remove: function(a) {
- 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]
- },
- start: function(a, b, c) {
- "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)))
- },
- restart: function(a, b) {
- "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))
- },
- dummy: function() {},
- preUpdate: function() {
- if (this._pendingState && this.game.isBooted) {
- if (this.clearCurrentState(), this.setCurrentState(this._pendingState), this.current !== this._pendingState) return;
- 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()
- }
- },
- clearCurrentState: function() {
- 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()))
- },
- checkState: function(a) {
- if (this.states[a]) {
- var b = !1;
- 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
- }
- return console.warn("Phaser.StateManager - No state found with the key: " + a), !1
- },
- link: function(a) {
- 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
- },
- unlink: function(a) {
- 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)
- },
- setCurrentState: function(a) {
- 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 = [])
- },
- getCurrentState: function() {
- return this.states[this.current]
- },
- loadComplete: function() {
- this._created === !1 && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0
- },
- pause: function() {
- this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game)
- },
- resume: function() {
- this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game)
- },
- update: function() {
- this._created && this.onUpdateCallback ? this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
- },
- pauseUpdate: function() {
- this._created && this.onPauseUpdateCallback ? this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
- },
- preRender: function() {
- this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game)
- },
- resize: function(a, b) {
- this.onResizeCallback && this.onResizeCallback.call(this.callbackContext, a, b)
- },
- render: function() {
- 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)
- },
- destroy: function() {
- 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
- }
- }, b.StateManager.prototype.constructor = b.StateManager, b.LinkedList = function() {
- this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0
- }, b.LinkedList.prototype = {
- add: function(a) {
- 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)
- },
- reset: function() {
- this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0
- },
- remove: function(a) {
- 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--)
- },
- callAll: function(a) {
- if (this.first && this.last) {
- var b = this.first;
- do b && b[a] && b[a].call(b), b = b.next; while (b != this.last.next)
- }
- }
- }, b.LinkedList.prototype.constructor = b.LinkedList, b.ArrayList = function() {
- this.total = 0, this.position = 0, this.list = []
- }, b.ArrayList.prototype = {
- add: function(a) {
- return this.exists(a) || (this.list.push(a), this.total++), a
- },
- getIndex: function(a) {
- return this.list.indexOf(a)
- },
- exists: function(a) {
- return this.list.indexOf(a) > -1
- },
- reset: function() {
- this.list.length = 0, this.total = 0
- },
- remove: function(a) {
- var b = this.list.indexOf(a);
- return b > -1 ? (this.list.splice(b, 1), this.total--, a) : void 0
- },
- setAll: function(a, b) {
- for (var c = this.list.length; c--;) this.list[c] && this.list[c][a] && (this.list[c][a] = b)
- },
- callAll: function(a) {
- 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)
- }
- }, Object.defineProperty(b.ArrayList.prototype, "first", {
- get: function() {
- return this.position = 0, this.total > 0 ? this.list[0] : null
- }
- }), Object.defineProperty(b.ArrayList.prototype, "next", {
- get: function() {
- return this.position < this.total ? (this.position++, this.list[this.position]) : null
- }
- }), b.ArrayList.prototype.constructor = b.ArrayList, b.Signal = function() {
- this._bindings = [], this._prevParams = null;
- var a = this;
- this.dispatch = function() {
- b.Signal.prototype.dispatch.apply(a, arguments)
- }
- }, b.Signal.prototype = {
- memorize: !1,
- _shouldPropagate: !0,
- active: !0,
- validateListener: function(a, b) {
- if ("function" != typeof a) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", b))
- },
- _registerListener: function(a, c, d, e) {
- var f, g = this._indexOfListener(a, d);
- if (-1 !== g) {
- 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.")
- } else f = new b.SignalBinding(this, a, c, d, e), this._addBinding(f);
- return this.memorize && this._prevParams && f.execute(this._prevParams), f
- },
- _addBinding: function(a) {
- var b = this._bindings.length;
- do b--; while (this._bindings[b] && a._priority <= this._bindings[b]._priority);
- this._bindings.splice(b + 1, 0, a)
- },
- _indexOfListener: function(a, b) {
- for (var c, d = this._bindings.length; d--;)
- if (c = this._bindings[d], c._listener === a && c.context === b) return d;
- return -1
- },
- has: function(a, b) {
- return -1 !== this._indexOfListener(a, b)
- },
- add: function(a, b, c) {
- return this.validateListener(a, "add"), this._registerListener(a, !1, b, c)
- },
- addOnce: function(a, b, c) {
- return this.validateListener(a, "addOnce"), this._registerListener(a, !0, b, c)
- },
- remove: function(a, b) {
- this.validateListener(a, "remove");
- var c = this._indexOfListener(a, b);
- return -1 !== c && (this._bindings[c]._destroy(), this._bindings.splice(c, 1)), a
- },
- removeAll: function(a) {
- "undefined" == typeof a && (a = null);
- 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();
- a || (this._bindings.length = 0)
- },
- getNumListeners: function() {
- return this._bindings.length
- },
- halt: function() {
- this._shouldPropagate = !1
- },
- dispatch: function() {
- if (this.active) {
- var a, b = Array.prototype.slice.call(arguments),
- c = this._bindings.length;
- if (this.memorize && (this._prevParams = b), c) {
- a = this._bindings.slice(), this._shouldPropagate = !0;
- do c--; while (a[c] && this._shouldPropagate && a[c].execute(b) !== !1)
- }
- }
- },
- forget: function() {
- this._prevParams = null
- },
- dispose: function() {
- this.removeAll(), delete this._bindings, delete this._prevParams
- },
- toString: function() {
- return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"
- }
- }, b.Signal.prototype.constructor = b.Signal, b.SignalBinding = function(a, b, c, d, e) {
- this._listener = b, this._isOnce = c, this.context = d, this._signal = a, this._priority = e || 0
- }, b.SignalBinding.prototype = {
- active: !0,
- params: null,
- execute: function(a) {
- var b, c;
- 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
- },
- detach: function() {
- return this.isBound() ? this._signal.remove(this._listener, this.context) : null
- },
- isBound: function() {
- return !!this._signal && !!this._listener
- },
- isOnce: function() {
- return this._isOnce
- },
- getListener: function() {
- return this._listener
- },
- getSignal: function() {
- return this._signal
- },
- _destroy: function() {
- delete this._signal, delete this._listener, delete this.context
- },
- toString: function() {
- return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"
- }
- }, b.SignalBinding.prototype.constructor = b.SignalBinding, b.Filter = function(a, c, d) {
- this.game = a, this.type = b.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.prevPoint = new b.Point;
- var e = new Date;
- if (this.uniforms = {
- resolution: {
- type: "2f",
- value: {
- x: 256,
- y: 256
- }
- },
- time: {
- type: "1f",
- value: 0
- },
- mouse: {
- type: "2f",
- value: {
- x: 0,
- y: 0
- }
- },
- date: {
- type: "4fv",
- value: [e.getFullYear(), e.getMonth(), e.getDate(), 60 * e.getHours() * 60 + 60 * e.getMinutes() + e.getSeconds()]
- },
- sampleRate: {
- type: "1f",
- value: 44100
- },
- iChannel0: {
- type: "sampler2D",
- value: null,
- textureData: {
- repeat: !0
- }
- },
- iChannel1: {
- type: "sampler2D",
- value: null,
- textureData: {
- repeat: !0
- }
- },
- iChannel2: {
- type: "sampler2D",
- value: null,
- textureData: {
- repeat: !0
- }
- },
- iChannel3: {
- type: "sampler2D",
- value: null,
- textureData: {
- repeat: !0
- }
- }
- }, c)
- for (var f in c) this.uniforms[f] = c[f];
- this.fragmentSrc = d || []
- }, b.Filter.prototype = {
- init: function() {},
- setResolution: function(a, b) {
- this.uniforms.resolution.value.x = a, this.uniforms.resolution.value.y = b
- },
- update: function(a) {
- if ("undefined" != typeof a) {
- var b = a.x / this.game.width,
- c = 1 - a.y / this.game.height;
- (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))
- }
- this.uniforms.time.value = this.game.time.totalElapsedSeconds()
- },
- destroy: function() {
- this.game = null
- }
- }, b.Filter.prototype.constructor = b.Filter, Object.defineProperty(b.Filter.prototype, "width", {
- get: function() {
- return this.uniforms.resolution.value.x
- },
- set: function(a) {
- this.uniforms.resolution.value.x = a
- }
- }), Object.defineProperty(b.Filter.prototype, "height", {
- get: function() {
- return this.uniforms.resolution.value.y
- },
- set: function(a) {
- this.uniforms.resolution.value.y = a
- }
- }), b.Plugin = function(a, b) {
- "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
- }, b.Plugin.prototype = {
- preUpdate: function() {},
- update: function() {},
- render: function() {},
- postRender: function() {},
- destroy: function() {
- this.game = null, this.parent = null, this.active = !1, this.visible = !1
- }
- }, b.Plugin.prototype.constructor = b.Plugin, b.PluginManager = function(a) {
- this.game = a, this.plugins = [], this._len = 0, this._i = 0
- }, b.PluginManager.prototype = {
- add: function(a) {
- var b = Array.prototype.splice.call(arguments, 1),
- c = !1;
- 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
- },
- remove: function(a) {
- for (this._i = this._len; this._i--;)
- if (this.plugins[this._i] === a) return a.destroy(), this.plugins.splice(this._i, 1), void this._len--
- },
- removeAll: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
- this.plugins.length = 0, this._len = 0
- },
- preUpdate: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate()
- },
- update: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update()
- },
- postUpdate: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate()
- },
- render: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render()
- },
- postRender: function() {
- for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender()
- },
- destroy: function() {
- this.removeAll(), this.game = null
- }
- }, b.PluginManager.prototype.constructor = b.PluginManager, b.Stage = function(a) {
- 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)
- }, b.Stage.prototype = Object.create(PIXI.Stage.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.parseConfig = function(a) {
- a.disableVisibilityChange && (this.disableVisibilityChange = a.disableVisibilityChange), a.backgroundColor && (this.backgroundColor = a.backgroundColor)
- }, b.Stage.prototype.boot = function() {
- b.Canvas.getOffset(this.game.canvas, this.offset);
- var a = this;
- this._onChange = function(b) {
- return a.visibilityChange(b)
- }, b.Canvas.setUserSelect(this.game.canvas, "none"), b.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility()
- }, b.Stage.prototype.preUpdate = function() {
- this.currentRenderOrderID = 0;
- for (var a = this.children.length, b = 0; a > b; b++) this.children[b].preUpdate()
- }, b.Stage.prototype.update = function() {
- for (var a = this.children.length; a--;) this.children[a].update()
- }, b.Stage.prototype.postUpdate = function() {
- if (this.game.world.camera.target) {
- this.game.world.camera.target.postUpdate(), this.game.world.camera.update();
- for (var a = this.children.length; a--;) this.children[a] !== this.game.world.camera.target && this.children[a].postUpdate()
- } else {
- this.game.world.camera.update();
- for (var a = this.children.length; a--;) this.children[a].postUpdate()
- }
- }, b.Stage.prototype.checkVisibility = function() {
- 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;
- var a = this;
- this.game.device.cocoonJSApp && (CocoonJS.App.onSuspended.addEventListener(function() {
- b.Stage.prototype.visibilityChange.call(a, {
- type: "pause"
- })
- }), CocoonJS.App.onActivated.addEventListener(function() {
- b.Stage.prototype.visibilityChange.call(a, {
- type: "resume"
- })
- }))
- }, b.Stage.prototype.visibilityChange = function(a) {
- 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)))
- }, b.Stage.prototype.setBackgroundColor = function(a) {
- if ("string" == typeof a) {
- var c = b.Color.hexToColor(a);
- this._backgroundColor = b.Color.getColor(c.r, c.g, c.b)
- } else {
- var c = b.Color.getRGB(a);
- this._backgroundColor = a
- }
- this.backgroundColorSplit = [c.r / 255, c.g / 255, c.b / 255], this.backgroundColorString = b.Color.RGBtoString(c.r, c.g, c.b, 255, "#")
- }, b.Stage.prototype.destroy = function() {
- this._hiddenVar && document.removeEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = null, window.onpageshow = null, window.onblur = null, window.onfocus = null
- }, Object.defineProperty(b.Stage.prototype, "backgroundColor", {
- get: function() {
- return this._backgroundColor
- },
- set: function(a) {
- this.game.transparent || this.setBackgroundColor(a)
- }
- }), Object.defineProperty(b.Stage.prototype, "smoothed", {
- get: function() {
- return !PIXI.scaleModes.LINEAR
- },
- set: function(a) {
- PIXI.scaleModes.LINEAR = a ? 0 : 1
- }
- }), b.Group = function(a, c, d, e, f, g) {
- "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]
- }, 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) {
- 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
- }, b.Group.prototype.addMultiple = function(a, b) {
- if (Array.isArray(a))
- for (var c = 0; c < a.length; c++) this.add(a[c], b);
- return a
- }, b.Group.prototype.addAt = function(a, b, c) {
- 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
- }, b.Group.prototype.getAt = function(a) {
- return 0 > a || a >= this.children.length ? -1 : this.getChildAt(a)
- }, b.Group.prototype.create = function(a, b, c, d, e) {
- "undefined" == typeof e && (e = !0);
- var f = new this.classType(this.game, a, b, c, d);
- 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
- }, b.Group.prototype.createMultiple = function(a, b, c, d) {
- "undefined" == typeof d && (d = !1);
- for (var e = 0; a > e; e++) this.create(0, 0, b, c, d)
- }, b.Group.prototype.updateZ = function() {
- for (var a = this.children.length; a--;) this.children[a].z = a
- }, b.Group.prototype.resetCursor = function(a) {
- 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
- }, b.Group.prototype.next = function() {
- 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
- }, b.Group.prototype.previous = function() {
- 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
- }, b.Group.prototype.swap = function(a, b) {
- this.swapChildren(a, b), this.updateZ()
- }, b.Group.prototype.bringToTop = function(a) {
- return a.parent === this && this.getIndex(a) < this.children.length && (this.remove(a, !1, !0), this.add(a, !0)), a
- }, b.Group.prototype.sendToBack = function(a) {
- return a.parent === this && this.getIndex(a) > 0 && (this.remove(a, !1, !0), this.addAt(a, 0, !0)), a
- }, b.Group.prototype.moveUp = function(a) {
- if (a.parent === this && this.getIndex(a) < this.children.length - 1) {
- var b = this.getIndex(a),
- c = this.getAt(b + 1);
- c && this.swap(a, c)
- }
- return a
- }, b.Group.prototype.moveDown = function(a) {
- if (a.parent === this && this.getIndex(a) > 0) {
- var b = this.getIndex(a),
- c = this.getAt(b - 1);
- c && this.swap(a, c)
- }
- return a
- }, b.Group.prototype.xy = function(a, b, c) {
- return 0 > a || a > this.children.length ? -1 : (this.getChildAt(a).x = b, void(this.getChildAt(a).y = c))
- }, b.Group.prototype.reverse = function() {
- this.children.reverse(), this.updateZ()
- }, b.Group.prototype.getIndex = function(a) {
- return this.children.indexOf(a)
- }, b.Group.prototype.replace = function(a, c) {
- var d = this.getIndex(a);
- if (-1 !== d) {
- void 0 !== c.parent && (c.events.onRemovedFromGroup.dispatch(c, this), c.parent.removeChild(c), c.parent instanceof b.Group && c.parent.updateZ());
- var e = a;
- return this.remove(e), this.addAt(c, d), e
- }
- }, b.Group.prototype.hasProperty = function(a, b) {
- var c = b.length;
- 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
- }, b.Group.prototype.setProperty = function(a, b, c, d, e) {
- if ("undefined" == typeof e && (e = !1), d = d || 0, !this.hasProperty(a, b) && (!e || d > 0)) return !1;
- var f = b.length;
- 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
- }, b.Group.prototype.checkProperty = function(a, c, d, e) {
- return "undefined" == typeof e && (e = !1), !b.Utils.getProperty(a, c) && e ? !1 : b.Utils.getProperty(a, c) !== d ? !1 : !0
- }, b.Group.prototype.set = function(a, b, c, d, e, f, g) {
- 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
- }, b.Group.prototype.setAll = function(a, b, c, d, e, f) {
- "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof f && (f = !1), a = a.split("."), e = e || 0;
- 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)
- }, b.Group.prototype.setAllChildren = function(a, c, d, e, f, g) {
- "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), "undefined" == typeof g && (g = !1), f = f || 0;
- 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))
- }, b.Group.prototype.checkAll = function(a, b, c, d, e) {
- "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
- for (var f = 0, g = this.children.length; g > f; f++)
- if ((!c || c && this.children[f].alive) && (!d || d && this.children[f].visible) && !this.checkProperty(this.children[f], a, b, e)) return !1;
- return !0
- }, b.Group.prototype.addAll = function(a, b, c, d) {
- this.setAll(a, b, c, d, 1)
- }, b.Group.prototype.subAll = function(a, b, c, d) {
- this.setAll(a, b, c, d, 2)
- }, b.Group.prototype.multiplyAll = function(a, b, c, d) {
- this.setAll(a, b, c, d, 3)
- }, b.Group.prototype.divideAll = function(a, b, c, d) {
- this.setAll(a, b, c, d, 4)
- }, b.Group.prototype.callAllExists = function(a, b) {
- 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)
- }, b.Group.prototype.callbackFromArray = function(a, b, c) {
- if (1 == c) {
- if (a[b[0]]) return a[b[0]]
- } else if (2 == c) {
- if (a[b[0]][b[1]]) return a[b[0]][b[1]]
- } else if (3 == c) {
- if (a[b[0]][b[1]][b[2]]) return a[b[0]][b[1]][b[2]]
- } else if (4 == c) {
- if (a[b[0]][b[1]][b[2]][b[3]]) return a[b[0]][b[1]][b[2]][b[3]]
- } else if (a[b]) return a[b];
- return !1
- }, b.Group.prototype.callAll = function(a, b) {
- if ("undefined" != typeof a) {
- a = a.split(".");
- var c = a.length;
- if ("undefined" == typeof b || null === b || "" === b) b = null;
- else if ("string" == typeof b) {
- b = b.split(".");
- var d = b.length
- }
- 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)
- }
- }, b.Group.prototype.preUpdate = function() {
- if (!this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
- for (var a = this.children.length; a--;) this.children[a].preUpdate();
- return !0
- }, b.Group.prototype.update = function() {
- for (var a = this.children.length; a--;) this.children[a].update()
- }, b.Group.prototype.postUpdate = function() {
- 1 === this._cache[7] && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y);
- for (var a = this.children.length; a--;) this.children[a].postUpdate()
- }, b.Group.prototype.filter = function(a, c) {
- for (var d = -1, e = this.children.length, f = new b.ArrayList; ++d < e;) {
- var g = this.children[d];
- (!c || c && g.exists) && a(g, d, this.children) && f.add(g)
- }
- return f
- }, b.Group.prototype.forEach = function(a, b, c) {
- "undefined" == typeof c && (c = !1);
- var d = Array.prototype.splice.call(arguments, 3);
- d.unshift(null);
- 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))
- }, b.Group.prototype.forEachExists = function(a, c) {
- var d = Array.prototype.splice.call(arguments, 2);
- d.unshift(null), this.iterate("exists", !0, b.Group.RETURN_TOTAL, a, c, d)
- }, b.Group.prototype.forEachAlive = function(a, c) {
- var d = Array.prototype.splice.call(arguments, 2);
- d.unshift(null), this.iterate("alive", !0, b.Group.RETURN_TOTAL, a, c, d)
- }, b.Group.prototype.forEachDead = function(a, c) {
- var d = Array.prototype.splice.call(arguments, 2);
- d.unshift(null), this.iterate("alive", !1, b.Group.RETURN_TOTAL, a, c, d)
- }, b.Group.prototype.sort = function(a, c) {
- 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())
- }, b.Group.prototype.customSort = function(a, b) {
- this.children.length < 2 || (this.children.sort(a.bind(b)), this.updateZ())
- }, b.Group.prototype.ascendingSortHandler = function(a, b) {
- return a[this._sortProperty] < b[this._sortProperty] ? -1 : a[this._sortProperty] > b[this._sortProperty] ? 1 : a.z < b.z ? -1 : 1
- }, b.Group.prototype.descendingSortHandler = function(a, b) {
- return a[this._sortProperty] < b[this._sortProperty] ? 1 : a[this._sortProperty] > b[this._sortProperty] ? -1 : 0
- }, b.Group.prototype.iterate = function(a, c, d, e, f, g) {
- if (d === b.Group.RETURN_TOTAL && 0 === this.children.length) return 0;
- "undefined" == typeof e && (e = !1);
- for (var h = 0, i = 0, j = this.children.length; j > i; i++)
- 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];
- return d === b.Group.RETURN_TOTAL ? h : d === b.Group.RETURN_CHILD ? null : void 0
- }, b.Group.prototype.getFirstExists = function(a) {
- return "boolean" != typeof a && (a = !0), this.iterate("exists", a, b.Group.RETURN_CHILD)
- }, b.Group.prototype.getFirstAlive = function() {
- return this.iterate("alive", !0, b.Group.RETURN_CHILD)
- }, b.Group.prototype.getFirstDead = function() {
- return this.iterate("alive", !1, b.Group.RETURN_CHILD)
- }, b.Group.prototype.getTop = function() {
- return this.children.length > 0 ? this.children[this.children.length - 1] : void 0
- }, b.Group.prototype.getBottom = function() {
- return this.children.length > 0 ? this.children[0] : void 0
- }, b.Group.prototype.countLiving = function() {
- return this.iterate("alive", !0, b.Group.RETURN_TOTAL)
- }, b.Group.prototype.countDead = function() {
- return this.iterate("alive", !1, b.Group.RETURN_TOTAL)
- }, b.Group.prototype.getRandom = function(a, b) {
- return 0 === this.children.length ? null : (a = a || 0, b = b || this.children.length, this.game.math.getRandom(this.children, a, b))
- }, b.Group.prototype.remove = function(a, b, c) {
- if ("undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !1), 0 === this.children.length || -1 === this.children.indexOf(a)) return !1;
- c || !a.events || a.destroyPhase || a.events.onRemovedFromGroup.dispatch(a, this);
- var d = this.removeChild(a);
- return this.updateZ(), this.cursor === a && this.next(), b && d && d.destroy(!0), !0
- }, b.Group.prototype.removeAll = function(a, b) {
- if ("undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), 0 !== this.children.length) {
- do {
- !b && this.children[0].events && this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
- var c = this.removeChild(this.children[0]);
- a && c && c.destroy(!0)
- } while (this.children.length > 0);
- this.cursor = null
- }
- }, b.Group.prototype.removeBetween = function(a, b, c, d) {
- if ("undefined" == typeof b && (b = this.children.length - 1), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), 0 !== this.children.length) {
- if (a > b || 0 > a || b > this.children.length) return !1;
- for (var e = b; e >= a;) {
- !d && this.children[e].events && this.children[e].events.onRemovedFromGroup.dispatch(this.children[e], this);
- var f = this.removeChild(this.children[e]);
- c && f && f.destroy(!0), this.cursor === this.children[e] && (this.cursor = null), e--
- }
- this.updateZ()
- }
- }, b.Group.prototype.destroy = function(a, b) {
- 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))
- }, Object.defineProperty(b.Group.prototype, "total", {
- get: function() {
- return this.iterate("exists", !0, b.Group.RETURN_TOTAL)
- }
- }), Object.defineProperty(b.Group.prototype, "length", {
- get: function() {
- return this.children.length
- }
- }), Object.defineProperty(b.Group.prototype, "angle", {
- get: function() {
- return b.Math.radToDeg(this.rotation)
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(a)
- }
- }), Object.defineProperty(b.Group.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), b.World = function(a) {
- 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
- }, b.World.prototype = Object.create(b.Group.prototype), b.World.prototype.constructor = b.World, b.World.prototype.boot = function() {
- 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)
- }, b.World.prototype.setBounds = function(a, b, c, d) {
- 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()
- }, b.World.prototype.resize = function(a, b) {
- 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()
- }, b.World.prototype.shutdown = function() {
- this.destroy(!0, !0)
- }, b.World.prototype.wrap = function(a, b, c, d, e) {
- "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))
- }, Object.defineProperty(b.World.prototype, "width", {
- get: function() {
- return this.bounds.width
- },
- set: function(a) {
- a < this.game.width && (a = this.game.width), this.bounds.width = a, this._width = a, this._definedSize = !0
- }
- }), Object.defineProperty(b.World.prototype, "height", {
- get: function() {
- return this.bounds.height
- },
- set: function(a) {
- a < this.game.height && (a = this.game.height), this.bounds.height = a, this._height = a, this._definedSize = !0
- }
- }), Object.defineProperty(b.World.prototype, "centerX", {
- get: function() {
- return this.bounds.x + this.bounds.halfWidth
- }
- }), Object.defineProperty(b.World.prototype, "centerY", {
- get: function() {
- return this.bounds.y + this.bounds.halfHeight
- }
- }), Object.defineProperty(b.World.prototype, "randomX", {
- get: function() {
- 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)
- }
- }), Object.defineProperty(b.World.prototype, "randomY", {
- get: function() {
- 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)
- }
- }), b.FlexGrid = function(a, c, d) {
- 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 = []
- }, b.FlexGrid.prototype = {
- setSize: function(a, c) {
- 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()
- },
- createCustomLayer: function(a, c, d, e) {
- "undefined" == typeof e && (e = !0), this.customWidth = a, this.customHeight = c, this.boundsCustom.width = a, this.boundsCustom.height = c;
- var f = new b.FlexLayer(this, this.positionCustom, this.boundsCustom, this.scaleCustom);
- return e && this.game.world.add(f), this.layers.push(f), "undefined" != typeof d && null !== typeof d && f.addMultiple(d), f
- },
- createFluidLayer: function(a, c) {
- "undefined" == typeof c && (c = !0);
- var d = new b.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
- return c && this.game.world.add(d), this.layers.push(d), "undefined" != typeof a && null !== typeof a && d.addMultiple(a), d
- },
- createFullLayer: function(a) {
- var c = new b.FlexLayer(this, this.positionFull, this.boundsFull, this.scaleFluid);
- return this.game.world.add(c), this.layers.push(c), "undefined" != typeof a && c.addMultiple(a), c
- },
- createFixedLayer: function(a) {
- var c = new b.FlexLayer(this, this.positionNone, this.boundsNone, this.scaleNone);
- return this.game.world.add(c), this.layers.push(c), "undefined" != typeof a && c.addMultiple(a), c
- },
- reset: function() {
- 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))
- },
- onResize: function(a, b) {
- this.refresh(a, b)
- },
- refresh: function() {
- 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)
- },
- debug: function() {
- 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)
- }
- }, b.FlexGrid.prototype.constructor = b.FlexGrid, b.FlexLayer = function(a, c, d, e) {
- 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
- }, b.FlexLayer.prototype = Object.create(b.Group.prototype), b.FlexLayer.prototype.constructor = b.FlexLayer, b.FlexLayer.prototype.resize = function() {}, b.FlexLayer.prototype.debug = function() {
- 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")
- }, b.ScaleManager = function(a, c, d) {
- 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)
- }, b.ScaleManager.EXACT_FIT = 0, b.ScaleManager.NO_SCALE = 1, b.ScaleManager.SHOW_ALL = 2, b.ScaleManager.RESIZE = 3, b.ScaleManager.prototype = {
- parseConfig: function(a) {
- a.scaleMode && (this.scaleMode = a.scaleMode), a.fullScreenScaleMode && (this.fullScreenScaleMode = a.fullScreenScaleMode), a.fullScreenTarget && (this.fullScreenTarget = a.fullScreenTarget)
- },
- setupScale: function(a, c) {
- var d, e = new b.Rectangle;
- "" !== 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);
- var f = 0,
- g = 0;
- "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)
- },
- boot: function() {
- this.fullScreenTarget = this.game.canvas;
- var a = this;
- this._checkOrientation = function(b) {
- return a.checkOrientation(b)
- }, this._checkResize = function(b) {
- return a.checkResize(b)
- }, this._fullScreenChange = function(b) {
- return a.fullScreenChange(b)
- }, 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)
- },
- setResizeCallback: function(a, b) {
- this.onResize = a, this.onResizeContext = b
- },
- setMinMax: function(a, b, c, d) {
- this.minWidth = a, this.minHeight = b, "undefined" != typeof c && (this.maxWidth = c), "undefined" != typeof d && (this.maxHeight = d)
- },
- preUpdate: function() {
- 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)
- },
- updateDimensions: function(a, b, c) {
- 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)
- },
- forceOrientation: function(a, b) {
- "undefined" == typeof b && (b = !1), this.forceLandscape = a, this.forcePortrait = b
- },
- checkOrientationState: function() {
- 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())
- },
- checkOrientation: function(a) {
- 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()
- },
- checkResize: function(a) {
- this.event = a;
- var c = this.isLandscape;
- 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()
- },
- refresh: function() {
- 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)) {
- this._iterations = this.maxIterations;
- var a = this;
- this._check = window.setInterval(function() {
- return a.setScreenSize()
- }, 10), this.setScreenSize()
- }
- },
- setScreenSize: function(a) {
- 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))
- },
- setSize: function() {
- 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()
- },
- reset: function(a) {
- a && this.grid.reset()
- },
- setMaximum: function() {
- this.width = window.innerWidth, this.height = window.innerHeight
- },
- setShowAll: function() {
- var a = Math.min(window.innerHeight / this.game.height, window.innerWidth / this.game.width);
- this.width = Math.round(this.game.width * a), this.height = Math.round(this.game.height * a)
- },
- setExactFit: function() {
- var a = window.innerWidth,
- b = window.innerHeight;
- this.width = this.maxWidth && a > this.maxWidth ? this.maxWidth : a, this.height = this.maxHeight && b > this.maxHeight ? this.maxHeight : b
- },
- startFullScreen: function(a) {
- !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]())
- },
- stopFullScreen: function() {
- document[this.game.device.cancelFullscreen]()
- },
- fullScreenChange: function(a) {
- 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))
- },
- destroy: function() {
- 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))
- }
- }, b.ScaleManager.prototype.constructor = b.ScaleManager, Object.defineProperty(b.ScaleManager.prototype, "scaleMode", {
- get: function() {
- return this._scaleMode
- },
- set: function(a) {
- a !== this._scaleMode && (this._scaleMode = a)
- }
- }), Object.defineProperty(b.ScaleManager.prototype, "isFullScreen", {
- get: function() {
- return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement
- }
- }), Object.defineProperty(b.ScaleManager.prototype, "isPortrait", {
- get: function() {
- return 0 === this.orientation || 180 === this.orientation
- }
- }), Object.defineProperty(b.ScaleManager.prototype, "isLandscape", {
- get: function() {
- return 90 === this.orientation || -90 === this.orientation
- }
- }), b.Game = function(a, c, d, e, f, g, h, i) {
- 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 = {
- enableDebug: !0
- }, "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));
- var j = this;
- return this._onBoot = function() {
- return j.boot()
- }, "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
- }, b.Game.prototype = {
- parseConfig: function(a) {
- 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);
- var c = [(Date.now() * Math.random()).toString()];
- a.seed && (c = a.seed), this.rnd = new b.RandomDataGenerator(c);
- var d = null;
- a.state && (d = a.state), this.state = new b.StateManager(this, d)
- },
- boot: function() {
- 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))
- },
- showDebugHeader: function() {
- var a = b.VERSION,
- c = "Canvas",
- d = "HTML Audio",
- e = 1;
- if (this.renderType === b.WEBGL ? (c = "WebGL", e++) : this.renderType == b.HEADLESS && (c = "Headless"), this.device.webAudio && (d = "WebAudio", e++), this.device.chrome) {
- 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");
- console.log.apply(console, f)
- } else window.console && console.log("Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " | http://www.play68.com")
- },
- setUpRenderer: function() {
- 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) {
- if (!this.device.canvas) throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");
- this.renderType === b.AUTO && (this.renderType = b.CANVAS), this.renderer = new PIXI.CanvasRenderer(this.width, this.height, {
- view: this.canvas,
- transparent: this.transparent,
- resolution: 1,
- clearBeforeRender: !0
- }), this.context = this.renderer.context
- } else this.renderType = b.WEBGL, this.renderer = new PIXI.WebGLRenderer(this.width, this.height, {
- view: this.canvas,
- transparent: this.transparent,
- resolution: 1,
- antialias: this.antialias,
- preserveDrawingBuffer: this.preserveDrawingBuffer
- }), this.context = null;
- this.renderType !== b.HEADLESS && (this.stage.smoothed = this.antialias, b.Canvas.addToDOM(this.canvas, this.parent, !1), b.Canvas.setTouchAction(this.canvas))
- },
- update: function(a) {
- 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))
- },
- enableStep: function() {
- this.stepping = !0, this.pendingStep = !1, this.stepCount = 0
- },
- disableStep: function() {
- this.stepping = !1, this.pendingStep = !1
- },
- step: function() {
- this.pendingStep = !1, this.stepCount++
- },
- destroy: function() {
- 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)
- },
- gamePaused: function(a) {
- this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.setMute(), this.onPause.dispatch(a))
- },
- gameResumed: function(a) {
- this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.unsetMute(), this.onResume.dispatch(a))
- },
- focusLoss: function(a) {
- this.onBlur.dispatch(a), this.stage.disableVisibilityChange || this.gamePaused(a)
- },
- focusGain: function(a) {
- this.onFocus.dispatch(a), this.stage.disableVisibilityChange || this.gameResumed(a)
- }
- }, b.Game.prototype.constructor = b.Game, Object.defineProperty(b.Game.prototype, "paused", {
- get: function() {
- return this._paused
- },
- set: function(a) {
- 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)
- }
- }), b.Input = function(a) {
- 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
- }, b.Input.MOUSE_OVERRIDES_TOUCH = 0, b.Input.TOUCH_OVERRIDES_MOUSE = 1, b.Input.MOUSE_TOUCH_COMBINE = 2, b.Input.prototype = {
- boot: function() {
- 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
- },
- destroy: function() {
- this.mouse.stop(), this.keyboard.stop(), this.touch.stop(), this.mspointer.stop(), this.gamepad.stop(), this.moveCallbacks = []
- },
- addMoveCallback: function(a, b) {
- return this.moveCallbacks.push({
- callback: a,
- context: b
- }) - 1
- },
- deleteMoveCallback: function(a) {
- this.moveCallbacks[a] && this.moveCallbacks.splice(a, 1)
- },
- addPointer: function() {
- for (var a = 0, c = 10; c > 0; c--) null === this["pointer" + c] && (a = c);
- 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])
- },
- update: function() {
- 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))
- },
- reset: function(a) {
- if (this.game.isBooted && !this.resetLocked) {
- "undefined" == typeof a && (a = !1), this.keyboard.reset(a), this.mousePointer.reset(), this.gamepad.reset();
- for (var c = 1; 10 >= c; c++) this["pointer" + c] && this["pointer" + c].reset();
- 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
- }
- },
- resetSpeed: function(a, b) {
- this._oldPosition.setTo(a, b), this.speed.setTo(0, 0)
- },
- startPointer: function(a) {
- if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) return null;
- if (this.pointer1.active === !1) return this.pointer1.start(a);
- if (this.pointer2.active === !1) return this.pointer2.start(a);
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].active === !1) return this["pointer" + b].start(a);
- return null
- },
- updatePointer: function(a) {
- if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.move(a);
- if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.move(a);
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].move(a);
- return null
- },
- stopPointer: function(a) {
- if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.stop(a);
- if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.stop(a);
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].stop(a);
- return null
- },
- getPointer: function(a) {
- if (a = a || !1, this.pointer1.active == a) return this.pointer1;
- if (this.pointer2.active == a) return this.pointer2;
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].active == a) return this["pointer" + b];
- return null
- },
- getPointerFromIdentifier: function(a) {
- if (this.pointer1.identifier === a) return this.pointer1;
- if (this.pointer2.identifier === a) return this.pointer2;
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].identifier === a) return this["pointer" + b];
- return null
- },
- getPointerFromId: function(a) {
- if (this.pointer1.pointerId === a) return this.pointer1;
- if (this.pointer2.pointerId === a) return this.pointer2;
- for (var b = 3; 10 >= b; b++)
- if (this["pointer" + b] && this["pointer" + b].pointerId === a) return this["pointer" + b];
- return null
- },
- getLocalPosition: function(a, c, d) {
- "undefined" == typeof d && (d = new b.Point);
- var e = a.worldTransform,
- f = 1 / (e.a * e.d + e.c * -e.b);
- 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)
- },
- hitTest: function(a, c, d) {
- if (!a.worldVisible) return !1;
- 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);
- if (a instanceof PIXI.Sprite) {
- var e = a.texture.frame.width,
- f = a.texture.frame.height,
- g = -e * a.anchor.x;
- if (this._localPoint.x >= g && this._localPoint.x < g + e) {
- var h = -f * a.anchor.y;
- if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
- }
- } else if (a instanceof b.TileSprite) {
- var e = a.width,
- f = a.height,
- g = -e * a.anchor.x;
- if (this._localPoint.x >= g && this._localPoint.x < g + e) {
- var h = -f * a.anchor.y;
- if (this._localPoint.y >= h && this._localPoint.y < h + f) return !0
- }
- } else if (a instanceof b.Graphics)
- for (var i = 0; i < a.graphicsData.length; i++) {
- var j = a.graphicsData[i];
- if (j.fill && j.shape && j.shape.contains(this._localPoint.x, this._localPoint.y)) return !0
- }
- for (var i = 0, k = a.children.length; k > i; i++)
- if (this.hitTest(a.children[i], c, d)) return !0;
- return !1
- }
- }, b.Input.prototype.constructor = b.Input, Object.defineProperty(b.Input.prototype, "x", {
- get: function() {
- return this._x
- },
- set: function(a) {
- this._x = Math.floor(a)
- }
- }), Object.defineProperty(b.Input.prototype, "y", {
- get: function() {
- return this._y
- },
- set: function(a) {
- this._y = Math.floor(a)
- }
- }), Object.defineProperty(b.Input.prototype, "pollLocked", {
- get: function() {
- return this.pollRate > 0 && this._pollCounter < this.pollRate
- }
- }), Object.defineProperty(b.Input.prototype, "totalInactivePointers", {
- get: function() {
- return 10 - this.currentPointers
- }
- }), Object.defineProperty(b.Input.prototype, "totalActivePointers", {
- get: function() {
- this.currentPointers = 0;
- for (var a = 1; 10 >= a; a++) this["pointer" + a] && this["pointer" + a].active && this.currentPointers++;
- return this.currentPointers
- }
- }), Object.defineProperty(b.Input.prototype, "worldX", {
- get: function() {
- return this.game.camera.view.x + this.x
- }
- }), Object.defineProperty(b.Input.prototype, "worldY", {
- get: function() {
- return this.game.camera.view.y + this.y
- }
- }), b.Key = function(a, c) {
- 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
- }, b.Key.prototype = {
- update: function() {
- this.enabled && this.isDown && (this.duration = this.game.time.now - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this))
- },
- processKeyDown: function(a) {
- 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)))
- },
- processKeyUp: function(a) {
- 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)))
- },
- reset: function(a) {
- "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)
- },
- justPressed: function(a) {
- return "undefined" == typeof a && (a = 50), this.isDown && this.duration < a
- },
- justReleased: function(a) {
- return "undefined" == typeof a && (a = 50), !this.isDown && this.game.time.now - this.timeUp < a
- }
- }, b.Key.prototype.constructor = b.Key, b.Keyboard = function(a) {
- 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
- }, b.Keyboard.prototype = {
- addCallbacks: function(a, b, c, d) {
- this.callbackContext = a, "undefined" != typeof b && (this.onDownCallback = b), "undefined" != typeof c && (this.onUpCallback = c), "undefined" != typeof d && (this.onPressCallback = d)
- },
- addKey: function(a) {
- return this._keys[a] || (this._keys[a] = new b.Key(this.game, a), this.addKeyCapture(a)), this._keys[a]
- },
- removeKey: function(a) {
- this._keys[a] && (this._keys[a] = null, this.removeKeyCapture(a))
- },
- createCursorKeys: function() {
- return {
- up: this.addKey(b.Keyboard.UP),
- down: this.addKey(b.Keyboard.DOWN),
- left: this.addKey(b.Keyboard.LEFT),
- right: this.addKey(b.Keyboard.RIGHT)
- }
- },
- start: function() {
- if (!this.game.device.cocoonJS && null === this._onKeyDown) {
- var a = this;
- this._onKeyDown = function(b) {
- return a.processKeyDown(b)
- }, this._onKeyUp = function(b) {
- return a.processKeyUp(b)
- }, this._onKeyPress = function(b) {
- return a.processKeyPress(b)
- }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
- }
- },
- stop: function() {
- window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null
- },
- destroy: function() {
- this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0
- },
- addKeyCapture: function(a) {
- if ("object" == typeof a)
- for (var b in a) this._capture[a[b]] = !0;
- else this._capture[a] = !0
- },
- removeKeyCapture: function(a) {
- delete this._capture[a]
- },
- clearCaptures: function() {
- this._capture = {}
- },
- update: function() {
- for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update()
- },
- processKeyDown: function(a) {
- 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))
- },
- processKeyPress: function(a) {
- this.pressEvent = a, this.game.input.disabled || this.disabled || this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(a.charCode), a)
- },
- processKeyUp: function(a) {
- 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))
- },
- reset: function(a) {
- "undefined" == typeof a && (a = !0), this.event = null;
- for (var b = this._keys.length; b--;) this._keys[b] && this._keys[b].reset(a)
- },
- justPressed: function(a, b) {
- return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justPressed(b) : !1
- },
- justReleased: function(a, b) {
- return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justReleased(b) : !1
- },
- isDown: function(a) {
- return this._keys[a] ? this._keys[a].isDown : !1
- }
- }, Object.defineProperty(b.Keyboard.prototype, "lastChar", {
- get: function() {
- return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode)
- }
- }), Object.defineProperty(b.Keyboard.prototype, "lastKey", {
- get: function() {
- return this._keys[this._k]
- }
- }), 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) {
- 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
- }, 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 = {
- start: function() {
- if ((!this.game.device.android || this.game.device.chrome !== !1) && null === this._onMouseDown) {
- var a = this;
- this._onMouseDown = function(b) {
- return a.onMouseDown(b)
- }, this._onMouseMove = function(b) {
- return a.onMouseMove(b)
- }, this._onMouseUp = function(b) {
- return a.onMouseUp(b)
- }, this._onMouseUpGlobal = function(b) {
- return a.onMouseUpGlobal(b)
- }, this._onMouseOut = function(b) {
- return a.onMouseOut(b)
- }, this._onMouseOver = function(b) {
- return a.onMouseOver(b)
- }, this._onMouseWheel = function(b) {
- return a.onMouseWheel(b)
- }, 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))
- }
- },
- onMouseDown: function(a) {
- 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))
- },
- onMouseMove: function(a) {
- 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))
- },
- onMouseUp: function(a) {
- 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))
- },
- onMouseUpGlobal: function(a) {
- 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))
- },
- onMouseOut: function(a) {
- 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))
- },
- onMouseWheel: function(a) {
- 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)
- },
- onMouseOver: function(a) {
- 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
- },
- requestPointerLock: function() {
- if (this.game.device.pointerLock) {
- var a = this.game.canvas;
- a.requestPointerLock = a.requestPointerLock || a.mozRequestPointerLock || a.webkitRequestPointerLock, a.requestPointerLock();
- var b = this;
- this._pointerLockChange = function(a) {
- return b.pointerLockChange(a)
- }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
- }
- },
- pointerLockChange: function(a) {
- var b = this.game.canvas;
- 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))
- },
- releasePointerLock: function() {
- 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)
- },
- stop: function() {
- 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)
- }
- }, b.Mouse.prototype.constructor = b.Mouse, b.MSPointer = function(a) {
- this.game = a, this.callbackContext = this.game, this.disabled = !1, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null
- }, b.MSPointer.prototype = {
- start: function() {
- if (null === this._onMSPointerDown) {
- var a = this;
- this.game.device.mspointer && (this._onMSPointerDown = function(b) {
- return a.onPointerDown(b)
- }, this._onMSPointerMove = function(b) {
- return a.onPointerMove(b)
- }, this._onMSPointerUp = function(b) {
- return a.onPointerUp(b)
- }, 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")
- }
- },
- onPointerDown: function(a) {
- this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.startPointer(a))
- },
- onPointerMove: function(a) {
- this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.updatePointer(a))
- },
- onPointerUp: function(a) {
- this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.stopPointer(a))
- },
- stop: function() {
- 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)
- }
- }, b.MSPointer.prototype.constructor = b.MSPointer, b.Pointer = function(a, c) {
- 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)
- }, b.Pointer.prototype = {
- start: function(a) {
- 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
- },
- update: function() {
- 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({
- x: this.position.x,
- y: this.position.y
- }), this._history.length > this.game.input.recordLimit && this._history.shift()))
- },
- move: function(a, c) {
- if (!this.game.input.pollLocked) {
- 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;
- 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);
- 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
- }
- },
- processInteractiveObjects: function(a) {
- this.game.input.interactiveItems.setAll("checked", !1), this._highestRenderOrderID = Number.MAX_SAFE_INTEGER, this._highestRenderObject = null, this._highestInputPriorityID = -1;
- var b = this.game.input.interactiveItems.first;
- 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);
- var b = this.game.input.interactiveItems.first;
- 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);
- 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
- },
- leave: function(a) {
- this.withinGame = !1, this.move(a, !1)
- },
- stop: function(a) {
- 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)
- },
- justPressed: function(a) {
- return a = a || this.game.input.justPressedRate, this.isDown === !0 && this.timeDown + a > this.game.time.now
- },
- justReleased: function(a) {
- return a = a || this.game.input.justReleasedRate, this.isUp === !0 && this.timeUp + a > this.game.time.now
- },
- reset: function() {
- 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
- },
- resetMovement: function() {
- this.movementX = 0, this.movementY = 0
- }
- }, b.Pointer.prototype.constructor = b.Pointer, Object.defineProperty(b.Pointer.prototype, "duration", {
- get: function() {
- return this.isUp ? -1 : this.game.time.now - this.timeDown
- }
- }), Object.defineProperty(b.Pointer.prototype, "worldX", {
- get: function() {
- return this.game.world.camera.x + this.x
- }
- }), Object.defineProperty(b.Pointer.prototype, "worldY", {
- get: function() {
- return this.game.world.camera.y + this.y
- }
- }), b.Touch = function(a) {
- 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
- }, b.Touch.prototype = {
- start: function() {
- if (null === this._onTouchStart) {
- var a = this;
- this.game.device.touch && (this._onTouchStart = function(b) {
- return a.onTouchStart(b)
- }, this._onTouchMove = function(b) {
- return a.onTouchMove(b)
- }, this._onTouchEnd = function(b) {
- return a.onTouchEnd(b)
- }, this._onTouchEnter = function(b) {
- return a.onTouchEnter(b)
- }, this._onTouchLeave = function(b) {
- return a.onTouchLeave(b)
- }, this._onTouchCancel = function(b) {
- return a.onTouchCancel(b)
- }, 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)))
- }
- },
- consumeDocumentTouches: function() {
- this._documentTouchMove = function(a) {
- a.preventDefault()
- }, document.addEventListener("touchmove", this._documentTouchMove, !1)
- },
- onTouchStart: function(a) {
- if (this.event = a, this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
- this.preventDefault && a.preventDefault();
- for (var b = 0; b < a.changedTouches.length; b++) this.game.input.startPointer(a.changedTouches[b])
- }
- },
- onTouchCancel: function(a) {
- if (this.event = a, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
- this.preventDefault && a.preventDefault();
- for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
- }
- },
- onTouchEnter: function(a) {
- this.event = a, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || this.preventDefault && a.preventDefault()
- },
- onTouchLeave: function(a) {
- this.event = a, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault()
- },
- onTouchMove: function(a) {
- this.event = a, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
- for (var b = 0; b < a.changedTouches.length; b++) this.game.input.updatePointer(a.changedTouches[b])
- },
- onTouchEnd: function(a) {
- this.event = a, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
- for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
- },
- stop: function() {
- 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))
- }
- }, b.Touch.prototype.constructor = b.Touch, b.Gamepad = function(a) {
- 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)]
- }, b.Gamepad.prototype = {
- addCallbacks: function(a, b) {
- "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)
- },
- start: function() {
- if (!this._active) {
- this._active = !0;
- var a = this;
- this._onGamepadConnected = function(b) {
- return a.onGamepadConnected(b)
- }, this._onGamepadDisconnected = function(b) {
- return a.onGamepadDisconnected(b)
- }, window.addEventListener("gamepadconnected", this._onGamepadConnected, !1), window.addEventListener("gamepaddisconnected", this._onGamepadDisconnected, !1)
- }
- },
- onGamepadConnected: function(a) {
- var b = a.gamepad;
- this._rawPads.push(b), this._gamepads[b.index].connect(b)
- },
- onGamepadDisconnected: function(a) {
- var b = a.gamepad;
- for (var c in this._rawPads) this._rawPads[c].index === b.index && this._rawPads.splice(c, 1);
- this._gamepads[b.index].disconnect()
- },
- update: function() {
- this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus()
- },
- _pollGamepads: function() {
- if (navigator.getGamepads) var a = navigator.getGamepads();
- else if (navigator.webkitGetGamepads) var a = navigator.webkitGetGamepads();
- else if (navigator.webkitGamepads) var a = navigator.webkitGamepads();
- if (a) {
- this._rawPads = [];
- 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++);
- if (b) {
- for (var d, e = {
- rawIndices: {},
- padIndices: {}
- }, f = 0; f < this._gamepads.length; f++)
- if (d = this._gamepads[f], d.connected)
- for (var g = 0; g < this._rawPads.length; g++) this._rawPads[g].index === d.index && (e.rawIndices[d.index] = !0, e.padIndices[f] = !0);
- for (var h = 0; h < this._gamepads.length; h++)
- if (d = this._gamepads[h], !e.padIndices[h]) {
- this._rawPads.length < 1 && d.disconnect();
- for (var i = 0; i < this._rawPads.length && !e.padIndices[h]; i++) {
- var j = this._rawPads[i];
- if (j) {
- if (e.rawIndices[j.index]) {
- d.disconnect();
- continue
- }
- d.connect(j), e.rawIndices[j.index] = !0, e.padIndices[h] = !0
- } else d.disconnect()
- }
- }
- }
- }
- },
- setDeadZones: function(a) {
- for (var b = 0; b < this._gamepads.length; b++) this._gamepads[b].deadZone = a
- },
- stop: function() {
- this._active = !1, window.removeEventListener("gamepadconnected", this._onGamepadConnected), window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnected)
- },
- reset: function() {
- this.update();
- for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].reset()
- },
- justPressed: function(a, b) {
- for (var c = 0; c < this._gamepads.length; c++)
- if (this._gamepads[c].justPressed(a, b) === !0) return !0;
- return !1
- },
- justReleased: function(a, b) {
- for (var c = 0; c < this._gamepads.length; c++)
- if (this._gamepads[c].justReleased(a, b) === !0) return !0;
- return !1
- },
- isDown: function(a) {
- for (var b = 0; b < this._gamepads.length; b++)
- if (this._gamepads[b].isDown(a) === !0) return !0;
- return !1
- },
- destroy: function() {
- this.stop();
- for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].destroy()
- }
- }, b.Gamepad.prototype.constructor = b.Gamepad, Object.defineProperty(b.Gamepad.prototype, "active", {
- get: function() {
- return this._active
- }
- }), Object.defineProperty(b.Gamepad.prototype, "supported", {
- get: function() {
- return this._gamepadSupportAvailable
- }
- }), Object.defineProperty(b.Gamepad.prototype, "padsConnected", {
- get: function() {
- return this._rawPads.length
- }
- }), Object.defineProperty(b.Gamepad.prototype, "pad1", {
- get: function() {
- return this._gamepads[0]
- }
- }), Object.defineProperty(b.Gamepad.prototype, "pad2", {
- get: function() {
- return this._gamepads[1]
- }
- }), Object.defineProperty(b.Gamepad.prototype, "pad3", {
- get: function() {
- return this._gamepads[2]
- }
- }), Object.defineProperty(b.Gamepad.prototype, "pad4", {
- get: function() {
- return this._gamepads[3]
- }
- }), 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) {
- 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
- }, b.SinglePad.prototype = {
- addCallbacks: function(a, b) {
- "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)
- },
- getButton: function(a) {
- return this._buttons[a] ? this._buttons[a] : null
- },
- pollStatus: function() {
- if (!(!this.connected || this.game.input.disabled || this.game.input.gamepad.disabled || this._rawPad.timestamp && this._rawPad.timestamp === this._prevTimestamp)) {
- for (var a = 0; a < this._buttonsLen; a++) {
- var b = isNaN(this._rawPad.buttons[a]) ? this._rawPad.buttons[a].value : this._rawPad.buttons[a];
- b !== this._buttons[a].value && (1 === b ? this.processButtonDown(a, b) : 0 === b ? this.processButtonUp(a, b) : this.processButtonFloat(a, b))
- }
- for (var c = 0; c < this._axesLen; c++) {
- var d = this._rawPad.axes[c];
- d > 0 && d > this.deadZone || 0 > d && d < -this.deadZone ? this.processAxisChange(c, d) : this.processAxisChange(c, 0)
- }
- this._prevTimestamp = this._rawPad.timestamp
- }
- },
- connect: function(a) {
- var c = !this.connected;
- this.connected = !0, this.index = a.index, this._rawPad = a, this._buttons = [], this._buttonsLen = a.buttons.length, this._axes = [], this._axesLen = a.axes.length;
- for (var d = 0; d < this._axesLen; d++) this._axes[d] = a.axes[d];
- for (var e in a.buttons) e = parseInt(e, 10), this._buttons[e] = new b.GamepadButton(this, e);
- c && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), c && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
- },
- disconnect: function() {
- var a = this.connected,
- b = this.index;
- this.connected = !1, this.index = null, this._rawPad = void 0;
- for (var c = 0; c < this._buttonsLen; c++) this._buttons[c].destroy();
- 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)
- },
- destroy: function() {
- this._rawPad = void 0;
- for (var a = 0; a < this._buttonsLen; a++) this._buttons[a].destroy();
- 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
- },
- processAxisChange: function(a, b) {
- 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))
- },
- processButtonDown: function(a, b) {
- 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)
- },
- processButtonUp: function(a, b) {
- 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)
- },
- processButtonFloat: function(a, b) {
- 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)
- },
- axis: function(a) {
- return this._axes[a] ? this._axes[a] : !1
- },
- isDown: function(a) {
- return this._buttons[a] ? this._buttons[a].isDown : !1
- },
- isUp: function(a) {
- return this._buttons[a] ? this._buttons[a].isUp : !1
- },
- justReleased: function(a, b) {
- return this._buttons[a] ? this._buttons[a].justReleased(b) : void 0
- },
- justPressed: function(a, b) {
- return this._buttons[a] ? this._buttons[a].justPressed(b) : void 0
- },
- buttonValue: function(a) {
- return this._buttons[a] ? this._buttons[a].value : null
- },
- reset: function() {
- for (var a = 0; a < this._axes.length; a++) this._axes[a] = 0
- }
- }, b.SinglePad.prototype.constructor = b.SinglePad, b.GamepadButton = function(a, c) {
- 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
- }, b.GamepadButton.prototype = {
- processButtonDown: function(a) {
- 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)
- },
- processButtonUp: function(a) {
- this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.value = a, this.onUp.dispatch(this, a)
- },
- processButtonFloat: function(a) {
- this.value = a, this.onFloat.dispatch(this, a)
- },
- justPressed: function(a) {
- return a = a || 250, this.isDown === !0 && this.timeDown + a > this.game.time.now
- },
- justReleased: function(a) {
- return a = a || 250, this.isUp === !0 && this.timeUp + a > this.game.time.now
- },
- reset: function() {
- this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0
- },
- destroy: function() {
- this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.pad = null, this.game = null
- }
- }, b.GamepadButton.prototype.constructor = b.GamepadButton, b.InputHandler = function(a) {
- 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({
- id: 0,
- x: 0,
- y: 0,
- isDown: !1,
- isUp: !1,
- isOver: !1,
- isOut: !1,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: !1
- })
- }, b.InputHandler.prototype = {
- start: function(a, c) {
- if (a = a || 0, "undefined" == typeof c && (c = !1), this.enabled === !1) {
- this.game.input.interactiveItems.add(this), this.useHandCursor = c, this.priorityID = a;
- for (var d = 0; 10 > d; d++) this._pointerData[d] = {
- id: d,
- x: 0,
- y: 0,
- isDown: !1,
- isUp: !1,
- isOver: !1,
- isOut: !1,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: !1
- };
- 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)
- }
- return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.flagged = !1, this.sprite
- },
- addedToGroup: function() {
- this._dragPhase || this._wasEnabled && !this.enabled && this.start()
- },
- removedFromGroup: function() {
- this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1)
- },
- reset: function() {
- this.enabled = !1, this.flagged = !1;
- for (var a = 0; 10 > a; a++) this._pointerData[a] = {
- id: a,
- x: 0,
- y: 0,
- isDown: !1,
- isUp: !1,
- isOver: !1,
- isOut: !1,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: !1
- }
- },
- stop: function() {
- this.enabled !== !1 && (this.enabled = !1, this.game.input.interactiveItems.remove(this))
- },
- destroy: function() {
- 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)
- },
- validForInput: function(a, b, c) {
- 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
- },
- isPixelPerfect: function() {
- return this.pixelPerfectClick || this.pixelPerfectOver
- },
- pointerX: function(a) {
- return a = a || 0, this._pointerData[a].x
- },
- pointerY: function(a) {
- return a = a || 0, this._pointerData[a].y
- },
- pointerDown: function(a) {
- return a = a || 0, this._pointerData[a].isDown
- },
- pointerUp: function(a) {
- return a = a || 0, this._pointerData[a].isUp
- },
- pointerTimeDown: function(a) {
- return a = a || 0, this._pointerData[a].timeDown
- },
- pointerTimeUp: function(a) {
- return a = a || 0, this._pointerData[a].timeUp
- },
- pointerOver: function(a) {
- if (this.enabled) {
- if ("undefined" != typeof a) return this._pointerData[a].isOver;
- for (var b = 0; 10 > b; b++)
- if (this._pointerData[b].isOver) return !0
- }
- return !1
- },
- pointerOut: function(a) {
- if (this.enabled) {
- if ("undefined" != typeof a) return this._pointerData[a].isOut;
- for (var b = 0; 10 > b; b++)
- if (this._pointerData[b].isOut) return !0
- }
- return !1
- },
- pointerTimeOver: function(a) {
- return a = a || 0, this._pointerData[a].timeOver
- },
- pointerTimeOut: function(a) {
- return a = a || 0, this._pointerData[a].timeOut
- },
- pointerDragged: function(a) {
- return a = a || 0, this._pointerData[a].isDragged
- },
- checkPointerDown: function(a, b) {
- 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
- },
- checkPointerOver: function(a, b) {
- 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
- },
- checkPixel: function(a, b, c) {
- if (this.sprite.texture.baseTexture.source) {
- if (null === a && null === b) {
- this.game.input.getLocalPosition(this.sprite, c, this._tempPoint);
- var a = this._tempPoint.x,
- b = this._tempPoint.y
- }
- 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;
- 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);
- var d = this.game.input.hitContext.getImageData(0, 0, 1, 1);
- if (d.data[3] >= this.pixelPerfectAlpha) return !0
- }
- return !1
- },
- update: function(a) {
- 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
- },
- _pointerOverHandler: function(a) {
- 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))
- },
- _pointerOutHandler: function(a) {
- 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))
- },
- _touchedHandler: function(a) {
- if (null !== this.sprite) {
- if (this._pointerData[a.id].isDown === !1 && this._pointerData[a.id].isOver === !0) {
- if (this.pixelPerfectClick && !this.checkPixel(null, null, a)) return;
- 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()
- }
- return this.consumePointerEvent
- }
- },
- _releasedHandler: function(a) {
- 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))
- },
- updateDrag: function(a) {
- if (a.isUp) return this.stopDrag(a), !1;
- var b = this.globalToLocalX(a.x) + this._dragPoint.x + this.dragOffset.x,
- c = this.globalToLocalY(a.y) + this._dragPoint.y + this.dragOffset.y;
- 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
- },
- justOver: function(a, b) {
- return a = a || 0, b = b || 500, this._pointerData[a].isOver && this.overDuration(a) < b
- },
- justOut: function(a, b) {
- return a = a || 0, b = b || 500, this._pointerData[a].isOut && this.game.time.now - this._pointerData[a].timeOut < b
- },
- justPressed: function(a, b) {
- return a = a || 0, b = b || 500, this._pointerData[a].isDown && this.downDuration(a) < b
- },
- justReleased: function(a, b) {
- return a = a || 0, b = b || 500, this._pointerData[a].isUp && this.game.time.now - this._pointerData[a].timeUp < b
- },
- overDuration: function(a) {
- return a = a || 0, this._pointerData[a].isOver ? this.game.time.now - this._pointerData[a].timeOver : -1
- },
- downDuration: function(a) {
- return a = a || 0, this._pointerData[a].isDown ? this.game.time.now - this._pointerData[a].timeDown : -1
- },
- enableDrag: function(a, c, d, e, f, g) {
- "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)
- },
- disableDrag: function() {
- if (this._pointerData)
- for (var a = 0; 10 > a; a++) this._pointerData[a].isDragged = !1;
- this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1
- },
- startDrag: function(a) {
- 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);
- else {
- if (this.dragFromCenter) {
- var b = this.sprite.getBounds();
- this.sprite.x = this.globalToLocalX(a.x) + (this.sprite.x - b.centerX), this.sprite.y = this.globalToLocalY(a.y) + (this.sprite.y - b.centerY)
- }
- this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(a.x), this.sprite.y - this.globalToLocalY(a.y))
- }
- this.updateDrag(a), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.sprite.events.onDragStart.dispatch(this.sprite, a)
- },
- globalToLocalX: function(a) {
- return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.x, a *= this.game.scale.grid.scaleFluidInversed.x), a
- },
- globalToLocalY: function(a) {
- return this.scaleLayer && (a -= this.game.scale.grid.boundsFluid.y, a *= this.game.scale.grid.scaleFluidInversed.y), a
- },
- stopDrag: function(a) {
- 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)
- },
- setDragLock: function(a, b) {
- "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), this.allowHorizontalDrag = a, this.allowVerticalDrag = b
- },
- enableSnap: function(a, b, c, d, e, f) {
- "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
- },
- disableSnap: function() {
- this.snapOnDrag = !1, this.snapOnRelease = !1
- },
- checkBoundsRect: function() {
- 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))
- },
- checkBoundsSprite: function() {
- 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))
- }
- }, b.InputHandler.prototype.constructor = b.InputHandler, b.Events = function(a) {
- 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
- }, b.Events.prototype = {
- destroy: function() {
- 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())
- }
- }, b.Events.prototype.constructor = b.Events, b.GameObjectFactory = function(a) {
- this.game = a, this.world = this.game.world
- }, b.GameObjectFactory.prototype = {
- existing: function(a) {
- return this.world.add(a)
- },
- image: function(a, c, d, e, f) {
- return "undefined" == typeof f && (f = this.world), f.add(new b.Image(this.game, a, c, d, e))
- },
- sprite: function(a, b, c, d, e) {
- return "undefined" == typeof e && (e = this.world), e.create(a, b, c, d)
- },
- tween: function(a) {
- return this.game.tweens.create(a)
- },
- group: function(a, c, d, e, f) {
- return new b.Group(this.game, a, c, d, e, f)
- },
- physicsGroup: function(a, c, d, e) {
- return new b.Group(this.game, c, d, e, !0, a)
- },
- spriteBatch: function(a, c, d) {
- return "undefined" == typeof a && (a = null), "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
- },
- audio: function(a, b, c, d) {
- return this.game.sound.add(a, b, c, d)
- },
- sound: function(a, b, c, d) {
- return this.game.sound.add(a, b, c, d)
- },
- audioSprite: function(a) {
- return this.game.sound.addSprite(a)
- },
- tileSprite: function(a, c, d, e, f, g, h) {
- return "undefined" == typeof h && (h = this.world), h.add(new b.TileSprite(this.game, a, c, d, e, f, g))
- },
- rope: function(a, c, d, e, f, g) {
- return "undefined" == typeof g && (g = this.world), g.add(new b.Rope(this.game, a, c, d, e, f))
- },
- text: function(a, c, d, e, f) {
- return "undefined" == typeof f && (f = this.world), f.add(new b.Text(this.game, a, c, d, e))
- },
- button: function(a, c, d, e, f, g, h, i, j, k) {
- return "undefined" == typeof k && (k = this.world), k.add(new b.Button(this.game, a, c, d, e, f, g, h, i, j))
- },
- graphics: function(a, c, d) {
- return "undefined" == typeof d && (d = this.world), d.add(new b.Graphics(this.game, a, c))
- },
- emitter: function(a, c, d) {
- return this.game.particles.add(new b.Particles.Arcade.Emitter(this.game, a, c, d))
- },
- retroFont: function(a, c, d, e, f, g, h, i, j) {
- return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
- },
- bitmapText: function(a, c, d, e, f, g) {
- return "undefined" == typeof g && (g = this.world), g.add(new b.BitmapText(this.game, a, c, d, e, f))
- },
- tilemap: function(a, c, d, e, f) {
- return new b.Tilemap(this.game, a, c, d, e, f)
- },
- renderTexture: function(a, c, d, e) {
- ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
- var f = new b.RenderTexture(this.game, a, c, d);
- return e && this.game.cache.addRenderTexture(d, f), f
- },
- bitmapData: function(a, c, d, e) {
- "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
- var f = new b.BitmapData(this.game, d, a, c);
- return e && this.game.cache.addBitmapData(d, f), f
- },
- filter: function(a) {
- var c = Array.prototype.splice.call(arguments, 1),
- a = new b.Filter[a](this.game);
- return a.init.apply(a, c), a
- },
- plugin: function(a) {
- return this.game.plugins.add(a)
- }
- }, b.GameObjectFactory.prototype.constructor = b.GameObjectFactory, b.GameObjectCreator = function(a) {
- this.game = a, this.world = this.game.world
- }, b.GameObjectCreator.prototype = {
- image: function(a, c, d, e) {
- return new b.Image(this.game, a, c, d, e)
- },
- sprite: function(a, c, d, e) {
- return new b.Sprite(this.game, a, c, d, e)
- },
- tween: function(a) {
- return new b.Tween(a, this.game)
- },
- group: function(a, c, d, e, f) {
- return new b.Group(this.game, null, c, d, e, f)
- },
- spriteBatch: function(a, c, d) {
- return "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
- },
- audio: function(a, b, c, d) {
- return this.game.sound.add(a, b, c, d)
- },
- audioSprite: function(a) {
- return this.game.sound.addSprite(a)
- },
- sound: function(a, b, c, d) {
- return this.game.sound.add(a, b, c, d)
- },
- tileSprite: function(a, c, d, e, f, g) {
- return new b.TileSprite(this.game, a, c, d, e, f, g)
- },
- rope: function(a, c, d, e, f) {
- return new b.Rope(this.game, a, c, d, e, f)
- },
- text: function(a, c, d, e) {
- return new b.Text(this.game, a, c, d, e)
- },
- button: function(a, c, d, e, f, g, h, i, j) {
- return new b.Button(this.game, a, c, d, e, f, g, h, i, j)
- },
- graphics: function(a, c) {
- return new b.Graphics(this.game, a, c)
- },
- emitter: function(a, c, d) {
- return new b.Particles.Arcade.Emitter(this.game, a, c, d)
- },
- retroFont: function(a, c, d, e, f, g, h, i, j) {
- return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
- },
- bitmapText: function(a, c, d, e, f) {
- return new b.BitmapText(this.game, a, c, d, e, f)
- },
- tilemap: function(a, c, d, e, f) {
- return new b.Tilemap(this.game, a, c, d, e, f)
- },
- renderTexture: function(a, c, d, e) {
- ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
- var f = new b.RenderTexture(this.game, a, c, d);
- return e && this.game.cache.addRenderTexture(d, f), f
- },
- bitmapData: function(a, c, d, e) {
- "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
- var f = new b.BitmapData(this.game, d, a, c);
- return e && this.game.cache.addBitmapData(d, f), f
- },
- filter: function(a) {
- var c = Array.prototype.splice.call(arguments, 1),
- a = new b.Filter[a](this.game);
- return a.init.apply(a, c), a
- }
- }, b.GameObjectCreator.prototype.constructor = b.GameObjectCreator, b.BitmapData = function(a, c, d, e) {
- "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 = {
- prev: 1,
- current: 1
- }, this._anchor = new b.Point, this._tempR = 0, this._tempG = 0, this._tempB = 0, this._circle = new b.Circle
- }, b.BitmapData.prototype = {
- add: function(a) {
- if (Array.isArray(a))
- for (var b = 0; b < a.length; b++) a[b].loadTexture && a[b].loadTexture(this);
- else a.loadTexture(this);
- return this
- },
- load: function(a) {
- 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
- },
- clear: function() {
- return this.context.clearRect(0, 0, this.width, this.height), this.dirty = !0, this
- },
- fill: function(a, b, c, d) {
- 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
- },
- resize: function(a, b) {
- 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
- },
- update: function(a, b, c, d) {
- 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
- },
- processPixelRGB: function(a, c, d, e, f, g) {
- "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = this.width), "undefined" == typeof g && (g = this.height);
- for (var h = d + f, i = e + g, j = b.Color.createColor(), k = {
- r: 0,
- g: 0,
- b: 0,
- a: 0
- }, l = !1, m = e; i > m; m++)
- 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);
- return l && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
- },
- processPixel: function(a, b, c, d, e, f) {
- "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = this.width), "undefined" == typeof f && (f = this.height);
- for (var g = c + e, h = d + f, i = 0, j = 0, k = !1, l = d; h > l; l++)
- 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);
- return k && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
- },
- replaceRGB: function(a, c, d, e, f, g, h, i, j) {
- var k = 0,
- l = 0,
- m = this.width,
- n = this.height,
- o = b.Color.packPixel(a, c, d, e);
- void 0 !== j && j instanceof b.Rectangle && (k = j.x, l = j.y, m = j.width, n = j.height);
- for (var p = 0; n > p; p++)
- 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);
- return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
- },
- setHSL: function(a, c, d, e) {
- 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) {
- "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
- for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
- 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);
- return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
- }
- },
- shiftHSL: function(a, c, d, e) {
- 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) {
- "undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height));
- for (var f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
- 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);
- return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
- }
- },
- setPixel32: function(a, c, d, e, f, g, h) {
- 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
- },
- setPixel: function(a, b, c, d, e, f) {
- return this.setPixel32(a, b, c, d, e, 255, f)
- },
- getPixel: function(a, c, d) {
- d || (d = b.Color.createColor());
- var e = ~~(a + c * this.width);
- return e *= 4, d.r = this.data[e], d.g = this.data[++e], d.b = this.data[++e], d.a = this.data[++e], d
- },
- getPixel32: function(a, b) {
- return a >= 0 && a <= this.width && b >= 0 && b <= this.height ? this.pixels[b * this.width + a] : void 0
- },
- getPixelRGB: function(a, c, d, e, f) {
- return b.Color.unpackPixel(this.getPixel32(a, c), d, e, f)
- },
- getPixels: function(a) {
- return this.context.getImageData(a.x, a.y, a.width, a.height)
- },
- getFirstPixel: function(a) {
- "undefined" == typeof a && (a = 0);
- var c = b.Color.createColor(),
- d = 0,
- e = 0,
- f = 1,
- g = !1;
- 1 === a ? (f = -1, e = this.height) : 3 === a && (f = -1, d = this.width);
- 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);
- return c.x = d, c.y = e, c
- },
- getBounds: function(a) {
- 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)
- },
- addToWorld: function(a, b, c, d, e, f) {
- e = e || 1, f = f || 1;
- var g = this.game.add.image(a, b, this);
- return g.anchor.set(c, d), g.scale.set(e, f), g
- },
- copy: function(a, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) {
- 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);
- else {
- 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;
- else if ("string" == typeof a) {
- if (a = this.game.cache.getImage(a), null === a) return;
- this._image = a
- }
- this._size.set(this._image.width, this._image.height)
- }
- 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)
- },
- copyRect: function(a, b, c, d, e, f, g) {
- 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)
- },
- draw: function(a, b, c, d, e, f, g) {
- return this.copy(a, null, null, null, null, b, c, d, e, null, null, null, null, null, null, f, g)
- },
- shadow: function(a, b, c, d) {
- "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)
- },
- alphaMask: function(a, b, c, d) {
- 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
- },
- extract: function(a, b, c, d, e, f, g, h, i) {
- 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) {
- return f.r === b && f.g === c && f.b === d && a.setPixel32(j, k, g, h, i, e, !1), !1
- }, this), a.context.putImageData(a.imageData, 0, 0), a.dirty = !0, a
- },
- rect: function(a, b, c, d, e) {
- return "undefined" != typeof e && (this.context.fillStyle = e), this.context.fillRect(a, b, c, d), this
- },
- circle: function(a, b, c, d) {
- 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
- },
- textureLine: function(a, c, d) {
- if ("undefined" == typeof d && (d = "repeat-x"), "string" != typeof c || (c = this.game.cache.getImage(c))) {
- var e = a.length;
- 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
- }
- },
- render: function() {
- return !this.disableTextureUpload && this.dirty && (this.baseTexture.dirty(), this.dirty = !1), this
- },
- blendReset: function() {
- return this.context.globalCompositeOperation = "source-over", this
- },
- blendSourceOver: function() {
- return this.context.globalCompositeOperation = "source-over", this
- },
- blendSourceIn: function() {
- return this.context.globalCompositeOperation = "source-in", this
- },
- blendSourceOut: function() {
- return this.context.globalCompositeOperation = "source-out", this
- },
- blendSourceAtop: function() {
- return this.context.globalCompositeOperation = "source-atop", this
- },
- blendDestinationOver: function() {
- return this.context.globalCompositeOperation = "destination-over", this
- },
- blendDestinationIn: function() {
- return this.context.globalCompositeOperation = "destination-in", this
- },
- blendDestinationOut: function() {
- return this.context.globalCompositeOperation = "destination-out", this
- },
- blendDestinationAtop: function() {
- return this.context.globalCompositeOperation = "destination-atop", this
- },
- blendXor: function() {
- return this.context.globalCompositeOperation = "xor", this
- },
- blendAdd: function() {
- return this.context.globalCompositeOperation = "lighter", this
- },
- blendMultiply: function() {
- return this.context.globalCompositeOperation = "multiply", this
- },
- blendScreen: function() {
- return this.context.globalCompositeOperation = "screen", this
- },
- blendOverlay: function() {
- return this.context.globalCompositeOperation = "overlay", this
- },
- blendDarken: function() {
- return this.context.globalCompositeOperation = "darken", this
- },
- blendLighten: function() {
- return this.context.globalCompositeOperation = "lighten", this
- },
- blendColorDodge: function() {
- return this.context.globalCompositeOperation = "color-dodge", this
- },
- blendColorBurn: function() {
- return this.context.globalCompositeOperation = "color-burn", this
- },
- blendHardLight: function() {
- return this.context.globalCompositeOperation = "hard-light", this
- },
- blendSoftLight: function() {
- return this.context.globalCompositeOperation = "soft-light", this
- },
- blendDifference: function() {
- return this.context.globalCompositeOperation = "difference", this
- },
- blendExclusion: function() {
- return this.context.globalCompositeOperation = "exclusion", this
- },
- blendHue: function() {
- return this.context.globalCompositeOperation = "hue", this
- },
- blendSaturation: function() {
- return this.context.globalCompositeOperation = "saturation", this
- },
- blendColor: function() {
- return this.context.globalCompositeOperation = "color", this
- },
- blendLuminosity: function() {
- return this.context.globalCompositeOperation = "luminosity", this
- }
- }, Object.defineProperty(b.BitmapData.prototype, "smoothed", {
- get: function() {
- b.Canvas.getSmoothingEnabled(this.context)
- },
- set: function(a) {
- b.Canvas.setSmoothingEnabled(this.context, a)
- }
- }), b.BitmapData.getTransform = function(a, b, c, d, e, f) {
- 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), {
- sx: c,
- sy: d,
- scaleX: c,
- scaleY: d,
- skewX: e,
- skewY: f,
- translateX: a,
- translateY: b,
- tx: a,
- ty: b
- }
- }, b.BitmapData.prototype.constructor = b.BitmapData, b.Sprite = function(a, c, d, e, f) {
- 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)
- }, b.Sprite.prototype = Object.create(PIXI.Sprite.prototype), b.Sprite.prototype.constructor = b.Sprite, b.Sprite.prototype.preUpdate = function() {
- 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;
- 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;
- if (this.lifespan > 0 && (this.lifespan -= this.game.time.elapsed, this.lifespan <= 0)) return this.kill(), !1;
- if ((this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds)
- if (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds)) this._cache[5] = 0, this.events.onEnterBounds.dispatch(this);
- 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;
- 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();
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
- return !0
- }, b.Sprite.prototype.update = function() {}, b.Sprite.prototype.postUpdate = function() {
- 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);
- for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
- }, b.Sprite.prototype.loadTexture = function(a, c, d) {
- c = c || 0, (d || "undefined" == typeof d) && this.animations.stop(), this.key = a;
- var e = !0,
- f = this.smoothed;
- 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)
- }, b.Sprite.prototype.setFrame = function(a) {
- 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 = {
- x: a.spriteSourceSizeX,
- y: a.spriteSourceSizeY,
- width: a.sourceSizeW,
- height: a.sourceSizeH
- }, 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()
- }, b.Sprite.prototype.resetFrame = function() {
- this._frame && this.setFrame(this._frame)
- }, b.Sprite.prototype.crop = function(a, c) {
- "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())
- }, b.Sprite.prototype.updateCrop = function() {
- if (this.cropRect) {
- this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
- var a = Math.max(this._frame.x, this._crop.x),
- c = Math.max(this._frame.y, this._crop.y),
- d = Math.min(this._frame.right, this._crop.right) - a,
- e = Math.min(this._frame.bottom, this._crop.bottom) - c;
- this.texture.crop.x = a, this.texture.crop.y = c, this.texture.crop.width = d, this.texture.crop.height = e, this.texture.frame.width = Math.min(d, this.cropRect.width), this.texture.frame.height = Math.min(e, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.texture._updateUvs()
- }
- }, b.Sprite.prototype.revive = function(a) {
- 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
- }, b.Sprite.prototype.kill = function() {
- return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
- }, b.Sprite.prototype.destroy = function(a) {
- if (null !== this.game && 1 !== this._cache[8]) {
- "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();
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- 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
- }
- }, b.Sprite.prototype.damage = function(a) {
- return this.alive && (this.health -= a, this.health <= 0 && this.kill()), this
- }, b.Sprite.prototype.reset = function(a, b, c) {
- 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
- }, b.Sprite.prototype.bringToTop = function() {
- return this.parent && this.parent.bringToTop(this), this
- }, b.Sprite.prototype.play = function(a, b, c, d) {
- return this.animations ? this.animations.play(a, b, c, d) : void 0
- }, b.Sprite.prototype.overlap = function(a) {
- return b.Rectangle.intersects(this.getBounds(), a.getBounds())
- }, Object.defineProperty(b.Sprite.prototype, "angle", {
- get: function() {
- return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
- }
- }), Object.defineProperty(b.Sprite.prototype, "deltaX", {
- get: function() {
- return this.world.x - this._cache[0]
- }
- }), Object.defineProperty(b.Sprite.prototype, "deltaY", {
- get: function() {
- return this.world.y - this._cache[1]
- }
- }), Object.defineProperty(b.Sprite.prototype, "deltaZ", {
- get: function() {
- return this.rotation - this._cache[2]
- }
- }), Object.defineProperty(b.Sprite.prototype, "inWorld", {
- get: function() {
- return this.game.world.bounds.intersects(this.getBounds())
- }
- }), Object.defineProperty(b.Sprite.prototype, "inCamera", {
- get: function() {
- return this.game.world.camera.screenView.intersects(this.getBounds())
- }
- }), Object.defineProperty(b.Sprite.prototype, "frame", {
- get: function() {
- return this.animations.frame
- },
- set: function(a) {
- this.animations.frame = a
- }
- }), Object.defineProperty(b.Sprite.prototype, "frameName", {
- get: function() {
- return this.animations.frameName
- },
- set: function(a) {
- this.animations.frameName = a
- }
- }), Object.defineProperty(b.Sprite.prototype, "renderOrderID", {
- get: function() {
- return this._cache[3]
- }
- }), Object.defineProperty(b.Sprite.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.Sprite.prototype, "exists", {
- get: function() {
- return !!this._cache[6]
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(b.Sprite.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.Sprite.prototype, "smoothed", {
- get: function() {
- return !this.texture.baseTexture.scaleMode
- },
- set: function(a) {
- a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
- }
- }), Object.defineProperty(b.Sprite.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(a) {
- this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.Sprite.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(a) {
- this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.Sprite.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.Image = function(a, c, d, e, f) {
- 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)
- }, b.Image.prototype = Object.create(PIXI.Sprite.prototype), b.Image.prototype.constructor = b.Image, b.Image.prototype.preUpdate = function() {
- 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;
- 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++);
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
- return !0
- }, b.Image.prototype.update = function() {}, b.Image.prototype.postUpdate = function() {
- 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);
- for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
- }, b.Image.prototype.loadTexture = function(a, c) {
- c = c || 0, this.key = a;
- var d = !0,
- e = this.smoothed;
- 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)
- }, b.Image.prototype.setFrame = function(a) {
- 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 = {
- x: a.spriteSourceSizeX,
- y: a.spriteSourceSizeY,
- width: a.sourceSizeW,
- height: a.sourceSizeH
- }, 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()
- }, b.Image.prototype.resetFrame = function() {
- this._frame && this.setFrame(this._frame)
- }, b.Image.prototype.crop = function(a, c) {
- "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())
- }, b.Image.prototype.updateCrop = function() {
- if (this.cropRect) {
- this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
- var a = Math.max(this._frame.x, this._crop.x),
- c = Math.max(this._frame.y, this._crop.y),
- d = Math.min(this._frame.right, this._crop.right) - a,
- e = Math.min(this._frame.bottom, this._crop.bottom) - c;
- this.texture.crop.x = a, this.texture.crop.y = c, this.texture.crop.width = d, this.texture.crop.height = e, this.texture.frame.width = Math.min(d, this.cropRect.width), this.texture.frame.height = Math.min(e, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.texture._updateUvs()
- }
- }, b.Image.prototype.revive = function() {
- return this.alive = !0, this.exists = !0, this.visible = !0, this.events && this.events.onRevived.dispatch(this), this
- }, b.Image.prototype.kill = function() {
- return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
- }, b.Image.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "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();
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
- }
- }, b.Image.prototype.reset = function(a, b) {
- 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
- }, b.Image.prototype.bringToTop = function() {
- return this.parent && this.parent.bringToTop(this), this
- }, Object.defineProperty(b.Image.prototype, "angle", {
- get: function() {
- return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
- }
- }), Object.defineProperty(b.Image.prototype, "deltaX", {
- get: function() {
- return this.world.x - this._cache[0]
- }
- }), Object.defineProperty(b.Image.prototype, "deltaY", {
- get: function() {
- return this.world.y - this._cache[1]
- }
- }), Object.defineProperty(b.Image.prototype, "deltaZ", {
- get: function() {
- return this.rotation - this._cache[2]
- }
- }), Object.defineProperty(b.Image.prototype, "inWorld", {
- get: function() {
- return this.game.world.bounds.intersects(this.getBounds())
- }
- }), Object.defineProperty(b.Image.prototype, "inCamera", {
- get: function() {
- return this.game.world.camera.screenView.intersects(this.getBounds())
- }
- }), Object.defineProperty(b.Image.prototype, "frame", {
- get: function() {
- return this._frame
- },
- set: function(a) {
- if (a !== this.frame) {
- var b = this.game.cache.getFrameData(this.key);
- b && a < b.total && b.getFrame(a) && (this.setTexture(PIXI.TextureCache[b.getFrame(a).uuid]), this._frame = a)
- }
- }
- }), Object.defineProperty(b.Image.prototype, "frameName", {
- get: function() {
- return this._frameName
- },
- set: function(a) {
- if (a !== this.frameName) {
- var b = this.game.cache.getFrameData(this.key);
- b && b.getFrameByName(a) && (this.setTexture(PIXI.TextureCache[b.getFrameByName(a).uuid]), this._frameName = a)
- }
- }
- }), Object.defineProperty(b.Image.prototype, "renderOrderID", {
- get: function() {
- return this._cache[3]
- }
- }), Object.defineProperty(b.Image.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.Image.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.Image.prototype, "smoothed", {
- get: function() {
- return !this.texture.baseTexture.scaleMode
- },
- set: function(a) {
- a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
- }
- }), Object.defineProperty(b.Image.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.TileSprite = function(a, c, d, e, f, g, h) {
- 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)
- }, b.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), b.TileSprite.prototype.constructor = b.TileSprite, b.TileSprite.prototype.preUpdate = function() {
- 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;
- 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;
- (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();
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
- return !0
- }, b.TileSprite.prototype.update = function() {}, b.TileSprite.prototype.postUpdate = function() {
- 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);
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
- }, b.TileSprite.prototype.autoScroll = function(a, b) {
- this._scroll.set(a, b)
- }, b.TileSprite.prototype.stopScroll = function() {
- this._scroll.set(0, 0)
- }, b.TileSprite.prototype.loadTexture = function(a, c) {
- 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()
- }, b.TileSprite.prototype.setFrame = function(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 = {
- x: a.spriteSourceSizeX,
- y: a.spriteSourceSizeY,
- width: a.sourceSizeW,
- height: a.sourceSizeH
- }, 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()
- }, b.TileSprite.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "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();
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.exists = !1, this.visible = !1, this.alive = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
- }
- }, b.TileSprite.prototype.play = function(a, b, c, d) {
- return this.animations.play(a, b, c, d)
- }, b.TileSprite.prototype.reset = function(a, b) {
- 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
- }, Object.defineProperty(b.TileSprite.prototype, "angle", {
- get: function() {
- return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
- }
- }), Object.defineProperty(b.TileSprite.prototype, "frame", {
- get: function() {
- return this.animations.frame
- },
- set: function(a) {
- a !== this.animations.frame && (this.animations.frame = a)
- }
- }), Object.defineProperty(b.TileSprite.prototype, "frameName", {
- get: function() {
- return this.animations.frameName
- },
- set: function(a) {
- a !== this.animations.frameName && (this.animations.frameName = a)
- }
- }), Object.defineProperty(b.TileSprite.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.TileSprite.prototype, "exists", {
- get: function() {
- return !!this._cache[6]
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(b.TileSprite.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.TileSprite.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(a) {
- this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.TileSprite.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(a) {
- this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.TileSprite.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.Rope = function(a, c, d, e, f, g) {
- 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)
- }, b.Rope.prototype = Object.create(PIXI.Rope.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.preUpdate = function() {
- 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;
- 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;
- (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();
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
- return !0
- }, b.Rope.prototype.update = function() {
- this._hasUpdateAnimation && this.updateAnimation.call(this)
- }, b.Rope.prototype.postUpdate = function() {
- 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);
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
- }, b.Rope.prototype.loadTexture = function(a, c) {
- 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]))
- }, b.Rope.prototype.setFrame = function(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 = {
- x: a.spriteSourceSizeX,
- y: a.spriteSourceSizeY,
- width: a.sourceSizeW,
- height: a.sourceSizeH
- }, 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()
- }, b.Rope.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "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();
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
- }
- }, b.Rope.prototype.play = function(a, b, c, d) {
- return this.animations.play(a, b, c, d)
- }, b.Rope.prototype.reset = function(a, b) {
- 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
- }, Object.defineProperty(b.Rope.prototype, "angle", {
- get: function() {
- return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
- }
- }), Object.defineProperty(b.Rope.prototype, "frame", {
- get: function() {
- return this.animations.frame
- },
- set: function(a) {
- a !== this.animations.frame && (this.animations.frame = a)
- }
- }), Object.defineProperty(b.Rope.prototype, "frameName", {
- get: function() {
- return this.animations.frameName
- },
- set: function(a) {
- a !== this.animations.frameName && (this.animations.frameName = a)
- }
- }), Object.defineProperty(b.Rope.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.Rope.prototype, "exists", {
- get: function() {
- return !!this._cache[6]
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(b.Rope.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.Rope.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(a) {
- this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.Rope.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(a) {
- this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
- }
- }), Object.defineProperty(b.Rope.prototype, "updateAnimation", {
- get: function() {
- return this._updateAnimation
- },
- set: function(a) {
- a && "function" == typeof a ? (this._hasUpdateAnimation = !0, this._updateAnimation = a) : (this._hasUpdateAnimation = !1, this._updateAnimation = null)
- }
- }), Object.defineProperty(b.Rope.prototype, "segments", {
- get: function() {
- 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);
- return j
- }
- }), Object.defineProperty(b.Rope.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.Text = function(a, c, d, e, f) {
- 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()
- }, b.Text.prototype = Object.create(PIXI.Text.prototype), b.Text.prototype.constructor = b.Text, b.Text.prototype.preUpdate = function() {
- 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;
- 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++);
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
- return !0
- }, b.Text.prototype.update = function() {}, b.Text.prototype.postUpdate = function() {
- 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);
- for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
- }, b.Text.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "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);
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
- }
- }, b.Text.prototype.setShadow = function(a, b, c, d) {
- 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
- }, b.Text.prototype.setStyle = function(a) {
- 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
- }, b.Text.prototype.updateText = function() {
- this.texture.baseTexture.resolution = this.resolution, this.context.font = this.style.font;
- var a = this.text;
- this.style.wordWrap && (a = this.runWordWrap(this.text));
- for (var b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = this.determineFontProperties(this.style.font), f = 0; f < b.length; f++) {
- var g = this.context.measureText(b[f]).width;
- c[f] = g, d = Math.max(d, g)
- }
- var h = d + this.style.strokeThickness;
- this.canvas.width = (h + this.context.lineWidth) * this.resolution;
- var i = e.fontSize + this.style.strokeThickness,
- j = i * b.length;
- 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";
- var k, l;
- 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));
- this.updateTexture()
- }, b.Text.prototype.updateLine = function(a, b, c) {
- for (var d = 0; d < a.length; d++) {
- var e = a[d];
- 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++
- }
- }, b.Text.prototype.clearColors = function() {
- this.colors = [], this.dirty = !0
- }, b.Text.prototype.addColor = function(a, b) {
- this.colors[b] = a, this.dirty = !0
- }, b.Text.prototype.runWordWrap = function(a) {
- for (var b = "", c = a.split("\n"), d = 0; d < c.length; d++) {
- for (var e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) {
- var h = this.context.measureText(f[g]).width,
- i = h + this.context.measureText(" ").width;
- i > e ? (g > 0 && (b += "\n"), b += f[g] + " ", e = this.style.wordWrapWidth - h) : (e -= i, b += f[g] + " ")
- }
- d < c.length - 1 && (b += "\n")
- }
- return b
- }, Object.defineProperty(b.Text.prototype, "angle", {
- get: function() {
- return b.Math.radToDeg(this.rotation)
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(a)
- }
- }), Object.defineProperty(b.Text.prototype, "text", {
- get: function() {
- return this._text
- },
- set: function(a) {
- a !== this._text && (this._text = a.toString() || " ", this.dirty = !0, this.parent && this.updateTransform())
- }
- }), Object.defineProperty(b.Text.prototype, "font", {
- get: function() {
- return this._font
- },
- set: function(a) {
- a !== this._font && (this._font = a.trim(), this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.parent && this.updateTransform())
- }
- }), Object.defineProperty(b.Text.prototype, "fontSize", {
- get: function() {
- return this._fontSize
- },
- set: function(a) {
- 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())
- }
- }), Object.defineProperty(b.Text.prototype, "fontWeight", {
- get: function() {
- return this._fontWeight
- },
- set: function(a) {
- a !== this._fontWeight && (this._fontWeight = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.parent && this.updateTransform())
- }
- }), Object.defineProperty(b.Text.prototype, "fill", {
- get: function() {
- return this.style.fill
- },
- set: function(a) {
- a !== this.style.fill && (this.style.fill = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "align", {
- get: function() {
- return this.style.align
- },
- set: function(a) {
- a !== this.style.align && (this.style.align = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "stroke", {
- get: function() {
- return this.style.stroke
- },
- set: function(a) {
- a !== this.style.stroke && (this.style.stroke = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "strokeThickness", {
- get: function() {
- return this.style.strokeThickness
- },
- set: function(a) {
- a !== this.style.strokeThickness && (this.style.strokeThickness = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "wordWrap", {
- get: function() {
- return this.style.wordWrap
- },
- set: function(a) {
- a !== this.style.wordWrap && (this.style.wordWrap = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "wordWrapWidth", {
- get: function() {
- return this.style.wordWrapWidth
- },
- set: function(a) {
- a !== this.style.wordWrapWidth && (this.style.wordWrapWidth = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "lineSpacing", {
- get: function() {
- return this._lineSpacing
- },
- set: function(a) {
- a !== this._lineSpacing && (this._lineSpacing = parseFloat(a), this.dirty = !0, this.parent && this.updateTransform())
- }
- }), Object.defineProperty(b.Text.prototype, "shadowOffsetX", {
- get: function() {
- return this.style.shadowOffsetX
- },
- set: function(a) {
- a !== this.style.shadowOffsetX && (this.style.shadowOffsetX = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "shadowOffsetY", {
- get: function() {
- return this.style.shadowOffsetY
- },
- set: function(a) {
- a !== this.style.shadowOffsetY && (this.style.shadowOffsetY = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "shadowColor", {
- get: function() {
- return this.style.shadowColor
- },
- set: function(a) {
- a !== this.style.shadowColor && (this.style.shadowColor = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "shadowBlur", {
- get: function() {
- return this.style.shadowBlur
- },
- set: function(a) {
- a !== this.style.shadowBlur && (this.style.shadowBlur = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.Text.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.Text.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.Text.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.BitmapText = function(a, c, d, e, f, g) {
- 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]
- }, b.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setStyle = function() {
- this.style = {
- align: this._align
- }, this.fontName = this._font, this.fontSize = this._fontSize, this.dirty = !0
- }, b.BitmapText.prototype.preUpdate = function() {
- 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)
- }, b.BitmapText.prototype.update = function() {}, b.BitmapText.prototype.postUpdate = function() {
- 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)
- }, b.BitmapText.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy ? this.children[c].destroy(a) : this.removeChild(this.children[c]);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
- }
- }, Object.defineProperty(b.BitmapText.prototype, "align", {
- get: function() {
- return this._align
- },
- set: function(a) {
- a !== this._align && (this._align = a, this.setStyle())
- }
- }), Object.defineProperty(b.BitmapText.prototype, "tint", {
- get: function() {
- return this._tint
- },
- set: function(a) {
- a !== this._tint && (this._tint = a, this.dirty = !0)
- }
- }), Object.defineProperty(b.BitmapText.prototype, "angle", {
- get: function() {
- return b.Math.radToDeg(this.rotation)
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(a)
- }
- }), Object.defineProperty(b.BitmapText.prototype, "font", {
- get: function() {
- return this._font
- },
- set: function(a) {
- a !== this._font && (this._font = a.trim(), this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
- }
- }), Object.defineProperty(b.BitmapText.prototype, "fontSize", {
- get: function() {
- return this._fontSize
- },
- set: function(a) {
- a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
- }
- }), Object.defineProperty(b.BitmapText.prototype, "text", {
- get: function() {
- return this._text
- },
- set: function(a) {
- a !== this._text && (this._text = a.toString() || " ", this.dirty = !0)
- }
- }), Object.defineProperty(b.BitmapText.prototype, "inputEnabled", {
- get: function() {
- return this.input && this.input.enabled
- },
- set: function(a) {
- 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()
- }
- }), Object.defineProperty(b.BitmapText.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.BitmapText.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.Button = function(a, c, d, e, f, g, h, i, j, k) {
- 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)
- }, b.Button.prototype = Object.create(b.Image.prototype), b.Button.prototype.constructor = b.Button, b.Button.prototype.clearFrames = function() {
- this._onOverFrameName = null, this._onOverFrameID = null, this._onOutFrameName = null, this._onOutFrameID = null, this._onDownFrameName = null, this._onDownFrameID = null, this._onUpFrameName = null, this._onUpFrameID = null
- }, b.Button.prototype.setFrames = function(a, b, c, d) {
- 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)))
- }, b.Button.prototype.setSounds = function(a, b, c, d, e, f, g, h) {
- this.setOverSound(a, b), this.setOutSound(e, f), this.setDownSound(c, d), this.setUpSound(g, h)
- }, b.Button.prototype.setOverSound = function(a, c) {
- this.onOverSound = null, this.onOverSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onOverSound = a), "string" == typeof c && (this.onOverSoundMarker = c)
- }, b.Button.prototype.setOutSound = function(a, c) {
- this.onOutSound = null, this.onOutSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onOutSound = a), "string" == typeof c && (this.onOutSoundMarker = c)
- }, b.Button.prototype.setDownSound = function(a, c) {
- this.onDownSound = null, this.onDownSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onDownSound = a), "string" == typeof c && (this.onDownSoundMarker = c)
- }, b.Button.prototype.setUpSound = function(a, c) {
- this.onUpSound = null, this.onUpSoundMarker = "", (a instanceof b.Sound || a instanceof b.AudioSprite) && (this.onUpSound = a), "string" == typeof c && (this.onUpSoundMarker = c)
- }, b.Button.prototype.onInputOverHandler = function(a, b) {
- 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)))
- }, b.Button.prototype.onInputOutHandler = function(a, b) {
- this.freezeFrames === !1 && this.setState(2), this.onOutSound && this.onOutSound.play(this.onOutSoundMarker), this.onInputOut && this.onInputOut.dispatch(this, b)
- }, b.Button.prototype.onInputDownHandler = function(a, b) {
- this.freezeFrames === !1 && this.setState(3), this.onDownSound && this.onDownSound.play(this.onDownSoundMarker), this.onInputDown && this.onInputDown.dispatch(this, b)
- }, b.Button.prototype.onInputUpHandler = function(a, b, c) {
- 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)
- }, b.Button.prototype.setState = function(a) {
- 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))
- }, b.Graphics = function(a, c, d) {
- 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]
- }, b.Graphics.prototype = Object.create(PIXI.Graphics.prototype), b.Graphics.prototype.constructor = b.Graphics, b.Graphics.prototype.preUpdate = function() {
- 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)
- }, b.Graphics.prototype.update = function() {}, b.Graphics.prototype.postUpdate = function() {
- 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)
- }, b.Graphics.prototype.destroy = function(a) {
- if (null !== this.game && !this.destroyPhase) {
- "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));
- var c = this.children.length;
- if (a)
- for (; c--;) this.children[c].destroy(a);
- else
- for (; c--;) this.removeChild(this.children[c]);
- this.exists = !1, this.visible = !1, this.game = null, this._cache[8] = 0
- }
- }, b.Graphics.prototype.drawTriangle = function(a, c) {
- "undefined" == typeof c && (c = !1);
- var d = new b.Polygon(a);
- if (c) {
- var e = new b.Point(this.game.camera.x - a[0].x, this.game.camera.y - a[0].y),
- f = new b.Point(a[1].x - a[0].x, a[1].y - a[0].y),
- g = new b.Point(a[1].x - a[2].x, a[1].y - a[2].y),
- h = g.cross(f);
- e.dot(h) > 0 && this.drawPolygon(d)
- } else this.drawPolygon(d)
- }, b.Graphics.prototype.drawTriangles = function(a, c, d) {
- "undefined" == typeof d && (d = !1);
- var e, f = new b.Point,
- g = new b.Point,
- h = new b.Point,
- i = [];
- if (c)
- if (a[0] instanceof b.Point)
- 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 = []);
- else
- 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 = []);
- else if (a[0] instanceof b.Point)
- for (e = 0; e < a.length / 3; e++) this.drawTriangle([a[3 * e], a[3 * e + 1], a[3 * e + 2]], d);
- else
- 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)
- }, Object.defineProperty(b.Graphics.prototype, "angle", {
- get: function() {
- return b.Math.radToDeg(this.rotation)
- },
- set: function(a) {
- this.rotation = b.Math.degToRad(a)
- }
- }), Object.defineProperty(b.Graphics.prototype, "fixedToCamera", {
- get: function() {
- return !!this._cache[7]
- },
- set: function(a) {
- a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
- }
- }), Object.defineProperty(b.Graphics.prototype, "destroyPhase", {
- get: function() {
- return !!this._cache[8]
- }
- }), b.RenderTexture = function(a, c, d, e, f, g) {
- "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
- }, b.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.renderXY = function(a, b, c, d) {
- 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)
- }, b.RenderTexture.prototype.render = function(a, b, c) {
- 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)
- }, b.SpriteBatch = function(a, c, d, e) {
- ("undefined" == typeof c || null === c) && (c = a.world), PIXI.SpriteBatch.call(this), b.Group.call(this, a, c, d, e), this.type = b.SPRITEBATCH
- }, 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) {
- if (!a.cache.checkImageKey(c)) return !1;
- ("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;
- for (var l = this.offsetX, m = this.offsetY, n = 0, o = 0; o < f.length; o++) {
- var p = a.rnd.uuid(),
- q = this.frameData.addFrame(new b.Frame(o, l, m, this.characterWidth, this.characterHeight, "", p));
- this.grabData[f.charCodeAt(o)] = q.index, PIXI.TextureCache[p] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
- x: l,
- y: m,
- width: this.characterWidth,
- height: this.characterHeight
- }), n++, n == this.characterPerRow ? (n = 0, l = this.offsetX, m += this.characterHeight + this.characterSpacingY) : l += this.characterWidth + this.characterSpacingX
- }
- 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
- }, 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) {
- "undefined" == typeof b && (b = "left"), this.fixedWidth = a, this.align = b
- }, b.RetroFont.prototype.setText = function(a, b, c, d, e, f) {
- 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)
- }, b.RetroFont.prototype.buildRetroFontText = function() {
- var a = 0,
- c = 0;
- if (this.clear(), this.multiLine) {
- var d = this._text.split("\n");
- this.fixedWidth > 0 ? this.resize(this.fixedWidth, d.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0) : this.resize(this.getLongestLine() * (this.characterWidth + this.customSpacingX), d.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0);
- for (var e = 0; e < d.length; e++) {
- switch (this.align) {
- case b.RetroFont.ALIGN_LEFT:
- a = 0;
- break;
- case b.RetroFont.ALIGN_RIGHT:
- a = this.width - d[e].length * (this.characterWidth + this.customSpacingX);
- break;
- case b.RetroFont.ALIGN_CENTER:
- a = this.width / 2 - d[e].length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
- }
- 0 > a && (a = 0), this.pasteLine(d[e], a, c, this.customSpacingX), c += this.characterHeight + this.customSpacingY
- }
- } else {
- 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) {
- case b.RetroFont.ALIGN_LEFT:
- a = 0;
- break;
- case b.RetroFont.ALIGN_RIGHT:
- a = this.width - this._text.length * (this.characterWidth + this.customSpacingX);
- break;
- case b.RetroFont.ALIGN_CENTER:
- a = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
- }
- this.textureBuffer.clear(), this.pasteLine(this._text, a, 0, this.customSpacingX)
- }
- }, b.RetroFont.prototype.pasteLine = function(a, c, d, e) {
- for (var f = new b.Point, g = 0; g < a.length; g++)
- if (" " == a.charAt(g)) c += this.characterWidth + e;
- 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
- }, b.RetroFont.prototype.getLongestLine = function() {
- var a = 0;
- if (this._text.length > 0)
- for (var b = this._text.split("\n"), c = 0; c < b.length; c++) b[c].length > a && (a = b[c].length);
- return a
- }, b.RetroFont.prototype.removeUnsupportedCharacters = function(a) {
- for (var b = "", c = 0; c < this._text.length; c++) {
- var d = this._text[c],
- e = d.charCodeAt(0);
- (this.grabData[e] >= 0 || !a && "\n" === d) && (b = b.concat(d))
- }
- return b
- }, b.RetroFont.prototype.updateOffset = function(a, b) {
- if (this.offsetX !== a || this.offsetY !== b) {
- 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;
- this.buildRetroFontText()
- }
- }, Object.defineProperty(b.RetroFont.prototype, "text", {
- get: function() {
- return this._text
- },
- set: function(a) {
- var b;
- b = this.autoUpperCase ? a.toUpperCase() : a, b !== this._text && (this._text = b, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
- }
- }), Object.defineProperty(b.RetroFont.prototype, "smoothed", {
- get: function() {
- return this.stamp.smoothed
- },
- set: function(a) {
- this.stamp.smoothed = a, this.buildRetroFontText()
- }
- }), b.Particle = function(a, c, d, e, f) {
- 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
- }, b.Particle.prototype = Object.create(b.Sprite.prototype), b.Particle.prototype.constructor = b.Particle, b.Particle.prototype.update = function() {
- 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)
- }, b.Particle.prototype.onEmit = function() {}, b.Particle.prototype.setAlphaData = function(a) {
- this.alphaData = a, this._a = a.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0
- }, b.Particle.prototype.setScaleData = function(a) {
- this.scaleData = a, this._s = a.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0
- }, b.Particle.prototype.reset = function(a, b, c) {
- 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
- }, b.Canvas = {
- create: function(a, b, c) {
- a = a || 256, b = b || 256;
- var d = document.createElement("canvas");
- return "string" == typeof c && "" !== c && (d.id = c), d.width = a, d.height = b, d.style.display = "block", d
- },
- getOffset: function(a, c) {
- c = c || new b.Point;
- var d = a.getBoundingClientRect(),
- e = a.clientTop || document.body.clientTop || 0,
- f = a.clientLeft || document.body.clientLeft || 0,
- g = 0,
- h = 0;
- 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
- },
- getAspectRatio: function(a) {
- return a.width / a.height
- },
- setBackgroundColor: function(a, b) {
- return b = b || "rgb(0,0,0)", a.style.backgroundColor = b, a
- },
- setTouchAction: function(a, b) {
- return b = b || "none", a.style.msTouchAction = b, a.style["ms-touch-action"] = b, a.style["touch-action"] = b, a
- },
- setUserSelect: function(a, b) {
- 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
- },
- addToDOM: function(a, b, c) {
- var d;
- 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
- },
- removeFromDOM: function(a) {
- a.parentNode && a.parentNode.removeChild(a)
- },
- setTransform: function(a, b, c, d, e, f, g) {
- return a.setTransform(d, f, g, e, b, c), a
- },
- setSmoothingEnabled: function(a, b) {
- return a.imageSmoothingEnabled = b, a.mozImageSmoothingEnabled = b, a.oImageSmoothingEnabled = b, a.webkitImageSmoothingEnabled = b, a.msImageSmoothingEnabled = b, a
- },
- getSmoothingEnabled: function(a) {
- return a.imageSmoothingEnabled || a.mozImageSmoothingEnabled || a.oImageSmoothingEnabled || a.webkitImageSmoothingEnabled || a.msImageSmoothingEnabled
- },
- setImageRenderingCrisp: function(a) {
- 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
- },
- setImageRenderingBicubic: function(a) {
- return a.style["image-rendering"] = "auto", a.style.msInterpolationMode = "bicubic", a
- }
- }, b.Device = function(a) {
- 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()
- }, b.Device.LITTLE_ENDIAN = !1, b.Device.prototype = {
- _checkOS: function() {
- var a = navigator.userAgent;
- /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)
- },
- _checkFeatures: function() {
- this.canvas = !!window.CanvasRenderingContext2D || this.cocoonJS;
- try {
- this.localStorage = !!localStorage.getItem
- } catch (a) {
- this.localStorage = !1
- }
- this.file = !!(window.File && window.FileReader && window.FileList && window.Blob), this.fileSystem = !!window.requestFileSystem, this.webGL = function() {
- try {
- var a = document.createElement("canvas");
- return a.screencanvas = !1, !!window.WebGLRenderingContext && (a.getContext("webgl") || a.getContext("experimental-webgl"))
- } catch (b) {
- return !1
- }
- }(), 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)
- },
- checkFullScreenSupport: function() {
- for (var a = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"], b = 0; b < a.length; b++)
- if (this.game.canvas[a[b]]) {
- this.fullscreen = !0, this.requestFullscreen = a[b];
- break
- }
- var c = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
- if (this.fullscreen)
- for (var b = 0; b < c.length; b++)
- if (document[c[b]]) {
- this.cancelFullscreen = c[b];
- break
- }
- window.Element && Element.ALLOW_KEYBOARD_INPUT && (this.fullscreenKeyboard = !0)
- },
- _checkBrowser: function() {
- var a = navigator.userAgent;
- 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 {
- this.nodeWebkit = "undefined" != typeof require("nw.gui")
- } catch (b) {
- this.nodeWebkit = !1
- }
- if (navigator.isCocoonJS && (this.cocoonJS = !0), this.cocoonJS) try {
- this.cocoonJSApp = "undefined" != typeof CocoonJS
- } catch (b) {
- this.cocoonJSApp = !1
- }
- "undefined" != typeof window.ejecta && (this.ejecta = !0), /Crosswalk/.test(a) && (this.crosswalk = !0)
- },
- _checkAudio: function() {
- this.audioData = !!window.Audio, this.webAudio = !(!window.webkitAudioContext && !window.AudioContext);
- var a = document.createElement("audio"),
- b = !1;
- try {
- (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))
- } catch (c) {}
- },
- _checkDevice: function() {
- 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)
- },
- _checkIsLittleEndian: function() {
- var a = new ArrayBuffer(4),
- b = new Uint8Array(a),
- c = new Uint32Array(a);
- return b[0] = 161, b[1] = 178, b[2] = 195, b[3] = 212, 3569595041 == c[0] ? !0 : 2712847316 == c[0] ? !1 : null
- },
- _checkIsUint8ClampedImageData: function() {
- if ("undefined" == typeof Uint8ClampedArray) return !1;
- var a = document.createElement("canvas"),
- b = a.getContext("2d");
- if (!b) return !1;
- var c = b.createImageData(1, 1);
- return c.data instanceof Uint8ClampedArray
- },
- _checkCSS3D: function() {
- var a, b = document.createElement("p"),
- c = {
- webkitTransform: "-webkit-transform",
- OTransform: "-o-transform",
- msTransform: "-ms-transform",
- MozTransform: "-moz-transform",
- transform: "transform"
- };
- document.body.insertBefore(b, null);
- for (var d in c) void 0 !== b.style[d] && (b.style[d] = "translate3d(1px,1px,1px)", a = window.getComputedStyle(b).getPropertyValue(c[d]));
- document.body.removeChild(b), this.css3D = void 0 !== a && a.length > 0 && "none" !== a
- },
- canPlayAudio: function(a) {
- 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
- },
- isConsoleOpen: function() {
- return window.console && window.console.firebug ? !0 : window.console && (console.profile(), console.profileEnd(), console.clear && console.clear(), console.profiles) ? console.profiles.length > 0 : !1
- }
- }, b.Device.prototype.constructor = b.Device, b.Device.isAndroidStockBrowser = function() {
- var a = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
- return a && a[1] < 537
- }, b.RequestAnimationFrame = function(a, b) {
- "undefined" == typeof b && (b = !1), this.game = a, this.isRunning = !1, this.forceSetTimeOut = b;
- 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"];
- this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
- }, b.RequestAnimationFrame.prototype = {
- start: function() {
- this.isRunning = !0;
- var a = this;
- !window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() {
- return a.updateSetTimeout()
- }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(b) {
- return a.updateRAF(b)
- }, this._timeOutID = window.requestAnimationFrame(this._onLoop))
- },
- updateRAF: function() {
- this.game.update(Date.now()), this._timeOutID = window.requestAnimationFrame(this._onLoop)
- },
- updateSetTimeout: function() {
- this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)
- },
- stop: function() {
- this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1
- },
- isSetTimeOut: function() {
- return this._isSetTimeOut
- },
- isRAF: function() {
- return this._isSetTimeOut === !1
- }
- }, b.RequestAnimationFrame.prototype.constructor = b.RequestAnimationFrame, b.Math = {
- PI2: 2 * Math.PI,
- fuzzyEqual: function(a, b, c) {
- return "undefined" == typeof c && (c = 1e-4), Math.abs(a - b) < c
- },
- fuzzyLessThan: function(a, b, c) {
- return "undefined" == typeof c && (c = 1e-4), b + c > a
- },
- fuzzyGreaterThan: function(a, b, c) {
- return "undefined" == typeof c && (c = 1e-4), a > b - c
- },
- fuzzyCeil: function(a, b) {
- return "undefined" == typeof b && (b = 1e-4), Math.ceil(a - b)
- },
- fuzzyFloor: function(a, b) {
- return "undefined" == typeof b && (b = 1e-4), Math.floor(a + b)
- },
- average: function() {
- for (var a = [], b = 0; b < arguments.length - 0; b++) a[b] = arguments[b + 0];
- for (var c = 0, d = 0; d < a.length; d++) c += a[d];
- return c / a.length
- },
- truncate: function(a) {
- return a > 0 ? Math.floor(a) : Math.ceil(a)
- },
- shear: function(a) {
- return a % 1
- },
- snapTo: function(a, b, c) {
- return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.round(a / b), c + a)
- },
- snapToFloor: function(a, b, c) {
- return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.floor(a / b), c + a)
- },
- snapToCeil: function(a, b, c) {
- return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.ceil(a / b), c + a)
- },
- snapToInArray: function(a, b, c) {
- if ("undefined" == typeof c && (c = !0), c && b.sort(), a < b[0]) return b[0];
- for (var d = 1; b[d] < a;) d++;
- var e = b[d - 1],
- f = d < b.length ? b[d] : Number.POSITIVE_INFINITY;
- return a - e >= f - a ? f : e
- },
- roundTo: function(a, b, c) {
- "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
- var d = Math.pow(c, -b);
- return Math.round(a * d) / d
- },
- floorTo: function(a, b, c) {
- "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
- var d = Math.pow(c, -b);
- return Math.floor(a * d) / d
- },
- ceilTo: function(a, b, c) {
- "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
- var d = Math.pow(c, -b);
- return Math.ceil(a * d) / d
- },
- interpolateFloat: function(a, b, c) {
- return (b - a) * c + a
- },
- angleBetween: function(a, b, c, d) {
- return Math.atan2(d - b, c - a)
- },
- angleBetweenY: function(a, b, c, d) {
- return Math.atan2(c - a, d - b)
- },
- angleBetweenPoints: function(a, b) {
- return Math.atan2(b.y - a.y, b.x - a.x)
- },
- angleBetweenPointsY: function(a, b) {
- return Math.atan2(b.x - a.x, b.y - a.y)
- },
- reverseAngle: function(a) {
- return this.normalizeAngle(a + Math.PI, !0)
- },
- normalizeAngle: function(a) {
- return a %= 2 * Math.PI, a >= 0 ? a : a + 2 * Math.PI
- },
- normalizeLatitude: function(a) {
- return Math.max(-90, Math.min(90, a))
- },
- normalizeLongitude: function(a) {
- return a % 360 == 180 ? 180 : (a %= 360, -180 > a ? a + 360 : a > 180 ? a - 360 : a)
- },
- chanceRoll: function(a) {
- return "undefined" == typeof a && (a = 50), 0 >= a ? !1 : a >= 100 ? !0 : 100 * Math.random() >= a ? !1 : !0
- },
- numberArray: function(a, b) {
- for (var c = [], d = a; b >= d; d++) c.push(d);
- return c
- },
- numberArrayStep: function(a, c, d) {
- a = +a || 0;
- var e = typeof c;
- "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;
- 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;
- return h
- },
- maxAdd: function(a, b, c) {
- return a += b, a > c && (a = c), a
- },
- minSub: function(a, b, c) {
- return a -= b, c > a && (a = c), a
- },
- wrap: function(a, b, c) {
- var d = c - b;
- if (0 >= d) return 0;
- var e = (a - b) % d;
- return 0 > e && (e += d), e + b
- },
- wrapValue: function(a, b, c) {
- var d;
- return a = Math.abs(a), b = Math.abs(b), c = Math.abs(c), d = (a + b) % c
- },
- limitValue: function(a, b, c) {
- return b > a ? b : a > c ? c : a
- },
- randomSign: function() {
- return Math.random() > .5 ? 1 : -1
- },
- isOdd: function(a) {
- return 1 & a
- },
- isEven: function(a) {
- return 1 & a ? !1 : !0
- },
- min: function() {
- if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
- else var a = arguments;
- for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] < a[c] && (c = b);
- return a[c]
- },
- max: function() {
- if (1 === arguments.length && "object" == typeof arguments[0]) var a = arguments[0];
- else var a = arguments;
- for (var b = 1, c = 0, d = a.length; d > b; b++) a[b] > a[c] && (c = b);
- return a[c]
- },
- minProperty: function(a) {
- if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
- else var b = arguments.slice(1);
- for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] < b[d][a] && (d = c);
- return b[d][a]
- },
- maxProperty: function(a) {
- if (2 === arguments.length && "object" == typeof arguments[1]) var b = arguments[1];
- else var b = arguments.slice(1);
- for (var c = 1, d = 0, e = b.length; e > c; c++) b[c][a] > b[d][a] && (d = c);
- return b[d][a]
- },
- wrapAngle: function(a, b) {
- var c = b ? Math.PI / 180 : 1;
- return this.wrap(a, -180 * c, 180 * c)
- },
- angleLimit: function(a, b, c) {
- var d = a;
- return a > c ? d = c : b > a && (d = b), d
- },
- linearInterpolation: function(a, b) {
- var c = a.length - 1,
- d = c * b,
- e = Math.floor(d);
- 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)
- },
- bezierInterpolation: function(a, b) {
- 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);
- return c
- },
- catmullRomInterpolation: function(a, b) {
- var c = a.length - 1,
- d = c * b,
- e = Math.floor(d);
- 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)
- },
- linear: function(a, b, c) {
- return (b - a) * c + a
- },
- bernstein: function(a, b) {
- return this.factorial(a) / this.factorial(b) / this.factorial(a - b)
- },
- factorial: function(a) {
- if (0 === a) return 1;
- for (var b = a; --a;) b *= a;
- return b
- },
- catmullRom: function(a, b, c, d, e) {
- var f = .5 * (c - a),
- g = .5 * (d - b),
- h = e * e,
- i = e * h;
- return (2 * b - 2 * c + f + g) * i + (-3 * b + 3 * c - 2 * f - g) * h + f * e + b
- },
- difference: function(a, b) {
- return Math.abs(a - b)
- },
- getRandom: function(a, b, c) {
- if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
- var d = c;
- if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) return a[b + Math.floor(Math.random() * d)]
- }
- return null
- },
- removeRandom: function(a, b, c) {
- if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
- var d = c;
- if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) {
- var e = b + Math.floor(Math.random() * d),
- f = a.splice(e, 1);
- return f[0]
- }
- }
- return null
- },
- floor: function(a) {
- var b = 0 | a;
- return a > 0 ? b : b != a ? b - 1 : b
- },
- ceil: function(a) {
- var b = 0 | a;
- return a > 0 && b != a ? b + 1 : b
- },
- sinCosGenerator: function(a, b, c, d) {
- "undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1);
- 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;
- return {
- sin: i,
- cos: h,
- length: a
- }
- },
- shift: function(a) {
- var b = a.shift();
- return a.push(b), b
- },
- shuffleArray: function(a) {
- for (var b = a.length - 1; b > 0; b--) {
- var c = Math.floor(Math.random() * (b + 1)),
- d = a[b];
- a[b] = a[c], a[c] = d
- }
- return a
- },
- distance: function(a, b, c, d) {
- var e = a - c,
- f = b - d;
- return Math.sqrt(e * e + f * f)
- },
- distancePow: function(a, b, c, d, e) {
- return "undefined" == typeof e && (e = 2), Math.sqrt(Math.pow(c - a, e) + Math.pow(d - b, e))
- },
- distanceRounded: function(a, c, d, e) {
- return Math.round(b.Math.distance(a, c, d, e))
- },
- clamp: function(a, b, c) {
- return b > a ? b : a > c ? c : a
- },
- clampBottom: function(a, b) {
- return b > a ? b : a
- },
- within: function(a, b, c) {
- return Math.abs(a - b) <= c
- },
- mapLinear: function(a, b, c, d, e) {
- return d + (a - b) * (e - d) / (c - b)
- },
- smoothstep: function(a, b, c) {
- return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * (3 - 2 * a)
- },
- smootherstep: function(a, b, c) {
- return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * a * (a * (6 * a - 15) + 10)
- },
- sign: function(a) {
- return 0 > a ? -1 : a > 0 ? 1 : 0
- },
- percent: function(a, b, c) {
- return "undefined" == typeof c && (c = 0), a > b || c > b ? 1 : c > a || c > a ? 0 : (a - c) / b
- },
- degToRad: function() {
- var a = Math.PI / 180;
- return function(b) {
- return b * a
- }
- }(),
- radToDeg: function() {
- var a = 180 / Math.PI;
- return function(b) {
- return b * a
- }
- }()
- }, b.RandomDataGenerator = function(a) {
- "undefined" == typeof a && (a = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.sow(a)
- }, b.RandomDataGenerator.prototype = {
- rnd: function() {
- var a = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c;
- return this.c = 0 | a, this.s0 = this.s1, this.s1 = this.s2, this.s2 = a - this.c, this.s2
- },
- sow: function(a) {
- "undefined" == typeof a && (a = []), this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1;
- 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)
- },
- hash: function(a) {
- var b, c, d;
- 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;
- return 2.3283064365386963e-10 * (d >>> 0)
- },
- integer: function() {
- return 4294967296 * this.rnd.apply(this)
- },
- frac: function() {
- return this.rnd.apply(this) + 1.1102230246251565e-16 * (2097152 * this.rnd.apply(this) | 0)
- },
- real: function() {
- return this.integer() + this.frac()
- },
- integerInRange: function(a, b) {
- return Math.floor(this.realInRange(0, b - a + 1) + a)
- },
- between: function(a, b) {
- return this.integerInRange(a, b)
- },
- realInRange: function(a, b) {
- return this.frac() * (b - a) + a
- },
- normal: function() {
- return 1 - 2 * this.frac()
- },
- uuid: function() {
- var a = "",
- b = "";
- for (b = a = ""; a++ < 36; b += ~a % 5 | 3 * a & 4 ? (15 ^ a ? 8 ^ this.frac() * (20 ^ a ? 16 : 4) : 4).toString(16) : "-");
- return b
- },
- pick: function(a) {
- return a[this.integerInRange(0, a.length - 1)]
- },
- weightedPick: function(a) {
- return a[~~(Math.pow(this.frac(), 2) * (a.length - 1))]
- },
- timestamp: function(a, b) {
- return this.realInRange(a || 9466848e5, b || 1577862e6)
- },
- angle: function() {
- return this.integerInRange(-180, 180)
- }
- }, b.RandomDataGenerator.prototype.constructor = b.RandomDataGenerator, b.QuadTree = function(a, b, c, d, e, f, g) {
- 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)
- }, b.QuadTree.prototype = {
- reset: function(a, b, c, d, e, f, g) {
- this.maxObjects = e || 10, this.maxLevels = f || 4, this.level = g || 0, this.bounds = {
- x: Math.round(a),
- y: Math.round(b),
- width: c,
- height: d,
- subWidth: Math.floor(c / 2),
- subHeight: Math.floor(d / 2),
- right: Math.round(a) + Math.floor(c / 2),
- bottom: Math.round(b) + Math.floor(d / 2)
- }, this.objects.length = 0, this.nodes.length = 0
- },
- populate: function(a) {
- a.forEach(this.populateHandler, this, !0)
- },
- populateHandler: function(a) {
- a.body && a.exists && this.insert(a.body)
- },
- split: function() {
- 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)
- },
- insert: function(a) {
- var b, c = 0;
- if (null != this.nodes[0] && (b = this.getIndex(a), -1 !== b)) return void this.nodes[b].insert(a);
- if (this.objects.push(a), this.objects.length > this.maxObjects && this.level < this.maxLevels)
- 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++
- },
- getIndex: function(a) {
- var b = -1;
- 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
- },
- retrieve: function(a) {
- if (a instanceof b.Rectangle) var c = this.objects,
- d = this.getIndex(a);
- else {
- if (!a.body) return this._empty;
- var c = this.objects,
- d = this.getIndex(a.body)
- }
- 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
- },
- clear: function() {
- this.objects.length = 0;
- for (var a = this.nodes.length; a--;) this.nodes[a].clear(), this.nodes.splice(a, 1);
- this.nodes.length = 0
- }
- }, b.QuadTree.prototype.constructor = b.QuadTree, b.Net = function(a) {
- this.game = a
- }, b.Net.prototype = {
- getHostName: function() {
- return window.location && window.location.hostname ? window.location.hostname : null
- },
- checkDomainName: function(a) {
- return -1 !== window.location.hostname.indexOf(a)
- },
- updateQueryString: function(a, b, c, d) {
- "undefined" == typeof c && (c = !1), ("undefined" == typeof d || "" === d) && (d = window.location.href);
- var e = "",
- f = new RegExp("([?|&])" + a + "=.*?(&|#|$)(.*)", "gi");
- if (f.test(d)) e = "undefined" != typeof b && null !== b ? d.replace(f, "$1" + a + "=" + b + "$2$3") : d.replace(f, "$1$3").replace(/(&|\?)$/, "");
- else if ("undefined" != typeof b && null !== b) {
- var g = -1 !== d.indexOf("?") ? "&" : "?",
- h = d.split("#");
- d = h[0] + g + a + "=" + b, h[1] && (d += "#" + h[1]), e = d
- } else e = d;
- return c ? void(window.location.href = e) : e
- },
- getQueryString: function(a) {
- "undefined" == typeof a && (a = "");
- var b = {},
- c = location.search.substring(1).split("&");
- for (var d in c) {
- var e = c[d].split("=");
- if (e.length > 1) {
- if (a && a == this.decodeURI(e[0])) return this.decodeURI(e[1]);
- b[this.decodeURI(e[0])] = this.decodeURI(e[1])
- }
- }
- return b
- },
- decodeURI: function(a) {
- return decodeURIComponent(a.replace(/\+/g, " "))
- }
- }, b.Net.prototype.constructor = b.Net, b.TweenManager = function(a) {
- this.game = a, this._tweens = [], this._add = [], this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this)
- }, b.TweenManager.prototype = {
- getAll: function() {
- return this._tweens
- },
- removeAll: function() {
- for (var a = 0; a < this._tweens.length; a++) this._tweens[a].pendingDelete = !0;
- this._add = []
- },
- add: function(a) {
- a._manager = this, this._add.push(a)
- },
- create: function(a) {
- return new b.Tween(a, this.game, this)
- },
- remove: function(a) {
- 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))
- },
- update: function() {
- var a = this._add.length,
- b = this._tweens.length;
- if (0 === b && 0 === a) return !1;
- for (var c = 0; b > c;) this._tweens[c].update(this.game.time.now) ? c++ : (this._tweens.splice(c, 1), b--);
- return a > 0 && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
- },
- isTweening: function(a) {
- return this._tweens.some(function(b) {
- return b._object === a
- })
- },
- _pauseAll: function() {
- for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._pause()
- },
- _resumeAll: function() {
- for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._resume()
- },
- pauseAll: function() {
- for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].pause()
- },
- resumeAll: function() {
- for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].resume(!0)
- }
- }, b.TweenManager.prototype.constructor = b.TweenManager, b.Tween = function(a, c, d) {
- 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
- }, b.Tween.prototype = {
- to: function(a, b, c, d, e, f, g) {
- b = b || 1e3, c = c || null, d = d || !1, e = e || 0, f = f || 0, g = g || !1, g && 0 === f && (f = 1);
- var h;
- 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
- },
- from: function(a, b, c, d, e, f, g) {
- var h = {};
- for (var i in a) h[i] = this._object[i], this._object[i] = a[i];
- return this.to(h, b, c, d, e, f, g)
- },
- start: function() {
- if (null !== this.game && null !== this._object) {
- this._manager.add(this), this.isRunning = !0, this._onStartCallbackFired = !1, this._startTime = this.game.time.now + this._delayTime;
- for (var a in this._valuesEnd) {
- if (Array.isArray(this._valuesEnd[a])) {
- if (0 === this._valuesEnd[a].length) continue;
- this._valuesEnd[a] = [this._object[a]].concat(this._valuesEnd[a])
- }
- this._valuesStart[a] = this._object[a], Array.isArray(this._valuesStart[a]) || (this._valuesStart[a] *= 1), this._valuesStartRepeat[a] = this._valuesStart[a] || 0
- }
- return this
- }
- },
- generateData: function(a, b) {
- if (null === this.game || null === this._object) return null;
- this._startTime = 0;
- for (var c in this._valuesEnd) {
- if (Array.isArray(this._valuesEnd[c])) {
- if (0 === this._valuesEnd[c].length) continue;
- this._valuesEnd[c] = [this._object[c]].concat(this._valuesEnd[c])
- }
- this._valuesStart[c] = this._object[c], Array.isArray(this._valuesStart[c]) || (this._valuesStart[c] *= 1), this._valuesStartRepeat[c] = this._valuesStart[c] || 0
- }
- for (var d = 0, e = Math.floor(a * (this._duration / 1e3)), f = this._duration / e, g = []; e--;) {
- var c, h = (d - this._startTime) / this._duration;
- h = h > 1 ? 1 : h;
- var i = this._easingFunction(h),
- j = {};
- for (c in this._valuesEnd) {
- var k = this._valuesStart[c] || 0,
- l = this._valuesEnd[c];
- l instanceof Array ? j[c] = this._interpolationFunction(l, i) : "string" == typeof l ? l = k + parseFloat(l, 10) : "number" == typeof l && (j[c] = k + (l - k) * i)
- }
- g.push(j), d += f
- }
- var j = {};
- for (c in this._valuesEnd) j[c] = this._valuesEnd[c];
- if (g.push(j), this._yoyo) {
- var m = g.slice();
- m.reverse(), g = g.concat(m)
- }
- return "undefined" != typeof b ? b = b.concat(g) : g
- },
- stop: function() {
- return this.isRunning = !1, this._onUpdateCallback = null, this._manager.remove(this), this
- },
- delay: function(a) {
- return this._delayTime = a, this
- },
- repeat: function(a) {
- return this._repeat = a, this
- },
- yoyo: function(a) {
- return this._yoyo = a, a && 0 === this._repeat && (this._repeat = 1), this
- },
- easing: function(a) {
- return this._easingFunction = a, this
- },
- interpolation: function(a) {
- return this._interpolationFunction = a, this
- },
- chain: function() {
- return this._chainedTweens = arguments, this
- },
- loop: function() {
- return this._lastChild.chain(this), this
- },
- onUpdateCallback: function(a, b) {
- return this._onUpdateCallback = a, this._onUpdateCallbackContext = b, this
- },
- pause: function() {
- this._codePaused = !0, this._paused = !0, this._pausedTime = this.game.time.now
- },
- _pause: function() {
- this._codePaused || (this._paused = !0, this._pausedTime = this.game.time.now)
- },
- resume: function() {
- this._paused && (this._paused = !1, this._codePaused = !1, this._startTime += this.game.time.now - this._pausedTime)
- },
- _resume: function() {
- this._codePaused || (this._startTime += this.game.time.pauseDuration, this._paused = !1)
- },
- update: function(a) {
- if (this.pendingDelete) return !1;
- if (this._paused || a < this._startTime) return !0;
- var b;
- if (a < this._startTime) return !0;
- this._onStartCallbackFired === !1 && (this.onStart.dispatch(this._object), this._onStartCallbackFired = !0);
- var c = (a - this._startTime) / this._duration;
- c = c > 1 ? 1 : c;
- var d = this._easingFunction(c);
- for (b in this._valuesEnd) {
- var e = this._valuesStart[b] || 0,
- f = this._valuesEnd[b];
- f instanceof Array ? this._object[b] = this._interpolationFunction(f, d) : ("string" == typeof f && (f = e + parseFloat(f, 10)), "number" == typeof f && (this._object[b] = e + (f - e) * d))
- }
- if (null !== this._onUpdateCallback && (this._onUpdateCallback.call(this._onUpdateCallbackContext, this, d), !this.isRunning)) return !1;
- if (1 == c) {
- if (this._repeat > 0) {
- isFinite(this._repeat) && this._repeat--;
- for (b in this._valuesStartRepeat) {
- if ("string" == typeof this._valuesEnd[b] && (this._valuesStartRepeat[b] = this._valuesStartRepeat[b] + parseFloat(this._valuesEnd[b], 10)), this._yoyo) {
- var g = this._valuesStartRepeat[b];
- this._valuesStartRepeat[b] = this._valuesEnd[b], this._valuesEnd[b] = g
- }
- this._valuesStart[b] = this._valuesStartRepeat[b]
- }
- return this._yoyo && (this._reversed = !this._reversed), this._startTime = a + this._delayTime, this.onLoop.dispatch(this._object), !0
- }
- this.isRunning = !1, this.onComplete.dispatch(this._object);
- for (var h = 0, i = this._chainedTweens.length; i > h; h++) this._chainedTweens[h].start(a);
- return !1
- }
- return !0
- }
- }, b.Tween.prototype.constructor = b.Tween, b.Easing = {
- Linear: {
- None: function(a) {
- return a
- }
- },
- Quadratic: {
- In: function(a) {
- return a * a
- },
- Out: function(a) {
- return a * (2 - a)
- },
- InOut: function(a) {
- return (a *= 2) < 1 ? .5 * a * a : -.5 * (--a * (a - 2) - 1)
- }
- },
- Cubic: {
- In: function(a) {
- return a * a * a
- },
- Out: function(a) {
- return --a * a * a + 1
- },
- InOut: function(a) {
- return (a *= 2) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2)
- }
- },
- Quartic: {
- In: function(a) {
- return a * a * a * a
- },
- Out: function(a) {
- return 1 - --a * a * a * a
- },
- InOut: function(a) {
- return (a *= 2) < 1 ? .5 * a * a * a * a : -.5 * ((a -= 2) * a * a * a - 2)
- }
- },
- Quintic: {
- In: function(a) {
- return a * a * a * a * a
- },
- Out: function(a) {
- return --a * a * a * a * a + 1
- },
- InOut: function(a) {
- return (a *= 2) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2)
- }
- },
- Sinusoidal: {
- In: function(a) {
- return 1 - Math.cos(a * Math.PI / 2)
- },
- Out: function(a) {
- return Math.sin(a * Math.PI / 2)
- },
- InOut: function(a) {
- return .5 * (1 - Math.cos(Math.PI * a))
- }
- },
- Exponential: {
- In: function(a) {
- return 0 === a ? 0 : Math.pow(1024, a - 1)
- },
- Out: function(a) {
- return 1 === a ? 1 : 1 - Math.pow(2, -10 * a)
- },
- InOut: function(a) {
- return 0 === a ? 0 : 1 === a ? 1 : (a *= 2) < 1 ? .5 * Math.pow(1024, a - 1) : .5 * (-Math.pow(2, -10 * (a - 1)) + 2)
- }
- },
- Circular: {
- In: function(a) {
- return 1 - Math.sqrt(1 - a * a)
- },
- Out: function(a) {
- return Math.sqrt(1 - --a * a)
- },
- InOut: function(a) {
- return (a *= 2) < 1 ? -.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
- }
- },
- Elastic: {
- In: function(a) {
- var b, c = .1,
- d = .4;
- 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)))
- },
- Out: function(a) {
- var b, c = .1,
- d = .4;
- 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)
- },
- InOut: function(a) {
- var b, c = .1,
- d = .4;
- 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)
- }
- },
- Back: {
- In: function(a) {
- var b = 1.70158;
- return a * a * ((b + 1) * a - b)
- },
- Out: function(a) {
- var b = 1.70158;
- return --a * a * ((b + 1) * a + b) + 1
- },
- InOut: function(a) {
- var b = 2.5949095;
- return (a *= 2) < 1 ? .5 * a * a * ((b + 1) * a - b) : .5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
- }
- },
- Bounce: {
- In: function(a) {
- return 1 - b.Easing.Bounce.Out(1 - a)
- },
- Out: function(a) {
- 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
- },
- InOut: function(a) {
- return .5 > a ? .5 * b.Easing.Bounce.In(2 * a) : .5 * b.Easing.Bounce.Out(2 * a - 1) + .5
- }
- }
- }, b.Easing.Default = b.Easing.Linear.None, b.Time = function(a) {
- 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
- }, b.Time.prototype = {
- boot: function() {
- this._started = Date.now(), this.events.start()
- },
- add: function(a) {
- return this._timers.push(a), a
- },
- create: function(a) {
- "undefined" == typeof a && (a = !0);
- var c = new b.Timer(this.game, a);
- return this._timers.push(c), c
- },
- removeAll: function() {
- for (var a = 0; a < this._timers.length; a++) this._timers[a].destroy();
- this._timers = [], this.events.removeAll()
- },
- update: function(a) {
- 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)
- 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--)
- },
- gamePaused: function() {
- this._pauseStarted = this.now, this.events.pause();
- for (var a = this._timers.length; a--;) this._timers[a]._pause()
- },
- gameResumed: function() {
- this.time = this.now = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume();
- for (var a = this._timers.length; a--;) this._timers[a]._resume()
- },
- totalElapsedSeconds: function() {
- return .001 * (this.now - this._started)
- },
- elapsedSince: function(a) {
- return this.now - a
- },
- elapsedSecondsSince: function(a) {
- return .001 * (this.now - a)
- },
- reset: function() {
- this._started = this.now, this.removeAll()
- }
- }, b.Time.prototype.constructor = b.Time, b.Timer = function(a, c) {
- "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
- }, b.Timer.MINUTE = 6e4, b.Timer.SECOND = 1e3, b.Timer.HALF = 500, b.Timer.QUARTER = 250, b.Timer.prototype = {
- create: function(a, c, d, e, f, g) {
- a = Math.round(a);
- var h = a;
- h += 0 === this._now ? this.game.time.now : this._now;
- var i = new b.TimerEvent(this, a, h, d, c, e, f, g);
- return this.events.push(i), this.order(), this.expired = !1, i
- },
- add: function(a, b, c) {
- return this.create(a, !1, 0, b, c, Array.prototype.splice.call(arguments, 3))
- },
- repeat: function(a, b, c, d) {
- return this.create(a, !1, b, c, d, Array.prototype.splice.call(arguments, 4))
- },
- loop: function(a, b, c) {
- return this.create(a, !0, 0, b, c, Array.prototype.splice.call(arguments, 3))
- },
- start: function(a) {
- if (!this.running) {
- this._started = this.game.time.now + (a || 0), this.running = !0;
- for (var b = 0; b < this.events.length; b++) this.events[b].tick = this.events[b].delay + this._started
- }
- },
- stop: function(a) {
- this.running = !1, "undefined" == typeof a && (a = !0), a && (this.events.length = 0)
- },
- remove: function(a) {
- for (var b = 0; b < this.events.length; b++)
- if (this.events[b] === a) return this.events[b].pendingDelete = !0, !0;
- return !1
- },
- order: function() {
- this.events.length > 0 && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick)
- },
- sortHandler: function(a, b) {
- return a.tick < b.tick ? -1 : a.tick > b.tick ? 1 : 0
- },
- clearPendingEvents: function() {
- for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
- this._len = this.events.length, this._i = 0
- },
- update: function(a) {
- if (this.paused) return !0;
- 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) {
- 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++;
- this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
- }
- return this.expired && this.autoDestroy ? !1 : !0
- },
- pause: function() {
- this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.now, this.paused = !0))
- },
- _pause: function() {
- !this.paused && this.running && (this._pauseStarted = this.game.time.now, this.paused = !0)
- },
- adjustEvents: function(a) {
- for (var b = 0; b < this.events.length; b++)
- if (!this.events[b].pendingDelete) {
- var c = this.events[b].tick - a;
- 0 > c && (c = 0), this.events[b].tick = this._now + c
- }
- var d = this.nextTick - a;
- this.nextTick = 0 > d ? this._now : this._now + d
- },
- resume: function() {
- if (this.paused) {
- var a = this.game.time.now;
- this._pauseTotal += a - this._now, this._now = a, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
- }
- },
- _resume: function() {
- this._codePaused || this.resume()
- },
- removeAll: function() {
- this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0
- },
- destroy: function() {
- this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0
- }
- }, Object.defineProperty(b.Timer.prototype, "next", {
- get: function() {
- return this.nextTick
- }
- }), Object.defineProperty(b.Timer.prototype, "duration", {
- get: function() {
- return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0
- }
- }), Object.defineProperty(b.Timer.prototype, "length", {
- get: function() {
- return this.events.length
- }
- }), Object.defineProperty(b.Timer.prototype, "ms", {
- get: function() {
- return this.running ? this._now - this._started - this._pauseTotal : 0
- }
- }), Object.defineProperty(b.Timer.prototype, "seconds", {
- get: function() {
- return this.running ? .001 * this.ms : 0
- }
- }), b.Timer.prototype.constructor = b.Timer, b.TimerEvent = function(a, b, c, d, e, f, g, h) {
- 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
- }, b.TimerEvent.prototype.constructor = b.TimerEvent, b.AnimationManager = function(a) {
- 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 = []
- }, b.AnimationManager.prototype = {
- loadFrameData: function(a, b) {
- if ("undefined" == typeof a) return !1;
- if (this.isLoaded)
- for (var c in this._anims) this._anims[c].updateFrameData(a);
- 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
- },
- copyFrameData: function(a, b) {
- if (this._frameData = a.clone(), this.isLoaded)
- for (var c in this._anims) this._anims[c].updateFrameData(this._frameData);
- return "undefined" == typeof b || null === b ? this.frame = 0 : "string" == typeof b ? this.frameName = b : this.frame = b, this.isLoaded = !0, !0
- },
- add: function(a, c, d, e, f) {
- 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]
- },
- validateFrames: function(a, b) {
- "undefined" == typeof b && (b = !0);
- for (var c = 0; c < a.length; c++)
- if (b === !0) {
- if (a[c] > this._frameData.total) return !1
- } else if (this._frameData.checkFrameName(a[c]) === !1) return !1;
- return !0
- },
- play: function(a, b, c, d) {
- 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
- },
- stop: function(a, b) {
- "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)
- },
- update: function() {
- return this.updateIfVisible && !this.sprite.visible ? !1 : this.currentAnim && this.currentAnim.update() === !0 ? (this.currentFrame = this.currentAnim.currentFrame, !0) : !1
- },
- next: function(a) {
- this.currentAnim && (this.currentAnim.next(a), this.currentFrame = this.currentAnim.currentFrame)
- },
- previous: function(a) {
- this.currentAnim && (this.currentAnim.previous(a), this.currentFrame = this.currentAnim.currentFrame)
- },
- getAnimation: function(a) {
- return "string" == typeof a && this._anims[a] ? this._anims[a] : null
- },
- refreshFrame: function() {
- this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)
- },
- destroy: function() {
- var a = null;
- for (var a in this._anims) this._anims.hasOwnProperty(a) && this._anims[a].destroy();
- this._anims = {}, this._frameData = null, this._frameIndex = 0, this.currentAnim = null, this.currentFrame = null
- }
- }, b.AnimationManager.prototype.constructor = b.AnimationManager, Object.defineProperty(b.AnimationManager.prototype, "frameData", {
- get: function() {
- return this._frameData
- }
- }), Object.defineProperty(b.AnimationManager.prototype, "frameTotal", {
- get: function() {
- return this._frameData.total
- }
- }), Object.defineProperty(b.AnimationManager.prototype, "paused", {
- get: function() {
- return this.currentAnim.isPaused
- },
- set: function(a) {
- this.currentAnim.paused = a
- }
- }), Object.defineProperty(b.AnimationManager.prototype, "name", {
- get: function() {
- return this.currentAnim ? this.currentAnim.name : void 0
- }
- }), Object.defineProperty(b.AnimationManager.prototype, "frame", {
- get: function() {
- return this.currentFrame ? this._frameIndex : void 0
- },
- set: function(a) {
- "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)))
- }
- }), Object.defineProperty(b.AnimationManager.prototype, "frameName", {
- get: function() {
- return this.currentFrame ? this.currentFrame.name : void 0
- },
- set: function(a) {
- "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)
- }
- }), b.Animation = function(a, c, d, e, f, g, h) {
- "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)
- }, b.Animation.prototype = {
- play: function(a, b, c) {
- 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
- },
- restart: function() {
- 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)
- },
- setFrame: function(a, b) {
- var c;
- if ("undefined" == typeof b && (b = !1), "string" == typeof a)
- for (var d = 0; d < this._frames.length; d++) this._frameData.getFrame(this._frames[d]).name === a && (c = d);
- else if ("number" == typeof a)
- if (b) c = a;
- else
- for (var d = 0; d < this._frames.length; d++) this.frames[d] === c && (c = d);
- c && (this._frameIndex = c - 1, this._timeNextFrame = this.game.time.now, this.update())
- },
- stop: function(a, b) {
- "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))
- },
- onPause: function() {
- this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.now)
- },
- onResume: function() {
- this.isPlaying && (this._timeNextFrame = this.game.time.now + this._frameDiff)
- },
- update: function() {
- 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
- },
- next: function(a) {
- "undefined" == typeof a && (a = 1);
- var b = this._frameIndex + a;
- 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))
- },
- previous: function(a) {
- "undefined" == typeof a && (a = 1);
- var b = this._frameIndex - a;
- 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))
- },
- updateFrameData: function(a) {
- this._frameData = a, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null
- },
- destroy: function() {
- 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()
- },
- complete: function() {
- 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()
- }
- }, b.Animation.prototype.constructor = b.Animation, Object.defineProperty(b.Animation.prototype, "paused", {
- get: function() {
- return this.isPaused
- },
- set: function(a) {
- this.isPaused = a, a ? this._pauseStartTime = this.game.time.now : this.isPlaying && (this._timeNextFrame = this.game.time.now + this.delay)
- }
- }), Object.defineProperty(b.Animation.prototype, "frameTotal", {
- get: function() {
- return this._frames.length
- }
- }), Object.defineProperty(b.Animation.prototype, "frame", {
- get: function() {
- return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex
- },
- set: function(a) {
- 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))
- }
- }), Object.defineProperty(b.Animation.prototype, "speed", {
- get: function() {
- return Math.round(1e3 / this.delay)
- },
- set: function(a) {
- a >= 1 && (this.delay = 1e3 / a)
- }
- }), Object.defineProperty(b.Animation.prototype, "enableUpdate", {
- get: function() {
- return null !== this.onUpdate
- },
- set: function(a) {
- a && null === this.onUpdate ? this.onUpdate = new b.Signal : a || null === this.onUpdate || (this.onUpdate.dispose(), this.onUpdate = null)
- }
- }), b.Animation.generateFrameNames = function(a, c, d, e, f) {
- "undefined" == typeof e && (e = "");
- var g = [],
- h = "";
- if (d > c)
- 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);
- else
- 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);
- return g
- }, b.Frame = function(a, c, d, e, f, g, h) {
- 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
- }, b.Frame.prototype = {
- setTrim: function(a, b, c, d, e, f, g) {
- 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)
- },
- clone: function() {
- var a = new b.Frame(this.index, this.x, this.y, this.width, this.height, this.name, this.uuid);
- for (var c in this) this.hasOwnProperty(c) && (a[c] = this[c]);
- return a
- },
- getRect: function(a) {
- 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
- }
- }, b.Frame.prototype.constructor = b.Frame, b.FrameData = function() {
- this._frames = [], this._frameNames = []
- }, b.FrameData.prototype = {
- addFrame: function(a) {
- return a.index = this._frames.length, this._frames.push(a), "" !== a.name && (this._frameNames[a.name] = a.index), a
- },
- getFrame: function(a) {
- return a > this._frames.length && (a = 0), this._frames[a]
- },
- getFrameByName: function(a) {
- return "number" == typeof this._frameNames[a] ? this._frames[this._frameNames[a]] : null
- },
- checkFrameName: function(a) {
- return null == this._frameNames[a] ? !1 : !0
- },
- clone: function() {
- for (var a = new b.FrameData, c = 0; c < this._frames.length; c++) a._frames.push(this._frames[c].clone());
- for (var c = 0; c < this._frameNames.length; c++) a._frameNames.push(this._frameNames[c]);
- return a
- },
- getFrameRange: function(a, b, c) {
- "undefined" == typeof c && (c = []);
- for (var d = a; b >= d; d++) c.push(this._frames[d]);
- return c
- },
- getFrames: function(a, b, c) {
- if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
- for (var d = 0; d < this._frames.length; d++) c.push(this._frames[d]);
- else
- for (var d = 0, e = a.length; e > d; d++) c.push(b ? this.getFrame(a[d]) : this.getFrameByName(a[d]));
- return c
- },
- getFrameIndexes: function(a, b, c) {
- if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
- for (var d = 0, e = this._frames.length; e > d; d++) c.push(this._frames[d].index);
- else
- 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);
- return c
- }
- }, b.FrameData.prototype.constructor = b.FrameData, Object.defineProperty(b.FrameData.prototype, "total", {
- get: function() {
- return this._frames.length
- }
- }), b.AnimationParser = {
- spriteSheet: function(a, c, d, e, f, g, h) {
- var i = a.cache.getImage(c);
- if (null == i) return null;
- var j = i.width,
- k = i.height;
- 0 >= d && (d = Math.floor(-j / Math.min(-1, d))), 0 >= e && (e = Math.floor(-k / Math.min(-1, e)));
- var l = Math.floor((j - g) / (d + h)),
- m = Math.floor((k - g) / (e + h)),
- n = l * m;
- 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;
- for (var o = new b.FrameData, p = g, q = g, r = 0; n > r; r++) {
- var s = a.rnd.uuid();
- o.addFrame(new b.Frame(r, p, q, d, e, "", s)), PIXI.TextureCache[s] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
- x: p,
- y: q,
- width: d,
- height: e
- }), p += d + h, p + d > j && (p = g, q += e + h)
- }
- return o
- },
- JSONData: function(a, c, d) {
- if (!c.frames) return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"), void console.log(c);
- for (var e, f = new b.FrameData, g = c.frames, h = 0; h < g.length; h++) {
- var i = a.rnd.uuid();
- 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], {
- x: g[h].frame.x,
- y: g[h].frame.y,
- width: g[h].frame.w,
- height: g[h].frame.h
- }), 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)
- }
- return f
- },
- JSONDataHash: function(a, c, d) {
- if (!c.frames) return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"), void console.log(c);
- var e, f = new b.FrameData,
- g = c.frames,
- h = 0;
- for (var i in g) {
- var j = a.rnd.uuid();
- 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], {
- x: g[i].frame.x,
- y: g[i].frame.y,
- width: g[i].frame.w,
- height: g[i].frame.h
- }), 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++
- }
- return f
- },
- XMLData: function(a, c, d) {
- if (!c.getElementsByTagName("TextureAtlas")) return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
- 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], {
- x: i,
- y: j,
- width: k,
- height: l
- }), (null !== m || null !== n) && e.setTrim(!0, k, l, m, n, o, p);
- return q
- }
- }, b.Cache = function(a) {
- 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
- }, 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 = {
- addCanvas: function(a, b, c) {
- this._canvases[a] = {
- canvas: b,
- context: c
- }
- },
- addBinary: function(a, b) {
- this._binary[a] = b
- },
- addBitmapData: function(a, b, c) {
- return b.key = a, this._bitmapDatas[a] = {
- data: b,
- frameData: c
- }, b
- },
- addRenderTexture: function(a, c) {
- var d = new b.Frame(0, 0, 0, c.width, c.height, "", "");
- this._textures[a] = {
- texture: c,
- frame: d
- }
- },
- addSpriteSheet: function(a, c, d, e, f, g, h, i) {
- this._images[a] = {
- url: c,
- data: d,
- frameWidth: e,
- frameHeight: f,
- margin: h,
- spacing: i
- }, 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]
- },
- addTilemap: function(a, b, c, d) {
- this._tilemaps[a] = {
- url: b,
- data: c,
- format: d
- }, this._urlMap[this._resolveUrl(b)] = this._tilemaps[a]
- },
- addTextureAtlas: function(a, c, d, e, f) {
- this._images[a] = {
- url: c,
- data: d
- }, 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]
- },
- addBitmapFont: function(a, c, d, e, f, g) {
- this._images[a] = {
- url: c,
- data: d
- }, 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]
- },
- addPhysicsData: function(a, b, c, d) {
- this._physics[a] = {
- url: b,
- data: c,
- format: d
- }, this._urlMap[this._resolveUrl(b)] = this._physics[a]
- },
- addDefaultImage: function() {
- var a = new Image;
- a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==", this._images.__default = {
- url: null,
- data: a
- }, 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)
- },
- addMissingImage: function() {
- var a = new Image;
- a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==", this._images.__missing = {
- url: null,
- data: a
- }, 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)
- },
- addText: function(a, b, c) {
- this._text[a] = {
- url: b,
- data: c
- }, this._urlMap[this._resolveUrl(b)] = this._text[a]
- },
- addJSON: function(a, b, c) {
- this._json[a] = {
- url: b,
- data: c
- }, this._urlMap[this._resolveUrl(b)] = this._json[a]
- },
- addXML: function(a, b, c) {
- this._xml[a] = {
- url: b,
- data: c
- }
- },
- addImage: function(a, c, d) {
- this._images[a] = {
- url: c,
- data: d
- }, 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]
- },
- addSound: function(a, b, c, d, e) {
- d = d || !0, e = e || !1;
- var f = !1;
- e && (f = !0), this._sounds[a] = {
- url: b,
- data: c,
- isDecoding: !1,
- decoded: f,
- webAudio: d,
- audioTag: e,
- locked: this.game.sound.touchLocked
- }, this._urlMap[this._resolveUrl(b)] = this._sounds[a]
- },
- reloadSound: function(a) {
- var b = this;
- this._sounds[a] && (this._sounds[a].data.src = this._sounds[a].url, this._sounds[a].data.addEventListener("canplaythrough", function() {
- return b.reloadSoundComplete(a)
- }, !1), this._sounds[a].data.load())
- },
- reloadSoundComplete: function(a) {
- this._sounds[a] && (this._sounds[a].locked = !1, this.onSoundUnlock.dispatch(a))
- },
- updateSound: function(a, b, c) {
- this._sounds[a] && (this._sounds[a][b] = c)
- },
- decodedSound: function(a, b) {
- this._sounds[a].data = b, this._sounds[a].decoded = !0, this._sounds[a].isDecoding = !1
- },
- getCanvas: function(a) {
- return this._canvases[a] ? this._canvases[a].canvas : void console.warn('Phaser.Cache.getCanvas: Invalid key: "' + a + '"')
- },
- getBitmapData: function(a) {
- return this._bitmapDatas[a] ? this._bitmapDatas[a].data : void console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + a + '"')
- },
- getBitmapFont: function(a) {
- return this._bitmapFont[a] ? this._bitmapFont[a] : void console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + a + '"')
- },
- getPhysicsData: function(a, b, c) {
- if ("undefined" == typeof b || null === b) {
- if (this._physics[a]) return this._physics[a].data;
- console.warn('Phaser.Cache.getPhysicsData: Invalid key: "' + a + '"')
- } else if (this._physics[a] && this._physics[a].data[b]) {
- var d = this._physics[a].data[b];
- if (!d || !c) return d;
- for (var e in d)
- if (e = d[e], e.fixtureKey === c) return e;
- console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "' + c + " in " + a + '"')
- } else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + a + " / " + b + '"');
- return null
- },
- checkKey: function(a, b) {
- return this._cacheMap[a][b] ? !0 : !1
- },
- checkCanvasKey: function(a) {
- return this.checkKey(b.Cache.CANVAS, a)
- },
- checkImageKey: function(a) {
- return this.checkKey(b.Cache.IMAGE, a)
- },
- checkTextureKey: function(a) {
- return this.checkKey(b.Cache.TEXTURE, a)
- },
- checkSoundKey: function(a) {
- return this.checkKey(b.Cache.SOUND, a)
- },
- checkTextKey: function(a) {
- return this.checkKey(b.Cache.TEXT, a)
- },
- checkPhysicsKey: function(a) {
- return this.checkKey(b.Cache.PHYSICS, a)
- },
- checkTilemapKey: function(a) {
- return this.checkKey(b.Cache.TILEMAP, a)
- },
- checkBinaryKey: function(a) {
- return this.checkKey(b.Cache.BINARY, a)
- },
- checkBitmapDataKey: function(a) {
- return this.checkKey(b.Cache.BITMAPDATA, a)
- },
- checkBitmapFontKey: function(a) {
- return this.checkKey(b.Cache.BITMAPFONT, a)
- },
- checkJSONKey: function(a) {
- return this.checkKey(b.Cache.JSON, a)
- },
- checkXMLKey: function(a) {
- return this.checkKey(b.Cache.XML, a)
- },
- checkUrl: function(a) {
- return this._urlMap[this._resolveUrl(a)] ? !0 : !1
- },
- getImage: function(a) {
- return this._images[a] ? this._images[a].data : (console.warn('Phaser.Cache.getImage: Invalid key: "' + a + '"'), null)
- },
- getTilemapData: function(a) {
- return this._tilemaps[a] ? this._tilemaps[a] : void console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + a + '"')
- },
- getFrameData: function(a, c) {
- return "undefined" == typeof c && (c = b.Cache.IMAGE), this._cacheMap[c][a] ? this._cacheMap[c][a].frameData : null
- },
- updateFrameData: function(a, b) {
- this._images[a] && (this._images[a].frameData = b)
- },
- getFrameByIndex: function(a, b) {
- return this._images[a] ? this._images[a].frameData.getFrame(b) : null
- },
- getFrameByName: function(a, b) {
- return this._images[a] ? this._images[a].frameData.getFrameByName(b) : null
- },
- getFrame: function(a) {
- return this._images[a] ? this._images[a].frame : null
- },
- getTextureFrame: function(a) {
- return this._textures[a] ? this._textures[a].frame : null
- },
- getTexture: function(a) {
- return this._textures[a] ? this._textures[a] : void console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"')
- },
- getSound: function(a) {
- return this._sounds[a] ? this._sounds[a] : void console.warn('Phaser.Cache.getSound: Invalid key: "' + a + '"')
- },
- getSoundData: function(a) {
- return this._sounds[a] ? this._sounds[a].data : void console.warn('Phaser.Cache.getSoundData: Invalid key: "' + a + '"')
- },
- isSoundDecoded: function(a) {
- return this._sounds[a] ? this._sounds[a].decoded : void 0
- },
- isSoundReady: function(a) {
- return this._sounds[a] && this._sounds[a].decoded && this.game.sound.touchLocked === !1
- },
- getFrameCount: function(a) {
- return this._images[a] ? this._images[a].frameData.total : 0
- },
- getText: function(a) {
- return this._text[a] ? this._text[a].data : void console.warn('Phaser.Cache.getText: Invalid key: "' + a + '"')
- },
- getJSON: function(a) {
- return this._json[a] ? this._json[a].data : void console.warn('Phaser.Cache.getJSON: Invalid key: "' + a + '"')
- },
- getXML: function(a) {
- return this._xml[a] ? this._xml[a].data : void console.warn('Phaser.Cache.getXML: Invalid key: "' + a + '"')
- },
- getBinary: function(a) {
- return this._binary[a] ? this._binary[a] : void console.warn('Phaser.Cache.getBinary: Invalid key: "' + a + '"')
- },
- getUrl: function(a) {
- return this._urlMap[this._resolveUrl(a)] ? this._urlMap[this._resolveUrl(a)] : void console.warn('Phaser.Cache.getUrl: Invalid url: "' + a + '"')
- },
- getKeys: function(a) {
- var c = null;
- switch (a) {
- case b.Cache.CANVAS:
- c = this._canvases;
- break;
- case b.Cache.IMAGE:
- c = this._images;
- break;
- case b.Cache.TEXTURE:
- c = this._textures;
- break;
- case b.Cache.SOUND:
- c = this._sounds;
- break;
- case b.Cache.TEXT:
- c = this._text;
- break;
- case b.Cache.PHYSICS:
- c = this._physics;
- break;
- case b.Cache.TILEMAP:
- c = this._tilemaps;
- break;
- case b.Cache.BINARY:
- c = this._binary;
- break;
- case b.Cache.BITMAPDATA:
- c = this._bitmapDatas;
- break;
- case b.Cache.BITMAPFONT:
- c = this._bitmapFont;
- break;
- case b.Cache.JSON:
- c = this._json;
- break;
- case b.Cache.XML:
- c = this._xml
- }
- if (c) {
- var d = [];
- for (var e in c) "__default" !== e && "__missing" !== e && d.push(e);
- return d
- }
- },
- removeCanvas: function(a) {
- delete this._canvases[a]
- },
- removeImage: function(a, b) {
- "undefined" == typeof b && (b = !0), delete this._images[a], b && PIXI.BaseTextureCache[a].destroy()
- },
- removeSound: function(a) {
- delete this._sounds[a]
- },
- removeText: function(a) {
- delete this._text[a]
- },
- removeJSON: function(a) {
- delete this._json[a]
- },
- removeXML: function(a) {
- delete this._xml[a]
- },
- removePhysics: function(a) {
- delete this._physics[a]
- },
- removeTilemap: function(a) {
- delete this._tilemaps[a]
- },
- removeBinary: function(a) {
- delete this._binary[a]
- },
- removeBitmapData: function(a) {
- delete this._bitmapDatas[a]
- },
- removeBitmapFont: function(a) {
- delete this._bitmapFont[a]
- },
- _resolveUrl: function(a) {
- return this._urlResolver.src = this.game.load.baseURL + a, this._urlTemp = this._urlResolver.src, this._urlResolver.src = "", this._urlTemp
- },
- destroy: function() {
- for (var a in this._canvases) delete this._canvases[a];
- for (var a in this._images) "__default" !== a && "__missing" !== a && delete this._images[a];
- for (var a in this._sounds) delete this._sounds[a];
- for (var a in this._text) delete this._text[a];
- for (var a in this._json) delete this._json[a];
- for (var a in this._xml) delete this._xml[a];
- for (var a in this._textures) delete this._textures[a];
- for (var a in this._physics) delete this._physics[a];
- for (var a in this._tilemaps) delete this._tilemaps[a];
- for (var a in this._binary) delete this._binary[a];
- for (var a in this._bitmapDatas) delete this._bitmapDatas[a];
- for (var a in this._bitmapFont) delete this._bitmapFont[a];
- this._urlMap = null, this._urlResolver = null, this._urlTemp = null
- }
- }, b.Cache.prototype.constructor = b.Cache, b.Loader = function(a) {
- 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
- }, 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 = {
- setPreloadSprite: function(a, c) {
- c = c || 0, this.preloadSprite = {
- sprite: a,
- direction: c,
- width: a.width,
- height: a.height,
- rect: null
- }, 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
- },
- checkKeyExists: function(a, b) {
- if (this._fileList.length > 0)
- for (var c = 0; c < this._fileList.length; c++)
- if (this._fileList[c].type === a && this._fileList[c].key === b) return !0;
- return !1
- },
- getAssetIndex: function(a, b) {
- if (this._fileList.length > 0)
- for (var c = 0; c < this._fileList.length; c++)
- if (this._fileList[c].type === a && this._fileList[c].key === b) return c;
- return -1
- },
- getAsset: function(a, b) {
- if (this._fileList.length > 0)
- for (var c = 0; c < this._fileList.length; c++)
- if (this._fileList[c].type === a && this._fileList[c].key === b) return {
- index: c,
- file: this._fileList[c]
- };
- return !1
- },
- reset: function() {
- this.preloadSprite = null, this.isLoading = !1, this._packList.length = 0, this._packIndex = 0, this._fileList.length = 0, this._fileIndex = 0
- },
- addToFileList: function(a, b, c, d) {
- var e = {
- type: a,
- key: b,
- url: c,
- data: null,
- error: !1,
- loaded: !1
- };
- if ("undefined" != typeof d)
- for (var f in d) e[f] = d[f];
- this.checkKeyExists(a, b) === !1 && this._fileList.push(e)
- },
- replaceInFileList: function(a, b, c, d) {
- var e = {
- type: a,
- key: b,
- url: c,
- data: null,
- error: !1,
- loaded: !1
- };
- if ("undefined" != typeof d)
- for (var f in d) e[f] = d[f];
- var g = this.getAssetIndex(a, b); - 1 === g ? this._fileList.push(e) : this._fileList[g] = e
- },
- pack: function(a, b, c, d) {
- 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({
- key: a,
- url: b,
- data: c,
- loaded: !1,
- error: !1,
- callbackContext: d
- }), this)
- },
- image: function(a, b, c) {
- return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("image", a, b) : this.addToFileList("image", a, b), this
- },
- text: function(a, b, c) {
- return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("text", a, b) : this.addToFileList("text", a, b), this
- },
- json: function(a, b, c) {
- return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("json", a, b) : this.addToFileList("json", a, b), this
- },
- xml: function(a, b, c) {
- return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("xml", a, b) : this.addToFileList("xml", a, b), this
- },
- script: function(a, b, c, d) {
- return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("script", a, b, {
- callback: c,
- callbackContext: d
- }), this
- },
- binary: function(a, b, c, d) {
- return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("binary", a, b, {
- callback: c,
- callbackContext: d
- }), this
- },
- spritesheet: function(a, b, c, d, e, f, g) {
- return "undefined" == typeof e && (e = -1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), this.addToFileList("spritesheet", a, b, {
- frameWidth: c,
- frameHeight: d,
- frameMax: e,
- margin: f,
- spacing: g
- }), this
- },
- audio: function(a, b, c) {
- return "undefined" == typeof c && (c = !0), this.addToFileList("audio", a, b, {
- buffer: null,
- autoDecode: c
- }), this
- },
- audiosprite: function(a, b, c) {
- return this.audio(a, b), this.json(a + "-audioatlas", c), this
- },
- tilemap: function(a, c, d, e) {
- 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;
- if (d) {
- switch (e) {
- case b.Tilemap.CSV:
- break;
- case b.Tilemap.TILED_JSON:
- "string" == typeof d && (d = JSON.parse(d))
- }
- this.game.cache.addTilemap(a, null, d, e)
- } else this.addToFileList("tilemap", a, c, {
- format: e
- });
- return this
- },
- physics: function(a, c, d, e) {
- 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, {
- format: e
- }), this)
- },
- bitmapFont: function(a, b, c, d, e, f) {
- 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, {
- xmlURL: c,
- xSpacing: e,
- ySpacing: f
- });
- else if ("string" == typeof d) {
- var g;
- try {
- if (window.DOMParser) {
- var h = new DOMParser;
- g = h.parseFromString(d, "text/xml")
- } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(d)
- } catch (i) {
- g = void 0
- }
- if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
- this.addToFileList("bitmapfont", a, b, {
- xmlURL: null,
- xmlData: g,
- xSpacing: e,
- ySpacing: f
- })
- }
- return this
- },
- atlasJSONArray: function(a, c, d, e) {
- return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_ARRAY)
- },
- atlasJSONHash: function(a, c, d, e) {
- return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_HASH)
- },
- atlasXML: function(a, c, d, e) {
- return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_XML_STARLING)
- },
- atlas: function(a, c, d, e, f) {
- 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, {
- atlasURL: d,
- format: f
- });
- else {
- switch (f) {
- case b.Loader.TEXTURE_ATLAS_JSON_ARRAY:
- "string" == typeof e && (e = JSON.parse(e));
- break;
- case b.Loader.TEXTURE_ATLAS_XML_STARLING:
- if ("string" == typeof e) {
- var g;
- try {
- if (window.DOMParser) {
- var h = new DOMParser;
- g = h.parseFromString(e, "text/xml")
- } else g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(e)
- } catch (i) {
- g = void 0
- }
- if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
- e = g
- }
- }
- this.addToFileList("textureatlas", a, c, {
- atlasURL: null,
- atlasData: e,
- format: f
- })
- }
- return this
- },
- removeFile: function(a, b) {
- var c = this.getAsset(a, b);
- c !== !1 && this._fileList.splice(c.index, 1)
- },
- removeAll: function() {
- this._fileList.length = 0
- },
- start: function() {
- this.isLoading || (this._packList.length > 0 ? (this._packIndex = 0, this.loadPack()) : this.beginLoad())
- },
- beginLoad: function() {
- 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())
- },
- loadPack: function() {
- if (!this._packList[this._packIndex]) return void console.warn("Phaser.Loader loadPackList invalid index " + this._packIndex);
- var a = this._packList[this._packIndex];
- null !== a.data ? this.packLoadComplete(this._packIndex, !1) : this.xhrLoad(this._packIndex, this.baseURL + a.url, "text", "packLoadComplete", "packLoadError")
- },
- packLoadComplete: function(a, c) {
- if ("undefined" == typeof c && (c = !0), !this._packList[a]) return void console.warn("Phaser.Loader packLoadComplete invalid index " + a);
- var d = this._packList[a];
- if (d.loaded = !0, c) var e = JSON.parse(this._xhr.responseText);
- else var e = this._packList[a].data;
- if (e[d.key])
- for (var f, g = 0; g < e[d.key].length; g++) switch (f = e[d.key][g], f.type) {
- case "image":
- this.image(f.key, f.url, f.overwrite);
- break;
- case "text":
- this.text(f.key, f.url, f.overwrite);
- break;
- case "json":
- this.json(f.key, f.url, f.overwrite);
- break;
- case "xml":
- this.xml(f.key, f.url, f.overwrite);
- break;
- case "script":
- this.script(f.key, f.url, f.callback, d.callbackContext);
- break;
- case "binary":
- this.binary(f.key, f.url, f.callback, d.callbackContext);
- break;
- case "spritesheet":
- this.spritesheet(f.key, f.url, f.frameWidth, f.frameHeight, f.frameMax, f.margin, f.spacing);
- break;
- case "audio":
- this.audio(f.key, f.urls, f.autoDecode);
- break;
- case "tilemap":
- this.tilemap(f.key, f.url, f.data, b.Tilemap[f.format]);
- break;
- case "physics":
- this.physics(f.key, f.url, f.data, b.Loader[f.format]);
- break;
- case "bitmapFont":
- this.bitmapFont(f.key, f.textureURL, f.xmlURL, f.xmlData, f.xSpacing, f.ySpacing);
- break;
- case "atlasJSONArray":
- this.atlasJSONArray(f.key, f.textureURL, f.atlasURL, f.atlasData);
- break;
- case "atlasJSONHash":
- this.atlasJSONHash(f.key, f.textureURL, f.atlasURL, f.atlasData);
- break;
- case "atlasXML":
- this.atlasXML(f.key, f.textureURL, f.atlasURL, f.atlasData);
- break;
- case "atlas":
- this.atlas(f.key, f.textureURL, f.atlasURL, f.atlasData, b.Loader[f.format])
- }
- this.nextPack(a, !0)
- },
- packError: function(a) {
- 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)
- },
- nextPack: function(a, b) {
- this.onPackComplete.dispatch(this._packList[a].key, b, this.totalLoadedPacks(), this._packList.length), this._packIndex++, this._packIndex < this._packList.length ? this.loadPack() : this.beginLoad()
- },
- loadFile: function() {
- if (!this._fileList[this._fileIndex]) return void console.warn("Phaser.Loader loadFile invalid index " + this._fileIndex);
- var a = this._fileList[this._fileIndex],
- c = this;
- switch (this.onFileStart.dispatch(this.progress, a.key, a.url), a.type) {
- case "image":
- case "spritesheet":
- case "textureatlas":
- case "bitmapfont":
- a.data = new Image, a.data.name = a.key, a.data.onload = function() {
- return c.fileComplete(c._fileIndex)
- }, a.data.onerror = function() {
- return c.fileError(c._fileIndex)
- }, this.crossOrigin && (a.data.crossOrigin = this.crossOrigin), a.data.src = this.baseURL + a.url;
- break;
- case "audio":
- 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() {
- return c.fileError(c._fileIndex)
- }, a.data.preload = "auto", a.data.src = this.baseURL + a.url, a.data.addEventListener("canplaythrough", function() {
- b.GAMES[c.game.id].load.fileComplete(c._fileIndex)
- }, !1), a.data.load())) : this.fileError(this._fileIndex);
- break;
- case "json":
- this.useXDomainRequest && window.XDomainRequest ? (this._ajax = new window.XDomainRequest, this._ajax.timeout = 3e3, this._ajax.onerror = function() {
- return c.dataLoadError(c._fileIndex)
- }, this._ajax.ontimeout = function() {
- return c.dataLoadError(c._fileIndex)
- }, this._ajax.onprogress = function() {}, this._ajax.onload = function() {
- return c.jsonLoadComplete(c._fileIndex)
- }, this._ajax.open("GET", this.baseURL + a.url, !0), setTimeout(function() {
- this._ajax.send()
- }, 0)) : this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
- break;
- case "xml":
- this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "xmlLoadComplete", "dataLoadError");
- break;
- case "tilemap":
- if (a.format === b.Tilemap.TILED_JSON) this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
- else {
- if (a.format !== b.Tilemap.CSV) throw new Error("Phaser.Loader. Invalid Tilemap format: " + a.format);
- this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "csvLoadComplete", "dataLoadError")
- }
- break;
- case "text":
- case "script":
- case "physics":
- this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "fileComplete", "fileError");
- break;
- case "binary":
- this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError")
- }
- },
- xhrLoad: function(a, b, c, d, e) {
- this._xhr.open("GET", b, !0), this._xhr.responseType = c;
- var f = this;
- this._xhr.onload = function() {
- return f[d](a)
- }, this._xhr.onerror = function() {
- return f[e](a)
- }, this._xhr.send()
- },
- getAudioURL: function(a) {
- var b;
- "string" == typeof a && (a = [a]);
- for (var c = 0; c < a.length; c++)
- 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];
- return null
- },
- fileError: function(a) {
- 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)
- },
- fileComplete: function(a) {
- if (!this._fileList[a]) return void console.warn("Phaser.Loader fileComplete invalid index " + a);
- var c = this._fileList[a];
- c.loaded = !0;
- var d = !0;
- switch (c.type) {
- case "image":
- this.game.cache.addImage(c.key, c.url, c.data);
- break;
- case "spritesheet":
- this.game.cache.addSpriteSheet(c.key, c.url, c.data, c.frameWidth, c.frameHeight, c.frameMax, c.margin, c.spacing);
- break;
- case "textureatlas":
- if (null == c.atlasURL) this.game.cache.addTextureAtlas(c.key, c.url, c.data, c.atlasData, c.format);
- 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");
- else {
- if (c.format != b.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + c.format);
- this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "xmlLoadComplete", "dataLoadError")
- }
- break;
- case "bitmapfont":
- 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"));
- break;
- case "audio":
- if (this.game.sound.usingWebAudio) {
- if (c.data = this._xhr.response, this.game.cache.addSound(c.key, c.url, c.data, !0, !1), c.autoDecode) {
- var e = this,
- f = c.key;
- this.game.cache.updateSound(f, "isDecoding", !0), this.game.sound.context.decodeAudioData(c.data, function(a) {
- a && (e.game.cache.decodedSound(f, a), e.game.sound.onSoundDecode.dispatch(f, e.game.cache.getSound(f)))
- })
- }
- } else c.data.removeEventListener("canplaythrough", b.GAMES[this.game.id].load.fileComplete), this.game.cache.addSound(c.key, c.url, c.data, !1, !0);
- break;
- case "text":
- c.data = this._xhr.responseText, this.game.cache.addText(c.key, c.url, c.data);
- break;
- case "physics":
- var g = JSON.parse(this._xhr.responseText);
- this.game.cache.addPhysicsData(c.key, c.url, g, c.format);
- break;
- case "script":
- 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));
- break;
- case "binary":
- 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)
- }
- d && this.nextFile(a, !0)
- },
- jsonLoadComplete: function(a) {
- if (!this._fileList[a]) return void console.warn("Phaser.Loader jsonLoadComplete invalid index " + a);
- var b = this._fileList[a];
- if (this._ajax && this._ajax.responseText) var c = JSON.parse(this._ajax.responseText);
- else var c = JSON.parse(this._xhr.responseText);
- b.loaded = !0, "tilemap" === b.type ? this.game.cache.addTilemap(b.key, b.url, c, b.format) : "json" === b.type ? this.game.cache.addJSON(b.key, b.url, c) : this.game.cache.addTextureAtlas(b.key, b.url, b.data, c, b.format), this.nextFile(a, !0)
- },
- csvLoadComplete: function(a) {
- if (!this._fileList[a]) return void console.warn("Phaser.Loader csvLoadComplete invalid index " + a);
- var b = this._fileList[a],
- c = this._xhr.responseText;
- b.loaded = !0, this.game.cache.addTilemap(b.key, b.url, c, b.format), this.nextFile(a, !0)
- },
- dataLoadError: function(a) {
- var b = this._fileList[a];
- b.loaded = !0, b.error = !0, console.warn("Phaser.Loader dataLoadError: " + b.key), this.nextFile(a, !0)
- },
- xmlLoadComplete: function(a) {
- "" !== this._xhr.responseType && "text" !== this._xhr.responseType && (console.warn("Invalid XML Response Type", this._fileList[a]), console.warn(this._xhr));
- var b, c = this._xhr.responseText;
- try {
- if (window.DOMParser) {
- var d = new DOMParser;
- b = d.parseFromString(c, "text/xml")
- } else b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(c)
- } catch (e) {
- b = void 0
- }
- if (!b || !b.documentElement || b.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid XML given");
- var f = this._fileList[a];
- 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)
- },
- nextFile: function(a, b) {
- 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())
- },
- totalLoadedFiles: function() {
- for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded && a++;
- return a
- },
- totalQueuedFiles: function() {
- for (var a = 0, b = 0; b < this._fileList.length; b++) this._fileList[b].loaded === !1 && a++;
- return a
- },
- totalLoadedPacks: function() {
- for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded && a++;
- return a
- },
- totalQueuedPacks: function() {
- for (var a = 0, b = 0; b < this._packList.length; b++) this._packList[b].loaded === !1 && a++;
- return a
- }
- }, b.Loader.prototype.constructor = b.Loader, b.LoaderParser = {
- bitmapFont: function(a, b, c, d, e) {
- var f = {},
- g = b.getElementsByTagName("info")[0],
- h = b.getElementsByTagName("common")[0];
- f.font = g.getAttribute("face"), f.size = parseInt(g.getAttribute("size"), 10), f.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + e, f.chars = {};
- for (var i = b.getElementsByTagName("char"), j = 0; j < i.length; j++) {
- var k = parseInt(i[j].getAttribute("id"), 10),
- l = new PIXI.Rectangle(parseInt(i[j].getAttribute("x"), 10), parseInt(i[j].getAttribute("y"), 10), parseInt(i[j].getAttribute("width"), 10), parseInt(i[j].getAttribute("height"), 10));
- f.chars[k] = {
- xOffset: parseInt(i[j].getAttribute("xoffset"), 10),
- yOffset: parseInt(i[j].getAttribute("yoffset"), 10),
- xAdvance: parseInt(i[j].getAttribute("xadvance"), 10) + d,
- kerning: {},
- texture: PIXI.TextureCache[c] = new PIXI.Texture(PIXI.BaseTextureCache[c], l)
- }
- }
- var m = b.getElementsByTagName("kerning");
- for (j = 0; j < m.length; j++) {
- var n = parseInt(m[j].getAttribute("first"), 10),
- o = parseInt(m[j].getAttribute("second"), 10),
- p = parseInt(m[j].getAttribute("amount"), 10);
- f.chars[o].kerning[n] = p
- }
- PIXI.BitmapText.fonts[c] = f
- }
- }, b.AudioSprite = function(a, b) {
- this.game = a, this.key = b, this.config = this.game.cache.getJSON(b + "-audioatlas"), this.autoplayKey = null, this.autoplay = !1, this.sounds = {};
- for (var c in this.config.spritemap) {
- var d = this.config.spritemap[c],
- e = this.game.add.sound(this.key);
- 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
- }
- this.config.autoplay && (this.autoplayKey = this.config.autoplay, this.play(this.autoplayKey), this.autoplay = this.sounds[this.autoplayKey])
- }, b.AudioSprite.prototype = {
- play: function(a, b) {
- return "undefined" == typeof b && (b = 1), this.sounds[a].play(a, null, b)
- },
- stop: function(a) {
- if (a) this.sounds[a].stop();
- else
- for (var b in this.sounds) this.sounds[b].stop()
- },
- get: function(a) {
- return this.sounds[a]
- }
- }, b.AudioSprite.prototype.constructor = b.AudioSprite, b.Sound = function(a, c, d, e, f) {
- "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
- }, b.Sound.prototype = {
- soundHasUnlocked: function(a) {
- a === this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration)
- },
- addMarker: function(a, b, c, d, e) {
- "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), this.markers[a] = {
- name: a,
- start: b,
- stop: b + c,
- volume: d,
- duration: c,
- durationMS: 1e3 * c,
- loop: e
- }
- },
- removeMarker: function(a) {
- delete this.markers[a]
- },
- update: function() {
- 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()))
- },
- play: function(a, b, c, d, e) {
- if ("undefined" == typeof a && (a = ""), "undefined" == typeof e && (e = !0), this.isPlaying && !this.allowMultiple && !e && !this.override) return this;
- 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) {
- if (!this.markers[a]) return console.warn("Phaser.Sound.play: audio marker " + a + " doesn't exist"), this;
- 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
- } 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;
- 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
- },
- restart: function(a, b, c, d) {
- a = a || "", b = b || 0, c = c || 1, "undefined" == typeof d && (d = !1), this.play(a, b, c, d, !0)
- },
- pause: function() {
- this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.now, this.onPause.dispatch(this), this.stop())
- },
- resume: function() {
- if (this.paused && this._sound) {
- if (this.usingWebAudio) {
- var a = this.position + this.pausedPosition / 1e3;
- 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)
- } else this._sound.play();
- this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.now - this.pausedTime, this.onResume.dispatch(this)
- }
- },
- stop: function() {
- if (this.isPlaying && this._sound)
- if (this.usingWebAudio)
- if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
- else try {
- this._sound.stop(0)
- } catch (a) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
- this.isPlaying = !1;
- var b = this.currentMarker;
- "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", this.paused || this.onStop.dispatch(this, b)
- },
- fadeIn: function(a, b) {
- "undefined" == typeof b && (b = !1), this.paused || (this.play("", 0, 0, b), this.fadeTo(a, 1))
- },
- fadeOut: function(a) {
- this.fadeTo(a, 0)
- },
- fadeTo: function(a, c) {
- if (this.isPlaying && !this.paused && c !== this.volume) {
- if ("undefined" == typeof a && (a = 1e3), "undefined" == typeof c) return void console.warn("Phaser.Sound.fadeTo: No Volume Specified.");
- var d = this.game.add.tween(this).to({
- volume: c
- }, a, b.Easing.Linear.None, !0);
- d.onComplete.add(this.fadeComplete, this)
- }
- },
- fadeComplete: function() {
- this.onFadeComplete.dispatch(this, this.volume), 0 === this.volume && this.stop()
- },
- destroy: function(a) {
- "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())
- }
- }, b.Sound.prototype.constructor = b.Sound, Object.defineProperty(b.Sound.prototype, "isDecoding", {
- get: function() {
- return this.game.cache.getSound(this.key).isDecoding
- }
- }), Object.defineProperty(b.Sound.prototype, "isDecoded", {
- get: function() {
- return this.game.cache.isSoundDecoded(this.key)
- }
- }), Object.defineProperty(b.Sound.prototype, "mute", {
- get: function() {
- return this._muted || this.game.sound.mute
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(b.Sound.prototype, "volume", {
- get: function() {
- return this._volume
- },
- set: function(a) {
- 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)
- }
- }), b.SoundManager = function(a) {
- 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
- }, b.SoundManager.prototype = {
- boot: function() {
- 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) {
- if (window.PhaserGlobal.disableAudio === !0) return this.usingWebAudio = !1, void(this.noAudio = !0);
- if (window.PhaserGlobal.disableWebAudio === !0) return this.usingWebAudio = !1, this.usingAudioTag = !0, void(this.noAudio = !1)
- }
- if (window.AudioContext) try {
- this.context = new window.AudioContext
- } catch (a) {
- this.context = null, this.usingWebAudio = !1, this.noAudio = !0
- } else if (window.webkitAudioContext) try {
- this.context = new window.webkitAudioContext
- } catch (a) {
- this.context = null, this.usingWebAudio = !1, this.noAudio = !0
- }
- 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))
- },
- unlock: function() {
- if (this.touchLocked !== !1)
- 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;
- else {
- var a = this.context.createBuffer(1, 1, 22050);
- this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = a, this._unlockSource.connect(this.context.destination), this._unlockSource.noteOn(0)
- }
- },
- stopAll: function() {
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].stop()
- },
- pauseAll: function() {
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].pause()
- },
- resumeAll: function() {
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].resume()
- },
- decode: function(a, b) {
- b = b || null;
- var c = this.game.cache.getSoundData(a);
- if (c && this.game.cache.isSoundDecoded(a) === !1) {
- this.game.cache.updateSound(a, "isDecoding", !0);
- var d = this;
- this.context.decodeAudioData(c, function(c) {
- d.game.cache.decodedSound(a, c), b && d.onSoundDecode.dispatch(a, b)
- })
- }
- },
- update: function() {
- 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);
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a].update()
- },
- add: function(a, c, d, e) {
- "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = this.connectToMaster);
- var f = new b.Sound(this.game, a, c, d, e);
- return this._sounds.push(f), f
- },
- addSprite: function(a) {
- var c = new b.AudioSprite(this.game, a);
- return c
- },
- remove: function(a) {
- for (var b = this._sounds.length; b--;)
- if (this._sounds[b] === a) return this._sounds[b].destroy(!1), this._sounds.splice(b, 1), !0;
- return !1
- },
- removeByKey: function(a) {
- 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++);
- return c
- },
- play: function(a, b, c) {
- var d = this.add(a, b, c);
- return d.play(), d
- },
- setMute: function() {
- if (!this._muted) {
- this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !0)
- }
- },
- unsetMute: function() {
- if (this._muted && !this._codeMuted) {
- this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !1)
- }
- },
- destroy: function() {
- this.stopAll();
- for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].destroy();
- this._sounds = [], this.onSoundDecode.dispose()
- }
- }, b.SoundManager.prototype.constructor = b.SoundManager, Object.defineProperty(b.SoundManager.prototype, "mute", {
- get: function() {
- return this._muted
- },
- set: function(a) {
- if (a = a || null) {
- if (this._muted) return;
- this._codeMuted = !0, this.setMute()
- } else {
- if (!this._muted) return;
- this._codeMuted = !1, this.unsetMute()
- }
- }
- }), Object.defineProperty(b.SoundManager.prototype, "volume", {
- get: function() {
- return this.usingWebAudio ? this.masterGain.gain.value : this._volume
- },
- set: function(a) {
- if (this._volume = a, this.usingWebAudio) this.masterGain.gain.value = a;
- else
- for (var b = 0; b < this._sounds.length; b++) this._sounds[b].usingAudioTag && (this._sounds[b].volume = this._sounds[b].volume * a)
- }
- }), b.Utils.Debug = function(a) {
- 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
- }, b.Utils.Debug.prototype = {
- boot: function() {
- 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"))
- },
- preUpdate: function() {
- 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)
- },
- reset: function() {
- this.context && this.context.clearRect(0, 0, this.game.width, this.game.height), this.sprite && this.bmd.clear()
- },
- start: function(a, b, c, d) {
- "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
- },
- stop: function() {
- this.context.restore(), this.context.globalAlpha = this.currentAlpha
- },
- line: function() {
- 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;
- this.currentY += this.lineHeight
- },
- soundInfo: function(a, b, c, d) {
- 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()
- },
- cameraInfo: function(a, b, c, d) {
- 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()
- },
- timer: function(a, b, c, d) {
- 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()
- },
- pointer: function(a, b, c, d, e) {
- 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()))
- },
- spriteInputInfo: function(a, b, c, d) {
- 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()
- },
- key: function(a, b, c, d) {
- 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()
- },
- inputInfo: function(a, b, c) {
- 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()
- },
- spriteBounds: function(a, b, c) {
- var d = a.getBounds();
- d.x += this.game.camera.x, d.y += this.game.camera.y, this.rectangle(d, b, c)
- },
- ropeSegments: function(a, b, c) {
- var d = a.segments;
- d.forEach(function(a) {
- this.rectangle(a, b, c)
- }, this)
- },
- spriteInfo: function(a, b, c, d) {
- 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()
- },
- spriteCoords: function(a, b, c, d) {
- 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()
- },
- lineInfo: function(a, b, c, d) {
- 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()
- },
- pixel: function(a, b, c, d) {
- d = d || 2, this.start(), this.context.fillStyle = c, this.context.fillRect(a, b, d, d), this.stop()
- },
- geom: function(a, c, d, e) {
- "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()
- },
- rectangle: function(a, b, c) {
- "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()
- },
- text: function(a, b, c, d, e) {
- 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()
- },
- quadTree: function(a, b) {
- b = b || "rgba(255,0,0,0.3)", this.start();
- var c = a.bounds;
- if (0 === a.nodes.length) {
- 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)";
- 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)
- } else
- for (var d = 0; d < a.nodes.length; d++) this.quadTree(a.nodes[d]);
- this.stop()
- },
- body: function(a, c, d) {
- 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())
- },
- bodyInfo: function(a, c, d, e) {
- 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())
- },
- box2dWorld: function() {
- 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()
- },
- box2dBody: function(a, c) {
- this.start(), b.Physics.Box2D.renderBody(this.context, a, c), this.stop()
- }
- }, b.Utils.Debug.prototype.constructor = b.Utils.Debug, b.Color = {
- packPixel: function(a, c, d, e) {
- return b.Device.LITTLE_ENDIAN ? (e << 24 | d << 16 | c << 8 | a) >>> 0 : (a << 24 | c << 16 | d << 8 | e) >>> 0
- },
- unpackPixel: function(a, c, d, e) {
- 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
- },
- fromRGBA: function(a, c) {
- 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
- },
- toRGBA: function(a, b, c, d) {
- return a << 24 | b << 16 | c << 8 | d
- },
- RGBtoHSL: function(a, c, d, e) {
- e || (e = b.Color.createColor(a, c, d, 1)), a /= 255, c /= 255, d /= 255;
- var f = Math.min(a, c, d),
- g = Math.max(a, c, d);
- if (e.h = 0, e.s = 0, e.l = (g + f) / 2, g !== f) {
- var h = g - f;
- e.s = e.l > .5 ? h / (2 - g - f) : h / (g + f), g === a ? e.h = (c - d) / h + (d > c ? 6 : 0) : g === c ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - c) / h + 4), e.h /= 6
- }
- return e
- },
- HSLtoRGB: function(a, c, d, e) {
- if (e ? (e.r = d, e.g = d, e.b = d) : e = b.Color.createColor(d, d, d), 0 !== c) {
- var f = .5 > d ? d * (1 + c) : d + c - d * c,
- g = 2 * d - f;
- e.r = b.Color.hueToColor(g, f, a + 1 / 3), e.g = b.Color.hueToColor(g, f, a), e.b = b.Color.hueToColor(g, f, a - 1 / 3)
- }
- 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
- },
- RGBtoHSV: function(a, c, d, e) {
- e || (e = b.Color.createColor(a, c, d, 255)), a /= 255, c /= 255, d /= 255;
- var f = Math.min(a, c, d),
- g = Math.max(a, c, d),
- h = g - f;
- 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
- },
- HSVtoRGB: function(a, c, d, e) {
- "undefined" == typeof e && (e = b.Color.createColor(0, 0, 0, 1, a, c, 0, d));
- var f, g, h, i = Math.floor(6 * a),
- j = 6 * a - i,
- k = d * (1 - c),
- l = d * (1 - j * c),
- m = d * (1 - (1 - j) * c);
- switch (i % 6) {
- case 0:
- f = d, g = m, h = k;
- break;
- case 1:
- f = l, g = d, h = k;
- break;
- case 2:
- f = k, g = d, h = m;
- break;
- case 3:
- f = k, g = l, h = d;
- break;
- case 4:
- f = m, g = k, h = d;
- break;
- case 5:
- f = d, g = k, h = l
- }
- return e.r = Math.floor(255 * f), e.g = Math.floor(255 * g), e.b = Math.floor(255 * h), b.Color.updateColor(e), e
- },
- hueToColor: function(a, b, c) {
- 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
- },
- createColor: function(a, c, d, e, f, g, h, i) {
- var j = {
- r: a || 0,
- g: c || 0,
- b: d || 0,
- a: e || 1,
- h: f || 0,
- s: g || 0,
- l: h || 0,
- v: i || 0,
- color: 0,
- color32: 0,
- rgba: ""
- };
- 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)
- },
- updateColor: function(a) {
- return a.rgba = "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + a.a.toString() + ")", a
- },
- getColor32: function(a, b, c, d) {
- return a << 24 | b << 16 | c << 8 | d
- },
- getColor: function(a, b, c) {
- return a << 16 | b << 8 | c
- },
- RGBtoString: function(a, c, d, e, f) {
- 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)
- },
- hexToRGB: function(a) {
- var c = b.Color.hexToColor(a);
- return c ? b.Color.getColor32(c.a, c.r, c.g, c.b) : void 0
- },
- hexToColor: function(a, c) {
- a = a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function(a, b, c, d) {
- return b + b + c + c + d + d
- });
- var d = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
- if (d) {
- var e = parseInt(d[1], 16),
- f = parseInt(d[2], 16),
- g = parseInt(d[3], 16);
- c ? (c.r = e, c.g = f, c.b = g) : c = b.Color.createColor(e, f, g)
- }
- return c
- },
- webToColor: function(a, c) {
- c || (c = b.Color.createColor());
- var d = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/.exec(a);
- return d && (c.r = parseInt(d[1], 10), c.g = parseInt(d[2], 10), c.b = parseInt(d[3], 10)), c
- },
- componentToHex: function(a) {
- var b = a.toString(16);
- return 1 == b.length ? "0" + b : b
- },
- HSVColorWheel: function(a, c) {
- "undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1);
- for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSVtoRGB(e / 359, a, c));
- return d
- },
- HSLColorWheel: function(a, c) {
- "undefined" == typeof a && (a = .5), "undefined" == typeof c && (c = .5);
- for (var d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSLtoRGB(e / 359, a, c));
- return d
- },
- interpolateColor: function(a, c, d, e, f) {
- "undefined" == typeof f && (f = 255);
- var g = b.Color.getRGB(a),
- h = b.Color.getRGB(c),
- i = (h.red - g.red) * e / d + g.red,
- j = (h.green - g.green) * e / d + g.green,
- k = (h.blue - g.blue) * e / d + g.blue;
- return b.Color.getColor32(f, i, j, k)
- },
- interpolateColorWithRGB: function(a, c, d, e, f, g) {
- var h = b.Color.getRGB(a),
- i = (c - h.red) * g / f + h.red,
- j = (d - h.green) * g / f + h.green,
- k = (e - h.blue) * g / f + h.blue;
- return b.Color.getColor(i, j, k)
- },
- interpolateRGB: function(a, c, d, e, f, g, h, i) {
- var j = (e - a) * i / h + a,
- k = (f - c) * i / h + c,
- l = (g - d) * i / h + d;
- return b.Color.getColor(j, k, l)
- },
- getRandomColor: function(a, c, d) {
- 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);
- var e = a + Math.round(Math.random() * (c - a)),
- f = a + Math.round(Math.random() * (c - a)),
- g = a + Math.round(Math.random() * (c - a));
- return b.Color.getColor32(d, e, f, g)
- },
- getRGB: function(a) {
- return a > 16777215 ? {
- alpha: a >>> 24,
- red: a >> 16 & 255,
- green: a >> 8 & 255,
- blue: 255 & a,
- a: a >>> 24,
- r: a >> 16 & 255,
- g: a >> 8 & 255,
- b: 255 & a
- } : {
- alpha: 255,
- red: a >> 16 & 255,
- green: a >> 8 & 255,
- blue: 255 & a,
- a: 255,
- r: a >> 16 & 255,
- g: a >> 8 & 255,
- b: 255 & a
- }
- },
- getWebRGB: function(a) {
- if ("object" == typeof a) return "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + (a.a / 255).toString() + ")";
- var c = b.Color.getRGB(a);
- return "rgba(" + c.r.toString() + "," + c.g.toString() + "," + c.b.toString() + "," + (c.a / 255).toString() + ")"
- },
- getAlpha: function(a) {
- return a >>> 24
- },
- getAlphaFloat: function(a) {
- return (a >>> 24) / 255
- },
- getRed: function(a) {
- return a >> 16 & 255
- },
- getGreen: function(a) {
- return a >> 8 & 255
- },
- getBlue: function(a) {
- return 255 & a
- }
- }, b.Physics = function(a, b) {
- 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()
- }, b.Physics.ARCADE = 0, b.Physics.P2JS = 1, b.Physics.NINJA = 2, b.Physics.BOX2D = 3, b.Physics.CHIPMUNK = 4, b.Physics.prototype = {
- parseConfig: function() {
- 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))
- },
- startSystem: function(a) {
- 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);
- else if (a === b.Physics.BOX2D && null === this.box2d) this.box2d = new b.Physics.Box2D(this.game, this.config);
- else if (a === b.Physics.CHIPMUNK && null === this.chipmunk) throw new Error("The Chipmunk physics system has not been implemented yet.")
- },
- enable: function(a, c, d) {
- "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)
- },
- preUpdate: function() {
- this.p2 && this.p2.preUpdate(), this.box2d && this.box2d.preUpdate()
- },
- update: function() {
- this.p2 && this.p2.update(), this.box2d && this.box2d.update()
- },
- setBoundsToWorld: function() {
- this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld(), this.box2d && this.box2d.setBoundsToWorld()
- },
- clear: function() {
- this.p2 && this.p2.clear(), this.box2d && this.box2d.clear()
- },
- destroy: function() {
- this.p2 && this.p2.destroy(), this.box2d && this.box2d.destroy(), this.arcade = null, this.ninja = null, this.p2 = null, this.box2d = null
- }
- }, b.Physics.prototype.constructor = b.Physics, b.Physics.Arcade = function(a) {
- this.game = a, this.gravity = new b.Point, this.bounds = new b.Rectangle(0, 0, a.world.width, a.world.height), this.checkCollision = {
- up: !0,
- down: !0,
- left: !0,
- right: !0
- }, 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()
- }, b.Physics.Arcade.prototype.constructor = b.Physics.Arcade, b.Physics.Arcade.prototype = {
- setBounds: function(a, b, c, d) {
- this.bounds.setTo(a, b, c, d)
- },
- setBoundsToWorld: function() {
- this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
- },
- enable: function(a, c) {
- "undefined" == typeof c && (c = !0);
- var d = 1;
- if (Array.isArray(a))
- 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));
- 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))
- },
- enableBody: function(a) {
- a.hasOwnProperty("body") && null === a.body && (a.body = new b.Physics.Arcade.Body(a))
- },
- updateMotion: function(a) {
- 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)
- },
- computeVelocity: function(a, b, c, d, e, f) {
- 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
- },
- overlap: function(a, b, c, d, e) {
- if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, !Array.isArray(a) && Array.isArray(b))
- for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !0);
- else if (Array.isArray(a) && !Array.isArray(b))
- for (var f = 0, g = a.length; g > f; f++) this.collideHandler(a[f], b, c, d, e, !0);
- else if (Array.isArray(a) && Array.isArray(b))
- for (var f = 0, g = a.length; g > f; f++)
- for (var h = 0, i = b.length; i > h; h++) this.collideHandler(a[f], b[h], c, d, e, !0);
- else this.collideHandler(a, b, c, d, e, !0);
- return this._total > 0
- },
- collide: function(a, b, c, d, e) {
- if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, !Array.isArray(a) && Array.isArray(b))
- for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !1);
- else if (Array.isArray(a) && !Array.isArray(b))
- for (var f = 0, g = a.length; g > f; f++) this.collideHandler(a[f], b, c, d, e, !1);
- else if (Array.isArray(a) && Array.isArray(b))
- for (var f = 0, h = a.length; h > f; f++)
- for (var i = 0, j = b.length; j > i; i++) this.collideHandler(a[f], b[i], c, d, e, !1);
- else this.collideHandler(a, b, c, d, e, !1);
- return this._total > 0
- },
- collideHandler: function(a, c, d, e, f, g) {
- 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)
- },
- collideSpriteVsSprite: function(a, b, c, d, e, f) {
- return a.body && b.body ? (this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++), !0) : !1
- },
- collideSpriteVsGroup: function(a, b, c, d, e, f) {
- if (0 !== b.length && a.body)
- if (a.body.skipQuadTree || this.skipQuadTree)
- 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);
- else {
- 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);
- 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++)
- }
- },
- collideGroupVsSelf: function(a, b, c, d, e) {
- if (0 !== a.length)
- for (var f = a.children.length, g = 0; f > g; g++)
- 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)
- },
- collideGroupVsGroup: function(a, c, d, e, f, g) {
- if (0 !== a.length && 0 !== c.length)
- 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))
- },
- collideSpriteVsTilemapLayer: function(a, b, c, d, e) {
- 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))
- 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]))
- },
- collideGroupVsTilemapLayer: function(a, b, c, d, e) {
- if (0 !== a.length)
- for (var f = 0, g = a.children.length; g > f; f++) a.children[f].exists && this.collideSpriteVsTilemapLayer(a.children[f], b, c, d, e)
- },
- separate: function(a, b, c, d, e) {
- 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
- },
- intersects: function(a, b) {
- 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
- },
- separateX: function(a, b, c) {
- 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)
- },
- separateY: function(a, b, c) {
- 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)
- },
- separateTile: function(a, b, c) {
- if (!b.enable || !c.intersects(b.position.x, b.position.y, b.right, b.bottom)) return !1;
- if (c.collisionCallback && !c.collisionCallback.call(c.collisionCallbackContext, b.sprite, c)) return !1;
- if (c.layer.callbacks[c.index] && !c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext, b.sprite, c)) return !1;
- if (!(c.faceLeft || c.faceRight || c.faceTop || c.faceBottom)) return !1;
- var d = 0,
- e = 0,
- f = 0,
- g = 1;
- 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) {
- 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;
- (c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c))
- } else {
- 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;
- (c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c))
- }
- return 0 !== d || 0 !== e
- },
- tileCheckX: function(a, b) {
- var c = 0;
- 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
- },
- tileCheckY: function(a, b) {
- var c = 0;
- 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
- },
- processTileSeparationX: function(a, b) {
- 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
- },
- processTileSeparationY: function(a, b) {
- 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
- },
- getObjectsUnderPointer: function(a, c, d, e) {
- if (0 !== c.length && a.exists) {
- 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);
- var f = new b.Rectangle(a.x, a.y, 1, 1),
- g = [];
- this._potentials = this.quadTree.retrieve(f);
- 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));
- return g
- }
- },
- moveToObject: function(a, b, c, d) {
- 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
- },
- moveToPointer: function(a, b, c, d) {
- 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
- },
- moveToXY: function(a, b, c, d, e) {
- 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
- },
- velocityFromAngle: function(a, c, d) {
- 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)
- },
- velocityFromRotation: function(a, c, d) {
- return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
- },
- accelerationFromRotation: function(a, c, d) {
- return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
- },
- accelerateToObject: function(a, b, c, d, e) {
- 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
- },
- accelerateToPointer: function(a, b, c, d, e) {
- 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
- },
- accelerateToXY: function(a, b, c, d, e, f) {
- 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
- },
- distanceBetween: function(a, b) {
- return this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
- },
- distanceToXY: function(a, b, c) {
- return this._dx = a.x - b, this._dy = a.y - c, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
- },
- distanceToPointer: function(a, b) {
- 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)
- },
- angleBetween: function(a, b) {
- return this._dx = b.x - a.x, this._dy = b.y - a.y, Math.atan2(this._dy, this._dx)
- },
- angleToXY: function(a, b, c) {
- return this._dx = b - a.x, this._dy = c - a.y, Math.atan2(this._dy, this._dx)
- },
- angleToPointer: function(a, b) {
- 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)
- }
- }, b.Physics.Arcade.Body = function(a) {
- 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 = {
- none: !1,
- any: !0,
- up: !0,
- down: !0,
- left: !0,
- right: !0
- }, this.touching = {
- none: !0,
- up: !1,
- down: !1,
- left: !1,
- right: !1
- }, this.wasTouching = {
- none: !0,
- up: !1,
- down: !1,
- left: !1,
- right: !1
- }, this.blocked = {
- up: !1,
- down: !1,
- left: !1,
- right: !1
- }, 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
- }, b.Physics.Arcade.Body.prototype = {
- updateBounds: function() {
- var a = Math.abs(this.sprite.scale.x),
- b = Math.abs(this.sprite.scale.y);
- (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)
- },
- preUpdate: function() {
- 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)
- },
- postUpdate: function() {
- 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)
- },
- destroy: function() {
- this.sprite.body = null, this.sprite = null
- },
- checkWorldBounds: function() {
- 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)
- },
- setSize: function(a, b, c, d) {
- "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)
- },
- reset: function(a, b) {
- 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)
- },
- hitTest: function(a, c) {
- return b.Rectangle.contains(this, a, c)
- },
- onFloor: function() {
- return this.blocked.down
- },
- onWall: function() {
- return this.blocked.left || this.blocked.right
- },
- deltaAbsX: function() {
- return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
- },
- deltaAbsY: function() {
- return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
- },
- deltaX: function() {
- return this.position.x - this.prev.x
- },
- deltaY: function() {
- return this.position.y - this.prev.y
- },
- deltaZ: function() {
- return this.rotation - this.preRotation
- }
- }, Object.defineProperty(b.Physics.Arcade.Body.prototype, "bottom", {
- get: function() {
- return this.position.y + this.height
- }
- }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "right", {
- get: function() {
- return this.position.x + this.width
- }
- }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(a) {
- this.position.x = a
- }
- }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(a) {
- this.position.y = a
- }
- }), b.Physics.Arcade.Body.render = function(a, b, c, d) {
- "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))
- }, b.Physics.Arcade.Body.renderBodyInfo = function(a, b) {
- 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)
- }, b.Physics.Arcade.Body.prototype.constructor = b.Physics.Arcade.Body, b.Particles = function(a) {
- this.game = a, this.emitters = {}, this.ID = 0
- }, b.Particles.prototype = {
- add: function(a) {
- return this.emitters[a.name] = a, a
- },
- remove: function(a) {
- delete this.emitters[a.name]
- },
- update: function() {
- for (var a in this.emitters) this.emitters[a].exists && this.emitters[a].update()
- }
- }, b.Particles.prototype.constructor = b.Particles, b.Particles.Arcade = {}, b.Particles.Arcade.Emitter = function(a, c, d, e) {
- 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
- }, 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() {
- if (this.on)
- if (this._explode) {
- this._counter = 0;
- do this.emitParticle(), this._counter++; while (this._counter < this._quantity);
- this.on = !1
- } 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);
- for (var a = this.children.length; a--;) this.children[a].exists && this.children[a].update()
- }, b.Particles.Arcade.Emitter.prototype.makeParticles = function(a, b, c, d, e) {
- "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.maxParticles), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
- var f, g = 0,
- h = a,
- i = b;
- 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++;
- return this
- }, b.Particles.Arcade.Emitter.prototype.kill = function() {
- this.on = !1, this.alive = !1, this.exists = !1
- }, b.Particles.Arcade.Emitter.prototype.revive = function() {
- this.alive = !0, this.exists = !0
- }, b.Particles.Arcade.Emitter.prototype.explode = function(a, b) {
- this.start(!0, a, 0, b, !1)
- }, b.Particles.Arcade.Emitter.prototype.flow = function(a, b, c) {
- this.start(!1, a, b, c, !0)
- }, b.Particles.Arcade.Emitter.prototype.start = function(a, b, c, d, e) {
- "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
- }, b.Particles.Arcade.Emitter.prototype.emitParticle = function() {
- var a = this.getFirstExists(!1);
- 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())
- }, b.Particles.Arcade.Emitter.prototype.setSize = function(a, b) {
- this.area.width = a, this.area.height = b
- }, b.Particles.Arcade.Emitter.prototype.setXSpeed = function(a, b) {
- a = a || 0, b = b || 0, this.minParticleSpeed.x = a, this.maxParticleSpeed.x = b
- }, b.Particles.Arcade.Emitter.prototype.setYSpeed = function(a, b) {
- a = a || 0, b = b || 0, this.minParticleSpeed.y = a, this.maxParticleSpeed.y = b
- }, b.Particles.Arcade.Emitter.prototype.setRotation = function(a, b) {
- a = a || 0, b = b || 0, this.minRotation = a, this.maxRotation = b
- }, b.Particles.Arcade.Emitter.prototype.setAlpha = function(a, c, d, e, f) {
- 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) {
- var g = {
- v: a
- },
- h = this.game.make.tween(g).to({
- v: c
- }, d, e);
- h.yoyo(f), this.alphaData = h.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0
- }
- }, b.Particles.Arcade.Emitter.prototype.setScale = function(a, c, d, e, f, g, h) {
- 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) {
- var i = {
- x: a,
- y: d
- },
- j = this.game.make.tween(i).to({
- x: c,
- y: e
- }, f, g);
- j.yoyo(h), this.scaleData = j.generateData(60), this.scaleData.reverse(), this.autoScale = !0
- }
- }, b.Particles.Arcade.Emitter.prototype.at = function(a) {
- 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)
- }, Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "width", {
- get: function() {
- return this.area.width
- },
- set: function(a) {
- this.area.width = a
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "height", {
- get: function() {
- return this.area.height
- },
- set: function(a) {
- this.area.height = a
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "x", {
- get: function() {
- return this.emitX
- },
- set: function(a) {
- this.emitX = a
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "y", {
- get: function() {
- return this.emitY
- },
- set: function(a) {
- this.emitY = a
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "left", {
- get: function() {
- return Math.floor(this.x - this.area.width / 2)
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "right", {
- get: function() {
- return Math.floor(this.x + this.area.width / 2)
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "top", {
- get: function() {
- return Math.floor(this.y - this.area.height / 2)
- }
- }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "bottom", {
- get: function() {
- return Math.floor(this.y + this.area.height / 2)
- }
- }), b.Tile = function(a, b, c, d, e, f) {
- 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
- }, b.Tile.prototype = {
- containsPoint: function(a, b) {
- return !(a < this.worldX || b < this.worldY || a > this.right || b > this.bottom)
- },
- intersects: function(a, b, c, d) {
- return c <= this.worldX ? !1 : d <= this.worldY ? !1 : a >= this.worldX + this.width ? !1 : b >= this.worldY + this.height ? !1 : !0
- },
- setCollisionCallback: function(a, b) {
- this.collisionCallback = a, this.collisionCallbackContext = b
- },
- destroy: function() {
- this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null
- },
- setCollision: function(a, b, c, d) {
- this.collideLeft = a, this.collideRight = b, this.collideUp = c, this.collideDown = d, this.faceLeft = a, this.faceRight = b, this.faceTop = c, this.faceBottom = d
- },
- resetCollision: function() {
- this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1
- },
- isInteresting: function(a, b) {
- 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
- },
- copy: function(a) {
- 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
- }
- }, b.Tile.prototype.constructor = b.Tile, Object.defineProperty(b.Tile.prototype, "collides", {
- get: function() {
- return this.collideLeft || this.collideRight || this.collideUp || this.collideDown
- }
- }), Object.defineProperty(b.Tile.prototype, "canCollide", {
- get: function() {
- return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback
- }
- }), Object.defineProperty(b.Tile.prototype, "left", {
- get: function() {
- return this.worldX
- }
- }), Object.defineProperty(b.Tile.prototype, "right", {
- get: function() {
- return this.worldX + this.width
- }
- }), Object.defineProperty(b.Tile.prototype, "top", {
- get: function() {
- return this.worldY
- }
- }), Object.defineProperty(b.Tile.prototype, "bottom", {
- get: function() {
- return this.worldY + this.height
- }
- }), b.Tilemap = function(a, c, d, e, f, g) {
- this.game = a, this.key = c;
- var h = b.TilemapParser.parse(this.game, c, d, e, f, g);
- 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)
- }, 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 = {
- create: function(a, b, c, d, e, f) {
- 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)
- },
- setTileSize: function(a, b) {
- this.tileWidth = a, this.tileHeight = b, this.widthInPixels = this.width * a, this.heightInPixels = this.height * b
- },
- addTilesetImage: function(a, c, d, e, f, g, h) {
- 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) {
- if ("string" != typeof a) return null;
- if (c = a, !this.game.cache.checkImageKey(c)) return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + c + '"'), null
- }
- 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;
- if (this.tilesets[a]) return this.tilesets[a].setImage(this.game.cache.getImage(c)), this.tilesets[a];
- var i = new b.Tileset(c, h, d, e, f, g, {});
- i.setImage(this.game.cache.getImage(c)), this.tilesets.push(i);
- 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++);
- return i
- },
- createFromObjects: function(a, c, d, e, f, g, h, i, j) {
- 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);
- for (var k, l = 0, m = this.objects[a].length; m > l; l++)
- if (this.objects[a][l].gid === c) {
- 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);
- for (var n in this.objects[a][l].properties) h.set(k, n, this.objects[a][l].properties[n], !1, !1, 0, !0)
- }
- },
- createLayer: function(a, c, d, e) {
- "undefined" == typeof c && (c = this.game.width), "undefined" == typeof d && (d = this.game.height), "undefined" == typeof e && (e = this.game.world);
- var f = a;
- 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))
- },
- createBlankLayer: function(a, c, d, e, f, g) {
- if ("undefined" == typeof g && (g = this.game.world), null !== this.getLayerIndex(a)) return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists");
- for (var h, i = {
- name: a,
- x: 0,
- y: 0,
- width: c,
- height: d,
- widthInPixels: c * e,
- heightInPixels: d * f,
- alpha: 1,
- visible: !0,
- properties: {},
- indexes: [],
- callbacks: [],
- bodies: [],
- data: null
- }, j = [], k = 0; d > k; k++) {
- h = [];
- for (var l = 0; c > l; l++) h.push(new b.Tile(i, -1, l, k, e, f));
- j.push(h)
- }
- i.data = j, this.layers.push(i), this.currentLayer = this.layers.length - 1;
- var m = i.widthInPixels,
- n = i.heightInPixels;
- m > this.game.width && (m = this.game.width), n > this.game.height && (n = this.game.height);
- var j = new b.TilemapLayer(this.game, this, this.layers.length - 1, m, n);
- return j.name = a, g.add(j)
- },
- getIndex: function(a, b) {
- for (var c = 0; c < a.length; c++)
- if (a[c].name === b) return c;
- return null
- },
- getLayerIndex: function(a) {
- return this.getIndex(this.layers, a)
- },
- getTilesetIndex: function(a) {
- return this.getIndex(this.tilesets, a)
- },
- getImageIndex: function(a) {
- return this.getIndex(this.images, a)
- },
- getObjectIndex: function(a) {
- return this.getIndex(this.objects, a)
- },
- setTileIndexCallback: function(a, b, c, d) {
- if (d = this.getLayer(d), "number" == typeof a) this.layers[d].callbacks[a] = {
- callback: b,
- callbackContext: c
- };
- else
- for (var e = 0, f = a.length; f > e; e++) this.layers[d].callbacks[a[e]] = {
- callback: b,
- callbackContext: c
- }
- },
- setTileLocationCallback: function(a, b, c, d, e, f, g) {
- if (g = this.getLayer(g), this.copy(a, b, c, d, g), !(this._results.length < 2))
- for (var h = 1; h < this._results.length; h++) this._results[h].setCollisionCallback(e, f)
- },
- setCollision: function(a, b, c, d) {
- 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);
- for (var e = 0, f = a.length; f > e; e++) this.setCollisionByIndex(a[e], b, c, !1);
- d && this.calculateFaces(c)
- },
- setCollisionBetween: function(a, b, c, d, e) {
- if ("undefined" == typeof c && (c = !0), "undefined" == typeof e && (e = !0), d = this.getLayer(d), !(a > b)) {
- for (var f = a; b >= f; f++) this.setCollisionByIndex(f, c, d, !1);
- e && this.calculateFaces(d)
- }
- },
- setCollisionByExclusion: function(a, b, c, d) {
- "undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c);
- for (var e = 0, f = this.tiles.length; f > e; e++) - 1 === a.indexOf(e) && this.setCollisionByIndex(e, b, c, !1);
- d && this.calculateFaces(c)
- },
- setCollisionByIndex: function(a, b, c, d) {
- if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = this.currentLayer), "undefined" == typeof d && (d = !0), b) this.collideIndexes.push(a);
- else {
- var e = this.collideIndexes.indexOf(a);
- e > -1 && this.collideIndexes.splice(e, 1)
- }
- for (var f = 0; f < this.layers[c].height; f++)
- for (var g = 0; g < this.layers[c].width; g++) {
- var h = this.layers[c].data[f][g];
- h && h.index === a && (b ? h.setCollision(!0, !0, !0, !0) : h.resetCollision(), h.faceTop = b, h.faceBottom = b, h.faceLeft = b, h.faceRight = b)
- }
- return d && this.calculateFaces(c), c
- },
- getLayer: function(a) {
- return "undefined" == typeof a ? a = this.currentLayer : "string" == typeof a ? a = this.getLayerIndex(a) : a instanceof b.TilemapLayer && (a = a.index), a
- },
- setPreventRecalculate: function(a) {
- if (a === !0 && this.preventingRecalculate !== !0 && (this.preventingRecalculate = !0, this.needToRecalculate = {}), a === !1 && this.preventingRecalculate === !0) {
- this.preventingRecalculate = !1;
- for (var b in this.needToRecalculate) this.calculateFaces(b);
- this.needToRecalculate = !1
- }
- },
- calculateFaces: function(a) {
- if (this.preventingRecalculate) return void(this.needToRecalculate[a] = !0);
- for (var b = null, c = null, d = null, e = null, f = 0, g = this.layers[a].height; g > f; f++)
- for (var h = 0, i = this.layers[a].width; i > h; h++) {
- var j = this.layers[a].data[f][h];
- j && (b = this.getTileAbove(a, h, f), c = this.getTileBelow(a, h, f), d = this.getTileLeft(a, h, f), e = this.getTileRight(a, h, f), j.collides && (j.faceTop = !0, j.faceBottom = !0, j.faceLeft = !0, j.faceRight = !0), b && b.collides && (j.faceTop = !1), c && c.collides && (j.faceBottom = !1), d && d.collides && (j.faceLeft = !1), e && e.collides && (j.faceRight = !1))
- }
- },
- getTileAbove: function(a, b, c) {
- return c > 0 ? this.layers[a].data[c - 1][b] : null
- },
- getTileBelow: function(a, b, c) {
- return c < this.layers[a].height - 1 ? this.layers[a].data[c + 1][b] : null
- },
- getTileLeft: function(a, b, c) {
- return b > 0 ? this.layers[a].data[c][b - 1] : null
- },
- getTileRight: function(a, b, c) {
- return b < this.layers[a].width - 1 ? this.layers[a].data[c][b + 1] : null
- },
- setLayer: function(a) {
- a = this.getLayer(a), this.layers[a] && (this.currentLayer = a)
- },
- hasTile: function(a, b, c) {
- return c = this.getLayer(c), this.layers[c].data[b][a].index > -1
- },
- removeTile: function(a, c, d) {
- if (d = this.getLayer(d), a >= 0 && a < this.layers[d].width && c >= 0 && c < this.layers[d].height && this.hasTile(a, c, d)) {
- var e = this.layers[d].data[c][a];
- 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
- }
- },
- removeTileWorldXY: function(a, b, c, d, e) {
- 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)
- },
- putTile: function(a, c, d, e) {
- if (null === a) return this.removeTile(c, d, e);
- if (e = this.getLayer(e), c >= 0 && c < this.layers[e].width && d >= 0 && d < this.layers[e].height) {
- var f;
- 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]
- }
- return null
- },
- putTileWorldXY: function(a, b, c, d, e, f) {
- 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)
- },
- searchTileIndex: function(a, b, c, d) {
- "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), d = this.getLayer(d);
- var e = 0;
- if (c) {
- for (var f = this.layers[d].height - 1; f >= 0; f--)
- for (var g = this.layers[d].width - 1; g >= 0; g--)
- if (this.layers[d].data[f][g].index === a) {
- if (e === b) return this.layers[d].data[f][g];
- e++
- }
- } else
- for (var f = 0; f < this.layers[d].height; f++)
- for (var g = 0; g < this.layers[d].width; g++)
- if (this.layers[d].data[f][g].index === a) {
- if (e === b) return this.layers[d].data[f][g];
- e++
- } return null
- },
- getTile: function(a, b, c, d) {
- 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
- },
- getTileWorldXY: function(a, b, c, d, e) {
- 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)
- },
- copy: function(a, b, c, d, e) {
- if (e = this.getLayer(e), !this.layers[e]) return void(this._results.length = 0);
- "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({
- x: a,
- y: b,
- width: c,
- height: d,
- layer: e
- });
- for (var f = b; b + d > f; f++)
- for (var g = a; a + c > g; g++) this._results.push(this.layers[e].data[f][g]);
- return this._results
- },
- paste: function(a, b, c, d) {
- if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), d = this.getLayer(d), c && !(c.length < 2)) {
- 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]);
- this.layers[d].dirty = !0, this.calculateFaces(d)
- }
- },
- swap: function(a, b, c, d, e, f, g) {
- 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))
- },
- swapHandler: function(a) {
- a.index === this._tempA ? a.index = this._tempB : a.index === this._tempB && (a.index = this._tempA)
- },
- forEach: function(a, b, c, d, e, f, g) {
- 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))
- },
- replace: function(a, b, c, d, e, f, g) {
- if (g = this.getLayer(g), this.copy(c, d, e, f, g), !(this._results.length < 2)) {
- for (var h = 1; h < this._results.length; h++) this._results[h].index === a && (this._results[h].index = b);
- this.paste(c, d, this._results, g)
- }
- },
- random: function(a, b, c, d, e) {
- if (e = this.getLayer(e), this.copy(a, b, c, d, e), !(this._results.length < 2)) {
- for (var f = [], g = 1; g < this._results.length; g++)
- if (this._results[g].index) {
- var h = this._results[g].index; - 1 === f.indexOf(h) && f.push(h)
- }
- for (var i = 1; i < this._results.length; i++) this._results[i].index = this.game.rnd.pick(f);
- this.paste(a, b, this._results, e)
- }
- },
- shuffle: function(a, c, d, e, f) {
- if (f = this.getLayer(f), this.copy(a, c, d, e, f), !(this._results.length < 2)) {
- for (var g = [], h = 1; h < this._results.length; h++) this._results[h].index && g.push(this._results[h].index);
- b.Utils.shuffle(g);
- for (var i = 1; i < this._results.length; i++) this._results[i].index = g[i - 1];
- this.paste(a, c, this._results, f)
- }
- },
- fill: function(a, b, c, d, e, f) {
- if (f = this.getLayer(f), this.copy(b, c, d, e, f), !(this._results.length < 2)) {
- for (var g = 1; g < this._results.length; g++) this._results[g].index = a;
- this.paste(b, c, this._results, f)
- }
- },
- removeAllLayers: function() {
- this.layers.length = 0, this.currentLayer = 0
- },
- dump: function() {
- for (var a = "", b = [""], c = 0; c < this.layers[this.currentLayer].height; c++) {
- 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)");
- a += "\n"
- }
- b[0] = a, console.log.apply(console, b)
- },
- destroy: function() {
- this.removeAllLayers(), this.data = [], this.game = null
- }
- }, b.Tilemap.prototype.constructor = b.Tilemap, Object.defineProperty(b.Tilemap.prototype, "layer", {
- get: function() {
- return this.layers[this.currentLayer]
- },
- set: function(a) {
- a !== this.currentLayer && this.setLayer(a)
- }
- }), b.TilemapLayer = function(a, c, d, e, f) {
- 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 = {
- cw: c.tileWidth,
- ch: c.tileHeight,
- ga: 1,
- dx: 0,
- dy: 0,
- dw: 0,
- dh: 0,
- tx: 0,
- ty: 0,
- tw: 0,
- th: 0,
- tl: 0,
- maxX: 0,
- maxY: 0,
- startX: 0,
- startY: 0,
- x: 0,
- y: 0,
- prevX: 0,
- prevY: 0
- }, this._results = [], this.updateMax()
- }, b.TilemapLayer.prototype = Object.create(b.Image.prototype), b.TilemapLayer.prototype.constructor = b.TilemapLayer, b.TilemapLayer.prototype.postUpdate = function() {
- 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)
- }, b.TilemapLayer.prototype.resizeWorld = function() {
- this.game.world.setBounds(0, 0, this.layer.widthInPixels, this.layer.heightInPixels)
- }, b.TilemapLayer.prototype._fixX = function(a) {
- return 0 > a && (a = 0), 1 === this.scrollFactorX ? a : this._mc.x + (a - this._mc.x / this.scrollFactorX)
- }, b.TilemapLayer.prototype._unfixX = function(a) {
- return 1 === this.scrollFactorX ? a : this._mc.x / this.scrollFactorX + (a - this._mc.x)
- }, b.TilemapLayer.prototype._fixY = function(a) {
- return 0 > a && (a = 0), 1 === this.scrollFactorY ? a : this._mc.y + (a - this._mc.y / this.scrollFactorY)
- }, b.TilemapLayer.prototype._unfixY = function(a) {
- return 1 === this.scrollFactorY ? a : this._mc.y / this.scrollFactorY + (a - this._mc.y)
- }, b.TilemapLayer.prototype.getTileX = function(a) {
- return this.game.math.snapToFloor(this._fixX(a), this.map.tileWidth) / this.map.tileWidth
- }, b.TilemapLayer.prototype.getTileY = function(a) {
- return this.game.math.snapToFloor(this._fixY(a), this.map.tileHeight) / this.map.tileHeight
- }, b.TilemapLayer.prototype.getTileXY = function(a, b, c) {
- return c.x = this.getTileX(a), c.y = this.getTileY(b), c
- }, b.TilemapLayer.prototype.getRayCastTiles = function(a, b, c, d) {
- ("undefined" == typeof b || null === b) && (b = this.rayStepRate), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1);
- var e = this.getTiles(a.x, a.y, a.width, a.height, c, d);
- if (0 === e.length) return [];
- for (var f = a.coordinatesOnLine(b), g = f.length, h = [], i = 0; i < e.length; i++)
- for (var j = 0; g > j; j++)
- if (e[i].containsPoint(f[j][0], f[j][1])) {
- h.push(e[i]);
- break
- }
- return h
- }, b.TilemapLayer.prototype.getTiles = function(a, b, c, d, e, f) {
- "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;
- for (var g = this._mc.ty; g < this._mc.ty + this._mc.th; g++)
- 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]);
- return this._results
- }, b.TilemapLayer.prototype.updateMax = function() {
- 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
- }, b.TilemapLayer.prototype.render = function() {
- if (this.layer.dirty && (this.dirty = !0), this.dirty && this.visible) {
- 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;
- var a, b;
- this.debug && (this.context.globalAlpha = this.debugAlpha);
- for (var c = this._mc.startY, d = this._mc.startY + this._mc.maxY; d > c; c++) {
- 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)
- for (var e = this._mc.startX, f = this._mc.startX + this._mc.maxX; f > e; e++) {
- var a = null;
- 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
- }
- this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
- }
- return this.debug && (this.context.globalAlpha = 1, this.renderDebug()), this.texture._updateUvs(), this.dirty = !1, this.layer.dirty = !1, !0
- }
- }, b.TilemapLayer.prototype.renderDebug = function() {
- this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.strokeStyle = this.debugColor, this.context.fillStyle = this.debugFillColor;
- for (var a = this._mc.startY, b = this._mc.startY + this._mc.maxY; b > a; a++) {
- 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)
- for (var c = this._mc.startX, d = this._mc.startX + this._mc.maxX; d > c; c++) {
- var e = null;
- 0 > c && this.wrap ? e = this._column[c + this.map.width] : c >= this.map.width && this.wrap ? e = this._column[c - this.map.width] : this._column[c] && (e = this._column[c]), e && (e.faceTop || e.faceBottom || e.faceLeft || e.faceRight) && (this._mc.tx = Math.floor(this._mc.tx), this.debugFill && this.context.fillRect(this._mc.tx, this._mc.ty, this._mc.cw, this._mc.ch), this.context.beginPath(), e.faceTop && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty)), e.faceBottom && (this.context.moveTo(this._mc.tx, this._mc.ty + this._mc.ch), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), e.faceLeft && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx, this._mc.ty + this._mc.ch)), e.faceRight && (this.context.moveTo(this._mc.tx + this._mc.cw, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), this.context.stroke()), this._mc.tx += this.map.tileWidth
- }
- this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
- }
- }, Object.defineProperty(b.TilemapLayer.prototype, "scrollX", {
- get: function() {
- return this._mc.x
- },
- set: function(a) {
- a !== this._mc.x && (this._mc.x = a, this._mc.startX = this.game.math.floor(this._mc.x / this.map.tileWidth), this.dirty = !0)
- }
- }), Object.defineProperty(b.TilemapLayer.prototype, "scrollY", {
- get: function() {
- return this._mc.y
- },
- set: function(a) {
- a !== this._mc.y && (this._mc.y = a, this._mc.startY = this.game.math.floor(this._mc.y / this.map.tileHeight), this.dirty = !0)
- }
- }), Object.defineProperty(b.TilemapLayer.prototype, "collisionWidth", {
- get: function() {
- return this._mc.cw
- },
- set: function(a) {
- this._mc.cw = a, this.dirty = !0
- }
- }), Object.defineProperty(b.TilemapLayer.prototype, "collisionHeight", {
- get: function() {
- return this._mc.ch
- },
- set: function(a) {
- this._mc.ch = a, this.dirty = !0
- }
- }), b.TilemapParser = {
- parse: function(a, c, d, e, f, g) {
- 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();
- if (null === c) return this.getEmptyData(d, e, f, g);
- var h = a.cache.getTilemapData(c);
- if (h) {
- if (h.format === b.Tilemap.CSV) return this.parseCSV(c, h.data, d, e);
- if (!h.format || h.format === b.Tilemap.TILED_JSON) return this.parseTiledJSON(h.data)
- } else console.warn("Phaser.TilemapParser.parse - No map data found for key " + c)
- },
- parseCSV: function(a, c, d, e) {
- var f = this.getEmptyData();
- c = c.trim();
- for (var g = [], h = c.split("\n"), i = h.length, j = 0, k = 0; k < h.length; k++) {
- g[k] = [];
- 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);
- 0 === j && (j = l.length)
- }
- 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
- },
- getEmptyData: function(a, b, c, d) {
- var e = {};
- 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;
- var f = [],
- g = {
- name: "layer",
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- widthInPixels: 0,
- heightInPixels: 0,
- alpha: 1,
- visible: !0,
- properties: {},
- indexes: [],
- callbacks: [],
- bodies: [],
- data: []
- };
- return f.push(g), e.layers = f, e.images = [], e.objects = {}, e.collision = {}, e.tilesets = [], e.tiles = [], e
- },
- parseTiledJSON: function(a) {
- function c(a, b) {
- var c = {};
- for (var d in b) {
- var e = b[d];
- c[e] = a[e]
- }
- return c
- }
- if ("orthogonal" !== a.orientation) return console.warn("TilemapParser.parseTiledJSON: Only orthogonal map types are supported in this version of Phaser"), null;
- var d = {};
- 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;
- for (var e = [], f = 0; f < a.layers.length; f++)
- if ("tilelayer" === a.layers[f].type) {
- var g = {
- name: a.layers[f].name,
- x: a.layers[f].x,
- y: a.layers[f].y,
- width: a.layers[f].width,
- height: a.layers[f].height,
- widthInPixels: a.layers[f].width * a.tilewidth,
- heightInPixels: a.layers[f].height * a.tileheight,
- alpha: a.layers[f].opacity,
- visible: a.layers[f].visible,
- properties: {},
- indexes: [],
- callbacks: [],
- bodies: []
- };
- a.layers[f].properties && (g.properties = a.layers[f].properties);
- 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 = []);
- g.data = j, e.push(g)
- }
- d.layers = e;
- for (var m = [], f = 0; f < a.layers.length; f++)
- if ("imagelayer" === a.layers[f].type) {
- var n = {
- name: a.layers[f].name,
- image: a.layers[f].image,
- x: a.layers[f].x,
- y: a.layers[f].y,
- alpha: a.layers[f].opacity,
- visible: a.layers[f].visible,
- properties: {}
- };
- a.layers[f].properties && (n.properties = a.layers[f].properties), m.push(n)
- }
- d.images = m;
- for (var o = [], f = 0; f < a.tilesets.length; f++) {
- var p = a.tilesets[f],
- q = new b.Tileset(p.name, p.firstgid, p.tilewidth, p.tileheight, p.margin, p.spacing, p.properties);
- 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)
- }
- d.tilesets = o;
- for (var r = {}, s = {}, f = 0; f < a.layers.length; f++)
- if ("objectgroup" === a.layers[f].type) {
- r[a.layers[f].name] = [], s[a.layers[f].name] = [];
- for (var t = 0, l = a.layers[f].objects.length; l > t; t++)
- if (a.layers[f].objects[t].gid) {
- var u = {
- gid: a.layers[f].objects[t].gid,
- name: a.layers[f].objects[t].name,
- x: a.layers[f].objects[t].x,
- y: a.layers[f].objects[t].y,
- visible: a.layers[f].objects[t].visible,
- properties: a.layers[f].objects[t].properties
- };
- r[a.layers[f].name].push(u)
- } else if (a.layers[f].objects[t].polyline) {
- var u = {
- name: a.layers[f].objects[t].name,
- type: a.layers[f].objects[t].type,
- x: a.layers[f].objects[t].x,
- y: a.layers[f].objects[t].y,
- width: a.layers[f].objects[t].width,
- height: a.layers[f].objects[t].height,
- visible: a.layers[f].objects[t].visible,
- properties: a.layers[f].objects[t].properties
- };
- u.polyline = [];
- 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]);
- s[a.layers[f].name].push(u), r[a.layers[f].name].push(u)
- } else if (a.layers[f].objects[t].polygon) {
- var u = c(a.layers[f].objects[t], ["name", "type", "x", "y", "visible", "properties"]);
- u.polygon = [];
- 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]);
- r[a.layers[f].name].push(u)
- } else if (a.layers[f].objects[t].ellipse) {
- var u = c(a.layers[f].objects[t], ["name", "type", "ellipse", "x", "y", "width", "height", "visible", "properties"]);
- r[a.layers[f].name].push(u)
- } else {
- var u = c(a.layers[f].objects[t], ["name", "type", "x", "y", "width", "height", "visible", "properties"]);
- u.rectangle = !0, r[a.layers[f].name].push(u)
- }
- }
- d.objects = r, d.collision = s, d.tiles = [];
- for (var f = 0; f < d.tilesets.length; f++)
- 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++);
- var f, A, B, g, C, D, p;
- for (f = 0; f < d.layers.length; f++)
- for (g = d.layers[f], A = 0; A < g.data.length; A++)
- 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]));
- return d
- }
- }, b.Tileset = function(a, b, c, d, e, f, g) {
- ("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 = []
- }, b.Tileset.prototype = {
- draw: function(a, b, c, d) {
- 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)
- },
- setImage: function(a) {
- 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;
- for (var b = this.tileMargin, c = this.tileMargin, d = this.firstgid, e = 0; e < this.rows; e++) {
- for (var f = 0; f < this.columns; f++) this.drawCoords[d] = [b, c], b += this.tileWidth + this.tileSpacing, d++;
- b = this.tileMargin, c += this.tileHeight + this.tileSpacing
- }
- },
- setSpacing: function(a, b) {
- this.tileMargin = a, this.tileSpacing = b, this.setImage(this.image)
- }
- }, 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() {
- return a.Phaser = b
- }()) : a.Phaser = b
- }.call(this), ! function(a) {
- "object" == typeof exports ? module.exports = a() : "function" == typeof define && define.amd ? define("p2", function() {
- return this.p2 = a()
- }()) : "undefined" != typeof window ? window.p2 = a() : "undefined" != typeof global ? self.p2 = a() : "undefined" != typeof self && (self.p2 = a())
- }(function() {
- return function a(b, c, d) {
- function e(g, h) {
- if (!c[g]) {
- if (!b[g]) {
- var i = "function" == typeof require && require;
- if (!h && i) return i(g, !0);
- if (f) return f(g, !0);
- throw new Error("Cannot find module '" + g + "'")
- }
- var j = c[g] = {
- exports: {}
- };
- b[g][0].call(j.exports, function(a) {
- var c = b[g][1][a];
- return e(c ? c : a)
- }, j, j.exports, a, b, c, d)
- }
- return c[g].exports
- }
- for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
- return e
- }({
- 1: [function(a, b) {
- a = function c(b, d, e) {
- function f(h, i) {
- if (!d[h]) {
- if (!b[h]) {
- var j = "function" == typeof a && a;
- if (!i && j) return j(h, !0);
- if (g) return g(h, !0);
- throw new Error("Cannot find module '" + h + "'")
- }
- var k = d[h] = {
- exports: {}
- };
- b[h][0].call(k.exports, function(a) {
- var c = b[h][1][a];
- return f(c ? c : a)
- }, k, k.exports, c, b, d, e)
- }
- return d[h].exports
- }
- for (var g = "function" == typeof a && a, h = 0; h < e.length; h++) f(e[h]);
- return f
- }({
- PcZj9L: [function(a, b, c) {
- function d(a, b) {
- var c = typeof a;
- if ("base64" === b && "string" === c)
- for (a = ib(a); a.length % 4 !== 0;) a += "=";
- var e;
- if ("number" === c) e = nb(a);
- else if ("string" === c) e = d.byteLength(a, b);
- else {
- if ("object" !== c) throw new Error("First argument needs to be a number, array or string.");
- e = nb(a.length)
- }
- var f = lb(new Cb(e));
- if (d.isBuffer(a)) f.set(a);
- else if (ob(a))
- for (var g = 0; e > g; g++) f[g] = d.isBuffer(a) ? a.readUInt8(g) : a[g];
- else "string" === c && f.write(a, 0, b);
- return f
- }
- function e(a, b, c, e) {
- c = Number(c) || 0;
- var f = a.length - c;
- e ? (e = Number(e), e > f && (e = f)) : e = f;
- var g = b.length;
- if (g % 2 !== 0) throw new Error("Invalid hex string");
- e > g / 2 && (e = g / 2);
- for (var h = 0; e > h; h++) {
- var i = parseInt(b.substr(2 * h, 2), 16);
- if (isNaN(i)) throw new Error("Invalid hex string");
- a[c + h] = i
- }
- return d._charsWritten = 2 * h, h
- }
- function f(a, b, c, e) {
- return d._charsWritten = tb(qb(b), a, c, e)
- }
- function g(a, b, c, e) {
- return d._charsWritten = tb(rb(b), a, c, e)
- }
- function h(a, b, c, d) {
- return g(a, b, c, d)
- }
- function i(a, b, c, e) {
- return d._charsWritten = tb(sb(b), a, c, e)
- }
- function j(a, b, c, d) {
- if (isFinite(b)) isFinite(c) || (d = c, c = void 0);
- else {
- var j = d;
- d = b, b = c, c = j
- }
- b = Number(b) || 0;
- var k = this.length - b;
- switch (c ? (c = Number(c), c > k && (c = k)) : c = k, d = String(d || "utf8").toLowerCase()) {
- case "hex":
- return e(this, a, b, c);
- case "utf8":
- case "utf-8":
- return f(this, a, b, c);
- case "ascii":
- return g(this, a, b, c);
- case "binary":
- return h(this, a, b, c);
- case "base64":
- return i(this, a, b, c);
- default:
- throw new Error("Unknown encoding")
- }
- }
- function k(a, b, c) {
- var d = this instanceof kb ? this._proxy : this;
- if (a = String(a || "utf8").toLowerCase(), b = Number(b) || 0, c = void 0 !== c ? Number(c) : c = d.length, c === b) return "";
- switch (a) {
- case "hex":
- return r(d, b, c);
- case "utf8":
- case "utf-8":
- return o(d, b, c);
- case "ascii":
- return p(d, b, c);
- case "binary":
- return q(d, b, c);
- case "base64":
- return n(d, b, c);
- default:
- throw new Error("Unknown encoding")
- }
- }
- function l() {
- return {
- type: "Buffer",
- data: Array.prototype.slice.call(this, 0)
- }
- }
- function m(a, b, c, d) {
- var e = this;
- if (c || (c = 0), d || 0 === d || (d = this.length), b || (b = 0), d !== c && 0 !== a.length && 0 !== e.length) {
- if (c > d) throw new Error("sourceEnd < sourceStart");
- if (0 > b || b >= a.length) throw new Error("targetStart out of bounds");
- if (0 > c || c >= e.length) throw new Error("sourceStart out of bounds");
- if (0 > d || d > e.length) throw new Error("sourceEnd out of bounds");
- d > this.length && (d = this.length), a.length - b < d - c && (d = a.length - b + c);
- for (var f = 0; d - c > f; f++) a[f + b] = this[f + c]
- }
- }
- function n(b, c, d) {
- var e = b.slice(c, d);
- return a("base64-js").fromByteArray(e)
- }
- function o(a, b, c) {
- 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++;
- return e + ub(f)
- }
- function p(a, b, c) {
- for (var d = a.slice(b, c), e = "", f = 0; f < d.length; f++) e += String.fromCharCode(d[f]);
- return e
- }
- function q(a, b, c) {
- return p(a, b, c)
- }
- function r(a, b, c) {
- var d = a.length;
- (!b || 0 > b) && (b = 0), (!c || 0 > c || c > d) && (c = d);
- for (var e = "", f = b; c > f; f++) e += pb(a[f]);
- return e
- }
- function s(a, b) {
- var c = this.length;
- return a = mb(a, c, 0), b = mb(b, c, c), lb(this.subarray(a, b))
- }
- function t(a, b) {
- var c = this;
- 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]
- }
- function u(a, b, c, d) {
- 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"));
- var e = a.length;
- if (!(b >= e)) {
- if (b + 1 === e) {
- var f = new Ab(new Bb(2));
- return f.setUint8(0, a[e - 1]), f.getUint16(0, c)
- }
- return a._dataview.getUint16(b, c)
- }
- }
- function v(a, b) {
- return u(this, a, !0, b)
- }
- function w(a, b) {
- return u(this, a, !1, b)
- }
- function x(a, b, c, d) {
- 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"));
- var e = a.length;
- if (!(b >= e)) {
- if (b + 3 >= e) {
- for (var f = new Ab(new Bb(4)), g = 0; e > g + b; g++) f.setUint8(g, a[g + b]);
- return f.getUint32(0, c)
- }
- return a._dataview.getUint32(b, c)
- }
- }
- function y(a, b) {
- return x(this, a, !0, b)
- }
- function z(a, b) {
- return x(this, a, !1, b)
- }
- function A(a, b) {
- var c = this;
- 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)
- }
- function B(a, b, c, d) {
- 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"));
- var e = a.length;
- if (!(b >= e)) {
- if (b + 1 === e) {
- var f = new Ab(new Bb(2));
- return f.setUint8(0, a[e - 1]), f.getInt16(0, c)
- }
- return a._dataview.getInt16(b, c)
- }
- }
- function C(a, b) {
- return B(this, a, !0, b)
- }
- function D(a, b) {
- return B(this, a, !1, b)
- }
- function E(a, b, c, d) {
- 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"));
- var e = a.length;
- if (!(b >= e)) {
- if (b + 3 >= e) {
- for (var f = new Ab(new Bb(4)), g = 0; e > g + b; g++) f.setUint8(g, a[g + b]);
- return f.getInt32(0, c)
- }
- return a._dataview.getInt32(b, c)
- }
- }
- function F(a, b) {
- return E(this, a, !0, b)
- }
- function G(a, b) {
- return E(this, a, !1, b)
- }
- function H(a, b, c, d) {
- 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)
- }
- function I(a, b) {
- return H(this, a, !0, b)
- }
- function J(a, b) {
- return H(this, a, !1, b)
- }
- function K(a, b, c, d) {
- 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)
- }
- function L(a, b) {
- return K(this, a, !0, b)
- }
- function M(a, b) {
- return K(this, a, !1, b)
- }
- function N(a, b, c) {
- var d = this;
- 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)
- }
- function O(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 1 === f) {
- var g = new Ab(new Bb(2));
- g.setUint16(0, b, d), a[c] = g.getUint8(0)
- } else a._dataview.setUint16(c, b, d)
- }
- function P(a, b, c) {
- O(this, a, b, !0, c)
- }
- function Q(a, b, c) {
- O(this, a, b, !1, c)
- }
- function R(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 3 >= f) {
- var g = new Ab(new Bb(4));
- g.setUint32(0, b, d);
- for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
- } else a._dataview.setUint32(c, b, d)
- }
- function S(a, b, c) {
- R(this, a, b, !0, c)
- }
- function T(a, b, c) {
- R(this, a, b, !1, c)
- }
- function U(a, b, c) {
- var d = this;
- 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)
- }
- function V(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 1 === f) {
- var g = new Ab(new Bb(2));
- g.setInt16(0, b, d), a[c] = g.getUint8(0)
- } else a._dataview.setInt16(c, b, d)
- }
- function W(a, b, c) {
- V(this, a, b, !0, c)
- }
- function X(a, b, c) {
- V(this, a, b, !1, c)
- }
- function Y(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 3 >= f) {
- var g = new Ab(new Bb(4));
- g.setInt32(0, b, d);
- for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
- } else a._dataview.setInt32(c, b, d)
- }
- function Z(a, b, c) {
- Y(this, a, b, !0, c)
- }
- function $(a, b, c) {
- Y(this, a, b, !1, c)
- }
- function _(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 3 >= f) {
- var g = new Ab(new Bb(4));
- g.setFloat32(0, b, d);
- for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
- } else a._dataview.setFloat32(c, b, d)
- }
- function ab(a, b, c) {
- _(this, a, b, !0, c)
- }
- function bb(a, b, c) {
- _(this, a, b, !1, c)
- }
- function cb(a, b, c, d, e) {
- 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));
- var f = a.length;
- if (!(c >= f))
- if (c + 7 >= f) {
- var g = new Ab(new Bb(8));
- g.setFloat64(0, b, d);
- for (var h = 0; f > h + c; h++) a[h + c] = g.getUint8(h)
- } else a._dataview.setFloat64(c, b, d)
- }
- function db(a, b, c) {
- cb(this, a, b, !0, c)
- }
- function eb(a, b, c) {
- cb(this, a, b, !1, c)
- }
- function fb(a, b, c) {
- 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");
- if (b > c) throw new Error("end < start");
- if (c !== b && 0 !== this.length) {
- if (0 > b || b >= this.length) throw new Error("start out of bounds");
- if (0 > c || c > this.length) throw new Error("end out of bounds");
- for (var d = b; c > d; d++) this[d] = a
- }
- }
- function gb() {
- for (var a = [], b = this.length, d = 0; b > d; d++)
- if (a[d] = pb(this[d]), d === c.INSPECT_MAX_BYTES) {
- a[d + 1] = "...";
- break
- }
- return "<Buffer " + a.join(" ") + ">"
- }
- function hb() {
- return new d(this).buffer
- }
- function ib(a) {
- return a.trim ? a.trim() : a.replace(/^\s+|\s+$/g, "")
- }
- function jb() {
- var a = new Cb(0);
- a.foo = function() {
- return 42
- };
- try {
- return 42 === a.foo()
- } catch (b) {
- return !1
- }
- }
- function kb(a) {
- this._arr = a, 0 !== a.byteLength && (this._dataview = new Ab(a.buffer, a.byteOffset, a.byteLength))
- }
- function lb(a) {
- 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;
- var b = new kb(a),
- c = new Proxy(b, Eb);
- return b._proxy = c, c
- }
- function mb(a, b, c) {
- return "number" != typeof a ? c : (a = ~~a, a >= b ? b : a >= 0 ? a : (a += b, a >= 0 ? a : 0))
- }
- function nb(a) {
- return a = ~~Math.ceil(+a), 0 > a ? 0 : a
- }
- function ob(a) {
- return Array.isArray(a) || d.isBuffer(a) || a && "object" == typeof a && "number" == typeof a.length
- }
- function pb(a) {
- return 16 > a ? "0" + a.toString(16) : a.toString(16)
- }
- function qb(a) {
- for (var b = [], c = 0; c < a.length; c++)
- if (a.charCodeAt(c) <= 127) b.push(a.charCodeAt(c));
- else
- for (var d = encodeURIComponent(a.charAt(c)).substr(1).split("%"), e = 0; e < d.length; e++) b.push(parseInt(d[e], 16));
- return b
- }
- function rb(a) {
- for (var b = [], c = 0; c < a.length; c++) b.push(255 & a.charCodeAt(c));
- return b
- }
- function sb(b) {
- return a("base64-js").toByteArray(b)
- }
- function tb(a, b, c, d) {
- for (var e = 0; d > e && !(e + c >= b.length || e >= a.length);) b[e + c] = a[e], e++;
- return e
- }
- function ub(a) {
- try {
- return decodeURIComponent(a)
- } catch (b) {
- return String.fromCharCode(65533)
- }
- }
- function vb(a, b) {
- 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")
- }
- function wb(a, b, c) {
- 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")
- }
- function xb(a, b, c) {
- 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")
- }
- function yb(a, b) {
- if (!a) throw new Error(b || "Failed assertion")
- }
- var zb = a("typedarray"),
- Ab = "undefined" == typeof DataView ? zb.DataView : DataView,
- Bb = "undefined" == typeof ArrayBuffer ? zb.ArrayBuffer : ArrayBuffer,
- Cb = "undefined" == typeof Uint8Array ? zb.Uint8Array : Uint8Array;
- c.Buffer = d, c.SlowBuffer = d, c.INSPECT_MAX_BYTES = 50, d.poolSize = 8192;
- var Db;
- d.isEncoding = function(a) {
- switch ((a + "").toLowerCase()) {
- case "hex":
- case "utf8":
- case "utf-8":
- case "ascii":
- case "binary":
- case "base64":
- case "ucs2":
- case "ucs-2":
- case "utf16le":
- case "utf-16le":
- case "raw":
- return !0;
- default:
- return !1
- }
- }, d.isBuffer = function(a) {
- return a && a._isBuffer
- }, d.byteLength = function(a, b) {
- switch (b || "utf8") {
- case "hex":
- return a.length / 2;
- case "utf8":
- case "utf-8":
- return qb(a).length;
- case "ascii":
- case "binary":
- return a.length;
- case "base64":
- return sb(a).length;
- default:
- throw new Error("Unknown encoding")
- }
- }, d.concat = function(a, b) {
- if (!Array.isArray(a)) throw new Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");
- var c, e;
- if (0 === a.length) return new d(0);
- if (1 === a.length) return a[0];
- if ("number" != typeof b)
- for (b = 0, c = 0; c < a.length; c++) e = a[c], b += e.length;
- var f = new d(b),
- g = 0;
- for (c = 0; c < a.length; c++) e = a[c], e.copy(f, g), g += e.length;
- return f
- }, 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() {
- return this._arr.subarray.apply(this._arr, arguments)
- }, kb.prototype.set = function() {
- return this._arr.set.apply(this._arr, arguments)
- };
- var Eb = {
- get: function(a, b) {
- return b in a ? a[b] : a._arr[b]
- },
- set: function(a, b, c) {
- a._arr[b] = c
- }
- }
- }, {
- "base64-js": 3,
- typedarray: 4
- }],
- "native-buffer-browserify": [function(a, b) {
- b.exports = a("PcZj9L")
- }, {}],
- 3: [function(a, b) {
- ! function() {
- "use strict";
- function a(a) {
- var b, c, e, f, g, h;
- if (a.length % 4 > 0) throw "Invalid string. Length must be a multiple of 4";
- 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);
- 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
- }
- function c(a) {
- function b(a) {
- return d[a >> 18 & 63] + d[a >> 12 & 63] + d[a >> 6 & 63] + d[63 & a]
- }
- var c, e, f, g = a.length % 3,
- h = "";
- 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);
- switch (g) {
- case 1:
- e = a[a.length - 1], h += d[e >> 2], h += d[e << 4 & 63], h += "==";
- break;
- case 2:
- 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 += "="
- }
- return h
- }
- var d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- b.exports.toByteArray = a, b.exports.fromByteArray = c
- }()
- }, {}],
- 4: [function(a, b, c) {
- function d(a) {
- if (L && K) {
- var b, c = L(a);
- for (b = 0; b < c.length; b += 1) K(a, c[b], {
- value: a[c[b]],
- writable: !1,
- enumerable: !1,
- configurable: !1
- })
- }
- }
- function e(a) {
- function b(b) {
- K(a, b, {
- get: function() {
- return a._getter(b)
- },
- set: function(c) {
- a._setter(b, c)
- },
- enumerable: !0,
- configurable: !1
- })
- }
- if (K) {
- if (a.length > B) throw new RangeError("Array too large for polyfill");
- var c;
- for (c = 0; c < a.length; c += 1) b(c)
- }
- }
- function f(a, b) {
- var c = 32 - b;
- return a << c >> c
- }
- function g(a, b) {
- var c = 32 - b;
- return a << c >>> c
- }
- function h(a) {
- return [255 & a]
- }
- function i(a) {
- return f(a[0], 8)
- }
- function j(a) {
- return [255 & a]
- }
- function k(a) {
- return g(a[0], 8)
- }
- function l(a) {
- return a = J(Number(a)), [0 > a ? 0 : a > 255 ? 255 : 255 & a]
- }
- function m(a) {
- return [a >> 8 & 255, 255 & a]
- }
- function n(a) {
- return f(a[0] << 8 | a[1], 16)
- }
- function o(a) {
- return [a >> 8 & 255, 255 & a]
- }
- function p(a) {
- return g(a[0] << 8 | a[1], 16)
- }
- function q(a) {
- return [a >> 24 & 255, a >> 16 & 255, a >> 8 & 255, 255 & a]
- }
- function r(a) {
- return f(a[0] << 24 | a[1] << 16 | a[2] << 8 | a[3], 32)
- }
- function s(a) {
- return [a >> 24 & 255, a >> 16 & 255, a >> 8 & 255, 255 & a]
- }
- function t(a) {
- return g(a[0] << 24 | a[1] << 16 | a[2] << 8 | a[3], 32)
- }
- function u(a, b, c) {
- function d(a) {
- var b = F(a),
- c = a - b;
- return .5 > c ? b : c > .5 ? b + 1 : b % 2 ? b + 1 : b
- }
- var e, f, g, h, i, j, k, l = (1 << b - 1) - 1;
- 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);
- for (h = b; h; h -= 1) i.push(f % 2 ? 1 : 0), f = F(f / 2);
- 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);
- return k
- }
- function v(a, b, c) {
- var d, e, f, g, h, i, j, k, l = [];
- for (d = a.length; d; d -= 1)
- for (f = a[d - 1], e = 8; e; e -= 1) l.push(f % 2 ? 1 : 0), f >>= 1;
- 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
- }
- function w(a) {
- return v(a, 11, 52)
- }
- function x(a) {
- return u(a, 11, 52)
- }
- function y(a) {
- return v(a, 8, 23)
- }
- function z(a) {
- return u(a, 8, 23)
- }
- var A = void 0,
- B = 1e5,
- C = function() {
- var a = Object.prototype.toString,
- b = Object.prototype.hasOwnProperty;
- return {
- Class: function(b) {
- return a.call(b).replace(/^\[object *|\]$/g, "")
- },
- HasProperty: function(a, b) {
- return b in a
- },
- HasOwnProperty: function(a, c) {
- return b.call(a, c)
- },
- IsCallable: function(a) {
- return "function" == typeof a
- },
- ToInt32: function(a) {
- return a >> 0
- },
- ToUint32: function(a) {
- return a >>> 0
- }
- }
- }(),
- D = Math.LN2,
- E = Math.abs,
- F = Math.floor,
- G = Math.log,
- H = Math.min,
- I = Math.pow,
- J = Math.round,
- K = Object.defineProperty || function(a, b, c) {
- if (!a === Object(a)) throw new TypeError("Object.defineProperty called on non-object");
- 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
- },
- L = Object.getOwnPropertyNames || function(a) {
- if (a !== Object(a)) throw new TypeError("Object.getOwnPropertyNames called on non-object");
- var b, c = [];
- for (b in a) C.HasOwnProperty(a, b) && c.push(b);
- return c
- };
- ! function() {
- function a(a, c, g) {
- var h;
- return h = function(a, c, f) {
- var g, i, j, k;
- if (arguments.length && "number" != typeof arguments[0])
- if ("object" == typeof arguments[0] && arguments[0].constructor === h)
- 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));
- else if ("object" != typeof arguments[0] || (arguments[0] instanceof b || "ArrayBuffer" === C.Class(arguments[0]))) {
- if ("object" != typeof arguments[0] || !(arguments[0] instanceof b || "ArrayBuffer" === C.Class(arguments[0]))) throw new TypeError("Unexpected argument type(s)");
- if (this.buffer = a, this.byteOffset = C.ToUint32(c), this.byteOffset > this.buffer.byteLength) throw new RangeError("byteOffset out of range");
- if (this.byteOffset % this.BYTES_PER_ELEMENT) throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");
- if (arguments.length < 3) {
- 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");
- this.length = this.byteLength / this.BYTES_PER_ELEMENT
- } else this.length = C.ToUint32(f), this.byteLength = this.length * this.BYTES_PER_ELEMENT;
- if (this.byteOffset + this.byteLength > this.buffer.byteLength) throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")
- } else
- 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));
- else {
- if (this.length = C.ToInt32(arguments[0]), 0 > f) throw new RangeError("ArrayBufferView size is not a small enough positive integer");
- this.byteLength = this.length * this.BYTES_PER_ELEMENT, this.buffer = new b(this.byteLength), this.byteOffset = 0
- }
- this.constructor = h, d(this), e(this)
- }, 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) {
- if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
- if (a = C.ToUint32(a), a >= this.length) return A;
- var b, c, d = [];
- 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]);
- return this._unpack(d)
- }, h.prototype.get = h.prototype._getter, h.prototype._setter = function(a, b) {
- if (arguments.length < 2) throw new SyntaxError("Not enough arguments");
- if (a = C.ToUint32(a), a >= this.length) return A;
- var c, d, e = this._pack(b);
- 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]
- }, h.prototype.set = function() {
- if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
- var a, b, c, d, e, f, g, h, i, j;
- if ("object" == typeof arguments[0] && arguments[0].constructor === this.constructor) {
- 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");
- if (h = this.byteOffset + c * this.BYTES_PER_ELEMENT, i = a.length * this.BYTES_PER_ELEMENT, a.buffer === this.buffer) {
- for (j = [], e = 0, f = a.byteOffset; i > e; e += 1, f += 1) j[e] = a.buffer._bytes[f];
- for (e = 0, g = h; i > e; e += 1, g += 1) this.buffer._bytes[g] = j[e]
- } else
- for (e = 0, f = a.byteOffset, g = h; i > e; e += 1, f += 1, g += 1) this.buffer._bytes[g] = a.buffer._bytes[f]
- } else {
- if ("object" != typeof arguments[0] || "undefined" == typeof arguments[0].length) throw new TypeError("Unexpected argument type(s)");
- 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");
- for (e = 0; d > e; e += 1) f = b[e], this._setter(c + e, Number(f))
- }
- }, h.prototype.subarray = function(a, b) {
- function c(a, b, c) {
- return b > a ? b : a > c ? c : a
- }
- 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);
- var d = b - a;
- return 0 > d && (d = 0), new this.constructor(this.buffer, this.byteOffset + a * this.BYTES_PER_ELEMENT, d)
- }, h
- }
- var b = function(a) {
- if (a = C.ToInt32(a), 0 > a) throw new RangeError("ArrayBuffer size is not a small enough positive integer");
- this.byteLength = a, this._bytes = [], this._bytes.length = a;
- var b;
- for (b = 0; b < this.byteLength; b += 1) this._bytes[b] = 0;
- d(this)
- };
- c.ArrayBuffer = c.ArrayBuffer || b;
- var f = function() {},
- g = a(1, h, i),
- u = a(1, j, k),
- v = a(1, l, k),
- B = a(2, m, n),
- D = a(2, o, p),
- E = a(4, q, r),
- F = a(4, s, t),
- G = a(4, z, y),
- H = a(8, x, w);
- 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
- }(),
- function() {
- function a(a, b) {
- return C.IsCallable(a.get) ? a.get(b) : a[b]
- }
- function b(b) {
- return function(c, d) {
- if (c = C.ToUint32(c), c + b.BYTES_PER_ELEMENT > this.byteLength) throw new RangeError("Array index out of range");
- c += this.byteOffset;
- var e, g = new Uint8Array(this.buffer, c, b.BYTES_PER_ELEMENT),
- h = [];
- for (e = 0; e < b.BYTES_PER_ELEMENT; e += 1) h.push(a(g, e));
- return Boolean(d) === Boolean(f) && h.reverse(), a(new b(new Uint8Array(h).buffer), 0)
- }
- }
- function e(b) {
- return function(c, d, e) {
- if (c = C.ToUint32(c), c + b.BYTES_PER_ELEMENT > this.byteLength) throw new RangeError("Array index out of range");
- var g, h, i = new b([d]),
- j = new Uint8Array(i.buffer),
- k = [];
- for (g = 0; g < b.BYTES_PER_ELEMENT; g += 1) k.push(a(j, g));
- Boolean(e) === Boolean(f) && k.reverse(), h = new Uint8Array(this.buffer, c, b.BYTES_PER_ELEMENT), h.set(k)
- }
- }
- var f = function() {
- var b = new c.Uint16Array([4660]),
- d = new c.Uint8Array(b.buffer);
- return 18 === a(d, 0)
- }(),
- g = function(a, b, c) {
- if (0 === arguments.length) a = new ArrayBuffer(0);
- else if (!(a instanceof ArrayBuffer || "ArrayBuffer" === C.Class(a))) throw new TypeError("TypeError");
- if (this.buffer = a || new ArrayBuffer(0), this.byteOffset = C.ToUint32(b), this.byteOffset > this.buffer.byteLength) throw new RangeError("byteOffset out of range");
- 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");
- d(this)
- };
- 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
- }()
- }, {}]
- }, {}, []), b.exports = a("native-buffer-browserify").Buffer
- }, {}],
- 2: [function(a, b) {
- var c = b.exports = {};
- c.nextTick = function() {
- var a = "undefined" != typeof window && window.setImmediate,
- b = "undefined" != typeof window && window.postMessage && window.addEventListener;
- if (a) return function(a) {
- return window.setImmediate(a)
- };
- if (b) {
- var c = [];
- return window.addEventListener("message", function(a) {
- if (a.source === window && "process-tick" === a.data && (a.stopPropagation(), c.length > 0)) {
- var b = c.shift();
- b()
- }
- }, !0),
- function(a) {
- c.push(a), window.postMessage("process-tick", "*")
- }
- }
- return function(a) {
- setTimeout(a, 0)
- }
- }(), c.title = "browser", c.browser = !0, c.env = {}, c.argv = [], c.binding = function() {
- throw new Error("process.binding is not supported")
- }, c.cwd = function() {
- return "/"
- }, c.chdir = function() {
- throw new Error("process.chdir is not supported")
- }
- }, {}],
- 3: [function(a, b) {
- function c() {}
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Scalar"));
- b.exports = c, c.lineInt = function(a, b, c) {
- c = c || 0;
- var e, f, g, h, i, j, k, l = [0, 0];
- 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
- }, c.segmentsIntersect = function(a, b, c, d) {
- var e = b[0] - a[0],
- f = b[1] - a[1],
- g = d[0] - c[0],
- h = d[1] - c[1];
- if (g * f - h * e == 0) return !1;
- var i = (e * (c[1] - a[1]) + f * (a[0] - c[0])) / (g * f - h * e),
- j = (g * (a[1] - c[1]) + h * (c[0] - a[0])) / (h * e - g * f);
- return i >= 0 && 1 >= i && j >= 0 && 1 >= j
- }
- }, {
- "./Scalar": 6,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 4: [function(a, b) {
- function c() {}
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c, c.area = function(a, b, c) {
- return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])
- }, c.left = function(a, b, d) {
- return c.area(a, b, d) > 0
- }, c.leftOn = function(a, b, d) {
- return c.area(a, b, d) >= 0
- }, c.right = function(a, b, d) {
- return c.area(a, b, d) < 0
- }, c.rightOn = function(a, b, d) {
- return c.area(a, b, d) <= 0
- };
- var d = [],
- e = [];
- c.collinear = function(a, b, f, g) {
- if (g) {
- var h = d,
- i = e;
- h[0] = b[0] - a[0], h[1] = b[1] - a[1], i[0] = f[0] - b[0], i[1] = f[1] - b[1];
- var j = h[0] * i[0] + h[1] * i[1],
- k = Math.sqrt(h[0] * h[0] + h[1] * h[1]),
- l = Math.sqrt(i[0] * i[0] + i[1] * i[1]),
- m = Math.acos(j / (k * l));
- return g > m
- }
- return 0 == c.area(a, b, f)
- }, c.sqdist = function(a, b) {
- var c = b[0] - a[0],
- d = b[1] - a[1];
- return c * c + d * d
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 5: [function(a, b) {
- function c() {
- this.vertices = []
- }
- function d(a, b, c, d, e) {
- e = e || 0;
- var f = b[1] - a[1],
- h = a[0] - b[0],
- i = f * a[0] + h * a[1],
- j = d[1] - c[1],
- k = c[0] - d[0],
- l = j * c[0] + k * c[1],
- m = f * k - j * h;
- return g.eq(m, 0, e) ? [0, 0] : [(k * i - h * l) / m, (f * l - j * i) / m]
- }
- var e = (a("__browserify_process"), a("__browserify_Buffer"), a("./Line")),
- f = a("./Point"),
- g = a("./Scalar");
- b.exports = c, c.prototype.at = function(a) {
- var b = this.vertices,
- c = b.length;
- return b[0 > a ? a % c + c : a % c]
- }, c.prototype.first = function() {
- return this.vertices[0]
- }, c.prototype.last = function() {
- return this.vertices[this.vertices.length - 1]
- }, c.prototype.clear = function() {
- this.vertices.length = 0
- }, c.prototype.append = function(a, b, c) {
- if ("undefined" == typeof b) throw new Error("From is not given!");
- if ("undefined" == typeof c) throw new Error("To is not given!");
- if (b > c - 1) throw new Error("lol1");
- if (c > a.vertices.length) throw new Error("lol2");
- if (0 > b) throw new Error("lol3");
- for (var d = b; c > d; d++) this.vertices.push(a.vertices[d])
- }, c.prototype.makeCCW = function() {
- 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);
- f.left(this.at(a - 1), this.at(a), this.at(a + 1)) || this.reverse()
- }, c.prototype.reverse = function() {
- for (var a = [], b = 0, c = this.vertices.length; b !== c; b++) a.push(this.vertices.pop());
- this.vertices = a
- }, c.prototype.isReflex = function(a) {
- return f.right(this.at(a - 1), this.at(a), this.at(a + 1))
- };
- var h = [],
- i = [];
- c.prototype.canSee = function(a, b) {
- var c, d, g = h,
- j = i;
- 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;
- d = f.sqdist(this.at(a), this.at(b));
- for (var k = 0; k !== this.vertices.length; ++k)
- 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;
- return !0
- }, c.prototype.copy = function(a, b, d) {
- var e = d || new c;
- if (e.clear(), b > a)
- for (var f = a; b >= f; f++) e.vertices.push(this.vertices[f]);
- else {
- for (var f = 0; b >= f; f++) e.vertices.push(this.vertices[f]);
- for (var f = a; f < this.vertices.length; f++) e.vertices.push(this.vertices[f])
- }
- return e
- }, c.prototype.getCutEdges = function() {
- for (var a = [], b = [], d = [], e = new c, f = Number.MAX_VALUE, g = 0; g < this.vertices.length; ++g)
- if (this.isReflex(g))
- for (var h = 0; h < this.vertices.length; ++h)
- if (this.canSee(g, h)) {
- b = this.copy(g, h, e).getCutEdges(), d = this.copy(h, g, e).getCutEdges();
- for (var i = 0; i < d.length; i++) b.push(d[i]);
- b.length < f && (a = b, f = b.length, a.push([this.at(g), this.at(h)]))
- }
- return a
- }, c.prototype.decomp = function() {
- var a = this.getCutEdges();
- return a.length > 0 ? this.slice(a) : [this]
- }, c.prototype.slice = function(a) {
- if (0 == a.length) return [this];
- if (a instanceof Array && a.length && a[0] instanceof Array && 2 == a[0].length && a[0][0] instanceof Array) {
- for (var b = [this], c = 0; c < a.length; c++)
- for (var d = a[c], e = 0; e < b.length; e++) {
- var f = b[e],
- g = f.slice(d);
- if (g) {
- b.splice(e, 1), b.push(g[0], g[1]);
- break
- }
- }
- return b
- }
- var d = a,
- c = this.vertices.indexOf(d[0]),
- e = this.vertices.indexOf(d[1]);
- return -1 != c && -1 != e ? [this.copy(c, e), this.copy(e, c)] : !1
- }, c.prototype.isSimple = function() {
- for (var a = this.vertices, b = 0; b < a.length - 1; b++)
- for (var c = 0; b - 1 > c; c++)
- if (e.segmentsIntersect(a[b], a[b + 1], a[c], a[c + 1])) return !1;
- for (var b = 1; b < a.length - 2; b++)
- if (e.segmentsIntersect(a[0], a[a.length - 1], a[b], a[b + 1])) return !1;
- return !0
- }, c.prototype.quickDecomp = function(a, b, e, g, h, i) {
- h = h || 100, i = i || 0, g = g || 25, a = "undefined" != typeof a ? a : [], b = b || [], e = e || [];
- var j = [0, 0],
- k = [0, 0],
- l = [0, 0],
- m = 0,
- n = 0,
- o = 0,
- p = 0,
- q = 0,
- r = 0,
- s = 0,
- t = new c,
- u = new c,
- v = this,
- w = this.vertices;
- if (w.length < 3) return a;
- if (i++, i > h) return console.warn("quickDecomp: max level (" + h + ") reached."), a;
- for (var x = 0; x < this.vertices.length; ++x)
- if (v.isReflex(x)) {
- b.push(v.vertices[x]), m = n = Number.MAX_VALUE;
- 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)));
- 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));
- else {
- if (r > q && (q += this.vertices.length), p = Number.MAX_VALUE, r > q) return a;
- 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));
- 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))
- }
- 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
- }
- return a.push(this), a
- }, c.prototype.removeCollinearPoints = function(a) {
- 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++);
- return b
- }
- }, {
- "./Line": 3,
- "./Point": 4,
- "./Scalar": 6,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 6: [function(a, b) {
- function c() {}
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c, c.eq = function(a, b, c) {
- return c = c || 0, Math.abs(a - b) < c
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 7: [function(a, b) {
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = {
- Polygon: a("./Polygon"),
- Point: a("./Point")
- }
- }, {
- "./Point": 4,
- "./Polygon": 5,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 8: [function(a, b) {
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = {
- name: "p2",
- version: "0.6.0",
- description: "A JavaScript 2D physics engine.",
- author: "www.play68.com",//"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
- keywords: ["p2.js", "p2", "physics", "engine", "2d"],
- main: "./src/p2.js",
- engines: {
- node: "*"
- },
- repository: {
- type: "git",
- url: "http://www.play68.com"
- },
- bugs: {
- url: "http://www.play68.com"
- },
- licenses: [{
- type: "MIT"
- }],
- devDependencies: {
- grunt: "~0.4.0",
- "grunt-contrib-jshint": "~0.9.2",
- "grunt-contrib-nodeunit": "~0.1.2",
- "grunt-contrib-uglify": "~0.4.0",
- "grunt-contrib-watch": "~0.5.0",
- "grunt-browserify": "~2.0.1",
- "grunt-contrib-concat": "^0.4.0"
- },
- dependencies: {
- "poly-decomp": "0.1.0"
- }
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 9: [function(a, b) {
- function c(a) {
- 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)
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"));
- a("../utils/Utils")
- }
- b.exports = c;
- var e = d.create();
- c.prototype.setFromPoints = function(a, b, c, f) {
- var g = this.lowerBound,
- h = this.upperBound;
- "number" != typeof c && (c = 0), 0 !== c ? d.rotate(g, a[0], c) : d.copy(g, a[0]), d.copy(h, g);
- for (var i = Math.cos(c), j = Math.sin(c), k = 1; k < a.length; k++) {
- var l = a[k];
- if (0 !== c) {
- var m = l[0],
- n = l[1];
- e[0] = i * m - j * n, e[1] = j * m + i * n, l = e
- }
- for (var o = 0; 2 > o; o++) l[o] > h[o] && (h[o] = l[o]), l[o] < g[o] && (g[o] = l[o])
- }
- 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)
- }, c.prototype.copy = function(a) {
- d.copy(this.lowerBound, a.lowerBound), d.copy(this.upperBound, a.upperBound)
- }, c.prototype.extend = function(a) {
- for (var b = 2; b--;) {
- var c = a.lowerBound[b];
- this.lowerBound[b] > c && (this.lowerBound[b] = c);
- var d = a.upperBound[b];
- this.upperBound[b] < d && (this.upperBound[b] = d)
- }
- }, c.prototype.overlaps = function(a) {
- var b = this.lowerBound,
- c = this.upperBound,
- d = a.lowerBound,
- e = a.upperBound;
- 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])
- }
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 10: [function(a, b) {
- function c(a) {
- this.type = a, this.result = [], this.world = null, this.boundingVolumeType = c.AABB
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- e = a("../objects/Body");
- b.exports = c, c.AABB = 1, c.BOUNDING_CIRCLE = 2, c.prototype.setWorld = function(a) {
- this.world = a
- }, c.prototype.getCollisionPairs = function() {
- throw new Error("getCollisionPairs must be implemented in a subclass!")
- };
- var f = d.create();
- c.boundingRadiusCheck = function(a, b) {
- d.sub(f, a.position, b.position);
- var c = d.squaredLength(f),
- e = a.boundingRadius + b.boundingRadius;
- return e * e >= c
- }, c.aabbCheck = function(a, b) {
- return a.getAABB().overlaps(b.getAABB())
- }, c.prototype.boundingVolumeCheck = function(a, b) {
- var d;
- switch (this.boundingVolumeType) {
- case c.BOUNDING_CIRCLE:
- d = c.boundingRadiusCheck(a, b);
- break;
- case c.AABB:
- d = c.aabbCheck(a, b);
- break;
- default:
- throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType)
- }
- return d
- }, c.canCollide = function(a, b) {
- 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
- }, c.NAIVE = 1, c.SAP = 2
- }, {
- "../math/vec2": 31,
- "../objects/Body": 32,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 11: [function(a, b) {
- function c(a) {
- d.apply(this), a = e.defaults(a, {
- xmin: -100,
- xmax: 100,
- ymin: -100,
- ymax: 100,
- nx: 10,
- ny: 10
- }), 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
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Particle"), a("../collision/Broadphase")),
- e = (a("../math/vec2"), a("../utils/Utils"));
- b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
- 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([]);
- for (var o = f / (j - h), p = g / (k - i), n = 0; n !== e; n++)
- 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++)
- for (var B = x; z >= B; B++) {
- var C = A,
- D = B,
- E = C * (g - 1) + D;
- E >= 0 && m > E && l[E].push(q)
- }
- for (var n = 0; n !== m; n++)
- for (var F = l[n], A = 0, G = F.length; A !== G; A++)
- for (var q = F[A], B = 0; B !== A; B++) {
- var H = F[B];
- d.canCollide(q, H) && this.boundingVolumeCheck(q, H) && b.push(q, H)
- }
- return b
- }
- }, {
- "../collision/Broadphase": 10,
- "../math/vec2": 31,
- "../shapes/Circle": 38,
- "../shapes/Particle": 42,
- "../shapes/Plane": 43,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 12: [function(a, b) {
- function c() {
- d.call(this, d.NAIVE)
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Shape"), a("../shapes/Particle"), a("../collision/Broadphase"));
- a("../math/vec2")
- }
- b.exports = c, c.prototype = new d, c.prototype.getCollisionPairs = function(a) {
- var b = a.bodies,
- c = this.result;
- c.length = 0;
- for (var e = 0, f = b.length; e !== f; e++)
- for (var g = b[e], h = 0; e > h; h++) {
- var i = b[h];
- d.canCollide(g, i) && this.boundingVolumeCheck(g, i) && c.push(g, i)
- }
- return c
- }
- }, {
- "../collision/Broadphase": 10,
- "../math/vec2": 31,
- "../shapes/Circle": 38,
- "../shapes/Particle": 42,
- "../shapes/Plane": 43,
- "../shapes/Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 13: [function(a, b) {
- function c() {
- 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
- }
- function d(a, b) {
- 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)
- }
- function e(a, b, c, d) {
- for (var e = R, i = S, j = T, k = U, l = a, m = b.vertices, n = null, o = 0; o !== m.length + 1; o++) {
- var p = m[o % m.length],
- q = m[(o + 1) % m.length];
- 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);
- var r = f.crossLength(j, k);
- if (null === n && (n = r), 0 >= r * n) return !1;
- n = r
- }
- return !0
- }
- var f = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- g = f.sub,
- h = f.add,
- i = f.dot,
- j = a("../utils/Utils"),
- k = a("../utils/TupleDictionary"),
- l = a("../equations/Equation"),
- m = a("../equations/ContactEquation"),
- n = a("../equations/FrictionEquation"),
- o = a("../shapes/Circle"),
- p = a("../shapes/Convex"),
- q = a("../shapes/Shape"),
- r = (a("../objects/Body"), a("../shapes/Rectangle"));
- b.exports = c;
- var s = f.fromValues(0, 1),
- t = f.fromValues(0, 0),
- u = f.fromValues(0, 0),
- v = f.fromValues(0, 0),
- w = f.fromValues(0, 0),
- x = f.fromValues(0, 0),
- y = f.fromValues(0, 0),
- z = f.fromValues(0, 0),
- A = f.fromValues(0, 0),
- B = f.fromValues(0, 0),
- C = f.fromValues(0, 0),
- D = f.fromValues(0, 0),
- E = f.fromValues(0, 0),
- F = f.fromValues(0, 0),
- G = f.fromValues(0, 0),
- H = f.fromValues(0, 0),
- I = f.fromValues(0, 0),
- J = f.fromValues(0, 0),
- K = f.fromValues(0, 0),
- L = [];
- c.prototype.collidedLastStep = function(a, b) {
- var c = 0 | a.id,
- d = 0 | b.id;
- return !!this.collidingBodiesLastStep.get(c, d)
- }, c.prototype.reset = function() {
- this.collidingBodiesLastStep.reset();
- for (var a = this.contactEquations, b = a.length; b--;) {
- var c = a[b],
- d = c.bodyA.id,
- e = c.bodyB.id;
- this.collidingBodiesLastStep.set(d, e, !0)
- }
- if (this.reuseObjects) {
- var f = this.contactEquations,
- g = this.frictionEquations,
- h = this.reusableFrictionEquations,
- i = this.reusableContactEquations;
- j.appendArray(i, f), j.appendArray(h, g)
- }
- this.contactEquations.length = this.frictionEquations.length = 0
- }, c.prototype.createContactEquation = function(a, b, c, d) {
- var e = this.reusableContactEquations.length ? this.reusableContactEquations.pop() : new m(a, b);
- 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
- }, c.prototype.createFrictionEquation = function(a, b, c, d) {
- var e = this.reusableFrictionEquations.length ? this.reusableFrictionEquations.pop() : new n(a, b);
- 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
- }, c.prototype.createFrictionFromContact = function(a) {
- var b = this.createFrictionEquation(a.bodyA, a.bodyB, a.shapeA, a.shapeB);
- return f.copy(b.contactPointA, a.contactPointA), f.copy(b.contactPointB, a.contactPointB), f.rotate90cw(b.t, a.normalA), b.contactEquations.push(a), b
- }, c.prototype.createFrictionFromAverage = function(a) {
- if (!a) throw new Error("numContacts == 0!"); {
- var b = this.contactEquations[this.contactEquations.length - 1],
- c = this.createFrictionEquation(b.bodyA, b.bodyB, b.shapeA, b.shapeB),
- d = b.bodyA;
- b.bodyB
- }
- f.set(c.contactPointA, 0, 0), f.set(c.contactPointB, 0, 0), f.set(c.t, 0, 0);
- 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);
- var g = 1 / a;
- 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
- }, c.prototype[q.LINE | q.CONVEX] = c.prototype.convexLine = function(a, b, c, d, e, f, g, h, i) {
- return i ? !1 : 0
- }, c.prototype[q.LINE | q.RECTANGLE] = c.prototype.lineRectangle = function(a, b, c, d, e, f, g, h, i) {
- return i ? !1 : 0
- };
- var M = new r(1, 1),
- N = f.create();
- 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) {
- var l = N;
- f.set(l, h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
- var m = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
- f.set(l, -h.length / 2, 0), f.rotate(l, l, j), f.add(l, l, i);
- var n = this.circleConvex(g, h, l, j, a, b, c, e, k, h.radius);
- if (k && (m || n)) return !0;
- var o = M;
- d(o, h);
- var p = this.convexConvex(a, b, c, e, g, o, i, j, k);
- return p + m + n
- }, c.prototype[q.CAPSULE | q.LINE] = c.prototype.lineCapsule = function(a, b, c, d, e, f, g, h, i) {
- return i ? !1 : 0
- };
- var O = f.create(),
- P = f.create(),
- Q = new r(1, 1);
- c.prototype[q.CAPSULE | q.CAPSULE] = c.prototype.capsuleCapsule = function(a, b, c, e, g, h, i, j, k) {
- for (var l, m = O, n = P, o = 0, p = 0; 2 > p; p++) {
- f.set(m, (0 === p ? -1 : 1) * b.length / 2, 0), f.rotate(m, m, e), f.add(m, m, c);
- for (var q = 0; 2 > q; q++) {
- 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);
- var r = this.circleCircle(a, b, m, e, g, h, n, j, k, b.radius, h.radius);
- if (this.enableFrictionReduction && (this.enableFriction = l), k && r) return !0;
- o += r
- }
- }
- this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1);
- var s = Q;
- d(s, b);
- var t = this.convexCapsule(a, s, c, e, g, h, i, j, k);
- if (this.enableFrictionReduction && (this.enableFriction = l), k && t) return !0;
- if (o += t, this.enableFrictionReduction) {
- var l = this.enableFriction;
- this.enableFriction = !1
- }
- d(s, h);
- var u = this.convexCapsule(g, s, i, j, a, b, c, e, k);
- return this.enableFrictionReduction && (this.enableFriction = l), k && u ? !0 : (o += u, this.enableFrictionReduction && o && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(o)), o)
- }, c.prototype[q.LINE | q.LINE] = c.prototype.lineLine = function(a, b, c, d, e, f, g, h, i) {
- return i ? !1 : 0
- }, c.prototype[q.PLANE | q.LINE] = c.prototype.planeLine = function(a, b, c, d, e, j, k, l, m) {
- var n = t,
- o = u,
- p = v,
- q = w,
- r = x,
- C = y,
- D = z,
- E = A,
- F = B,
- G = L,
- H = 0;
- f.set(n, -j.length / 2, 0), f.set(o, j.length / 2, 0), f.rotate(p, n, l), f.rotate(q, o, l), h(p, p, k), h(q, q, k), f.copy(n, p), f.copy(o, q), g(r, o, n), f.normalize(C, r), f.rotate90cw(F, C), f.rotate(E, s, d), G[0] = n, G[1] = o;
- for (var I = 0; I < G.length; I++) {
- var J = G[I];
- g(D, J, c);
- var K = i(D, E);
- if (0 > K) {
- if (m) return !0;
- var M = this.createContactEquation(a, e, b, j);
- 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))
- }
- }
- return m ? !1 : (this.enableFrictionReduction || H && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(H)), H)
- }, c.prototype[q.PARTICLE | q.CAPSULE] = c.prototype.particleCapsule = function(a, b, c, d, e, f, g, h, i) {
- return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius, 0)
- }, c.prototype[q.CIRCLE | q.LINE] = c.prototype.circleLine = function(a, b, c, d, e, j, k, l, m, n, o) {
- var n = n || 0,
- o = "undefined" != typeof o ? o : b.radius,
- p = t,
- q = u,
- r = v,
- s = w,
- H = x,
- I = y,
- J = z,
- K = A,
- M = B,
- N = C,
- O = D,
- P = E,
- Q = F,
- R = G,
- S = L;
- 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);
- var T = i(P, H);
- g(s, K, k), g(Q, c, k);
- var U = o + n;
- if (Math.abs(T) < U) {
- 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);
- var V = i(J, r),
- W = i(J, K),
- X = i(J, M);
- if (V > W && X > V) {
- if (m) return !0;
- var Y = this.createContactEquation(a, e, b, j);
- 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
- }
- }
- S[0] = K, S[1] = M;
- for (var Z = 0; Z < S.length; Z++) {
- var $ = S[Z];
- if (g(P, $, c), f.squaredLength(P) < Math.pow(U, 2)) {
- if (m) return !0;
- var Y = this.createContactEquation(a, e, b, j);
- 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
- }
- }
- return 0
- }, c.prototype[q.CIRCLE | q.CAPSULE] = c.prototype.circleCapsule = function(a, b, c, d, e, f, g, h, i) {
- return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius)
- }, 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) {
- 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++) {
- var O = M[N % M.length],
- P = M[(N + 1) % M.length];
- 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)) {
- f.sub(E, o, B);
- var Q = Math.abs(f.dot(E, s));
- L > Q && (f.copy(J, B), L = Q, f.scale(A, s, Q), f.add(A, A, B), K = !0)
- }
- }
- if (K) {
- if (m) return !0;
- var R = this.createContactEquation(a, i, b, j);
- 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
- }
- if (n > 0)
- for (var N = 0; N < M.length; N++) {
- var S = M[N];
- if (f.rotate(z, S, l), h(z, z, k), g(y, z, c), f.squaredLength(y) < Math.pow(n, 2)) {
- if (m) return !0;
- var R = this.createContactEquation(a, i, b, j);
- 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
- }
- }
- return 0
- };
- var R = f.create(),
- S = f.create(),
- T = f.create(),
- U = f.create();
- 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) {
- var o = t,
- p = u,
- q = v,
- r = w,
- s = x,
- A = y,
- B = z,
- D = C,
- E = F,
- G = J,
- H = K,
- I = Number.MAX_VALUE,
- L = !1,
- M = k.vertices;
- if (!e(c, k, l, m)) return 0;
- if (n) return !0;
- for (var N = 0; N !== M.length + 1; N++) {
- var O = M[N % M.length],
- P = M[(N + 1) % M.length];
- 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); {
- i(D, s)
- }
- g(A, o, l), g(B, c, l), f.sub(G, o, c);
- var Q = Math.abs(f.dot(G, s));
- I > Q && (I = Q, f.scale(E, s, Q), f.add(E, E, c), f.copy(H, s), L = !0)
- }
- if (L) {
- var R = this.createContactEquation(a, j, b, k);
- 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
- }
- return 0
- }, c.prototype[q.CIRCLE] = c.prototype.circleCircle = function(a, b, c, d, e, i, j, k, l, m, n) {
- var o = t,
- m = m || b.radius,
- n = n || i.radius;
- g(o, c, j);
- var p = m + n;
- if (f.squaredLength(o) > Math.pow(p, 2)) return 0;
- if (l) return !0;
- var q = this.createContactEquation(a, e, b, i);
- 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
- }, 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) {
- var n = t,
- o = u,
- p = v,
- q = 0;
- f.rotate(o, s, d);
- for (var r = 0; r !== j.vertices.length; r++) {
- var w = j.vertices[r];
- if (f.rotate(n, w, l), h(n, n, k), g(p, n, c), i(p, o) <= 0) {
- if (m) return !0;
- q++;
- var x = this.createContactEquation(a, e, b, j);
- g(p, n, c), f.copy(x.normalA, o);
- var y = i(p, x.normalA);
- 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))
- }
- }
- return this.enableFrictionReduction && this.enableFriction && q && this.frictionEquations.push(this.createFrictionFromAverage(q)), q
- }, c.prototype[q.PARTICLE | q.PLANE] = c.prototype.particlePlane = function(a, b, c, d, e, h, j, k, l) {
- var m = t,
- n = u;
- k = k || 0, g(m, c, j), f.rotate(n, s, k);
- var o = i(m, n);
- if (o > 0) return 0;
- if (l) return !0;
- var p = this.createContactEquation(e, a, h, b);
- 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
- }, c.prototype[q.CIRCLE | q.PARTICLE] = c.prototype.circleParticle = function(a, b, c, d, e, i, j, k, l) {
- var m = t;
- if (g(m, j, c), f.squaredLength(m) > Math.pow(b.radius, 2)) return 0;
- if (l) return !0;
- var n = this.createContactEquation(a, e, b, i);
- 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
- }; {
- var V = new o(1),
- W = f.create(),
- X = f.create();
- f.create()
- }
- c.prototype[q.PLANE | q.CAPSULE] = c.prototype.planeCapsule = function(a, b, c, d, e, g, i, j, k) {
- var l = W,
- m = X,
- n = V;
- 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;
- var o;
- this.enableFrictionReduction && (o = this.enableFriction, this.enableFriction = !1);
- var p = this.circlePlane(e, n, l, 0, a, b, c, d, k),
- q = this.circlePlane(e, n, m, 0, a, b, c, d, k);
- if (this.enableFrictionReduction && (this.enableFriction = o), k) return p || q;
- var r = p + q;
- return this.enableFrictionReduction && r && this.frictionEquations.push(this.createFrictionFromAverage(r)), r
- }, c.prototype[q.CIRCLE | q.PLANE] = c.prototype.circlePlane = function(a, b, c, d, e, j, k, l, m) {
- var n = a,
- o = b,
- p = c,
- q = e,
- r = k,
- w = l;
- w = w || 0;
- var x = t,
- y = u,
- z = v;
- g(x, p, r), f.rotate(y, s, w);
- var A = i(y, x);
- if (A > o.radius) return 0;
- if (m) return !0;
- var B = this.createContactEquation(q, n, j, b);
- 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
- }, 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) {
- var p = t,
- q = u,
- r = v,
- s = w,
- y = x,
- C = z,
- D = A,
- E = B,
- F = 0,
- o = "number" == typeof o ? o : 0,
- G = c.findSeparatingAxis(b, d, e, k, l, m, p);
- if (!G) return 0;
- g(D, l, d), i(p, D) > 0 && f.scale(p, p, -1);
- var H = c.getClosestEdge(b, e, p, !0),
- I = c.getClosestEdge(k, m, p);
- if (-1 === H || -1 === I) return 0;
- for (var J = 0; 2 > J; J++) {
- var K = H,
- L = I,
- M = b,
- N = k,
- O = d,
- P = l,
- Q = e,
- R = m,
- S = a,
- T = j;
- if (0 === J) {
- var U;
- 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
- }
- for (var V = L; L + 2 > V; V++) {
- var W = N.vertices[(V + N.vertices.length) % N.vertices.length];
- f.rotate(q, W, R), h(q, q, P);
- for (var X = 0, Y = K - 1; K + 2 > Y; Y++) {
- var Z = M.vertices[(Y + M.vertices.length) % M.vertices.length],
- $ = M.vertices[(Y + 1 + M.vertices.length) % M.vertices.length];
- 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);
- var _ = i(E, D);
- (Y === K && o >= _ || Y !== K && 0 >= _) && X++
- }
- if (X >= 3) {
- if (n) return !0;
- var ab = this.createContactEquation(S, T, M, N);
- F++;
- var Z = M.vertices[K % M.vertices.length],
- $ = M.vertices[(K + 1) % M.vertices.length];
- 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);
- var _ = i(ab.normalA, D);
- 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))
- }
- }
- }
- return this.enableFrictionReduction && this.enableFriction && F && this.frictionEquations.push(this.createFrictionFromAverage(F)), F
- };
- var Y = f.fromValues(0, 0);
- c.projectConvexOntoAxis = function(a, b, c, d, e) {
- var g, h, j = null,
- k = null,
- l = Y;
- f.rotate(l, d, -c);
- 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);
- if (k > j) {
- var n = k;
- k = j, j = n
- }
- var o = i(b, d);
- f.set(e, k + o, j + o)
- };
- var Z = f.fromValues(0, 0),
- $ = f.fromValues(0, 0),
- _ = f.fromValues(0, 0),
- ab = f.fromValues(0, 0),
- bb = f.fromValues(0, 0),
- cb = f.fromValues(0, 0);
- c.findSeparatingAxis = function(a, b, d, e, h, i, j) {
- var k = null,
- l = !1,
- m = !1,
- n = Z,
- o = $,
- p = _,
- q = ab,
- s = bb,
- t = cb;
- if (a instanceof r && e instanceof r)
- for (var u = 0; 2 !== u; u++) {
- var v = a,
- w = d;
- 1 === u && (v = e, w = i);
- for (var x = 0; 2 !== x; x++) {
- 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);
- var y = s,
- z = t,
- A = !1;
- s[0] > t[0] && (z = s, y = t, A = !0);
- var B = z[0] - y[1];
- l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
- }
- } else
- for (var u = 0; 2 !== u; u++) {
- var v = a,
- w = d;
- 1 === u && (v = e, w = i);
- for (var x = 0; x !== v.vertices.length; x++) {
- 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);
- var y = s,
- z = t,
- A = !1;
- s[0] > t[0] && (z = s, y = t, A = !0);
- var B = z[0] - y[1];
- l = 0 >= B, (null === k || B > k) && (f.copy(j, q), k = B, m = l)
- }
- }
- return m
- };
- var db = f.fromValues(0, 0),
- eb = f.fromValues(0, 0),
- fb = f.fromValues(0, 0);
- c.getClosestEdge = function(a, b, c, d) {
- var e = db,
- h = eb,
- j = fb;
- f.rotate(e, c, -b), d && f.scale(e, e, -1);
- for (var k = -1, l = a.vertices.length, m = -1, n = 0; n !== l; n++) {
- g(h, a.vertices[(n + 1) % l], a.vertices[n % l]), f.rotate90cw(j, h), f.normalize(j, j);
- var o = i(j, e);
- (-1 === k || o > m) && (k = n % l, m = o)
- }
- return k
- };
- var gb = f.create(),
- hb = f.create(),
- ib = f.create(),
- jb = f.create(),
- kb = f.create(),
- lb = f.create(),
- mb = f.create();
- c.prototype[q.CIRCLE | q.HEIGHTFIELD] = c.prototype.circleHeightfield = function(a, b, c, d, e, i, j, k, l, m) {
- var n = i.data,
- m = m || b.radius,
- o = i.elementWidth,
- p = hb,
- q = gb,
- r = kb,
- s = mb,
- t = lb,
- u = ib,
- v = jb,
- w = Math.floor((c[0] - m - j[0]) / o),
- x = Math.ceil((c[0] + m - j[0]) / o);
- 0 > w && (w = 0), x >= n.length && (x = n.length - 1);
- 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]);
- if (c[1] - m > y) return l ? !1 : 0;
- for (var B = !1, A = w; x > A; A++) {
- 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);
- var C = f.dot(p, t);
- if (q[0] >= u[0] && q[0] < v[0] && 0 >= C) {
- if (l) return !0;
- B = !0, f.scale(p, t, -C), f.add(r, q, p), f.copy(s, t);
- var D = this.createContactEquation(e, a, i, b);
- 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))
- }
- }
- if (B = !1, m > 0)
- for (var A = w; x >= A; A++)
- 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)) {
- if (l) return !0;
- B = !0;
- var D = this.createContactEquation(e, a, i, b);
- 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))
- }
- return B ? 1 : 0
- };
- var nb = f.create(),
- ob = f.create(),
- pb = f.create(),
- qb = new p([f.create(), f.create(), f.create(), f.create()]);
- 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) {
- var k = g.data,
- l = g.elementWidth,
- m = nb,
- n = ob,
- o = pb,
- p = qb,
- q = Math.floor((a.aabb.lowerBound[0] - h[0]) / l),
- r = Math.ceil((a.aabb.upperBound[0] - h[0]) / l);
- 0 > q && (q = 0), r >= k.length && (r = k.length - 1);
- 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]);
- if (a.aabb.lowerBound[1] > s) return j ? !1 : 0;
- for (var v = 0, u = q; r > u; u++) {
- 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);
- var w = 100;
- 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)
- }
- return v
- }
- }, {
- "../equations/ContactEquation": 22,
- "../equations/Equation": 23,
- "../equations/FrictionEquation": 24,
- "../math/vec2": 31,
- "../objects/Body": 32,
- "../shapes/Circle": 38,
- "../shapes/Convex": 39,
- "../shapes/Rectangle": 44,
- "../shapes/Shape": 45,
- "../utils/TupleDictionary": 49,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 14: [function(a, b) {
- function c() {
- e.call(this, e.SAP), this.axisList = [], this.axisIndex = 0;
- var a = this;
- this._addBodyHandler = function(b) {
- a.axisList.push(b.body)
- }, this._removeBodyHandler = function(b) {
- var c = a.axisList.indexOf(b.body); - 1 !== c && a.axisList.splice(c, 1)
- }
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../utils/Utils")),
- e = a("../collision/Broadphase");
- b.exports = c, c.prototype = new e, c.prototype.setWorld = function(a) {
- 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
- }, c.sortAxisList = function(a, b) {
- b = 0 | b;
- for (var c = 1, d = a.length; d > c; c++) {
- 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];
- a[f + 1] = e
- }
- return a
- }, c.prototype.getCollisionPairs = function() {
- var a = this.axisList,
- b = this.result,
- d = this.axisIndex;
- b.length = 0;
- for (var f = a.length; f--;) {
- var g = a[f];
- g.aabbNeedsUpdate && g.updateAABB()
- }
- c.sortAxisList(a, d);
- for (var h = 0, i = 0 | a.length; h !== i; h++)
- for (var j = a[h], k = h + 1; i > k; k++) {
- var l = a[k],
- m = l.aabb.lowerBound[d] <= j.aabb.upperBound[d];
- if (!m) break;
- e.canCollide(j, l) && this.boundingVolumeCheck(j, l) && b.push(j, l)
- }
- return b
- }
- }, {
- "../collision/Broadphase": 10,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 15: [function(a, b) {
- function c(a, b, c, e) {
- this.type = c, e = d.defaults(e, {
- collideConnected: !0,
- wakeUpBodies: !0
- }), this.equations = [], this.bodyA = a, this.bodyB = b, this.collideConnected = e.collideConnected, e.wakeUpBodies && (a && a.wakeUp(), b && b.wakeUp())
- }
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c;
- var d = a("../utils/Utils");
- c.prototype.update = function() {
- throw new Error("method update() not implmemented in this Constraint subclass!")
- }, c.DISTANCE = 1, c.GEAR = 2, c.LOCK = 3, c.PRISMATIC = 4, c.REVOLUTE = 5, c.prototype.setStiffness = function(a) {
- for (var b = this.equations, c = 0; c !== b.length; c++) {
- var d = b[c];
- d.stiffness = a, d.needsUpdate = !0
- }
- }, c.prototype.setRelaxation = function(a) {
- for (var b = this.equations, c = 0; c !== b.length; c++) {
- var d = b[c];
- d.relaxation = a, d.needsUpdate = !0
- }
- }
- }, {
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 16: [function(a, b) {
- function c(a, b, c) {
- c = g.defaults(c, {
- localAnchorA: [0, 0],
- localAnchorB: [0, 0]
- }), 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]);
- var h = this.localAnchorA,
- i = this.localAnchorB;
- if (this.distance = 0, "number" == typeof c.distance) this.distance = c.distance;
- else {
- var j = f.create(),
- k = f.create(),
- l = f.create();
- 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)
- }
- var m;
- m = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce;
- var n = new e(a, b, -m, m);
- this.equations = [n], this.maxForce = m;
- var l = f.create(),
- o = f.create(),
- p = f.create(),
- q = this;
- n.computeGq = function() {
- var a = this.bodyA,
- b = this.bodyB,
- c = a.position,
- d = b.position;
- 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
- }, this.setMaxForce(m), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, this.lowerLimit = 0, this.position = 0
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
- e = a("../equations/Equation"),
- f = a("../math/vec2"),
- g = a("../utils/Utils");
- b.exports = c, c.prototype = new d;
- var h = f.create(),
- i = f.create(),
- j = f.create();
- c.prototype.update = function() {
- var a = this.equations[0],
- b = this.bodyA,
- c = this.bodyB,
- d = (this.distance, b.position),
- e = c.position,
- g = this.equations[0],
- k = a.G;
- 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);
- var l = !1;
- 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);
- g.enabled = !0, f.normalize(h, h);
- var m = f.crossLength(i, h),
- n = f.crossLength(j, h);
- k[0] = -h[0], k[1] = -h[1], k[2] = -m, k[3] = h[0], k[4] = h[1], k[5] = n
- }, c.prototype.setMaxForce = function(a) {
- var b = this.equations[0];
- b.minForce = -a, b.maxForce = a
- }, c.prototype.getMaxForce = function() {
- var a = this.equations[0];
- return a.maxForce
- }
- }, {
- "../equations/Equation": 23,
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Constraint": 15,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 17: [function(a, b) {
- function c(a, b, c) {
- 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)
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
- e = (a("../equations/Equation"), a("../equations/AngleLockEquation"));
- a("../math/vec2")
- }
- b.exports = c, c.prototype = new d, c.prototype.update = function() {
- var a = this.equations[0];
- a.ratio !== this.ratio && a.setRatio(this.ratio), a.angle = this.angle
- }, c.prototype.setMaxTorque = function(a) {
- this.equations[0].setMaxTorque(a)
- }, c.prototype.getMaxTorque = function() {
- return this.equations[0].maxForce
- }
- }, {
- "../equations/AngleLockEquation": 21,
- "../equations/Equation": 23,
- "../math/vec2": 31,
- "./Constraint": 15,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 18: [function(a, b) {
- function c(a, b, c) {
- c = c || {}, d.call(this, a, b, d.LOCK, c);
- var g = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce,
- h = (c.localAngleB || 0, new f(a, b, -g, g)),
- i = new f(a, b, -g, g),
- j = new f(a, b, -g, g),
- k = e.create(),
- l = e.create(),
- m = this;
- h.computeGq = function() {
- return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[0]
- }, i.computeGq = function() {
- return e.rotate(k, m.localOffsetB, a.angle), e.sub(l, b.position, a.position), e.sub(l, l, k), l[1]
- };
- var n = e.create(),
- o = e.create();
- j.computeGq = function() {
- 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)
- }, 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)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
- e = a("../math/vec2"),
- f = a("../equations/Equation");
- b.exports = c, c.prototype = new d, c.prototype.setMaxForce = function(a) {
- for (var b = this.equations, c = 0; c < this.equations.length; c++) b[c].maxForce = a, b[c].minForce = -a
- }, c.prototype.getMaxForce = function() {
- return this.equations[0].maxForce
- };
- var g = e.create(),
- h = e.create(),
- i = e.create(),
- j = e.fromValues(1, 0),
- k = e.fromValues(0, 1);
- c.prototype.update = function() {
- var a = this.equations[0],
- b = this.equations[1],
- c = this.equations[2],
- d = this.bodyA,
- f = this.bodyB;
- 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)
- }
- }, {
- "../equations/Equation": 23,
- "../math/vec2": 31,
- "./Constraint": 15,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 19: [function(a, b) {
- function c(a, b, c) {
- c = c || {}, d.call(this, a, b, d.PRISMATIC, c);
- var i = g.fromValues(0, 0),
- j = g.fromValues(1, 0),
- k = g.fromValues(0, 0);
- 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;
- var l = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE,
- m = new f(a, b, -l, l),
- n = new g.create,
- o = new g.create,
- p = new g.create,
- q = new g.create;
- if (m.computeGq = function() {
- return g.dot(p, q)
- }, m.updateJacobian = function() {
- var c = this.G,
- d = a.position,
- e = b.position;
- 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)
- }, this.equations.push(m), !c.disableRotationalLock) {
- var r = new h(a, b, -l, l);
- this.equations.push(r)
- }
- 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; {
- var s = this,
- t = this.motorEquation;
- t.computeGW
- }
- t.computeGq = function() {
- return 0
- }, t.computeGW = function() {
- var a = this.G,
- b = this.bodyA,
- c = this.bodyB,
- d = b.velocity,
- e = c.velocity,
- f = b.angularVelocity,
- g = c.angularVelocity;
- return this.gmult(a, d, f, e, g) + s.motorSpeed
- }
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
- e = a("../equations/ContactEquation"),
- f = a("../equations/Equation"),
- g = a("../math/vec2"),
- h = a("../equations/RotationalLockEquation");
- b.exports = c, c.prototype = new d;
- var i = g.create(),
- j = g.create(),
- k = g.create(),
- l = g.create(),
- m = g.create(),
- n = g.create();
- c.prototype.update = function() {
- var a = this.equations,
- b = a[0],
- c = this.upperLimit,
- d = this.lowerLimit,
- e = this.upperLimitEquation,
- f = this.lowerLimitEquation,
- h = this.bodyA,
- o = this.bodyB,
- p = this.localAxisA,
- q = this.localAnchorA,
- r = this.localAnchorB;
- 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);
- var s = this.position = g.dot(k, i) - g.dot(j, i);
- if (this.motorEnabled) {
- var t = this.motorEquation.G;
- 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)
- }
- 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);
- else {
- var u = a.indexOf(e); - 1 !== u && a.splice(u, 1)
- }
- 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);
- else {
- var u = a.indexOf(f); - 1 !== u && a.splice(u, 1)
- }
- }, c.prototype.enableMotor = function() {
- this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
- }, c.prototype.disableMotor = function() {
- if (this.motorEnabled) {
- var a = this.equations.indexOf(this.motorEquation);
- this.equations.splice(a, 1), this.motorEnabled = !1
- }
- }, c.prototype.setLimits = function(a, b) {
- "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)
- }
- }, {
- "../equations/ContactEquation": 22,
- "../equations/Equation": 23,
- "../equations/RotationalLockEquation": 25,
- "../math/vec2": 31,
- "./Constraint": 15,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 20: [function(a, b) {
- function c(a, b, c) {
- c = c || {}, d.call(this, a, b, d.REVOLUTE, c);
- var n = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE;
- 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));
- var o = this.equations = [new e(a, b, -n, n), new e(a, b, -n, n)],
- p = o[0],
- q = o[1],
- r = this;
- p.computeGq = function() {
- 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)
- }, q.computeGq = function() {
- 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)
- }, 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
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Constraint")),
- e = a("../equations/Equation"),
- f = a("../equations/RotationalVelocityEquation"),
- g = a("../equations/RotationalLockEquation"),
- h = a("../math/vec2");
- b.exports = c;
- var i = h.create(),
- j = h.create(),
- k = h.fromValues(1, 0),
- l = h.fromValues(0, 1),
- m = h.create();
- c.prototype = new d, c.prototype.setLimits = function(a, b) {
- "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)
- }, c.prototype.update = function() {
- var a = this.bodyA,
- b = this.bodyB,
- c = this.pivotA,
- d = this.pivotB,
- e = this.equations,
- f = (e[0], e[1], e[0]),
- g = e[1],
- m = this.upperLimit,
- n = this.lowerLimit,
- o = this.upperLimitEquation,
- p = this.lowerLimitEquation,
- q = this.angle = b.angle - a.angle;
- if (this.upperLimitEnabled && q > m) o.angle = m, -1 === e.indexOf(o) && e.push(o);
- else {
- var r = e.indexOf(o); - 1 !== r && e.splice(r, 1)
- }
- if (this.lowerLimitEnabled && n > q) p.angle = n, -1 === e.indexOf(p) && e.push(p);
- else {
- var r = e.indexOf(p); - 1 !== r && e.splice(r, 1)
- }
- 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)
- }, c.prototype.enableMotor = function() {
- this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0)
- }, c.prototype.disableMotor = function() {
- if (this.motorEnabled) {
- var a = this.equations.indexOf(this.motorEquation);
- this.equations.splice(a, 1), this.motorEnabled = !1
- }
- }, c.prototype.motorIsEnabled = function() {
- return !!this.motorEnabled
- }, c.prototype.setMotorSpeed = function(a) {
- if (this.motorEnabled) {
- var b = this.equations.indexOf(this.motorEquation);
- this.equations[b].relativeVelocity = a
- }
- }, c.prototype.getMotorSpeed = function() {
- return this.motorEnabled ? this.motorEquation.relativeVelocity : !1
- }
- }, {
- "../equations/Equation": 23,
- "../equations/RotationalLockEquation": 25,
- "../equations/RotationalVelocityEquation": 26,
- "../math/vec2": 31,
- "./Constraint": 15,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 21: [function(a, b) {
- function c(a, b, c) {
- 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)
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation"));
- a("../math/vec2")
- }
- b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeGq = function() {
- return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle
- }, c.prototype.setRatio = function(a) {
- var b = this.G;
- b[2] = a, b[5] = -1, this.ratio = a
- }, c.prototype.setMaxTorque = function(a) {
- this.maxForce = a, this.minForce = -a
- }
- }, {
- "../math/vec2": 31,
- "./Equation": 23,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 22: [function(a, b) {
- function c(a, b) {
- 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
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
- var d = this.bodyA,
- f = this.bodyB,
- g = this.contactPointA,
- h = this.contactPointB,
- i = d.position,
- j = f.position,
- k = this.penetrationVec,
- l = this.normalA,
- m = this.G,
- n = e.crossLength(g, l),
- o = e.crossLength(h, l);
- 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);
- var p, q;
- 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());
- var r = this.computeGiMf(),
- s = -q * a - p * b - c * r;
- return s
- }
- }, {
- "../math/vec2": 31,
- "./Equation": 23,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 23: [function(a, b) {
- function c(a, b, d, f) {
- 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);
- for (var g = 0; 6 > g; g++) this.G[g] = 0;
- 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
- }
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c; {
- var d = a("../math/vec2"),
- e = a("../utils/Utils");
- a("../objects/Body")
- }
- c.prototype.constructor = c, c.DEFAULT_STIFFNESS = 1e6, c.DEFAULT_RELAXATION = 4, c.prototype.update = function() {
- var a = this.stiffness,
- b = this.relaxation,
- c = this.timeStep;
- 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
- }, c.prototype.gmult = function(a, b, c, d, e) {
- return a[0] * b[0] + a[1] * b[1] + a[2] * c + a[3] * d[0] + a[4] * d[1] + a[5] * e
- }, c.prototype.computeB = function(a, b, c) {
- var d = this.computeGW(),
- e = this.computeGq(),
- f = this.computeGiMf();
- return -e * a - d * b - f * c
- };
- var f = d.create(),
- g = d.create();
- c.prototype.computeGq = function() {
- var a = this.G,
- b = this.bodyA,
- c = this.bodyB,
- d = (b.position, c.position, b.angle),
- e = c.angle;
- return this.gmult(a, f, d, g, e) + this.offset
- }, c.prototype.computeGW = function() {
- var a = this.G,
- b = this.bodyA,
- c = this.bodyB,
- d = b.velocity,
- e = c.velocity,
- f = b.angularVelocity,
- g = c.angularVelocity;
- return this.gmult(a, d, f, e, g) + this.relativeVelocity
- }, c.prototype.computeGWlambda = function() {
- var a = this.G,
- b = this.bodyA,
- c = this.bodyB,
- d = b.vlambda,
- e = c.vlambda,
- f = b.wlambda,
- g = c.wlambda;
- return this.gmult(a, d, f, e, g)
- };
- var h = d.create(),
- i = d.create();
- c.prototype.computeGiMf = function() {
- var a = this.bodyA,
- b = this.bodyB,
- c = a.force,
- e = a.angularForce,
- f = b.force,
- g = b.angularForce,
- j = a.invMassSolve,
- k = b.invMassSolve,
- l = a.invInertiaSolve,
- m = b.invInertiaSolve,
- n = this.G;
- return d.scale(h, c, j), d.scale(i, f, k), this.gmult(n, h, e * l, i, g * m)
- }, c.prototype.computeGiMGt = function() {
- var a = this.bodyA,
- b = this.bodyB,
- c = a.invMassSolve,
- d = b.invMassSolve,
- e = a.invInertiaSolve,
- f = b.invInertiaSolve,
- g = this.G;
- 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
- }; {
- var j = d.create(),
- k = d.create(),
- l = d.create();
- d.create(), d.create(), d.create()
- }
- c.prototype.addToWlambda = function(a) {
- var b = this.bodyA,
- c = this.bodyB,
- e = j,
- f = k,
- g = l,
- h = b.invMassSolve,
- i = c.invMassSolve,
- m = b.invInertiaSolve,
- n = c.invInertiaSolve,
- o = this.G;
- 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
- }, c.prototype.computeInvC = function(a) {
- return 1 / (this.computeGiMGt() + a)
- }
- }, {
- "../math/vec2": 31,
- "../objects/Body": 32,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 24: [function(a, b) {
- function c(a, b, c) {
- 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
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- e = a("./Equation");
- a("../utils/Utils")
- }
- b.exports = c, c.prototype = new e, c.prototype.constructor = c, c.prototype.setSlipForce = function(a) {
- this.maxForce = a, this.minForce = -a
- }, c.prototype.getSlipForce = function() {
- return this.maxForce
- }, c.prototype.computeB = function(a, b, c) {
- var e = (this.bodyA, this.bodyB, this.contactPointA),
- f = this.contactPointB,
- g = this.t,
- h = this.G;
- 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);
- var i = this.computeGW(),
- j = this.computeGiMf(),
- k = -i * b - c * j;
- return k
- }
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Equation": 23,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 25: [function(a, b) {
- function c(a, b, c) {
- c = c || {}, d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0;
- var e = this.G;
- e[2] = 1, e[5] = -1
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.constructor = c;
- var f = e.create(),
- g = e.create(),
- h = e.fromValues(1, 0),
- i = e.fromValues(0, 1);
- c.prototype.computeGq = function() {
- return e.rotate(f, h, this.bodyA.angle + this.angle), e.rotate(g, i, this.bodyB.angle), e.dot(f, g)
- }
- }, {
- "../math/vec2": 31,
- "./Equation": 23,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 26: [function(a, b) {
- function c(a, b) {
- d.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Equation"));
- a("../math/vec2")
- }
- b.exports = c, c.prototype = new d, c.prototype.constructor = c, c.prototype.computeB = function(a, b, c) {
- var d = this.G;
- d[2] = -1, d[5] = this.ratio;
- var e = this.computeGiMf(),
- f = this.computeGW(),
- g = -f * b - c * e;
- return g
- }
- }, {
- "../math/vec2": 31,
- "./Equation": 23,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 27: [function(a, b) {
- var c = (a("__browserify_process"), a("__browserify_Buffer"), function() {});
- b.exports = c, c.prototype = {
- constructor: c,
- on: function(a, b, c) {
- b.context = c || this, void 0 === this._listeners && (this._listeners = {});
- var d = this._listeners;
- return void 0 === d[a] && (d[a] = []), -1 === d[a].indexOf(b) && d[a].push(b), this
- },
- has: function(a, b) {
- if (void 0 === this._listeners) return !1;
- var c = this._listeners;
- if (b) {
- if (void 0 !== c[a] && -1 !== c[a].indexOf(b)) return !0
- } else if (void 0 !== c[a]) return !0;
- return !1
- },
- off: function(a, b) {
- if (void 0 === this._listeners) return this;
- var c = this._listeners,
- d = c[a].indexOf(b);
- return -1 !== d && c[a].splice(d, 1), this
- },
- emit: function(a) {
- if (void 0 === this._listeners) return this;
- var b = this._listeners,
- c = b[a.type];
- if (void 0 !== c) {
- a.target = this;
- for (var d = 0, e = c.length; e > d; d++) {
- var f = c[d];
- f.call(f.context, a)
- }
- }
- return this
- }
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 28: [function(a, b) {
- function c(a, b, f) {
- if (f = f || {}, !(a instanceof d && b instanceof d)) throw new Error("First two arguments must be Material instances.");
- 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
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Material")),
- e = a("../equations/Equation");
- b.exports = c, c.idCounter = 0
- }, {
- "../equations/Equation": 23,
- "./Material": 29,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 29: [function(a, b) {
- function c(a) {
- this.id = a || c.idCounter++
- }
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c, c.idCounter = 0
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 30: [function(a, b) {
- var c = (a("__browserify_process"), a("__browserify_Buffer"), {});
- c.GetArea = function(a) {
- if (a.length < 6) return 0;
- 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]);
- return c += (a[0] - a[b]) * (a[b + 1] + a[1]), .5 * -c
- }, c.Triangulate = function(a) {
- var b = a.length >> 1;
- if (3 > b) return [];
- for (var d = [], e = [], f = 0; b > f; f++) e.push(f);
- for (var f = 0, g = b; g > 3;) {
- var h = e[(f + 0) % g],
- i = e[(f + 1) % g],
- j = e[(f + 2) % g],
- k = a[2 * h],
- l = a[2 * h + 1],
- m = a[2 * i],
- n = a[2 * i + 1],
- o = a[2 * j],
- p = a[2 * j + 1],
- q = !1;
- if (c._convex(k, l, m, n, o, p)) {
- q = !0;
- for (var r = 0; g > r; r++) {
- var s = e[r];
- if (s != h && s != i && s != j && c._PointInTriangle(a[2 * s], a[2 * s + 1], k, l, m, n, o, p)) {
- q = !1;
- break
- }
- }
- }
- if (q) d.push(h, i, j), e.splice((f + 1) % g, 1), g--, f = 0;
- else if (f++ > 3 * g) break
- }
- return d.push(e[0], e[1], e[2]), d
- }, c._PointInTriangle = function(a, b, c, d, e, f, g, h) {
- var i = g - c,
- j = h - d,
- k = e - c,
- l = f - d,
- m = a - c,
- n = b - d,
- o = i * i + j * j,
- p = i * k + j * l,
- q = i * m + j * n,
- r = k * k + l * l,
- s = k * m + l * n,
- t = 1 / (o * r - p * p),
- u = (r * q - p * s) * t,
- v = (o * s - p * q) * t;
- return u >= 0 && v >= 0 && 1 > u + v
- }, c._convex = function(a, b, c, d, e, f) {
- return (b - d) * (e - c) + (c - a) * (f - d) >= 0
- }, b.exports = c
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 31: [function(a, b) {
- var c = (a("__browserify_process"), a("__browserify_Buffer"), b.exports = {}),
- d = a("../utils/Utils");
- c.crossLength = function(a, b) {
- return a[0] * b[1] - a[1] * b[0]
- }, c.crossVZ = function(a, b, d) {
- return c.rotate(a, b, -Math.PI / 2), c.scale(a, a, d), a
- }, c.crossZV = function(a, b, d) {
- return c.rotate(a, d, Math.PI / 2), c.scale(a, a, b), a
- }, c.rotate = function(a, b, c) {
- if (0 !== c) {
- var d = Math.cos(c),
- e = Math.sin(c),
- f = b[0],
- g = b[1];
- a[0] = d * f - e * g, a[1] = e * f + d * g
- } else a[0] = b[0], a[1] = b[1]
- }, c.rotate90cw = function(a, b) {
- var c = b[0],
- d = b[1];
- a[0] = d, a[1] = -c
- }, c.toLocalFrame = function(a, b, d, e) {
- c.copy(a, b), c.sub(a, a, d), c.rotate(a, a, -e)
- }, c.toGlobalFrame = function(a, b, d, e) {
- c.copy(a, b), c.rotate(a, a, e), c.add(a, a, d)
- }, c.centroid = function(a, b, d, e) {
- return c.add(a, b, d), c.add(a, a, e), c.scale(a, a, 1 / 3), a
- }, c.create = function() {
- var a = new d.ARRAY_TYPE(2);
- return a[0] = 0, a[1] = 0, a
- }, c.clone = function(a) {
- var b = new d.ARRAY_TYPE(2);
- return b[0] = a[0], b[1] = a[1], b
- }, c.fromValues = function(a, b) {
- var c = new d.ARRAY_TYPE(2);
- return c[0] = a, c[1] = b, c
- }, c.copy = function(a, b) {
- return a[0] = b[0], a[1] = b[1], a
- }, c.set = function(a, b, c) {
- return a[0] = b, a[1] = c, a
- }, c.add = function(a, b, c) {
- return a[0] = b[0] + c[0], a[1] = b[1] + c[1], a
- }, c.subtract = function(a, b, c) {
- return a[0] = b[0] - c[0], a[1] = b[1] - c[1], a
- }, c.sub = c.subtract, c.multiply = function(a, b, c) {
- return a[0] = b[0] * c[0], a[1] = b[1] * c[1], a
- }, c.mul = c.multiply, c.divide = function(a, b, c) {
- return a[0] = b[0] / c[0], a[1] = b[1] / c[1], a
- }, c.div = c.divide, c.scale = function(a, b, c) {
- return a[0] = b[0] * c, a[1] = b[1] * c, a
- }, c.distance = function(a, b) {
- var c = b[0] - a[0],
- d = b[1] - a[1];
- return Math.sqrt(c * c + d * d)
- }, c.dist = c.distance, c.squaredDistance = function(a, b) {
- var c = b[0] - a[0],
- d = b[1] - a[1];
- return c * c + d * d
- }, c.sqrDist = c.squaredDistance, c.length = function(a) {
- var b = a[0],
- c = a[1];
- return Math.sqrt(b * b + c * c)
- }, c.len = c.length, c.squaredLength = function(a) {
- var b = a[0],
- c = a[1];
- return b * b + c * c
- }, c.sqrLen = c.squaredLength, c.negate = function(a, b) {
- return a[0] = -b[0], a[1] = -b[1], a
- }, c.normalize = function(a, b) {
- var c = b[0],
- d = b[1],
- e = c * c + d * d;
- return e > 0 && (e = 1 / Math.sqrt(e), a[0] = b[0] * e, a[1] = b[1] * e), a
- }, c.dot = function(a, b) {
- return a[0] * b[0] + a[1] * b[1]
- }, c.str = function(a) {
- return "vec2(" + a[0] + ", " + a[1] + ")"
- }
- }, {
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 32: [function(a, b) {
- function c(a) {
- 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()
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- e = a("poly-decomp"),
- f = a("../shapes/Convex"),
- g = a("../collision/AABB"),
- h = a("../events/EventEmitter");
- b.exports = c, c.prototype = new h, c._idCounter = 0, c.prototype.updateSolveMassProperties = function() {
- this.sleepState === c.SLEEPING || this.type === c.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia)
- }, c.prototype.setDensity = function(a) {
- var b = this.getArea();
- this.mass = b * a, this.updateMassProperties()
- }, c.prototype.getArea = function() {
- for (var a = 0, b = 0; b < this.shapes.length; b++) a += this.shapes[b].area;
- return a
- }, c.prototype.getAABB = function() {
- return this.aabbNeedsUpdate && this.updateAABB(), this.aabb
- };
- var i = new g,
- j = d.create();
- c.prototype.updateAABB = function() {
- for (var a = this.shapes, b = this.shapeOffsets, c = this.shapeAngles, e = a.length, f = j, g = this.angle, h = 0; h !== e; h++) {
- var k = a[h],
- l = c[h] + g;
- 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)
- }
- this.aabbNeedsUpdate = !1
- }, c.prototype.updateBoundingRadius = function() {
- for (var a = this.shapes, b = this.shapeOffsets, c = a.length, e = 0, f = 0; f !== c; f++) {
- var g = a[f],
- h = d.length(b[f]),
- i = g.boundingRadius;
- h + i > e && (e = h + i)
- }
- this.boundingRadius = e
- }, c.prototype.addShape = function(a, b, c) {
- 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
- }, c.prototype.removeShape = function(a) {
- var b = this.shapes.indexOf(a);
- return -1 !== b ? (this.shapes.splice(b, 1), this.shapeOffsets.splice(b, 1), this.shapeAngles.splice(b, 1), this.aabbNeedsUpdate = !0, !0) : !1
- }, c.prototype.updateMassProperties = function() {
- 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;
- else {
- var a = this.shapes,
- b = a.length,
- e = this.mass / b,
- f = 0;
- if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0;
- else {
- for (var g = 0; b > g; g++) {
- var h = a[g],
- i = d.squaredLength(this.shapeOffsets[g]),
- j = h.computeMomentOfInertia(e);
- f += j + e * i
- }
- this.inertia = f, this.invInertia = f > 0 ? 1 / f : 0
- }
- this.invMass = 1 / this.mass
- }
- };
- var k = d.create();
- c.prototype.applyForce = function(a, b) {
- var c = k;
- d.sub(c, b, this.position), d.add(this.force, this.force, a);
- var e = d.crossLength(c, a);
- this.angularForce += e
- }, c.prototype.toLocalFrame = function(a, b) {
- d.toLocalFrame(a, b, this.position, this.angle)
- }, c.prototype.toWorldFrame = function(a, b) {
- d.toGlobalFrame(a, b, this.position, this.angle)
- }, c.prototype.fromPolygon = function(a, b) {
- b = b || {};
- for (var c = this.shapes.length; c >= 0; --c) this.removeShape(this.shapes[c]);
- var g = new e.Polygon;
- if (g.vertices = a, g.makeCCW(), "number" == typeof b.removeCollinearPoints && g.removeCollinearPoints(b.removeCollinearPoints), "undefined" == typeof b.skipSimpleCheck && !g.isSimple()) return !1;
- this.concavePath = g.vertices.slice(0);
- for (var c = 0; c < this.concavePath.length; c++) {
- var h = [0, 0];
- d.copy(h, this.concavePath[c]), this.concavePath[c] = h
- }
- var i;
- i = b.optimalDecomp ? g.decomp() : g.quickDecomp();
- for (var j = d.create(), c = 0; c !== i.length; c++) {
- for (var k = new f(i[c].vertices), l = 0; l !== k.vertices.length; l++) {
- var h = k.vertices[l];
- d.sub(h, h, k.centerOfMass)
- }
- d.scale(j, k.centerOfMass, 1), k.updateTriangles(), k.updateCenterOfMass(), k.updateBoundingRadius(), this.addShape(k, j)
- }
- return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0
- };
- var l = (d.fromValues(0, 0), d.fromValues(0, 0)),
- m = d.fromValues(0, 0),
- n = d.fromValues(0, 0);
- c.prototype.adjustCenterOfMass = function() {
- var a = l,
- b = m,
- c = n,
- e = 0;
- d.set(b, 0, 0);
- for (var f = 0; f !== this.shapes.length; f++) {
- var g = this.shapes[f],
- h = this.shapeOffsets[f];
- d.scale(a, h, g.area), d.add(b, b, a), e += g.area
- }
- d.scale(c, b, 1 / e);
- for (var f = 0; f !== this.shapes.length; f++) {
- var g = this.shapes[f],
- h = this.shapeOffsets[f];
- h || (h = this.shapeOffsets[f] = d.create()), d.sub(h, h, c)
- }
- d.add(this.position, this.position, c);
- for (var f = 0; this.concavePath && f < this.concavePath.length; f++) d.sub(this.concavePath[f], this.concavePath[f], c);
- this.updateMassProperties(), this.updateBoundingRadius()
- }, c.prototype.setZeroForce = function() {
- d.set(this.force, 0, 0), this.angularForce = 0
- }, c.prototype.resetConstraintVelocity = function() {
- var a = this,
- b = a.vlambda;
- d.set(b, 0, 0), a.wlambda = 0
- }, c.prototype.addConstraintVelocity = function() {
- var a = this,
- b = a.velocity;
- d.add(b, b, a.vlambda), a.angularVelocity += a.wlambda
- }, c.prototype.applyDamping = function(a) {
- if (this.type === c.DYNAMIC) {
- var b = this.velocity;
- d.scale(b, b, Math.pow(1 - this.damping, a)), this.angularVelocity *= Math.pow(1 - this.angularDamping, a)
- }
- }, c.prototype.wakeUp = function() {
- var a = this.sleepState;
- this.sleepState = c.AWAKE, this.idleTime = 0, a !== c.AWAKE && this.emit(c.wakeUpEvent)
- }, c.prototype.sleep = function() {
- 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)
- }, c.prototype.sleepTick = function(a, b, e) {
- if (this.allowSleep && this.type !== c.SLEEPING) {
- this.wantsToSleep = !1;
- var f = (this.sleepState, d.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2)),
- g = Math.pow(this.sleepSpeedLimit, 2);
- 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())
- }
- }, c.prototype.getVelocityFromPosition = function(a, b) {
- return a = a || d.create(), d.sub(a, this.position, this.previousPosition), d.scale(a, a, 1 / b), a
- }, c.prototype.getAngularVelocityFromPosition = function(a) {
- return (this.angle - this.previousAngle) / a
- }, c.prototype.overlaps = function(a) {
- return this.world.overlapKeeper.bodiesAreOverlapping(this, a)
- }, c.sleepyEvent = {
- type: "sleepy"
- }, c.sleepEvent = {
- type: "sleep"
- }, c.wakeUpEvent = {
- type: "wakeup"
- }, c.DYNAMIC = 1, c.STATIC = 2, c.KINEMATIC = 4, c.AWAKE = 0, c.SLEEPY = 1, c.SLEEPING = 2
- }, {
- "../collision/AABB": 9,
- "../events/EventEmitter": 27,
- "../math/vec2": 31,
- "../shapes/Convex": 39,
- __browserify_Buffer: 1,
- __browserify_process: 2,
- "poly-decomp": 7
- }],
- 33: [function(a, b) {
- function c(a, b, c) {
- 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);
- var f = d.create(),
- g = d.create();
- this.getWorldAnchorA(f), this.getWorldAnchorB(g);
- var h = d.distance(f, g);
- this.restLength = "number" == typeof c.restLength ? c.restLength : h
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- e = a("./Spring");
- a("../utils/Utils")
- }
- b.exports = c, c.prototype = new e, c.prototype.setWorldAnchorA = function(a) {
- this.bodyA.toLocalFrame(this.localAnchorA, a)
- }, c.prototype.setWorldAnchorB = function(a) {
- this.bodyB.toLocalFrame(this.localAnchorB, a)
- }, c.prototype.getWorldAnchorA = function(a) {
- this.bodyA.toWorldFrame(a, this.localAnchorA)
- }, c.prototype.getWorldAnchorB = function(a) {
- this.bodyB.toWorldFrame(a, this.localAnchorB)
- };
- var f = d.create(),
- g = d.create(),
- h = d.create(),
- i = d.create(),
- j = d.create(),
- k = d.create(),
- l = d.create(),
- m = d.create(),
- n = d.create();
- c.prototype.applyForce = function() {
- var a = this.stiffness,
- b = this.damping,
- c = this.restLength,
- e = this.bodyA,
- o = this.bodyB,
- p = f,
- q = g,
- r = h,
- s = i,
- t = n,
- u = j,
- v = k,
- w = l,
- x = m;
- this.getWorldAnchorA(u), this.getWorldAnchorB(v), d.sub(w, u, e.position), d.sub(x, v, o.position), d.sub(p, v, u);
- var y = d.len(p);
- 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);
- var z = d.crossLength(w, s),
- A = d.crossLength(x, s);
- e.angularForce -= z, o.angularForce += A
- }
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Spring": 35,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 34: [function(a, b) {
- function c(a, b, c) {
- c = c || {}, d.call(this, a, b, c), this.restAngle = "number" == typeof c.restAngle ? c.restAngle : b.angle - a.angle
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("./Spring"));
- b.exports = c, c.prototype = new d, c.prototype.applyForce = function() {
- var a = this.stiffness,
- b = this.damping,
- c = this.restAngle,
- d = this.bodyA,
- e = this.bodyB,
- f = e.angle - d.angle,
- g = e.angularVelocity - d.angularVelocity,
- h = -a * (f - c) - b * g * 0;
- d.angularForce -= h, e.angularForce += h
- }
- }, {
- "../math/vec2": 31,
- "./Spring": 35,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 35: [function(a, b) {
- function c(a, b, c) {
- c = d.defaults(c, {
- stiffness: 100,
- damping: 1
- }), this.stiffness = c.stiffness, this.damping = c.damping, this.bodyA = a, this.bodyB = b
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("../utils/Utils"));
- b.exports = c, c.prototype.applyForce = function() {}
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 36: [function(a, b) {
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = {
- AABB: a("./collision/AABB"),
- AngleLockEquation: a("./equations/AngleLockEquation"),
- Body: a("./objects/Body"),
- Broadphase: a("./collision/Broadphase"),
- Capsule: a("./shapes/Capsule"),
- Circle: a("./shapes/Circle"),
- Constraint: a("./constraints/Constraint"),
- ContactEquation: a("./equations/ContactEquation"),
- ContactMaterial: a("./material/ContactMaterial"),
- Convex: a("./shapes/Convex"),
- DistanceConstraint: a("./constraints/DistanceConstraint"),
- Equation: a("./equations/Equation"),
- EventEmitter: a("./events/EventEmitter"),
- FrictionEquation: a("./equations/FrictionEquation"),
- GearConstraint: a("./constraints/GearConstraint"),
- GridBroadphase: a("./collision/GridBroadphase"),
- GSSolver: a("./solver/GSSolver"),
- Heightfield: a("./shapes/Heightfield"),
- Line: a("./shapes/Line"),
- LockConstraint: a("./constraints/LockConstraint"),
- Material: a("./material/Material"),
- Narrowphase: a("./collision/Narrowphase"),
- NaiveBroadphase: a("./collision/NaiveBroadphase"),
- Particle: a("./shapes/Particle"),
- Plane: a("./shapes/Plane"),
- RevoluteConstraint: a("./constraints/RevoluteConstraint"),
- PrismaticConstraint: a("./constraints/PrismaticConstraint"),
- Rectangle: a("./shapes/Rectangle"),
- RotationalVelocityEquation: a("./equations/RotationalVelocityEquation"),
- SAPBroadphase: a("./collision/SAPBroadphase"),
- Shape: a("./shapes/Shape"),
- Solver: a("./solver/Solver"),
- Spring: a("./objects/Spring"),
- LinearSpring: a("./objects/LinearSpring"),
- RotationalSpring: a("./objects/RotationalSpring"),
- Utils: a("./utils/Utils"),
- World: a("./world/World"),
- vec2: a("./math/vec2"),
- version: a("../package.json").version
- }
- }, {
- "../package.json": 8,
- "./collision/AABB": 9,
- "./collision/Broadphase": 10,
- "./collision/GridBroadphase": 11,
- "./collision/NaiveBroadphase": 12,
- "./collision/Narrowphase": 13,
- "./collision/SAPBroadphase": 14,
- "./constraints/Constraint": 15,
- "./constraints/DistanceConstraint": 16,
- "./constraints/GearConstraint": 17,
- "./constraints/LockConstraint": 18,
- "./constraints/PrismaticConstraint": 19,
- "./constraints/RevoluteConstraint": 20,
- "./equations/AngleLockEquation": 21,
- "./equations/ContactEquation": 22,
- "./equations/Equation": 23,
- "./equations/FrictionEquation": 24,
- "./equations/RotationalVelocityEquation": 26,
- "./events/EventEmitter": 27,
- "./material/ContactMaterial": 28,
- "./material/Material": 29,
- "./math/vec2": 31,
- "./objects/Body": 32,
- "./objects/LinearSpring": 33,
- "./objects/RotationalSpring": 34,
- "./objects/Spring": 35,
- "./shapes/Capsule": 37,
- "./shapes/Circle": 38,
- "./shapes/Convex": 39,
- "./shapes/Heightfield": 40,
- "./shapes/Line": 41,
- "./shapes/Particle": 42,
- "./shapes/Plane": 43,
- "./shapes/Rectangle": 44,
- "./shapes/Shape": 45,
- "./solver/GSSolver": 46,
- "./solver/Solver": 47,
- "./utils/Utils": 50,
- "./world/World": 54,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 37: [function(a, b) {
- function c(a, b) {
- this.length = a || 1, this.radius = b || 1, d.call(this, d.CAPSULE)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
- var b = this.radius,
- c = this.length + b,
- d = 2 * b;
- return a * (d * d + c * c) / 12
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = this.radius + this.length / 2
- }, c.prototype.updateArea = function() {
- this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length
- };
- var f = e.create();
- c.prototype.computeAABB = function(a, b, c) {
- var d = this.radius;
- 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)
- }
- }, {
- "../math/vec2": 31,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 38: [function(a, b) {
- function c(a) {
- this.radius = a || 1, d.call(this, d.CIRCLE)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
- var b = this.radius;
- return a * b * b / 2
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = this.radius
- }, c.prototype.updateArea = function() {
- this.area = Math.PI * this.radius * this.radius
- }, c.prototype.computeAABB = function(a, b) {
- var c = this.radius;
- 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))
- }
- }, {
- "../math/vec2": 31,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 39: [function(a, b) {
- function c(a, b) {
- this.vertices = [], this.axes = [];
- for (var c = 0; c < a.length; c++) {
- var f = e.create();
- e.copy(f, a[c]), this.vertices.push(f)
- }
- if (b)
- for (var c = 0; c < b.length; c++) {
- var g = e.create();
- e.copy(g, b[c]), this.axes.push(g)
- } else
- for (var c = 0; c < a.length; c++) {
- var h = a[c],
- i = a[(c + 1) % a.length],
- j = e.create();
- e.sub(j, i, h), e.rotate90cw(j, j), e.normalize(j, j), this.axes.push(j)
- }
- 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.")
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2"),
- f = a("../math/polyk");
- a("poly-decomp")
- }
- b.exports = c, c.prototype = new d;
- var g = e.create(),
- h = e.create();
- c.prototype.projectOntoLocalAxis = function(a, b) {
- 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);
- if (h > f) {
- var j = h;
- h = f, f = j
- }
- e.set(b, h, f)
- }, c.prototype.projectOntoWorldAxis = function(a, b, c, d) {
- var f = h;
- this.projectOntoLocalAxis(a, d), 0 !== c ? e.rotate(f, a, c) : f = a;
- var g = e.dot(b, f);
- e.set(d, d[0] + g, d[1] + g)
- }, c.prototype.updateTriangles = function() {
- this.triangles.length = 0;
- for (var a = [], b = 0; b < this.vertices.length; b++) {
- var c = this.vertices[b];
- a.push(c[0], c[1])
- }
- for (var d = f.Triangulate(a), b = 0; b < d.length; b += 3) {
- var e = d[b],
- g = d[b + 1],
- h = d[b + 2];
- this.triangles.push([e, g, h])
- }
- }; {
- var i = e.create(),
- j = e.create(),
- k = e.create(),
- l = e.create(),
- m = e.create();
- e.create(), e.create(), e.create(), e.create()
- }
- c.prototype.updateCenterOfMass = function() {
- var a = this.triangles,
- b = this.vertices,
- d = this.centerOfMass,
- f = i,
- g = k,
- h = l,
- n = m,
- o = j;
- e.set(d, 0, 0);
- for (var p = 0, q = 0; q !== a.length; q++) {
- var r = a[q],
- g = b[r[0]],
- h = b[r[1]],
- n = b[r[2]];
- e.centroid(f, g, h, n);
- var s = c.triangleArea(g, h, n);
- p += s, e.scale(o, f, s), e.add(d, d, o)
- }
- e.scale(d, d, 1 / p)
- }, c.prototype.computeMomentOfInertia = function(a) {
- for (var b = 0, c = 0, d = this.vertices.length, f = d - 1, g = 0; d > g; f = g, g++) {
- var h = this.vertices[f],
- i = this.vertices[g],
- j = Math.abs(e.crossLength(h, i)),
- k = e.dot(i, i) + e.dot(i, h) + e.dot(h, h);
- b += j * k, c += j
- }
- return a / 6 * (b / c)
- }, c.prototype.updateBoundingRadius = function() {
- for (var a = this.vertices, b = 0, c = 0; c !== a.length; c++) {
- var d = e.squaredLength(a[c]);
- d > b && (b = d)
- }
- this.boundingRadius = Math.sqrt(b)
- }, c.triangleArea = function(a, b, c) {
- return .5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]))
- }, c.prototype.updateArea = function() {
- this.updateTriangles(), this.area = 0;
- for (var a = this.triangles, b = this.vertices, d = 0; d !== a.length; d++) {
- var e = a[d],
- f = b[e[0]],
- g = b[e[1]],
- h = b[e[2]],
- i = c.triangleArea(f, g, h);
- this.area += i
- }
- }, c.prototype.computeAABB = function(a, b, c) {
- a.setFromPoints(this.vertices, b, c, 0)
- }
- }, {
- "../math/polyk": 30,
- "../math/vec2": 31,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2,
- "poly-decomp": 7
- }],
- 40: [function(a, b) {
- function c(a, b) {
- if (b = e.defaults(b, {
- maxValue: null,
- minValue: null,
- elementWidth: .1
- }), null === b.minValue || null === b.maxValue) {
- b.maxValue = a[0], b.minValue = a[0];
- for (var c = 0; c !== a.length; c++) {
- var f = a[c];
- f > b.maxValue && (b.maxValue = f), f < b.minValue && (b.minValue = f)
- }
- }
- this.data = a, this.maxValue = b.maxValue, this.minValue = b.minValue, this.elementWidth = b.elementWidth, d.call(this, d.HEIGHTFIELD)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = (a("../math/vec2"), a("../utils/Utils"));
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
- return Number.MAX_VALUE
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = Number.MAX_VALUE
- }, c.prototype.updateArea = function() {
- for (var a = this.data, b = 0, c = 0; c < a.length - 1; c++) b += (a[c] + a[c + 1]) / 2 * this.elementWidth;
- this.area = b
- }, c.prototype.computeAABB = function(a, b) {
- 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
- }
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 41: [function(a, b) {
- function c(a) {
- this.length = a || 1, d.call(this, d.LINE)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function(a) {
- return a * Math.pow(this.length, 2) / 12
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = this.length / 2
- };
- var f = [e.create(), e.create()];
- c.prototype.computeAABB = function(a, b, c) {
- var d = this.length / 2;
- e.set(f[0], -d, 0), e.set(f[1], d, 0), a.setFromPoints(f, b, c, 0)
- }
- }, {
- "../math/vec2": 31,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 42: [function(a, b) {
- function c() {
- d.call(this, d.PARTICLE)
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2");
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
- return 0
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = 0
- }, c.prototype.computeAABB = function(a, b) {
- e.copy(a.lowerBound, b), e.copy(a.upperBound, b)
- }
- }, {
- "../math/vec2": 31,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 43: [function(a, b) {
- function c() {
- d.call(this, d.PLANE)
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Shape")),
- e = a("../math/vec2");
- a("../utils/Utils")
- }
- b.exports = c, c.prototype = new d, c.prototype.computeMomentOfInertia = function() {
- return 0
- }, c.prototype.updateBoundingRadius = function() {
- this.boundingRadius = Number.MAX_VALUE
- }, c.prototype.computeAABB = function(a, b, c) {
- var d = 0,
- f = e.set;
- "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)
- }, c.prototype.updateArea = function() {
- this.area = Number.MAX_VALUE
- }
- }, {
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 44: [function(a, b) {
- function c(a, b) {
- this.width = a || 1, this.height = b || 1;
- 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)],
- g = [d.fromValues(1, 0), d.fromValues(0, 1)];
- f.call(this, c, g), this.type = e.RECTANGLE
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- e = a("./Shape"),
- f = a("./Convex");
- b.exports = c, c.prototype = new f([]), c.prototype.computeMomentOfInertia = function(a) {
- var b = this.width,
- c = this.height;
- return a * (c * c + b * b) / 12
- }, c.prototype.updateBoundingRadius = function() {
- var a = this.width,
- b = this.height;
- this.boundingRadius = Math.sqrt(a * a + b * b) / 2
- };
- d.create(), d.create(), d.create(), d.create();
- c.prototype.computeAABB = function(a, b, c) {
- a.setFromPoints(this.vertices, b, c, 0)
- }, c.prototype.updateArea = function() {
- this.area = this.width * this.height
- }
- }, {
- "../math/vec2": 31,
- "./Convex": 39,
- "./Shape": 45,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 45: [function(a, b) {
- function c(a) {
- 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()
- }
- a("__browserify_process"), a("__browserify_Buffer");
- 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() {
- throw new Error("Shape.computeMomentOfInertia is not implemented in this Shape...")
- }, c.prototype.updateBoundingRadius = function() {
- throw new Error("Shape.updateBoundingRadius is not implemented in this Shape...")
- }, c.prototype.updateArea = function() {}, c.prototype.computeAABB = function() {}
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 46: [function(a, b) {
- function c(a) {
- 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
- }
- function d(a) {
- for (var b = a.length; b--;) a[b] = 0
- }
- var e = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2")),
- f = a("./Solver"),
- g = a("../utils/Utils"),
- h = a("../equations/FrictionEquation");
- b.exports = c, c.prototype = new f, c.prototype.solve = function(a, b) {
- this.sortEquations();
- var f = 0,
- i = this.iterations,
- j = this.frictionIterations,
- k = this.equations,
- l = k.length,
- m = Math.pow(this.tolerance * l, 2),
- n = b.bodies,
- o = b.bodies.length,
- p = (e.add, e.set, this.useZeroRHS),
- q = this.lambda;
- if (this.usedIterations = 0, l)
- for (var r = 0; r !== o; r++) {
- var s = n[r];
- s.updateSolveMassProperties()
- }
- 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);
- for (var t = this.invCs, u = this.Bs, q = this.lambda, r = 0; r !== k.length; r++) {
- var v = k[r];
- (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)
- }
- var v, w, r, x;
- if (0 !== l) {
- for (r = 0; r !== o; r++) {
- var s = n[r];
- s.resetConstraintVelocity()
- }
- if (j) {
- for (f = 0; f !== j; f++) {
- for (w = 0, x = 0; x !== l; x++) {
- v = k[x];
- var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
- w += Math.abs(y)
- }
- if (this.usedIterations++, m >= w * w) break
- }
- for (c.updateMultipliers(k, q, 1 / a), x = 0; x !== l; x++) {
- var z = k[x];
- if (z instanceof h) {
- for (var A = 0, B = 0; B !== z.contactEquations.length; B++) A += z.contactEquations[B].multiplier;
- A *= z.frictionCoefficient / z.contactEquations.length, z.maxForce = A, z.minForce = -A
- }
- }
- }
- for (f = 0; f !== i; f++) {
- for (w = 0, x = 0; x !== l; x++) {
- v = k[x];
- var y = c.iterateEquation(x, v, v.epsilon, u, t, q, p, a, f);
- w += Math.abs(y)
- }
- if (this.usedIterations++, m >= w * w) break
- }
- for (r = 0; r !== o; r++) n[r].addConstraintVelocity();
- c.updateMultipliers(k, q, 1 / a)
- }
- }, c.updateMultipliers = function(a, b, c) {
- for (var d = a.length; d--;) a[d].multiplier = b[d] * c
- }, c.iterateEquation = function(a, b, c, d, e, f, g, h) {
- var i = d[a],
- j = e[a],
- k = f[a],
- l = b.computeGWlambda(),
- m = b.maxForce,
- n = b.minForce;
- g && (i = 0);
- var o = j * (i - l - c * k),
- p = k + o;
- return n * h > p ? o = n * h - k : p > m * h && (o = m * h - k), f[a] += o, b.addToWlambda(o), o
- }
- }, {
- "../equations/FrictionEquation": 24,
- "../math/vec2": 31,
- "../utils/Utils": 50,
- "./Solver": 47,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 47: [function(a, b) {
- function c(a, b) {
- a = a || {}, d.call(this), this.type = b, this.equations = [], this.equationSortFunction = a.equationSortFunction || !1
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../utils/Utils"), a("../events/EventEmitter"));
- b.exports = c, c.prototype = new d, c.prototype.solve = function() {
- throw new Error("Solver.solve should be implemented by subclasses!")
- };
- var e = {
- bodies: []
- };
- c.prototype.solveIsland = function(a, b) {
- this.removeAllEquations(), b.equations.length && (this.addEquations(b.equations), e.bodies.length = 0, b.getBodies(e.bodies), e.bodies.length && this.solve(a, e))
- }, c.prototype.sortEquations = function() {
- this.equationSortFunction && this.equations.sort(this.equationSortFunction)
- }, c.prototype.addEquation = function(a) {
- a.enabled && this.equations.push(a)
- }, c.prototype.addEquations = function(a) {
- for (var b = 0, c = a.length; b !== c; b++) {
- var d = a[b];
- d.enabled && this.equations.push(d)
- }
- }, c.prototype.removeEquation = function(a) {
- var b = this.equations.indexOf(a); - 1 !== b && this.equations.splice(b, 1)
- }, c.prototype.removeAllEquations = function() {
- this.equations.length = 0
- }, c.GS = 1, c.ISLAND = 2
- }, {
- "../events/EventEmitter": 27,
- "../utils/Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 48: [function(a, b) {
- function c() {
- this.overlappingShapesLastState = new e, this.overlappingShapesCurrentState = new e, this.recordPool = [], this.tmpDict = new e, this.tmpArray1 = []
- }
- function d(a, b, c, d) {
- this.shapeA = b, this.shapeB = d, this.bodyA = a, this.bodyB = c
- } {
- var e = (a("__browserify_process"), a("__browserify_Buffer"), a("./TupleDictionary"));
- a("./Utils")
- }
- b.exports = c, c.prototype.tick = function() {
- for (var a = this.overlappingShapesLastState, b = this.overlappingShapesCurrentState, c = a.keys.length; c--;) {
- var d = a.keys[c],
- e = a.getByKey(d),
- f = b.getByKey(d);
- e && !f && this.recordPool.push(e)
- }
- a.reset(), a.copy(b), b.reset()
- }, c.prototype.setOverlapping = function(a, b, c, e) {
- var f = (this.overlappingShapesLastState, this.overlappingShapesCurrentState);
- if (!f.get(b.id, e.id)) {
- var g;
- 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)
- }
- }, c.prototype.getNewOverlaps = function(a) {
- return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, a)
- }, c.prototype.getEndOverlaps = function(a) {
- return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, a)
- }, c.prototype.bodiesAreOverlapping = function(a, b) {
- for (var c = this.overlappingShapesCurrentState, d = c.keys.length; d--;) {
- var e = c.keys[d],
- f = c.data[e];
- if (f.bodyA === a && f.bodyB === b || f.bodyA === b && f.bodyB === a) return !0
- }
- return !1
- }, c.prototype.getDiff = function(a, b, c) {
- var c = c || [],
- d = a,
- e = b;
- c.length = 0;
- for (var f = e.keys.length; f--;) {
- var g = e.keys[f],
- h = e.data[g];
- if (!h) throw new Error("Key " + g + " had no data!");
- var i = d.data[g];
- i || c.push(h)
- }
- return c
- }, c.prototype.isNewOverlap = function(a, b) {
- var c = 0 | a.id,
- d = 0 | b.id,
- e = this.overlappingShapesLastState,
- f = this.overlappingShapesCurrentState;
- return !e.get(c, d) && !!f.get(c, d)
- }, c.prototype.getNewBodyOverlaps = function(a) {
- this.tmpArray1.length = 0;
- var b = this.getNewOverlaps(this.tmpArray1);
- return this.getBodyDiff(b, a)
- }, c.prototype.getEndBodyOverlaps = function(a) {
- this.tmpArray1.length = 0;
- var b = this.getEndOverlaps(this.tmpArray1);
- return this.getBodyDiff(b, a)
- }, c.prototype.getBodyDiff = function(a, b) {
- b = b || [];
- for (var c = this.tmpDict, d = a.length; d--;) {
- var e = a[d];
- c.set(0 | e.bodyA.id, 0 | e.bodyB.id, e)
- }
- for (d = c.keys.length; d--;) {
- var e = c.getByKey(c.keys[d]);
- e && b.push(e.bodyA, e.bodyB)
- }
- return c.reset(), b
- }, d.prototype.set = function(a, b, c, e) {
- d.call(this, a, b, c, e)
- }
- }, {
- "./TupleDictionary": 49,
- "./Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 49: [function(a, b) {
- function c() {
- this.data = {}, this.keys = []
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("./Utils"));
- b.exports = c, c.prototype.getKey = function(a, b) {
- 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)
- }, c.prototype.getByKey = function(a) {
- return a = 0 | a, this.data[a]
- }, c.prototype.get = function(a, b) {
- return this.data[this.getKey(a, b)]
- }, c.prototype.set = function(a, b, c) {
- if (!c) throw new Error("No data!");
- var d = this.getKey(a, b);
- return this.data[d] || this.keys.push(d), this.data[d] = c, d
- }, c.prototype.reset = function() {
- for (var a = this.data, b = this.keys, c = b.length; c--;) delete a[b[c]];
- b.length = 0
- }, c.prototype.copy = function(a) {
- this.reset(), d.appendArray(this.keys, a.keys);
- for (var b = a.keys.length; b--;) {
- var c = a.keys[b];
- this.data[c] = a.data[c]
- }
- }
- }, {
- "./Utils": 50,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 50: [function(a, b) {
- function c() {}
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c, c.appendArray = function(a, b) {
- if (b.length < 15e4) a.push.apply(a, b);
- else
- for (var c = 0, d = b.length; c !== d; ++c) a.push(b[c])
- }, c.splice = function(a, b, c) {
- c = c || 1;
- for (var d = b, e = a.length - c; e > d; d++) a[d] = a[d + c];
- a.length = e
- }, c.ARRAY_TYPE = window.Float32Array || Array, c.extend = function(a, b) {
- for (var c in b) a[c] = b[c]
- }, c.defaults = function(a, b) {
- a = a || {};
- for (var c in b) c in a || (a[c] = b[c]);
- return a
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 51: [function(a, b) {
- function c() {
- this.equations = [], this.bodies = []
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../objects/Body"));
- b.exports = c, c.prototype.reset = function() {
- this.equations.length = this.bodies.length = 0
- };
- var e = [];
- c.prototype.getBodies = function(a) {
- var b = a || [],
- c = this.equations;
- e.length = 0;
- for (var d = 0; d !== c.length; d++) {
- 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))
- }
- return b
- }, c.prototype.wantsToSleep = function() {
- for (var a = 0; a < this.bodies.length; a++) {
- var b = this.bodies[a];
- if (b.type === d.DYNAMIC && !b.wantsToSleep) return !1
- }
- return !0
- }, c.prototype.sleep = function() {
- for (var a = 0; a < this.bodies.length; a++) {
- var b = this.bodies[a];
- b.sleep()
- }
- return !0
- }
- }, {
- "../objects/Body": 32,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 52: [function(a, b) {
- function c() {
- this._nodePool = [], this._islandPool = [], this.equations = [], this.islands = [], this.nodes = [], this.queue = []
- }
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../math/vec2"), a("./Island")),
- e = a("./IslandNode"),
- f = a("../objects/Body");
- b.exports = c, c.getUnvisitedNode = function(a) {
- for (var b = a.length, c = 0; c !== b; c++) {
- var d = a[c];
- if (!d.visited && d.body.type === f.DYNAMIC) return d
- }
- return !1
- }, c.prototype.visit = function(a, b, c) {
- b.push(a.body);
- for (var d = a.equations.length, e = 0; e !== d; e++) {
- var f = a.equations[e]; - 1 === c.indexOf(f) && c.push(f)
- }
- }, c.prototype.bfs = function(a, b, d) {
- var e = this.queue;
- for (e.length = 0, e.push(a), a.visited = !0, this.visit(a, b, d); e.length;)
- 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)
- }, c.prototype.split = function(a) {
- for (var b = a.bodies, f = this.nodes, g = this.equations; f.length;) this._nodePool.push(f.pop());
- for (var h = 0; h !== b.length; h++)
- if (this._nodePool.length) {
- var i = this._nodePool.pop();
- i.reset(), i.body = b[h], f.push(i)
- } else f.push(new e(b[h]));
- for (var j = 0; j !== g.length; j++) {
- var k = g[j],
- h = b.indexOf(k.bodyA),
- l = b.indexOf(k.bodyB),
- m = f[h],
- n = f[l];
- m.neighbors.push(n), n.neighbors.push(m), m.equations.push(k), n.equations.push(k)
- }
- for (var o = this.islands; o.length;) {
- var p = o.pop();
- p.reset(), this._islandPool.push(p)
- }
- for (var q; q = c.getUnvisitedNode(f);) {
- var p = this._islandPool.length ? this._islandPool.pop() : new d;
- this.bfs(q, p.bodies, p.equations), o.push(p)
- }
- return o
- }
- }, {
- "../math/vec2": 31,
- "../objects/Body": 32,
- "./Island": 51,
- "./IslandNode": 53,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 53: [function(a, b) {
- function c(a) {
- this.body = a, this.neighbors = [], this.equations = [], this.visited = !1
- }
- a("__browserify_process"), a("__browserify_Buffer");
- b.exports = c, c.prototype.reset = function() {
- this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null
- }
- }, {
- __browserify_Buffer: 1,
- __browserify_process: 2
- }],
- 54: [function(a, b) {
- function c(a) {
- 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 = {
- type: "postStep"
- }, this.addBodyEvent = {
- type: "addBody",
- body: null
- }, this.removeBodyEvent = {
- type: "removeBody",
- body: null
- }, this.addSpringEvent = {
- type: "addSpring",
- spring: null
- }, this.impactEvent = {
- type: "impact",
- bodyA: null,
- bodyB: null,
- shapeA: null,
- shapeB: null,
- contactEquation: null
- }, this.postBroadphaseEvent = {
- type: "postBroadphase",
- pairs: null
- }, this.sleepMode = c.NO_SLEEPING, this.beginContactEvent = {
- type: "beginContact",
- shapeA: null,
- shapeB: null,
- bodyA: null,
- bodyB: null,
- contactEquations: []
- }, this.endContactEvent = {
- type: "endContact",
- shapeA: null,
- shapeB: null,
- bodyA: null,
- bodyB: null
- }, this.preSolveEvent = {
- type: "preSolve",
- contactEquations: null,
- frictionEquations: null
- }, this.overlappingShapesLastState = {
- keys: []
- }, this.overlappingShapesCurrentState = {
- keys: []
- }, this.overlapKeeper = new r
- } {
- var d = (a("__browserify_process"), a("__browserify_Buffer"), a("../solver/GSSolver")),
- e = (a("../solver/Solver"), a("../collision/NaiveBroadphase"), a("../math/vec2")),
- f = a("../shapes/Circle"),
- g = (a("../shapes/Rectangle"), a("../shapes/Convex")),
- h = (a("../shapes/Line"), a("../shapes/Plane")),
- i = a("../shapes/Capsule"),
- j = a("../shapes/Particle"),
- k = a("../events/EventEmitter"),
- l = a("../objects/Body"),
- m = (a("../shapes/Shape"), a("../objects/LinearSpring"), a("../material/Material")),
- n = a("../material/ContactMaterial"),
- 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")),
- p = a("../collision/Narrowphase"),
- q = a("../utils/Utils"),
- r = a("../utils/OverlapKeeper"),
- s = a("./IslandManager");
- a("../objects/RotationalSpring")
- }
- if (b.exports = c, "undefined" == typeof performance && (performance = {}), !performance.now) {
- var t = Date.now();
- performance.timing && performance.timing.navigationStart && (t = performance.timing.navigationStart), performance.now = function() {
- return Date.now() - t
- }
- }
- c.prototype = new Object(k.prototype), c.NO_SLEEPING = 1, c.BODY_SLEEPING = 2, c.ISLAND_SLEEPING = 4, c.prototype.addConstraint = function(a) {
- this.constraints.push(a)
- }, c.prototype.addContactMaterial = function(a) {
- this.contactMaterials.push(a)
- }, c.prototype.removeContactMaterial = function(a) {
- var b = this.contactMaterials.indexOf(a); - 1 !== b && q.splice(this.contactMaterials, b, 1)
- }, c.prototype.getContactMaterial = function(a, b) {
- for (var c = this.contactMaterials, d = 0, e = c.length; d !== e; d++) {
- var f = c[d];
- if (f.materialA.id === a.id && f.materialB.id === b.id || f.materialA.id === b.id && f.materialB.id === a.id) return f
- }
- return !1
- }, c.prototype.removeConstraint = function(a) {
- var b = this.constraints.indexOf(a); - 1 !== b && q.splice(this.constraints, b, 1)
- };
- var u = (e.create(), e.create(), e.create(), e.create(), e.create(), e.create(), e.create()),
- v = e.fromValues(0, 0),
- w = e.fromValues(0, 0),
- x = (e.fromValues(0, 0), e.fromValues(0, 0));
- c.prototype.step = function(a, b, c) {
- if (c = c || 10, b = b || 0, 0 === b) this.internalStep(a), this.time += a;
- else {
- var d = Math.floor((this.time + b) / a) - Math.floor(this.time / a);
- d = Math.min(d, c);
- for (var f = performance.now(), g = 0; g !== d && (this.internalStep(a), !(performance.now() - f > 1e3 * a)); g++);
- this.time += b;
- for (var h = this.time % a, i = h / a, j = 0; j !== this.bodies.length; j++) {
- var k = this.bodies[j];
- 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)
- }
- }
- };
- var y = [];
- c.prototype.internalStep = function(a) {
- this.stepping = !0;
- var b, d, f = this,
- g = this.doProfiling,
- h = this.springs.length,
- i = this.springs,
- j = this.bodies,
- k = this.gravity,
- m = this.solver,
- n = this.bodies.length,
- o = this.broadphase,
- p = this.narrowphase,
- r = this.constraints,
- s = u,
- t = (e.scale, e.add),
- v = (e.rotate, this.islandManager);
- if (this.overlapKeeper.tick(), this.lastTimeStep = a, g && (b = performance.now()), this.useWorldGravityAsFrictionGravity) {
- var w = e.length(this.gravity);
- 0 === w && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = w)
- }
- if (this.applyGravity)
- for (var x = 0; x !== n; x++) {
- var z = j[x],
- A = z.force;
- z.type === l.DYNAMIC && z.sleepState !== l.SLEEPING && (e.scale(s, k, z.mass * z.gravityScale), t(A, A, s))
- }
- if (this.applySpringForces)
- for (var x = 0; x !== h; x++) {
- var B = i[x];
- B.applyForce()
- }
- if (this.applyDamping)
- for (var x = 0; x !== n; x++) {
- var z = j[x];
- z.type === l.DYNAMIC && z.applyDamping(a)
- }
- for (var C = o.getCollisionPairs(this), D = this.disabledBodyCollisionPairs, x = D.length - 2; x >= 0; x -= 2)
- 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);
- var F = r.length;
- for (x = 0; x !== F; x++) {
- var G = r[x];
- if (!G.collideConnected)
- 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)
- }
- this.postBroadphaseEvent.pairs = C, this.emit(this.postBroadphaseEvent), p.reset(this);
- for (var x = 0, H = C.length; x !== H; x += 2)
- for (var I = C[x], J = C[x + 1], K = 0, L = I.shapes.length; K !== L; K++)
- for (var M = I.shapes[K], N = I.shapeOffsets[K], O = I.shapeAngles[K], P = 0, Q = J.shapes.length; P !== Q; P++) {
- var R = J.shapes[P],
- S = J.shapeOffsets[P],
- T = J.shapeAngles[P],
- U = this.defaultContactMaterial;
- if (M.material && R.material) {
- var V = this.getContactMaterial(M.material, R.material);
- V && (U = V)
- }
- this.runNarrowphase(p, I, M, N, O, J, R, S, T, U, this.frictionGravity)
- }
- for (var x = 0; x !== n; x++) {
- var W = j[x];
- W._wakeUpAfterNarrowphase && (W.wakeUp(), W._wakeUpAfterNarrowphase = !1)
- }
- if (this.has("endContact")) {
- this.overlapKeeper.getEndOverlaps(y);
- for (var X = this.endContactEvent, P = y.length; P--;) {
- var Y = y[P];
- X.shapeA = Y.shapeA, X.shapeB = Y.shapeB, X.bodyA = Y.bodyA, X.bodyB = Y.bodyB, this.emit(X)
- }
- }
- var Z = this.preSolveEvent;
- Z.contactEquations = p.contactEquations, Z.frictionEquations = p.frictionEquations, this.emit(Z);
- var F = r.length;
- for (x = 0; x !== F; x++) r[x].update();
- if (p.contactEquations.length || p.frictionEquations.length || r.length)
- if (this.islandSplit) {
- 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);
- v.split(this);
- for (var x = 0; x !== v.islands.length; x++) {
- var $ = v.islands[x];
- $.equations.length && m.solveIsland(a, $)
- }
- } else {
- for (m.addEquations(p.contactEquations), m.addEquations(p.frictionEquations), x = 0; x !== F; x++) m.addEquations(r[x].equations);
- this.solveConstraints && m.solve(a, this), m.removeAllEquations()
- }
- for (var x = 0; x !== n; x++) {
- var W = j[x];
- W.sleepState !== l.SLEEPING && W.type !== l.STATIC && c.integrateBody(W, a)
- }
- for (var x = 0; x !== n; x++) j[x].setZeroForce();
- if (g && (d = performance.now(), f.lastStepTime = d - b), this.emitImpactEvent && this.has("impact"))
- for (var _ = this.impactEvent, x = 0; x !== p.contactEquations.length; x++) {
- var ab = p.contactEquations[x];
- ab.firstImpact && (_.bodyA = ab.bodyA, _.bodyB = ab.bodyB, _.shapeA = ab.shapeA, _.shapeB = ab.shapeB, _.contactEquation = ab, this.emit(_))
- }
- if (this.sleepMode === c.BODY_SLEEPING)
- for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !1, a);
- else if (this.sleepMode === c.ISLAND_SLEEPING && this.islandSplit) {
- for (x = 0; x !== n; x++) j[x].sleepTick(this.time, !0, a);
- for (var x = 0; x < this.islandManager.islands.length; x++) {
- var $ = this.islandManager.islands[x];
- $.wantsToSleep() && $.sleep()
- }
- }
- if (this.stepping = !1, this.bodiesToBeRemoved.length) {
- for (var x = 0; x !== this.bodiesToBeRemoved.length; x++) this.removeBody(this.bodiesToBeRemoved[x]);
- this.bodiesToBeRemoved.length = 0
- }
- this.emit(this.postStepEvent)
- };
- var z = e.create(),
- A = e.create();
- c.integrateBody = function(a, b) {
- var c = a.invMass,
- d = a.force,
- f = a.position,
- g = a.velocity;
- 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
- }, c.prototype.runNarrowphase = function(a, b, c, d, f, g, h, i, j, k, m) {
- if (0 !== (c.collisionGroup & h.collisionMask) && 0 !== (h.collisionGroup & c.collisionMask)) {
- e.rotate(v, d, b.angle), e.rotate(w, i, g.angle), e.add(v, v, b.position), e.add(w, w, g.position);
- var n = f + b.angle,
- o = j + g.angle;
- a.enableFriction = k.friction > 0, a.frictionCoefficient = k.friction;
- var p;
- 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;
- var q = a[c.type | h.type],
- r = 0;
- if (q) {
- var s = c.sensor || h.sensor,
- t = a.frictionEquations.length;
- 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);
- var u = a.frictionEquations.length - t;
- if (r) {
- if (b.allowSleep && b.type === l.DYNAMIC && b.sleepState === l.SLEEPING && g.sleepState === l.AWAKE && g.type !== l.STATIC) {
- var x = e.squaredLength(g.velocity) + Math.pow(g.angularVelocity, 2),
- y = Math.pow(g.sleepSpeedLimit, 2);
- x >= 2 * y && (b._wakeUpAfterNarrowphase = !0)
- }
- if (g.allowSleep && g.type === l.DYNAMIC && g.sleepState === l.SLEEPING && b.sleepState === l.AWAKE && b.type !== l.STATIC) {
- var z = e.squaredLength(b.velocity) + Math.pow(b.angularVelocity, 2),
- A = Math.pow(b.sleepSpeedLimit, 2);
- z >= 2 * A && (g._wakeUpAfterNarrowphase = !0)
- }
- if (this.overlapKeeper.setOverlapping(b, c, g, h), this.has("beginContact") && this.overlapKeeper.isNewOverlap(c, h)) {
- var B = this.beginContactEvent;
- if (B.shapeA = c, B.shapeB = h, B.bodyA = b, B.bodyB = g, B.contactEquations.length = 0, "number" == typeof r)
- for (var C = a.contactEquations.length - r; C < a.contactEquations.length; C++) B.contactEquations.push(a.contactEquations[C]);
- this.emit(B)
- }
- if ("number" == typeof r && u > 1)
- for (var C = a.frictionEquations.length - u; C < a.frictionEquations.length; C++) {
- var D = a.frictionEquations[C];
- D.setSlipForce(D.getSlipForce() / u)
- }
- }
- }
- }
- }, c.prototype.addSpring = function(a) {
- this.springs.push(a), this.addSpringEvent.spring = a, this.emit(this.addSpringEvent)
- }, c.prototype.removeSpring = function(a) {
- var b = this.springs.indexOf(a); - 1 !== b && q.splice(this.springs, b, 1)
- }, c.prototype.addBody = function(a) {
- -1 === this.bodies.indexOf(a) && (this.bodies.push(a), a.world = this, this.addBodyEvent.body = a, this.emit(this.addBodyEvent))
- }, c.prototype.removeBody = function(a) {
- if (this.stepping) this.bodiesToBeRemoved.push(a);
- else {
- a.world = null;
- var b = this.bodies.indexOf(a); - 1 !== b && (q.splice(this.bodies, b, 1), this.removeBodyEvent.body = a, a.resetConstraintVelocity(), this.emit(this.removeBodyEvent))
- }
- }, c.prototype.getBodyById = function(a) {
- for (var b = this.bodies, c = 0; c < b.length; c++) {
- var d = b[c];
- if (d.id === a) return d
- }
- return !1
- }, c.prototype.disableBodyCollision = function(a, b) {
- this.disabledBodyCollisionPairs.push(a, b)
- }, c.prototype.enableBodyCollision = function(a, b) {
- for (var c = this.disabledBodyCollisionPairs, d = 0; d < c.length; d += 2)
- if (c[d] === a && c[d + 1] === b || c[d + 1] === a && c[d] === b) return void c.splice(d, 2)
- }, c.prototype.clear = function() {
- this.time = 0, this.fixedStepTime = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
- for (var a = this.constraints, b = a.length - 1; b >= 0; b--) this.removeConstraint(a[b]);
- for (var d = this.bodies, b = d.length - 1; b >= 0; b--) this.removeBody(d[b]);
- for (var e = this.springs, b = e.length - 1; b >= 0; b--) this.removeSpring(e[b]);
- for (var f = this.contactMaterials, b = f.length - 1; b >= 0; b--) this.removeContactMaterial(f[b]);
- c.apply(this)
- }, c.prototype.clone = function() {
- var a = new c;
- return a.fromJSON(this.toJSON()), a
- };
- var B = e.create(),
- C = e.fromValues(0, 0),
- D = e.fromValues(0, 0);
- c.prototype.hitTest = function(a, b, c) {
- c = c || 0;
- var d = new l({
- position: a
- }),
- k = new j,
- m = a,
- n = 0,
- o = B,
- p = C,
- q = D;
- d.addShape(k);
- for (var r = this.narrowphase, s = [], t = 0, u = b.length; t !== u; t++)
- for (var v = b[t], w = 0, x = v.shapes.length; w !== x; w++) {
- var y = v.shapes[w],
- z = v.shapeOffsets[w] || p,
- A = v.shapeAngles[w] || 0;
- e.rotate(o, z, v.angle), e.add(o, o, v.position);
- var E = A + v.angle;
- (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)
- }
- return s
- }, c.prototype.setGlobalEquationParameters = function(a) {
- a = a || {};
- for (var b = 0; b !== this.constraints.length; b++)
- for (var c = this.constraints[b], d = 0; d !== c.equations.length; d++) {
- var e = c.equations[d];
- "undefined" != typeof a.stiffness && (e.stiffness = a.stiffness), "undefined" != typeof a.relaxation && (e.relaxation = a.relaxation), e.needsUpdate = !0
- }
- for (var b = 0; b !== this.contactMaterials.length; b++) {
- var c = this.contactMaterials[b];
- "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
- }
- var c = this.defaultContactMaterial;
- "undefined" != typeof a.stiffness && (c.stiffness = a.stiffness, c.frictionStiffness = a.stiffness), "undefined" != typeof a.relaxation && (c.relaxation = a.relaxation, c.frictionRelaxation = a.relaxation)
- }, c.prototype.setGlobalStiffness = function(a) {
- this.setGlobalEquationParameters({
- stiffness: a
- })
- }, c.prototype.setGlobalRelaxation = function(a) {
- this.setGlobalEquationParameters({
- relaxation: a
- })
- }
- }, {
- "../../package.json": 8,
- "../collision/Broadphase": 10,
- "../collision/NaiveBroadphase": 12,
- "../collision/Narrowphase": 13,
- "../collision/SAPBroadphase": 14,
- "../constraints/Constraint": 15,
- "../constraints/DistanceConstraint": 16,
- "../constraints/GearConstraint": 17,
- "../constraints/LockConstraint": 18,
- "../constraints/PrismaticConstraint": 19,
- "../constraints/RevoluteConstraint": 20,
- "../events/EventEmitter": 27,
- "../material/ContactMaterial": 28,
- "../material/Material": 29,
- "../math/vec2": 31,
- "../objects/Body": 32,
- "../objects/LinearSpring": 33,
- "../objects/RotationalSpring": 34,
- "../shapes/Capsule": 37,
- "../shapes/Circle": 38,
- "../shapes/Convex": 39,
- "../shapes/Line": 41,
- "../shapes/Particle": 42,
- "../shapes/Plane": 43,
- "../shapes/Rectangle": 44,
- "../shapes/Shape": 45,
- "../solver/GSSolver": 46,
- "../solver/Solver": 47,
- "../utils/OverlapKeeper": 48,
- "../utils/Utils": 50,
- "./IslandManager": 52,
- __browserify_Buffer: 1,
- __browserify_process: 2
- }]
- }, {}, [36])(36)
- }), p2.Body.prototype.parent = null, p2.Spring.prototype.parent = null, Phaser.Physics.P2 = function(a, b) {
- this.game = a, "undefined" != typeof b && b.hasOwnProperty("gravity") && b.hasOwnProperty("broadphase") || (b = {
- gravity: [0, 0],
- broadphase: new p2.SAPBroadphase
- }), this.config = b, this.world = new p2.World(this.config), this.frameRate = 1 / 60, this.useElapsedTime = !1, this.paused = !1, this.materials = [], this.gravity = new Phaser.Physics.P2.InversePointProxy(this, this.world.gravity), this.walls = {
- left: null,
- right: null,
- top: null,
- bottom: null
- }, 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)
- }, Phaser.Physics.P2.prototype = {
- removeBodyNextStep: function(a) {
- this._toRemove.push(a)
- },
- preUpdate: function() {
- for (var a = this._toRemove.length; a--;) this.removeBody(this._toRemove[a]);
- this._toRemove.length = 0
- },
- enable: function(a, b, c) {
- "undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !0);
- var d = 1;
- if (Array.isArray(a))
- 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));
- 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))
- },
- enableBody: function(a, b) {
- 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))
- },
- setImpactEvents: function(a) {
- a ? this.world.on("impact", this.impactHandler, this) : this.world.off("impact", this.impactHandler, this)
- },
- setPostBroadphaseCallback: function(a, b) {
- this.postBroadphaseCallback = a, this.callbackContext = b, null !== a ? this.world.on("postBroadphase", this.postBroadphaseHandler, this) : this.world.off("postBroadphase", this.postBroadphaseHandler, this)
- },
- postBroadphaseHandler: function(a) {
- var b = a.pairs.length;
- if (this.postBroadphaseCallback && b > 0)
- 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)
- },
- impactHandler: function(a) {
- if (a.bodyA.parent && a.bodyB.parent) {
- var b = a.bodyA.parent,
- c = a.bodyB.parent;
- 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)
- }
- },
- beginContactHandler: function(a) {
- 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)
- },
- endContactHandler: function(a) {
- 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)
- },
- setBoundsToWorld: function(a, b, c, d, e) {
- 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)
- },
- setWorldMaterial: function(a, b, c, d, e) {
- "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)
- },
- updateBoundsCollisionGroup: function(a) {
- var b = this.everythingCollisionGroup.mask;
- "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)
- },
- setBounds: function(a, b, c, d, e, f, g, h, i) {
- "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({
- mass: 0,
- position: [this.pxmi(a), this.pxmi(b)],
- angle: 1.5707963267948966
- }), 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({
- mass: 0,
- position: [this.pxmi(a + c), this.pxmi(b)],
- angle: -1.5707963267948966
- }), 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({
- mass: 0,
- position: [this.pxmi(a), this.pxmi(b)],
- angle: -3.141592653589793
- }), 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({
- mass: 0,
- position: [this.pxmi(a), this.pxmi(b + d)]
- }), this.walls.bottom.addShape(new p2.Plane), i && (this.walls.bottom.shapes[0].collisionGroup = this.boundsCollisionGroup.mask), this.world.addBody(this.walls.bottom))
- },
- pause: function() {
- this.paused = !0
- },
- resume: function() {
- this.paused = !1
- },
- update: function() {
- this.paused || this.world.step(this.useElapsedTime ? this.game.time.physicsElapsed : this.frameRate)
- },
- clear: function() {
- 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 = []
- },
- destroy: function() {
- this.clear(), this.game = null
- },
- addBody: function(a) {
- return a.data.world ? !1 : (this.world.addBody(a.data), this.onBodyAdded.dispatch(a), !0)
- },
- removeBody: function(a) {
- return a.data.world == this.world && (this.world.removeBody(a.data), this.onBodyRemoved.dispatch(a)), a
- },
- addSpring: function(a) {
- return this.world.addSpring(a instanceof Phaser.Physics.P2.Spring || a instanceof Phaser.Physics.P2.RotationalSpring ? a.data : a), this.onSpringAdded.dispatch(a), a
- },
- removeSpring: function(a) {
- return this.world.removeSpring(a instanceof Phaser.Physics.P2.Spring || a instanceof Phaser.Physics.P2.RotationalSpring ? a.data : a), this.onSpringRemoved.dispatch(a), a
- },
- createDistanceConstraint: function(a, b, c, d, e, f) {
- 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")
- },
- createGearConstraint: function(a, b, c, d) {
- 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")
- },
- createRevoluteConstraint: function(a, b, c, d, e, f) {
- 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")
- },
- createLockConstraint: function(a, b, c, d, e) {
- 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")
- },
- createPrismaticConstraint: function(a, b, c, d, e, f, g) {
- 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")
- },
- addConstraint: function(a) {
- return this.world.addConstraint(a), this.onConstraintAdded.dispatch(a), a
- },
- removeConstraint: function(a) {
- return this.world.removeConstraint(a), this.onConstraintRemoved.dispatch(a), a
- },
- addContactMaterial: function(a) {
- return this.world.addContactMaterial(a), this.onContactMaterialAdded.dispatch(a), a
- },
- removeContactMaterial: function(a) {
- return this.world.removeContactMaterial(a), this.onContactMaterialRemoved.dispatch(a), a
- },
- getContactMaterial: function(a, b) {
- return this.world.getContactMaterial(a, b)
- },
- setMaterial: function(a, b) {
- for (var c = b.length; c--;) b[c].setMaterial(a)
- },
- createMaterial: function(a, b) {
- a = a || "";
- var c = new Phaser.Physics.P2.Material(a);
- return this.materials.push(c), "undefined" != typeof b && b.setMaterial(c), c
- },
- createContactMaterial: function(a, b, c) {
- "undefined" == typeof a && (a = this.createMaterial()), "undefined" == typeof b && (b = this.createMaterial());
- var d = new Phaser.Physics.P2.ContactMaterial(a, b, c);
- return this.addContactMaterial(d)
- },
- getBodies: function() {
- for (var a = [], b = this.world.bodies.length; b--;) a.push(this.world.bodies[b].parent);
- return a
- },
- getBody: function(a) {
- 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
- },
- getSprings: function() {
- for (var a = [], b = this.world.springs.length; b--;) a.push(this.world.springs[b].parent);
- return a
- },
- getConstraints: function() {
- for (var a = [], b = this.world.constraints.length; b--;) a.push(this.world.constraints[b].parent);
- return a
- },
- hitTest: function(a, b, c, d) {
- "undefined" == typeof b && (b = this.world.bodies), "undefined" == typeof c && (c = 5), "undefined" == typeof d && (d = !1);
- 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);
- return this.world.hitTest(e, f, c)
- },
- toJSON: function() {
- return this.world.toJSON()
- },
- createCollisionGroup: function(a) {
- var b = Math.pow(2, this._collisionGroupID);
- 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++;
- var c = new Phaser.Physics.P2.CollisionGroup(b);
- return this.collisionGroups.push(c), a && this.setCollisionGroup(a, c), c
- },
- setCollisionGroup: function(a, b) {
- if (a instanceof Phaser.Group)
- 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);
- else a.body.setCollisionGroup(b)
- },
- createSpring: function(a, b, c, d, e, f, g, h, i) {
- 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")
- },
- createRotationalSpring: function(a, b, c, d, e) {
- 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")
- },
- createBody: function(a, b, c, d, e, f) {
- "undefined" == typeof d && (d = !1);
- var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
- if (f) {
- var h = g.addPolygon(e, f);
- if (!h) return !1
- }
- return d && this.world.addBody(g.data), g
- },
- createParticle: function(a, b, c, d, e, f) {
- "undefined" == typeof d && (d = !1);
- var g = new Phaser.Physics.P2.Body(this.game, null, a, b, c);
- if (f) {
- var h = g.addPolygon(e, f);
- if (!h) return !1
- }
- return d && this.world.addBody(g.data), g
- },
- convertCollisionObjects: function(a, b, c) {
- "undefined" == typeof c && (c = !0);
- for (var d = [], e = 0, f = a.collision[b].length; f > e; e++) {
- var g = a.collision[b][e],
- h = this.createBody(g.x, g.y, 0, c, {}, g.polyline);
- h && d.push(h)
- }
- return d
- },
- clearTilemapLayerBodies: function(a, b) {
- b = a.getLayer(b);
- for (var c = a.layers[b].bodies.length; c--;) a.layers[b].bodies[c].destroy();
- a.layers[b].bodies.length = 0
- },
- convertTilemap: function(a, b, c, d) {
- b = a.getLayer(b), "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !0), this.clearTilemapLayerBodies(a, b);
- for (var e = 0, f = 0, g = 0, h = 0, i = a.layers[b].height; i > h; h++) {
- e = 0;
- for (var j = 0, k = a.layers[b].width; k > j; j++) {
- var l = a.layers[b].data[h][j];
- if (l && l.index > -1 && l.collides)
- if (d) {
- var m = a.getTileRight(b, j, h);
- if (0 === e && (f = l.x * l.width, g = l.y * l.height, e = l.width), m && m.collides) e += l.width;
- else {
- var n = this.createBody(f, g, 0, !1);
- n.addRectangle(e, l.height, e / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n), e = 0
- }
- } else {
- var n = this.createBody(l.x * l.width, l.y * l.height, 0, !1);
- n.addRectangle(l.width, l.height, l.width / 2, l.height / 2, 0), c && this.addBody(n), a.layers[b].bodies.push(n)
- }
- }
- }
- return a.layers[b].bodies
- },
- mpx: function(a) {
- return a *= 20
- },
- pxm: function(a) {
- return .05 * a
- },
- mpxi: function(a) {
- return a *= -20
- },
- pxmi: function(a) {
- return a * -.05
- }
- }, Object.defineProperty(Phaser.Physics.P2.prototype, "friction", {
- get: function() {
- return this.world.defaultContactMaterial.friction
- },
- set: function(a) {
- this.world.defaultContactMaterial.friction = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "restitution", {
- get: function() {
- return this.world.defaultContactMaterial.restitution
- },
- set: function(a) {
- this.world.defaultContactMaterial.restitution = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "contactMaterial", {
- get: function() {
- return this.world.defaultContactMaterial
- },
- set: function(a) {
- this.world.defaultContactMaterial = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", {
- get: function() {
- return this.world.applySpringForces
- },
- set: function(a) {
- this.world.applySpringForces = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", {
- get: function() {
- return this.world.applyDamping
- },
- set: function(a) {
- this.world.applyDamping = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", {
- get: function() {
- return this.world.applyGravity
- },
- set: function(a) {
- this.world.applyGravity = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", {
- get: function() {
- return this.world.solveConstraints
- },
- set: function(a) {
- this.world.solveConstraints = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "time", {
- get: function() {
- return this.world.time
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", {
- get: function() {
- return this.world.emitImpactEvent
- },
- set: function(a) {
- this.world.emitImpactEvent = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "sleepMode", {
- get: function() {
- return this.world.sleepMode
- },
- set: function(a) {
- this.world.sleepMode = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.prototype, "total", {
- get: function() {
- return this.world.bodies.length
- }
- }), Phaser.Physics.P2.FixtureList = function(a) {
- Array.isArray(a) || (a = [a]), this.rawList = a, this.init(), this.parse(this.rawList)
- }, Phaser.Physics.P2.FixtureList.prototype = {
- init: function() {
- this.namedFixtures = {}, this.groupedFixtures = [], this.allFixtures = []
- },
- setCategory: function(a, b) {
- var c = function(b) {
- b.collisionGroup = a
- };
- this.getFixtures(b).forEach(c)
- },
- setMask: function(a, b) {
- var c = function(b) {
- b.collisionMask = a
- };
- this.getFixtures(b).forEach(c)
- },
- setSensor: function(a, b) {
- var c = function(b) {
- b.sensor = a
- };
- this.getFixtures(b).forEach(c)
- },
- setMaterial: function(a, b) {
- var c = function(b) {
- b.material = a
- };
- this.getFixtures(b).forEach(c)
- },
- getFixtures: function(a) {
- var b = [];
- if (a) {
- a instanceof Array || (a = [a]);
- var c = this;
- return a.forEach(function(a) {
- c.namedFixtures[a] && b.push(c.namedFixtures[a])
- }), this.flatten(b)
- }
- return this.allFixtures
- },
- getFixtureByKey: function(a) {
- return this.namedFixtures[a]
- },
- getGroup: function(a) {
- return this.groupedFixtures[a]
- },
- parse: function() {
- var a, b, c, d;
- c = this.rawList, d = [];
- 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))
- },
- flatten: function(a) {
- var b, c;
- return b = [], c = arguments.callee, a.forEach(function(a) {
- return Array.prototype.push.apply(b, Array.isArray(a) ? c(a) : [a])
- }), b
- }
- }, Phaser.Physics.P2.PointProxy = function(a, b) {
- this.world = a, this.destination = b
- }, Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProxy, Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
- get: function() {
- return this.world.mpx(this.destination[0])
- },
- set: function(a) {
- this.destination[0] = this.world.pxm(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
- get: function() {
- return this.world.mpx(this.destination[1])
- },
- set: function(a) {
- this.destination[1] = this.world.pxm(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "mx", {
- get: function() {
- return this.destination[0]
- },
- set: function(a) {
- this.destination[0] = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "my", {
- get: function() {
- return this.destination[1]
- },
- set: function(a) {
- this.destination[1] = a
- }
- }), Phaser.Physics.P2.InversePointProxy = function(a, b) {
- this.world = a, this.destination = b
- }, Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.InversePointProxy, Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
- get: function() {
- return this.world.mpxi(this.destination[0])
- },
- set: function(a) {
- this.destination[0] = this.world.pxmi(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
- get: function() {
- return this.world.mpxi(this.destination[1])
- },
- set: function(a) {
- this.destination[1] = this.world.pxmi(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "mx", {
- get: function() {
- return this.destination[0]
- },
- set: function(a) {
- this.destination[0] = -a
- }
- }), Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "my", {
- get: function() {
- return this.destination[1]
- },
- set: function(a) {
- this.destination[1] = -a
- }
- }), Phaser.Physics.P2.Body = function(a, b, c, d, e) {
- 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({
- position: [this.world.pxmi(c), this.world.pxmi(d)],
- mass: e
- }), 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))
- }, Phaser.Physics.P2.Body.prototype = {
- createBodyCallback: function(a, b, c) {
- var d = -1;
- 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))
- },
- createGroupCallback: function(a, b, c) {
- null === b ? (delete this._groupCallbacks[a.mask], delete this._groupCallbacksContext[a.mask]) : (this._groupCallbacks[a.mask] = b, this._groupCallbackContext[a.mask] = c)
- },
- getCollisionMask: function() {
- var a = 0;
- this._collideWorldBounds && (a = this.game.physics.p2.boundsCollisionGroup.mask);
- for (var b = 0; b < this.collidesWith.length; b++) a |= this.collidesWith[b].mask;
- return a
- },
- updateCollisionMask: function(a) {
- var b = this.getCollisionMask();
- if ("undefined" == typeof a)
- for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].collisionMask = b;
- else a.collisionMask = b
- },
- setCollisionGroup: function(a, b) {
- var c = this.getCollisionMask();
- if ("undefined" == typeof b)
- for (var d = this.data.shapes.length - 1; d >= 0; d--) this.data.shapes[d].collisionGroup = a.mask, this.data.shapes[d].collisionMask = c;
- else b.collisionGroup = a.mask, b.collisionMask = c
- },
- clearCollision: function(a, b, c) {
- if ("undefined" == typeof c)
- 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);
- else a && (c.collisionGroup = null), b && (c.collisionMask = null);
- a && (this.collidesWith.length = 0)
- },
- collides: function(a, b, c, d) {
- if (Array.isArray(a))
- 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));
- else -1 === this.collidesWith.indexOf(a) && (this.collidesWith.push(a), b && this.createGroupCallback(a, b, c));
- var f = this.getCollisionMask();
- if ("undefined" == typeof d)
- for (var e = this.data.shapes.length - 1; e >= 0; e--) this.data.shapes[e].collisionMask = f;
- else d.collisionMask = f
- },
- adjustCenterOfMass: function() {
- this.data.adjustCenterOfMass()
- },
- applyDamping: function(a) {
- this.data.applyDamping(a)
- },
- applyForce: function(a, b, c) {
- this.data.applyForce(a, [this.world.pxmi(b), this.world.pxmi(c)])
- },
- setZeroForce: function() {
- this.data.setZeroForce()
- },
- setZeroRotation: function() {
- this.data.angularVelocity = 0
- },
- setZeroVelocity: function() {
- this.data.velocity[0] = 0, this.data.velocity[1] = 0
- },
- setZeroDamping: function() {
- this.data.damping = 0, this.data.angularDamping = 0
- },
- toLocalFrame: function(a, b) {
- return this.data.toLocalFrame(a, b)
- },
- toWorldFrame: function(a, b) {
- return this.data.toWorldFrame(a, b)
- },
- rotateLeft: function(a) {
- this.data.angularVelocity = this.world.pxm(-a)
- },
- rotateRight: function(a) {
- this.data.angularVelocity = this.world.pxm(a)
- },
- moveForward: function(a) {
- var b = this.world.pxmi(-a),
- c = this.data.angle + Math.PI / 2;
- this.data.velocity[0] = b * Math.cos(c), this.data.velocity[1] = b * Math.sin(c)
- },
- moveBackward: function(a) {
- var b = this.world.pxmi(-a),
- c = this.data.angle + Math.PI / 2;
- this.data.velocity[0] = -(b * Math.cos(c)), this.data.velocity[1] = -(b * Math.sin(c))
- },
- thrust: function(a) {
- var b = this.world.pxmi(-a),
- c = this.data.angle + Math.PI / 2;
- this.data.force[0] += b * Math.cos(c), this.data.force[1] += b * Math.sin(c)
- },
- reverse: function(a) {
- var b = this.world.pxmi(-a),
- c = this.data.angle + Math.PI / 2;
- this.data.force[0] -= b * Math.cos(c), this.data.force[1] -= b * Math.sin(c)
- },
- moveLeft: function(a) {
- this.data.velocity[0] = this.world.pxmi(-a)
- },
- moveRight: function(a) {
- this.data.velocity[0] = this.world.pxmi(a)
- },
- moveUp: function(a) {
- this.data.velocity[1] = this.world.pxmi(-a)
- },
- moveDown: function(a) {
- this.data.velocity[1] = this.world.pxmi(a)
- },
- preUpdate: function() {
- this.removeNextStep && (this.removeFromWorld(), this.removeNextStep = !1)
- },
- postUpdate: function() {
- 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)
- },
- reset: function(a, b, c, d) {
- "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
- },
- addToWorld: function() {
- if (this.game.physics.p2._toRemove)
- 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);
- this.data.world !== this.game.physics.p2.world && this.game.physics.p2.addBody(this)
- },
- removeFromWorld: function() {
- this.data.world === this.game.physics.p2.world && this.game.physics.p2.removeBodyNextStep(this)
- },
- destroy: function() {
- 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
- },
- clearShapes: function() {
- for (var a = this.data.shapes.length; a--;) this.data.removeShape(this.data.shapes[a]);
- this.shapeChanged()
- },
- addShape: function(a, b, c, d) {
- 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
- },
- addCircle: function(a, b, c, d) {
- var e = new p2.Circle(this.world.pxm(a));
- return this.addShape(e, b, c, d)
- },
- addRectangle: function(a, b, c, d, e) {
- var f = new p2.Rectangle(this.world.pxm(a), this.world.pxm(b));
- return this.addShape(f, c, d, e)
- },
- addPlane: function(a, b, c) {
- var d = new p2.Plane;
- return this.addShape(d, a, b, c)
- },
- addParticle: function(a, b, c) {
- var d = new p2.Particle;
- return this.addShape(d, a, b, c)
- },
- addLine: function(a, b, c, d) {
- var e = new p2.Line(this.world.pxm(a));
- return this.addShape(e, b, c, d)
- },
- addCapsule: function(a, b, c, d, e) {
- var f = new p2.Capsule(this.world.pxm(a), this.world.pxm(b));
- return this.addShape(f, c, d, e)
- },
- addPolygon: function(a, b) {
- a = a || {}, Array.isArray(b) || (b = Array.prototype.slice.call(arguments, 1));
- var c = [];
- if (1 === b.length && Array.isArray(b[0])) c = b[0].slice(0);
- else if (Array.isArray(b[0])) c = b.slice();
- else if ("number" == typeof b[0])
- for (var d = 0, e = b.length; e > d; d += 2) c.push([b[d], b[d + 1]]);
- var f = c.length - 1;
- c[f][0] === c[0][0] && c[f][1] === c[0][1] && c.pop();
- 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]);
- var h = this.data.fromPolygon(c, a);
- return this.shapeChanged(), h
- },
- removeShape: function(a) {
- var b = this.data.removeShape(a);
- return this.shapeChanged(), b
- },
- setCircle: function(a, b, c, d) {
- return this.clearShapes(), this.addCircle(a, b, c, d)
- },
- setRectangle: function(a, b, c, d, e) {
- return "undefined" == typeof a && (a = 16), "undefined" == typeof b && (b = 16), this.clearShapes(), this.addRectangle(a, b, c, d, e)
- },
- setRectangleFromSprite: function(a) {
- return "undefined" == typeof a && (a = this.sprite), this.clearShapes(), this.addRectangle(a.width, a.height, 0, 0, a.rotation)
- },
- setMaterial: function(a, b) {
- if ("undefined" == typeof b)
- for (var c = this.data.shapes.length - 1; c >= 0; c--) this.data.shapes[c].material = a;
- else b.material = a
- },
- shapeChanged: function() {
- this.debugBody && this.debugBody.draw()
- },
- addPhaserPolygon: function(a, b) {
- for (var c = this.game.cache.getPhysicsData(a, b), d = [], e = 0; e < c.length; e++) {
- var f = c[e],
- g = this.addFixture(f);
- d[f.filter.group] = d[f.filter.group] || [], d[f.filter.group] = d[f.filter.group].concat(g), f.fixtureKey && (d[f.fixtureKey] = g)
- }
- return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), d
- },
- addFixture: function(a) {
- var b = [];
- if (a.circle) {
- var c = new p2.Circle(this.world.pxm(a.circle.radius));
- c.collisionGroup = a.filter.categoryBits, c.collisionMask = a.filter.maskBits, c.sensor = a.isSensor;
- var d = p2.vec2.create();
- 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)
- } else
- for (var e = a.polygons, f = p2.vec2.create(), g = 0; g < e.length; g++) {
- 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])]);
- for (var c = new p2.Convex(i), k = 0; k !== c.vertices.length; k++) {
- var l = c.vertices[k];
- p2.vec2.sub(l, l, c.centerOfMass)
- }
- 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)
- }
- return b
- },
- loadPolygon: function(a, b) {
- for (var c = this.game.cache.getPhysicsData(a, b), d = p2.vec2.create(), e = 0; e < c.length; e++) {
- 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])]);
- for (var h = new p2.Convex(f), i = 0; i !== h.vertices.length; i++) {
- var j = h.vertices[i];
- p2.vec2.sub(j, j, h.centerOfMass)
- }
- 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)
- }
- return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), !0
- }
- }, 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", {
- get: function() {
- return this.data.type === Phaser.Physics.P2.Body.STATIC
- },
- set: function(a) {
- 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))
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
- get: function() {
- return this.data.type === Phaser.Physics.P2.Body.DYNAMIC
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
- get: function() {
- return this.data.type === Phaser.Physics.P2.Body.KINEMATIC
- },
- set: function(a) {
- 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)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
- get: function() {
- return this.data.allowSleep
- },
- set: function(a) {
- a !== this.data.allowSleep && (this.data.allowSleep = a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angle", {
- get: function() {
- return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.data.angle))
- },
- set: function(a) {
- this.data.angle = Phaser.Math.degToRad(Phaser.Math.wrapAngle(a))
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
- get: function() {
- return this.data.angularDamping
- },
- set: function(a) {
- this.data.angularDamping = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
- get: function() {
- return this.data.angularForce
- },
- set: function(a) {
- this.data.angularForce = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
- get: function() {
- return this.data.angularVelocity
- },
- set: function(a) {
- this.data.angularVelocity = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
- get: function() {
- return this.data.damping
- },
- set: function(a) {
- this.data.damping = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
- get: function() {
- return this.data.fixedRotation
- },
- set: function(a) {
- a !== this.data.fixedRotation && (this.data.fixedRotation = a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
- get: function() {
- return this.data.inertia
- },
- set: function(a) {
- this.data.inertia = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
- get: function() {
- return this.data.mass
- },
- set: function(a) {
- a !== this.data.mass && (this.data.mass = a, this.data.updateMassProperties())
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
- get: function() {
- return this.data.type
- },
- set: function(a) {
- a !== this.data.type && (this.data.type = a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "rotation", {
- get: function() {
- return this.data.angle
- },
- set: function(a) {
- this.data.angle = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
- get: function() {
- return this.data.sleepSpeedLimit
- },
- set: function(a) {
- this.data.sleepSpeedLimit = a
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
- get: function() {
- return this.world.mpxi(this.data.position[0])
- },
- set: function(a) {
- this.data.position[0] = this.world.pxmi(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
- get: function() {
- return this.world.mpxi(this.data.position[1])
- },
- set: function(a) {
- this.data.position[1] = this.world.pxmi(a)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
- get: function() {
- return this.data.id
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
- get: function() {
- return null !== this.debugBody
- },
- set: function(a) {
- a && !this.debugBody ? this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data) : !a && this.debugBody && (this.debugBody.destroy(), this.debugBody = null)
- }
- }), Object.defineProperty(Phaser.Physics.P2.Body.prototype, "collideWorldBounds", {
- get: function() {
- return this._collideWorldBounds
- },
- set: function(a) {
- a && !this._collideWorldBounds ? (this._collideWorldBounds = !0, this.updateCollisionMask()) : !a && this._collideWorldBounds && (this._collideWorldBounds = !1, this.updateCollisionMask())
- }
- }), Phaser.Physics.P2.BodyDebug = function(a, b, c) {
- Phaser.Group.call(this, a);
- var d = {
- pixelsPerLengthUnit: 20,
- debugPolygons: !1,
- lineWidth: 1,
- alpha: .5
- };
- 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()
- }, 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, {
- update: function() {
- this.updateSpriteTransform()
- },
- updateSpriteTransform: function() {
- return this.position.x = this.body.position[0] * this.ppu, this.position.y = this.body.position[1] * this.ppu, this.rotation = this.body.angle
- },
- draw: function() {
- var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o;
- 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) {
- var p = h.shapes.length;
- for (d = 0; d !== p;) {
- 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);
- else if (b instanceof p2.Convex) {
- 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]);
- this.drawConvex(j, l, b.triangles, f, c, g, this.settings.debugPolygons, [i[0] * this.ppu, -i[1] * this.ppu])
- } 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);
- d++
- }
- }
- },
- drawRectangle: function(a, b, c, d, e, f, g, h, i) {
- "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)
- },
- drawCircle: function(a, b, c, d, e, f, g) {
- "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))
- },
- drawLine: function(a, b, c, d) {
- "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)
- },
- drawConvex: function(a, b, c, d, e, f, g, h) {
- var i, j, k, l, m, n, o, p, q, r, s;
- if ("undefined" == typeof f && (f = 1), "undefined" == typeof d && (d = 0), g) {
- 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++;
- return a.lineStyle(f, 0, 1), a.drawCircle(h[0], h[1], 2 * f)
- }
- 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++;
- 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
- },
- drawPath: function(a, b, c, d, e) {
- var f, g, h, i, j, k, l, m, n, o, p, q, r;
- 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++;
- "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]))
- },
- drawPlane: function(a, b, c, d, e, f, g, h, i, j) {
- var k, l, m;
- "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)
- },
- randomPastelHex: function() {
- var a, b, c, d;
- 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)
- },
- rgbToHex: function(a, b, c) {
- return this.componentToHex(a) + this.componentToHex(b) + this.componentToHex(c)
- },
- componentToHex: function(a) {
- var b;
- return b = a.toString(16), 2 === b.len ? b : b + "0"
- }
- }), Phaser.Physics.P2.Spring = function(a, b, c, d, e, f, g, h, i, j) {
- 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);
- var k = {
- restLength: d,
- stiffness: e,
- damping: f
- };
- "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
- }, Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring, Phaser.Physics.P2.RotationalSpring = function(a, b, c, d, e, f) {
- 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));
- var g = {
- restAngle: d,
- stiffness: e,
- damping: f
- };
- this.data = new p2.RotationalSpring(b, c, g), this.data.parent = this
- }, Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring, Phaser.Physics.P2.Material = function(a) {
- this.name = a, p2.Material.call(this)
- }, 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) {
- p2.ContactMaterial.call(this, a, b, c)
- }, 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) {
- this.mask = a
- }, Phaser.Physics.P2.DistanceConstraint = function(a, b, c, d, e, f, g) {
- "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])];
- var h = {
- distance: d,
- localAnchorA: e,
- localAnchorB: f,
- maxForce: g
- };
- p2.DistanceConstraint.call(this, b, c, h)
- }, 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) {
- "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 1), this.game = a.game, this.world = a;
- var f = {
- angle: d,
- ratio: e
- };
- p2.GearConstraint.call(this, b, c, f)
- }, 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) {
- "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])];
- var g = {
- localOffsetB: d,
- localAngleB: e,
- maxForce: f
- };
- p2.LockConstraint.call(this, b, c, g)
- }, 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) {
- "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])];
- var i = {
- localAnchorA: e,
- localAnchorB: f,
- localAxisA: g,
- maxForce: h,
- disableRotationalLock: !d
- };
- p2.PrismaticConstraint.call(this, b, c, i)
- }, 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) {
- "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])]);
- var h = {
- worldPivot: g,
- localPivotA: c,
- localPivotB: e,
- maxForce: f
- };
- p2.RevoluteConstraint.call(this, b, d, h)
- }, Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype), Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
- (function() {
- 'use strict';
- var isCommonjs = typeof module !== 'undefined' && module.exports;
- var adInterstitialProvider = 'none';
- var adBannerProvider = 'none';
- var adInterstitialProviderDefault = 'none';
- var adBannerProviderDefault = 'none';
- var responseObj = null;
- var adserver = {
- readServerResponse: function(obj) {
- responseObj = obj;
- if (obj.banner) {
- if (obj.banner.provider == 'self') {
- adBannerProvider = 'self'
- } else if (obj.banner.provider) {
- adBannerProvider = obj.banner.provider
- } else {
- adBannerProvider = 'leadbolt'
- }
- } else {
- adBannerProvider = adBannerProviderDefault
- }
- if (obj.interstitial) {
- if (obj.interstitial.provider == 'self') {
- adInterstitialProvider = 'self'
- } else if (obj.interstitial.provider) {
- adInterstitialProvider = obj.interstitial.provider
- } else {
- adInterstitialProvider = 'leadbolt'
- }
- } else {
- adInterstitialProvider = adInterstitialProviderDefault
- }
- },
- initialize: function(onready, onerror, gameID) {
- var params = '';
- if (gameID === undefined) {
- params = ''
- } else {
- params = '?g=' + gameID.toString()
- }
- var req = new XMLHttpRequest();
- req.open('GET', '#' + params, true); /*Paste your ad link here*/
- req.timeout = 3000;
- req.onload = function() {
- if (req.readyState == 4 && req.status == 200) {
- adserver.readServerResponse(JSON.parse(req.responseText));
- onready.call()
- } else {
- onerror.call()
- }
- };
- req.ontimeout = onerror;
- req.onerror = onerror;
- req.onabort = onerror;
- req.send()
- }
- };
- Object.defineProperties(adserver, {
- interstitialProvider: {
- get: function() {
- return adInterstitialProvider
- }
- },
- bannerProvider: {
- get: function() {
- return adBannerProvider
- }
- },
- responseObject: {
- get: function() {
- return responseObj
- }
- }
- });
- if (isCommonjs) {
- module.exports = adserver
- } else {
- window.adserver = adserver
- }
- })();
- (function() {
- 'use strict';
- var isCommonjs = typeof module !== 'undefined' && module.exports;
- var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
- var fn = (function() {
- var val;
- var valLength;
- var fnMap = [
- ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
- ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
- ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
- ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
- ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']
- ];
- var i = 0;
- var l = fnMap.length;
- var ret = {};
- for (; i < l; i++) {
- val = fnMap[i];
- if (val && val[1] in document) {
- for (i = 0, valLength = val.length; i < valLength; i++) {
- ret[fnMap[0][i]] = val[i]
- }
- return ret
- }
- }
- return false
- })();
- var screenfull = {
- request: function(elem) {
- var request = fn.requestFullscreen;
- elem = elem || document.documentElement;
- if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
- elem[request]()
- } else {
- elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT)
- }
- },
- exit: function() {
- document[fn.exitFullscreen]()
- },
- toggle: function(elem) {
- if (this.isFullscreen) {
- this.exit()
- } else {
- this.request(elem)
- }
- },
- onchange: function() {},
- onerror: function() {},
- raw: fn
- };
- if (!fn) {
- if (isCommonjs) {
- module.exports = false
- } else {
- window.screenfull = false
- }
- return
- }
- Object.defineProperties(screenfull, {
- isFullscreen: {
- get: function() {
- return !!document[fn.fullscreenElement]
- }
- },
- element: {
- enumerable: true,
- get: function() {
- return document[fn.fullscreenElement]
- }
- },
- enabled: {
- enumerable: true,
- get: function() {
- return !!document[fn.fullscreenEnabled]
- }
- }
- });
- document.addEventListener(fn.fullscreenchange, function(e) {
- screenfull.onchange.call(screenfull, e)
- });
- document.addEventListener(fn.fullscreenerror, function(e) {
- screenfull.onerror.call(screenfull, e)
- });
- if (isCommonjs) {
- module.exports = screenfull
- } else {
- window.screenfull = screenfull
- }
- })();
- (function() {
- var BasicGame = {};
- var GC = {};
- GC.totalLevels = 27;
- GC.FullScreenEnabled = false;
- GC.playSound = true;
- GC.soundDisabled = false;
- BasicGame.stateFirst = 'state_menu';
- BasicGame.loadPreTextured = true;
- BasicGame.previewMode = false;
- BasicGame.showSponsor = false;
- BasicGame.winStarsCurrent = 0;
- BasicGame.winStarsPrevious = 0;
- BasicGame.debug = false;
- BasicGame.debugPhysics = false;
- BasicGame.currentLevel = 0;
- BasicGame.Levels = new Array(GC.totalLevels);
- BasicGame.LevelStarShots = new Array(GC.totalLevels);
- BasicGame.LevelStars = [];
- BasicGame.LevelsOpen = [];
- BasicGame.sndMenuLoop = null;
- BasicGame.sndGameLoop = null;
- BasicGame.linkAppStore = 'http://www.play68.com'//'http://www.yiv.com';
- BasicGame.linkAndroid = 'http://www.play68.com'//'http://www.yiv.com';
- BasicGame.linkWinPhone = 'http://www.play68.com'//'http://www.yiv.com';
- BasicGame.linkDownloadPage = 'http://www.play68.com'//'http://www.yiv.com';
- function btnDownloadsPressed() {
- _czc.push(["_trackEvent","小虎回家","更多游戏","","",""]);
- if(document.referrer)
- Play68.goHome();
- else
- play68_goHome();
- // if (game.device.desktop) {
- // window.open(BasicGame.linkDownloadPage, '_blank')
- // } else if (this.game.device.android) {
- // window.open(BasicGame.linkAndroid)
- // } else if (this.game.device.iOS) {
- // window.open(BasicGame.linkDownloadPage, '_blank')
- // } else if (this.game.device.windowsPhone) {
- // window.open(BasicGame.linkWinPhone)
- // } else {
- // window.open(BasicGame.linkWinPhone, '_blank')
- // }
- };
- BasicGame.saveGame = function() {
- if (typeof(Storage) !== "undefined") {
- try {
- var levelStars = [],totalLevelStars=0;
- var i = 0;
- for (i = 0; i < GC.totalLevels; i++) {
- levelStars[i] = BasicGame.LevelStars[i]
- if(i<(BasicGame.currentLevel+1))
- totalLevelStars+=BasicGame.LevelStars[i];
- }
- window.localStorage.removeItem('foxystars');
- window.localStorage.setItem('foxystars', levelStars);
- var levelsOpen = [];
- for (i = 0; i < GC.totalLevels; i++) {
- levelsOpen[i] = BasicGame.LevelsOpen[i]
- }
- window.localStorage.removeItem('foxylevels');
- window.localStorage.setItem('foxylevels', levelsOpen)
- updateShare(BasicGame.currentLevel+1,totalLevelStars);
- Play68.setRankingLevelScoreDesc(BasicGame.currentLevel+1,totalLevelStars);
- console.log(BasicGame.currentLevel+1,totalLevelStars)
- } catch (err) {}
- }
- };
- BasicGame.loadGame = function() {
- if (typeof(Storage) !== "undefined") {
- try {
- var levelStars = window.localStorage.getItem('foxystars');
- var i = 0;
- if (levelStars) {
- levelStars = levelStars.split(',');
- for (i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelStars[i] = parseInt(levelStars[i], 10)
- }
- } else {
- for (i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelStars[i] = 0
- }
- }
- var levelsOpen = window.localStorage.getItem('foxylevels');
- if (levelsOpen) {
- levelsOpen = levelsOpen.split(',');
- for (i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = parseInt(levelsOpen[i], 10)
- }
- } else {
- BasicGame.LevelsOpen[0] = 1;
- for (i = 1; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = 0
- }
- }
- } catch (err) {
- for (var i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelStars[i] = 0
- }
- BasicGame.LevelsOpen[0] = 1;
- for (i = 1; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = 0
- }
- }
- } else {
- for (var i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelStars[i] = 0
- }
- BasicGame.LevelsOpen[0] = 1;
- for (i = 1; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = 0
- }
- }
- };
- BasicGame.clearAllData = function() {
- BasicGame.LevelStars[0] = 0;
- BasicGame.LevelsOpen[0] = 1;
- for (var i = 1; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = BasicGame.LevelStars[i] = 0
- }
- BasicGame.saveGame()
- };
- BasicGame.openAllLevels = function() {
- for (var i = 0; i < GC.totalLevels; i++) {
- BasicGame.LevelsOpen[i] = 1
- }
- BasicGame.saveGame()
- };
- var desiredOrientation = 'portrait';
- var orientationGoodAtFirst = false;
- var orientReload = false;
- var noMoreReload = false;
- BasicGame.StateBoot = function() {};
- BasicGame.StateBoot.prototype = {
- preload: function() {
- BasicGame.loadGame();
- this.game.load.bitmapFont('grobold_loading', 'assets/fonts/grobold_loading_0.png', 'assets/fonts/grobold_loading.fnt');
- this.game.load.atlas('atlas_preloader', 'assets/graphics/preloader_assets.png', 'assets/graphics/preloader_assets.json');
- this.game.load.onLoadComplete.addOnce(this.loadingCompleted, this);
- this.bootBd = this.make.bitmapData(this.game.width - 30, 10);
- this.bootBd.addToWorld(15, this.game.height / 2 - 5);
- this.bootBd.context.fillStyle = '#383838';
- GC.FullScreenEnabled = (this.game.device.desktop && screenfull.enabled);
- if (GC.FullScreenEnabled) {
- document.addEventListener(screenfull.raw.fullscreenchange, screenFullResize)
- }
- this.setupScaling();
- if (BasicGame.debug) {
- this.game.add.plugin(Phaser.Plugin.Debug)
- }
- this.world.setBounds(-200, -200, this.game.width + 400, this.game.height + 400);
- this.world.camera.position.x = 0;
- this.world.camera.position.y = 0;
- this.game.physics.startSystem(Phaser.Physics.P2JS)
- },
- create: function() {
- //initAds()
- },
- update: function() {
- if (this.load.progress > 0) {
- this.bootBd.context.fillRect(0, 0, this.bootBd.width * (this.load.progress / 100), 10);
- this.bootBd.dirty = true
- }
- },
- setupScaling: function() {
- if (this.game.device.desktop) {
- this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
- this.scale.pageAlignHorizontally = true;
- this.scale.pageAlignVertically = true;
- this.scale.setScreenSize();
- this.scale.refresh()
- } else {
- if (desiredOrientation == 'landscape') {
- if (window.innerWidth > window.innerHeight) {
- orientationGoodAtFirst = true
- }
- } else if (desiredOrientation == 'portrait') {
- if (window.innerWidth < window.innerHeight) {
- orientationGoodAtFirst = true
- }
- }
- this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
- this.scale.pageAlignHorizontally = true;
- this.scale.pageAlignVertically = true;
- this.scale.forceOrientation(false, true);
- this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);
- this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);
- this.scale.setScreenSize();
- this.scale.refresh()
- }
- },
- enterIncorrectOrientation: function() {
- if (!orientationGoodAtFirst && (this.game.state.current == 'state_boot' || this.game.state.current == 'state_preload') && !this.game.device.desktop) {
- orientReload = true
- }
- if (desiredOrientation == 'landscape' && window.innerWidth > window.innerHeight) {
- return
- } else if (desiredOrientation == 'portrait' && window.innerWidth < window.innerHeight) {
- return
- }
- BasicGame.orientated = false;
- this.game.paused = true;
- document.getElementById('orientation').style.display = 'block'
- },
- leaveIncorrectOrientation: function() {
- if (!orientationGoodAtFirst && !noMoreReload && orientReload && (this.game.state.current == 'state_boot' || this.game.state.current == 'state_preload')) {
- noMoreReload = true;
- orientReload = false;
- location.reload()
- }
- BasicGame.orientated = true;
- this.game.paused = false;
- document.getElementById('orientation').style.display = 'none'
- },
- loadingCompleted: function() {
- this.bootBd.context.fillRect(0, 0, this.bootBd.width * (this.load.progress / 100), 10);
- this.bootBd.dirty = true;
- this.game.state.start('state_preload')
- }
- };
- BasicGame.StatePreload = function() {};
- BasicGame.StatePreload.prototype = {
- preload: function() {
- showBannerAd();
- this.prevLoadPercent = 0;
- this.imgBd = this.add.image(0, 0, 'atlas_preloader', 'preloader_background');
- this.style = {
- font: "65px Arial",
- fill: "#ff0044",
- align: "center"
- };
- this.txtPercent = this.game.add.bitmapText(100, this.game.height / 2 - 45, 'grobold_loading', 'LOADING...');
- this.txtPercent.x = this.world.centerX - this.txtPercent.textWidth / 2;
- this.btnDown = null;
- if (this.game.device.desktop) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.android) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
- } else if (this.game.device.iOS) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.windowsPhone) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
- } else {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 65, 'atlas_preloader', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- }
- this.btnDown.anchor.setTo(0.5, 0.5);
- this.btnDown.scale.set(1.5, 1.5);
- if (this.game.device.desktop) {
- this.btnDown.input.useHandCursor = true
- }
- this.imgPreload = this.make.sprite(0, 0, 'atlas_preloader', 'preload_image');
- this.imgPreloadBD = this.make.bitmapData(this.imgPreload.width / 2, this.imgPreload.height);
- this.imgPreloadBD.addToWorld(this.world.centerX, this.game.height / 2 - 95, 0.5, 1);
- this.copyArea = new Phaser.Rectangle(this.imgPreload.width / 2, 0, this.imgPreload.width / 2, this.imgPreload.height);
- this.imgPreloadBD.copyRect(this.imgPreload, this.copyArea, 0, 0);
- this.game.load.atlas('atlas_menu', 'assets/graphics/menu_assets.png', 'assets/graphics/menu_assets.json');
- this.game.load.atlas('atlas_game', 'assets/graphics/game_assets.png', 'assets/graphics/game_assets.json');
- this.game.load.atlas('atlas_intermenu', 'assets/graphics/intermenu_assets.png', 'assets/graphics/intermenu_assets.json');
- this.game.load.bitmapFont('grobold', 'assets/fonts/grobold_0.png', 'assets/fonts/grobold.fnt');
- this.game.load.tilemap('level_000', 'assets/levels/level_000.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_001', 'assets/levels/level_001.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_002', 'assets/levels/level_002.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_003', 'assets/levels/level_003.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_004', 'assets/levels/level_004.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_005', 'assets/levels/level_005.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_006', 'assets/levels/level_006.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_007', 'assets/levels/level_007.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_008', 'assets/levels/level_008.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_009', 'assets/levels/level_009.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_010', 'assets/levels/level_010.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_011', 'assets/levels/level_011.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_012', 'assets/levels/level_012.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_013', 'assets/levels/level_013.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_014', 'assets/levels/level_014.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_015', 'assets/levels/level_015.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_016', 'assets/levels/level_016.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_017', 'assets/levels/level_017.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_018', 'assets/levels/level_018.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_019', 'assets/levels/level_019.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_020', 'assets/levels/level_020.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_021', 'assets/levels/level_021.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_022', 'assets/levels/level_022.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_023', 'assets/levels/level_023.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_024', 'assets/levels/level_024.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_025', 'assets/levels/level_025.json', null, Phaser.Tilemap.TILED_JSON);
- this.game.load.tilemap('level_026', 'assets/levels/level_026.json', null, Phaser.Tilemap.TILED_JSON);
- var dec = true;
- this.game.load.audio('sndMenuLoop', ['assets/sounds/menu_loop.mp3', 'assets/sounds/menu_loop.ogg']);
- this.game.load.audio('sndGameLoop', ['assets/sounds/game_loop.mp3', 'assets/sounds/game_loop.ogg']);
- this.game.load.audio('sndButtonClick', ['assets/sounds/button_click.mp3', 'assets/sounds/button_click.ogg']);
- this.game.load.audio('sndLevelFail', ['assets/sounds/level_fail.mp3', 'assets/sounds/level_fail.ogg']);
- this.game.load.audio('sndLevelWin', ['assets/sounds/level_win.mp3', 'assets/sounds/level_win.ogg']);
- this.game.load.audio('sndObjectRemove', ['assets/sounds/object_remove.mp3', 'assets/sounds/object_remove.ogg']);
- this.game.load.audio('sndWinStar1', ['assets/sounds/win_star_1.mp3', 'assets/sounds/win_star_1.ogg']);
- this.game.load.audio('sndWinStar2', ['assets/sounds/win_star_2.mp3', 'assets/sounds/win_star_2.ogg']);
- this.game.load.audio('sndWinStar3', ['assets/sounds/win_star_3.mp3', 'assets/sounds/win_star_3.ogg']);
- this.game.load.onFileComplete.add(this.oneFileCompleted, this);
- this.game.load.onLoadComplete.addOnce(this.loadingCompleted, this)
- },
- btnSponsorImgPressed: function() {
- sponsorLinkOpen()
- },
- create: function() {},
- update: function() {
- if (this.prevLoadPercent != this.game.load.progress) {
- this.updatePreloadImage();
- this.prevLoadPercent = this.game.load.progress
- }
- },
- oneFileCompleted: function() {
- if (arguments[1].indexOf('level_') >= 0) {
- var num = parseInt(arguments[1].substring(6), 10);
- var level = this.make.tilemap(arguments[1]);
- BasicGame.Levels[num] = level;
- if (level.properties.star_1 && level.properties.star_2 && level.properties.star_3) {
- BasicGame.LevelStarShots[num] = [parseInt(level.properties.star_3, 10), parseInt(level.properties.star_2, 10), parseInt(level.properties.star_1, 10)]
- } else {
- BasicGame.LevelStarShots[num] = [1, 2, 3]
- }
- }
- this.txtPercent.text = this.load.progress + ' %';
- this.txtPercent.updateText();
- this.txtPercent.x = this.world.centerX - this.txtPercent.textWidth / 2;
- this.updatePreloadImage()
- },
- loadingCompleted: function() {
- BasicGame.sndMenuLoop = new Phaser.Sound(this.game, 'sndMenuLoop', 1, true);
- BasicGame.sndGameLoop = new Phaser.Sound(this.game, 'sndGameLoop', 1, true);
- this.txtPercent.destroy();
- var btnPlayGroup = this.add.group();
- var btnPlay = this.make.button(0, 0, 'atlas_preloader', function() {
- this.btnPlayClicked(false)
- }, this, 'btn_preloader_play', 'btn_preloader_play', 'btn_preloader_play');
- btnPlayGroup.add(btnPlay);
- var btnPlayMutedGroup = this.add.group();
- var btnPlayMuted = this.make.button(0, 0, 'atlas_preloader', function() {
- this.btnPlayClicked(true)
- }, this, 'btn_preloader_play_muted', 'btn_preloader_play_muted', 'btn_preloader_play_muted');
- btnPlayMutedGroup.add(btnPlayMuted);
- btnPlayGroup.x = this.world.centerX - 125;
- btnPlayGroup.y = this.game.height + 100;
- btnPlayMutedGroup.x = this.world.centerX - 125;
- btnPlayMutedGroup.y = this.game.height + 200;
- if (this.game.device.desktop) {
- btnPlay.input.useHandCursor = true;
- btnPlayMuted.input.useHandCursor = true
- }
- var tweenBtnPlay = this.game.add.tween(btnPlayGroup).to({
- y: this.game.height - 200
- }, 700, Phaser.Easing.Cubic.Out, true).start();
- var tweenBtnPlayMuted = this.game.add.tween(btnPlayMutedGroup).to({
- y: this.game.height - 120
- }, 900, Phaser.Easing.Cubic.Out, true).start();
- this.updatePreloadImage()
- },
- updatePreloadImage: function() {
- this.copyArea.x = 0;
- this.copyArea.y = this.imgPreload.height - (this.game.load.progress / 100) * this.imgPreload.height;
- this.copyArea.height = this.imgPreload.height - this.copyArea.y;
- this.imgPreloadBD.copyRect(this.imgPreload, this.copyArea, 0, this.copyArea.y)
- },
- btnPlayClicked: function(muted) {
- if (this.game.device.windowsPhone) {
- GC.soundDisabled = true
- }
- this.game.sound.mute = muted;
- GC.playSound = !muted;
- this.state.start(BasicGame.stateFirst)
- },
- loadTimerCompleted: function() {},
- shutdown: function() {
- this.imgPreload = null;
- this.imgPreloadBD = null;
- this.copyArea = null;
- this.btnPlay = null;
- this.btnPLayMuted = null;
- 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.state = null;
- this.stage = null;
- this.time = null;
- this.tweens = null;
- this.world = null;
- this.particles = null;
- this.rnd = null;
- this.physics = null
- }
- };
- BasicGame.StateMenu = function() {};
- BasicGame.StateMenu.prototype = {
- initVars: function(game) {
- this.game = game;
- this.currentChapter = 0;
- this.totalChapters = Math.ceil(GC.totalLevels / 9);
- this.pnlInfoIn = false;
- this.pressable = false
- },
- preload: function() {
- this.pressable = true;
- this.pnlInfoIn = false;
- this.soundOnImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_sound_on'];
- this.soundOffImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_sound_off'];
- this.fullscreenEnterImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_fullscreen_enter'];
- this.fullscreenLeaveImage = this.game.cache._images['atlas_menu'].frameData._frameNames['btn_fullscreen_leave']
- },
- create: function() {
- showBannerAd();
- if (GC.FullScreenEnabled) {
- if (!this.game.device.desktop) {
- this.input.touch.preventDefault = false
- }
- if (this.game.canvas.addEventListener) {
- document.getElementById('gameContainer').addEventListener('click', menuClickedFullscreenCheck, false)
- } else {
- document.getElementById('gameContainer').attachEvent('onclick', menuClickedFullscreenCheck)
- }
- }
- if (!BasicGame.sndMenuLoop.isPlaying) {
- BasicGame.sndMenuLoop.play('', 0, (GC.playSound ? 1 : 0), true)
- }
- this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
- this.imgBg = this.game.add.sprite(0, 0, 'atlas_menu', 'menu_background');
- this.tileCloud = this.game.add.tileSprite(0, 50, this.game.width, 85, 'atlas_menu', 'cloud');
- this.tileCloud.autoScroll(-15, 0);
- this.imgLogo = this.game.add.sprite(this.game.world.centerX, 200, 'atlas_menu', 'main_logo');
- this.imgLogo.anchor.setTo(0.5, 1);
- this.btnPlay = this.game.add.button(this.game.world.centerX, 340, 'atlas_menu', this.btnPlayClicked, this, 'btn_play', 'btn_play', 'btn_play');
- this.btnPlay.anchor.setTo(0.5, 0.5);
- 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');
- this.btnSound.anchor.setTo(0.5, 0.5);
- this.btnSound.x += this.btnSound.width / 2;
- this.btnSound.y -= this.btnSound.height / 2;
- if (this.game.sound.mute) {
- this.btnSound.frame = this.soundOffImage
- }
- 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');
- this.btnInfo.anchor.setTo(0.5, 0.5);
- this.btnInfo.y -= this.btnInfo.height / 2;
- if (GC.FullScreenEnabled) {
- 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');
- this.btnFullscreen.anchor.setTo(0.5, 0.5);
- this.btnFullscreen.x -= this.btnFullscreen.width / 2;
- this.btnFullscreen.y -= this.btnFullscreen.height / 2;
- if (this.scale.isFullscreen) {
- this.btnFullscreen.frame = this.fullscreenLeaveImage
- }
- } else {
- this.btnInfo.x = this.game.width - this.btnInfo.width / 2 - 15
- }
- this.btnDown = null;
- if (this.game.device.desktop) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.android) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
- } else if (this.game.device.iOS) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.windowsPhone) {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
- } else {
- this.btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 150, 'atlas_menu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- }
- this.btnDown.anchor.setTo(0.5, 0.5);
- this.blackBg = this.make.tileSprite(0, 0, this.game.width, this.game.height, 'atlas_menu', 'black_bg');
- this.pnlInfo = this.make.sprite(0, 0, 'atlas_menu', 'panel_info');
- this.pnlInfo.anchor.setTo(0.5, 0.5);
- this.pnlInfo.alpha = 0;
- this.pnlInfo.x = this.world.centerX;
- this.input.onTap.add(this.tappedCallback, this);
- this.imgLogo.scale.setTo(0.4, 0.4);
- this.imgLogo.visible = false;
- this.btnPlay.y = this.game.height + 150;
- this.btnSound.y = this.game.height + 100;
- this.btnInfo.y = this.game.height + 100;
- this.btnDown.y = this.game.height + 100;
- if (GC.FullScreenEnabled) {
- this.btnFullscreen.y = this.game.height + 100
- }
- if (this.game.device.desktop) {
- this.btnPlay.input.useHandCursor = true;
- this.btnInfo.input.useHandCursor = true;
- this.btnSound.input.useHandCursor = true;
- if (GC.FullScreenEnabled) {
- this.btnFullscreen.input.useHandCursor = true
- }
- this.btnDown.input.useHandCursor = true
- }
- if (BasicGame.previewMode) {
- var tomb = [78, 79, 84, 32, 70, 79, 82, 32, 80, 85, 66, 76, 73, 67, 32, 85, 83, 69, 33];
- var vizjel = '';
- for (var z = tomb.length - 1; z >= 0; z--) {
- vizjel = String.fromCharCode(tomb[z]) + vizjel
- }
- var v = this.add.bitmapText(3, 3, 'grobold', vizjel);
- v.alpha = 0.35;
- v.fontSize = 24
- }
- this.game.world.alpha = 0;
- this.tweenFadeIn = this.game.add.tween(this.game.world).to({
- alpha: 1
- }, 500, Phaser.Easing.Quadratic.In, true);
- this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
- this.tweenFadeIn.start()
- },
- btnSponsorImgPressed: function() {
- if (this.pressable) {
- sponsorLinkOpen()
- }
- },
- fadeInCompleted: function() {
- this.pressable = true;
- this.game.time.events.add(Phaser.Timer.SECOND / 3, this.beginMenuInAnimation, this)
- },
- beginMenuInAnimation: function() {
- this.imgLogo.visible = true;
- this.tweenLogo = this.game.add.tween(this.imgLogo.scale).to({
- x: 1,
- y: 1
- }, 400, Phaser.Easing.Back.Out, true);
- this.tweenLogo.onComplete.addOnce(this.tweenLogoInCompleted, this);
- this.tweenLogo.start()
- },
- tweenLogoInCompleted: function() {
- this.tweenBtnPlay = this.game.add.tween(this.btnPlay).to({
- y: 350
- }, 400, Phaser.Easing.Cubic.Out, true);
- this.tweenBtnPlay.onComplete.addOnce(this.tweenBtnPlayCompleted, this);
- this.tweenBtnPlay.start()
- },
- tweenBtnPlayCompleted: function() {
- this.tweenBtnSound = this.game.add.tween(this.btnSound).to({
- y: this.game.height - 55 - this.btnSound.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true);
- this.tweenBtnInfo = this.game.add.tween(this.btnInfo).to({
- y: this.game.height - 55 - this.btnInfo.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true);
- this.tweenBtnDown = this.game.add.tween(this.btnDown).to({
- y: this.game.height / 2 + 150
- }, 350, Phaser.Easing.Cubic.Out, true);
- if (GC.FullScreenEnabled) {
- this.tweenBtnFullscreen = this.game.add.tween(this.btnFullscreen).to({
- y: this.game.height - 50 - this.btnFullscreen.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true)
- }
- },
- update: function() {},
- tappedCallback: function() {
- this.removeInfoPanel()
- },
- removeInfoPanel: function() {
- if (this.pnlInfoIn) {
- this.btnDown.visible = true;
- this.world.remove(this.blackBg);
- this.pnlInfoIn = false;
- this.add.tween(this.pnlInfo).to({
- y: this.world.centerY + 50
- }, 200, Phaser.Easing.Quadratic.In, true).onComplete.addOnce(this.removeInfoPanelCompleted, this);
- this.add.tween(this.pnlInfo).to({
- alpha: 0
- }, 200, Phaser.Easing.Quadratic.In, true)
- }
- },
- removeInfoPanelCompleted: function() {
- this.world.remove(this.pnlInfo, false, true);
- this.pnlInfoIn = false;
- this.pressable = true
- },
- btnInfoClicked: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnDown.visible = false;
- this.add.tween(this.btnInfo.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.world.add(this.blackBg);
- this.pnlInfoIn = true;
- this.pressable = false;
- this.world.add(this.pnlInfo);
- this.pnlInfo.alpha = 0;
- this.pnlInfo.y = this.world.centerY + 50;
- this.add.tween(this.pnlInfo).to({
- y: this.world.centerY
- }, 300, Phaser.Easing.Quadratic.Out, true);
- this.add.tween(this.pnlInfo).to({
- alpha: 1
- }, 300, Phaser.Easing.Quadratic.Out, true)
- }
- },
- btnFullscreenPressed: function() {
- if (!this.pressable) {
- return
- }
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- },
- refreshFullscreenUi: function() {
- if (GC.FullScreenEnabled) {
- if (screenfull.isFullscreen) {
- this.btnFullscreen.frame = this.fullscreenLeaveImage
- } else {
- this.btnFullscreen.frame = this.fullscreenEnterImage
- }
- }
- },
- btnPlayClicked: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnPlay.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 700, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutToLevelSelect, this);
- this.tweenFadeOut.start()
- }
- },
- btnSoundClicked: function() {
- if (!this.pressable) {
- return
- }
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnSound.scale.x = this.btnSound.scale.y = 1;
- this.add.tween(this.btnSound.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.game.sound.mute = !this.game.sound.mute;
- GC.playSound = !this.game.sound.mute;
- if (this.game.sound.mute) {
- this.btnSound.frame = this.soundOffImage
- } else {
- this.btnSound.frame = this.soundOnImage
- }
- if (BasicGame.sndMenuLoop.isPlaying) {
- BasicGame.sndMenuLoop.volume = (GC.playSound ? 1 : 0)
- }
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.volume = (GC.playSound ? 1 : 0)
- }
- },
- fadeOutToLevelSelect: function() {
- this.game.state.start('state_level_select')
- },
- shutdown: function() {
- if (GC.FullScreenEnabled) {
- if (this.game.canvas.addEventListener) {
- document.getElementById('gameContainer').removeEventListener('click', menuClickedFullscreenCheck)
- } else {
- document.getElementById('gameContainer').detachEvent('onclick', menuClickedFullscreenCheck)
- }
- }
- this.soundClick.destroy(true);
- this.btnPlay = null;
- this.btnInfo = null;
- this.pnlInfo = null;
- this.btnSound = null;
- this.imgBg = null;
- this.imgLogo = null
- }
- };
- BasicGame.StateLevelSelect = function() {};
- BasicGame.StateLevelSelect.prototype = {
- initVars: function(game) {
- this.game = game;
- this.currentChapter = 0;
- this.totalChapters = Math.ceil(GC.totalLevels / 9);
- this.pressable = false
- },
- preload: function() {},
- create: function() {
- hideBannerAd();
- if (!BasicGame.sndMenuLoop.isPlaying) {
- BasicGame.sndMenuLoop.play('', 0, (GC.playSound ? 1 : 0), true)
- }
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.stop()
- }
- this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
- this.pressable = false;
- this.currentChapter = Math.floor(BasicGame.currentLevel / 9);
- this.imgBg = this.game.add.sprite(0, 0, 'atlas_menu', 'menu_background');
- this.tileCloud = this.game.add.tileSprite(0, 50, this.game.width, 85, 'atlas_menu', 'cloud');
- this.tileCloud.autoScroll(-15, 0);
- this.groupLogo = this.add.group();
- this.imgLogo = this.game.make.sprite(0, 0, 'atlas_menu', 'level_select_logo');
- this.txtLogo = this.make.bitmapText(0, 0, 'grobold', '选择关卡');
- this.txtLogo.scale.setTo(1.3, 1.3);
- this.txtLogo.x = this.imgLogo.width / 2 - this.txtLogo.width / 2;
- this.txtLogo.y = 5;
- this.groupLogo.add(this.imgLogo);
- this.groupLogo.add(this.txtLogo);
- this.groupLogo.x = this.game.width / 2 - this.imgLogo.width / 2;
- this.groupLogo.y = 50;
- this.btnBack = this.game.add.button(this.world.centerX, this.game.height - 20, 'atlas_menu', this.btnBackClicked, this, 'btn_home', 'btn_home', 'btn_home');
- this.btnBack.anchor.setTo(0.5, 0.5);
- this.btnBack.y -= this.btnBack.height / 2;
- 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');
- this.btnPreviousChapter.anchor.setTo(0.5, 0.5);
- this.btnPreviousChapter.x += this.btnPreviousChapter.width / 2;
- this.btnPreviousChapter.y -= this.btnPreviousChapter.height / 2;
- 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');
- this.btnNextChapter.anchor.setTo(0.5, 0.5);
- this.btnNextChapter.x -= this.btnNextChapter.width / 2;
- this.btnNextChapter.y -= this.btnNextChapter.height / 2;
- this.btnGroupAll = this.add.group();
- this.btnsLevel = [];
- var count = 0;
- var btn;
- var txt;
- var st1;
- var st2;
- var st3;
- var closedSign;
- var currLevel = 0;
- for (var i = 0; i < 3; i++) {
- for (var j = 0; j < 3; j++) {
- if (count < GC.totalLevels) {
- currLevel = (this.currentChapter * 9) + count;
- this.btnsLevel[count] = this.add.group();
- btn = this.make.button(0, 0, 'atlas_menu', this.btnLevelClicked, this, 'btn_level', 'btn_level', 'btn_level');
- if (this.game.device.desktop) {
- btn.input.useHandCursor = true
- }
- btn.anchor.setTo(0.5, 0.5);
- btn.x += btn.width / 2;
- btn.y += btn.height / 2;
- btn.name = count.toString();
- txt = this.make.bitmapText(10, 7, 'grobold', (currLevel + 1).toString());
- txt.x = btn.width / 2 - txt.textWidth / 2;
- st1 = this.make.image(5, 40, 'atlas_menu', 'star_levelselect');
- st2 = this.make.image(27, 40, 'atlas_menu', 'star_levelselect');
- st3 = this.make.image(49, 40, 'atlas_menu', 'star_levelselect');
- closedSign = this.make.image(0, 0, 'atlas_menu', 'btn_level_disabled_overlay');
- closedSign.anchor.setTo(0.5, 0.5);
- closedSign.x += closedSign.width / 2;
- closedSign.y += closedSign.height / 2;
- this.btnsLevel[count].add(btn);
- this.btnsLevel[count].add(st1);
- this.btnsLevel[count].add(st2);
- this.btnsLevel[count].add(st3);
- this.btnsLevel[count].add(txt);
- this.btnsLevel[count].add(closedSign);
- this.btnsLevel[count].x = 75 + j * 123;
- this.btnsLevel[count].y = 175 + i * 125;
- this.btnGroupAll.add(this.btnsLevel[count]);
- if (currLevel >= GC.totalLevels) {
- this.btnsLevel[count].visible = false
- } else {
- if (BasicGame.LevelsOpen[currLevel] == 1) {
- closedSign.visible = false
- }
- st1.visible = st2.visible = st3.visible = false;
- switch (BasicGame.LevelStars[currLevel]) {
- case 1:
- st1.visible = true;
- break;
- case 2:
- st1.visible = st2.visible = true;
- break;
- case 3:
- st1.visible = st2.visible = st3.visible = true;
- break
- }
- }
- }
- count++
- }
- }
- this.checkChaptering();
- if (BasicGame.previewMode) {
- this.btnOpenAll = this.add.button(0, 0, 'atlas_menu', this.btnOpenAllPressed, this, 'btn_open_all', 'btn_open_all', 'btn_open_all');
- this.btnClearAll = this.add.button(this.game.width, 0, 'atlas_menu', this.btnClearAllPressed, this, 'btn_clear_all', 'btn_clear_all', 'btn_clear_all');
- this.btnClearAll.anchor.setTo(1, 0)
- }
- this.btnGroupAll.x = 0;
- this.btnGroupAll.y = this.game.height + 100;
- this.groupLogo.y = -100;
- this.btnBack.y = this.game.height + 150;
- this.btnPreviousChapter.y = this.game.height + 150;
- this.btnNextChapter.y = this.game.height + 150;
- if (this.game.device.desktop) {
- this.btnPreviousChapter.input.useHandCursor = true;
- this.btnNextChapter.input.useHandCursor = true;
- this.btnBack.input.useHandCursor = true
- }
- this.game.world.alpha = 0;
- this.tweenFadeIn = this.game.add.tween(this.game.world).to({
- alpha: 1
- }, 500, Phaser.Easing.Quadratic.In, true);
- this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
- this.tweenFadeIn.start()
- },
- btnOpenAllPressed: function() {
- if (!this.pressable) {
- return
- }
- BasicGame.openAllLevels();
- this.checkChaptering();
- this.checkLevelButtonsChapter()
- },
- btnClearAllPressed: function() {
- if (!this.pressable) {
- return
- }
- BasicGame.clearAllData();
- this.checkChaptering();
- this.checkLevelButtonsChapter()
- },
- btnLevelClicked: function(button) {
- var currLevel = (this.currentChapter * 9 + parseInt(button.name, 10));
- if (this.pressable && BasicGame.LevelsOpen[currLevel] == 1) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(button.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- BasicGame.currentLevel = currLevel;
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 500, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutToGame, this);
- this.tweenFadeOut.start()
- }
- },
- fadeInCompleted: function() {
- this.game.time.events.add(Phaser.Timer.SECOND / 2, this.beginLogoInAnimation, this)
- },
- beginLogoInAnimation: function() {
- this.tweenLogo = this.game.add.tween(this.groupLogo).to({
- y: 50
- }, 300, Phaser.Easing.Back.Out, true);
- this.tweenLogo.onComplete.addOnce(this.tweenLevelButtons, this);
- this.tweenLogo.start()
- },
- tweenLevelButtons: function() {
- this.tweenLevelIn = this.game.add.tween(this.btnGroupAll).to({
- y: 0
- }, 500, Phaser.Easing.Cubic.Out, true, 100);
- this.tweenLevelIn.onComplete.addOnce(this.tweenMenuButtons, this)
- },
- tweenMenuButtons: function() {
- this.tweenBtnBack = this.game.add.tween(this.btnBack).to({
- y: this.game.height - 20 - this.btnBack.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true);
- this.tweenBtnPreviousChapter = this.game.add.tween(this.btnPreviousChapter).to({
- y: this.game.height - 20 - this.btnPreviousChapter.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true);
- this.tweenBtnNextChapter = this.game.add.tween(this.btnNextChapter).to({
- y: this.game.height - 20 - this.btnNextChapter.height / 2
- }, 350, Phaser.Easing.Cubic.Out, true);
- this.pressable = true
- },
- update: function() {},
- btnPreviousChapterPressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnPreviousChapter.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.currentChapter--;
- this.checkChaptering();
- this.tweenOutLevelButtons('right')
- }
- },
- btnNextChapterPressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnNextChapter.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.currentChapter++;
- this.checkChaptering();
- this.tweenOutLevelButtons('left')
- }
- },
- tweenOutLevelButtons: function(direction) {
- var xAdd = (direction == 'left' ? -this.game.width - 200 : this.game.width + 200);
- this.add.tween(this.btnGroupAll).to({
- x: xAdd
- }, 500, Phaser.Easing.Cubic.In, true).onComplete.addOnce(function() {
- this.tweenInLevelButtons(direction)
- }, this)
- },
- tweenInLevelButtons: function(direction) {
- this.checkLevelButtonsChapter();
- this.btnGroupAll.x = (direction == 'left' ? this.game.width + 200 : -this.game.width - 200);
- this.add.tween(this.btnGroupAll).to({
- x: 0
- }, 500, Phaser.Easing.Cubic.Out, true).onComplete.addOnce(this.enablePressing, this)
- },
- enablePressing: function() {
- this.pressable = true
- },
- checkChaptering: function() {
- if (this.currentChapter < 0) {
- this.currentChapter = 0
- }
- if (this.currentChapter > this.totalChapters - 1) {
- this.currentChapter = this.totalChapters - 1
- }
- if (this.currentChapter == 0) {
- this.btnPreviousChapter.visible = false
- } else {
- this.btnPreviousChapter.visible = true
- }
- if (this.currentChapter == this.totalChapters - 1) {
- this.btnNextChapter.visible = false
- } else {
- this.btnNextChapter.visible = true
- }
- },
- checkLevelButtonsChapter: function() {
- var count = 0;
- var elem;
- var st1;
- var st2;
- var st3;
- var closedSign;
- var currLevel = 0;
- for (var i = 0; i < 3; i++) {
- for (var j = 0; j < 3; j++) {
- currLevel = (this.currentChapter * 9) + count;
- if (currLevel < GC.totalLevels) {
- this.btnsLevel[count].visible = true;
- elem = this.btnsLevel[count].getAt(4);
- elem.text = (currLevel + 1).toString();
- elem.updateText();
- elem.x = 84 / 2 - elem.textWidth / 2;
- st1 = this.btnsLevel[count].getAt(1);
- st2 = this.btnsLevel[count].getAt(2);
- st3 = this.btnsLevel[count].getAt(3);
- closedSign = this.btnsLevel[count].getAt(5);
- st1.visible = st2.visible = st3.visible = false;
- switch (BasicGame.LevelStars[currLevel]) {
- case 1:
- st1.visible = true;
- break;
- case 2:
- st1.visible = st2.visible = true;
- break;
- case 3:
- st1.visible = st2.visible = st3.visible = true;
- break
- }
- closedSign.visible = (BasicGame.LevelsOpen[currLevel] == 0 ? true : false)
- } else {
- this.btnsLevel[count].visible = false
- }
- count++
- }
- }
- },
- btnBackClicked: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnBack.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 500, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutToMenu, this);
- this.tweenFadeOut.start()
- }
- },
- fadeOutToGame: function() {
- this.game.state.start('state_game')
- },
- fadeOutToMenu: function() {
- this.game.state.start('state_menu')
- },
- shutdown: function() {
- this.soundClick.destroy(true);
- this.btnGroupAll.destroy(true, false);
- this.btnBack = null;
- this.btnPreviousChapter = null;
- this.btnNextChapter = null;
- this.imgBg = null;
- this.imgLogo = null
- }
- };
- BasicGame.StateGame = function() {};
- BasicGame.StateGame.prototype = {
- initVars: function(game) {
- this.game = game;
- this.currentMap = null
- },
- preload: function() {
- this.pressable = false;
- this.paused = false;
- this.fadeOutState = 'state_menu';
- this.currentMap = null;
- this.currentLevel = 0;
- this.objectsWood = [];
- this.objectsStone = [];
- this.objectsGood = [];
- this.objectsBad = [];
- this.objectsGoal = [];
- this.tutorialSpot = null;
- this.tutorialFinger = null;
- this.tutorialTween = null;
- this.objectRemoveCount = 0;
- this.pivotJointNameList = [];
- this.levelAtlas = 'atlas_game';
- this.levelAtlasPrefix = 'l_'
- },
- create: function() {
- showBannerAd();
- this.levelAtlas = 'atlas_game';
- this.levelAtlasPrefix = 'l_' + String(BasicGame.currentLevel) + '_';
- if (BasicGame.sndMenuLoop.isPlaying) {
- BasicGame.sndMenuLoop.stop()
- }
- if (!BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.play('', 0, (GC.playSound ? 1 : 0), true)
- }
- this.currentLevel = BasicGame.currentLevel;
- BasicGame.winStarsPrevious = BasicGame.LevelStars[this.currentLevel];
- this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
- this.soundWin = this.game.add.audio('sndLevelWin', 1, false);
- this.soundFail = this.game.add.audio('sndLevelFail', 1, false);
- this.soundObjectRemove = this.game.add.audio('sndObjectRemove', 1, false);
- this.game.physics.startSystem(Phaser.Physics.P2JS);
- this.game.physics.p2.gravity.y = 300;
- this.game.physics.p2.world.defaultContactMaterial.friction = 1;
- this.imgBg = this.game.add.image(0, 0, this.levelAtlas, 'game_background');
- this.tileCloud = this.game.add.tileSprite(0, 90, this.game.width, 85, this.levelAtlas, 'cloud');
- this.tileCloud.autoScroll(-15, 0);
- this.ground = this.game.add.sprite(0, 200, this.levelAtlas, 'ground');
- this.game.physics.p2.enable([this.ground], false);
- this.ground.body.static = true;
- this.ground.body.clearShapes();
- this.ground.body.addPolygon({
- optimalDecomp: false,
- skipSimpleCheck: true,
- removeCollinearPoints: false
- }, [
- [0, 0],
- [630, 0],
- [630, 80],
- [0, 80]
- ]);
- this.ground.body.x = this.world.centerX;
- this.ground.body.y = this.game.height - this.ground.height / 2;
- this.loadLevel(BasicGame.currentLevel);
- this.btnPause = this.game.add.button(this.game.width - 20, 45, this.levelAtlas, this.btnPausePressed, this, 'btn_pause', 'btn_pause', 'btn_pause');
- this.btnPause.anchor.setTo(1, 0);
- this.btnRestart = this.game.add.button(20, 45, this.levelAtlas, this.btnRestartPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
- this.btnRestart.anchor.setTo(0, 0);
- this.imgStarUi3 = this.add.image(0, this.game.height - 80 - 22, this.levelAtlas, 'star_ui_1');
- this.imgStarUi2 = this.add.image(0, this.imgStarUi3.y - 22, this.levelAtlas, 'star_ui_2');
- this.imgStarUi1 = this.add.image(0, this.imgStarUi2.y - 22, this.levelAtlas, 'star_ui_3');
- var strStarsEarn = BasicGame.LevelStarShots[this.currentLevel][0] + '\n' + BasicGame.LevelStarShots[this.currentLevel][1] + '\n' + BasicGame.LevelStarShots[this.currentLevel][2];
- this.txtStarsEarn = this.game.add.bitmapText(this.imgStarUi1.x + this.imgStarUi1.width, this.imgStarUi1.y, 'grobold', strStarsEarn);
- this.txtStarsEarn.scale.setTo(0.65, 0.65);
- this.txtStarsEarn.align = 'left';
- if (BasicGame.previewMode) {
- var tomb = [78, 79, 84, 32, 70, 79, 82, 32, 80, 85, 66, 76, 73, 67, 32, 85, 83, 69, 33];
- var vizjel = '';
- for (var z = tomb.length - 1; z >= 0; z--) {
- vizjel = String.fromCharCode(tomb[z]) + vizjel
- }
- var v = this.add.bitmapText(3, 3, 'grobold', vizjel);
- v.alpha = 0.35;
- v.fontSize = 24
- }
- this.txtLevel = this.game.add.bitmapText(this.game.width / 2, 10, 'grobold', '关卡: ' + (BasicGame.currentLevel + 1).toString());
- this.txtLevel.x -= (this.txtLevel.textWidth / 2);
- if (this.game.device.desktop) {
- var btnDown = this.add.button(this.game.width / 2, this.game.height - 10, this.levelAtlas, btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download');
- btnDown.anchor.setTo(0.5, 1);
- btnDown.input.useHandCursor = true
- }
- if (this.game.device.desktop) {
- this.btnPause.input.useHandCursor = true;
- this.btnRestart.input.useHandCursor = true;
- }
- this.pnlPause = new BasicGame.PanelPause(this.game, 0, 0, this.unpause, this);
- this.pnlPause.visible = false;
- this.game.world.alpha = 0;
- this.tweenFadeIn = this.game.add.tween(this.game.world).to({
- alpha: 1
- }, 500, Phaser.Easing.Quadratic.In, true);
- this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
- this.tweenFadeIn.start();
- this.game.input.onDown.add(this.tappedCallback, this);
- this.physics.p2.onBeginContact.add(this.bodiesCollide, this)
- },
- btnSponsorImgPressed: function() {
- if (this.pressable) {
- sponsorLinkOpen()
- }
- },
- removeGood: function(bodyGood) {
- for (var j = this.objectsGood.length - 1; j >= 0; j--) {
- if (this.objectsGood[j].body.id == bodyGood.id) {
- splice1(this.objectsGood, j);
- break
- }
- }
- bodyGood.parent.sprite.destroy()
- },
- bodiesCollide: function(bodyA, bodyB, shapeA, shapeB, contactEquations) {
- var i = 0;
- for (i = this.objectsGood.length - 1; i >= 0; i--) {
- if (this.objectsGood[i].body.id == bodyA.id) {
- if (this.solveForGood(bodyA, bodyB)) {
- this.removeGood(bodyA);
- if (this.objectsGood.length == 0) {
- this.levelWin()
- }
- }
- return
- }
- }
- for (i = this.objectsBad.length - 1; i >= 0; i--) {
- if (this.objectsBad[i].body.id == bodyA.id) {
- this.solveForBad(bodyA, bodyB);
- return
- }
- }
- for (i = this.objectsGoal.length - 1; i >= 0; i--) {
- if (this.objectsGoal[i].body.id == bodyA.id) {
- this.solveForGoal(bodyA, bodyB);
- return
- }
- }
- },
- solveForGood: function(bodyGood, bodyOther) {
- if (!this.pressable) {
- return
- }
- var i = 0;
- for (i = this.objectsBad.length - 1; i >= 0; i--) {
- if (this.objectsBad[i].body.id == bodyOther.id) {
- if (bodyGood.parent.sprite.frameName.indexOf('circle') > 0) {
- bodyGood.parent.sprite.frameName = 'good_circle_lose'
- } else {
- bodyGood.parent.sprite.frameName = 'good_rect_lose'
- }
- this.levelLose();
- return false
- }
- }
- for (i = this.objectsGoal.length - 1; i >= 0; i--) {
- if (this.objectsGoal[i].body.id == bodyOther.id) {
- bodyOther.parent.sprite.animations.play('filled');
- return true
- }
- }
- return false
- },
- solveForBad: function(bodyBad, bodyOther) {
- if (!this.pressable) {
- return
- }
- var i = 0;
- for (i = this.objectsGood.length - 1; i >= 0; i--) {
- if (this.objectsGood[i].body.id == bodyOther.id) {
- if (bodyOther.parent.sprite.frameName.indexOf('circle') > 0) {
- bodyOther.parent.sprite.frameName = 'good_circle_lose'
- } else {
- bodyOther.parent.sprite.frameName = 'good_rect_lose'
- }
- this.levelLose();
- return
- }
- }
- for (i = this.objectsGoal.length - 1; i >= 0; i--) {
- if (this.objectsGoal[i].body.id == bodyOther.id) {
- this.levelLose();
- return
- }
- }
- },
- solveForGoal: function(bodyGoal, bodyOther) {
- if (!this.pressable) {
- return
- }
- var i = 0;
- for (i = this.objectsGood.length - 1; i >= 0; i--) {
- if (this.objectsGood[i].body.id == bodyOther.id) {
- bodyGoal.parent.sprite.animations.play('filled');
- this.removeGood(bodyOther);
- if (this.objectsGood.length == 0) {
- this.levelWin()
- }
- return
- }
- }
- for (i = this.objectsBad.length - 1; i >= 0; i--) {
- if (this.objectsBad[i].body.id == bodyOther.id) {
- this.levelLose();
- return
- }
- }
- },
- tappedCallback: function(pointer) {
- if (!this.pressable || this.paused || this.objectsWood.length <= 0) {
- return
- }
- var bodies = this.physics.p2.hitTest(pointer.position, this.objectsWood);
- if (bodies.length > 0) {
- for (var j = this.objectsWood.length - 1; j >= 0; j--) {
- if (this.objectsWood[j].body.id == bodies[0].id) {
- splice1(this.objectsWood, j);
- this.objectRemoveCount++;
- var strStarsEarnable = '';
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][0]) {
- this.imgStarUi1.visible = false
- } else {
- strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][0] - this.objectRemoveCount)
- }
- strStarsEarnable += '\n';
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][1]) {
- this.imgStarUi2.visible = false
- } else {
- strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][1] - this.objectRemoveCount)
- }
- strStarsEarnable += '\n';
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][2]) {
- this.imgStarUi3.visible = false
- } else {
- strStarsEarnable += String(BasicGame.LevelStarShots[this.currentLevel][2] - this.objectRemoveCount)
- }
- this.txtStarsEarn.text = strStarsEarnable;
- if (this.tutorialFinger != null) {
- this.tutorialFinger.destroy();
- this.tutorialFinger = null
- }
- if (this.tutorialSpot != null) {
- this.tutorialSpot.destroy();
- this.tutorialSpot = null
- }
- if (this.tutorialTween != null) {
- this.tutorialTween.stop();
- this.tutorialTween = null
- }
- if (!GC.soundDisabled) {
- this.soundObjectRemove.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- break
- }
- }
- var indexOfJoint = this.pivotJointNameList.indexOf(bodies[0].parent.sprite.name);
- if (indexOfJoint >= 0) {
- this.removeWitnName(bodies[0].parent.sprite.name + '_pivot');
- splice1(this.pivotJointNameList, indexOfJoint)
- }
- bodies[0].parent.sprite.destroy()
- }
- },
- removeWitnName: function(name) {
- for (var i = this.world.children.length - 1; i >= 0; i--) {
- if (this.world.children[i].name == name) {
- this.world.children[i].destroy();
- return
- }
- }
- },
- setPaused: function(value) {
- this.paused = value;
- this.physics.p2.paused = this.paused
- },
- loadLevel: function(levelNum) {
- if (BasicGame.Levels[levelNum] == undefined) {
- return
- }
- this.currentMap = BasicGame.Levels[levelNum];
- var obj;
- var b;
- var spr;
- var i = 0;
- var j = 0;
- for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
- obj = this.currentMap.objects['objects'][i];
- if (obj.type == 'goal') {
- spr = this.addGoalObject(obj);
- this.objectsGoal[this.objectsGoal.length] = spr
- }
- }
- for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
- obj = this.currentMap.objects['objects'][i];
- spr = null;
- if (obj.type == 'good') {
- spr = this.addGoodObject(obj);
- this.objectsGood[this.objectsGood.length] = spr
- } else if (obj.type == 'bad') {
- spr = this.addBadObject(obj);
- this.objectsBad[this.objectsBad.length] = spr
- } else if (obj.type == 'wood') {
- spr = this.addWoodObject(obj);
- this.objectsWood[this.objectsWood.length] = spr
- } else if (obj.type == 'stone') {
- spr = this.addStoneObject(obj);
- this.objectsStone[this.objectsStone.length] = spr
- }
- if (spr == null) {
- continue
- }
- if (obj.name) {
- spr.name = obj.name
- }
- if (obj.properties) {
- if (obj.properties.offsetX) spr.body.x += Number(obj.properties.offsetX);
- if (obj.properties.offsetY) spr.body.y += Number(obj.properties.offsetY);
- if (obj.properties.rotation) spr.body.angle = Number(obj.properties.rotation);
- spr.body.data.updateAABB()
- }
- }
- spr = null;
- for (i = this.currentMap.objects['objects'].length - 1; i >= 0; i--) {
- obj = this.currentMap.objects['objects'][i];
- if (obj.type == 'tutorial') {
- if (obj.name == 'pointer') {
- this.tutorialSpot = this.add.sprite(obj.x + 10, obj.y, this.levelAtlas, 'tutorial_spot');
- this.tutorialSpot.anchor.setTo(0.5, 0.5);
- this.tutorialSpot.alpha = 0;
- spr = this.add.sprite(obj.x + 20, obj.y + 75, this.levelAtlas, 'tutorial_pointer');
- this.tutorialFinger = spr;
- spr.angle = -20;
- spr.name = String(obj.x - 20);
- this.tutorialTween = this.add.tween(spr).to({
- x: obj.x - 20,
- y: obj.y
- }, 1500, Phaser.Easing.Quadratic.Out, true, 0, Number.MAX_VALUE, true);
- this.tutorialTween.onLoop.add(this.tutorialFingerFinished, this)
- } else {
- spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'tutorial_' + obj.name);
- spr.anchor.setTo(0.5, 0.5)
- }
- } else if (obj.type == 'pivot_joint') {
- if (obj.properties.object == '' || obj.properties.object == undefined) {
- continue
- }
- for (j = this.world.children.length - 1; j >= 0; j--) {
- if (obj.properties.object == this.world.children[j].name) {
- this.addPivotJointToSprite(obj, this.world.children[j]);
- break
- }
- }
- }
- }
- },
- addPivotJointToSprite: function(obj, spr) {
- var sprPivot = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'pivot_joint');
- sprPivot.anchor.setTo(0.5, 0.5);
- sprPivot.name = spr.name + '_pivot';
- this.physics.p2.enableBody(sprPivot, BasicGame.debugPhysics);
- sprPivot.body.mass = 1;
- sprPivot.body.static = true;
- sprPivot.body.x = obj.x;
- sprPivot.body.y = obj.y;
- var physicsPos = [this.physics.p2.pxmi(obj.x), this.physics.p2.pxmi(obj.y)];
- var localPointInBody = [0, 0];
- spr.body.toLocalFrame(localPointInBody, physicsPos);
- var constraint = this.game.physics.p2.createRevoluteConstraint(sprPivot, [0, 0], spr.body, [this.physics.p2.mpxi(localPointInBody[0]), this.physics.p2.mpxi(localPointInBody[1])]);
- constraint.collideConnected = false;
- this.pivotJointNameList[this.pivotJointNameList.length] = spr.name;
- if (obj.properties.motor) {
- constraint.enableMotor();
- constraint.setMotorSpeed(parseFloat(obj.properties.motor))
- }
- },
- tutorialFingerFinished: function() {
- if (String(arguments[0].x) == arguments[0].name) {
- if (this.tutorialSpot != null) {
- this.tutorialSpot.alpha = 1;
- this.tutorialSpot.scale.x = this.tutorialSpot.scale.y = 0.6;
- this.add.tween(this.tutorialSpot.scale).to({
- x: 1.5,
- y: 1.5
- }, 700, Phaser.Easing.Cubic.Out, true, 0, 0, false);
- this.add.tween(this.tutorialSpot).to({
- alpha: 0
- }, 1000, Phaser.Easing.Cubic.Out, true, 0, 0, false)
- }
- }
- },
- addGoodObject: function(obj) {
- var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, (obj.rectangle ? 'good_rect_normal' : 'good_circle_normal'));
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- if (obj.rectangle) {
- spr.body.setRectangle(50, 50, 25, 25)
- } else {
- spr.body.setCircle(25, 25, 25)
- }
- spr.body.mass = spr.body.data.shapes[0].area;
- if (obj.properties.static) {
- spr.body.static = true
- } else {
- spr.body.dynamic = true;
- spr.body.data.updateAABB()
- }
- spr.body.x = obj.x;
- spr.body.y = obj.y;
- spr.body.adjustCenterOfMass();
- if (BasicGame.debugPhysics) {
- spr.body.debug = true
- }
- if (BasicGame.debugPhysics) {
- spr.body.debugBody.draw()
- }
- spr.body.velocity.x = spr.body.velocity.y = 0;
- return spr
- },
- addBadObject: function(obj) {
- var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, (obj.rectangle ? 'bad_rect_normal' : 'bad_circle_normal'));
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- if (obj.rectangle) {
- spr.body.setRectangle(50, 50, 25, 25);
- spr.animations.add('lose', ['bad_rect_normal', 'bad_rect_lose'], 8, true, false)
- } else {
- spr.body.setCircle(25, 25, 25);
- spr.animations.add('lose', ['bad_circle_normal', 'bad_circle_lose'], 8, true, false)
- }
- spr.body.mass = spr.body.data.shapes[0].area;
- if (obj.properties.static) {
- spr.body.static = true;
- spr.body.data.updateAABB()
- } else {
- spr.body.dynamic = true
- }
- spr.body.x = obj.x;
- spr.body.y = obj.y;
- spr.body.adjustCenterOfMass();
- if (BasicGame.debugPhysics) {
- spr.body.debug = true
- }
- if (BasicGame.debugPhysics) {
- spr.body.debugBody.draw()
- }
- spr.body.velocity.x = spr.body.velocity.y = 0;
- return spr
- },
- addGoalObject: function(obj) {
- var spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, 'goal_normal');
- spr.animations.add('filled', ['goal_filled_0', 'goal_filled_1', 'goal_filled_0'], 2, true, false);
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- spr.body.setCircle(10, 35, 55);
- spr.body.data.shapes[0].sensor = true;
- spr.body.mass = 10;
- spr.body.static = true;
- spr.body.x = obj.x;
- spr.body.y = obj.y;
- spr.body.adjustCenterOfMass();
- spr.anchor.setTo(0.5, 0.91);
- if (BasicGame.debugPhysics) {
- spr.body.debug = true
- }
- if (BasicGame.debugPhysics) {
- spr.body.debugBody.draw()
- }
- spr.body.velocity.x = spr.body.velocity.y = 0;
- return spr
- },
- addStoneObject: function(obj) {
- var spr;
- if (obj.rectangle) {
- spr = this.tempCreateRectSprite(obj, '#808080')
- } else if (obj.ellipse) {
- spr = this.tempCreateCircleSprite(obj, '#808080')
- } else if (obj.polygon) {
- spr = this.tempCreatePolygonSprite(obj, '#808080')
- }
- spr.body.mass = spr.body.data.shapes[0].area * 2.5;
- if (obj.properties.static) {
- spr.body.static = true
- } else {
- spr.body.dynamic = true;
- spr.body.data.updateAABB()
- }
- if (BasicGame.debugPhysics) {
- spr.body.debug = true
- }
- if (BasicGame.debugPhysics) {
- spr.body.debugBody.draw()
- }
- spr.body.velocity.x = spr.body.velocity.y = 0;
- return spr
- },
- addWoodObject: function(obj) {
- var spr;
- if (obj.rectangle) {
- spr = this.tempCreateRectSprite(obj, '#7F3300')
- } else if (obj.ellipse) {
- spr = this.tempCreateCircleSprite(obj, '#7F3300')
- } else if (obj.polygon) {
- spr = this.tempCreatePolygonSprite(obj, '#7F3300')
- }
- spr.body.mass = spr.body.data.shapes[0].area * 0.7;
- if (obj.properties.static) {
- spr.body.static = true
- } else {
- spr.body.dynamic = true;
- spr.body.data.updateAABB()
- }
- if (BasicGame.debugPhysics) {
- spr.body.debug = true
- }
- if (BasicGame.debugPhysics) {
- spr.body.debugBody.draw()
- }
- spr.body.velocity.x = spr.body.velocity.y = 0;
- return spr
- },
- tempCreatePolygonSprite: function(obj, color) {
- var polys = [];
- var len = obj.polygon.length;
- for (var j = 0; j < len; j++) {
- polys[j] = [obj.polygon[j][0], obj.polygon[j][1]]
- }
- var spr;
- if (BasicGame.loadPreTextured) {
- spr = this.add.sprite(obj.x, obj.y, this.levelAtlas, this.levelAtlasPrefix + obj.name)
- } else {
- var spr = this.add.sprite(obj.x, obj.x)
- }
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- spr.body.addPolygon({
- optimalDecomp: false,
- skipSimpleCheck: true,
- removeCollinearPoints: false
- }, polys);
- spr.body.mass = 10;
- spr.body.adjustCenterOfMass();
- spr.body.data.updateAABB();
- spr.body.data.updateBoundingRadius();
- var points = spr.body.data.shapes[0].vertices;
- var shapeWidth = Math.abs(this.physics.p2.mpxi(spr.body.data.aabb.lowerBound[0]) - this.physics.p2.mpxi(spr.body.data.aabb.upperBound[0]));
- var shapeHeight = Math.abs(this.physics.p2.mpxi(spr.body.data.aabb.lowerBound[1]) - this.physics.p2.mpxi(spr.body.data.aabb.upperBound[1]));
- if (!BasicGame.loadPreTextured) {
- var renderTarget = new Phaser.BitmapData(this, 'scenery' + this.levelAtlasPrefix + obj.name, shapeWidth, shapeHeight)
- }
- var minXP = Number.MAX_VALUE,
- minYP = Number.MAX_VALUE;
- for (j = points.length - 1; j >= 0; j--) {
- minXP = this.math.min(minXP, this.physics.p2.mpxi(points[j][0]));
- minYP = this.math.min(minYP, this.physics.p2.mpxi(points[j][1]))
- }
- var offsetX = (shapeWidth / 2) + minXP;
- var offsetY = (shapeHeight / 2) + minYP;
- if (!BasicGame.loadPreTextured) {
- renderTarget.ctx.translate(-offsetX, -offsetY);
- renderTarget.ctx.fillStyle = color;
- renderTarget.ctx.beginPath();
- renderTarget.ctx.moveTo((this.physics.p2.mpxi(points[0][0]) + shapeWidth * 0.5), (this.physics.p2.mpxi(points[0][1]) + shapeHeight * 0.5));
- for (j = 1; j < points.length; j++) {
- renderTarget.ctx.lineTo((this.physics.p2.mpxi(points[j][0]) + shapeWidth * 0.5), (this.physics.p2.mpxi(points[j][1]) + shapeHeight * 0.5))
- }
- renderTarget.ctx.closePath();
- renderTarget.ctx.fill();
- spr.loadTexture(renderTarget)
- }
- spr.anchor.setTo(0.5 - (offsetX / shapeWidth), 0.5 - (offsetY / shapeHeight));
- spr.body.x = obj.x - minXP;
- spr.body.y = obj.y - minYP;
- return spr
- },
- tempCreateRectSprite: function(obj, color) {
- if (BasicGame.loadPreTextured) {
- var spr = this.add.sprite(obj.x, obj.x, this.levelAtlas, this.levelAtlasPrefix + obj.name)
- } else {
- var spr = this.add.sprite(obj.x, obj.x)
- }
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- if (!BasicGame.loadPreTextured) {
- var b = this.make.bitmapData(obj.width, obj.height);
- b.ctx.fillStyle = color;
- b.rect(0, 0, obj.width, obj.height);
- spr.loadTexture(b)
- }
- spr.body.setRectangle(obj.width, obj.height, obj.width / 2, obj.height / 2);
- spr.body.adjustCenterOfMass();
- spr.body.x = obj.x + obj.width / 2;
- spr.body.y = obj.y + obj.height / 2;
- return spr
- },
- tempCreateCircleSprite: function(obj, color) {
- if (BasicGame.loadPreTextured) {
- var spr = this.add.sprite(obj.x, obj.x, this.levelAtlas, this.levelAtlasPrefix + obj.name)
- } else {
- var spr = this.add.sprite(obj.x, obj.x)
- }
- this.game.physics.p2.enable(spr, BasicGame.debugPhysics);
- if (!BasicGame.loadPreTextured) {
- var b = this.make.bitmapData(obj.width, obj.width);
- b.ctx.fillStyle = color;
- b.circle(obj.width / 2, obj.width / 2, obj.width / 2);
- spr.loadTexture(b)
- }
- spr.body.setCircle(obj.width / 2, obj.width / 2, obj.width / 2);
- spr.body.adjustCenterOfMass();
- spr.body.x = obj.x + obj.width / 2;
- spr.body.y = obj.y + obj.width / 2;
- return spr
- },
- fadeInCompleted: function() {
- this.pressable = true
- },
- update: function() {
- if (!this.game.paused) {
- for (var i = this.objectsGood.length - 1; i >= 0; i--) {
- if (!this.objectsGood[i].inCamera) {
- if (this.objectsGood[i].y > 0) {
- this.levelLose();
- break
- }
- }
- }
- }
- },
- levelWin: function() {
- if (this.pressable) {
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.stop()
- }
- if (!GC.soundDisabled) {
- this.soundWin.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- BasicGame.winStarsCurrent = 3;
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][0]) {
- BasicGame.winStarsCurrent = 2
- }
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][1]) {
- BasicGame.winStarsCurrent = 1
- }
- if (this.objectRemoveCount > BasicGame.LevelStarShots[this.currentLevel][2]) {
- BasicGame.winStarsCurrent = 0
- }
- BasicGame.LevelStars[BasicGame.currentLevel] = (BasicGame.winStarsCurrent > BasicGame.winStarsPrevious ? BasicGame.winStarsCurrent : BasicGame.winStarsPrevious);
- if (BasicGame.currentLevel < GC.totalLevels - 1) {
- BasicGame.LevelsOpen[BasicGame.currentLevel + 1] = 1
- }
- BasicGame.saveGame();
- this.pressable = false;
- this.fadeOutState = 'state_win_panel';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 300, Phaser.Easing.Quadratic.Out, true, 1300);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- levelLose: function() {
- if (this.pressable) {
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.stop()
- }
- if (!GC.soundDisabled) {
- this.soundFail.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- for (var j = this.objectsBad.length - 1; j >= 0; j--) {
- this.objectsBad[j].animations.play('lose')
- }
- this.pressable = false;
- this.fadeOutState = 'state_lose_panel';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 300, Phaser.Easing.Quadratic.Out, true, 1300);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnPausePressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.setPaused(true);
- this.pressable = false;
- this.world.add(this.pnlPause);
- this.pnlPause.visible = true
- }
- },
- btnRestartPressed: function() {
- if (this.pressable) {
- this.pressable = false;
- this.game.state.restart(true)
- }
- },
- unpause: function() {
- this.setPaused(false);
- this.pressable = true
- },
- fadeOutCompleted: function() {
- this.game.state.start(this.fadeOutState)
- },
- shutdown: function() {
- this.soundClick.destroy(true);
- this.soundWin.destroy(true);
- this.soundFail.destroy(true);
- this.btnPlay = null;
- if (this.pnlPause != null) {
- this.pnlPause.destroy(true);
- this.pnlPause = null
- }
- }
- };
- BasicGame.PanelPause = function(game, x, y, closeCallback, closeCallbackContext) {
- this.callbackClose = closeCallback;
- this.callbackCloseContext = closeCallbackContext;
- this.soundOnImage = game.cache._images['atlas_intermenu'].frameData._frameNames['btn_sound_on'];
- this.soundOffImage = game.cache._images['atlas_intermenu'].frameData._frameNames['btn_sound_off'];
- this.soundClick = new Phaser.Sound(game, 'sndButtonClick', 1, false);
- Phaser.TileSprite.call(this, game, x, y, game.width, game.height, 'atlas_intermenu', 'black_bg');
- var sprOverlay = new Phaser.Sprite(this.game, this.game.width / 2, 0, 'atlas_intermenu', 'pause_overlay');
- sprOverlay.anchor.set(0.5, 0);
- this.addChild(sprOverlay);
- 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');
- this.btnResume.anchor.set(0.5, 0);
- this.addChild(this.btnResume);
- this.btnRetry = new Phaser.Button(this.game, 20, this.game.height - 85, 'atlas_intermenu', this.btnRetryPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
- this.btnRetry.anchor.set(0, 1);
- this.addChild(this.btnRetry);
- 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');
- this.btnHome.anchor.set(0.5, 1);
- this.addChild(this.btnHome);
- 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');
- this.btnSound.anchor.setTo(0.5, 0.5);
- this.btnSound.y -= this.btnSound.height / 2;
- this.addChild(this.btnSound);
- if (this.game.sound.mute) {
- this.btnSound.frame = this.soundOffImage
- }
- 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');
- this.btnGames.anchor.set(0.5, 0.5);
- this.btnGames.x -= this.btnGames.width / 2;
- this.btnGames.y -= this.btnGames.height / 2;
- this.addChild(this.btnGames);
- if (this.game.device.desktop) {
- this.btnResume.input.useHandCursor = true;
- this.btnRetry.input.useHandCursor = true;
- this.btnHome.input.useHandCursor = true;
- this.btnSound.input.useHandCursor = true;
- this.btnGames.input.useHandCursor = true;
- }
- };
- BasicGame.PanelPause.prototype = Object.create(Phaser.TileSprite.prototype);
- BasicGame.PanelPause.prototype.constructor = BasicGame.PanelPause;
- BasicGame.PanelPause.prototype.btnResumePressed = function() {
- if (this.callbackClose) {
- this.callbackClose.call(this.callbackCloseContext)
- }
- this.game.world.remove(this, false);
- this.visible = false
- };
- BasicGame.PanelPause.prototype.btnSponsorImgPressed = function() {
- sponsorLinkOpen()
- };
- BasicGame.PanelPause.prototype.btnSoundClicked = function() {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnSound.scale.x = this.btnSound.scale.y = 1;
- this.game.add.tween(this.btnSound.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.game.sound.mute = !this.game.sound.mute;
- if (this.game.sound.mute) {
- this.btnSound.frame = this.soundOffImage
- } else {
- this.btnSound.frame = this.soundOnImage
- }
- if (BasicGame.sndMenuLoop.isPlaying) {
- BasicGame.sndMenuLoop.volume = (GC.playSound ? 1 : 0)
- }
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.volume = (GC.playSound ? 1 : 0)
- }
- };
- BasicGame.PanelPause.prototype.btnHomePressed = function() {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.game.add.tween(this.btnHome.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.game.state.start('state_level_select');
- this.game.world.remove(this, true);
- this.visible = false
- };
- BasicGame.PanelPause.prototype.btnRetryPressed = function() {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.game.state.restart(true)
- };
- BasicGame.PanelPause.prototype.btnGamesPressed = function() {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnGames.scale.x = this.btnGames.scale.y = 1;
- this.game.add.tween(this.btnGames.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- sponsorLinkOpen()
- };
- BasicGame.StateWinPanel = function() {};
- BasicGame.StateWinPanel.prototype = {
- initVars: function() {
- this.pressable = false;
- this.fadeOutState = 'state_game';
- this.animateStarCount = 0;
- this.tweenObj = null
- },
- create: function() {
- adProcess();
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.stop()
- }
- this.soundClick = this.game.add.audio('sndButtonClick', 1, false);
- this.soundWin1 = this.game.add.audio('sndWinStar1', 1, false);
- this.soundWin2 = this.game.add.audio('sndWinStar2', 1, false);
- this.soundWin3 = this.game.add.audio('sndWinStar3', 1, false);
- this.pressable = false;
- this.fadeOutState = 'state_game';
- this.imgBg = this.add.image(0, 0, 'atlas_intermenu', 'pause_menu_background');
- this.imgOverlay = this.add.image(this.game.width / 2, 15, 'atlas_intermenu', 'win_overlay');
- this.imgOverlay.anchor.set(0.5, 0);
- this.imgStar1 = this.make.image(138 - this.imgOverlay.width / 2, 85 + 105 * 2, 'atlas_intermenu', 'win_star_1');
- this.imgStar2 = this.make.image(246 - this.imgOverlay.width / 2, 85 + 105 * 2, 'atlas_intermenu', 'win_star_2');
- this.imgStar3 = this.make.image(192 - this.imgOverlay.width / 2, 39 + 155 * 2, 'atlas_intermenu', 'win_star_3');
- this.imgStar1.anchor.x = 1;
- this.imgStar2.anchor.x = 0;
- this.imgStar3.anchor.x = 0.5;
- this.imgStar1.anchor.y = this.imgStar2.anchor.y = this.imgStar3.anchor.y = 2;
- this.imgOverlay.addChild(this.imgStar1);
- this.imgOverlay.addChild(this.imgStar2);
- this.imgOverlay.addChild(this.imgStar3);
- this.imgStar1.name = 'star_1';
- this.imgStar2.name = 'star_2';
- this.imgStar3.name = 'star_3';
- this.imgStar1.visible = this.imgStar2.visible = this.imgStar3.visible = false;
- if (BasicGame.winStarsPrevious == 3) {
- this.imgStar1.visible = this.imgStar2.visible = this.imgStar3.visible = true
- } else if (BasicGame.winStarsPrevious == 2) {
- this.imgStar1.visible = this.imgStar2.visible = true;
- this.imgStar3.scale.set(2, 2)
- } else if (BasicGame.winStarsPrevious == 1) {
- this.imgStar1.visible = true;
- this.imgStar2.scale.set(2, 2);
- this.imgStar3.scale.set(2, 2)
- } else {
- this.imgStar1.scale.set(2, 2);
- this.imgStar2.scale.set(2, 2);
- this.imgStar3.scale.set(2, 2)
- }
- this.animateStarCount = BasicGame.winStarsCurrent - BasicGame.winStarsPrevious;
- this.animateStarCount = Math.max(0, Math.min(3, this.animateStarCount));
- 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');
- this.btnNext.anchor.setTo(0.5, 0.5);
- this.btnRestart = this.add.button(50, this.game.height - 60, 'atlas_intermenu', this.btnRestartPressed, this, 'btn_retry', 'btn_retry', 'btn_retry');
- this.btnRestart.anchor.setTo(0.5, 0.5);
- this.btnRestart.x += this.btnRestart.width / 2;
- this.btnRestart.y -= this.btnRestart.height / 2;
- this.btnHome = this.add.button(this.game.width / 2, this.game.height - 60, 'atlas_intermenu', this.btnHomePressed, this, 'btn_home', 'btn_home', 'btn_home');
- this.btnHome.anchor.setTo(0.5, 0.5);
- this.btnHome.y -= this.btnHome.height / 2;
- this.btnGames = this.add.button(this.game.width - 50, this.game.height - 60, 'atlas_intermenu', this.btnGamesPressed, this, 'btn_games', 'btn_games', 'btn_games');
- this.btnGames.anchor.setTo(0.5, 0.5);
- this.btnGames.x -= this.btnGames.width / 2;
- this.btnGames.y -= this.btnGames.height / 2;
- var btnDown = null;
- if (this.game.device.desktop) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.android) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
- } else if (this.game.device.iOS) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.windowsPhone) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
- } else {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- }
- btnDown.anchor.setTo(0.5, 0);
- btnDown.scale.setTo(1.3, 1.3);
- if (this.game.device.desktop) {
- this.btnNext.input.useHandCursor = true;
- this.btnRestart.input.useHandCursor = true;
- this.btnHome.input.useHandCursor = true;
- this.btnGames.input.useHandCursor = true;
- btnDown.input.useHandCursor = true;
- }
- this.game.world.alpha = 0;
- this.tweenFadeIn = this.game.add.tween(this.game.world).to({
- alpha: 1
- }, 300, Phaser.Easing.Quadratic.In, true);
- this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
- this.tweenFadeIn.start()
- },
- btnSponsorImgPressed: function() {
- if (this.pressable) {
- sponsorLinkOpen()
- }
- },
- fadeInCompleted: function() {
- this.pressable = true;
- this.animateNextStar()
- },
- animateNextStar: function() {
- if (this.animateStarCount > 0) {
- BasicGame.winStarsPrevious += 1;
- this.animateStarCount -= 1;
- if (BasicGame.winStarsPrevious == 1) {
- this.tweenObj = this.imgStar1
- } else if (BasicGame.winStarsPrevious == 2) {
- this.tweenObj = this.imgStar2
- } else if (BasicGame.winStarsPrevious == 3) {
- this.tweenObj = this.imgStar3
- }
- this.tweenObj.visible = true;
- this.add.tween(this.tweenObj.scale).to({
- x: 1,
- y: 1
- }, 400, Phaser.Easing.Cubic.In, true).onComplete.addOnce(this.shakeCamera, this);
- this.game.time.events.add(Phaser.Timer.SECOND / 5, this.middleAnimateStar, this)
- }
- },
- middleAnimateStar: function() {
- if (this.tweenObj != null && GC.playSound) {
- if (this.tweenObj.name == 'star_1') {
- if (!GC.soundDisabled) {
- this.soundWin1.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- } else if (this.tweenObj.name == 'star_2') {
- if (!GC.soundDisabled) {
- this.soundWin2.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- } else if (this.tweenObj.name == 'star_3') {
- if (!GC.soundDisabled) {
- this.soundWin3.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- }
- }
- },
- shakeCamera: function() {
- this.world.camera.x += 5;
- this.world.camera.y += 5;
- this.animateNextStar()
- },
- update: function() {
- this.world.camera.x *= 0.9;
- this.world.camera.y *= 0.9
- },
- shutdown: function() {
- this.soundClick.destroy(true);
- this.soundWin1.destroy(true);
- this.soundWin2.destroy(true);
- this.soundWin3.destroy(true);
- this.world.camera.x = 0;
- this.world.camera.y = 0;
- if (BasicGame.winStarsCurrent > BasicGame.winStarsPrevious) {
- BasicGame.winStarsPrevious = BasicGame.winStarsCurrent
- }
- this.imgOverlay = null;
- this.btnNext = null;
- this.btnRestart = null;
- this.btnHome = null;
- this.btnGames = null
- },
- btnNextPressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnNext.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- if (BasicGame.currentLevel >= GC.totalLevels - 1) {
- this.fadeOutState = 'state_level_select'
- } else {
- this.fadeOutState = 'state_game';
- BasicGame.currentLevel += 1
- }
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 400, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnRestartPressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnRestart.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.fadeOutState = 'state_game';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 400, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnHomePressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnHome.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.fadeOutState = 'state_level_select';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 400, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnGamesPressed: function() {
- if (!GC.soundDisabled) {
- this.soundClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnGames.scale.x = 1;
- this.btnGames.scale.y = 1;
- this.add.tween(this.btnGames.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- sponsorLinkOpen()
- },
- fadeOutCompleted: function() {
- this.game.state.start(this.fadeOutState)
- }
- };
- BasicGame.StateLosePanel = function() {};
- BasicGame.StateLosePanel.prototype = {
- initVars: function() {},
- create: function() {
- adProcess();
- this.sndButtonClick = this.game.add.audio('sndButtonClick', 1, false);
- if (BasicGame.sndGameLoop.isPlaying) {
- BasicGame.sndGameLoop.stop()
- }
- this.pressable = false;
- this.fadeOutState = 'state_game';
- this.imgBg = this.add.image(0, 0, 'atlas_intermenu', 'pause_menu_background');
- this.imgOverlay = this.add.image(this.game.width / 2, 15, 'atlas_intermenu', 'lose_overlay');
- this.imgOverlay.anchor.set(0.5, 0);
- 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');
- this.btnRetry.anchor.setTo(0.5, 0.5);
- 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');
- this.btnHome.anchor.setTo(0.5, 0.5);
- this.btnHome.x -= this.btnHome.width / 2;
- this.btnHome.y -= this.btnHome.height / 2;
- 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');
- this.btnGames.anchor.setTo(0.5, 0.5);
- this.btnGames.x += this.btnGames.width / 2;
- this.btnGames.y -= this.btnGames.height / 2;
- var btnDown = null;
- if (this.game.device.desktop) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.android) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_google', 'store_google', 'store_google')
- } else if (this.game.device.iOS) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- } else if (this.game.device.windowsPhone) {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_winphone', 'store_winphone', 'store_winphone')
- } else {
- btnDown = this.add.button(this.game.width / 2, this.game.height / 2 + 105, 'atlas_intermenu', btnDownloadsPressed, null, 'store_download', 'store_download', 'store_download')
- }
- btnDown.anchor.setTo(0.5, 0);
- btnDown.scale.setTo(1.3, 1.3);
- if (this.game.device.desktop) {
- this.btnRetry.input.useHandCursor = true;
- this.btnHome.input.useHandCursor = true;
- this.btnGames.input.useHandCursor = true;
- btnDown.input.useHandCursor = true
- }
- this.game.world.alpha = 0;
- this.tweenFadeIn = this.game.add.tween(this.game.world).to({
- alpha: 1
- }, 300, Phaser.Easing.Quadratic.In, true);
- this.tweenFadeIn.onComplete.addOnce(this.fadeInCompleted, this);
- this.tweenFadeIn.start()
- },
- btnSponsorImgPressed: function() {
- if (this.pressable) {
- sponsorLinkOpen()
- }
- },
- fadeInCompleted: function() {
- this.pressable = true
- },
- update: function() {},
- shutdown: function() {},
- btnRetryPressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnRetry.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.fadeOutState = 'state_game';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 400, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnHomePressed: function() {
- if (this.pressable) {
- if (!GC.soundDisabled) {
- this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.add.tween(this.btnHome.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- this.pressable = false;
- this.fadeOutState = 'state_level_select';
- this.tweenFadeOut = this.game.add.tween(this.game.world).to({
- alpha: 0
- }, 400, Phaser.Easing.Quadratic.Out, true);
- this.tweenFadeOut.onComplete.addOnce(this.fadeOutCompleted, this);
- this.tweenFadeOut.start()
- }
- },
- btnGamesPressed: function() {
- if (!GC.soundDisabled) {
- this.sndButtonClick.play('', 0, (GC.playSound ? 1 : 0), false)
- }
- this.btnGames.scale.x = 1;
- this.btnGames.scale.y = 1;
- this.add.tween(this.btnGames.scale).to({
- x: 1.2,
- y: 0.8
- }, 100, Phaser.Easing.Quadratic.Out, true, 0, 0, true);
- sponsorLinkOpen()
- },
- fadeOutCompleted: function() {
- this.game.state.start(this.fadeOutState)
- },
- shutdown: function() {
- this.sndButtonClick.destroy(true)
- }
- };
- function splice1(a, i) {
- var l = a.length;
- if (l) {
- while (i < l) {
- a[i++] = a[i]
- }--a.length
- }
- };
- var screenFullResize = function() {
- game.scale.setShowAll();
- if (game.state.current == 'state_menu') {
- var s = game.state.getCurrentState();
- s.refreshFullscreenUi()
- }
- };
- function menuClickedFullscreenCheck() {
- if (screenfull.enabled) {
- if (game.state.current == 'state_menu') {
- var s = game.state.getCurrentState();
- var p = game.input.activePointer.position;
- var b = s.btnFullscreen;
- var oX = b.anchor.x * b.width;
- var oY = b.anchor.y * b.height;
- 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)) {
- return
- }
- }
- if (screenfull.isFullscreen) {
- screenfull.exit()
- } else {
- screenfull.request()
- }
- }
- };
- function sponsorLinkOpen() {
- _czc.push(["_trackEvent","小虎回家","更多游戏","","",""]);
- if(document.referrer)
- Play68.goHome();
- else
- play68_goHome();
- //window.open(BasicGame.linkDownloadPage, '_blank')
- };
- var adScaleX = 0.8;
- var adScaleY = 0.8;
- var adsAvailable = true;
- function initAds() {
- adserver.initialize(adServerSuccess, adServerFail, '');
- if (game.device.desktop) {
- adsAvailable = false;
- return
- }
- var btnClose = document.getElementById('ad_close_button');
- btnClose.onclick = function() {
- hideInterstitialAd()
- };
- var bannerDiv = document.getElementById('banner_container');
- if (!bannerDiv) {
- return
- }
- bannerDiv.style.position = 'absolute';
- bannerDiv.style.bottom = '0';
- bannerDiv.style.msTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
- bannerDiv.style.msTransformOrigin = '50% 100%';
- bannerDiv.style.webkitTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
- bannerDiv.style.webkitTransformOrigin = '50% 100%';
- bannerDiv.style.OTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
- bannerDiv.style.OTransformOrigin = '50% 100%';
- bannerDiv.style.MozTransform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
- bannerDiv.style.MozTransformOrigin = '70% 100%';
- bannerDiv.style.transform = 'scale(' + adScaleX.toString() + ', ' + adScaleY.toString() + ')';
- bannerDiv.style.transformOrigin = '50% 100%'
- };
- function adServerSuccess() {
- if (adserver.responseObject != null) {
- var o = adserver.responseObject;
- if (o.interstitial.provider == 'self') {
- var img = new Image();
- img.onload = adImageLoaded;
- img.src = o.interstitial.src;
- adSelfUrl = o.interstitial.url;
- var container = document.createElement('div');
- container.id = 'self_inter_container';
- container.style.display = 'none';
- container.style.position = 'absolute';
- container.style.top = '0';
- container.style.textAlign = 'center';
- var btnClose = document.createElement('div');
- btnClose.id = 'self_ad_close_button';
- btnClose.style.position = 'absolute';
- btnClose.style.left = '10px';
- btnClose.style.top = '50px';
- btnClose.onclick = hideSelfInterstitialAd;
- var imgClose = document.createElement('img');
- imgClose.src = 'assets/close_button.png';
- btnClose.appendChild(imgClose);
- container.appendChild(btnClose);
- document.body.appendChild(container)
- }
- }
- };
- function adServerFail() {};
- var adSelfUrl = '#'; /*ad server URL or main website URL paste here*/
-
- function adImageLoaded(e) {
- adSelfAvailable = true;
- var container = document.getElementById('self_inter_container');
- if (!container) {
- return
- }
- var screenAR = document.body.clientWidth / document.body.clientHeight;
- var imgAR = e.target.width / e.target.height;
- if (screenAR > imgAR) {
- e.target.style.height = (document.body.clientHeight - 5) + 'px';
- e.target.style.width = 'auto'
- } else {
- e.target.style.width = (document.body.clientWidth - 5) + 'px';
- e.target.style.height = 'auto'
- }
- container.insertBefore(e.target, container.childNodes[container.childNodes.length - 1]);
- e.target.onclick = selfInterstitialAdClicked;
- };
- var adCounter = 2;
- var adSelfAvailable = false;
- var adSwap = true;
- function adProcess() {
- adCounter += 1;
- if (adCounter > 3) {
- adCounter = 0;
- if (adSelfAvailable) {
- if (adSwap) {
- showSelfInterstitialAd()
- } else {
- showInterstitialAd()
- }
- adSwap = !adSwap
- } else {
- showInterstitialAd()
- }
- }
- };
- function showInterstitialAd() {
- if (!adsAvailable) {
- return
- }
- var container = document.getElementById('interstitial_container');
- if (!container) {
- return
- }
- container.style.display = 'block';
- var bgContainer = document.getElementById('interstitial_bg');
- bgContainer.style.display = 'block';
- bgContainer.style.width = window.innerWidth.toString() + 'px';
- bgContainer.style.height = window.innerHeight.toString() + 'px';
- bgContainer.style.fontSize = '50px';
- bgContainer.style.textAlign = 'center';
- bgContainer.style.color = '#EFEFEF';
- var sf = 1;
- if (game) {
- if (game.scale) {
- sf = Math.min(game.scale.scaleFactor.x, game.scale.scaleFactor.y)
- }
- }
- sf = (1 / sf);
- var ad_close_button = document.getElementById('ad_close_button');
- if (!ad_close_button) {
- return
- }
- ad_close_button.style.msTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.msTransformOrigin = '0% 0%';
- ad_close_button.style.webkitTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.webkitTransformOrigin = '0% 0%';
- ad_close_button.style.OTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.OTransformOrigin = '0% 0%';
- ad_close_button.style.MozTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.MozTransformOrigin = '0% 0%';
- ad_close_button.style.transform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.transformOrigin = '0% 0%'
- };
- function showSelfInterstitialAd() {
- if (!adSelfAvailable) {
- return
- }
- var container = document.getElementById('self_inter_container');
- if (!container) {
- return
- }
- var img = container.childNodes[0];
- if (!img) {
- return
- }
- var screenAR = document.body.clientWidth / document.body.clientHeight;
- var imgAR = img.width / img.height;
- if (screenAR > imgAR) {
- img.style.height = (document.body.clientHeight - 5) + 'px';
- img.style.width = 'auto'
- } else {
- img.style.width = (document.body.clientWidth - 5) + 'px';
- img.style.height = 'auto'
- }
- container.style.display = 'block';
- container.style.left = '50%';
- container.style.top = '50%';
- container.style.msTransform = 'translate(-50%, -50%)';
- container.style.webkitTransform = 'translate(-50%, -50%)';
- container.style.OTransform = 'translate(-50%, -50%)';
- container.style.MozTransform = 'translate(-50%, -50%)';
- container.style.transform = 'translate(-50%, -50%)';
- var sf = 1;
- if (game) {
- if (game.scale) {
- sf = Math.min(game.scale.scaleFactor.x, game.scale.scaleFactor.y)
- }
- }
- sf = (1 / sf);
- var ad_close_button = document.getElementById('self_ad_close_button');
- if (!ad_close_button) {
- return
- }
- ad_close_button.style.msTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.msTransformOrigin = '0% 0%';
- ad_close_button.style.webkitTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.webkitTransformOrigin = '0% 0%';
- ad_close_button.style.OTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.OTransformOrigin = '0% 0%';
- ad_close_button.style.MozTransform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.MozTransformOrigin = '0% 0%';
- ad_close_button.style.transform = 'scale(' + sf.toString() + ', ' + sf.toString() + ')';
- ad_close_button.style.transformOrigin = '0% 0%'
- };
- function selfInterstitialAdClicked() {
- if (adSelfUrl != '') {
- window.open(adSelfUrl, '_blank')
- }
- };
- function hideSelfInterstitialAd() {
- if (!adSelfAvailable) {
- return
- }
- var container = document.getElementById('self_inter_container');
- if (!container) {
- return
- }
- container.style.display = 'none'
- };
- function showBannerAd() {
- if (!adsAvailable) {
- return
- }
- var container = document.getElementById('banner_container');
- if (!container) {
- return
- }
- container.style.display = 'block'
- };
- function hideInterstitialAd() {
- if (!adsAvailable) {
- return
- }
- var container = document.getElementById('interstitial_container');
- if (!container) {
- return
- }
- container.style.display = 'none';
- var bgContainer = document.getElementById('interstitial_bg');
- bgContainer.style.display = 'none'
- };
- function scaleBannerAd(x, y) {
- if (!adsAvailable) {
- return
- }
- var container = document.getElementById('banner_container');
- if (!container) {
- return
- }
- container.style.transform = 'scale(' + x + ', ' + y + ')';
- container.style.transformOrigin = '50% 100%'
- };
- function hideBannerAd() {
- if (!adsAvailable) {
- return
- }
- var container = document.getElementById('banner_container');
- if (!container) {
- return
- }
- container.style.display = 'none'
- };
- var game;
- window.onload = function() {
- game = new Phaser.Game(480, 690, Phaser.AUTO, 'gameContainer');
- game.state.add('state_boot', BasicGame.StateBoot);
- game.state.add('state_preload', BasicGame.StatePreload);
- game.state.add('state_menu', BasicGame.StateMenu);
- game.state.add('state_level_select', BasicGame.StateLevelSelect);
- game.state.add('state_game', BasicGame.StateGame);
- game.state.add('state_win_panel', BasicGame.StateWinPanel);
- game.state.add('state_lose_panel', BasicGame.StateLosePanel);
- BasicGame.StateMenu.prototype.initVars(game);
- BasicGame.StateLevelSelect.prototype.initVars(game);
- BasicGame.StateGame.prototype.initVars(game);
- game.state.start('state_boot')
- }
- })();
|