main-compiled.js 222 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587
  1. var highestEvolutionLevel=0;
  2. function pickAdURL() {}
  3. function DetectIphone() {
  4. return -1 < uagent.search(deviceIphone) ? DetectIpad() || DetectIpod() ? !1 : !0 : !1
  5. }
  6. function DetectIpod() {
  7. return -1 < uagent.search(deviceIpod) ? !0 : !1
  8. }
  9. function DetectIpad() {
  10. return -1 < uagent.search(deviceIpad) && DetectWebkit() ? !0 : !1
  11. }
  12. function DetectIphoneOrIpod() {
  13. return -1 < uagent.search(deviceIphone) || -1 < uagent.search(deviceIpod) ? !0 : !1
  14. }
  15. function DetectIos() {
  16. return DetectIphoneOrIpod() || DetectIpad() ? !0 : !1
  17. }
  18. function DetectAndroid() {
  19. return -1 < uagent.search(deviceAndroid) || DetectGoogleTV() ? !0 : -1 < uagent.search(deviceHtcFlyer) ? !0 : !1
  20. }
  21. function DetectAndroidPhone() {
  22. return DetectAndroid() && -1 < uagent.search(mobile) || DetectOperaAndroidPhone() ? !0 : -1 < uagent.search(deviceHtcFlyer) ? !0 : !1
  23. }
  24. function DetectAndroidTablet() {
  25. return !DetectAndroid() || DetectOperaMobile() || -1 < uagent.search(deviceHtcFlyer) ? !1 : -1 < uagent.search(mobile) ? !1 : !0
  26. }
  27. function DetectAndroidWebKit() {
  28. return DetectAndroid() && DetectWebkit() ? !0 : !1
  29. }
  30. function DetectGoogleTV() {
  31. return -1 < uagent.search(deviceGoogleTV) ? !0 : !1
  32. }
  33. function DetectWebkit() {
  34. return -1 < uagent.search(engineWebKit) ? !0 : !1
  35. }
  36. function DetectS60OssBrowser() {
  37. return DetectWebkit() ? -1 < uagent.search(deviceS60) || -1 < uagent.search(deviceSymbian) ? !0 : !1 : !1
  38. }
  39. function DetectSymbianOS() {
  40. return -1 < uagent.search(deviceSymbian) || -1 < uagent.search(deviceS60) || -1 < uagent.search(deviceS70) || -1 < uagent.search(deviceS80) || -1 < uagent.search(deviceS90) ? !0 : !1
  41. }
  42. function DetectWindowsPhone7() {
  43. return -1 < uagent.search(deviceWinPhone7) ? !0 : !1
  44. }
  45. function DetectWindowsMobile() {
  46. return DetectWindowsPhone7() ? !1 : -1 < uagent.search(deviceWinMob) || -1 < uagent.search(deviceIeMob) || -1 < uagent.search(enginePie) || -1 < uagent.search(devicePpc) && !(-1 < uagent.search(deviceMacPpc)) ? !0 : -1 < uagent.search(manuHtc) && -1 < uagent.search(deviceWindows) ? !0 : !1
  47. }
  48. function DetectBlackBerry() {
  49. return -1 < uagent.search(deviceBB) ? !0 : -1 < uagent.search(vndRIM) ? !0 : !1
  50. }
  51. function DetectBlackBerryTablet() {
  52. return -1 < uagent.search(deviceBBPlaybook) ? !0 : !1
  53. }
  54. function DetectBlackBerryWebKit() {
  55. return DetectBlackBerry() && -1 < uagent.search(engineWebKit) ? !0 : !1
  56. }
  57. function DetectBlackBerryTouch() {
  58. return DetectBlackBerry() && (-1 < uagent.search(deviceBBStorm) || -1 < uagent.search(deviceBBTorch) || -1 < uagent.search(deviceBBBoldTouch) || -1 < uagent.search(deviceBBCurveTouch)) ? !0 : !1
  59. }
  60. function DetectBlackBerryHigh() {
  61. return DetectBlackBerryWebKit() ? !1 : DetectBlackBerry() ? DetectBlackBerryTouch() || -1 < uagent.search(deviceBBBold) || -1 < uagent.search(deviceBBTour) || -1 < uagent.search(deviceBBCurve) ? !0 : !1 : !1
  62. }
  63. function DetectBlackBerryLow() {
  64. return DetectBlackBerry() ? DetectBlackBerryHigh() || DetectBlackBerryWebKit() ? !1 : !0 : !1
  65. }
  66. function DetectPalmOS() {
  67. return -1 < uagent.search(devicePalm) || -1 < uagent.search(engineBlazer) || -1 < uagent.search(engineXiino) ? DetectPalmWebOS() ? !1 : !0 : !1
  68. }
  69. function DetectPalmWebOS() {
  70. return -1 < uagent.search(deviceWebOS) ? !0 : !1
  71. }
  72. function DetectWebOSTablet() {
  73. return -1 < uagent.search(deviceWebOShp) && -1 < uagent.search(deviceTablet) ? !0 : !1
  74. }
  75. function DetectGarminNuvifone() {
  76. return -1 < uagent.search(deviceNuvifone) ? !0 : !1
  77. }
  78. function DetectSmartphone() {
  79. return DetectIphoneOrIpod() || DetectAndroidPhone() || DetectS60OssBrowser() || DetectSymbianOS() || DetectWindowsMobile() || DetectWindowsPhone7() || DetectBlackBerry() || DetectPalmWebOS() || DetectPalmOS() || DetectGarminNuvifone() ? !0 : !1
  80. }
  81. function DetectArchos() {
  82. return -1 < uagent.search(deviceArchos) ? !0 : !1
  83. }
  84. function DetectBrewDevice() {
  85. return -1 < uagent.search(deviceBrew) ? !0 : !1
  86. }
  87. function DetectDangerHiptop() {
  88. return -1 < uagent.search(deviceDanger) || -1 < uagent.search(deviceHiptop) ? !0 : !1
  89. }
  90. function DetectMaemoTablet() {
  91. return -1 < uagent.search(maemo) ? !0 : -1 < uagent.search(linux) && -1 < uagent.search(deviceTablet) && !DetectWebOSTablet() && !DetectAndroid() ? !0 : !1
  92. }
  93. function DetectSonyMylo() {
  94. return -1 < uagent.search(manuSony) ? -1 < uagent.search(qtembedded) || -1 < uagent.search(mylocom2) ? !0 : !1 : !1
  95. }
  96. function DetectOperaMobile() {
  97. return -1 < uagent.search(engineOpera) ? -1 < uagent.search(mini) || -1 < uagent.search(mobi) ? !0 : !1 : !1
  98. }
  99. function DetectOperaAndroidPhone() {
  100. return -1 < uagent.search(engineOpera) && -1 < uagent.search(deviceAndroid) && -1 < uagent.search(mobi) ? !0 : !1
  101. }
  102. function DetectOperaAndroidTablet() {
  103. return -1 < uagent.search(engineOpera) && -1 < uagent.search(deviceAndroid) && -1 < uagent.search(deviceTablet) ? !0 : !1
  104. }
  105. function DetectSonyPlaystation() {
  106. return -1 < uagent.search(devicePlaystation) ? !0 : !1
  107. }
  108. function DetectNintendo() {
  109. return -1 < uagent.search(deviceNintendo) || -1 < uagent.search(deviceWii) || -1 < uagent.search(deviceNintendoDs) ? !0 : !1
  110. }
  111. function DetectXbox() {
  112. return -1 < uagent.search(deviceXbox) ? !0 : !1
  113. }
  114. function DetectGameConsole() {
  115. return DetectSonyPlaystation() || DetectNintendo() ? !0 : DetectXbox() ? !0 : !1
  116. }
  117. function DetectKindle() {
  118. return -1 < uagent.search(deviceKindle) && !DetectAndroid() ? !0 : !1
  119. }
  120. function DetectAmazonSilk() {
  121. return -1 < uagent.search(engineSilk) ? !0 : !1
  122. }
  123. function DetectMobileQuick() {
  124. return DetectTierTablet() ? !1 : DetectSmartphone() || -1 < uagent.search(deviceMidp) || DetectBrewDevice() || DetectOperaMobile() || -1 < uagent.search(engineNetfront) || -1 < uagent.search(engineUpBrowser) || -1 < uagent.search(engineOpenWeb) || DetectDangerHiptop() || DetectMaemoTablet() || DetectArchos() || -1 < uagent.search(devicePda) && !(-1 < uagent.search(disUpdate)) || -1 < uagent.search(mobile) || DetectKindle() || DetectAmazonSilk() ? !0 : !1
  125. }
  126. function DetectMobileLong() {
  127. return DetectMobileQuick() || DetectGameConsole() || DetectSonyMylo() || -1 < uagent.search(manuSamsung1) || -1 < uagent.search(manuSonyEricsson) || -1 < uagent.search(manuericsson) || -1 < uagent.search(svcDocomo) || -1 < uagent.search(svcKddi) || -1 < uagent.search(svcVodafone) ? !0 : !1
  128. }
  129. function DetectTierTablet() {
  130. return DetectIpad() || DetectAndroidTablet() || DetectBlackBerryTablet() || DetectWebOSTablet() ? !0 : !1
  131. }
  132. function DetectTierIphone() {
  133. return DetectIphoneOrIpod() || DetectAndroidPhone() || DetectBlackBerryWebKit() && DetectBlackBerryTouch() || DetectWindowsPhone7() || DetectPalmWebOS() ? !0 : DetectGarminNuvifone() ? !0 : !1
  134. }
  135. function DetectTierRichCss() {
  136. return DetectMobileQuick() ? DetectTierIphone() || DetectKindle() ? !1 : DetectWebkit() || DetectS60OssBrowser() || DetectBlackBerryHigh() || DetectWindowsMobile() ? !0 : -1 < uagent.search(engineTelecaQ) ? !0 : !1 : !1
  137. }
  138. function DetectTierOtherPhones() {
  139. return DetectMobileLong() ? DetectTierIphone() || DetectTierRichCss() ? !1 : !0 : !1
  140. }
  141. function InitDeviceScan() {
  142. isIphone = DetectIphoneOrIpod();
  143. isAndroidPhone = DetectAndroidPhone();
  144. isTierIphone = DetectTierIphone();
  145. isTierTablet = DetectTierTablet();
  146. isTierRichCss = DetectTierRichCss();
  147. isTierGenericMobile = DetectTierOtherPhones()
  148. }
  149. function randomSnd() {
  150. for (var e = 0, t = 0; 3 > t; t++) var n = Random.random(),
  151. e = e + (2 * n - 1);
  152. return e
  153. }
  154. function randNormal(e, t) {
  155. return randomSnd() * t + e
  156. }
  157. function rand(e) {
  158. return Math.floor(Math.random() * e)
  159. }
  160. function containsObject(e, t) {
  161. var n;
  162. for (n = 0; n < t.length; n++)
  163. if (t[n] === e) return !0;
  164. return !1
  165. }
  166. function addCommas(e) {
  167. x = (e + "").split(".");
  168. x1 = x[0];
  169. x2 = 1 < x.length ? "." + x[1] : "";
  170. for (e = /(\d+)(\d{3})/; e.test(x1);) x1 = x1.replace(e, "$1,$2");
  171. return x1 + x2
  172. }
  173. function initHighscore() {
  174. var e = localStorage[GAME_UID + "highscoreTable"];
  175. return void 0 === e || null === e ? [] : JSON.parse(e)
  176. }
  177. function createHighscoreEntry(e) {
  178. var t = {};
  179. t.date = Date.now();
  180. t.score = e;
  181. return t
  182. }
  183. function addToHighscoreList(e) {
  184. var t;
  185. for (t = 0; t < _G.highscoreTable.length && !(_G.highscoreTable[t].score < e.score); t++);
  186. _G.highscoreTable.splice(t, 0, e);
  187. 10 < _G.highscoreTable.length && _G.highscoreTable.pop();
  188. localStorage[GAME_UID + "highscoreTable"] = JSON.stringify(_G.highscoreTable)
  189. }
  190. function setLoadingScene() {
  191. var e = new Scene,
  192. t = new Sprite(320, 480);
  193. t.image = enchant.Game.instance.assets["res/splashScreen.png"];
  194. e.addChild(t);
  195. enchant.Game.instance.loadingScene = e;
  196. enchant.Game.instance.start()
  197. }
  198. var isIphone = !1,
  199. isAndroidPhone = !1,
  200. isTierTablet = !1,
  201. isTierIphone = !1,
  202. isTierRichCss = !1,
  203. isTierGenericMobile = !1,
  204. engineWebKit = "webkit",
  205. deviceIphone = "iphone",
  206. deviceIpod = "ipod",
  207. deviceIpad = "ipad",
  208. deviceMacPpc = "macintosh",
  209. deviceAndroid = "android",
  210. deviceGoogleTV = "googletv",
  211. deviceXoom = "xoom",
  212. deviceHtcFlyer = "htc_flyer",
  213. deviceNuvifone = "nuvifone",
  214. deviceSymbian = "symbian",
  215. deviceS60 = "series60",
  216. deviceS70 = "series70",
  217. deviceS80 = "series80",
  218. deviceS90 = "series90",
  219. deviceWinPhone7 = "windows phone os 7",
  220. deviceWinMob = "windows ce",
  221. deviceWindows = "windows",
  222. deviceIeMob = "iemobile",
  223. devicePpc = "ppc",
  224. enginePie = "wm5 pie",
  225. deviceBB = "blackberry",
  226. vndRIM = "vnd.rim",
  227. deviceBBStorm = "blackberry95",
  228. deviceBBBold = "blackberry97",
  229. deviceBBBoldTouch = "blackberry 99",
  230. deviceBBTour = "blackberry96",
  231. deviceBBCurve = "blackberry89",
  232. deviceBBCurveTouch = "blackberry 938",
  233. deviceBBTorch = "blackberry 98",
  234. deviceBBPlaybook = "playbook",
  235. devicePalm = "palm",
  236. deviceWebOS = "webos",
  237. deviceWebOShp = "hpwos",
  238. engineBlazer = "blazer",
  239. engineXiino = "xiino",
  240. deviceKindle = "kindle",
  241. engineSilk = "silk",
  242. vndwap = "vnd.wap",
  243. wml = "wml",
  244. deviceTablet = "tablet",
  245. deviceBrew = "brew",
  246. deviceDanger = "danger",
  247. deviceHiptop = "hiptop",
  248. devicePlaystation = "playstation",
  249. deviceNintendoDs = "nitro",
  250. deviceNintendo = "nintendo",
  251. deviceWii = "wii",
  252. deviceXbox = "xbox",
  253. deviceArchos = "archos",
  254. engineOpera = "opera",
  255. engineNetfront = "netfront",
  256. engineUpBrowser = "up.browser",
  257. engineOpenWeb = "openweb",
  258. deviceMidp = "midp",
  259. uplink = "up.link",
  260. engineTelecaQ = "teleca q",
  261. devicePda = "pda",
  262. mini = "mini",
  263. mobile = "mobile",
  264. mobi = "mobi",
  265. maemo = "maemo",
  266. linux = "linux",
  267. qtembedded = "qt embedded",
  268. mylocom2 = "com2",
  269. manuSonyEricsson = "sonyericsson",
  270. manuericsson = "ericsson",
  271. manuSamsung1 = "sec-sgh",
  272. manuSony = "sony",
  273. manuHtc = "htc",
  274. svcDocomo = "docomo",
  275. svcKddi = "kddi",
  276. svcVodafone = "vodafone",
  277. disUpdate = "update",
  278. uagent = "";
  279. navigator && navigator.userAgent && (uagent = navigator.userAgent.toLowerCase());
  280. InitDeviceScan();
  281. Random = {};
  282. (function(e, t, n, r, i, s, o) {
  283. function u(e) {
  284. var t, r, i = this,
  285. s = e.length,
  286. o = 0,
  287. u = i.i = i.j = i.m = 0;
  288. i.S = [];
  289. i.c = [];
  290. for (s || (e = [s++]); o < n;) i.S[o] = o++;
  291. for (o = 0; o < n; o++) t = i.S[o], u = u + t + e[o % s] & n - 1, r = i.S[u], i.S[o] = r, i.S[u] = t;
  292. i.g = function(e) {
  293. var t = i.S,
  294. r = i.i + 1 & n - 1,
  295. s = t[r],
  296. o = i.j + s & n - 1,
  297. u = t[o];
  298. t[r] = u;
  299. t[o] = s;
  300. for (var a = t[s + u & n - 1]; --e;) r = r + 1 & n - 1, s = t[r], o = o + s & n - 1, u = t[o], t[r] = u, t[o] = s, a = a * n + t[s + u & n - 1];
  301. i.i = r;
  302. i.j = o;
  303. return a
  304. };
  305. i.g(n)
  306. }
  307. function a(e, t, n, r, i) {
  308. n = [];
  309. i = typeof e;
  310. if (t && "object" == i)
  311. for (r in e)
  312. if (5 > r.indexOf("S")) try {
  313. n.push(a(e[r], t - 1))
  314. } catch (s) {}
  315. return n.length ? n : e + ("string" != i ? "\0" : "")
  316. }
  317. function f(e, t, r, i) {
  318. e += "";
  319. for (i = r = 0; i < e.length; i++) {
  320. var s = t,
  321. o = i & n - 1,
  322. u = (r ^= 19 * t[i & n - 1]) + e.charCodeAt(i);
  323. s[o] = u & n - 1
  324. }
  325. e = "";
  326. for (i in t) e += String.fromCharCode(t[i]);
  327. return e
  328. }
  329. t.seedrandom = function(l, p) {
  330. var v = [],
  331. m, l = f(a(p ? [l, e] : arguments.length ? l : [(new Date).getTime(), e, window], 3), v);
  332. m = new u(v);
  333. f(m.S, e);
  334. t.random = function() {
  335. for (var e = m.g(r), t = o, u = 0; e < i;) e = (e + u) * n, t *= n, u = m.g(1);
  336. for (; e >= s;) e /= 2, t /= 2, u >>>= 1;
  337. return (e + u) / t
  338. };
  339. return l
  340. };
  341. o = Math.pow(n, r);
  342. i = Math.pow(2, i);
  343. s = 2 * i;
  344. f(Math.random(), e)
  345. })([], Random, 256, 6, 52);
  346. (window._gsQueue || (window._gsQueue = [])).push(function() {
  347. _gsDefine("easing.Back", ["easing.Ease"], function(e) {
  348. var t = window.com.greensock._class,
  349. n = function(n, r) {
  350. var i = t("easing." + n, function() {}, !0),
  351. s = i.prototype = new e;
  352. s.constructor = i;
  353. s.getRatio = r;
  354. return i
  355. },
  356. r = function(n, r) {
  357. var i = t("easing." + n, function(e) {
  358. this._p1 = e || 0 === e ? e : 1.70158;
  359. this._p2 = 1.525 * this._p1
  360. }, !0),
  361. s = i.prototype = new e;
  362. s.constructor = i;
  363. s.getRatio = r;
  364. s.config = function(e) {
  365. return new i(e)
  366. };
  367. return i
  368. },
  369. i = r("BackOut", function(e) {
  370. return (e -= 1) * e * ((this._p1 + 1) * e + this._p1) + 1
  371. }),
  372. s = r("BackIn", function(e) {
  373. return e * e * ((this._p1 + 1) * e - this._p1)
  374. }),
  375. r = r("BackInOut", function(e) {
  376. return 1 > (e *= 2) ? .5 * e * e * ((this._p2 + 1) * e - this._p2) : .5 * ((e -= 2) * e * ((this._p2 + 1) * e + this._p2) + 2)
  377. }),
  378. o = n("BounceOut", function(e) {
  379. return e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + .75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + .9375 : 7.5625 * (e -= 2.625 / 2.75) * e + .984375
  380. }),
  381. u = n("BounceIn", function(e) {
  382. return (e = 1 - e) < 1 / 2.75 ? 1 - 7.5625 * e * e : e < 2 / 2.75 ? 1 - (7.5625 * (e -= 1.5 / 2.75) * e + .75) : e < 2.5 / 2.75 ? 1 - (7.5625 * (e -= 2.25 / 2.75) * e + .9375) : 1 - (7.5625 * (e -= 2.625 / 2.75) * e + .984375)
  383. }),
  384. a = n("BounceInOut", function(e) {
  385. var t = .5 > e,
  386. e = t ? 1 - 2 * e : 2 * e - 1,
  387. e = e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + .75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + .9375 : 7.5625 * (e -= 2.625 / 2.75) * e + .984375;
  388. return t ? .5 * (1 - e) : .5 * e + .5
  389. }),
  390. f = n("CircOut", function(e) {
  391. return Math.sqrt(1 - (e -= 1) * e)
  392. }),
  393. l = n("CircIn", function(e) {
  394. return -(Math.sqrt(1 - e * e) - 1)
  395. }),
  396. c = n("CircInOut", function(e) {
  397. return 1 > (e *= 2) ? -.5 * (Math.sqrt(1 - e * e) - 1) : .5 * (Math.sqrt(1 - (e -= 2) * e) + 1)
  398. }),
  399. h = 2 * Math.PI,
  400. p = function(n, r, i) {
  401. var s = t("easing." + n, function(e, t) {
  402. e = e || 0;
  403. this._p1 = !e || 1 > e ? 1 : e;
  404. this._p2 = t || i;
  405. this._p3 = this._p2 / h * Math.asin(1 / this._p1)
  406. }, !0),
  407. n = s.prototype = new e;
  408. n.constructor = s;
  409. n.getRatio = r;
  410. n.config = function(e, t) {
  411. return new s(e, t)
  412. };
  413. return s
  414. },
  415. d = p("ElasticOut", function(e) {
  416. return this._p1 * Math.pow(2, -10 * e) * Math.sin((e - this._p3) * h / this._p2) + 1
  417. }, .3),
  418. v = p("ElasticIn", function(e) {
  419. return -(this._p1 * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - this._p3) * h / this._p2))
  420. }, .3),
  421. p = p("ElasticInOut", function(e) {
  422. return 1 > (e *= 2) ? -.5 * this._p1 * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - this._p3) * h / this._p2) : .5 * this._p1 * Math.pow(2, -10 * (e -= 1)) * Math.sin((e - this._p3) * h / this._p2) + 1
  423. }, .45),
  424. m = n("ExpoOut", function(e) {
  425. return 1 - Math.pow(2, -10 * e)
  426. }),
  427. g = n("ExpoIn", function(e) {
  428. return Math.pow(2, 10 * (e - 1)) - .001
  429. }),
  430. y = n("ExpoInOut", function(e) {
  431. return 1 > (e *= 2) ? .5 * Math.pow(2, 10 * (e - 1)) : .5 * (2 - Math.pow(2, -10 * (e - 1)))
  432. }),
  433. b = Math.PI / 2,
  434. w = n("SineOut", function(e) {
  435. return Math.sin(e * b)
  436. }),
  437. E = n("SineIn", function(e) {
  438. return -Math.cos(e * b) + 1
  439. }),
  440. n = n("SineInOut", function(e) {
  441. return -.5 * (Math.cos(Math.PI * e) - 1)
  442. }),
  443. S = t("easing.SlowMo", function(e, t, n) {
  444. null == e ? e = .7 : 1 < e && (e = 1);
  445. this._p = 1 != e ? t || 0 === t ? t : .7 : 0;
  446. this._p1 = (1 - e) / 2;
  447. this._p2 = e;
  448. this._p3 = this._p1 + this._p2;
  449. this._calcEnd = !0 === n
  450. }, !0),
  451. x = S.prototype = new e;
  452. x.constructor = S;
  453. x.getRatio = function(e) {
  454. var t = e + (.5 - e) * this._p;
  455. return e < this._p1 ? this._calcEnd ? 1 - (e = 1 - e / this._p1) * e : t - (e = 1 - e / this._p1) * e * e * e * t : e > this._p3 ? this._calcEnd ? 1 - (e = (e - this._p3) / this._p1) * e : t + (e - t) * (e = (e - this._p3) / this._p1) * e * e * e : this._calcEnd ? 1 : t
  456. };
  457. S.ease = new S(.7, .7);
  458. x.config = S.config = function(e, t, n) {
  459. return new S(e, t, n)
  460. };
  461. var T = t("easing.SteppedEase", function(e) {
  462. e = e || 1;
  463. this._p1 = 1 / e;
  464. this._p2 = e + 1
  465. }, !0),
  466. x = T.prototype = new e;
  467. x.constructor = T;
  468. x.getRatio = function(e) {
  469. 0 > e ? e = 0 : 1 <= e && (e = .999999999);
  470. return (this._p2 * e >> 0) * this._p1
  471. };
  472. x.config = T.config = function(e) {
  473. return new T(e)
  474. };
  475. t("easing.Bounce", {
  476. easeOut: new o,
  477. easeIn: new u,
  478. easeInOut: new a
  479. }, !0);
  480. t("easing.Circ", {
  481. easeOut: new f,
  482. easeIn: new l,
  483. easeInOut: new c
  484. }, !0);
  485. t("easing.Elastic", {
  486. easeOut: new d,
  487. easeIn: new v,
  488. easeInOut: new p
  489. }, !0);
  490. t("easing.Expo", {
  491. easeOut: new m,
  492. easeIn: new g,
  493. easeInOut: new y
  494. }, !0);
  495. t("easing.Sine", {
  496. easeOut: new w,
  497. easeIn: new E,
  498. easeInOut: new n
  499. }, !0);
  500. return {
  501. easeOut: new i,
  502. easeIn: new s,
  503. easeInOut: new r
  504. }
  505. }, !0)
  506. });
  507. window._gsDefine && _gsQueue.pop()();
  508. (function(e) {
  509. var t = function(t) {
  510. var t = t.split("."),
  511. n = e,
  512. r;
  513. for (r = 0; r < t.length; r++) n[t[r]] = n = n[t[r]] || {};
  514. return n
  515. },
  516. n = t("com.greensock"),
  517. r, i, s, o, u = {},
  518. a = function(n, r, i, s) {
  519. this.sc = u[n] ? u[n].sc : [];
  520. u[n] = this;
  521. this.gsClass = null;
  522. this.def = i;
  523. var o = r || [],
  524. f = [];
  525. this.check = function(r) {
  526. for (var l = o.length, c = 0, h; - 1 < --l;)(h = u[o[l]] || new a(o[l])).gsClass ? f[l] = h.gsClass : (c++, r && h.sc.push(this));
  527. if (0 === c && i) {
  528. var r = ("com.greensock." + n).split("."),
  529. l = r.pop(),
  530. p = t(r.join("."))[l] = this.gsClass = i.apply(i, f);
  531. s && ((e.GreenSockGlobals || e)[l] = p, "function" === typeof define && define.amd ? define((e.GreenSockAMDPath ? e.GreenSockAMDPath + "/" : "") + n.split(".").join("/"), [], function() {
  532. return p
  533. }) : "undefined" !== typeof module && module.exports && (module.exports = p));
  534. for (l = 0; l < this.sc.length; l++) this.sc[l].check(!1)
  535. }
  536. };
  537. this.check(!0)
  538. },
  539. f = n._class = function(e, t, n) {
  540. new a(e, [], function() {
  541. return t
  542. }, n);
  543. return t
  544. };
  545. e._gsDefine = function(e, t, n, r) {
  546. return new a(e, t, n, r)
  547. };
  548. var l = [0, 0, 1, 1],
  549. c = [],
  550. h = f("easing.Ease", function(e, t, n, r) {
  551. this._func = e;
  552. this._type = n || 0;
  553. this._power = r || 0;
  554. this._params = t ? l.concat(t) : l
  555. }, !0);
  556. s = h.prototype;
  557. s._calcEnd = !1;
  558. s.getRatio = function(e) {
  559. if (this._func) return this._params[0] = e, this._func.apply(null, this._params);
  560. var t = this._type,
  561. n = this._power,
  562. r = 1 === t ? 1 - e : 2 === t ? e : .5 > e ? 2 * e : 2 * (1 - e);
  563. 1 === n ? r *= r : 2 === n ? r *= r * r : 3 === n ? r *= r * r * r : 4 === n && (r *= r * r * r * r);
  564. return 1 === t ? 1 - r : 2 === t ? r : .5 > e ? r / 2 : 1 - r / 2
  565. };
  566. r = ["Linear", "Quad", "Cubic", "Quart", "Quint"];
  567. for (i = r.length; - 1 < --i;) s = f("easing." + r[i], function() {}, !0), o = f("easing.Power" + i, function() {}, !0), s.easeOut = o.easeOut = new h(null, null, 1, i), s.easeIn = o.easeIn = new h(null, null, 2, i), s.easeInOut = o.easeInOut = new h(null, null, 3, i);
  568. f("easing.Strong", n.easing.Power4, !0);
  569. n.easing.Linear.easeNone = n.easing.Linear.easeIn;
  570. s = f("events.EventDispatcher", function(e) {
  571. this._listeners = {};
  572. this._eventTarget = e || this
  573. }).prototype;
  574. s.addEventListener = function(e, t, n, r, i) {
  575. var i = i || 0,
  576. s = this._listeners[e],
  577. o = 0,
  578. u;
  579. null == s && (this._listeners[e] = s = []);
  580. for (u = s.length; - 1 < --u;) e = s[u], e.c === t ? s.splice(u, 1) : 0 === o && e.pr < i && (o = u + 1);
  581. s.splice(o, 0, {
  582. c: t,
  583. s: n,
  584. up: r,
  585. pr: i
  586. })
  587. };
  588. s.removeEventListener = function(e, t) {
  589. var n = this._listeners[e];
  590. if (n)
  591. for (var r = n.length; - 1 < --r;)
  592. if (n[r].c === t) {
  593. n.splice(r, 1);
  594. break
  595. }
  596. };
  597. s.dispatchEvent = function(e) {
  598. var t = this._listeners[e];
  599. if (t)
  600. for (var n = t.length, r, i = this._eventTarget; - 1 < --n;) r = t[n], r.up ? r.c.call(r.s || i, {
  601. type: e,
  602. target: i
  603. }) : r.c.call(r.s || i)
  604. };
  605. var p = e.requestAnimationFrame,
  606. d = e.cancelAnimationFrame,
  607. v = Date.now || function() {
  608. return (new Date).getTime()
  609. };
  610. r = ["ms", "moz", "webkit", "o"];
  611. for (i = r.length; - 1 < --i && !p;) p = e[r[i] + "RequestAnimationFrame"], d = e[r[i] + "CancelAnimationFrame"] || e[r[i] + "CancelRequestAnimationFrame"];
  612. d || (d = function(t) {
  613. e.clearTimeout(t)
  614. });
  615. f("Ticker", function(t, n) {
  616. this.frame = this.time = 0;
  617. var r = this,
  618. i = v(),
  619. s = !1 !== n,
  620. o, u, a, f, l;
  621. this.tick = function() {
  622. r.time = (v() - i) / 1e3;
  623. if (!o || r.time >= l) r.frame++, l = r.time + f - (r.time - l) - 5e-4, l <= r.time && (l = r.time + .001), r.dispatchEvent("tick");
  624. a = u(r.tick)
  625. };
  626. this.fps = function(t) {
  627. if (!arguments.length) return o;
  628. o = t;
  629. f = 1 / (o || 60);
  630. l = this.time + f;
  631. u = 0 === o ? function() {} : !s || !p ? function(t) {
  632. return e.setTimeout(t, 1e3 * (l - r.time) + 1 >> 0 || 1)
  633. } : p;
  634. d(a);
  635. a = u(r.tick)
  636. };
  637. this.useRAF = function(e) {
  638. if (!arguments.length) return s;
  639. s = e;
  640. this.fps(o)
  641. };
  642. this.fps(t)
  643. });
  644. s = n.Ticker.prototype = new n.events.EventDispatcher;
  645. s.constructor = n.Ticker;
  646. var m = f("core.Animation", function(e, t) {
  647. this.vars = t || {};
  648. this._duration = this._totalDuration = e || 0;
  649. this._delay = Number(this.vars.delay) || 0;
  650. this._timeScale = 1;
  651. this._active = !0 == this.vars.immediateRender;
  652. this.data = this.vars.data;
  653. this._reversed = !0 == this.vars.reversed;
  654. if (N) {
  655. var n = this.vars.useFrames ? T : N;
  656. n.insert(this, n._time);
  657. this.vars.paused && this.paused(!0)
  658. }
  659. }),
  660. g = m.ticker = new n.Ticker;
  661. s = m.prototype;
  662. s._dirty = s._gc = s._initted = s._paused = !1;
  663. s._totalTime = s._time = 0;
  664. s._rawPrevTime = -1;
  665. s._next = s._last = s._onUpdate = s._timeline = s.timeline = null;
  666. s._paused = !1;
  667. s.play = function(e, t) {
  668. arguments.length && this.seek(e, t);
  669. this.reversed(!1);
  670. return this.paused(!1)
  671. };
  672. s.pause = function(e, t) {
  673. arguments.length && this.seek(e, t);
  674. return this.paused(!0)
  675. };
  676. s.resume = function(e, t) {
  677. arguments.length && this.seek(e, t);
  678. return this.paused(!1)
  679. };
  680. s.seek = function(e, t) {
  681. return this.totalTime(Number(e), !1 != t)
  682. };
  683. s.restart = function(e, t) {
  684. this.reversed(!1);
  685. this.paused(!1);
  686. return this.totalTime(e ? -this._delay : 0, !1 != t)
  687. };
  688. s.reverse = function(e, t) {
  689. arguments.length && this.seek(e || this.totalDuration(), t);
  690. this.reversed(!0);
  691. return this.paused(!1)
  692. };
  693. s.render = function() {};
  694. s.invalidate = function() {
  695. return this
  696. };
  697. s._enabled = function(e, t) {
  698. this._gc = !e;
  699. this._active = e && !this._paused && 0 < this._totalTime && this._totalTime < this._totalDuration;
  700. !0 != t && (e && null == this.timeline ? this._timeline.insert(this, this._startTime - this._delay) : !e && null != this.timeline && this._timeline._remove(this, !0));
  701. return !1
  702. };
  703. s._kill = function() {
  704. return this._enabled(!1, !1)
  705. };
  706. s.kill = function(e, t) {
  707. this._kill(e, t);
  708. return this
  709. };
  710. s._uncache = function(e) {
  711. for (e = e ? this : this.timeline; e;) e._dirty = !0, e = e.timeline;
  712. return this
  713. };
  714. s.eventCallback = function(e, t, n, r) {
  715. if (null == e) return null;
  716. if ("on" === e.substr(0, 2)) {
  717. if (1 === arguments.length) return this.vars[e];
  718. if (null == t) delete this.vars[e];
  719. else if (this.vars[e] = t, this.vars[e + "Params"] = n, this.vars[e + "Scope"] = r, n)
  720. for (var i = n.length; - 1 < --i;) "{self}" === n[i] && (n = this.vars[e + "Params"] = n.concat(), n[i] = this);
  721. "onUpdate" === e && (this._onUpdate = t)
  722. }
  723. return this
  724. };
  725. s.delay = function(e) {
  726. if (!arguments.length) return this._delay;
  727. this._timeline.smoothChildTiming && this.startTime(this._startTime + e - this._delay);
  728. this._delay = e;
  729. return this
  730. };
  731. s.duration = function(e) {
  732. if (!arguments.length) return this._dirty = !1, this._duration;
  733. this._duration = this._totalDuration = e;
  734. this._uncache(!0);
  735. this._timeline.smoothChildTiming && this._active && 0 != e && this.totalTime(this._totalTime * (e / this._duration), !0);
  736. return this
  737. };
  738. s.totalDuration = function(e) {
  739. this._dirty = !1;
  740. return !arguments.length ? this._totalDuration : this.duration(e)
  741. };
  742. s.time = function(e, t) {
  743. if (!arguments.length) return this._time;
  744. this._dirty && this.totalDuration();
  745. e > this._duration && (e = this._duration);
  746. return this.totalTime(e, t)
  747. };
  748. s.totalTime = function(e, t) {
  749. if (!arguments.length) return this._totalTime;
  750. if (this._timeline) {
  751. 0 > e && (e += this.totalDuration());
  752. if (this._timeline.smoothChildTiming && (this._dirty && this.totalDuration(), e > this._totalDuration && (e = this._totalDuration), this._startTime = (this._paused ? this._pauseTime : this._timeline._time) - (!this._reversed ? e : this._totalDuration - e) / this._timeScale, this._timeline._dirty || this._uncache(!1), !this._timeline._active))
  753. for (var n = this._timeline; n._timeline;) n.totalTime(n._totalTime, !0), n = n._timeline;
  754. this._gc && this._enabled(!0, !1);
  755. this._totalTime != e && this.render(e, t, !1)
  756. }
  757. return this
  758. };
  759. s.startTime = function(e) {
  760. if (!arguments.length) return this._startTime;
  761. e != this._startTime && (this._startTime = e, this.timeline && this.timeline._sortChildren && this.timeline.insert(this, e - this._delay));
  762. return this
  763. };
  764. s.timeScale = function(e) {
  765. if (!arguments.length) return this._timeScale;
  766. e = e || 1e-6;
  767. if (this._timeline && this._timeline.smoothChildTiming) {
  768. var t = this._pauseTime || 0 == this._pauseTime ? this._pauseTime : this._timeline._totalTime;
  769. this._startTime = t - (t - this._startTime) * this._timeScale / e
  770. }
  771. this._timeScale = e;
  772. return this._uncache(!1)
  773. };
  774. s.reversed = function(e) {
  775. if (!arguments.length) return this._reversed;
  776. e != this._reversed && (this._reversed = e, this.totalTime(this._totalTime, !0));
  777. return this
  778. };
  779. s.paused = function(e) {
  780. if (!arguments.length) return this._paused;
  781. e != this._paused && this._timeline && (!e && this._timeline.smoothChildTiming && (this._startTime += this._timeline.rawTime() - this._pauseTime, this._uncache(!1)), this._pauseTime = e ? this._timeline.rawTime() : null, this._paused = e, this._active = !this._paused && 0 < this._totalTime && this._totalTime < this._totalDuration);
  782. this._gc && (e || this._enabled(!0, !1));
  783. return this
  784. };
  785. n = f("core.SimpleTimeline", function(e) {
  786. m.call(this, 0, e);
  787. this.autoRemoveChildren = this.smoothChildTiming = !0
  788. });
  789. s = n.prototype = new m;
  790. s.constructor = n;
  791. s.kill()._gc = !1;
  792. s._first = s._last = null;
  793. s._sortChildren = !1;
  794. s.insert = function(e, t) {
  795. e._startTime = Number(t || 0) + e._delay;
  796. e._paused && this !== e._timeline && (e._pauseTime = e._startTime + (this.rawTime() - e._startTime) / e._timeScale);
  797. e.timeline && e.timeline._remove(e, !0);
  798. e.timeline = e._timeline = this;
  799. e._gc && e._enabled(!0, !0);
  800. var n = this._last;
  801. if (this._sortChildren)
  802. for (var r = e._startTime; n && n._startTime > r;) n = n._prev;
  803. n ? (e._next = n._next, n._next = e) : (e._next = this._first, this._first = e);
  804. e._next ? e._next._prev = e : this._last = e;
  805. e._prev = n;
  806. this._timeline && this._uncache(!0);
  807. return this
  808. };
  809. s._remove = function(e, t) {
  810. e.timeline === this && (t || e._enabled(!1, !0), e.timeline = null, e._prev ? e._prev._next = e._next : this._first === e && (this._first = e._next), e._next ? e._next._prev = e._prev : this._last === e && (this._last = e._prev), this._timeline && this._uncache(!0));
  811. return this
  812. };
  813. s.render = function(e, t) {
  814. var n = this._first,
  815. r;
  816. for (this._totalTime = this._time = this._rawPrevTime = e; n;) {
  817. r = n._next;
  818. if (n._active || e >= n._startTime && !n._paused) n._reversed ? n.render((!n._dirty ? n._totalDuration : n.totalDuration()) - (e - n._startTime) * n._timeScale, t, !1) : n.render((e - n._startTime) * n._timeScale, t, !1);
  819. n = r
  820. }
  821. };
  822. s.rawTime = function() {
  823. return this._totalTime
  824. };
  825. var y = f("TweenLite", function(e, t, n) {
  826. m.call(this, t, n);
  827. if (null == e) throw "Cannot tween an undefined reference.";
  828. this.target = e;
  829. this._overwrite = null == this.vars.overwrite ? x[y.defaultOverwrite] : "number" === typeof this.vars.overwrite ? this.vars.overwrite >> 0 : x[this.vars.overwrite];
  830. if ((e instanceof Array || e.jquery) && "object" === typeof e[0]) {
  831. this._targets = e.slice(0);
  832. this._propLookup = [];
  833. this._siblings = [];
  834. for (e = 0; e < this._targets.length; e++) n = this._targets[e], n.jquery ? (this._targets.splice(e--, 1), this._targets = this._targets.concat(n.constructor.makeArray(n))) : (this._siblings[e] = C(n, this, !1), 1 === this._overwrite && 1 < this._siblings[e].length && k(n, this, null, 1, this._siblings[e]))
  835. } else this._propLookup = {}, this._siblings = C(e, this, !1), 1 === this._overwrite && 1 < this._siblings.length && k(e, this, null, 1, this._siblings);
  836. (this.vars.immediateRender || 0 === t && 0 === this._delay && !1 != this.vars.immediateRender) && this.render(0, !1, !0)
  837. }, !0);
  838. s = y.prototype = new m;
  839. s.constructor = y;
  840. s.kill()._gc = !1;
  841. s.ratio = 0;
  842. s._firstPT = s._targets = s._overwrittenProps = null;
  843. s._notifyPluginsOfEnabled = !1;
  844. y.version = 12;
  845. y.defaultEase = s._ease = new h(null, null, 1, 1);
  846. y.defaultOverwrite = "auto";
  847. y.ticker = g;
  848. var b = y._plugins = {},
  849. w = {},
  850. E = 0,
  851. S = {
  852. ease: 1,
  853. delay: 1,
  854. overwrite: 1,
  855. onComplete: 1,
  856. onCompleteParams: 1,
  857. onCompleteScope: 1,
  858. useFrames: 1,
  859. runBackwards: 1,
  860. startAt: 1,
  861. onUpdate: 1,
  862. onUpdateParams: 1,
  863. onUpdateScope: 1,
  864. onStart: 1,
  865. onStartParams: 1,
  866. onStartScope: 1,
  867. onReverseComplete: 1,
  868. onReverseCompleteParams: 1,
  869. onReverseCompleteScope: 1,
  870. onRepeat: 1,
  871. onRepeatParams: 1,
  872. onRepeatScope: 1,
  873. easeParams: 1,
  874. yoyo: 1,
  875. orientToBezier: 1,
  876. immediateRender: 1,
  877. repeat: 1,
  878. repeatDelay: 1,
  879. data: 1,
  880. paused: 1,
  881. reversed: 1
  882. },
  883. x = {
  884. none: 0,
  885. all: 1,
  886. auto: 2,
  887. concurrent: 3,
  888. allOnStart: 4,
  889. preexisting: 5,
  890. "true": 1,
  891. "false": 0
  892. },
  893. T = m._rootFramesTimeline = new n,
  894. N = m._rootTimeline = new n;
  895. N._startTime = g.time;
  896. T._startTime = g.frame;
  897. N._active = T._active = !0;
  898. m._updateRoot = function() {
  899. N.render((g.time - N._startTime) * N._timeScale, !1, !1);
  900. T.render((g.frame - T._startTime) * T._timeScale, !1, !1);
  901. if (!(g.frame % 120)) {
  902. var e, t, n;
  903. for (n in w) {
  904. t = w[n].tweens;
  905. for (e = t.length; - 1 < --e;) t[e]._gc && t.splice(e, 1);
  906. 0 === t.length && delete w[n]
  907. }
  908. }
  909. };
  910. g.addEventListener("tick", m._updateRoot);
  911. var C = function(e, t, n) {
  912. var r = e._gsTweenID,
  913. i;
  914. if (!w[r || (e._gsTweenID = r = "t" + E++)]) w[r] = {
  915. target: e,
  916. tweens: []
  917. };
  918. if (t && (e = w[r].tweens, e[i = e.length] = t, n))
  919. for (; - 1 < --i;) e[i] === t && e.splice(i, 1);
  920. return w[r].tweens
  921. },
  922. k = function(e, t, n, r, i) {
  923. var s, o, u;
  924. if (1 === r || 4 <= r) {
  925. e = i.length;
  926. for (s = 0; s < e; s++)
  927. if ((u = i[s]) !== t) u._gc || u._enabled(!1, !1) && (o = !0);
  928. else if (5 === r) break;
  929. return o
  930. }
  931. var a = t._startTime + 1e-10,
  932. f = [],
  933. l = 0,
  934. c;
  935. for (s = i.length; - 1 < --s;)
  936. if (!((u = i[s]) === t || u._gc || u._paused)) u._timeline !== t._timeline ? (c = c || L(t, 0), 0 === L(u, c) && (f[l++] = u)) : u._startTime <= a && u._startTime + u.totalDuration() / u._timeScale + 1e-10 > a && ((0 === t._duration || !u._initted) && 2e-10 >= a - u._startTime || (f[l++] = u));
  937. for (s = l; - 1 < --s;)
  938. if (u = f[s], 2 === r && u._kill(n, e) && (o = !0), 2 !== r || !u._firstPT && u._initted) u._enabled(!1, !1) && (o = !0);
  939. return o
  940. },
  941. L = function(e, t) {
  942. for (var n = e._timeline, r = n._timeScale, i = e._startTime; n._timeline;) {
  943. i += n._startTime;
  944. r *= n._timeScale;
  945. if (n._paused) return -100;
  946. n = n._timeline
  947. }
  948. i /= r;
  949. return i > t ? i - t : !e._initted && 2e-10 > i - t ? 1e-10 : (i += e.totalDuration() / e._timeScale / r) > t ? 0 : i - t - 1e-10
  950. };
  951. s._init = function() {
  952. this.vars.startAt && (this.vars.startAt.overwrite = 0, this.vars.startAt.immediateRender = !0, y.to(this.target, 0, this.vars.startAt));
  953. var e, t;
  954. this._ease = this.vars.ease instanceof h ? this.vars.easeParams instanceof Array ? this.vars.ease.config.apply(this.vars.ease, this.vars.easeParams) : this.vars.ease : "function" === typeof this.vars.ease ? new h(this.vars.ease, this.vars.easeParams) : y.defaultEase;
  955. this._easeType = this._ease._type;
  956. this._easePower = this._ease._power;
  957. this._firstPT = null;
  958. if (this._targets)
  959. for (e = this._targets.length; - 1 < --e;) {
  960. if (this._initProps(this._targets[e], this._propLookup[e] = {}, this._siblings[e], this._overwrittenProps ? this._overwrittenProps[e] : null)) t = !0
  961. } else t = this._initProps(this.target, this._propLookup, this._siblings, this._overwrittenProps);
  962. t && y._onPluginEvent("_onInitAllProps", this);
  963. this._overwrittenProps && null == this._firstPT && "function" !== typeof this.target && this._enabled(!1, !1);
  964. if (this.vars.runBackwards)
  965. for (e = this._firstPT; e;) e.s += e.c, e.c = -e.c, e = e._next;
  966. this._onUpdate = this.vars.onUpdate;
  967. this._initted = !0
  968. };
  969. s._initProps = function(e, t, n, r) {
  970. var i, s, o, u, a;
  971. if (null == e) return !1;
  972. for (i in this.vars) {
  973. if (S[i]) {
  974. if ("onStartParams" === i || "onUpdateParams" === i || "onCompleteParams" === i || "onReverseCompleteParams" === i || "onRepeatParams" === i)
  975. if (a = this.vars[i])
  976. for (s = a.length; - 1 < --s;) "{self}" === a[s] && (a = this.vars[i] = a.concat(), a[s] = this)
  977. } else if (b[i] && (u = new b[i])._onInitTween(e, this.vars[i], this)) {
  978. this._firstPT = {
  979. _next: this._firstPT,
  980. t: u,
  981. p: "setRatio",
  982. s: 0,
  983. c: 1,
  984. f: !0,
  985. n: i,
  986. pg: !0,
  987. pr: u._priority
  988. };
  989. for (s = u._overwriteProps.length; - 1 < --s;) t[u._overwriteProps[s]] = this._firstPT;
  990. if (u._priority || u._onInitAllProps) o = !0;
  991. if (u._onDisable || u._onEnable) this._notifyPluginsOfEnabled = !0
  992. } else this._firstPT = t[i] = {
  993. _next: this._firstPT,
  994. t: e,
  995. p: i,
  996. f: "function" === typeof e[i],
  997. n: i,
  998. pg: !1,
  999. pr: 0
  1000. }, this._firstPT.s = !this._firstPT.f ? parseFloat(e[i]) : e[i.indexOf("set") || "function" !== typeof e["get" + i.substr(3)] ? i : "get" + i.substr(3)](), this._firstPT.c = "number" === typeof this.vars[i] ? this.vars[i] - this._firstPT.s : "string" === typeof this.vars[i] ? parseFloat(this.vars[i].split("=").join("")) : 0;
  1001. this._firstPT && this._firstPT._next && (this._firstPT._next._prev = this._firstPT)
  1002. }
  1003. return r && this._kill(r, e) ? this._initProps(e, t, n, r) : 1 < this._overwrite && this._firstPT && 1 < n.length && k(e, this, t, this._overwrite, n) ? (this._kill(t, e), this._initProps(e, t, n, r)) : o
  1004. };
  1005. s.render = function(e, t, n) {
  1006. var r = this._time,
  1007. i, s;
  1008. if (e >= this._duration) {
  1009. if (this._totalTime = this._time = this._duration, this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1, this._reversed || (i = !0, s = "onComplete"), 0 === this._duration) {
  1010. if (0 === e || 0 > this._rawPrevTime) this._rawPrevTime !== e && (n = !0);
  1011. this._rawPrevTime = e
  1012. }
  1013. } else if (0 >= e) {
  1014. this._totalTime = this._time = 0;
  1015. this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0;
  1016. if (0 !== r || 0 === this._duration && 0 < this._rawPrevTime) s = "onReverseComplete", i = this._reversed;
  1017. 0 > e ? (this._active = !1, 0 === this._duration && (0 <= this._rawPrevTime && (n = !0), this._rawPrevTime = e)) : this._initted || (n = !0)
  1018. } else if (this._totalTime = this._time = e, this._easeType) {
  1019. var o = e / this._duration,
  1020. u = this._easeType,
  1021. a = this._easePower;
  1022. if (1 === u || 3 === u && .5 <= o) o = 1 - o;
  1023. 3 === u && (o *= 2);
  1024. 1 === a ? o *= o : 2 === a ? o *= o * o : 3 === a ? o *= o * o * o : 4 === a && (o *= o * o * o * o);
  1025. this.ratio = 1 === u ? 1 - o : 2 === u ? o : .5 > e / this._duration ? o / 2 : 1 - o / 2
  1026. } else this.ratio = this._ease.getRatio(e / this._duration); if (this._time !== r || n) {
  1027. this._initted || (this._init(), !i && this._time && (this.ratio = this._ease.getRatio(this._time / this._duration)));
  1028. !this._active && !this._paused && (this._active = !0);
  1029. if (0 === r && this.vars.onStart && (0 !== this._time || 0 === this._duration)) t || this.vars.onStart.apply(this.vars.onStartScope || this, this.vars.onStartParams || c);
  1030. for (e = this._firstPT; e;) {
  1031. if (e.f) e.t[e.p](e.c * this.ratio + e.s);
  1032. else e.t[e.p] = e.c * this.ratio + e.s;
  1033. e = e._next
  1034. }
  1035. this._onUpdate && (t || this._onUpdate.apply(this.vars.onUpdateScope || this, this.vars.onUpdateParams || c));
  1036. s && !this._gc && (i && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), t || this.vars[s] && this.vars[s].apply(this.vars[s + "Scope"] || this, this.vars[s + "Params"] || c))
  1037. }
  1038. };
  1039. s._kill = function(e, t) {
  1040. "all" === e && (e = null);
  1041. if (null == e && (null == t || t == this.target)) return this._enabled(!1, !1);
  1042. var t = t || this._targets || this.target,
  1043. n, r, i, s, o, u, a;
  1044. if ((t instanceof Array || t.jquery) && "object" === typeof t[0])
  1045. for (n = t.length; - 1 < --n;) this._kill(e, t[n]) && (o = !0);
  1046. else {
  1047. if (this._targets)
  1048. for (n = this._targets.length; - 1 < --n;) {
  1049. if (t === this._targets[n]) {
  1050. s = this._propLookup[n] || {};
  1051. this._overwrittenProps = this._overwrittenProps || [];
  1052. r = this._overwrittenProps[n] = e ? this._overwrittenProps[n] || {} : "all";
  1053. break
  1054. }
  1055. } else {
  1056. if (t !== this.target) return !1;
  1057. s = this._propLookup;
  1058. r = this._overwrittenProps = e ? this._overwrittenProps || {} : "all"
  1059. } if (s)
  1060. for (i in u = e || s, a = e != r && "all" != r && e != s && (null == e || !0 != e._tempKill), u) {
  1061. if (n = s[i]) {
  1062. n.pg && n.t._kill(u) && (o = !0);
  1063. if (!n.pg || 0 === n.t._overwriteProps.length) n._prev ? n._prev._next = n._next : n === this._firstPT && (this._firstPT = n._next), n._next && (n._next._prev = n._prev), n._next = n._prev = null;
  1064. delete s[i]
  1065. }
  1066. a && (r[i] = 1)
  1067. }
  1068. }
  1069. return o
  1070. };
  1071. s.invalidate = function() {
  1072. this._notifyPluginsOfEnabled && y._onPluginEvent("_onDisable", this);
  1073. this._onUpdate = this._overwrittenProps = this._firstPT = null;
  1074. this._initted = this._active = this._notifyPluginsOfEnabled = !1;
  1075. this._propLookup = this._targets ? {} : [];
  1076. return this
  1077. };
  1078. s._enabled = function(e, t) {
  1079. if (e && this._gc)
  1080. if (this._targets)
  1081. for (var n = this._targets.length; - 1 < --n;) this._siblings[n] = C(this._targets[n], this, !0);
  1082. else this._siblings = C(this.target, this, !0);
  1083. m.prototype._enabled.call(this, e, t);
  1084. return this._notifyPluginsOfEnabled && this._firstPT ? y._onPluginEvent(e ? "_onEnable" : "_onDisable", this) : !1
  1085. };
  1086. y.to = function(e, t, n) {
  1087. return new y(e, t, n)
  1088. };
  1089. y.from = function(e, t, n) {
  1090. n.runBackwards = !0;
  1091. !1 != n.immediateRender && (n.immediateRender = !0);
  1092. return new y(e, t, n)
  1093. };
  1094. y.fromTo = function(e, t, n, r) {
  1095. r.startAt = n;
  1096. n.immediateRender && (r.immediateRender = !0);
  1097. return new y(e, t, r)
  1098. };
  1099. y.delayedCall = function(e, t, n, r, i) {
  1100. return new y(t, 0, {
  1101. delay: e,
  1102. onComplete: t,
  1103. onCompleteParams: n,
  1104. onCompleteScope: r,
  1105. onReverseComplete: t,
  1106. onReverseCompleteParams: n,
  1107. onReverseCompleteScope: r,
  1108. immediateRender: !1,
  1109. useFrames: i,
  1110. overwrite: 0
  1111. })
  1112. };
  1113. y.set = function(e, t) {
  1114. return new y(e, 0, t)
  1115. };
  1116. y.killTweensOf = y.killDelayedCallsTo = function(e, t) {
  1117. for (var n = y.getTweensOf(e), r = n.length; - 1 < --r;) n[r]._kill(t, e)
  1118. };
  1119. y.getTweensOf = function(e) {
  1120. if (null != e) {
  1121. var t, n, r;
  1122. if ((e instanceof Array || e.jquery) && "object" === typeof e[0]) {
  1123. t = e.length;
  1124. for (n = []; - 1 < --t;) n = n.concat(y.getTweensOf(e[t]));
  1125. for (t = n.length; - 1 < --t;) {
  1126. r = n[t];
  1127. for (e = t; - 1 < --e;) r === n[e] && n.splice(t, 1)
  1128. }
  1129. } else {
  1130. n = C(e).concat();
  1131. for (t = n.length; - 1 < --t;) n[t]._gc && n.splice(t, 1)
  1132. }
  1133. return n
  1134. }
  1135. };
  1136. var A = f("plugins.TweenPlugin", function(e, t) {
  1137. this._overwriteProps = (e || "").split(",");
  1138. this._propName = this._overwriteProps[0];
  1139. this._priority = t || 0
  1140. }, !0);
  1141. s = A.prototype;
  1142. A.version = 12;
  1143. A.API = 2;
  1144. s._firstPT = null;
  1145. s._addTween = function(e, t, n, r, i, s) {
  1146. var o;
  1147. if (null != r && (o = "number" === typeof r || "=" !== r.charAt(1) ? Number(r) - n : Number(r.split("=").join("")))) this._firstPT = {
  1148. _next: this._firstPT,
  1149. t: e,
  1150. p: t,
  1151. s: n,
  1152. c: o,
  1153. f: "function" == typeof e[t],
  1154. n: i || t,
  1155. r: s
  1156. }, this._firstPT._next && (this._firstPT._next._prev = this._firstPT)
  1157. };
  1158. s.setRatio = function(e) {
  1159. for (var t = this._firstPT, n; t;) {
  1160. n = t.c * e + t.s;
  1161. t.r && (n = n + (0 < n ? .5 : -.5) >> 0);
  1162. if (t.f) t.t[t.p](n);
  1163. else t.t[t.p] = n;
  1164. t = t._next
  1165. }
  1166. };
  1167. s._kill = function(e) {
  1168. if (null != e[this._propName]) this._overwriteProps = [];
  1169. else
  1170. for (var t = this._overwriteProps.length; - 1 < --t;) null != e[this._overwriteProps[t]] && this._overwriteProps.splice(t, 1);
  1171. for (t = this._firstPT; t;) null != e[t.n] && ((t._next && (t._next._prev = t._prev), t._prev) ? (t._prev._next = t._next, t._prev = null) : this._firstPT === t && (this._firstPT = t._next)), t = t._next;
  1172. return !1
  1173. };
  1174. s._roundProps = function(e, t) {
  1175. for (var n = this._firstPT; n;) {
  1176. if (e[this._propName] || null != n.n && e[n.n.split(this._propName + "_").join("")]) n.r = t;
  1177. n = n._next
  1178. }
  1179. };
  1180. y._onPluginEvent = function(e, t) {
  1181. var n = t._firstPT,
  1182. r;
  1183. if ("_onInitAllProps" === e) {
  1184. for (var i, s, o, u; n;) {
  1185. u = n._next;
  1186. for (i = s; i && i.pr > n.pr;) i = i._next;
  1187. (n._prev = i ? i._prev : o) ? n._prev._next = n: s = n;
  1188. (n._next = i) ? i._prev = n: o = n;
  1189. n = u
  1190. }
  1191. n = t._firstPT = s
  1192. }
  1193. for (; n;) n.pg && "function" === typeof n.t[e] && n.t[e]() && (r = !0), n = n._next;
  1194. return r
  1195. };
  1196. A.activate = function(e) {
  1197. for (var t = e.length; - 1 < --t;) e[t].API === A.API && (y._plugins[(new e[t])._propName] = e[t]);
  1198. return !0
  1199. };
  1200. if (r = e._gsQueue) {
  1201. for (i = 0; i < r.length; i++) r[i]();
  1202. for (s in u) u[s].def || console.log("Warning: TweenLite encountered missing dependency: com.greensock." + s)
  1203. }
  1204. })(window);
  1205. (window._gsQueue || (window._gsQueue = [])).push(function() {
  1206. _gsDefine("TimelineMax", ["TimelineLite", "TweenLite", "easing.Ease"], function(e, t, n) {
  1207. var r = function(t) {
  1208. e.call(this, t);
  1209. this._repeat = this.vars.repeat || 0;
  1210. this._repeatDelay = this.vars.repeatDelay || 0;
  1211. this._cycle = 0;
  1212. this._yoyo = !0 == this.vars.yoyo;
  1213. this._dirty = !0
  1214. },
  1215. i = [],
  1216. s = new n(null, null, 1, 0),
  1217. n = r.prototype = new e;
  1218. n.constructor = r;
  1219. n.kill()._gc = !1;
  1220. r.version = 12;
  1221. n.invalidate = function() {
  1222. this._yoyo = !0 == this.vars.yoyo;
  1223. this._repeat = this.vars.repeat || 0;
  1224. this._repeatDelay = this.vars.repeatDelay || 0;
  1225. this._uncache(!0);
  1226. return e.prototype.invalidate.call(this)
  1227. };
  1228. n.addCallback = function(e, n, r, i) {
  1229. return this.insert(t.delayedCall(0, e, r, i), n)
  1230. };
  1231. n.removeCallback = function(e, t) {
  1232. if (null == t) this._kill(null, e);
  1233. else
  1234. for (var n = this.getTweensOf(e, !1), r = n.length, i = this._parseTimeOrLabel(t, !1); - 1 < --r;) n[r]._startTime === i && n[r]._enabled(!1, !1);
  1235. return this
  1236. };
  1237. n.tweenTo = function(e, n) {
  1238. var n = n || {},
  1239. r = {
  1240. ease: s,
  1241. overwrite: 2,
  1242. useFrames: this.usesFrames(),
  1243. immediateRender: !1
  1244. },
  1245. o, u;
  1246. for (o in n) r[o] = n[o];
  1247. r.time = this._parseTimeOrLabel(e, !1);
  1248. u = new t(this, Math.abs(Number(r.time) - this._time) / this._timeScale || .001, r);
  1249. r.onStart = function() {
  1250. u.target.paused(!0);
  1251. u.vars.time != u.target.time() && u.duration(Math.abs(u.vars.time - u.target.time()) / u.target._timeScale);
  1252. n.onStart && n.onStart.apply(n.onStartScope || u, n.onStartParams || i)
  1253. };
  1254. return u
  1255. };
  1256. n.tweenFromTo = function(e, t, n) {
  1257. n = n || {};
  1258. n.startAt = {
  1259. time: this._parseTimeOrLabel(e, !1)
  1260. };
  1261. e = this.tweenTo(t, n);
  1262. return e.duration(Math.abs(e.vars.time - e.vars.startAt.time) / this._timeScale || .001)
  1263. };
  1264. n.render = function(e, t, n) {
  1265. this._gc && this._enabled(!0, !1);
  1266. this._active = !this._paused;
  1267. var r = !this._dirty ? this._totalDuration : this.totalDuration(),
  1268. s = this._time,
  1269. o = this._totalTime,
  1270. u = this._startTime,
  1271. a = this._timeScale,
  1272. f = this._rawPrevTime,
  1273. l = this._paused,
  1274. c = this._cycle,
  1275. h, p;
  1276. if (e >= r) {
  1277. this._locked || (this._totalTime = r, this._cycle = this._repeat);
  1278. if (!this._reversed && !this._hasPausedChild() && (h = !0, p = "onComplete", 0 === this._duration && (0 === e || 0 > this._rawPrevTime))) this._rawPrevTime !== e && (n = !0);
  1279. this._rawPrevTime = e;
  1280. this._yoyo && 0 !== (this._cycle & 1) ? (this._time = 0, e = -1e-6) : (this._time = this._duration, e = this._duration + 1e-6)
  1281. } else if (0 >= e) {
  1282. this._locked || (this._totalTime = this._cycle = 0);
  1283. this._time = 0;
  1284. if (0 !== s || 0 === this._duration && 0 < this._rawPrevTime) p = "onReverseComplete", h = this._reversed;
  1285. 0 > e ? (this._active = !1, 0 === this._duration && 0 <= this._rawPrevTime && (n = !0)) : this._initted || (n = !0);
  1286. this._rawPrevTime = e;
  1287. e = -1e-6
  1288. } else if (this._time = this._rawPrevTime = e, !this._locked && (this._totalTime = e, 0 !== this._repeat))(e = this._duration + this._repeatDelay, this._cycle = this._totalTime / e >> 0, 0 !== this._cycle && this._cycle === this._totalTime / e && this._cycle--, this._time = this._totalTime - this._cycle * e, this._yoyo && 0 != (this._cycle & 1) && (this._time = this._duration - this._time), this._time > this._duration) ? (this._time = this._duration, e = this._duration + 1e-6) : 0 > this._time ? (this._time = 0, e = -1e-6) : e = this._time;
  1289. if (this._cycle !== c && !this._locked) {
  1290. var d = this._yoyo && 0 !== (c & 1),
  1291. v = d === (this._yoyo && 0 !== (this._cycle & 1)),
  1292. m = this._totalTime,
  1293. g = this._cycle,
  1294. y = this._rawPrevTime,
  1295. b = this._time;
  1296. this._totalTime = c * this._duration;
  1297. this._cycle < c ? d = !d : this._totalTime += this._duration;
  1298. this._time = s;
  1299. this._rawPrevTime = f;
  1300. this._cycle = c;
  1301. this._locked = !0;
  1302. s = d ? 0 : this._duration;
  1303. this.render(s, t, !1);
  1304. t || this._gc || this.vars.onRepeat && this.vars.onRepeat.apply(this.vars.onRepeatScope || this, vars.onRepeatParams || i);
  1305. v && (s = d ? this._duration + 1e-6 : -1e-6, this.render(s, !0, !1));
  1306. this._time = b;
  1307. this._totalTime = m;
  1308. this._cycle = g;
  1309. this._rawPrevTime = y;
  1310. this._locked = !1
  1311. }
  1312. if (this._time !== s || n) {
  1313. this._initted || (this._initted = !0);
  1314. 0 === o && this.vars.onStart && 0 !== this._totalTime && (t || this.vars.onStart.apply(this.vars.onStartScope || this, this.vars.onStartParams || i));
  1315. if (this._time > s)
  1316. for (n = this._first; n;) {
  1317. o = n._next;
  1318. if (this._paused && !l) break;
  1319. else if (n._active || n._startTime <= this._time && !n._paused && !n._gc) n._reversed ? n.render((!n._dirty ? n._totalDuration : n.totalDuration()) - (e - n._startTime) * n._timeScale, t, !1) : n.render((e - n._startTime) * n._timeScale, t, !1);
  1320. n = o
  1321. } else
  1322. for (n = this._last; n;) {
  1323. o = n._prev;
  1324. if (this._paused && !l) break;
  1325. else if (n._active || n._startTime <= s && !n._paused && !n._gc) n._reversed ? n.render((!n._dirty ? n._totalDuration : n.totalDuration()) - (e - n._startTime) * n._timeScale, t, !1) : n.render((e - n._startTime) * n._timeScale, t, !1);
  1326. n = o
  1327. }
  1328. this._onUpdate && (t || this._onUpdate.apply(this.vars.onUpdateScope || this, this.vars.onUpdateParams || i));
  1329. if (p && !this._locked && !this._gc && (u === this._startTime || a != this._timeScale))
  1330. if (0 === this._time || r >= this.totalDuration()) h && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), t || this.vars[p] && this.vars[p].apply(this.vars[p + "Scope"] || this, this.vars[p + "Params"] || i)
  1331. }
  1332. };
  1333. n.getActive = function(e, t, n) {
  1334. null == e && (e = !0);
  1335. null == t && (t = !0);
  1336. null == n && (n = !1);
  1337. var r = [],
  1338. e = this.getChildren(e, t, n),
  1339. t = 0,
  1340. n = e.length,
  1341. i, s;
  1342. for (i = 0; i < n; i++)
  1343. if (s = e[i], !s._paused && s._timeline._time >= s._startTime && s._timeline._time < s._startTime + s._totalDuration / s._timeScale) {
  1344. var o;
  1345. e: {
  1346. for (o = s._timeline; o;) {
  1347. if (o._paused) {
  1348. o = !0;
  1349. break e
  1350. }
  1351. o = o._timeline
  1352. }
  1353. o = !1
  1354. }
  1355. o || (r[t++] = s)
  1356. }
  1357. return r
  1358. };
  1359. n.getLabelAfter = function(e) {
  1360. !e && 0 !== e && (e = this._time);
  1361. var t = this.getLabelsArray(),
  1362. n = t.length,
  1363. r;
  1364. for (r = 0; r < n; r++)
  1365. if (t[r].time > e) return t[r].name;
  1366. return null
  1367. };
  1368. n.getLabelBefore = function(e) {
  1369. null == e && (e = this._time);
  1370. for (var t = this.getLabelsArray(), n = t.length; - 1 < --n;)
  1371. if (t[n].time < e) return t[n].name;
  1372. return null
  1373. };
  1374. n.getLabelsArray = function() {
  1375. var e = [],
  1376. t = 0,
  1377. n;
  1378. for (n in this._labels) e[t++] = {
  1379. time: this._labels[n],
  1380. name: n
  1381. };
  1382. e.sort(function(e, t) {
  1383. return e.time - t.time
  1384. });
  1385. return e
  1386. };
  1387. n.progress = function(e) {
  1388. return !arguments.length ? this._time / this.duration() : this.totalTime(this.duration() * e + this._cycle * this._duration, !1)
  1389. };
  1390. n.totalProgress = function(e) {
  1391. return !arguments.length ? this._totalTime / this.totalDuration() : this.totalTime(this.totalDuration() * e, !1)
  1392. };
  1393. n.totalDuration = function(t) {
  1394. return !arguments.length ? (this._dirty && (e.prototype.totalDuration.call(this), this._totalDuration = -1 === this._repeat ? 999999999999 : this._duration * (this._repeat + 1) + this._repeatDelay * this._repeat), this._totalDuration) : -1 == this._repeat ? this : this.duration((t - this._repeat * this._repeatDelay) / (this._repeat + 1))
  1395. };
  1396. n.time = function(e, t) {
  1397. if (!arguments.length) return this._time;
  1398. this._dirty && this.totalDuration();
  1399. e > this._duration && (e = this._duration);
  1400. this._yoyo && 0 !== (this._cycle & 1) ? e = this._duration - e + this._cycle * (this._duration + this._repeatDelay) : 0 != this._repeat && (e += this._cycle * (this._duration + this._repeatDelay));
  1401. return this.totalTime(e, t)
  1402. };
  1403. n.repeat = function(e) {
  1404. if (!arguments.length) return this._repeat;
  1405. this._repeat = e;
  1406. return this._uncache(!0)
  1407. };
  1408. n.repeatDelay = function(e) {
  1409. if (!arguments.length) return this._repeatDelay;
  1410. this._repeatDelay = e;
  1411. return this._uncache(!0)
  1412. };
  1413. n.yoyo = function(e) {
  1414. if (!arguments.length) return this._yoyo;
  1415. this._yoyo = e;
  1416. return this
  1417. };
  1418. n.currentLabel = function(e) {
  1419. return !arguments.length ? this.getLabelBefore(this._time + 1e-8) : this.seek(e, !0)
  1420. };
  1421. return r
  1422. }, !0);
  1423. _gsDefine("TimelineLite", ["core.Animation", "core.SimpleTimeline", "TweenLite"], function(e, t, n) {
  1424. var r = function(e) {
  1425. t.call(this, e);
  1426. this._labels = {};
  1427. this.autoRemoveChildren = !0 == this.vars.autoRemoveChildren;
  1428. this.smoothChildTiming = !0 == this.vars.smoothChildTiming;
  1429. this._sortChildren = !0;
  1430. this._onUpdate = this.vars.onUpdate;
  1431. for (var e = i.length, n, r; - 1 < --e;)
  1432. if (r = this.vars[i[e]])
  1433. for (n = r.length; - 1 < --n;) "{self}" === r[n] && (r = this.vars[i[e]] = r.concat(), r[n] = this);
  1434. this.vars.tweens instanceof Array && this.insertMultiple(this.vars.tweens, 0, this.vars.align || "normal", this.vars.stagger || 0)
  1435. },
  1436. i = ["onStartParams", "onUpdateParams", "onCompleteParams", "onReverseCompleteParams", "onRepeatParams"],
  1437. s = [],
  1438. o = r.prototype = new t;
  1439. o.constructor = r;
  1440. o.kill()._gc = !1;
  1441. o.to = function(e, t, r, i, s) {
  1442. return this.insert(new n(e, t, r), this._parseTimeOrLabel(s) + (i || 0))
  1443. };
  1444. o.from = function(e, t, r, i, s) {
  1445. return this.insert(n.from(e, t, r), this._parseTimeOrLabel(s) + (i || 0))
  1446. };
  1447. o.fromTo = function(e, t, r, i, s, o) {
  1448. return this.insert(n.fromTo(e, t, r, i), this._parseTimeOrLabel(o) + (s || 0))
  1449. };
  1450. o.staggerTo = function(e, t, i, s, o, u, a, f, l) {
  1451. a = new r({
  1452. onComplete: a,
  1453. onCompleteParams: f,
  1454. onCompleteScope: l
  1455. });
  1456. s = s || 0;
  1457. for (f = 0; f < e.length; f++) a.insert(new n(e[f], t, i), f * s);
  1458. return this.insert(a, this._parseTimeOrLabel(u) + (o || 0))
  1459. };
  1460. o.staggerFrom = function(e, t, n, r, i, s, o, u, a) {
  1461. null == n.immediateRender && (n.immediateRender = !0);
  1462. n.runBackwards = !0;
  1463. return this.staggerTo(e, t, n, r, i, s, o, u, a)
  1464. };
  1465. o.staggerFromTo = function(e, t, n, r, i, s, o, u, a, f) {
  1466. r.startAt = n;
  1467. n.immediateRender && (r.immediateRender = !0);
  1468. return this.staggerTo(e, t, r, i, s, o, u, a, f)
  1469. };
  1470. o.call = function(e, t, r, i, s) {
  1471. return this.insert(n.delayedCall(0, e, t, r), this._parseTimeOrLabel(s) + (i || 0))
  1472. };
  1473. o.set = function(e, t, r, i) {
  1474. t.immediateRender = !1;
  1475. return this.insert(new n(e, 0, t), this._parseTimeOrLabel(i) + (r || 0))
  1476. };
  1477. r.exportRoot = function(e, t) {
  1478. e = e || {};
  1479. null == e.smoothChildTiming && (e.smoothChildTiming = !0);
  1480. var i = new r(e),
  1481. s = i._timeline;
  1482. null == t && (t = !0);
  1483. s._remove(i, !0);
  1484. i._startTime = 0;
  1485. i._rawPrevTime = i._time = i._totalTime = s._time;
  1486. for (var o = s._first, u; o;) u = o._next, (!t || !(o instanceof n && o.target == o.vars.onComplete)) && i.insert(o, o._startTime - o._delay), o = u;
  1487. s.insert(i, 0);
  1488. return i
  1489. };
  1490. o.insert = function(r, i) {
  1491. if (!(r instanceof e)) {
  1492. if (r instanceof Array) return this.insertMultiple(r, i);
  1493. if ("string" === typeof r) return this.addLabel(r, this._parseTimeOrLabel(i || 0, !0));
  1494. if ("function" === typeof r) r = n.delayedCall(0, r);
  1495. else throw "ERROR: Cannot insert() " + r + " into the TimelineLite/Max because it is neither a tween, timeline, function, nor a String."
  1496. }
  1497. t.prototype.insert.call(this, r, this._parseTimeOrLabel(i || 0, !0));
  1498. if (this._gc && !this._paused && this._time === this._duration && this._time < this.duration())
  1499. for (var s = this; s._gc && s._timeline;) s._timeline.smoothChildTiming ? s.totalTime(s._totalTime, !0) : s._enabled(!0, !1), s = s._timeline;
  1500. return this
  1501. };
  1502. o.remove = function(t) {
  1503. if (t instanceof e) return this._remove(t, !1);
  1504. if (t instanceof Array) {
  1505. for (var n = t.length; - 1 < --n;) this.remove(t[n]);
  1506. return this
  1507. }
  1508. return "string" === typeof t ? this.removeLabel(t) : this.kill(null, t)
  1509. };
  1510. o.append = function(e, t) {
  1511. return this.insert(e, this.duration() + (t || 0))
  1512. };
  1513. o.insertMultiple = function(e, t, n, i) {
  1514. for (var n = n || "normal", i = i || 0, s, o = this._parseTimeOrLabel(t || 0, !0), u = e.length, t = 0; t < u; t++) {
  1515. if ((s = e[t]) instanceof Array) s = new r({
  1516. tweens: s
  1517. });
  1518. this.insert(s, o);
  1519. "string" === typeof s || "function" === typeof s || ("sequence" === n ? o = s._startTime + s.totalDuration() / s._timeScale : "start" === n && (s._startTime -= s.delay()));
  1520. o += i
  1521. }
  1522. return this._uncache(!0)
  1523. };
  1524. o.appendMultiple = function(e, t, n, r) {
  1525. return this.insertMultiple(e, this.duration() + (t || 0), n, r)
  1526. };
  1527. o.addLabel = function(e, t) {
  1528. this._labels[e] = t;
  1529. return this
  1530. };
  1531. o.removeLabel = function(e) {
  1532. delete this._labels[e];
  1533. return this
  1534. };
  1535. o.getLabelTime = function(e) {
  1536. return null != this._labels[e] ? this._labels[e] : -1
  1537. };
  1538. o._parseTimeOrLabel = function(e, t) {
  1539. return null == e ? this.duration() : "string" === typeof e && isNaN(e) ? null == this._labels[e] ? t ? this._labels[e] = this.duration() : 0 : this._labels[e] : Number(e)
  1540. };
  1541. o.seek = function(e, t) {
  1542. return this.totalTime(this._parseTimeOrLabel(e, !1), !1 != t)
  1543. };
  1544. o.stop = function() {
  1545. return this.paused(!0)
  1546. };
  1547. o.gotoAndPlay = function(e, n) {
  1548. return t.prototype.play.call(this, e, n)
  1549. };
  1550. o.gotoAndStop = function(e, t) {
  1551. return this.pause(e, t)
  1552. };
  1553. o.render = function(e, t, n) {
  1554. this._gc && this._enabled(!0, !1);
  1555. this._active = !this._paused;
  1556. var r = !this._dirty ? this._totalDuration : this.totalDuration(),
  1557. i = this._time,
  1558. o = this._startTime,
  1559. u = this._timeScale,
  1560. a = this._paused,
  1561. l, c, h;
  1562. if (e >= r) {
  1563. this._totalTime = this._time = r;
  1564. if (!this._reversed && !this._hasPausedChild() && (l = !0, h = "onComplete", 0 === this._duration && (0 === e || 0 > this._rawPrevTime))) this._rawPrevTime !== e && (n = !0);
  1565. this._rawPrevTime = e;
  1566. e = r + 1e-6
  1567. } else if (0 >= e) {
  1568. this._totalTime = this._time = 0;
  1569. if (0 !== i || 0 === this._duration && 0 < this._rawPrevTime) h = "onReverseComplete", l = this._reversed;
  1570. 0 > e ? (this._active = !1, 0 === this._duration && 0 <= this._rawPrevTime && (n = !0)) : this._initted || (n = !0);
  1571. this._rawPrevTime = e;
  1572. e = -1e-6
  1573. } else this._totalTime = this._time = this._rawPrevTime = e; if (this._time !== i || n) {
  1574. this._initted || (this._initted = !0);
  1575. 0 === i && this.vars.onStart && 0 !== this._time && (t || this.vars.onStart.apply(this.vars.onStartScope || this, this.vars.onStartParams || s));
  1576. if (this._time > i)
  1577. for (n = this._first; n;) {
  1578. c = n._next;
  1579. if (this._paused && !a) break;
  1580. else if (n._active || n._startTime <= this._time && !n._paused && !n._gc) n._reversed ? n.render((!n._dirty ? n._totalDuration : n.totalDuration()) - (e - n._startTime) * n._timeScale, t, !1) : n.render((e - n._startTime) * n._timeScale, t, !1);
  1581. n = c
  1582. } else
  1583. for (n = this._last; n;) {
  1584. c = n._prev;
  1585. if (this._paused && !a) break;
  1586. else if (n._active || n._startTime <= i && !n._paused && !n._gc) n._reversed ? n.render((!n._dirty ? n._totalDuration : n.totalDuration()) - (e - n._startTime) * n._timeScale, t, !1) : n.render((e - n._startTime) * n._timeScale, t, !1);
  1587. n = c
  1588. }
  1589. this._onUpdate && (t || this._onUpdate.apply(this.vars.onUpdateScope || this, this.vars.onUpdateParams || s));
  1590. if (h && !this._gc && (o === this._startTime || u != this._timeScale))
  1591. if (0 === this._time || r >= this.totalDuration()) l && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), t || this.vars[h] && this.vars[h].apply(this.vars[h + "Scope"] || this, this.vars[h + "Params"] || s)
  1592. }
  1593. };
  1594. o._hasPausedChild = function() {
  1595. for (var e = this._first; e;) {
  1596. if (e._paused || e instanceof r && e._hasPausedChild()) return !0;
  1597. e = e._next
  1598. }
  1599. return !1
  1600. };
  1601. o.getChildren = function(e, t, r, i) {
  1602. for (var i = i || -9999999999, s = [], o = this._first, u = 0; o;) o._startTime < i || (o instanceof n ? !1 != t && (s[u++] = o) : (!1 != r && (s[u++] = o), !1 != e && (s = s.concat(o.getChildren(!0, t, r)), u = s.length))), o = o._next;
  1603. return s
  1604. };
  1605. o.getTweensOf = function(e, t) {
  1606. for (var r = n.getTweensOf(e), i = r.length, s = [], o = 0; - 1 < --i;)
  1607. if (r[i].timeline === this || t && this._contains(r[i])) s[o++] = r[i];
  1608. return s
  1609. };
  1610. o._contains = function(e) {
  1611. for (e = e.timeline; e;) {
  1612. if (e === this) return !0;
  1613. e = e.timeline
  1614. }
  1615. return !1
  1616. };
  1617. o.shiftChildren = function(e, t, n) {
  1618. for (var n = n || 0, r = this._first; r;) r._startTime >= n && (r._startTime += e), r = r._next;
  1619. if (t)
  1620. for (var i in this._labels) this._labels[i] >= n && (this._labels[i] += e);
  1621. return this._uncache(!0)
  1622. };
  1623. o._kill = function(e, t) {
  1624. if (null == e && null == t) return this._enabled(!1, !1);
  1625. for (var n = null == t ? this.getChildren(!0, !0, !1) : this.getTweensOf(t), r = n.length, i = !1; - 1 < --r;) n[r]._kill(e, t) && (i = !0);
  1626. return i
  1627. };
  1628. o.clear = function(e) {
  1629. var t = this.getChildren(!1, !0, !0),
  1630. n = t.length;
  1631. for (this._time = this._totalTime = 0; - 1 < --n;) t[n]._enabled(!1, !1);
  1632. !1 != e && (this._labels = {});
  1633. return this._uncache(!0)
  1634. };
  1635. o.invalidate = function() {
  1636. for (var e = this._first; e;) e.invalidate(), e = e._next;
  1637. return this
  1638. };
  1639. o._enabled = function(e, n) {
  1640. if (e == this._gc)
  1641. for (var r = this._first; r;) r._enabled(e, !0), r = r._next;
  1642. return t.prototype._enabled.call(this, e, n)
  1643. };
  1644. o.progress = function(e) {
  1645. return !arguments.length ? this._time / this.duration() : this.totalTime(this.duration() * e, !1)
  1646. };
  1647. o.duration = function(e) {
  1648. if (!arguments.length) return this._dirty && this.totalDuration(), this._duration;
  1649. 0 !== this.duration() && 0 !== e && this.timeScale(this._duration / e);
  1650. return this
  1651. };
  1652. o.totalDuration = function(e) {
  1653. if (!arguments.length) {
  1654. if (this._dirty) {
  1655. for (var t = 0, n = this._first, r = -999999999999, i; n;) i = n._next, n._startTime < r && this._sortChildren ? this.insert(n, n._startTime - n._delay) : r = n._startTime, 0 > n._startTime && (t -= n._startTime, this.shiftChildren(-n._startTime, !1, -9999999999)), n = n._startTime + (!n._dirty ? n._totalDuration : n.totalDuration()) / n._timeScale, n > t && (t = n), n = i;
  1656. this._duration = this._totalDuration = t;
  1657. this._dirty = !1
  1658. }
  1659. return this._totalDuration
  1660. }
  1661. 0 !== this.totalDuration() && 0 !== e && this.timeScale(this._totalDuration / e);
  1662. return this
  1663. };
  1664. o.usesFrames = function() {
  1665. for (var t = this._timeline; t._timeline;) t = t._timeline;
  1666. return t === e._rootFramesTimeline
  1667. };
  1668. o.rawTime = function() {
  1669. return this._paused || 0 !== this._totalTime && this._totalTime !== this._totalDuration ? this._totalTime : (this._timeline.rawTime() - this._startTime) * this._timeScale
  1670. };
  1671. return r
  1672. }, !0)
  1673. });
  1674. window._gsDefine && _gsQueue.pop()();
  1675. "undefined" == typeof JKL && (JKL = function() {});
  1676. JKL.ParseXML = function(e, t, n) {
  1677. this.http = new JKL.ParseXML.HTTP(e, t, n, !1);
  1678. return this
  1679. };
  1680. JKL.ParseXML.VERSION = "0.22";
  1681. JKL.ParseXML.MIME_TYPE_XML = "text/xml";
  1682. JKL.ParseXML.MAP_NODETYPE = " ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE".split(" ");
  1683. JKL.ParseXML.prototype.async = function(e, t) {
  1684. this.callback_func = e;
  1685. this.callback_arg = t
  1686. };
  1687. JKL.ParseXML.prototype.onerror = function(e) {
  1688. this.onerror_func = e
  1689. };
  1690. JKL.ParseXML.prototype.parse = function() {
  1691. if (this.http) {
  1692. if (this.onerror_func) this.http.onerror(this.onerror_func);
  1693. if (this.callback_func) {
  1694. var e = this;
  1695. this.http.async(function() {
  1696. if (e.http) {
  1697. var t = e.parseResponse();
  1698. e.callback_func(t, e.callback_arg)
  1699. }
  1700. })
  1701. }
  1702. this.http.load();
  1703. if (!this.callback_func) return this.parseResponse()
  1704. }
  1705. };
  1706. JKL.ParseXML.prototype.setOutputArrayAll = function() {
  1707. this.setOutputArray(!0)
  1708. };
  1709. JKL.ParseXML.prototype.setOutputArrayAuto = function() {
  1710. this.setOutputArray(null)
  1711. };
  1712. JKL.ParseXML.prototype.setOutputArrayNever = function() {
  1713. this.setOutputArray(!1)
  1714. };
  1715. JKL.ParseXML.prototype.setOutputArrayElements = function(e) {
  1716. this.setOutputArray(e)
  1717. };
  1718. JKL.ParseXML.prototype.setOutputArray = function(e) {
  1719. "string" == typeof e && (e = [e]);
  1720. if (e && "object" == typeof e)
  1721. if (0 > e.length) e = !1;
  1722. else {
  1723. for (var t = {}, n = 0; n < e.length; n++) t[e[n]] = !0;
  1724. e = t;
  1725. e["*"] && (e = !0)
  1726. }
  1727. this.usearray = e
  1728. };
  1729. JKL.ParseXML.prototype.parseResponse = function() {
  1730. var e = this.http.documentElement();
  1731. return this.parseDocument(e)
  1732. };
  1733. JKL.ParseXML.prototype.parseDocument = function(e) {
  1734. if (e) {
  1735. var t = this.parseElement(e);
  1736. !0 == this.usearray ? t = [t] : !1 != this.usearray && null != this.usearray && this.usearray[e.nodeName] && (t = [t]);
  1737. var n = {};
  1738. n[e.nodeName] = t;
  1739. return n
  1740. }
  1741. };
  1742. JKL.ParseXML.prototype.parseElement = function(e) {
  1743. if (7 != e.nodeType) {
  1744. if (3 == e.nodeType || 4 == e.nodeType) return null == e.nodeValue.match(/[^\x00-\x20]/) ? void 0 : e.nodeValue;
  1745. var t, n = {};
  1746. if (e.attributes && e.attributes.length) {
  1747. t = {};
  1748. for (var r = 0; r < e.attributes.length; r++) {
  1749. var i = e.attributes[r].nodeName;
  1750. if ("string" == typeof i) {
  1751. var s = e.attributes[r].nodeValue;
  1752. s && ("undefined" == typeof n[i] && (n[i] = 0), n[i]++, this.addNode(t, i, n[i], s))
  1753. }
  1754. }
  1755. }
  1756. if (e.childNodes && e.childNodes.length) {
  1757. i = !0;
  1758. t && (i = !1);
  1759. for (r = 0; r < e.childNodes.length && i; r++) s = e.childNodes[r].nodeType, 3 == s || 4 == s || (i = !1);
  1760. if (i) {
  1761. t || (t = "");
  1762. for (r = 0; r < e.childNodes.length; r++) t += e.childNodes[r].nodeValue
  1763. } else {
  1764. t || (t = {});
  1765. for (r = 0; r < e.childNodes.length; r++)
  1766. if (i = e.childNodes[r].nodeName, "string" == typeof i && (s = this.parseElement(e.childNodes[r]))) "undefined" == typeof n[i] && (n[i] = 0), n[i]++, this.addNode(t, i, n[i], s)
  1767. }
  1768. }
  1769. return t
  1770. }
  1771. };
  1772. JKL.ParseXML.prototype.addNode = function(e, t, n, r) {
  1773. !0 == this.usearray ? (1 == n && (e[t] = []), e[t][e[t].length] = r) : !1 == this.usearray ? 1 == n && (e[t] = r) : null == this.usearray ? 1 == n ? e[t] = r : 2 == n ? e[t] = [e[t], r] : e[t][e[t].length] = r : this.usearray[t] ? (1 == n && (e[t] = []), e[t][e[t].length] = r) : 1 == n && (e[t] = r)
  1774. };
  1775. JKL.ParseXML.Text = function(e, t, n) {
  1776. this.http = new JKL.ParseXML.HTTP(e, t, n, !0);
  1777. return this
  1778. };
  1779. JKL.ParseXML.Text.prototype.parse = JKL.ParseXML.prototype.parse;
  1780. JKL.ParseXML.Text.prototype.async = JKL.ParseXML.prototype.async;
  1781. JKL.ParseXML.Text.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1782. JKL.ParseXML.Text.prototype.parseResponse = function() {
  1783. return this.http.responseText()
  1784. };
  1785. JKL.ParseXML.JSON = function(e, t, n) {
  1786. this.http = new JKL.ParseXML.HTTP(e, t, n, !0);
  1787. return this
  1788. };
  1789. JKL.ParseXML.JSON.prototype.parse = JKL.ParseXML.prototype.parse;
  1790. JKL.ParseXML.JSON.prototype.async = JKL.ParseXML.prototype.async;
  1791. JKL.ParseXML.JSON.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1792. JKL.ParseXML.JSON.prototype.parseResponse = function() {
  1793. var a = this.http.responseText();
  1794. if ("undefined" != typeof a && a.length) return eval("(" + a + ")")
  1795. };
  1796. JKL.ParseXML.DOM = function(e, t, n) {
  1797. this.http = new JKL.ParseXML.HTTP(e, t, n, !1);
  1798. return this
  1799. };
  1800. JKL.ParseXML.DOM.prototype.parse = JKL.ParseXML.prototype.parse;
  1801. JKL.ParseXML.DOM.prototype.async = JKL.ParseXML.prototype.async;
  1802. JKL.ParseXML.DOM.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1803. JKL.ParseXML.DOM.prototype.parseResponse = function() {
  1804. return this.http.documentElement()
  1805. };
  1806. JKL.ParseXML.CSV = function(e, t, n) {
  1807. this.http = new JKL.ParseXML.HTTP(e, t, n, !0);
  1808. return this
  1809. };
  1810. JKL.ParseXML.CSV.prototype.parse = JKL.ParseXML.prototype.parse;
  1811. JKL.ParseXML.CSV.prototype.async = JKL.ParseXML.prototype.async;
  1812. JKL.ParseXML.CSV.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1813. JKL.ParseXML.CSV.prototype.parseResponse = function() {
  1814. var e = this.http.responseText();
  1815. return this.parseCSV(e)
  1816. };
  1817. JKL.ParseXML.CSV.prototype.parseCSV = function(e) {
  1818. for (var e = e.replace(/\r\n?/g, "\n"), t = 0, n = e.length, r = []; t < n;) {
  1819. for (var i = []; t < n;) {
  1820. if ('"' == e.charAt(t)) {
  1821. for (var s = e.indexOf('"', t + 1); s < n && -1 < s && '"' == e.charAt(s + 1);) s = e.indexOf('"', s + 2);
  1822. if (!(0 > s))
  1823. if ("," == e.charAt(s + 1)) {
  1824. t = e.substr(t + 1, s - t - 1);
  1825. t = t.replace(/""/g, '"');
  1826. i[i.length] = t;
  1827. t = s + 2;
  1828. continue
  1829. } else if ("\n" == e.charAt(s + 1) || n == s + 1) {
  1830. t = e.substr(t + 1, s - t - 1);
  1831. t = t.replace(/""/g, '"');
  1832. i[i.length] = t;
  1833. t = s + 2;
  1834. break
  1835. }
  1836. }
  1837. var s = e.indexOf(",", t),
  1838. o = e.indexOf("\n", t);
  1839. 0 > o && (o = n);
  1840. if (-1 < s && s < o) i[i.length] = e.substr(t, s - t), t = s + 1;
  1841. else {
  1842. i[i.length] = e.substr(t, o - t);
  1843. t = o + 1;
  1844. break
  1845. }
  1846. }
  1847. 0 <= i.length && (r[r.length] = i)
  1848. }
  1849. if (!(0 > r.length)) return r
  1850. };
  1851. JKL.ParseXML.CSVmap = function(e, t, n) {
  1852. this.http = new JKL.ParseXML.HTTP(e, t, n, !0);
  1853. return this
  1854. };
  1855. JKL.ParseXML.CSVmap.prototype.parse = JKL.ParseXML.prototype.parse;
  1856. JKL.ParseXML.CSVmap.prototype.async = JKL.ParseXML.prototype.async;
  1857. JKL.ParseXML.CSVmap.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1858. JKL.ParseXML.CSVmap.prototype.parseCSV = JKL.ParseXML.CSV.prototype.parseCSV;
  1859. JKL.ParseXML.CSVmap.prototype.parseResponse = function() {
  1860. var e = this.http.responseText();
  1861. if ((e = this.parseCSV(e)) && !(0 > e.length)) {
  1862. for (var t = e.shift(), n = [], r = 0; r < e.length; r++) {
  1863. for (var i = {}, s = 0; s < t.length && s < e[r].length; s++) i[t[s]] = e[r][s];
  1864. n[n.length] = i
  1865. }
  1866. return n
  1867. }
  1868. };
  1869. JKL.ParseXML.LoadVars = function(e, t, n) {
  1870. this.http = new JKL.ParseXML.HTTP(e, t, n, !0);
  1871. return this
  1872. };
  1873. JKL.ParseXML.LoadVars.prototype.parse = JKL.ParseXML.prototype.parse;
  1874. JKL.ParseXML.LoadVars.prototype.async = JKL.ParseXML.prototype.async;
  1875. JKL.ParseXML.LoadVars.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1876. JKL.ParseXML.LoadVars.prototype.parseResponse = function() {
  1877. for (var e = this.http.responseText(), e = e.replace(/\r\n?/g, "\n"), t = {}, e = e.split("&"), n = 0; n < e.length; n++) {
  1878. var r = e[n].indexOf("=");
  1879. if (-1 < r) {
  1880. var i = decodeURIComponent(e[n].substr(0, r).replace("+", "%20")),
  1881. r = decodeURIComponent(e[n].substr(r + 1).replace("+", "%20"));
  1882. t[i] = r
  1883. } else t[e[n]] = ""
  1884. }
  1885. return t
  1886. };
  1887. JKL.ParseXML.HTTP = function(e, t, n, r) {
  1888. this.url = e;
  1889. this.query = "string" == typeof t ? t : "";
  1890. this.method = n ? n : "string" == typeof t ? "POST" : "GET";
  1891. this.textmode = r ? !0 : !1;
  1892. this.req = null;
  1893. this.xmldom_flag = !1;
  1894. this.already_done = this.callback_func = this.onerror_func = null;
  1895. return this
  1896. };
  1897. JKL.ParseXML.HTTP.REQUEST_TYPE = "application/x-www-form-urlencoded";
  1898. JKL.ParseXML.HTTP.ACTIVEX_XMLDOM = "Microsoft.XMLDOM";
  1899. JKL.ParseXML.HTTP.ACTIVEX_XMLHTTP = "Microsoft.XMLHTTP";
  1900. JKL.ParseXML.HTTP.EPOCH_TIMESTAMP = "Thu, 01 Jun 1970 00:00:00 GMT";
  1901. JKL.ParseXML.HTTP.prototype.onerror = JKL.ParseXML.prototype.onerror;
  1902. JKL.ParseXML.HTTP.prototype.async = function(e) {
  1903. this.async_func = e
  1904. };
  1905. JKL.ParseXML.HTTP.prototype.load = function() {
  1906. if (window.ActiveXObject) {
  1907. var e = JKL.ParseXML.HTTP.ACTIVEX_XMLHTTP;
  1908. "GET" == this.method && !this.textmode && (e = JKL.ParseXML.HTTP.ACTIVEX_XMLDOM);
  1909. this.req = new ActiveXObject(e)
  1910. } else window.XMLHttpRequest && (this.req = new XMLHttpRequest);
  1911. e = this.async_func ? !0 : !1;
  1912. "undefined" != typeof this.req.send && this.req.open(this.method, this.url, e);
  1913. "undefined" != typeof this.req.setRequestHeader && this.req.setRequestHeader("Content-Type", JKL.ParseXML.HTTP.REQUEST_TYPE);
  1914. "undefined" != typeof this.req.overrideMimeType && !this.textmode && this.req.overrideMimeType(JKL.ParseXML.MIME_TYPE_XML);
  1915. if (e) {
  1916. var t = this;
  1917. t.already_done = !1;
  1918. this.req.onreadystatechange = function() {
  1919. 4 == t.req.readyState && t.checkResponse() && !t.already_done && (t.already_done = !0, t.async_func())
  1920. }
  1921. }
  1922. "undefined" != typeof this.req.send ? this.req.send(this.query) : "undefined" != typeof this.req.load && (this.req.async = e, this.req.load(this.url));
  1923. e || this.checkResponse()
  1924. };
  1925. JKL.ParseXML.HTTP.prototype.checkResponse = function() {
  1926. if (this.req.parseError && 0 != this.req.parseError.errorCode) {
  1927. if (this.onerror_func) this.onerror_func(this.req.parseError.reason);
  1928. return !1
  1929. }
  1930. if (0 < this.req.status - 0 && 200 != this.req.status && 206 != this.req.status && 304 != this.req.status) {
  1931. if (this.onerror_func) this.onerror_func(this.req.status);
  1932. return !1
  1933. }
  1934. return !0
  1935. };
  1936. JKL.ParseXML.HTTP.prototype.documentElement = function() {
  1937. if (this.req) return this.req.responseXML ? this.req.responseXML.documentElement : this.req.documentElement
  1938. };
  1939. JKL.ParseXML.HTTP.prototype.responseText = function() {
  1940. if (this.req) {
  1941. if (navigator.appVersion.match("KHTML")) {
  1942. var e = escape(this.req.responseText);
  1943. if (!e.match("%u") && e.match("%")) return decodeURIComponent(e)
  1944. }
  1945. return this.req.responseText
  1946. }
  1947. };
  1948. "function" !== typeof Object.defineProperty && (Object.defineProperty = function(e, t, n) {
  1949. "value" in n && (e[t] = n.value);
  1950. "get" in n && e.__defineGetter__(t, n.get);
  1951. "set" in n && e.__defineSetter__(t, n.set);
  1952. return e
  1953. });
  1954. "function" !== typeof Object.defineProperties && (Object.defineProperties = function(e, t) {
  1955. for (var n in t) t.hasOwnProperty(n) && Object.defineProperty(e, n, t[n]);
  1956. return e
  1957. });
  1958. "function" !== typeof Object.create && (Object.create = function(e, t) {
  1959. function n() {}
  1960. n.prototype = e;
  1961. var r = new n;
  1962. t != null && Object.defineProperties(r, t);
  1963. return r
  1964. });
  1965. "function" !== typeof Object.getPrototypeOf && (Object.getPrototypeOf = function(e) {
  1966. return e.__proto__
  1967. });
  1968. "function" !== typeof Function.prototype.bind && (Function.prototype.bind = function(e) {
  1969. var t = this,
  1970. n = Array.prototype.slice.call(arguments, 1),
  1971. r = function() {},
  1972. i = function() {
  1973. var i = n.concat(Array.prototype.slice.call(arguments));
  1974. return t.apply(this instanceof r ? this : e || window, i)
  1975. };
  1976. r.prototype = t.prototype;
  1977. i.prototype = new r;
  1978. return i
  1979. });
  1980. var enchant = function(e) {
  1981. if (e != null) {
  1982. e instanceof Array || (e = Array.prototype.slice.call(arguments));
  1983. e = e.filter(function(e) {
  1984. return "" + e
  1985. })
  1986. }(function t(n, r) {
  1987. var i = [],
  1988. s, o;
  1989. for (o in n)
  1990. if (n.hasOwnProperty(o))
  1991. if (typeof n[o] === "function") window[o] = n[o];
  1992. else if (typeof n[o] === "object" && Object.getPrototypeOf(n[o]) === Object.prototype)
  1993. if (e == null) i.push(o);
  1994. else {
  1995. s = e.indexOf(r + o);
  1996. if (s !== -1) {
  1997. i.push(o);
  1998. e.splice(s, 1)
  1999. }
  2000. }
  2001. s = 0;
  2002. for (o = i.length; s < o; s++) t(n[i[s]], r + i[s] + ".")
  2003. })(enchant, "");
  2004. if (e != null && e.length) throw Error("Cannot load module: " + e.join(", "))
  2005. };
  2006. window.addEventListener("message", function(e) {
  2007. try {
  2008. var t = JSON.parse(e.data);
  2009. if (t.type === "event") enchant.Game.instance.dispatchEvent(new enchant.Event(t.value));
  2010. else if (t.type === "debug") switch (t.value) {
  2011. case "start":
  2012. enchant.Game.instance.start();
  2013. break;
  2014. case "pause":
  2015. enchant.Game.instance.pause();
  2016. break;
  2017. case "resume":
  2018. enchant.Game.instance.resume();
  2019. break;
  2020. case "tick":
  2021. enchant.Game.instance._tick()
  2022. }
  2023. } catch (n) {}
  2024. }, !1);
  2025. enchant.Class = function(e, t) {
  2026. return enchant.Class.create(e, t)
  2027. };
  2028. enchant.Class.create = function(e, t) {
  2029. if (arguments.length === 0) return enchant.Class.create(Object, t);
  2030. if (arguments.length === 1 && typeof arguments[0] !== "function") return enchant.Class.create(Object, arguments[0]);
  2031. for (var n in t)
  2032. if (t.hasOwnProperty(n))
  2033. if (typeof t[n] === "object" && Object.getPrototypeOf(t[n]) === Object.prototype) {
  2034. if (!("enumerable" in t[n])) t[n].enumerable = true
  2035. } else t[n] = {
  2036. value: t[n],
  2037. enumerable: true,
  2038. writable: true
  2039. };
  2040. var r = function() {
  2041. if (this instanceof r) r.prototype.initialize.apply(this, arguments);
  2042. else return new r
  2043. };
  2044. r.prototype = Object.create(e.prototype, t);
  2045. r.prototype.constructor = r;
  2046. if (r.prototype.initialize == null) r.prototype.initialize = function() {
  2047. e.apply(this, arguments)
  2048. };
  2049. return r
  2050. };
  2051. enchant.ENV = {
  2052. VENDOR_PREFIX: function() {
  2053. var e = navigator.userAgent;
  2054. return e.indexOf("Opera") !== -1 ? "O" : e.indexOf("MSIE") !== -1 ? "ms" : e.indexOf("WebKit") !== -1 ? "webkit" : navigator.product === "Gecko" ? "Moz" : ""
  2055. }(),
  2056. TOUCH_ENABLED: function() {
  2057. var e = document.createElement("div");
  2058. e.setAttribute("ontouchstart", "return");
  2059. return typeof e.ontouchstart === "function"
  2060. }(),
  2061. RETINA_DISPLAY: function() {
  2062. if (navigator.userAgent.indexOf("iPhone") !== -1 && window.devicePixelRatio === 2) {
  2063. var e = document.querySelector('meta[name="viewport"]');
  2064. if (e == null) {
  2065. e = document.createElement("meta");
  2066. document.head.appendChild(e)
  2067. }
  2068. return true
  2069. }
  2070. return false
  2071. }(),
  2072. USE_FLASH_SOUND: function() {
  2073. var e = navigator.userAgent,
  2074. t = navigator.vendor || "";
  2075. return location.href.indexOf("http") === 0 && e.indexOf("Mobile") === -1 && t.indexOf("Apple") !== -1
  2076. }(),
  2077. USE_DEFAULT_EVENT_TAGS: ["input", "textarea", "select", "area"],
  2078. CANVAS_DRAWING_METHODS: "putImageData drawImage drawFocusRing fill stroke clearRect fillRect strokeRect fillText strokeText".split(" ")
  2079. };
  2080. enchant.Event = enchant.Class.create({
  2081. initialize: function(e) {
  2082. this.type = e;
  2083. this.target = null;
  2084. this.localY = this.localX = this.y = this.x = 0
  2085. },
  2086. _initPosition: function(e, t) {
  2087. var n = enchant.Game.instance;
  2088. this.x = this.localX = (e - n._pageX) / n.scale;
  2089. this.y = this.localY = (t - n._pageY) / n.scale
  2090. }
  2091. });
  2092. enchant.Event.LOAD = "load";
  2093. enchant.Event.PROGRESS = "progress";
  2094. enchant.Event.ENTER_FRAME = "enterframe";
  2095. enchant.Event.EXIT_FRAME = "exitframe";
  2096. enchant.Event.ENTER = "enter";
  2097. enchant.Event.EXIT = "exit";
  2098. enchant.Event.ADDED = "added";
  2099. enchant.Event.ADDED_TO_SCENE = "addedtoscene";
  2100. enchant.Event.REMOVED = "removed";
  2101. enchant.Event.REMOVED_FROM_SCENE = "removedfromscene";
  2102. enchant.Event.TOUCH_START = "touchstart";
  2103. enchant.Event.TOUCH_MOVE = "touchmove";
  2104. enchant.Event.TOUCH_END = "touchend";
  2105. enchant.Event.RENDER = "render";
  2106. enchant.Event.INPUT_START = "inputstart";
  2107. enchant.Event.INPUT_CHANGE = "inputchange";
  2108. enchant.Event.INPUT_END = "inputend";
  2109. enchant.Event.LEFT_BUTTON_DOWN = "leftbuttondown";
  2110. enchant.Event.LEFT_BUTTON_UP = "leftbuttonup";
  2111. enchant.Event.RIGHT_BUTTON_DOWN = "rightbuttondown";
  2112. enchant.Event.RIGHT_BUTTON_UP = "rightbuttonup";
  2113. enchant.Event.UP_BUTTON_DOWN = "upbuttondown";
  2114. enchant.Event.UP_BUTTON_UP = "upbuttonup";
  2115. enchant.Event.DOWN_BUTTON_DOWN = "downbuttondown";
  2116. enchant.Event.DOWN_BUTTON_UP = "downbuttonup";
  2117. enchant.Event.A_BUTTON_DOWN = "abuttondown";
  2118. enchant.Event.A_BUTTON_UP = "abuttonup";
  2119. enchant.Event.B_BUTTON_DOWN = "bbuttondown";
  2120. enchant.Event.B_BUTTON_UP = "bbuttonup";
  2121. enchant.EventTarget = enchant.Class.create({
  2122. initialize: function() {
  2123. this._listeners = {}
  2124. },
  2125. addEventListener: function(e, t) {
  2126. var n = this._listeners[e];
  2127. n == null ? this._listeners[e] = [t] : n.indexOf(t) === -1 && n.unshift(t)
  2128. },
  2129. on: function() {
  2130. this.addEventListener.apply(this, arguments)
  2131. },
  2132. removeEventListener: function(e, t) {
  2133. var n = this._listeners[e];
  2134. if (n != null) {
  2135. var r = n.indexOf(t);
  2136. r !== -1 && n.splice(r, 1)
  2137. }
  2138. },
  2139. clearEventListener: function(e) {
  2140. e != null ? delete this._listeners[e] : this._listeners = {}
  2141. },
  2142. dispatchEvent: function(e) {
  2143. e.target = this;
  2144. e.localX = e.x - this._offsetX;
  2145. e.localY = e.y - this._offsetY;
  2146. if (this["on" + e.type] != null) this["on" + e.type](e);
  2147. var t = this._listeners[e.type];
  2148. if (t != null)
  2149. for (var t = t.slice(), n = 0, r = t.length; n < r; n++) t[n].call(this, e)
  2150. }
  2151. });
  2152. (function() {
  2153. var e;
  2154. enchant.Game = enchant.Class.create(enchant.EventTarget, {
  2155. initialize: function(t, n) {
  2156. if (window.document.body === null) throw Error("document.body is null. Please excute 'new Game()' in window.onload.");
  2157. enchant.EventTarget.call(this);
  2158. var r = true;
  2159. if (e) {
  2160. r = false;
  2161. e.stop()
  2162. }
  2163. // play68_init();
  2164. e = enchant.Game.instance = this;
  2165. this.width = t || 320;
  2166. this.height = n || 320;
  2167. this.scale = 1;
  2168. var i = document.getElementById("enchant-stage");
  2169. if (i) {
  2170. var s = window.getComputedStyle(i),
  2171. t = parseInt(s.width, 10),
  2172. n = parseInt(s.height, 10);
  2173. if (t && n) this.scale = Math.min(t / this.width, n / this.height);
  2174. else {
  2175. i.style.width = this.width + "px";
  2176. i.style.height = this.height + "px"
  2177. }
  2178. for (; i.firstChild;) i.removeChild(i.firstChild);
  2179. i.style.position = "relative";
  2180. s = i.getBoundingClientRect();
  2181. this._pageX = Math.round(window.scrollX + s.left);
  2182. this._pageY = Math.round(window.scrollY + s.top)
  2183. } else {
  2184. i = document.createElement("div");
  2185. i.id = "enchant-stage";
  2186. i.style.width = window.innerWidth + "px";
  2187. i.style.height = window.innerHeight + "px";
  2188. i.style.position = "absolute";
  2189. document.body.firstChild ? document.body.insertBefore(i, document.body.firstChild) : document.body.appendChild(i);
  2190. this.scale = Math.min(window.innerWidth / this.width, window.innerHeight / this.height);
  2191. this._pageY = this._pageX = 0
  2192. } if (!this.scale) this.scale = 1;
  2193. i.style.fontSize = "12px";
  2194. i.style.webkitTextSizeAdjust = "none";
  2195. this._element = i;
  2196. this.fps = 30;
  2197. this.frame = 0;
  2198. this.ready = null;
  2199. this.running = false;
  2200. this.assets = {};
  2201. var o = this._assets = [];
  2202. (function m(e) {
  2203. e.assets instanceof Array && [].push.apply(o, e.assets);
  2204. for (var t in e) e.hasOwnProperty(t) && typeof e[t] === "object" && Object.getPrototypeOf(e[t]) === Object.prototype && m(e[t])
  2205. })(enchant);
  2206. this._scenes = [];
  2207. this.currentScene = null;
  2208. this.rootScene = new enchant.Scene;
  2209. this.pushScene(this.rootScene);
  2210. this.loadingScene = new enchant.Scene;
  2211. this.loadingScene.backgroundColor = "#000";
  2212. var u = this.width * .9 | 0,
  2213. f = this.width * .3 | 0,
  2214. l = u * .05 | 0,
  2215. i = new enchant.Sprite(u, f);
  2216. i.x = (this.width - u) / 2;
  2217. i.y = (this.height - f) / 2;
  2218. var c = new enchant.Surface(u, f);
  2219. c.context.fillStyle = "#fff";
  2220. c.context.fillRect(0, 0, u, f);
  2221. c.context.fillStyle = "#000";
  2222. c.context.fillRect(l, l, u - l * 2, f - l * 2);
  2223. i.image = c;
  2224. var h = 0,
  2225. p = 0;
  2226. this.addEventListener("progress", function(e) {
  2227. h = e.loaded / e.total
  2228. });
  2229. i.addEventListener("enterframe", function() {
  2230. p = p * .9;
  2231. p = p + h * .1;
  2232. c.context.fillStyle = "#fff";
  2233. c.context.fillRect(l, 0, (u - l * 2) * p, f)
  2234. });
  2235. this.loadingScene.addChild(i);
  2236. this._soundID = this._surfaceID = this._mousedownID = 0;
  2237. this._intervalID = null;
  2238. this._offsetY = this._offsetX = 0;
  2239. this.input = {};
  2240. this._keybind = {};
  2241. this.keybind(37, "left");
  2242. this.keybind(38, "up");
  2243. this.keybind(39, "right");
  2244. this.keybind(40, "down");
  2245. var d = 0;
  2246. ["left", "right", "up", "down", "a", "b"].forEach(function(e) {
  2247. this.addEventListener(e + "buttondown", function(t) {
  2248. var n;
  2249. if (!this.input[e]) {
  2250. this.input[e] = true;
  2251. n = new enchant.Event(d++ ? "inputchange" : "inputstart");
  2252. this.dispatchEvent(n)
  2253. }
  2254. this.currentScene.dispatchEvent(t);
  2255. n && this.currentScene.dispatchEvent(n)
  2256. });
  2257. this.addEventListener(e + "buttonup", function(t) {
  2258. var n;
  2259. if (this.input[e]) {
  2260. this.input[e] = false;
  2261. n = new enchant.Event(--d ? "inputchange" : "inputend");
  2262. this.dispatchEvent(n)
  2263. }
  2264. this.currentScene.dispatchEvent(t);
  2265. n && this.currentScene.dispatchEvent(n)
  2266. })
  2267. }, this);
  2268. if (r) {
  2269. var i = enchant.Game.instance._element,
  2270. v;
  2271. document.addEventListener("keydown", function(t) {
  2272. e.dispatchEvent(new enchant.Event("keydown"));
  2273. if (37 <= t.keyCode && t.keyCode <= 40 || t.keyCode === 32) {
  2274. t.preventDefault();
  2275. t.stopPropagation()
  2276. }
  2277. if (e.running)
  2278. if (t = e._keybind[t.keyCode]) {
  2279. v = new enchant.Event(t + "buttondown");
  2280. e.dispatchEvent(v)
  2281. }
  2282. }, true);
  2283. document.addEventListener("keyup", function(t) {
  2284. if (e.running)
  2285. if (t = e._keybind[t.keyCode]) {
  2286. v = new enchant.Event(t + "buttonup");
  2287. e.dispatchEvent(v)
  2288. }
  2289. }, true);
  2290. if (enchant.ENV.TOUCH_ENABLED) {
  2291. i.addEventListener("touchstart", function(t) {
  2292. var n = t.target.tagName.toLowerCase();
  2293. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2294. t.preventDefault();
  2295. e.running || t.stopPropagation()
  2296. }
  2297. }, true);
  2298. i.addEventListener("touchmove", function(t) {
  2299. var n = t.target.tagName.toLowerCase();
  2300. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2301. t.preventDefault();
  2302. e.running || t.stopPropagation()
  2303. }
  2304. }, true);
  2305. i.addEventListener("touchend", function(t) {
  2306. var n = t.target.tagName.toLowerCase();
  2307. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2308. t.preventDefault();
  2309. e.running || t.stopPropagation()
  2310. }
  2311. }, true)
  2312. } else {
  2313. i.addEventListener("mousedown", function(t) {
  2314. var n = t.target.tagName.toLowerCase();
  2315. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2316. t.preventDefault();
  2317. e._mousedownID++;
  2318. e.running || t.stopPropagation()
  2319. }
  2320. }, true);
  2321. i.addEventListener("mousemove", function(t) {
  2322. var n = t.target.tagName.toLowerCase();
  2323. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2324. t.preventDefault();
  2325. e.running || t.stopPropagation()
  2326. }
  2327. }, true);
  2328. i.addEventListener("mouseup", function(t) {
  2329. var n = t.target.tagName.toLowerCase();
  2330. if (enchant.ENV.USE_DEFAULT_EVENT_TAGS.indexOf(n) === -1) {
  2331. t.preventDefault();
  2332. e.running || t.stopPropagation()
  2333. }
  2334. }, true)
  2335. }
  2336. }
  2337. },
  2338. preload: function(e) {
  2339. e instanceof Array || (e = Array.prototype.slice.call(arguments));
  2340. [].push.apply(this._assets, e)
  2341. },
  2342. load: function(t, n) {
  2343. n == null && (n = function() {});
  2344. var r = enchant.Game.findExt(t);
  2345. if (enchant.Game._loadFuncs[r]) enchant.Game._loadFuncs[r].call(this, t, n, r);
  2346. else {
  2347. var i = new XMLHttpRequest;
  2348. i.open("GET", t, true);
  2349. i.onreadystatechange = function() {
  2350. if (i.readyState === 4) {
  2351. if (i.status !== 200 && i.status !== 0) throw Error(i.status + ": Cannot load an asset: " + t);
  2352. var r = i.getResponseHeader("Content-Type") || "";
  2353. if (r.match(/^image/)) {
  2354. e.assets[t] = enchant.Surface.load(t);
  2355. e.assets[t].addEventListener("load", n)
  2356. } else if (r.match(/^audio/)) {
  2357. e.assets[t] = enchant.Sound.load(t, r);
  2358. e.assets[t].addEventListener("load", n)
  2359. } else {
  2360. e.assets[t] = i.responseText;
  2361. n()
  2362. }
  2363. }
  2364. };
  2365. i.send(null)
  2366. }
  2367. },
  2368. start: function() {
  2369. if (this._intervalID) window.clearInterval(this._intervalID);
  2370. else if (this._assets.length) {
  2371. if (enchant.Sound.enabledInMobileSafari && !e._touched && enchant.ENV.VENDOR_PREFIX === "webkit" && enchant.ENV.TOUCH_ENABLED) {
  2372. var t = new enchant.Scene;
  2373. t.backgroundColor = "#000";
  2374. var n = Math.round(e.width / 10),
  2375. r = new enchant.Sprite(e.width, n);
  2376. r.y = (e.height - n) / 2;
  2377. r.image = new enchant.Surface(e.width, n);
  2378. r.image.context.fillStyle = "#fff";
  2379. r.image.context.font = n - 1 + "px bold Helvetica,Arial,sans-serif";
  2380. var i = r.image.context.measureText("Touch to Start").width;
  2381. r.image.context.fillText("Touch to Start", (e.width - i) / 2, n - 1);
  2382. t.addChild(r);
  2383. document.addEventListener("touchstart", function() {
  2384. e._touched = true;
  2385. e.removeScene(t);
  2386. e.start()
  2387. }, true);
  2388. e.pushScene(t);
  2389. return
  2390. }
  2391. var s = {},
  2392. n = this._assets.filter(function(e) {
  2393. return e in s ? false : s[e] = true
  2394. }),
  2395. o = 0,
  2396. u = n.length,
  2397. r = function() {
  2398. var t = new enchant.Event("progress");
  2399. t.loaded = ++o;
  2400. t.total = u;
  2401. e.dispatchEvent(t);
  2402. if (o === u) {
  2403. e.removeScene(e.loadingScene);
  2404. e.dispatchEvent(new enchant.Event("load"))
  2405. }
  2406. },
  2407. i = 0;
  2408. for (; i < u; i++) this.load(n[i], r);
  2409. this.pushScene(this.loadingScene)
  2410. } else this.dispatchEvent(new enchant.Event("load"));
  2411. this.currentTime = Date.now();
  2412. this._intervalID = window.setInterval(function() {
  2413. e._tick()
  2414. }, 1e3 / this.fps);
  2415. this.running = true
  2416. },
  2417. debug: function() {
  2418. this._debug = true;
  2419. this.rootScene.addEventListener("enterframe", function(e) {
  2420. this._actualFps = 1 / e
  2421. });
  2422. this.start()
  2423. },
  2424. actualFps: {
  2425. get: function() {
  2426. return this._actualFps || this.fps
  2427. }
  2428. },
  2429. _tick: function() {
  2430. var e = Date.now(),
  2431. t = new enchant.Event("enterframe");
  2432. t.elapsed = e - this.currentTime;
  2433. this.currentTime = e;
  2434. for (var e = this.currentScene.childNodes.slice(), n = Array.prototype.push; e.length;) {
  2435. var r = e.pop();
  2436. r.dispatchEvent(t);
  2437. r.age++;
  2438. r.childNodes && n.apply(e, r.childNodes)
  2439. }
  2440. this.currentScene.age++;
  2441. this.currentScene.dispatchEvent(t);
  2442. this.dispatchEvent(t);
  2443. this.dispatchEvent(new enchant.Event("exitframe"));
  2444. this.frame++
  2445. },
  2446. stop: function() {
  2447. if (this._intervalID) {
  2448. window.clearInterval(this._intervalID);
  2449. this._intervalID = null
  2450. }
  2451. this.running = false
  2452. },
  2453. pause: function() {
  2454. if (this._intervalID) {
  2455. window.clearInterval(this._intervalID);
  2456. this._intervalID = null
  2457. }
  2458. },
  2459. resume: function() {
  2460. if (!this._intervalID) {
  2461. this.currentTime = Date.now();
  2462. this._intervalID = window.setInterval(function() {
  2463. e._tick()
  2464. }, 1e3 / this.fps);
  2465. this.running = true
  2466. }
  2467. },
  2468. pushScene: function(e) {
  2469. this._element.appendChild(e._element);
  2470. this.currentScene && this.currentScene.dispatchEvent(new enchant.Event("exit"));
  2471. this.currentScene = e;
  2472. this.currentScene.dispatchEvent(new enchant.Event("enter"));
  2473. return this._scenes.push(e)
  2474. },
  2475. popScene: function() {
  2476. if (this.currentScene === this.rootScene) return this.currentScene;
  2477. this._element.removeChild(this.currentScene._element);
  2478. this.currentScene.dispatchEvent(new enchant.Event("exit"));
  2479. this.currentScene = this._scenes[this._scenes.length - 2];
  2480. this.currentScene.dispatchEvent(new enchant.Event("enter"));
  2481. return this._scenes.pop()
  2482. },
  2483. replaceScene: function(e) {
  2484. this.popScene();
  2485. return this.pushScene(e)
  2486. },
  2487. removeScene: function(e) {
  2488. if (this.currentScene === e) return this.popScene();
  2489. var t = this._scenes.indexOf(e);
  2490. if (t !== -1) {
  2491. this._scenes.splice(t, 1);
  2492. this._element.removeChild(e._element);
  2493. return e
  2494. }
  2495. return null
  2496. },
  2497. keybind: function(e, t) {
  2498. this._keybind[e] = t
  2499. },
  2500. getElapsedTime: function() {
  2501. return this.frame / this.fps
  2502. }
  2503. });
  2504. enchant.Game._loadFuncs = {};
  2505. enchant.Game._loadFuncs.jpg = enchant.Game._loadFuncs.jpeg = enchant.Game._loadFuncs.gif = enchant.Game._loadFuncs.png = enchant.Game._loadFuncs.bmp = function(e, t) {
  2506. this.assets[e] = enchant.Surface.load(e);
  2507. this.assets[e].addEventListener("load", t)
  2508. };
  2509. enchant.Game._loadFuncs.mp3 = enchant.Game._loadFuncs.aac = enchant.Game._loadFuncs.m4a = enchant.Game._loadFuncs.wav = enchant.Game._loadFuncs.ogg = function(e, t, n) {
  2510. this.assets[e] = enchant.Sound.load(e, "audio/" + n);
  2511. this.assets[e].addEventListener("load", t)
  2512. };
  2513. enchant.Game.findExt = function(e) {
  2514. var t = e.match(/\.\w+$/);
  2515. return t && t.length > 0 ? t[0].slice(1).toLowerCase() : e.indexOf("data:") === 0 ? e.split(/[\/;]/)[1].toLowerCase() : null
  2516. };
  2517. enchant.Game.instance = null
  2518. })();
  2519. enchant.Node = enchant.Class.create(enchant.EventTarget, {
  2520. initialize: function() {
  2521. enchant.EventTarget.call(this);
  2522. this.age = this._offsetY = this._offsetX = this._y = this._x = 0;
  2523. this.scene = this.parentNode = null;
  2524. this.addEventListener("touchstart", function(e) {
  2525. this.parentNode && !this.parentNode._element && this.parentNode.dispatchEvent(e)
  2526. });
  2527. this.addEventListener("touchmove", function(e) {
  2528. this.parentNode && !this.parentNode._element && this.parentNode.dispatchEvent(e)
  2529. });
  2530. this.addEventListener("touchend", function(e) {
  2531. this.parentNode && !this.parentNode._element && this.parentNode.dispatchEvent(e)
  2532. })
  2533. },
  2534. moveTo: function(e, t) {
  2535. this._x = e;
  2536. this._y = t;
  2537. this._updateCoordinate()
  2538. },
  2539. moveBy: function(e, t) {
  2540. this._x = this._x + e;
  2541. this._y = this._y + t;
  2542. this._updateCoordinate()
  2543. },
  2544. x: {
  2545. get: function() {
  2546. return this._x
  2547. },
  2548. set: function(e) {
  2549. this._x = e;
  2550. this._updateCoordinate()
  2551. }
  2552. },
  2553. y: {
  2554. get: function() {
  2555. return this._y
  2556. },
  2557. set: function(e) {
  2558. this._y = e;
  2559. this._updateCoordinate()
  2560. }
  2561. },
  2562. _updateCoordinate: function() {
  2563. if (this.parentNode) {
  2564. this._offsetX = this.parentNode._offsetX + this._x;
  2565. this._offsetY = this.parentNode._offsetY + this._y
  2566. } else {
  2567. this._offsetX = this._x;
  2568. this._offsetY = this._y
  2569. }
  2570. },
  2571. remove: function() {
  2572. this._listener && this.clearEventListener();
  2573. this.parentNode && this.parentNode.removeChild(this)
  2574. }
  2575. });
  2576. enchant.Entity = enchant.Class.create(enchant.Node, {
  2577. initialize: function() {
  2578. var e = enchant.Game.instance;
  2579. enchant.Node.call(this);
  2580. this._element = document.createElement("div");
  2581. this._style = this._element.style;
  2582. this._style.position = "absolute";
  2583. this._height = this._width = 0;
  2584. this._backgroundColor = null;
  2585. this._opacity = 1;
  2586. this._visible = true;
  2587. this._buttonMode = null;
  2588. if (enchant.Game.instance._debug) {
  2589. this._style.border = "1px solid blue";
  2590. this._style.margin = "-1px"
  2591. }
  2592. this.buttonMode = null;
  2593. this.buttonPressed = false;
  2594. this.addEventListener("touchstart", function() {
  2595. if (this.buttonMode) {
  2596. this.buttonPressed = true;
  2597. var t = new enchant.Event(this.buttonMode + "buttondown");
  2598. this.dispatchEvent(t);
  2599. e.dispatchEvent(t)
  2600. }
  2601. });
  2602. this.addEventListener("touchend", function() {
  2603. if (this.buttonMode) {
  2604. this.buttonPressed = false;
  2605. var t = new enchant.Event(this.buttonMode + "buttonup");
  2606. this.dispatchEvent(t);
  2607. e.dispatchEvent(t)
  2608. }
  2609. });
  2610. var t = this,
  2611. n = function() {
  2612. t.dispatchEvent(new enchant.Event("render"))
  2613. };
  2614. this.addEventListener("addedtoscene", function() {
  2615. n();
  2616. e.addEventListener("exitframe", n)
  2617. });
  2618. this.addEventListener("removedfromscene", function() {
  2619. e.removeEventListener("exitframe", n)
  2620. });
  2621. this.addEventListener("render", function() {
  2622. if (this._offsetX !== this._previousOffsetX) this._style.left = this._offsetX + "px";
  2623. if (this._offsetY !== this._previousOffsetY) this._style.top = this._offsetY + "px";
  2624. this._previousOffsetX = this._offsetX;
  2625. this._previousOffsetY = this._offsetY
  2626. });
  2627. if (enchant.ENV.TOUCH_ENABLED) {
  2628. this._element.addEventListener("touchstart", function(e) {
  2629. for (var n = e.touches, r = 0, i = n.length; r < i; r++) {
  2630. e = new enchant.Event("touchstart");
  2631. e.identifier = n[r].identifier;
  2632. e._initPosition(n[r].pageX, n[r].pageY);
  2633. t.dispatchEvent(e)
  2634. }
  2635. }, false);
  2636. this._element.addEventListener("touchmove", function(e) {
  2637. for (var n = e.touches, r = 0, i = n.length; r < i; r++) {
  2638. e = new enchant.Event("touchmove");
  2639. e.identifier = n[r].identifier;
  2640. e._initPosition(n[r].pageX, n[r].pageY);
  2641. t.dispatchEvent(e)
  2642. }
  2643. }, false);
  2644. this._element.addEventListener("touchend", function(e) {
  2645. for (var n = e.changedTouches, r = 0, i = n.length; r < i; r++) {
  2646. e = new enchant.Event("touchend");
  2647. e.identifier = n[r].identifier;
  2648. e._initPosition(n[r].pageX, n[r].pageY);
  2649. t.dispatchEvent(e)
  2650. }
  2651. }, false)
  2652. } else {
  2653. this._element.addEventListener("mousedown", function(n) {
  2654. var r = n.pageX,
  2655. i = n.pageY,
  2656. n = new enchant.Event("touchstart");
  2657. n.identifier = e._mousedownID;
  2658. n._initPosition(r, i);
  2659. t.dispatchEvent(n);
  2660. t._mousedown = true
  2661. }, false);
  2662. e._element.addEventListener("mousemove", function(n) {
  2663. if (t._mousedown) {
  2664. var r = n.pageX,
  2665. i = n.pageY,
  2666. n = new enchant.Event("touchmove");
  2667. n.identifier = e._mousedownID;
  2668. n._initPosition(r, i);
  2669. t.dispatchEvent(n)
  2670. }
  2671. }, false);
  2672. e._element.addEventListener("mouseup", function(n) {
  2673. if (t._mousedown) {
  2674. var r = n.pageX,
  2675. i = n.pageY,
  2676. n = new enchant.Event("touchend");
  2677. n.identifier = e._mousedownID;
  2678. n._initPosition(r, i);
  2679. t.dispatchEvent(n);
  2680. t._mousedown = false
  2681. }
  2682. }, false)
  2683. }
  2684. },
  2685. id: {
  2686. get: function() {
  2687. return this._element.id
  2688. },
  2689. set: function(e) {
  2690. this._element.id = e
  2691. }
  2692. },
  2693. className: {
  2694. get: function() {
  2695. return this._element.className
  2696. },
  2697. set: function(e) {
  2698. this._element.className = e
  2699. }
  2700. },
  2701. width: {
  2702. get: function() {
  2703. return this._width
  2704. },
  2705. set: function(e) {
  2706. this._style.width = (this._width = e) + "px"
  2707. }
  2708. },
  2709. height: {
  2710. get: function() {
  2711. return this._height
  2712. },
  2713. set: function(e) {
  2714. this._style.height = (this._height = e) + "px"
  2715. }
  2716. },
  2717. backgroundColor: {
  2718. get: function() {
  2719. return this._backgroundColor
  2720. },
  2721. set: function(e) {
  2722. this._element.style.backgroundColor = this._backgroundColor = e
  2723. }
  2724. },
  2725. opacity: {
  2726. get: function() {
  2727. return this._opacity
  2728. },
  2729. set: function(e) {
  2730. this._style.opacity = this._opacity = e
  2731. }
  2732. },
  2733. visible: {
  2734. get: function() {
  2735. return this._visible
  2736. },
  2737. set: function(e) {
  2738. this._style.display = (this._visible = e) ? "block" : "none"
  2739. }
  2740. },
  2741. touchEnabled: {
  2742. get: function() {
  2743. return this._touchEnabled
  2744. },
  2745. set: function(e) {
  2746. this._style.pointerEvents = (this._touchEnabled = e) ? "all" : "none"
  2747. }
  2748. },
  2749. intersect: function(e) {
  2750. return this._offsetX < e._offsetX + e.width && e._offsetX < this._offsetX + this.width && this._offsetY < e._offsetY + e.height && e._offsetY < this._offsetY + this.height
  2751. },
  2752. within: function(e, t) {
  2753. t == null && (t = (this.width + this.height + e.width + e.height) / 4);
  2754. var n;
  2755. return (n = this._offsetX - e._offsetX + (this.width - e.width) / 2) * n + (n = this._offsetY - e._offsetY + (this.height - e.height) / 2) * n < t * t
  2756. },
  2757. scale: function(e, t) {
  2758. t == null && (t = e);
  2759. this._scaleX = this._scaleX * e;
  2760. this._scaleY = this._scaleY * t;
  2761. this._dirty = true
  2762. },
  2763. rotate: function(e) {
  2764. this._rotation = this._rotation + e;
  2765. this._dirty = true
  2766. },
  2767. scaleX: {
  2768. get: function() {
  2769. return this._scaleX
  2770. },
  2771. set: function(e) {
  2772. this._scaleX = e;
  2773. this._dirty = true
  2774. }
  2775. },
  2776. scaleY: {
  2777. get: function() {
  2778. return this._scaleY
  2779. },
  2780. set: function(e) {
  2781. this._scaleY = e;
  2782. this._dirty = true
  2783. }
  2784. },
  2785. rotation: {
  2786. get: function() {
  2787. return this._rotation
  2788. },
  2789. set: function(e) {
  2790. this._rotation = e;
  2791. this._dirty = true
  2792. }
  2793. }
  2794. });
  2795. enchant.Sprite = enchant.Class.create(enchant.Entity, {
  2796. initialize: function(e, t) {
  2797. enchant.Entity.call(this);
  2798. this.width = e;
  2799. this.height = t;
  2800. this._scaleY = this._scaleX = 1;
  2801. this._rotation = 0;
  2802. this._dirty = false;
  2803. this._image = null;
  2804. this._frame = 0;
  2805. this._frameSequence = [];
  2806. this._style.overflow = "hidden";
  2807. this.addEventListener("render", function() {
  2808. if (this._dirty) {
  2809. var e = ["rotate(", this._rotation, "deg)", "scale(", this._scaleX, ",", this._scaleY, ")"];
  2810. navigator.userAgent.indexOf("iPhone") !== -1 && e.push("translate3d(0,0,0)");
  2811. this._style[enchant.ENV.VENDOR_PREFIX + "Transform"] = e.join("");
  2812. this._dirty = false
  2813. }
  2814. });
  2815. this.addEventListener("enterframe", function() {
  2816. if (this._frameSequence.length !== 0) {
  2817. var e = this._frameSequence.shift();
  2818. if (e === null) this._frameSequence = [];
  2819. else {
  2820. this._setFrame(e);
  2821. this._frameSequence.push(e)
  2822. }
  2823. }
  2824. });
  2825. if (enchant.Game.instance._debug) {
  2826. this._style.border = "1px solid red";
  2827. this._style.margin = "-1px"
  2828. }
  2829. },
  2830. image: {
  2831. get: function() {
  2832. return this._image
  2833. },
  2834. set: function(e) {
  2835. if (e !== this._image) {
  2836. if (this._image != null)
  2837. if (this._image.css) this._style.backgroundImage = "";
  2838. else if (this._element.firstChild) {
  2839. this._element.removeChild(this._element.firstChild);
  2840. if (this._dirtyListener) {
  2841. this.removeEventListener("render", this._dirtyListener);
  2842. this._dirtyListener = null
  2843. } else this._image._parent = null
  2844. }
  2845. if (e != null)
  2846. if (e._css) this._style.backgroundImage = e._css;
  2847. else if (e._parent) {
  2848. var t = document.createElement("canvas"),
  2849. n = t.getContext("2d");
  2850. t.width = e.width;
  2851. t.height = e.height;
  2852. n.drawImage(e._element, 0, 0);
  2853. this._dirtyListener = function() {
  2854. if (e._dirty) {
  2855. n.drawImage(e._element);
  2856. e._dirty = false
  2857. }
  2858. };
  2859. this.addEventListener("render", this._dirtyListener);
  2860. this._element.appendChild(t)
  2861. } else {
  2862. e._parent = this;
  2863. this._element.appendChild(e._element)
  2864. }
  2865. this._image = e;
  2866. this.frame = this.frame
  2867. }
  2868. }
  2869. },
  2870. frame: {
  2871. get: function() {
  2872. return this._frame
  2873. },
  2874. set: function(e) {
  2875. if (e instanceof Array) {
  2876. var t = e.shift();
  2877. this._setFrame(t);
  2878. e.push(t);
  2879. this._frameSequence = e
  2880. } else {
  2881. this._setFrame(e);
  2882. this._frameSequence = [];
  2883. this._frame = e
  2884. }
  2885. }
  2886. },
  2887. _setFrame: function(e) {
  2888. if (this._image != null) {
  2889. this._frame = e;
  2890. var t = this._image.width / this._width | 0;
  2891. if (this._image._css) this._style.backgroundPosition = [-(e % t | 0) * this._width, "px ", -(e / t | 0) * this._height, "px"].join("");
  2892. else if (this._element.firstChild) {
  2893. var n = this._element.firstChild.style;
  2894. n.left = -(e % t | 0) * this._width + "px";
  2895. n.top = -(e / t | 0) * this._height + "px"
  2896. }
  2897. }
  2898. }
  2899. });
  2900. enchant.Label = enchant.Class.create(enchant.Entity, {
  2901. initialize: function(e) {
  2902. enchant.Entity.call(this);
  2903. this.width = 300;
  2904. this.text = e;
  2905. this.textAlign = "left"
  2906. },
  2907. text: {
  2908. get: function() {
  2909. return this._element.innerHTML
  2910. },
  2911. set: function(e) {
  2912. this._element.innerHTML = e
  2913. }
  2914. },
  2915. textAlign: {
  2916. get: function() {
  2917. return this._style.textAlign
  2918. },
  2919. set: function(e) {
  2920. this._style.textAlign = e
  2921. }
  2922. },
  2923. font: {
  2924. get: function() {
  2925. return this._style.font
  2926. },
  2927. set: function(e) {
  2928. this._style.font = e
  2929. }
  2930. },
  2931. color: {
  2932. get: function() {
  2933. return this._style.color
  2934. },
  2935. set: function(e) {
  2936. this._style.color = e
  2937. }
  2938. }
  2939. });
  2940. (function() {
  2941. enchant.Map = enchant.Class.create(enchant.Entity, {
  2942. initialize: function(e, t) {
  2943. var n = enchant.Game.instance;
  2944. enchant.Entity.call(this);
  2945. var r = document.createElement("canvas");
  2946. if (enchant.ENV.RETINA_DISPLAY && n.scale === 2) {
  2947. r.width = n.width * 2;
  2948. r.height = n.height * 2;
  2949. this._style.webkitTransformOrigin = "0 0";
  2950. this._style.webkitTransform = "scale(0.5)"
  2951. } else {
  2952. r.width = n.width;
  2953. r.height = n.height
  2954. }
  2955. this._element.appendChild(r);
  2956. this._context = r.getContext("2d");
  2957. this._tileWidth = e || 0;
  2958. this._tileHeight = t || 0;
  2959. this._image = null;
  2960. this._data = [
  2961. [
  2962. []
  2963. ]
  2964. ];
  2965. this.touchEnabled = this._tight = this._dirty = false;
  2966. this.collisionData = null;
  2967. this._listeners.render = null;
  2968. this.addEventListener("render", function() {
  2969. if (this._dirty || this._previousOffsetX == null) {
  2970. this._dirty = false;
  2971. this.redraw(0, 0, n.width, n.height)
  2972. } else if (this._offsetX !== this._previousOffsetX || this._offsetY !== this._previousOffsetY)
  2973. if (this._tight) {
  2974. var e = -this._offsetX,
  2975. t = -this._offsetY,
  2976. r = -this._previousOffsetX,
  2977. i = -this._previousOffsetY,
  2978. s = e - r + n.width,
  2979. o = r - e + n.width,
  2980. u = t - i + n.height,
  2981. a = i - t + n.height;
  2982. if (s > this._tileWidth && o > this._tileWidth && u > this._tileHeight && a > this._tileHeight) {
  2983. var f;
  2984. if (s < o) {
  2985. f = 0;
  2986. e = r - e;
  2987. o = s
  2988. } else {
  2989. f = e - r;
  2990. e = 0
  2991. } if (u < a) {
  2992. s = 0;
  2993. t = i - t
  2994. } else {
  2995. s = t - i;
  2996. t = 0;
  2997. u = a
  2998. } if (n._buffer == null) {
  2999. n._buffer = document.createElement("canvas");
  3000. n._buffer.width = this._context.canvas.width;
  3001. n._buffer.height = this._context.canvas.height
  3002. }
  3003. a = n._buffer.getContext("2d");
  3004. if (this._doubledImage) {
  3005. a.clearRect(0, 0, o * 2, u * 2);
  3006. a.drawImage(this._context.canvas, f * 2, s * 2, o * 2, u * 2, 0, 0, o * 2, u * 2);
  3007. a = this._context;
  3008. a.clearRect(e * 2, t * 2, o * 2, u * 2);
  3009. a.drawImage(n._buffer, 0, 0, o * 2, u * 2, e * 2, t * 2, o * 2, u * 2)
  3010. } else {
  3011. a.clearRect(0, 0, o, u);
  3012. a.drawImage(this._context.canvas, f, s, o, u, 0, 0, o, u);
  3013. a = this._context;
  3014. a.clearRect(e, t, o, u);
  3015. a.drawImage(n._buffer, 0, 0, o, u, e, t, o, u)
  3016. }
  3017. e === 0 ? this.redraw(o, 0, n.width - o, n.height) : this.redraw(0, 0, n.width - o, n.height);
  3018. t === 0 ? this.redraw(0, u, n.width, n.height - u) : this.redraw(0, 0, n.width, n.height - u)
  3019. } else this.redraw(0, 0, n.width, n.height)
  3020. } else this.redraw(0, 0, n.width, n.height);
  3021. this._previousOffsetX = this._offsetX;
  3022. this._previousOffsetY = this._offsetY
  3023. })
  3024. },
  3025. loadData: function(e) {
  3026. this._data = Array.prototype.slice.apply(arguments);
  3027. this._dirty = true;
  3028. this._tight = false;
  3029. for (var t = 0, n = this._data.length; t < n; t++) {
  3030. for (var r = 0, e = this._data[t], i = 0, s = e.length; i < s; i++)
  3031. for (var o = 0, u = e[i].length; o < u; o++) e[i][o] >= 0 && r++;
  3032. if (r / (e.length * e[0].length) > .2) {
  3033. this._tight = true;
  3034. break
  3035. }
  3036. }
  3037. },
  3038. checkTile: function(e, t) {
  3039. if (e < 0 || this.width <= e || t < 0 || this.height <= t) return false;
  3040. var n = this._image.width,
  3041. r = this._image.height,
  3042. r = this._tileHeight || r,
  3043. e = e / (this._tileWidth || n) | 0;
  3044. return this._data[0][t / r | 0][e]
  3045. },
  3046. hitTest: function(e, t) {
  3047. if (e < 0 || this.width <= e || t < 0 || this.height <= t) return false;
  3048. var n = this._image.width,
  3049. r = this._image.height,
  3050. i = this._tileWidth || n,
  3051. s = this._tileHeight || r,
  3052. e = e / i | 0,
  3053. t = t / s | 0;
  3054. if (this.collisionData != null) return this.collisionData[t] && !!this.collisionData[t][e];
  3055. for (var o = 0, u = this._data.length; o < u; o++) {
  3056. var a = this._data[o],
  3057. f;
  3058. if (a[t] != null && (f = a[t][e]) != null && 0 <= f && f < (n / i | 0) * (r / s | 0)) return true
  3059. }
  3060. return false
  3061. },
  3062. image: {
  3063. get: function() {
  3064. return this._image
  3065. },
  3066. set: function(e) {
  3067. var t = enchant.Game.instance;
  3068. this._image = e;
  3069. if (enchant.ENV.RETINA_DISPLAY && t.scale === 2) {
  3070. for (var t = new enchant.Surface(e.width * 2, e.height * 2), n = this._tileWidth || e.width, r = this._tileHeight || e.height, i = e.width / n | 0, s = e.height / r | 0, o = 0; o < s; o++)
  3071. for (var u = 0; u < i; u++) t.draw(e, u * n, o * r, n, r, u * n * 2, o * r * 2, n * 2, r * 2);
  3072. this._doubledImage = t
  3073. }
  3074. this._dirty = true
  3075. }
  3076. },
  3077. tileWidth: {
  3078. get: function() {
  3079. return this._tileWidth
  3080. },
  3081. set: function(e) {
  3082. this._tileWidth = e;
  3083. this._dirty = true
  3084. }
  3085. },
  3086. tileHeight: {
  3087. get: function() {
  3088. return this._tileHeight
  3089. },
  3090. set: function(e) {
  3091. this._tileHeight = e;
  3092. this._dirty = true
  3093. }
  3094. },
  3095. width: {
  3096. get: function() {
  3097. return this._tileWidth * this._data[0][0].length
  3098. }
  3099. },
  3100. height: {
  3101. get: function() {
  3102. return this._tileHeight * this._data[0].length
  3103. }
  3104. },
  3105. redraw: function(e, t, n, r) {
  3106. if (this._image != null) {
  3107. var i, s, o, u, a;
  3108. if (this._doubledImage) {
  3109. i = this._doubledImage;
  3110. s = this._tileWidth * 2;
  3111. o = this._tileHeight * 2;
  3112. u = -this._offsetX * 2;
  3113. a = -this._offsetY * 2;
  3114. e = e * 2;
  3115. t = t * 2;
  3116. n = n * 2;
  3117. r = r * 2
  3118. } else {
  3119. i = this._image;
  3120. s = this._tileWidth;
  3121. o = this._tileHeight;
  3122. u = -this._offsetX;
  3123. a = -this._offsetY
  3124. }
  3125. var f = i.width / s | 0,
  3126. l = i.height / o | 0,
  3127. c = Math.max((e + u) / s | 0, 0),
  3128. h = Math.max((t + a) / o | 0, 0),
  3129. p = Math.ceil((e + u + n) / s),
  3130. d = Math.ceil((t + a + r) / o);
  3131. i = i._element;
  3132. var v = this._context;
  3133. v.clearRect(e, t, n, r);
  3134. n = 0;
  3135. for (r = this._data.length; n < r; n++)
  3136. for (var m = this._data[n], g = Math.min(p, m[0].length), y = Math.min(d, m.length), t = h; t < y; t++)
  3137. for (e = c; e < g; e++) {
  3138. var b = m[t][e];
  3139. 0 <= b && b < f * l && v.drawImage(i, b % f * s, (b / f | 0) * o, s, o, e * s - u, t * o - a, s, o)
  3140. }
  3141. }
  3142. }
  3143. })
  3144. })();
  3145. enchant.Group = enchant.Class.create(enchant.Node, {
  3146. initialize: function() {
  3147. enchant.Node.call(this);
  3148. this.childNodes = [];
  3149. this._y = this._x = 0
  3150. },
  3151. addChild: function(e) {
  3152. this.childNodes.push(e);
  3153. e.parentNode = this;
  3154. e.dispatchEvent(new enchant.Event("added"));
  3155. if (this.scene) {
  3156. var t = new enchant.Event("addedtoscene");
  3157. e.scene = this.scene;
  3158. e.dispatchEvent(t);
  3159. e._updateCoordinate();
  3160. var n = document.createDocumentFragment(),
  3161. r, i = Array.prototype.push;
  3162. if (e._element) n.appendChild(e._element);
  3163. else if (e.childNodes)
  3164. for (r = e.childNodes.slice().reverse(); r.length;) {
  3165. e = r.pop();
  3166. e.scene = this.scene;
  3167. e.dispatchEvent(t);
  3168. e._element ? n.appendChild(e._element) : e.childNodes && i.apply(r, e.childNodes.reverse())
  3169. }
  3170. if (n.childNodes.length) {
  3171. for (var s, t = this; t.parentNode;) {
  3172. r = t.parentNode.childNodes;
  3173. for (r = r.slice(r.indexOf(t) + 1).reverse(); r.length;) {
  3174. e = r.pop();
  3175. if (e._element) {
  3176. s = e._element;
  3177. break
  3178. } else e.childNodes && i.apply(r, e.childNodes.slice().reverse())
  3179. }
  3180. t = t.parentNode
  3181. }
  3182. s ? this.scene._element.insertBefore(n, s) : this.scene._element.appendChild(n)
  3183. }
  3184. }
  3185. },
  3186. insertBefore: function(e, t) {
  3187. var n = this.childNodes.indexOf(t);
  3188. if (n !== -1) {
  3189. this.childNodes.splice(n, 0, e);
  3190. e.parentNode = this;
  3191. e.dispatchEvent(new enchant.Event("added"));
  3192. if (this.scene) {
  3193. var r = new enchant.Event("addedtoscene");
  3194. e.scene = this.scene;
  3195. e.dispatchEvent(r);
  3196. e._updateCoordinate();
  3197. var i = document.createDocumentFragment(),
  3198. s, o = Array.prototype.push;
  3199. if (e._element) i.appendChild(e._element);
  3200. else if (e.childNodes)
  3201. for (s = e.childNodes.slice().reverse(); s.length;) {
  3202. e = s.pop();
  3203. e.scene = this.scene;
  3204. e.dispatchEvent(r);
  3205. e._element ? i.appendChild(e._element) : e.childNodes && o.apply(s, e.childNodes.reverse())
  3206. }
  3207. if (i.childNodes.length) {
  3208. for (var u, r = t; r !== this;) {
  3209. if (n != null) {
  3210. s = this.childNodes.slice(n + 1).reverse();
  3211. n = null
  3212. } else {
  3213. s = r.parentNode.childNodes;
  3214. s = s.slice(s.indexOf(r) + 1).reverse()
  3215. }
  3216. for (; s.length;) {
  3217. e = s.pop();
  3218. if (e._element) {
  3219. u = e._element;
  3220. break
  3221. } else e.childNodes && o.apply(s, e.childNodes.slice().reverse())
  3222. }
  3223. r = r.parentNode
  3224. }
  3225. u ? this.scene._element.insertBefore(i, u) : this.scene._element.appendChild(i)
  3226. }
  3227. }
  3228. } else this.addChild(e)
  3229. },
  3230. removeChild: function(e) {
  3231. var t = this.childNodes.indexOf(e);
  3232. if (t !== -1) {
  3233. this.childNodes.splice(t, 1);
  3234. e.parentNode = null;
  3235. e.dispatchEvent(new enchant.Event("removed"));
  3236. if (this.scene) {
  3237. t = new enchant.Event("removedfromscene");
  3238. e.scene = null;
  3239. e.dispatchEvent(t);
  3240. if (e._element) this.scene._element.removeChild(e._element);
  3241. else if (e.childNodes)
  3242. for (var n = e.childNodes.slice(), r = Array.prototype.push; n.length;) {
  3243. e = n.pop();
  3244. e.scene = null;
  3245. e.dispatchEvent(t);
  3246. e._element ? this.scene._element.removeChild(e._element) : e.childNodes && r.apply(n, e.childNodes)
  3247. }
  3248. }
  3249. }
  3250. },
  3251. firstChild: {
  3252. get: function() {
  3253. return this.childNodes[0]
  3254. }
  3255. },
  3256. lastChild: {
  3257. get: function() {
  3258. return this.childNodes[this.childNodes.length - 1]
  3259. }
  3260. },
  3261. _updateCoordinate: function() {
  3262. if (this.parentNode) {
  3263. this._offsetX = this.parentNode._offsetX + this._x;
  3264. this._offsetY = this.parentNode._offsetY + this._y
  3265. } else {
  3266. this._offsetX = this._x;
  3267. this._offsetY = this._y
  3268. }
  3269. for (var e = 0, t = this.childNodes.length; e < t; e++) this.childNodes[e]._updateCoordinate()
  3270. }
  3271. });
  3272. enchant.RGroup = enchant.Class.create(enchant.Group, {
  3273. initialize: function(e, t) {
  3274. enchant.Group.call(this);
  3275. if (arguments.length < 2) throw "Width and height of RGroup must be specified";
  3276. this.width = e;
  3277. this.height = t;
  3278. this.rotationOrigin = {
  3279. x: e / 2,
  3280. y: t / 2
  3281. };
  3282. this._rotation = 0
  3283. },
  3284. addChild: function(e) {
  3285. enchant.Group.prototype.addChild.apply(this, arguments);
  3286. e.transformOrigin = "0 0"
  3287. },
  3288. rotation: {
  3289. get: function() {
  3290. return this._rotation
  3291. },
  3292. set: function(e) {
  3293. var t = e - this._rotation;
  3294. if (t !== 0) {
  3295. for (var n = t / 180 * Math.PI, r = Math.sin(n), n = Math.cos(n), i = this.width / 2, s = this.height / 2, o = 0, u = this.childNodes.length; o < u; o++) {
  3296. var a = this.childNodes[o];
  3297. a.rotation = a.rotation - t;
  3298. var f = a.x - i,
  3299. l = a.y - s;
  3300. a.x = +n * f + r * l + i;
  3301. a.y = -r * f + n * l + s
  3302. }
  3303. this._rotation = e
  3304. }
  3305. }
  3306. }
  3307. });
  3308. enchant.Scene = enchant.Class.create(enchant.Group, {
  3309. initialize: function() {
  3310. var e = enchant.Game.instance;
  3311. enchant.Group.call(this);
  3312. this._element = document.createElement("div");
  3313. this._element.style.position = "absolute";
  3314. this._element.style.overflow = "hidden";
  3315. this._element.style.width = (this.width = e.width) + "px";
  3316. this._element.style.height = (this.height = e.height) + "px";
  3317. this._element.style[enchant.ENV.VENDOR_PREFIX + "TransformOrigin"] = "0 0";
  3318. this._element.style[enchant.ENV.VENDOR_PREFIX + "Transform"] = "scale(" + e.scale + ")";
  3319. this.scene = this;
  3320. var t = this;
  3321. if (enchant.ENV.TOUCH_ENABLED) {
  3322. this._element.addEventListener("touchstart", function(e) {
  3323. for (var n = e.touches, r = 0, i = n.length; r < i; r++) {
  3324. e = new enchant.Event("touchstart");
  3325. e.identifier = n[r].identifier;
  3326. e._initPosition(n[r].pageX, n[r].pageY);
  3327. t.dispatchEvent(e)
  3328. }
  3329. }, false);
  3330. this._element.addEventListener("touchmove", function(e) {
  3331. for (var n = e.touches, r = 0, i = n.length; r < i; r++) {
  3332. e = new enchant.Event("touchmove");
  3333. e.identifier = n[r].identifier;
  3334. e._initPosition(n[r].pageX, n[r].pageY);
  3335. t.dispatchEvent(e)
  3336. }
  3337. }, false);
  3338. this._element.addEventListener("touchend", function(e) {
  3339. for (var n = e.changedTouches, r = 0, i = n.length; r < i; r++) {
  3340. e = new enchant.Event("touchend");
  3341. e.identifier = n[r].identifier;
  3342. e._initPosition(n[r].pageX, n[r].pageY);
  3343. t.dispatchEvent(e)
  3344. }
  3345. }, false)
  3346. } else {
  3347. this._element.addEventListener("mousedown", function(n) {
  3348. var r = n.pageX,
  3349. i = n.pageY,
  3350. n = new enchant.Event("touchstart");
  3351. n.identifier = e._mousedownID;
  3352. n._initPosition(r, i);
  3353. t.dispatchEvent(n);
  3354. t._mousedown = true
  3355. }, false);
  3356. e._element.addEventListener("mousemove", function(n) {
  3357. if (t._mousedown) {
  3358. var r = n.pageX,
  3359. i = n.pageY,
  3360. n = new enchant.Event("touchmove");
  3361. n.identifier = e._mousedownID;
  3362. n._initPosition(r, i);
  3363. t.dispatchEvent(n)
  3364. }
  3365. }, false);
  3366. e._element.addEventListener("mouseup", function(n) {
  3367. if (t._mousedown) {
  3368. var r = n.pageX,
  3369. i = n.pageY,
  3370. n = new enchant.Event("touchend");
  3371. n.identifier = e._mousedownID;
  3372. n._initPosition(r, i);
  3373. t.dispatchEvent(n);
  3374. t._mousedown = false
  3375. }
  3376. }, false)
  3377. }
  3378. },
  3379. backgroundColor: {
  3380. get: function() {
  3381. return this._backgroundColor
  3382. },
  3383. set: function(e) {
  3384. this._element.style.backgroundColor = this._backgroundColor = e
  3385. }
  3386. },
  3387. _updateCoordinate: function() {
  3388. this._offsetX = this._x;
  3389. this._offsetY = this._y;
  3390. for (var e = 0, t = this.childNodes.length; e < t; e++) this.childNodes[e]._updateCoordinate()
  3391. }
  3392. });
  3393. (function() {
  3394. enchant.CanvasGroup = enchant.Class.create(enchant.Group, {
  3395. initialize: function() {
  3396. var t = enchant.Game.instance,
  3397. o = this;
  3398. enchant.Group.call(this);
  3399. this._dirty = false;
  3400. this._rotation = 0;
  3401. this._cvsCache = {};
  3402. this._cvsCache.matrix = [1, 0, 0, 1, 0, 0];
  3403. this._cvsCache.detectColor = "#000000";
  3404. this.width = t.width;
  3405. this.height = t.height;
  3406. [enchant.Event.ADDED_TO_SCENE, enchant.Event.REMOVED_FROM_SCENE].forEach(function(e) {
  3407. this.addEventListener(e, function(e) {
  3408. this.childNodes.forEach(function(t) {
  3409. t.scene = this.scene;
  3410. t.dispatchEvent(e)
  3411. }, this)
  3412. })
  3413. }, this);
  3414. this._element = document.createElement("canvas");
  3415. this._element.width = t.width;
  3416. this._element.height = t.height;
  3417. this._element.style.position = "absolute";
  3418. this._detect = document.createElement("canvas");
  3419. this._detect.width = t.width;
  3420. this._detect.height = t.height;
  3421. this._detect.style.position = "absolute";
  3422. this.context = this._element.getContext("2d");
  3423. this._dctx = this._detect.getContext("2d");
  3424. this._colorManager = new s(16, 256);
  3425. if (enchant.ENV.TOUCH_ENABLED) {
  3426. this._element.addEventListener("touchstart", function(e) {
  3427. for (var t = e.touches, r = 0, i = t.length; r < i; r++) {
  3428. e = new enchant.Event("touchstart");
  3429. e.identifier = t[r].identifier;
  3430. e._initPosition(t[r].pageX, t[r].pageY);
  3431. n.call(o, e)
  3432. }
  3433. }, false);
  3434. this._element.addEventListener("touchmove", function(e) {
  3435. for (var t = e.touches, n = 0, i = t.length; n < i; n++) {
  3436. e = new enchant.Event("touchmove");
  3437. e.identifier = t[n].identifier;
  3438. e._initPosition(t[n].pageX, t[n].pageY);
  3439. r.call(o, e)
  3440. }
  3441. }, false);
  3442. this._element.addEventListener("touchend", function(e) {
  3443. for (var t = e.changedTouches, n = 0, r = t.length; n < r; n++) {
  3444. e = new enchant.Event("touchend");
  3445. e.identifier = t[n].identifier;
  3446. e._initPosition(t[n].pageX, t[n].pageY);
  3447. i.call(o, e)
  3448. }
  3449. }, false)
  3450. } else {
  3451. this._element.addEventListener("mousedown", function(e) {
  3452. var r = e.pageX,
  3453. i = e.pageY,
  3454. e = new enchant.Event("touchstart");
  3455. e.identifier = t._mousedownID;
  3456. e._initPosition(r, i);
  3457. n.call(o, e);
  3458. o._mousedown = true
  3459. }, false);
  3460. t._element.addEventListener("mousemove", function(e) {
  3461. if (o._mousedown) {
  3462. var n = e.pageX,
  3463. i = e.pageY,
  3464. e = new enchant.Event("touchmove");
  3465. e.identifier = t._mousedownID;
  3466. e._initPosition(n, i);
  3467. r.call(o, e)
  3468. }
  3469. }, false);
  3470. t._element.addEventListener("mouseup", function(e) {
  3471. if (o._mousedown) {
  3472. var n = e.pageX,
  3473. r = e.pageY,
  3474. e = new enchant.Event("touchend");
  3475. e.identifier = t._mousedownID;
  3476. e._initPosition(n, r);
  3477. i.call(o, e);
  3478. o._mousedown = false
  3479. }
  3480. }, false)
  3481. }
  3482. var u = [enchant.Event.EXIT, enchant.Event.REMOVED_FROM_SCENE];
  3483. [enchant.Event.ENTER, enchant.Event.ADDED_TO_SCENE].forEach(function(t) {
  3484. this.addEventListener(t, this._startRendering);
  3485. this.addEventListener(t, function() {
  3486. e.push(this)
  3487. })
  3488. }, this);
  3489. u.forEach(function(t) {
  3490. this.addEventListener(t, this._stopRendering);
  3491. this.addEventListener(t, function() {
  3492. var t = e.indexOf(this);
  3493. t !== -1 && e.splice(t, 1)
  3494. })
  3495. }, this);
  3496. this._onexitframe = function() {
  3497. var e = o.context;
  3498. e.clearRect(0, 0, t.width, t.height);
  3499. h.call(o, o._colorManager);
  3500. a.call(o, e)
  3501. }
  3502. },
  3503. _startRendering: function() {
  3504. var e = enchant.Game.instance;
  3505. e._listeners.exitframe || (e._listeners.exitframe = []);
  3506. e._listeners.exitframe.push(this._onexitframe)
  3507. },
  3508. _stopRendering: function() {
  3509. enchant.Game.instance.removeEventListener("exitframe", this._onexitframe)
  3510. },
  3511. _getEntityByPosition: function(e, t) {
  3512. var n = this._dctx;
  3513. n.clearRect(0, 0, this.width, this.height);
  3514. f.call(this, n);
  3515. n = n.getImageData(e, t, 1, 1).data;
  3516. return this._colorManager.getSpriteByColor(n)
  3517. },
  3518. _touchstartPropagation: function(e) {
  3519. var t = this._getEntityByPosition(e.x, e.y);
  3520. if (t) {
  3521. this._touching = t;
  3522. v.call(this._touching, e, this.parentNode)
  3523. } else t = null;
  3524. return t
  3525. },
  3526. _touchmovePropagation: function(e) {
  3527. this._touching != null && v.call(this._touching, e, this.parentNode)
  3528. },
  3529. _touchendPropagation: function(e) {
  3530. if (this._touching != null) {
  3531. v.call(this._touching, e, this.parentNode);
  3532. this._touching = null
  3533. }
  3534. },
  3535. rotation: {
  3536. get: function() {
  3537. return this._rotation
  3538. },
  3539. set: function(e) {
  3540. this._rotation = e;
  3541. this._dirty = true
  3542. }
  3543. },
  3544. scaleX: {
  3545. get: function() {
  3546. return this._scaleX
  3547. },
  3548. set: function(e) {
  3549. this._scaleX = e;
  3550. this._dirty = true
  3551. }
  3552. },
  3553. scaleY: {
  3554. get: function() {
  3555. return this._scaleY
  3556. },
  3557. set: function(e) {
  3558. this._scaleY = e;
  3559. this._dirty = true
  3560. }
  3561. },
  3562. addChild: function(e) {
  3563. this.childNodes.push(e);
  3564. e.parentNode = this;
  3565. e.dispatchEvent(new enchant.Event("added"));
  3566. if (this.scene) {
  3567. e.scene = this.scene;
  3568. var t = new enchant.Event("addedtoscene");
  3569. p.call(e, t, this._colorManager)
  3570. }
  3571. },
  3572. insertBefore: function(e, t) {
  3573. var n = this.childNodes.indexOf(t);
  3574. if (n !== -1) {
  3575. this.childNodes.splice(n, 0, e);
  3576. e.dispatchEvent(new enchant.Event("added"));
  3577. if (this.scene) {
  3578. e.scene = this.scene;
  3579. n = new enchant.Event("addedtoscene");
  3580. p.call(e, n, this._colorManager)
  3581. }
  3582. } else this.addChild(e)
  3583. },
  3584. removeChild: function(e) {
  3585. var t;
  3586. (t = this.childNodes.indexOf(e)) !== -1 && this.childNodes.splice(t, 1);
  3587. e.parentNode = null;
  3588. e.dispatchEvent(new enchant.Event("removed"));
  3589. if (this.scene) {
  3590. e.scene = null;
  3591. t = new enchant.Event("removedfromscene");
  3592. d.call(e, t, this._colorManager)
  3593. }
  3594. }
  3595. });
  3596. var e = [],
  3597. t = null,
  3598. n = function(n) {
  3599. for (var r = enchant.Game.instance, i, s = e.length - 1; s >= 0; s--) {
  3600. i = e[s];
  3601. if (i.scene === r.currentScene && i._touchstartPropagation(n)) {
  3602. t = i;
  3603. break
  3604. }
  3605. }
  3606. },
  3607. r = function(e) {
  3608. t != null && t._touchmovePropagation(e)
  3609. },
  3610. i = function(e) {
  3611. if (t != null) {
  3612. t._touchendPropagation(e);
  3613. t = null
  3614. }
  3615. };
  3616. if (enchant.widget) enchant.widget.EntityGroup.prototype.cvsRender = function(e) {
  3617. this.background && this.background._element.width > 0 && this.background._element.height > 0 && e.drawImage(this.background._element, 0, 0, this.width + 0, this.height + 0);
  3618. e.beginPath();
  3619. e.rect(0, 0, this.width, this.height);
  3620. e.clip()
  3621. };
  3622. enchant.Map.prototype.cvsRender = function(e) {
  3623. var t = enchant.Game.instance;
  3624. e.save();
  3625. e.setTransform(1, 0, 0, 1, 0, 0);
  3626. e.drawImage(this._element.firstChild, 0, 0, t.width, t.height);
  3627. e.restore()
  3628. };
  3629. enchant.Sprite.prototype.cvsRender = function(e) {
  3630. var t, n, r, i, s;
  3631. if (this._image) {
  3632. i = Math.abs(this._frame) || 0;
  3633. t = this._image;
  3634. n = t._element;
  3635. r = t.width / this._width | 0;
  3636. s = (i % r | 0) * this._width;
  3637. r = (i / r | 0) * this._height % t.height;
  3638. r = Math.min(r, t.height - this._height);
  3639. i = Math.min(t.width - s, this._width);
  3640. t = Math.min(t.height - r, this._height);
  3641. e.drawImage(n, s, r, i, t, 0, 0, this._width + 0, this._height + 0)
  3642. }
  3643. };
  3644. enchant.Label.prototype.cvsRender = function(e) {
  3645. if (this.text) {
  3646. e.textBaseline = "top";
  3647. e.font = this.font;
  3648. e.fillStyle = this.color || "#000000";
  3649. e.fillText(this.text, 0, 0, this.width + 0)
  3650. }
  3651. };
  3652. var s = enchant.Class.create({
  3653. initialize: function(e, t) {
  3654. this.reference = [];
  3655. this.detectColorNum = 0;
  3656. this.colorResolution = e || 16;
  3657. this.max = t || 1
  3658. },
  3659. attachDetectColor: function(e) {
  3660. this.detectColorNum = this.detectColorNum + 1;
  3661. this.reference[this.detectColorNum] = e;
  3662. return this._createNewColor()
  3663. },
  3664. detachDetectColor: function(e) {
  3665. e = this.reference.indexOf(e);
  3666. e !== -1 && (this.reference[e] = null)
  3667. },
  3668. _createNewColor: function() {
  3669. var e = this.detectColorNum,
  3670. t = this.colorResolution,
  3671. n = t / this.max;
  3672. return [parseInt(e / t / t % t, 10) / n, parseInt(e / t % t, 10) / n, parseInt(e % t, 10) / n, 1]
  3673. },
  3674. _decodeDetectColor: function(e) {
  3675. var t = this.colorResolution;
  3676. return ~~(e[0] * t * t * t / 256) + ~~(e[1] * t * t / 256) + ~~(e[2] * t / 256)
  3677. },
  3678. getSpriteByColor: function(e) {
  3679. return this.reference[this._decodeDetectColor(e)]
  3680. }
  3681. }),
  3682. o = function(e, t) {
  3683. var e = e || function() {},
  3684. t = t || function() {},
  3685. n = function() {
  3686. e.apply(this, arguments);
  3687. var r;
  3688. if (this.childNodes)
  3689. for (var i = 0, s = this.childNodes.length; i < s; i++) {
  3690. r = this.childNodes[i];
  3691. n.apply(r, arguments)
  3692. }
  3693. t.apply(this, arguments)
  3694. };
  3695. return n
  3696. },
  3697. u = function(e) {
  3698. if (e.__dirty || e._cvsCache.x !== e.x || e._cvsCache.y !== e.y || e._cvsCache.width !== e.width || e._cvsCache.height !== e.height) {
  3699. var t = e._cvsCache.matrix,
  3700. n = e.x,
  3701. r = e.y,
  3702. i = e.width || 0,
  3703. s = e.height || 0,
  3704. o = typeof e.scaleX === "number" ? e.scaleX : 1,
  3705. u = typeof e.scaleY === "number" ? e.scaleY : 1,
  3706. a = Math.PI * (e.rotation || 0) / 180,
  3707. f = Math.cos(a),
  3708. a = Math.sin(a),
  3709. i = typeof e.originX === "number" ? e.originX : i / 2,
  3710. s = typeof e.originY === "number" ? e.originY : s / 2;
  3711. t[0] = o * f;
  3712. t[1] = o * a;
  3713. t[2] = -u * a;
  3714. t[3] = u * f;
  3715. t[4] = -(o * f) * i + u * a * s + n + i;
  3716. t[5] = -(o * a) * i - u * f * s + r + s;
  3717. e.__dirty = false;
  3718. e._cvsCache.x = e.x;
  3719. e._cvsCache.y = e.y;
  3720. e._cvsCache.width = e.width;
  3721. e._cvsCache.height = e.height
  3722. }
  3723. },
  3724. a = o(function(e) {
  3725. e.save();
  3726. e.globalCompositeOperation = this.alphaBlending ? this.alphaBlending : "source-atob";
  3727. e.globalAlpha = this.opacity || 1;
  3728. u(this);
  3729. e.transform.apply(e, this._cvsCache.matrix);
  3730. var t = enchant.Game.instance;
  3731. if (this.backgroundColor) {
  3732. e.fillStyle = this.backgroundColor;
  3733. e.fillRect(0, 0, this.width + 0, this.height + 0)
  3734. }
  3735. this.cvsRender && this.cvsRender(e);
  3736. if (t._debug) {
  3737. e.strokeStyle = this instanceof enchant.Label || this instanceof enchant.Sprite ? "#ff0000" : "#0000ff";
  3738. e.strokeRect(0, 0, this.width + 0, this.height + 0)
  3739. }
  3740. }, function(e) {
  3741. e.restore()
  3742. }),
  3743. f = o(function(e) {
  3744. e.save();
  3745. u(this);
  3746. e.transform.apply(e, this._cvsCache.matrix);
  3747. e.fillStyle = this._cvsCache.detectColor;
  3748. e.fillRect(0, 0, this.width, this.height)
  3749. }, function(e) {
  3750. e.restore()
  3751. }),
  3752. l = function() {
  3753. this.__dirty = this._dirty ? true : false
  3754. },
  3755. c = function(e) {
  3756. if (!this._cvsCache) {
  3757. this.addEventListener("render", l);
  3758. this._cvsCache = {};
  3759. this._cvsCache.matrix = [];
  3760. var t = this._cvsCache,
  3761. e = e.attachDetectColor(this),
  3762. e = "#" + ("00" + Number(parseInt(e[0], 10)).toString(16)).slice(-2) + ("00" + Number(parseInt(e[1], 10)).toString(16)).slice(-2) + ("00" + Number(parseInt(e[2], 10)).toString(16)).slice(-2);
  3763. t.detectColor = e
  3764. }
  3765. },
  3766. h = o(function(e) {
  3767. c.call(this, e)
  3768. }),
  3769. p = o(function(e, t) {
  3770. this.dispatchEvent(e);
  3771. c.call(this, t)
  3772. }),
  3773. d = o(function(e, t) {
  3774. this.dispatchEvent(e);
  3775. if (this._cvsCache) {
  3776. this.removeEventListener("render", l);
  3777. t.detachDetectColor(this);
  3778. delete this._cvsCache
  3779. }
  3780. });
  3781. o(function(e) {
  3782. this.dispatchEvent(e)
  3783. });
  3784. var v = function(e, t) {
  3785. this.dispatchEvent(e);
  3786. this.parentNode && this.parentNode !== t && v.call(this.parentNode, e, t)
  3787. }
  3788. })();
  3789. enchant.Scene = enchant.Class.create(enchant.Group, {
  3790. initialize: function() {
  3791. enchant.Group.call(this);
  3792. this._element = document.createElement("div");
  3793. this._element.style.position = "absolute";
  3794. this._element.style.overflow = "hidden";
  3795. this._element.style.width = (this.width = enchant.Game.instance.width) + "px";
  3796. this._element.style.height = (this.height = enchant.Game.instance.height) + "px";
  3797. this._element.style[enchant.ENV.VENDOR_PREFIX + "TransformOrigin"] = "0 0";
  3798. this._element.style[enchant.ENV.VENDOR_PREFIX + "Transform"] = "scale(" + enchant.Game.instance.scale + ")";
  3799. this.scene = this;
  3800. var e = this;
  3801. if (enchant.ENV.TOUCH_ENABLED) {
  3802. this._element.addEventListener("touchstart", function(t) {
  3803. for (var n = t.touches, r = 0, i = n.length; r < i; r++) {
  3804. t = new enchant.Event("touchstart");
  3805. t.identifier = n[r].identifier;
  3806. t._initPosition(n[r].pageX, n[r].pageY);
  3807. e.dispatchEvent(t)
  3808. }
  3809. }, false);
  3810. this._element.addEventListener("touchmove", function(t) {
  3811. for (var n = t.touches, r = 0, i = n.length; r < i; r++) {
  3812. t = new enchant.Event("touchmove");
  3813. t.identifier = n[r].identifier;
  3814. t._initPosition(n[r].pageX, n[r].pageY);
  3815. e.dispatchEvent(t)
  3816. }
  3817. }, false);
  3818. this._element.addEventListener("touchend", function(t) {
  3819. for (var n = t.changedTouches, r = 0, i = n.length; r < i; r++) {
  3820. t = new enchant.Event("touchend");
  3821. t.identifier = n[r].identifier;
  3822. t._initPosition(n[r].pageX, n[r].pageY);
  3823. e.dispatchEvent(t)
  3824. }
  3825. }, false)
  3826. } else {
  3827. this._element.addEventListener("mousedown", function(t) {
  3828. var n = t.pageX,
  3829. r = t.pageY,
  3830. t = new enchant.Event("touchstart");
  3831. t.identifier = enchant.Game.instance._mousedownID;
  3832. t._initPosition(n, r);
  3833. e.dispatchEvent(t);
  3834. e._mousedown = true
  3835. }, false);
  3836. enchant.Game.instance._element.addEventListener("mousemove", function(t) {
  3837. if (e._mousedown) {
  3838. var n = t.pageX,
  3839. r = t.pageY,
  3840. t = new enchant.Event("touchmove");
  3841. t.identifier = enchant.Game.instance._mousedownID;
  3842. t._initPosition(n, r);
  3843. e.dispatchEvent(t)
  3844. }
  3845. }, false);
  3846. enchant.Game.instance._element.addEventListener("mouseup", function(t) {
  3847. if (e._mousedown) {
  3848. var n = t.pageX,
  3849. r = t.pageY,
  3850. t = new enchant.Event("touchend");
  3851. t.identifier = enchant.Game.instance._mousedownID;
  3852. t._initPosition(n, r);
  3853. e.dispatchEvent(t);
  3854. e._mousedown = false
  3855. }
  3856. }, false)
  3857. }
  3858. },
  3859. backgroundColor: {
  3860. get: function() {
  3861. return this._backgroundColor
  3862. },
  3863. set: function(e) {
  3864. this._element.style.backgroundColor = this._backgroundColor = e
  3865. }
  3866. },
  3867. _updateCoordinate: function() {
  3868. this._offsetX = this._x;
  3869. this._offsetY = this._y;
  3870. for (var e = 0, t = this.childNodes.length; e < t; e++) this.childNodes[e]._updateCoordinate()
  3871. }
  3872. });
  3873. enchant.Surface = enchant.Class.create(enchant.EventTarget, {
  3874. initialize: function(e, t) {
  3875. enchant.EventTarget.call(this);
  3876. var n = enchant.Game.instance;
  3877. this.width = e;
  3878. this.height = t;
  3879. this.context = null;
  3880. n = "enchant-surface" + n._surfaceID++;
  3881. if (document.getCSSCanvasContext) {
  3882. this.context = document.getCSSCanvasContext("2d", n, e, t);
  3883. this._element = this.context.canvas;
  3884. this._css = "-webkit-canvas(" + n + ")"
  3885. } else if (document.mozSetImageElement) {
  3886. this._element = document.createElement("canvas");
  3887. this._element.width = e;
  3888. this._element.height = t;
  3889. this._css = "-moz-element(#" + n + ")";
  3890. this.context = this._element.getContext("2d");
  3891. document.mozSetImageElement(n, this._element)
  3892. } else {
  3893. this._element = document.createElement("canvas");
  3894. this._element.width = e;
  3895. this._element.height = t;
  3896. this._element.style.position = "absolute";
  3897. this.context = this._element.getContext("2d");
  3898. enchant.ENV.CANVAS_DRAWING_METHODS.forEach(function(e) {
  3899. var t = this.context[e];
  3900. this.context[e] = function() {
  3901. t.apply(this, arguments);
  3902. this._dirty = true
  3903. }
  3904. }, this)
  3905. }
  3906. },
  3907. getPixel: function(e, t) {
  3908. return this.context.getImageData(e, t, 1, 1).data
  3909. },
  3910. setPixel: function(e, t, n, r, i, s) {
  3911. var o = this.context.createImageData(1, 1);
  3912. o.data[0] = n;
  3913. o.data[1] = r;
  3914. o.data[2] = i;
  3915. o.data[3] = s;
  3916. this.context.putImageData(o, e, t)
  3917. },
  3918. clear: function() {
  3919. this.context.clearRect(0, 0, this.width, this.height)
  3920. },
  3921. draw: function(e) {
  3922. e = e._element;
  3923. if (arguments.length === 1) this.context.drawImage(e, 0, 0);
  3924. else {
  3925. var t = arguments;
  3926. t[0] = e;
  3927. this.context.drawImage.apply(this.context, t)
  3928. }
  3929. },
  3930. clone: function() {
  3931. var e = new enchant.Surface(this.width, this.height);
  3932. e.draw(this);
  3933. return e
  3934. },
  3935. toDataURL: function() {
  3936. var e = this._element.src;
  3937. return e ? e.slice(0, 5) === "data:" ? e : this.clone().toDataURL() : this._element.toDataURL()
  3938. }
  3939. });
  3940. enchant.Surface.load = function(e) {
  3941. var t = new Image,
  3942. n = Object.create(enchant.Surface.prototype, {
  3943. context: {
  3944. value: null
  3945. },
  3946. _css: {
  3947. value: "url(" + e + ")"
  3948. },
  3949. _element: {
  3950. value: t
  3951. }
  3952. });
  3953. enchant.EventTarget.call(n);
  3954. t.src = e;
  3955. t.onerror = function() {
  3956. throw Error("Cannot load an asset: " + t.src)
  3957. };
  3958. t.onload = function() {
  3959. n.width = t.width;
  3960. n.height = t.height;
  3961. n.dispatchEvent(new enchant.Event("load"))
  3962. };
  3963. return n
  3964. };
  3965. enchant.Sound = enchant.Class.create(enchant.EventTarget, {
  3966. initialize: function() {
  3967. enchant.EventTarget.call(this);
  3968. this.duration = 0;
  3969. throw Error("Illegal Constructor")
  3970. },
  3971. play: function() {
  3972. this._element && this._element.play()
  3973. },
  3974. pause: function() {
  3975. this._element && this._element.pause()
  3976. },
  3977. stop: function() {
  3978. this.pause();
  3979. this.currentTime = 0
  3980. },
  3981. clone: function() {
  3982. var e;
  3983. if (this._element instanceof Audio) e = Object.create(enchant.Sound.prototype, {
  3984. _element: {
  3985. value: this._element.cloneNode(false)
  3986. },
  3987. duration: {
  3988. value: this.duration
  3989. }
  3990. });
  3991. else {
  3992. if (enchant.ENV.USE_FLASH_SOUND) return this;
  3993. e = Object.create(enchant.Sound.prototype)
  3994. }
  3995. enchant.EventTarget.call(e);
  3996. return e
  3997. },
  3998. currentTime: {
  3999. get: function() {
  4000. return this._element ? this._element.currentTime : 0
  4001. },
  4002. set: function(e) {
  4003. if (this._element) this._element.currentTime = e
  4004. }
  4005. },
  4006. volume: {
  4007. get: function() {
  4008. return this._element ? this._element.volume : 1
  4009. },
  4010. set: function(e) {
  4011. if (this._element) this._element.volume = e
  4012. }
  4013. }
  4014. });
  4015. enchant.Sound.load = function(e, t) {
  4016. if (t == null) var n = enchant.Game.findExt(e),
  4017. t = n ? "audio/" + n : "";
  4018. var t = t.replace("mp3", "mpeg").replace("m4a", "mp4"),
  4019. r = Object.create(enchant.Sound.prototype);
  4020. enchant.EventTarget.call(r);
  4021. var i = new Audio;
  4022. if (!enchant.Sound.enabledInMobileSafari && enchant.ENV.VENDOR_PREFIX === "webkit" && enchant.ENV.TOUCH_ENABLED) window.setTimeout(function() {
  4023. r.dispatchEvent(new enchant.Event("load"))
  4024. }, 0);
  4025. else if (!enchant.ENV.USE_FLASH_SOUND && i.canPlayType(t)) {
  4026. i.src = e;
  4027. i.load();
  4028. i.autoplay = false;
  4029. i.onerror = function() {
  4030. throw Error("Cannot load an asset: " + i.src)
  4031. };
  4032. i.addEventListener("canplaythrough", function() {
  4033. r.duration = i.duration;
  4034. r.dispatchEvent(new enchant.Event("load"))
  4035. }, false);
  4036. r._element = i
  4037. } else if (t === "audio/mpeg") {
  4038. var s = document.createElement("embed"),
  4039. n = "enchant-audio" + enchant.Game.instance._soundID++;
  4040. s.width = s.height = 1;
  4041. s.name = n;
  4042. s.src = "sound.swf?id=" + n + "&src=" + e;
  4043. s.allowscriptaccess = "always";
  4044. s.style.position = "absolute";
  4045. s.style.left = "-1px";
  4046. r.addEventListener("load", function() {
  4047. Object.defineProperties(s, {
  4048. currentTime: {
  4049. get: function() {
  4050. return s.getCurrentTime()
  4051. },
  4052. set: function(e) {
  4053. s.setCurrentTime(e)
  4054. }
  4055. },
  4056. volume: {
  4057. get: function() {
  4058. return s.getVolume()
  4059. },
  4060. set: function(e) {
  4061. s.setVolume(e)
  4062. }
  4063. }
  4064. });
  4065. r._element = s;
  4066. r.duration = s.getDuration()
  4067. });
  4068. enchant.Game.instance._element.appendChild(s);
  4069. enchant.Sound[n] = r
  4070. } else window.setTimeout(function() {
  4071. r.dispatchEvent(new enchant.Event("load"))
  4072. }, 0);
  4073. return r
  4074. };
  4075. enchant.Sound.enabledInMobileSafari = !1;
  4076. enchant.tl = {};
  4077. enchant.Event.ADDED_TO_TIMELINE = "addedtotimeline";
  4078. enchant.Event.REMOVED_FROM_TIMELINE = "removedfromtimeline";
  4079. enchant.Event.ACTION_START = "actionstart";
  4080. enchant.Event.ACTION_END = "actionend";
  4081. enchant.Event.ACTION_TICK = "actiontick";
  4082. enchant.Event.ACTION_ADDED = "actionadded";
  4083. enchant.Event.ACTION_REMOVED = "actionremoved";
  4084. (function() {
  4085. var e = enchant.Node.prototype.initialize;
  4086. enchant.Node.prototype.initialize = function() {
  4087. e.apply(this, arguments);
  4088. var t = this.tl = new enchant.tl.Timeline(this);
  4089. this.addEventListener("enterframe", function() {
  4090. t.dispatchEvent(new enchant.Event("enterframe"))
  4091. })
  4092. }
  4093. })();
  4094. enchant.tl.ActionEventTarget = enchant.Class.create(enchant.EventTarget, {
  4095. initialize: function() {
  4096. enchant.EventTarget.apply(this, arguments)
  4097. },
  4098. dispatchEvent: function(e) {
  4099. if (this.node) {
  4100. var t = this.node;
  4101. e.target = t;
  4102. e.localX = e.x - t._offsetX;
  4103. e.localY = e.y - t._offsetY
  4104. } else this.node = null;
  4105. null != this["on" + e.type] && this["on" + e.type].call(t, e);
  4106. var n = this._listeners[e.type];
  4107. if (null != n)
  4108. for (var n = n.slice(), r = 0, i = n.length; r < i; r++) n[r].call(t, e)
  4109. }
  4110. });
  4111. enchant.tl.Action = enchant.Class.create(enchant.tl.ActionEventTarget, {
  4112. initialize: function(e) {
  4113. enchant.tl.ActionEventTarget.call(this);
  4114. this.time = null;
  4115. this.frame = 0;
  4116. for (var t in e) e.hasOwnProperty(t) && null != e[t] && (this[t] = e[t]);
  4117. var n = this;
  4118. this.node = this.timeline = null;
  4119. this.addEventListener(enchant.Event.ADDED_TO_TIMELINE, function(e) {
  4120. n.timeline = e.timeline;
  4121. n.node = e.timeline.node;
  4122. n.frame = 0
  4123. });
  4124. this.addEventListener(enchant.Event.REMOVED_FROM_TIMELINE, function() {
  4125. n.timeline = null;
  4126. n.node = null;
  4127. n.frame = 0
  4128. });
  4129. this.addEventListener(enchant.Event.ACTION_TICK, function(e) {
  4130. n.frame++;
  4131. null != n.time && n.frame > n.time && e.timeline.next()
  4132. })
  4133. }
  4134. });
  4135. enchant.tl.ParallelAction = enchant.Class.create(enchant.tl.Action, {
  4136. initialize: function(e) {
  4137. enchant.tl.Action.call(this, e);
  4138. this.actions = [];
  4139. this.endedActions = [];
  4140. var t = this;
  4141. this.addEventListener(enchant.Event.ACTION_START, function(e) {
  4142. for (var n = 0, r = t.actions.length; n < r; n++) t.actions[n].dispatchEvent(e)
  4143. });
  4144. this.addEventListener(enchant.Event.ACTION_TICK, function(e) {
  4145. var n, r, i = new enchant.Event("actiontick");
  4146. i.timeline = {
  4147. next: function() {
  4148. var e = t.actions[n];
  4149. t.actions.splice(n--, 1);
  4150. r = t.actions.length;
  4151. t.endedActions.push(e);
  4152. var i = new enchant.Event("actionend");
  4153. i.timeline = this;
  4154. e.dispatchEvent(i);
  4155. i = new enchant.Event("removedfromtimeline");
  4156. i.timeline = this;
  4157. e.dispatchEvent(i)
  4158. }
  4159. };
  4160. n = 0;
  4161. for (r = t.actions.length; n < r; n++) t.actions[n].dispatchEvent(i);
  4162. 0 == t.actions.length && e.timeline.next()
  4163. });
  4164. this.addEventListener(enchant.Event.ADDED_TO_TIMELINE, function(e) {
  4165. for (var n = 0, r = t.actions.length; n < r; n++) t.actions[n].dispatchEvent(e)
  4166. });
  4167. this.addEventListener(enchant.Event.REMOVED_FROM_TIMELINE, function() {
  4168. this.actions = this.endedActions;
  4169. this.endedActions = []
  4170. })
  4171. }
  4172. });
  4173. enchant.tl.Tween = enchant.Class.create(enchant.tl.Action, {
  4174. initialize: function(e) {
  4175. var t = {},
  4176. n = {};
  4177. enchant.tl.Action.call(this, e);
  4178. null == this.easing && (this.easing = function(e, t, n, r) {
  4179. return n * e / r + t
  4180. });
  4181. var r = this;
  4182. this.addEventListener(enchant.Event.ACTION_START, function() {
  4183. var i = ["frame", "time", "callback", "onactiontick", "onactionstart", "onactionend"],
  4184. s;
  4185. for (s in e)
  4186. if (e.hasOwnProperty(s)) {
  4187. var o;
  4188. o = typeof e[s] == "function" ? e[s].call(r.node) : e[s];
  4189. if (i.indexOf(s) == -1) {
  4190. t[s] = r.node[s];
  4191. n[s] = o
  4192. }
  4193. }
  4194. });
  4195. this.addEventListener(enchant.Event.ACTION_TICK, function() {
  4196. var e = r.easing(r.frame, 0, 1, r.time),
  4197. i;
  4198. for (i in n)
  4199. if (n.hasOwnProperty(i) && typeof this[i] !== "undefined") {
  4200. var s = n[i] * e + t[i] * (1 - e);
  4201. r.node[i] = i === "x" || i === "y" ? Math.round(s) : s
  4202. }
  4203. })
  4204. }
  4205. });
  4206. enchant.tl.Timeline = enchant.Class.create(enchant.EventTarget, {
  4207. initialize: function(e) {
  4208. enchant.EventTarget.call(this);
  4209. this.node = e;
  4210. this.queue = [];
  4211. this.looped = this.paused = !1;
  4212. this._parallel = null;
  4213. this.addEventListener(enchant.Event.ENTER_FRAME, this.tick)
  4214. },
  4215. next: function() {
  4216. var e, t = this.queue.shift();
  4217. e = new enchant.Event("actionend");
  4218. e.timeline = this;
  4219. t.dispatchEvent(e);
  4220. this.looped ? (e = new enchant.Event("removedfromtimeline"), e.timeline = this, t.dispatchEvent(e), t.frame = 0, this.add(t)) : (e = new enchant.Event("removedfromtimeline"), e.timeline = this, t.dispatchEvent(e));
  4221. this.dispatchEvent(new enchant.Event("enterframe"))
  4222. },
  4223. tick: function() {
  4224. if (0 < this.queue.length) {
  4225. var e = this.queue[0];
  4226. 0 == e.frame && (t = new enchant.Event("actionstart"), t.timeline = this, e.dispatchEvent(t));
  4227. var t = new enchant.Event("actiontick");
  4228. t.timeline = this;
  4229. e.dispatchEvent(t)
  4230. }
  4231. },
  4232. add: function(e) {
  4233. this._parallel ? (this._parallel.actions.push(e), this._parallel = null) : this.queue.push(e);
  4234. e.frame = 0;
  4235. var t = new enchant.Event("addedtotimeline");
  4236. t.timeline = this;
  4237. e.dispatchEvent(t);
  4238. t = new enchant.Event("actionadded");
  4239. t.action = e;
  4240. this.dispatchEvent(t);
  4241. return this
  4242. },
  4243. action: function(e) {
  4244. return this.add(new enchant.tl.Action(e))
  4245. },
  4246. tween: function(e) {
  4247. return this.add(new enchant.tl.Tween(e))
  4248. },
  4249. clear: function() {
  4250. var e = new enchant.Event("removedfromtimeline");
  4251. e.timeline = this;
  4252. for (var t = 0, n = this.queue.length; t < n; t++) this.queue[t].dispatchEvent(e);
  4253. this.queue = [];
  4254. return this
  4255. },
  4256. skip: function(e) {
  4257. for (; e--;) this.dispatchEvent(new enchant.Event("enterframe"));
  4258. return this
  4259. },
  4260. pause: function() {
  4261. this.paused = !1;
  4262. return this
  4263. },
  4264. resume: function() {
  4265. this.paused = !0;
  4266. return this
  4267. },
  4268. loop: function() {
  4269. this.looped = !0;
  4270. return this
  4271. },
  4272. unloop: function() {
  4273. this.looped = !1;
  4274. return this
  4275. },
  4276. delay: function(e) {
  4277. this.add(new enchant.tl.Action({
  4278. time: e
  4279. }));
  4280. return this
  4281. },
  4282. wait: function() {
  4283. return this
  4284. },
  4285. then: function(e) {
  4286. var t = this;
  4287. this.add(new enchant.tl.Action({
  4288. onactiontick: function() {
  4289. e.call(t.node);
  4290. t.next()
  4291. }
  4292. }));
  4293. return this
  4294. },
  4295. exec: function(e) {
  4296. this.then(e)
  4297. },
  4298. cue: function(e) {
  4299. var t = 0,
  4300. n;
  4301. for (n in e) e.hasOwnProperty(n) && (this.delay(n - t), this.then(e[n]), t = n)
  4302. },
  4303. repeat: function(e, t) {
  4304. this.add(new enchant.tl.Action({
  4305. onactiontick: function() {
  4306. e.call(this)
  4307. },
  4308. time: t
  4309. }));
  4310. return this
  4311. },
  4312. and: function() {
  4313. var e = this.queue.pop();
  4314. if (e instanceof enchant.tl.ParallelAction) this._parallel = e, this.queue.push(e);
  4315. else {
  4316. var t = new enchant.tl.ParallelAction;
  4317. t.actions.push(e);
  4318. this.queue.push(t);
  4319. this._parallel = t
  4320. }
  4321. return this
  4322. },
  4323. or: function() {
  4324. return this
  4325. },
  4326. doAll: function() {
  4327. return this
  4328. },
  4329. waitAll: function() {
  4330. return this
  4331. },
  4332. waitUntil: function(e) {
  4333. var t = this;
  4334. this.add(new enchant.tl.Action({
  4335. onactionstart: e,
  4336. onactiontick: function(e) {
  4337. e.call(this) && t.next()
  4338. }
  4339. }));
  4340. return this
  4341. },
  4342. fadeTo: function(e, t, n) {
  4343. this.tween({
  4344. opacity: e,
  4345. time: t,
  4346. easing: n
  4347. });
  4348. return this
  4349. },
  4350. fadeIn: function(e, t) {
  4351. return this.fadeTo(1, e, t)
  4352. },
  4353. fadeOut: function(e, t) {
  4354. return this.fadeTo(0, e, t)
  4355. },
  4356. moveTo: function(e, t, n, r) {
  4357. return this.tween({
  4358. x: e,
  4359. y: t,
  4360. time: n,
  4361. easing: r
  4362. })
  4363. },
  4364. moveX: function(e, t, n) {
  4365. return this.tween({
  4366. x: e,
  4367. time: t,
  4368. easing: n
  4369. })
  4370. },
  4371. moveY: function(e, t, n) {
  4372. return this.tween({
  4373. y: e,
  4374. time: t,
  4375. easing: n
  4376. })
  4377. },
  4378. moveBy: function(e, t, n, r) {
  4379. return this.tween({
  4380. x: function() {
  4381. return this.x + e
  4382. },
  4383. y: function() {
  4384. return this.y + t
  4385. },
  4386. time: n,
  4387. easing: r
  4388. })
  4389. },
  4390. hide: function() {
  4391. return this.then(function() {
  4392. this.opacity = 0
  4393. })
  4394. },
  4395. show: function() {
  4396. return this.then(function() {
  4397. this.opacity = 1
  4398. })
  4399. },
  4400. removeFromScene: function() {
  4401. return this.then(function() {
  4402. this.scene.removeChild(this)
  4403. })
  4404. },
  4405. scaleTo: function(e, t, n) {
  4406. return this.tween({
  4407. scaleX: e,
  4408. scaleY: e,
  4409. time: t,
  4410. easing: n
  4411. })
  4412. },
  4413. scaleBy: function(e, t, n) {
  4414. return this.tween({
  4415. scaleX: function() {
  4416. return this.scaleX * e
  4417. },
  4418. scaleY: function() {
  4419. return this.scaleY * e
  4420. },
  4421. time: t,
  4422. easing: n
  4423. })
  4424. },
  4425. rotateTo: function(e, t, n) {
  4426. return this.tween({
  4427. rotation: e,
  4428. time: t,
  4429. easing: n
  4430. })
  4431. },
  4432. rotateBy: function(e, t, n) {
  4433. return this.tween({
  4434. rotation: function() {
  4435. return this.rotation + e
  4436. },
  4437. time: t,
  4438. easing: n
  4439. })
  4440. }
  4441. });
  4442. enchant.Easing = {
  4443. LINEAR: function(e, t, n, r) {
  4444. return n * e / r + t
  4445. },
  4446. QUAD_EASEIN: function(e, t, n, r) {
  4447. return n * (e /= r) * e + t
  4448. },
  4449. QUAD_EASEOUT: function(e, t, n, r) {
  4450. return -n * (e /= r) * (e - 2) + t
  4451. },
  4452. QUAD_EASEINOUT: function(e, t, n, r) {
  4453. return 1 > (e /= r / 2) ? n / 2 * e * e + t : -n / 2 * (--e * (e - 2) - 1) + t
  4454. },
  4455. CUBIC_EASEIN: function(e, t, n, r) {
  4456. return n * (e /= r) * e * e + t
  4457. },
  4458. CUBIC_EASEOUT: function(e, t, n, r) {
  4459. return n * ((e = e / r - 1) * e * e + 1) + t
  4460. },
  4461. CUBIC_EASEINOUT: function(e, t, n, r) {
  4462. return 1 > (e /= r / 2) ? n / 2 * e * e * e + t : n / 2 * ((e -= 2) * e * e + 2) + t
  4463. },
  4464. QUART_EASEIN: function(e, t, n, r) {
  4465. return n * (e /= r) * e * e * e + t
  4466. },
  4467. QUART_EASEOUT: function(e, t, n, r) {
  4468. return -n * ((e = e / r - 1) * e * e * e - 1) + t
  4469. },
  4470. QUART_EASEINOUT: function(e, t, n, r) {
  4471. return 1 > (e /= r / 2) ? n / 2 * e * e * e * e + t : -n / 2 * ((e -= 2) * e * e * e - 2) + t
  4472. },
  4473. QUINT_EASEIN: function(e, t, n, r) {
  4474. return n * (e /= r) * e * e * e * e + t
  4475. },
  4476. QUINT_EASEOUT: function(e, t, n, r) {
  4477. return n * ((e = e / r - 1) * e * e * e * e + 1) + t
  4478. },
  4479. QUINT_EASEINOUT: function(e, t, n, r) {
  4480. return 1 > (e /= r / 2) ? n / 2 * e * e * e * e * e + t : n / 2 * ((e -= 2) * e * e * e * e + 2) + t
  4481. },
  4482. SIN_EASEIN: function(e, t, n, r) {
  4483. return -n * Math.cos(e / r * (Math.PI / 2)) + n + t
  4484. },
  4485. SIN_EASEOUT: function(e, t, n, r) {
  4486. return n * Math.sin(e / r * (Math.PI / 2)) + t
  4487. },
  4488. SIN_EASEINOUT: function(e, t, n, r) {
  4489. return -n / 2 * (Math.cos(Math.PI * e / r) - 1) + t
  4490. },
  4491. CIRC_EASEIN: function(e, t, n, r) {
  4492. return -n * (Math.sqrt(1 - (e /= r) * e) - 1) + t
  4493. },
  4494. CIRC_EASEOUT: function(e, t, n, r) {
  4495. return n * Math.sqrt(1 - (e = e / r - 1) * e) + t
  4496. },
  4497. CIRC_EASEINOUT: function(e, t, n, r) {
  4498. return 1 > (e /= r / 2) ? -n / 2 * (Math.sqrt(1 - e * e) - 1) + t : n / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) + t
  4499. },
  4500. ELASTIC_EASEIN: function(e, t, n, r, i, s) {
  4501. if (0 == e) return t;
  4502. if (1 == (e /= r)) return t + n;
  4503. s || (s = .3 * r);
  4504. !i || i < Math.abs(n) ? (i = n, n = s / 4) : n = s / (2 * Math.PI) * Math.asin(n / i);
  4505. return -(i * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - n) * 2 * Math.PI / s)) + t
  4506. },
  4507. ELASTIC_EASEOUT: function(e, t, n, r, i, s) {
  4508. if (0 == e) return t;
  4509. if (1 == (e /= r)) return t + n;
  4510. s || (s = .3 * r);
  4511. if (!i || i < Math.abs(n)) var i = n,
  4512. o = s / 4;
  4513. else o = s / (2 * Math.PI) * Math.asin(n / i);
  4514. return i * Math.pow(2, -10 * e) * Math.sin((e * r - o) * 2 * Math.PI / s) + n + t
  4515. },
  4516. ELASTIC_EASEINOUT: function(e, t, n, r, i, s) {
  4517. if (0 == e) return t;
  4518. if (2 == (e /= r / 2)) return t + n;
  4519. s || (s = r * .3 * 1.5);
  4520. if (!i || i < Math.abs(n)) var i = n,
  4521. o = s / 4;
  4522. else o = s / (2 * Math.PI) * Math.asin(n / i);
  4523. return 1 > e ? -.5 * i * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - o) * 2 * Math.PI / s) + t : .5 * i * Math.pow(2, -10 * (e -= 1)) * Math.sin((e * r - o) * 2 * Math.PI / s) + n + t
  4524. },
  4525. BOUNCE_EASEOUT: function(e, t, n, r) {
  4526. return (e /= r) < 1 / 2.75 ? n * 7.5625 * e * e + t : e < 2 / 2.75 ? n * (7.5625 * (e -= 1.5 / 2.75) * e + .75) + t : e < 2.5 / 2.75 ? n * (7.5625 * (e -= 2.25 / 2.75) * e + .9375) + t : n * (7.5625 * (e -= 2.625 / 2.75) * e + .984375) + t
  4527. },
  4528. BOUNCE_EASEIN: function(e, t, n, r) {
  4529. return n - enchant.Easing.BOUNCE_EASEOUT(r - e, 0, n, r) + t
  4530. },
  4531. BOUNCE_EASEINOUT: function(e, t, n, r) {
  4532. return e < r / 2 ? .5 * enchant.Easing.BOUNCE_EASEIN(2 * e, 0, n, r) + t : .5 * enchant.Easing.BOUNCE_EASEOUT(2 * e - r, 0, n, r) + .5 * n + t
  4533. },
  4534. BACK_EASEIN: function(e, t, n, r, i) {
  4535. void 0 == i && (i = 1.70158);
  4536. return n * (e /= r) * e * ((i + 1) * e - i) + t
  4537. },
  4538. BACK_EASEOUT: function(e, t, n, r, i) {
  4539. void 0 == i && (i = 1.70158);
  4540. return n * ((e = e / r - 1) * e * ((i + 1) * e + i) + 1) + t
  4541. },
  4542. BACK_EASEINOUT: function(e, t, n, r, i) {
  4543. void 0 == i && (i = 1.70158);
  4544. return 1 > (e /= r / 2) ? n / 2 * e * e * (((i *= 1.525) + 1) * e - i) + t : n / 2 * ((e -= 2) * e * (((i *= 1.525) + 1) * e + i) + 2) + t
  4545. },
  4546. EXPO_EASEIN: function(e, t, n, r) {
  4547. return 0 == e ? t : n * Math.pow(2, 10 * (e / r - 1)) + t
  4548. },
  4549. EXPO_EASEOUT: function(e, t, n, r) {
  4550. return e == r ? t + n : n * (-Math.pow(2, -10 * e / r) + 1) + t
  4551. },
  4552. EXPO_EASEINOUT: function(e, t, n, r) {
  4553. return 0 == e ? t : e == r ? t + n : 1 > (e /= r / 2) ? n / 2 * Math.pow(2, 10 * (e - 1)) + t : n / 2 * (-Math.pow(2, -10 * --e) + 2) + t
  4554. }
  4555. };
  4556. window.addEventListener("load", function() {
  4557. var e = window.config && window.config.code_run_origin || "http://coderun.9leap.net",
  4558. t = {
  4559. 37: "left",
  4560. 38: "up",
  4561. 39: "right",
  4562. 40: "down",
  4563. 32: "a"
  4564. },
  4565. n = {},
  4566. r;
  4567. (r = document.getElementById("preview-iframe")) && r.contentWindow && ["down", "up"].forEach(function(i) {
  4568. window.addEventListener("key" + i, function(s) {
  4569. for (var o in t)
  4570. if (t.hasOwnProperty(o) && o == s.keyCode) {
  4571. if ("down" == i && n[o] || "up" == i && !n[o]) break;
  4572. n[o] = "down" === i;
  4573. r.contentWindow.postMessage(JSON.stringify({
  4574. type: "event",
  4575. value: t[o] + "button" + i
  4576. }), e);
  4577. console.log("event sent: ", t[o] + "button" + i)
  4578. }
  4579. }, !1)
  4580. })
  4581. });
  4582. enchant.bmfont = {};
  4583. enchant.bmfont.fonts = {};
  4584. enchant.bmfont.createFont = function(e, t, n) {
  4585. void 0 === enchant.bmfont.getFont(e) && (t = new Font(e, t, n), enchant.bmfont.fonts[e] = t)
  4586. };
  4587. enchant.bmfont.getFont = function(e) {
  4588. return enchant.bmfont.fonts[e]
  4589. };
  4590. enchant.bmfont.Font = enchant.Class.create({
  4591. initialize: function(e, t, n) {
  4592. t = (new JKL.ParseXML(t)).parse().font.chars["char"];
  4593. this.fontName = e;
  4594. this.charactersCount = t.length;
  4595. this.characters = {};
  4596. for (e = t.length - 1; 0 <= e; e--) this.characters[t[e].id] = t[e];
  4597. this.fontTexture = n
  4598. }
  4599. });
  4600. enchant.bmfont.FontSprite = enchant.Class.create(enchant.Sprite, {
  4601. initialize: function(e, t, n, r) {
  4602. this.font = "string" === typeof e ? enchant.bmfont.getFont(e) : e;
  4603. this._text = "";
  4604. this._textWidth = 0;
  4605. enchant.Sprite.call(this, t, n);
  4606. this.image = new Surface(t, n);
  4607. this.text = r
  4608. },
  4609. text: {
  4610. get: function() {
  4611. return this._text
  4612. },
  4613. set: function(e) {
  4614. this._text = e;
  4615. this.draw(e)
  4616. }
  4617. },
  4618. textWidth: {
  4619. get: function() {
  4620. return this._textWidth
  4621. }
  4622. },
  4623. draw: function(e) {
  4624. var t, n, r, i, s, o, u, a, f = 0;
  4625. this.image.clear();
  4626. for (t = 0; t < e.length; t++) n = e.charCodeAt(t), a = this.font.characters[n.toString()], n = parseInt(a.x), r = parseInt(a.y), i = parseInt(a.width), s = parseInt(a.height), u = parseInt(a.xoffset), o = parseInt(a.yoffset), a = parseInt(a.xadvance), this.image.draw(this.font.fontTexture, n, r, i, s, f + u, o, i, s), f += a;
  4627. this._textWidth = f
  4628. }
  4629. });
  4630. GAME_UID = "cfd002";
  4631. _G = {
  4632. ROW_MAXIMUM: 10,
  4633. COLUMN_MAXIMUM: 6,
  4634. FLICK_MIN_DISTANCE: 50,
  4635. FLICK_MAX_VARIANCE: 25
  4636. };
  4637. _G.highscoreTable = initHighscore();
  4638. _G.score = 0;
  4639. var Gem = enchant.Class.create(enchant.Sprite, {
  4640. initialize: function() {
  4641. enchant.Sprite.apply(this, [40, 40]);
  4642. this.image = _G.game.assets["res/gem_sheet_1.png"];
  4643. this.evolutions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
  4644. this.evolutionLevel = 0;
  4645. this.y = this.x = -100
  4646. },
  4647. setEvolutionLevel: function(e) {
  4648. this.tl.clear();
  4649. this.evolutionLevel = e;
  4650. if (this.evolutionLevel < this.evolutions.length) return this.frame = this.evolutions[this.evolutionLevel], !1;
  4651. this.evolutionLevel = this.evolutions.length - 1;
  4652. this.frame = this.evolutions[this.evolutionLevel];
  4653. return !0
  4654. },
  4655. flashToWhite: function() {
  4656. var e = this;
  4657. this.tl.repeat(function() {
  4658. e.tl.delay(1).then(function() {
  4659. this.frame += this.evolutions.length
  4660. })
  4661. }, 3)
  4662. },
  4663. fadeFromWhite: function() {
  4664. var e = this;
  4665. this.frame += 4 * this.evolutions.length;
  4666. this.tl.repeat(function() {
  4667. e.tl.delay(1).then(function() {
  4668. this.frame -= this.evolutions.length
  4669. })
  4670. }, 3)
  4671. },
  4672. toJSON: function() {
  4673. return this.evolutionLevel
  4674. }
  4675. }),
  4676. PopupScore = enchant.Class.create(enchant.Label, {
  4677. initialize: function(e) {
  4678. enchant.Label.apply(this, [e]);
  4679. this.font = "18px verdana";
  4680. this.textAlign = "left";
  4681. this.color = "#ffffff";
  4682. this._style.textShadow = "-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black"
  4683. },
  4684. setup: function(e, t, n) {
  4685. this.color = 3 >= e ? "#00ff00" : 3 < e && 7 > e ? "#ffff00" : "#ff0000";
  4686. this.text = addCommas(t.toString());
  4687. 1 < n && (this.text += " x " + n.toString())
  4688. }
  4689. }),
  4690. PopupScorePool = enchant.Class.create(enchant.Group, {
  4691. initialize: function() {
  4692. enchant.Group.apply(this);
  4693. this.pool = []
  4694. },
  4695. get: function() {
  4696. var e = this.pool.pop();
  4697. void 0 === e && (e = new PopupScore("test"));
  4698. return e
  4699. },
  4700. remove: function(e) {
  4701. e.parentNode.removeChild(e);
  4702. this.pool.push(e)
  4703. }
  4704. }),
  4705. ReportTab = enchant.Class.create(enchant.Group, {
  4706. initialize: function() {
  4707. enchant.Group.apply(this);
  4708. this.tab = new Sprite(168, 271);
  4709. this.tab.image = _G.game.assets["res/GUI_NewSpecies.png"];
  4710. this.isAppear = !1;
  4711. this.isClickable = !0;
  4712. this.tab.addEventListener("touchstart", this.onTouchStart);
  4713. this.addChild(this.tab);
  4714. this.x = -136;
  4715. this.y = 88;
  4716. this.warning = new Sprite(38, 44);
  4717. this.warning.image = _G.game.assets["res/GUI_NewSpecies_Warning.png"];
  4718. this.addChild(this.warning);
  4719. this.warning.x = 136;
  4720. this.warning.y = 22;
  4721. this.warning.opacity = 0
  4722. },
  4723. onTouchStart: function() {
  4724. this.parentNode.isClickable && (this.parentNode.isAppear = !this.parentNode.isAppear, this.parentNode.isAppear ? TweenLite.to(this.parentNode, .75, {
  4725. x: 0,
  4726. ease: Power2.easeOut
  4727. }) : TweenLite.to(this.parentNode, .75, {
  4728. x: -136,
  4729. ease: Power2.easeOut
  4730. }))
  4731. },
  4732. addCreature: function(e) {
  4733. var t = new Gem;
  4734. t.setEvolutionLevel(e);
  4735. if (highestEvolutionLevel < e + 1) {
  4736. highestEvolutionLevel = e + 1
  4737. }
  4738. this.addChild(t);
  4739. t.x = 42 + 44 * (e % 2);
  4740. t.y = 223 - 42 * Math.floor(e / 2)
  4741. },
  4742. postNotification: function() {
  4743. var e = this.warning;
  4744. this.warning.opacity = 0;
  4745. this.warning.scaleX = 1.5;
  4746. this.warning.scaleY = 1.5;
  4747. this.warning.tl.delay(30).fadeIn(10).and().scaleTo(1, 10, enchant.Easing.BOUNCE_EASEOUT).delay(20).then(function() {
  4748. e.opacity = 0
  4749. })
  4750. }
  4751. }),
  4752. Board = enchant.Class.create(enchant.Group, {
  4753. initialize: function(e, t) {
  4754. enchant.Group.apply(this);
  4755. this.rowMaximum = e;
  4756. this.columnMaximum = t;
  4757. this.pool = [];
  4758. this.board = Array(this.rowMaximum);
  4759. for (var n = 0; n < this.rowMaximum; n++) {
  4760. this.board[n] = Array(this.columnMaximum);
  4761. for (var r = 0; r < this.columnMaximum; r++) {
  4762. this.board[n][r] = null;
  4763. var i = this.createGem(0);
  4764. this.addGemToGroup(i);
  4765. this.poolGem(i)
  4766. }
  4767. }
  4768. },
  4769. poolGem: function(e) {
  4770. this.removeChild(e);
  4771. this.pool.push(e)
  4772. },
  4773. createGem: function(e) {
  4774. var t = this.pool.pop();
  4775. void 0 == t && (t = new Gem);
  4776. t.setEvolutionLevel(e);
  4777. t.scene = this;
  4778. t.row = -1;
  4779. t.column = -1;
  4780. return t
  4781. },
  4782. addGemToGroup: function(e) {
  4783. this.addChild(e)
  4784. },
  4785. getGemAt: function(e, t) {
  4786. if (0 <= e && e < this.rowMaximum && 0 <= t && t < this.columnMaximum) return this.board[e][t]
  4787. },
  4788. removeGemAt: function(e, t) {
  4789. this.board[e][t] = null
  4790. },
  4791. removeGem: function(e) {
  4792. this.getGemAt(e.row, e.column) === e && this.removeGemAt(e.row, e.column)
  4793. },
  4794. setGemAt: function(e, t, n) {
  4795. e.row = t;
  4796. e.column = n;
  4797. this.board[t][n] = e
  4798. },
  4799. getGemPositionAt: function(e, t) {
  4800. 1 < e ? e = 2 === e ? 1.2 : e - 1 : 1 === e && null != this.getGemAt(2, t) && (e = .2);
  4801. return {
  4802. x: 38 * t + 44,
  4803. y: 38 * e + 6
  4804. }
  4805. },
  4806. checkGemsMatch: function(e, t) {
  4807. return null !== e && null !== t ? e.evolutionLevel === t.evolutionLevel : !1
  4808. },
  4809. makeGemFall: function(a, b) {
  4810. for (var c = !1, d = this.rowMaximum - 1; 0 < d; d--)
  4811. for (var e = 0; e < this.columnMaximum; e++)
  4812. if (null === this.getGemAt(d, e))
  4813. for (var f = 0, g = null, h = d; 0 <= h; h--) g = this.getGemAt(h, e), null === g ? f++ : (this.removeGem(g), this.setGemAt(g, h + f, e), c = this.getGemPositionAt(h + f, e), g.x = c.x, g.tl.moveTo(g.x, c.y, 6, enchant.Easing.QUAD_EASEIN).scaleTo(1.25, 1).scaleTo(1, 12, enchant.Easing.ELASTIC_EASEOUT), c = !0);
  4814. if (void 0 !== a)
  4815. if (c) with(b) setTimeout(function() {
  4816. a.call(b)
  4817. }, 500);
  4818. else a.call(b)
  4819. },
  4820. queryGemsIntoGroup: function() {
  4821. for (var e = [], t = 0; t < _G.ROW_MAXIMUM; t++)
  4822. for (var n = 0; n < _G.COLUMN_MAXIMUM; n++) {
  4823. var r = this.getGemAt(t, n);
  4824. if (null !== r) {
  4825. for (var i = !1, s = 0; s < e.length; s++)
  4826. if (containsObject(r, e[s])) {
  4827. i = !0;
  4828. break
  4829. }
  4830. i || (i = [], this.findSameColor(i, r), 2 < i.length && e.push(i))
  4831. }
  4832. }
  4833. return e
  4834. },
  4835. findSameColor: function(e, t) {
  4836. if (null !== t) {
  4837. e.push(t);
  4838. var n = t.row,
  4839. r = t.column;
  4840. if (0 < t.row) {
  4841. var i = this.getGemAt(n - 1, r);
  4842. this.checkGemsMatch(t, i) && !1 == containsObject(i, e) && this.findSameColor(e, i)
  4843. }
  4844. t.row < _G.ROW_MAXIMUM - 1 && (i = this.getGemAt(n + 1, r), this.checkGemsMatch(t, i) && !1 == containsObject(i, e) && this.findSameColor(e, i));
  4845. 0 < t.column && (i = this.getGemAt(n, r - 1), this.checkGemsMatch(t, i) && !1 == containsObject(i, e) && this.findSameColor(e, i));
  4846. t.column < _G.COLUMN_MAXIMUM - 1 && (i = this.getGemAt(n, r + 1), this.checkGemsMatch(t, i) && !1 == containsObject(i, e) && this.findSameColor(e, i))
  4847. }
  4848. },
  4849. mergeGems: function(e) {
  4850. var t, n, r = _G.COLUMN_MAXIMUM,
  4851. i = 0,
  4852. s;
  4853. for (n = 0; n < e.length; n++) t = e[n], t.row > i ? (i = t.row, r = t.column) : t.row === i && t.column < r && (r = t.column);
  4854. var o = this.getGemPositionAt(i, r);
  4855. for (n = 0; n < e.length; n++) t = e[n], this.removeGem(t), s = t.evolutionLevel, t.tl.clear(), t.flashToWhite(), TweenLite.to(t, .75, {
  4856. x: o.x,
  4857. y: o.y,
  4858. ease: Back.easeIn,
  4859. onComplete: function(e, t) {
  4860. e.poolGem(t)
  4861. },
  4862. onCompleteParams: [this, t]
  4863. });
  4864. e = this.createGem(s + 1);
  4865. this.setGemAt(e, i, r);
  4866. e.x = o.x;
  4867. e.y = o.y;
  4868. e.scaleX = 0;
  4869. e.scaleY = 0;
  4870. this.addGemToGroup(e);
  4871. e.fadeFromWhite();
  4872. e.tl.delay(12).scaleTo(1, 12, enchant.Easing.ELASTIC_EASEOUT);
  4873. r = {};
  4874. r.gem = e;
  4875. r.level = s + 2;
  4876. return r
  4877. },
  4878. randomFill: function() {
  4879. for (var e = 0; e < this.rowMaximum; e++)
  4880. for (var t = 0; t < this.columnMaximum; t++) {
  4881. var n = this.createGem(0);
  4882. this.setGemAt(n, e, t);
  4883. this.addGemToGroup(n);
  4884. var r = this.getGemPositionAt(e, t);
  4885. n.x = r.x;
  4886. n.y = -200;
  4887. n.tl.moveTo(n.x, r.y, 24, enchant.Easing.EXPO_EASEIN)
  4888. }
  4889. }
  4890. }),
  4891. HighscoreBoard = enchant.Class.create(enchant.Group, {
  4892. initialize: function() {
  4893. enchant.Group.apply(this);
  4894. this.logo = new Sprite(185, 30);
  4895. this.logo.image = _G.game.assets["res/GUI_MainMenu_Menu_HighScoreHeader.png"];
  4896. this.logo.x = 69;
  4897. this.logo.y = 39;
  4898. this.addChild(this.logo);
  4899. this.entries = [];
  4900. for (var e = 0; 10 > e; e++) {
  4901. var t = new Group,
  4902. n = new Label((e + 1).toString() + ".) ------"),
  4903. r = new Label("0"),
  4904. i = _G.highscoreTable[e];
  4905. if (void 0 != i) {
  4906. var s = new Date(i.date);
  4907. n.text = (e + 1).toString() + ".) " + s.getFullYear() + "/" + (s.getMonth() + 1) + "/" + s.getDate();
  4908. r.text = addCommas(i.score.toString())
  4909. }
  4910. t.addChild(n);
  4911. t.addChild(r);
  4912. n.x = 54;
  4913. r.x = -54;
  4914. n.y = r.y = 104 + 24 * e;
  4915. n.font = r.font = "12px verdana";
  4916. n.textAlign = "left";
  4917. r.textAlign = "right";
  4918. this.entries.push(t);
  4919. this.addChild(t)
  4920. }
  4921. },
  4922. fadeOut: function() {},
  4923. fadeIn: function() {}
  4924. }),
  4925. ReplaySession = enchant.Class.create({
  4926. initialize: function(e) {
  4927. this.seed = e;
  4928. this.boardState = [];
  4929. this.score = [];
  4930. this.selectedGems = [];
  4931. this.reservedGems = [];
  4932. this.nextGems = []
  4933. },
  4934. recordTurn: function(e, t, n, r, i) {
  4935. this.boardState.push(e);
  4936. this.score.push(t);
  4937. this.selectedGems.push(n);
  4938. this.reservedGems.push(r);
  4939. this.nextGems.push(i)
  4940. },
  4941. stringify: function() {
  4942. var e = {};
  4943. e.boardState = this.boardState;
  4944. e.score = this.score;
  4945. e.selectedGems = this.selectedGems;
  4946. e.reservedGems = this.reservedGems;
  4947. e.nextGems = this.nextGems;
  4948. return JSON.stringify(e)
  4949. }
  4950. }),
  4951. ScenePause = enchant.Class.create(enchant.Scene, {
  4952. initialize: function() {
  4953. enchant.Scene.apply(this);
  4954. this.blackBG = new Sprite(320, 480);
  4955. var e = new Surface(320, 480);
  4956. e.context.beginPath();
  4957. e.context.rect(0, 0, 320, 480);
  4958. e.context.fillStyle = "#000000";
  4959. e.context.fill();
  4960. this.blackBG.image = e;
  4961. this.blackBG.opacity = .5;
  4962. this.addChild(this.blackBG);
  4963. this.addEventListener("touchend", function() {
  4964. enchant.Game.instance.popScene()
  4965. })
  4966. }
  4967. }),
  4968. SceneGame = enchant.Class.create(enchant.Scene, {
  4969. initialize: function() {
  4970. this.replaySession = new ReplaySession(Random.seedrandom());
  4971. enchant.Scene.apply(this);
  4972. this.STATE_WAIT = 0;
  4973. this.STATE_CONTROL = 1;
  4974. this.STATE_GAMEOVER = 2;
  4975. this.currentCombo = 1;
  4976. this.selectedGems = [];
  4977. this.reservedGems = [];
  4978. this.nextGems = [];
  4979. this.popupPool = new PopupScorePool;
  4980. this.board = new Board(_G.ROW_MAXIMUM, _G.COLUMN_MAXIMUM);
  4981. this.state = this.STATE_WAIT;
  4982. this.flickFinish = this.isControllable = !1;
  4983. this.touchStartPos = {
  4984. x: 0,
  4985. y: 0
  4986. };
  4987. var a = new Sprite(320, 480),
  4988. b = new Sprite(92, 63),
  4989. c = new Sprite(238, 19);
  4990. this.reportTab = new ReportTab;
  4991. for (var d = 0; 2 > d; d++) this.reportTab.addCreature(d);
  4992. b.x = 32;
  4993. b.y = 363;
  4994. this.reserveArea = new Sprite(48, 96);
  4995. this.reserveArea.owner = this;
  4996. a.image = _G.game.assets["res/ABO_BG.png"];
  4997. b.image = _G.game.assets["res/game_anim_sheet.png"];
  4998. b.tl.delay(30).then(function() {
  4999. b.frame = 1
  5000. }).delay(30).then(function() {
  5001. b.frame = 0
  5002. }).loop();
  5003. c.image = _G.game.assets["res/wave_sheet.png"];
  5004. c.x = 40;
  5005. c.y = 84;
  5006. c.tl.repeat(function() {
  5007. c.tl.delay(10).then(function() {
  5008. c.frame += 1;
  5009. c.frame %= 4
  5010. })
  5011. }, 4).loop();
  5012. this.warning = new Sprite(38, 44);
  5013. this.warning.image = _G.game.assets["res/GUI_NewSpecies_Warning.png"];
  5014. this.warning.x = 136;
  5015. this.warning.y = 22;
  5016. this.warning.opacity = 0;
  5017. this.scoreLabel = new FontSprite("score", 200, 48, "0");
  5018. this.scoreLabel.x = 280 - this.scoreLabel.textWidth;
  5019. this.scoreLabel.y = 380;
  5020. this.bgAnim = b;
  5021. this.addChild(a);
  5022. this.addChild(b);
  5023. this.addChild(c);
  5024. this.addChild(this.board);
  5025. this.addChild(this.warning);
  5026. this.addChild(this.reserveArea);
  5027. this.addChild(this.popupPool);
  5028. this.addChild(this.reportTab);
  5029. this.addChild(this.scoreLabel);
  5030. this.instruction = new Sprite(320, 440);
  5031. this.instruction.image = _G.game.assets["res/Instructions_2.png"];
  5032. this.addChild(this.instruction);
  5033. TweenLite.from(this.instruction, .5, {
  5034. opacity: 0,
  5035. scaleX: .8,
  5036. scaleY: .8
  5037. });
  5038. this.registerTouchListeners();
  5039. this.registerKeyboardListeners();
  5040. this.evolutionLevel = 2;
  5041. this.generateNextPairOfGems();
  5042. with(this) setTimeout(function() {
  5043. getNextPairOfGems()
  5044. }, 500);
  5045. this.setScore(0);
  5046. a = new PopupScore("更多好玩的游戏在Play68.com");
  5047. a.textAlign = "center";
  5048. a.font = "14px verdana";
  5049. a.x = 10;
  5050. a.y = 452;
  5051. this.addChild(a)
  5052. },
  5053. showScorePopup: function(e, t, n, r, i) {
  5054. var s = this.popupPool,
  5055. o = this.popupPool.get();
  5056. o.x = e;
  5057. o.y = t;
  5058. o.setup(n, r, i);
  5059. o.tl.moveTo(e, t - 16, 15, enchant.Easing.QUAD_EASEOUT).delay(20).then(function() {
  5060. s.remove(o)
  5061. });
  5062. s.addChild(o)
  5063. },
  5064. setScore: function(e) {
  5065. _G.score === _G.confirmScore ? (_G.score = e, _G.confirmScore = _G.score, this.scoreLabel.text = addCommas(e.toString())) : this.scoreLabel.text = "I CHEATED!";
  5066. this.scoreLabel.x = 280 - this.scoreLabel.textWidth
  5067. },
  5068. changeState: function(e) {
  5069. e === this.STATE_WAIT ? this.isControllable = !1 : this.state === this.STATE_WAIT && e === this.STATE_CONTROL && (this.isControllable = !0);
  5070. this.state = e
  5071. },
  5072. generateNextPairOfGems: function() {
  5073. for (var e = 0; 2 > e; e++) {
  5074. var t = this.board.createGem(this.randomNextGem());
  5075. this.nextGems.push(t);
  5076. var n = this.board.getGemPositionAt(e, _G.COLUMN_MAXIMUM);
  5077. t.x = n.x;
  5078. t.y = n.y - 48;
  5079. t.scaleX = 1;
  5080. t.scaleY = 1;
  5081. TweenLite.to(t, .5, {
  5082. y: n.y,
  5083. ease: Quad.easeOut
  5084. });
  5085. this.board.addGemToGroup(t)
  5086. }
  5087. },
  5088. randomNextGem: function() {
  5089. for (var e = this.evolutionLevel; e >= this.evolutionLevel;) e = Math.floor(randNormal(0, 11 / 3)), e = Math.abs(e);
  5090. return e
  5091. },
  5092. getNextPairOfGems: function() {
  5093. for (var a = 0; 2 > a; a++) {
  5094. var b = this.nextGems[a],
  5095. c = this.board.getGemPositionAt(1, 2 + a);
  5096. this.board.setGemAt(b, 1, 2 + a);
  5097. TweenLite.to(b, .5, {
  5098. x: c.x,
  5099. y: c.y,
  5100. ease: Power2.easeOut
  5101. });
  5102. this.selectedGems.push(b)
  5103. }
  5104. this.nextGems = [];
  5105. this.generateNextPairOfGems();
  5106. with(this) setTimeout(function() {
  5107. changeState(STATE_CONTROL)
  5108. }, 300)
  5109. },
  5110. moveHorizontal: function(e) {
  5111. for (var t = !0, n, r, i = 0; 2 > i; i++)
  5112. if (n = this.selectedGems[i], r = n.column + e, 0 > r || r >= _G.COLUMN_MAXIMUM) {
  5113. t = !1;
  5114. break
  5115. }
  5116. if (t)
  5117. for (i = 0; 2 > i; i++) {
  5118. n = this.selectedGems[i];
  5119. r = n.column + e;
  5120. t = n.row;
  5121. this.board.removeGem(n);
  5122. var s = this.board.getGemPositionAt(t, r);
  5123. this.board.setGemAt(n, t, r);
  5124. TweenLite.to(n, .5, {
  5125. x: s.x,
  5126. y: s.y,
  5127. ease: Power2.easeOut
  5128. })
  5129. }
  5130. },
  5131. rotateGems: function() {
  5132. var e, t, n, r, i, s;
  5133. e = this.selectedGems[0];
  5134. t = this.selectedGems[1];
  5135. n = e.row;
  5136. r = e.column;
  5137. i = t.row;
  5138. s = t.column;
  5139. e.row === t.row ? e.column < t.column ? (n = 0, r = t.column) : (i = 0, s = e.column) : e.row < t.row ? 0 === t.column ? (n = t.row, r = t.column + 1) : (n = t.row, r = t.column, s = t.column - 1) : 0 === e.column ? (i = e.row, s = e.column + 1) : (i = e.row, s = e.column, r = e.column - 1);
  5140. var o = this.board.getGemPositionAt(n, r),
  5141. u = this.board.getGemPositionAt(i, s);
  5142. this.board.removeGem(e);
  5143. this.board.removeGem(t);
  5144. this.board.setGemAt(e, n, r);
  5145. this.board.setGemAt(t, i, s);
  5146. TweenLite.to(e, .5, {
  5147. x: o.x,
  5148. y: o.y,
  5149. ease: Power2.easeOut
  5150. });
  5151. TweenLite.to(t, .5, {
  5152. x: u.x,
  5153. y: u.y,
  5154. ease: Power2.easeOut
  5155. })
  5156. },
  5157. dropSelectedGems: function() {
  5158. null != this.instruction && (TweenLite.to(this.instruction, .5, {
  5159. opacity: 0,
  5160. onCompleteScope: this.instruction,
  5161. onComplete: function() {
  5162. this.parentNode.removeChild(this)
  5163. }
  5164. }), this.instruction = null);
  5165. for (var a = 0; a < this.selectedGems.length; a++) TweenLite.killTweensOf(this.selectedGems[a]);
  5166. this.selectedGems = [];
  5167. this.changeState(this.STATE_WAIT);
  5168. this.board.makeGemFall();
  5169. with(this) setTimeout(function() {
  5170. checkForMatches()
  5171. }, 305)
  5172. },
  5173. saveTurnState: function(e) {
  5174. e.recordTurn(this.board.board, this.score, this.selectedGems, this.reservedGems, this.nextGems)
  5175. },
  5176. swapWithReserve: function() {
  5177. var e, t, n, r;
  5178. if (0 === this.reservedGems.length) {
  5179. for (var i = 0; 2 > i; i++) e = this.selectedGems[i], this.board.removeGem(e), e.row = -1, e.column = -1, n = this.board.getGemPositionAt(i, -1), this.reservedGems.push(e), TweenLite.to(e, .5, {
  5180. x: n.x,
  5181. y: n.y,
  5182. ease: Power2.easeOut
  5183. });
  5184. this.selectedGems = [];
  5185. this.getNextPairOfGems()
  5186. } else
  5187. for (i = 0; 2 > i; i++) e = this.selectedGems[i], t = this.reservedGems[i], this.board.setGemAt(t, e.row, e.column), e.row = -1, e.column = -1, this.reservedGems[i] = e, this.selectedGems[i] = t, n = this.board.getGemPositionAt(i, -1), r = this.board.getGemPositionAt(t.row, t.column), TweenLite.to(e, .5, {
  5188. x: n.x,
  5189. y: n.y,
  5190. ease: Power2.easeOut
  5191. }), TweenLite.to(t, .5, {
  5192. x: r.x,
  5193. y: r.y,
  5194. ease: Power2.easeOut
  5195. })
  5196. },
  5197. checkForMatches: function() {
  5198. var a = this.board.queryGemsIntoGroup();
  5199. if (0 !== a.length) with(this) setTimeout(function() {
  5200. eraseTheMatches(a)
  5201. }, 100);
  5202. else this.currentCombo = 1, this.checkGameEndCondition()
  5203. },
  5204. eraseTheMatches: function(a) {
  5205. for (var b = 0; b < a.length; b++) {
  5206. var c = a[b].length,
  5207. d = this.board.mergeGems(a[b]),
  5208. e = d.level,
  5209. d = d.gem,
  5210. f = Math.pow(3, e - 1),
  5211. g = Math.pow(3, e - 2) * Math.max(a[b].length - 3, 0);
  5212. this.setScore(_G.score + (f - g) * this.currentCombo);
  5213. this.showScorePopup(d.x, d.y, c, f - g, this.currentCombo);
  5214. e > this.evolutionLevel && (this.evolutionLevel = e, this.reportTab.addCreature(e - 1), this.postNotification(d.x, d.y))
  5215. }
  5216. this.currentCombo++;
  5217. with(this) setTimeout(function() {
  5218. board.makeGemFall()
  5219. }, 1255), setTimeout(function() {
  5220. checkForMatches()
  5221. }, 1525)
  5222. },
  5223. postNotification: function(e, t) {
  5224. var n = this.warning;
  5225. this.warning.x = e;
  5226. this.warning.y = t - 32;
  5227. this.warning.opacity = 0;
  5228. this.warning.scaleX = 1.5;
  5229. this.warning.scaleY = 1.5;
  5230. this.warning.tl.delay(30).fadeIn(10).and().scaleTo(1, 10, enchant.Easing.BOUNCE_EASEOUT).delay(20).then(function() {
  5231. n.opacity = 0
  5232. })
  5233. },
  5234. checkGameEndCondition: function() {
  5235. for (var a = !1, b, c = 0; 3 > c; c++)
  5236. for (var d = 0; d < _G.COLUMN_MAXIMUM; d++)
  5237. if (b = this.board.getGemAt(c, d), null !== b) {
  5238. a = !0;
  5239. break
  5240. }
  5241. if (a) with(this) setTimeout(function() {
  5242. gameOverEffect()
  5243. }, 250);
  5244. else this.getNextPairOfGems()
  5245. },
  5246. gameOverEffect: function() {
  5247. if (_G.score === _G.confirmScore) {
  5248. var e = createHighscoreEntry(_G.score);
  5249. addToHighscoreList(e);
  5250. // updateShareScore(_G.score);
  5251. // Play68.setRankingLevelScoreDesc(highestEvolutionLevel, _G.score)
  5252. }
  5253. for (var t = this, n = 0; n < _G.ROW_MAXIMUM; n++)
  5254. for (var r = 0; r < _G.COLUMN_MAXIMUM; r++)
  5255. if (e = this.board.getGemAt(n, r), null != e) {
  5256. e.beforeShakeX = e.x;
  5257. e.beforeShakeY = e.y;
  5258. var i = new TimelineMax({
  5259. repeat: 12,
  5260. onCompleteScope: e,
  5261. onComplete: function() {
  5262. this.tl.clear();
  5263. this.tl.moveTo(-120 + rand(440), -100 - rand(200), 30, enchant.Easing.QUAD_EASEOUT)
  5264. }
  5265. });
  5266. i.append(TweenLite.to(e, 1 / enchant.Game.instance.fps, {
  5267. onComplete: function() {
  5268. var e = this.beforeShakeX - 2 + 4 * Math.random(),
  5269. t = this.beforeShakeY - 2 + 4 * Math.random();
  5270. this.moveTo(e, t)
  5271. },
  5272. onCompleteScope: e
  5273. }));
  5274. i.append(TweenLite.to(e, 1 / enchant.Game.instance.fps, {
  5275. onComplete: function() {
  5276. this.moveTo(this.beforeShakeX, this.beforeShakeY)
  5277. },
  5278. onCompleteScope: e
  5279. }))
  5280. }
  5281. var s = this.bgAnim;
  5282. s.image = _G.game.assets["res/game_anim_gameover_sheet.png"];
  5283. s.tl.clear();
  5284. s.tl.delay(5).then(function() {
  5285. s.frame = 1
  5286. }).delay(5).then(function() {
  5287. s.frame = 0
  5288. }).loop();
  5289. this.gameOverLogo = new Sprite(195, 50);
  5290. this.gameOverLogo.image = _G.game.assets["res/GUI_GameOver.png"];
  5291. this.gameOverLogo.opacity = 0;
  5292. this.gameOverLogo.x = 62;
  5293. this.gameOverLogo.y = 190;
  5294. this.gameOverLogo.tl.delay(40).fadeIn(10).then(function() {
  5295. t.state = t.STATE_GAMEOVER;
  5296. });
  5297. this.addChild(this.gameOverLogo)
  5298. },
  5299. touchToReturn: function() {
  5300. _G.game.replaceScene(new SceneMainMenu)
  5301. },
  5302. registerTouchListeners: function() {
  5303. this.reserveArea.addEventListener("touchstart", function() {
  5304. this.owner.isControllable && this.owner.swapWithReserve()
  5305. });
  5306. this.addEventListener("touchstart", function(e) {
  5307. window.scrollTo(0, 0);
  5308. this.state === this.STATE_GAMEOVER ? this.touchToReturn() : (null != this.instruction && (TweenLite.to(this.instruction, .5, {
  5309. opacity: 0,
  5310. onCompleteScope: this.instruction,
  5311. onComplete: function() {
  5312. this.parentNode.removeChild(this)
  5313. }
  5314. }), this.instruction = null), this.flickFinish = !1, this.touchStartPos.x = e.x, this.touchStartPos.y = e.y)
  5315. });
  5316. this.addEventListener("touchmove", function(e) {
  5317. if (!this.flickFinish && this.isControllable) {
  5318. var t = e.x - this.touchStartPos.x,
  5319. n = e.y - this.touchStartPos.y,
  5320. r = Math.abs(t),
  5321. i = Math.abs(n);
  5322. r > _G.FLICK_MIN_DISTANCE && i < _G.FLICK_MAX_VARIANCE ? (0 < t ? this.moveHorizontal(1) : this.moveHorizontal(-1), this.flickFinish = !0) : i > _G.FLICK_MIN_DISTANCE && r < _G.FLICK_MAX_VARIANCE && (0 < n ? this.dropSelectedGems() : this.rotateGems(), this.flickFinish = !0);
  5323. this.flickFinish && (this.touchStartPos.x = e.x, this.touchStartPos.y = e.y, this.flickFinish = !1)
  5324. }
  5325. })
  5326. },
  5327. registerKeyboardListeners: function() {
  5328. this.addEventListener("abuttondown", function() {
  5329. this.isControllable && this.swapWithReserve()
  5330. });
  5331. this.addEventListener("leftbuttondown", function() {
  5332. this.isControllable && this.moveHorizontal(-1)
  5333. });
  5334. this.addEventListener("rightbuttondown", function() {
  5335. this.isControllable && this.moveHorizontal(1)
  5336. });
  5337. this.addEventListener("upbuttondown", function() {
  5338. this.isControllable && this.rotateGems()
  5339. });
  5340. this.addEventListener("downbuttondown", function() {
  5341. this.isControllable && this.dropSelectedGems()
  5342. })
  5343. }
  5344. }),
  5345. SceneMainMenu = enchant.Class.create(enchant.Scene, {
  5346. initialize: function() {
  5347. enchant.Scene.apply(this);
  5348. this.STATE_WAIT = 0;
  5349. this.STATE_MAIN = 1;
  5350. this.STATE_HIGHSCORE = 2;
  5351. this.state = this.STATE_WAIT;
  5352. var e = new Sprite(320, 480),
  5353. t = new Sprite(92, 63),
  5354. n = new Sprite(238, 19);
  5355. this.logo = new Sprite(195, 65);
  5356. this.startBtn = new Sprite(71, 27);
  5357. this.highscoreBtn = new Sprite(103, 27);
  5358. this.moregamesBtn = new Sprite(122, 27);
  5359. this.menuBoard = new Group;
  5360. this.helpText = new Label("点击按钮选择");
  5361. t.x = 32;
  5362. t.y = 363;
  5363. e.image = _G.game.assets["res/ABO_BG.png"];
  5364. t.image = _G.game.assets["res/game_anim_sheet.png"];
  5365. t.tl.delay(30).then(function() {
  5366. t.frame = 1
  5367. }).delay(30).then(function() {
  5368. t.frame = 0
  5369. }).loop();
  5370. n.image = _G.game.assets["res/wave_sheet.png"];
  5371. n.x = 40;
  5372. n.y = 84;
  5373. n.tl.repeat(function() {
  5374. n.tl.delay(10).then(function() {
  5375. n.frame += 1;
  5376. n.frame %= 4
  5377. })
  5378. }, 4).loop();
  5379. this.logo.image = _G.game.assets["res/GUI_MainMenu_LogoHTML5.png"];
  5380. this.logo.x = 64;
  5381. this.logo.y = 120;
  5382. this.logo.opacity = 0;
  5383. this.startBtn.image = _G.game.assets["res/GUI_MainMenu_Menu_Start.png"];
  5384. this.startBtn.x = 124;
  5385. this.startBtn.y = 206;
  5386. this.startBtn.opacity = 0;
  5387. this.startBtn.addEventListener("touchstart", function() {
  5388. var e = _G.game.currentScene;
  5389. e.state === e.STATE_MAIN && e.showInstructions()
  5390. });
  5391. this.highscoreBtn.image = _G.game.assets["res/GUI_MainMenu_Menu_HighScore.png"];
  5392. this.highscoreBtn.x = 109;
  5393. this.highscoreBtn.y = 260;
  5394. this.highscoreBtn.opacity = 0;
  5395. this.highscoreBtn.addEventListener("touchstart", function() {
  5396. var e = _G.game.currentScene;
  5397. e.state === e.STATE_MAIN && e.goToHighscoreScene()
  5398. });
  5399. this.moregamesBtn.image = _G.game.assets["res/GUI_MainMenu_Menu_MoreGames.png"];
  5400. this.moregamesBtn.x = 99;
  5401. this.moregamesBtn.y = 314;
  5402. this.moregamesBtn.opacity = 0;
  5403. this.moregamesBtn.addEventListener("touchstart", function() {
  5404. // Play68.goHome()
  5405. });
  5406. this.menuBoard.addChild(this.logo);
  5407. this.menuBoard.addChild(this.startBtn);
  5408. this.menuBoard.addChild(this.highscoreBtn);
  5409. this.menuBoard.addChild(this.moregamesBtn);
  5410. this.helpText.font = "12px verdana";
  5411. this.helpText.textAlign = "center";
  5412. this.helpText.color = "#ffffff";
  5413. this.helpText._style.textShadow = "-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black";
  5414. this.helpText.x = 70;
  5415. this.helpText.y = 390;
  5416. this.addChild(e);
  5417. this.addChild(t);
  5418. this.addChild(n);
  5419. this.addChild(this.menuBoard);
  5420. this.addChild(this.helpText);
  5421. var r = this;
  5422. this.logo.tl.fadeIn(10);
  5423. this.startBtn.tl.delay(5).fadeIn(10);
  5424. this.highscoreBtn.tl.delay(10).fadeIn(10).then(function() {
  5425. r.state = r.STATE_MAIN
  5426. });
  5427. this.moregamesBtn.tl.delay(15).fadeIn(10);
  5428. e = new PopupScore("更多好玩的游戏在Play68.com");
  5429. e.textAlign = "center";
  5430. e.font = "14px verdana";
  5431. e.x = 10;
  5432. e.y = 452;
  5433. this.addChild(e);
  5434. e = new PopupScore("V." + VERSION.toFixed(2));
  5435. e.textAlign = "center";
  5436. e.font = "10px verdana";
  5437. e.x = 10;
  5438. e.y = 0;
  5439. this.addChild(e)
  5440. },
  5441. goToHighscoreScene: function() {
  5442. // Play68.shareFriend()
  5443. },
  5444. showInstructions: function() {
  5445. var e = this;
  5446. this.logo.tl.fadeOut(10);
  5447. this.startBtn.tl.fadeOut(10);
  5448. this.highscoreBtn.tl.fadeOut(10);
  5449. this.moregamesBtn.tl.fadeOut(10);
  5450. this.blackBG = new Sprite(320, 440);
  5451. var t = new Surface(320, 440);
  5452. t.context.beginPath();
  5453. t.context.rect(0, 0, 320, 440);
  5454. t.context.fillStyle = "#000000";
  5455. t.context.fill();
  5456. this.blackBG.image = t;
  5457. this.blackBG.opacity = 0;
  5458. this.addChild(this.blackBG);
  5459. this.blackBG.tl.fadeTo(.75, 12);
  5460. this.instruction = new Sprite(274, 397);
  5461. this.instruction.image = enchant.Game.instance.assets["res/GUI_Tutorial.png"];
  5462. this.instruction.y = -397;
  5463. this.instruction.x = 23;
  5464. this.addChild(this.instruction);
  5465. this.instruction.tl.moveTo(this.instruction.x, 0, 12, enchant.Easing.QUAD_EASEOUT).then(function() {
  5466. e.addEventListener("touchstart", e.goToGameScene)
  5467. })
  5468. },
  5469. goToGameScene: function() {
  5470. isMobilePhone && (banad.style.display = "none");
  5471. this.removeEventListener("touchstart", this.goToGameScene);
  5472. this.blackBG.tl.fadeOut(12);
  5473. this.instruction.tl.moveTo(this.instruction.x, -397, 12, enchant.Easing.QUAD_EASEIN).then(function() {
  5474. _G.game.replaceScene(new SceneGame(1))
  5475. })
  5476. },
  5477. touchToReturn: function() {
  5478. var e = this;
  5479. this.state = this.STATE_WAIT;
  5480. this.logo.tl.fadeIn(10);
  5481. this.startBtn.tl.fadeIn(10);
  5482. this.highscoreBtn.tl.fadeIn(10);
  5483. this.moregamesBtn.tl.fadeIn(10).then(function() {
  5484. e.highscoreBoard.fadeOut();
  5485. e.removeEventListener("touchstart", e.touchToReturn)
  5486. }).then(function() {
  5487. e.removeChild(e.highscoreBoard);
  5488. e.highscoreBoard = null;
  5489. e.state = e.STATE_MAIN;
  5490. e.helpText.text = "点击按钮选择"
  5491. })
  5492. }
  5493. });
  5494. _G.confirmScore = 0;
  5495. enchant();
  5496. banad = null;
  5497. VERSION = 1;
  5498. window.onload = function() {
  5499. var e = new Game(320, 480);
  5500. _G.game = e;
  5501. _G.banad = e.keybind(32, "a");
  5502. e.preload("res/ABO_BG.png", "res/Instructions_2.png", "res/GUI_NewSpecies_Warning.png", "res/GUI_NewSpecies.png", "res/GUI_MainMenu_LogoHTML5.png", "res/GUI_GameOver.png", "res/GUI_Tutorial.png", "res/GUI_MainMenu_Menu_HighScore.png", "res/GUI_MainMenu_Menu_Start.png", "res/GUI_MainMenu_Menu_MoreGames.png", "res/GUI_MainMenu_Menu_HighScoreHeader.png", "res/game_anim_sheet.png", "res/game_anim_gameover_sheet.png", "res/wave_sheet.png", "res/gem_sheet_1.png", "res/font_0.png", "res/GUI_Controller_Button_Pause.png");
  5503. e.fps = 24;
  5504. e.scale = 1;
  5505. window.scrollTo(0, 0);
  5506. if (isMobilePhone = DetectTierIphone() || DetectTierTablet()) {
  5507. e.scale = Math.min(window.innerHeight / e.height, window.innerWidth / e.width);
  5508. var t = document.getElementById("enchant-stage");
  5509. t.style.position = "relative";
  5510. t.style.width = Math.floor(320 * e.scale) + "px"
  5511. }
  5512. banad = document.getElementById("banad");
  5513. banad.style.display = "none";
  5514. isMobilePhone ? (banad.style.left = window.innerWidth / 2 - 160 + "px", banad.style.top = window.innerHeight - 48 + "px") : (banad.style.position = "relative", banad.style.left = "0px", banad.style.margin = "0 auto");
  5515. e.load("res/splashScreen.png", setLoadingScene);
  5516. e.onload = function() {
  5517. enchant.bmfont.createFont("score", "res/font.fnt", this.assets["res/font_0.png"]);
  5518. var t = new Scene,
  5519. n = new Sprite(320, 480);
  5520. n.image = this.assets["res/splashScreen.png"];
  5521. t.addChild(n);
  5522. e.pushScene(t);
  5523. setTimeout(function() {
  5524. var e = new SceneMainMenu;
  5525. enchant.Game.instance.replaceScene(e)
  5526. }, 1e3);
  5527. banad.style.display = "block"
  5528. }
  5529. };