cocos2d-html5.js 399 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009
  1. var cc = cc || {};
  2. cc._tmp = cc._tmp || {};
  3. cc._LogInfos = {};
  4. _p = window;
  5. _p = Object.prototype;
  6. delete window._p;
  7. cc.newElement = function (a) {
  8. return document.createElement(a)
  9. };
  10. cc._addEventListener = function (a, b, c, d) {
  11. a.addEventListener(b, c, d)
  12. };
  13. cc._isNodeJs = "undefined" !== typeof require && require("fs");
  14. cc.each = function (a, b, c) {
  15. if (a)if (a instanceof Array)for (var d = 0, e = a.length; d < e && !1 !== b.call(c, a[d], d); d++); else for (d in a)if (!1 === b.call(c, a[d], d))break
  16. };
  17. cc.isCrossOrigin = function (a) {
  18. if (!a)return cc.log("invalid URL"), !1;
  19. var b = a.indexOf("://");
  20. if (-1 == b)return!1;
  21. b = a.indexOf("/", b + 3);
  22. return(-1 == b ? a : a.substring(0, b)) != location.origin
  23. };
  24. cc.async = {_counterFunc: function (a) {
  25. var b = this.counter;
  26. if (!b.err) {
  27. var c = b.length, d = b.results, e = b.option, f = e.cb, g = e.cbTarget, h = e.trigger, e = e.triggerTarget;
  28. if (a) {
  29. if (b.err = a, f)return f.call(g, a)
  30. } else {
  31. var k = Array.apply(null, arguments).slice(1), l = k.length;
  32. 0 == l ? k = null : 1 == l && (k = k[0]);
  33. d[this.index] = k;
  34. b.count--;
  35. h && h.call(e, k, c - b.count, c);
  36. 0 == b.count && f && f.apply(g, [null, d])
  37. }
  38. }
  39. }, _emptyFunc: function () {
  40. }, parallel: function (a, b, c) {
  41. var d = cc.async;
  42. if (void 0 !== c)"function" == typeof b && (b = {trigger: b}), b.cb = c || b.cb; else if (void 0 !==
  43. b)"function" == typeof b && (b = {cb: b}); else if (void 0 !== a)b = {}; else throw"arguments error!";
  44. var e = (c = a instanceof Array) ? a.length : Object.keys(a).length;
  45. if (0 == e)b.cb && b.cb.call(b.cbTarget, null); else {
  46. var f = {length: e, count: e, option: b, results: c ? [] : {}};
  47. cc.each(a, function (a, c) {
  48. if (f.err)return!1;
  49. var e = !b.cb && !b.trigger ? d._emptyFunc : d._counterFunc.bind({counter: f, index: c});
  50. a(e, c)
  51. })
  52. }
  53. }, map: function (a, b, c) {
  54. var d = this, e = arguments.length;
  55. "function" == typeof b && (b = {iterator: b});
  56. if (3 === e)b.cb = c || b.cb; else if (2 > e)throw"arguments error!";
  57. "function" == typeof b && (b = {iterator: b});
  58. if (void 0 !== c)b.cb = c || b.cb; else if (void 0 === a)throw"arguments error!";
  59. var f = (e = a instanceof Array) ? a.length : Object.keys(a).length;
  60. if (0 === f)b.cb && b.cb.call(b.cbTarget, null); else {
  61. var g = {length: f, count: f, option: b, results: e ? [] : {}};
  62. cc.each(a, function (a, c) {
  63. if (g.err)return!1;
  64. var e = !b.cb ? d._emptyFunc : d._counterFunc.bind({counter: g, index: c});
  65. b.iterator.call(b.iteratorTarget, a, c, e)
  66. })
  67. }
  68. }};
  69. cc.path = {join: function () {
  70. for (var a = arguments.length, b = "", c = 0; c < a; c++)b = (b + ("" == b ? "" : "/") + arguments[c]).replace(/(\/|\\\\)$/, "");
  71. return b
  72. }, extname: function (a) {
  73. return(a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null
  74. }, mainFileName: function (a) {
  75. if (a) {
  76. var b = a.lastIndexOf(".");
  77. if (-1 !== b)return a.substring(0, b)
  78. }
  79. return a
  80. }, basename: function (a, b) {
  81. var c = a.indexOf("?");
  82. 0 < c && (a = a.substring(0, c));
  83. c = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, ""));
  84. if (!c)return null;
  85. c = c[2];
  86. return b && a.substring(a.length -
  87. b.length).toLowerCase() == b.toLowerCase() ? c.substring(0, c.length - b.length) : c
  88. }, dirname: function (a) {
  89. return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2")
  90. }, changeExtname: function (a, b) {
  91. b = b || "";
  92. var c = a.indexOf("?"), d = "";
  93. 0 < c && (d = a.substring(c), a = a.substring(0, c));
  94. c = a.lastIndexOf(".");
  95. return 0 > c ? a + b + d : a.substring(0, c) + b + d
  96. }, changeBasename: function (a, b, c) {
  97. if (0 == b.indexOf("."))return this.changeExtname(a, b);
  98. var d = a.indexOf("?"), e = "";
  99. c = c ? this.extname(a) : "";
  100. 0 < d && (e = a.substring(d), a = a.substring(0, d));
  101. d = a.lastIndexOf("/");
  102. return a.substring(0, 0 >= d ? 0 : d + 1) + b + c + e
  103. }};
  104. cc.loader = {_jsCache: {}, _register: {}, _langPathCache: {}, _aliases: {}, resPath: "", audioPath: "", cache: {}, getXMLHttpRequest: function () {
  105. return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP")
  106. }, _getArgs4Js: function (a) {
  107. var b = a[0], c = a[1], d = a[2], e = ["", null, null];
  108. if (1 === a.length)e[1] = b instanceof Array ? b : [b]; else if (2 === a.length)"function" == typeof c ? (e[1] = b instanceof Array ? b : [b], e[2] = c) : (e[0] = b || "", e[1] = c instanceof Array ? c : [c]); else if (3 === a.length)e[0] = b || "", e[1] = c instanceof
  109. Array ? c : [c], e[2] = d; else throw"arguments error to load js!";
  110. return e
  111. }, loadJs: function (a, b, c) {
  112. var d = this, e = d._jsCache, f = d._getArgs4Js(arguments);
  113. -1 < navigator.userAgent.indexOf("Trident/5") ? d._loadJs4Dependency(f[0], f[1], 0, f[2]) : cc.async.map(f[1], function (a, b, c) {
  114. a = cc.path.join(f[0], a);
  115. if (e[a])return c(null);
  116. d._createScript(a, !1, c)
  117. }, f[2])
  118. }, loadJsWithImg: function (a, b, c) {
  119. var d = this._loadJsImg(), e = this._getArgs4Js(arguments);
  120. this.loadJs(e[0], e[1], function (a) {
  121. if (a)throw a;
  122. d.parentNode.removeChild(d);
  123. if (e[2])e[2]()
  124. })
  125. },
  126. _createScript: function (a, b, c) {
  127. var d = document, e = cc.newElement("script");
  128. e.async = b;
  129. e.src = a;
  130. this._jsCache[a] = !0;
  131. cc._addEventListener(e, "load", function () {
  132. this.removeEventListener("load", arguments.callee, !1);
  133. c()
  134. }, !1);
  135. cc._addEventListener(e, "error", function () {
  136. c("Load " + a + " failed!")
  137. }, !1);
  138. d.body.appendChild(e)
  139. }, _loadJs4Dependency: function (a, b, c, d) {
  140. if (c >= b.length)d && d(); else {
  141. var e = this;
  142. e._createScript(cc.path.join(a, b[c]), !1, function (f) {
  143. if (f)return d(f);
  144. e._loadJs4Dependency(a, b, c + 1, d)
  145. })
  146. }
  147. }, _loadJsImg: function () {
  148. var a =
  149. document, b = a.getElementById("cocos2d_loadJsImg");
  150. if (!b) {
  151. b = cc.newElement("img");
  152. cc._loadingImage && (b.src = cc._loadingImage);
  153. a = a.getElementById(cc.game.config.id);
  154. a.style.backgroundColor = "black";
  155. a.parentNode.appendChild(b);
  156. var c = getComputedStyle ? getComputedStyle(a) : a.currentStyle;
  157. c || (c = {width: a.width, height: a.height});
  158. b.style.left = a.offsetLeft + (parseFloat(c.width) - b.width) / 2 + "px";
  159. b.style.top = a.offsetTop + (parseFloat(c.height) - b.height) / 2 + "px";
  160. b.style.position = "absolute"
  161. }
  162. return b
  163. }, loadTxt: function (a, b) {
  164. if (cc._isNodeJs)require("fs").readFile(a,
  165. function (a, c) {
  166. a ? b(a) : b(null, c.toString())
  167. }); else {
  168. var c = this.getXMLHttpRequest(), d = "load " + a + " failed!";
  169. c.open("GET", a, !0);
  170. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (c.setRequestHeader("Accept-Charset", "utf-8"), c.onreadystatechange = function () {
  171. 4 == c.readyState && 200 == c.status ? b(null, c.responseText) : b(d)
  172. }) : (c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dutf-8"), c.onload = function () {
  173. 4 == c.readyState && 200 == c.status ? b(null, c.responseText) : b(d)
  174. });
  175. c.send(null)
  176. }
  177. }, _loadTxtSync: function (a) {
  178. if (cc._isNodeJs)return require("fs").readFileSync(a).toString();
  179. var b = this.getXMLHttpRequest();
  180. b.open("GET", a, !1);
  181. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? b.setRequestHeader("Accept-Charset", "utf-8") : b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dutf-8");
  182. b.send(null);
  183. return 4 == !b.readyState || 200 != b.status ? null : b.responseText
  184. }, loadJson: function (a, b) {
  185. this.loadTxt(a, function (c, d) {
  186. try {
  187. c ? b(c) : b(null, JSON.parse(d))
  188. } catch (e) {
  189. throw"load json [" + a + "] failed : " + e;
  190. }
  191. })
  192. }, _checkIsImageURL: function (a) {
  193. return null != /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)
  194. },
  195. loadImg: function (a, b, c) {
  196. var d = !0;
  197. void 0 !== c ? d = null == b.isCrossOrigin ? d : b.isCrossOrigin : void 0 !== b && (c = b);
  198. var e = new Image;
  199. d && "file://" != location.origin && (e.crossOrigin = "Anonymous");
  200. cc._addEventListener(e, "load", function () {
  201. this.removeEventListener("load", arguments.callee, !1);
  202. this.removeEventListener("error", arguments.callee, !1);
  203. c && c(null, e)
  204. });
  205. cc._addEventListener(e, "error", function () {
  206. this.removeEventListener("error", arguments.callee, !1);
  207. c && c("load image failed")
  208. });
  209. e.src = a;
  210. return e
  211. }, _loadResIterator: function (a, b, c) {
  212. var d = this, e = null, f = a.type;
  213. f ? (f = "." + f.toLowerCase(), e = a.src ? a.src : a.name + f) : (e = a, f = cc.path.extname(e));
  214. if (b = d.cache[e])return c(null, b);
  215. b = d._register[f.toLowerCase()];
  216. if (!b)return cc.error("loader for [" + f + "] not exists!"), c();
  217. f = b.getBasePath ? b.getBasePath() : d.resPath;
  218. f = d.getUrl(f, e);
  219. b.load(f, e, a, function (a, b) {
  220. a ? (cc.log(a), d.cache[e] = null, delete d.cache[e], c()) : (d.cache[e] = b, c(null, b))
  221. })
  222. }, getUrl: function (a, b) {
  223. var c = this._langPathCache, d = cc.path;
  224. if (void 0 !== a && void 0 === b) {
  225. b = a;
  226. var e = d.extname(b),
  227. e = e ? e.toLowerCase() : "";
  228. a = (e = this._register[e]) ? e.getBasePath ? e.getBasePath() : this.resPath : this.resPath
  229. }
  230. b = cc.path.join(a || "", b);
  231. if (b.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) {
  232. if (c[b])return c[b];
  233. d = d.extname(b) || "";
  234. b = c[b] = b.substring(0, b.length - d.length) + "_" + cc.sys.language + d
  235. }
  236. return b
  237. }, load: function (a, b, c) {
  238. if (void 0 !== c)"function" == typeof b && (b = {trigger: b}); else if (void 0 !== b)"function" == typeof b && (c = b, b = {}); else if (void 0 !== a)b = {}; else throw"arguments error!";
  239. b.cb = function (a, b) {
  240. a && cc.log(a);
  241. c && c(b)
  242. };
  243. a instanceof
  244. Array || (a = [a]);
  245. b.iterator = this._loadResIterator;
  246. b.iteratorTarget = this;
  247. cc.async.map(a, b)
  248. }, _handleAliases: function (a, b) {
  249. var c = this._aliases, d = [], e;
  250. for (e in a) {
  251. var f = a[e];
  252. c[e] = f;
  253. d.push(f)
  254. }
  255. this.load(d, b)
  256. }, loadAliases: function (a, b) {
  257. var c = this, d = c.getRes(a);
  258. d ? c._handleAliases(d.filenames, b) : c.load(a, function (a) {
  259. c._handleAliases(a[0].filenames, b)
  260. })
  261. }, register: function (a, b) {
  262. if (a && b) {
  263. if ("string" == typeof a)return this._register[a.trim().toLowerCase()] = b;
  264. for (var c = 0, d = a.length; c < d; c++)this._register["." + a[c].trim().toLowerCase()] =
  265. b
  266. }
  267. }, getRes: function (a) {
  268. return this.cache[a] || this.cache[this._aliases[a]]
  269. }, release: function (a) {
  270. var b = this.cache, c = this._aliases;
  271. delete b[a];
  272. delete b[c[a]];
  273. delete c[a]
  274. }, releaseAll: function () {
  275. var a = this.cache, b = this._aliases, c;
  276. for (c in a)delete a[c];
  277. for (c in b)delete b[c]
  278. }};
  279. (function () {
  280. var a = window, b, c;
  281. "undefined" !== typeof document.hidden ? (b = "hidden", c = "visibilitychange") : "undefined" !== typeof document.mozHidden ? (b = "mozHidden", c = "mozvisibilitychange") : "undefined" !== typeof document.msHidden ? (b = "msHidden", c = "msvisibilitychange") : "undefined" !== typeof document.webkitHidden && (b = "webkitHidden", c = "webkitvisibilitychange");
  282. var d = function () {
  283. cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide)
  284. }, e = function () {
  285. cc.eventManager && cc.game._eventShow &&
  286. cc.eventManager.dispatchEvent(cc.game._eventShow)
  287. };
  288. b ? cc._addEventListener(document, c, function () {
  289. document[b] ? d() : e()
  290. }, !1) : (cc._addEventListener(a, "blur", d, !1), cc._addEventListener(a, "focus", e, !1));
  291. "onpageshow"in window && "onpagehide"in window && (cc._addEventListener(a, "pagehide", d, !1), cc._addEventListener(a, "pageshow", e, !1));
  292. c = a = null
  293. })();
  294. cc.log = cc.warn = cc.error = cc.assert = function () {
  295. };
  296. cc.create3DContext = function (a, b) {
  297. for (var c = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], d = null, e = 0; e < c.length; ++e) {
  298. try {
  299. d = a.getContext(c[e], b)
  300. } catch (f) {
  301. }
  302. if (d)break
  303. }
  304. return d
  305. };
  306. cc._initSys = function (a, b) {
  307. cc._RENDER_TYPE_CANVAS = 0;
  308. cc._RENDER_TYPE_WEBGL = 1;
  309. var c = cc.sys = {};
  310. c.LANGUAGE_ENGLISH = "en";
  311. c.LANGUAGE_CHINESE = "zh";
  312. c.LANGUAGE_FRENCH = "fr";
  313. c.LANGUAGE_ITALIAN = "it";
  314. c.LANGUAGE_GERMAN = "de";
  315. c.LANGUAGE_SPANISH = "es";
  316. c.LANGUAGE_RUSSIAN = "ru";
  317. c.LANGUAGE_KOREAN = "ko";
  318. c.LANGUAGE_JAPANESE = "ja";
  319. c.LANGUAGE_HUNGARIAN = "hu";
  320. c.LANGUAGE_PORTUGUESE = "pt";
  321. c.LANGUAGE_ARABIC = "ar";
  322. c.LANGUAGE_NORWEGIAN = "no";
  323. c.LANGUAGE_POLISH = "pl";
  324. c.OS_WINDOWS = "Windows";
  325. c.OS_IOS = "iOS";
  326. c.OS_OSX = "OS X";
  327. c.OS_UNIX = "UNIX";
  328. c.OS_LINUX = "Linux";
  329. c.OS_ANDROID = "Android";
  330. c.OS_UNKNOWN = "Unknown";
  331. c.BROWSER_TYPE_WECHAT = "wechat";
  332. c.BROWSER_TYPE_ANDROID = "androidbrowser";
  333. c.BROWSER_TYPE_IE = "ie";
  334. c.BROWSER_TYPE_QQ = "qqbrowser";
  335. c.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
  336. c.BROWSER_TYPE_UC = "ucbrowser";
  337. c.BROWSER_TYPE_360 = "360browser";
  338. c.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
  339. c.BROWSER_TYPE_BAIDU = "baidubrowser";
  340. c.BROWSER_TYPE_MAXTHON = "maxthon";
  341. c.BROWSER_TYPE_OPERA = "opera";
  342. c.BROWSER_TYPE_MIUI = "miuibrowser";
  343. c.BROWSER_TYPE_FIREFOX = "firefox";
  344. c.BROWSER_TYPE_SAFARI =
  345. "safari";
  346. c.BROWSER_TYPE_CHROME = "chrome";
  347. c.BROWSER_TYPE_UNKNOWN = "unknown";
  348. c.isNative = !1;
  349. var d = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_SAFARI], e = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_SAFARI, c.BROWSER_TYPE_UC, c.BROWSER_TYPE_QQ, c.BROWSER_TYPE_MOBILE_QQ, c.BROWSER_TYPE_IE], f = window, g = f.navigator, h = document.documentElement, k = g.userAgent.toLowerCase();
  350. c.isMobile = -1 != k.indexOf("mobile") ||
  351. -1 != k.indexOf("android");
  352. var l = g.language, l = (l = l ? l : g.browserLanguage) ? l.split("-")[0] : c.LANGUAGE_ENGLISH;
  353. c.language = l;
  354. var l = c.BROWSER_TYPE_UNKNOWN, m = k.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i) || k.match(/chrome|safari/i);
  355. m && 0 < m.length && (l = m[0].toLowerCase(), "micromessenger" == l ? l = c.BROWSER_TYPE_WECHAT : "safari" === l && k.match(/android.*applewebkit/) ? l = c.BROWSER_TYPE_ANDROID : "trident" == l && (l = c.BROWSER_TYPE_IE));
  356. c.browserType = l;
  357. c._supportMultipleAudio = -1 < e.indexOf(c.browserType);
  358. e = parseInt(a[b.renderMode]);
  359. l = cc._RENDER_TYPE_WEBGL;
  360. m = cc.newElement("Canvas");
  361. cc._supportRender = !0;
  362. d = -1 == d.indexOf(c.browserType);
  363. if (1 === e || 0 === e && (c.isMobile || d))l = cc._RENDER_TYPE_CANVAS;
  364. if (l == cc._RENDER_TYPE_WEBGL && (!f.WebGLRenderingContext || !cc.create3DContext(m, {stencil: !0, preserveDrawingBuffer: !0})))0 == e ? l = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1;
  365. if (l == cc._RENDER_TYPE_CANVAS)try {
  366. m.getContext("2d")
  367. m.webkitImageSmoothingEnabled = false;
  368. m.mozImageSmoothingEnabled = false;
  369. m.imageSmoothingEnabled = false;
  370. } catch (n) {
  371. cc._supportRender = !1
  372. }
  373. cc._renderType = l;
  374. try {
  375. c._supportWebAudio = !!new (f.AudioContext || f.webkitAudioContext || f.mozAudioContext)
  376. } catch (q) {
  377. c._supportWebAudio = !1
  378. }
  379. try {
  380. var r = c.localStorage = f.localStorage;
  381. r.setItem("storage", "");
  382. r.removeItem("storage");
  383. r = null
  384. } catch (t) {
  385. ("SECURITY_ERR" === t.name || "QuotaExceededError" === t.name) && cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"), c.localStorage = function () {
  386. }
  387. }
  388. r = c.capabilities = {canvas: !0};
  389. cc._renderType == cc._RENDER_TYPE_WEBGL && (r.opengl = !0);
  390. void 0 !== h.ontouchstart || g.msPointerEnabled ? r.touches = !0 : void 0 !== h.onmouseup && (r.mouse = !0);
  391. void 0 !== h.onkeyup && (r.keyboard = !0);
  392. if (f.DeviceMotionEvent || f.DeviceOrientationEvent)r.accelerometer = !0;
  393. f = k.match(/(iPad|iPhone|iPod)/i) ? !0 : !1;
  394. k = k.match(/android/i) || g.platform.match(/android/i) ? !0 : !1;
  395. h = c.OS_UNKNOWN;
  396. -1 != g.appVersion.indexOf("Win") ? h = c.OS_WINDOWS : f ? h = c.OS_IOS : -1 != g.appVersion.indexOf("Mac") ? h = c.OS_OSX : -1 != g.appVersion.indexOf("X11") ? h = c.OS_UNIX : -1 != g.appVersion.indexOf("Linux") ? h = c.OS_LINUX :
  397. k && (h = c.OS_ANDROID);
  398. c.os = h;
  399. c.garbageCollect = function () {
  400. };
  401. c.dumpRoot = function () {
  402. };
  403. c.restartVM = function () {
  404. };
  405. c.dump = function () {
  406. var a;
  407. a = "" + ("isMobile : " + this.isMobile + "\r\n");
  408. a += "language : " + this.language + "\r\n";
  409. a += "browserType : " + this.browserType + "\r\n";
  410. a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n";
  411. a += "os : " + this.os + "\r\n";
  412. cc.log(a)
  413. }
  414. };
  415. cc.ORIENTATION_PORTRAIT = 0;
  416. cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
  417. cc.ORIENTATION_LANDSCAPE_LEFT = 2;
  418. cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
  419. cc._drawingUtil = null;
  420. cc._renderContext = null;
  421. cc._canvas = null;
  422. cc._gameDiv = null;
  423. cc._rendererInitialized = !1;
  424. cc._setupCalled = !1;
  425. cc._setup = function (a, b, c) {
  426. if (!cc._setupCalled) {
  427. cc._setupCalled = !0;
  428. var d = window;
  429. d.requestAnimFrame = d.requestAnimationFrame || d.webkitRequestAnimationFrame || d.mozRequestAnimationFrame || d.oRequestAnimationFrame || d.msRequestAnimationFrame;
  430. var e = cc.$(a) || cc.$("#" + a), f;
  431. "CANVAS" == e.tagName ? (b = b || e.width, c = c || e.height, f = cc.container = cc.newElement("DIV"), a = cc._canvas = e, a.parentNode.insertBefore(f, a), a.appendTo(f), f.setAttribute("id", "Cocos2dGameContainer")) : ("DIV" != e.tagName && cc.log("Warning: target element is not a DIV or CANVAS"),
  432. b = b || e.clientWidth, c = c || e.clientHeight, f = cc.container = e, a = cc._canvas = cc.$(cc.newElement("CANVAS")), e.appendChild(a));
  433. a.addClass("gameCanvas");
  434. a.setAttribute("width", b || 480);
  435. a.setAttribute("height", c || 320);
  436. a.setAttribute("tabindex", 99);
  437. a.style.outline = "none";
  438. e = f.style;
  439. e.width = (b || 480) + "px";
  440. e.height = (c || 320) + "px";
  441. e.margin = "0 auto";
  442. e.position = "relative";
  443. e.overflow = "hidden";
  444. f.top = "100%";
  445. cc._renderType == cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, {stencil: !0, preserveDrawingBuffer: !0,
  446. antialias: !cc.sys.isMobile, alpha: !1}));
  447. cc._renderContext ? (d.gl = cc._renderContext, cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext), cc._rendererInitialized = !0, cc.textureCache._initializingRenderer(), cc.shaderCache._init()) : (cc._renderContext = a.getContext("2d"), cc._mainRenderContextBackup = cc._renderContext, cc._renderContext.translate(0, a.height), cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(cc._renderContext) : null);
  448. cc._gameDiv = f;
  449. cc.log(cc.ENGINE_VERSION);
  450. cc._setContextMenuEnable(!1);
  451. cc.sys.isMobile && (b = cc.newElement("style"), b.type = "text/css", document.body.appendChild(b), b.textContent = "body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}");
  452. cc.view = cc.EGLView._getInstance();
  453. cc.inputManager.registerSystemEvent(cc._canvas);
  454. cc.director = cc.Director._getInstance();
  455. cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view);
  456. cc.winSize = cc.director.getWinSize();
  457. cc.saxParser = new cc.SAXParser;
  458. cc.plistParser = new cc.PlistParser
  459. }
  460. };
  461. cc._checkWebGLRenderMode = function () {
  462. if (cc._renderType !== cc._RENDER_TYPE_WEBGL)throw"This feature supports WebGL render mode only.";
  463. };
  464. cc._isContextMenuEnable = !1;
  465. cc._setContextMenuEnable = function (a) {
  466. cc._isContextMenuEnable = a;
  467. cc._canvas.oncontextmenu = function () {
  468. if (!cc._isContextMenuEnable)return!1
  469. }
  470. };
  471. cc.game = {DEBUG_MODE_NONE: 0, DEBUG_MODE_INFO: 1, DEBUG_MODE_WARN: 2, DEBUG_MODE_ERROR: 3, DEBUG_MODE_INFO_FOR_WEB_PAGE: 4, DEBUG_MODE_WARN_FOR_WEB_PAGE: 5, DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6, EVENT_HIDE: "game_on_hide", EVENT_SHOW: "game_on_show", _eventHide: null, _eventShow: null, _onBeforeStartArr: [], CONFIG_KEY: {engineDir: "engineDir", dependencies: "dependencies", debugMode: "debugMode", showFPS: "showFPS", frameRate: "frameRate", id: "id", renderMode: "renderMode", jsList: "jsList", classReleaseMode: "classReleaseMode"}, _prepareCalled: !1,
  472. _prepared: !1, _paused: !0, _intervalId: null, config: null, onStart: null, onStop: null, setFrameRate: function (a) {
  473. this.config[this.CONFIG_KEY.frameRate] = a;
  474. this._intervalId && clearInterval(this._intervalId);
  475. this._paused = !0;
  476. this._runMainLoop()
  477. }, _runMainLoop: function () {
  478. var a = this, b, c = a.config, d = a.CONFIG_KEY, e = window, f = c[d.frameRate], g = cc.director;
  479. g.setDisplayStats(c[d.showFPS]);
  480. e.requestAnimFrame && 60 == f ? (b = function () {
  481. a._paused || (g.mainLoop(), e.requestAnimFrame(b))
  482. }, e.requestAnimFrame(b)) : (b = function () {
  483. g.mainLoop()
  484. },
  485. a._intervalId = setInterval(b, 1E3 / f));
  486. a._paused = !1
  487. }, run: function (a) {
  488. var b = this, c = function () {
  489. a && (b.config[b.CONFIG_KEY.id] = a);
  490. b._prepareCalled ? cc._supportRender && (b._checkPrepare = setInterval(function () {
  491. b._prepared && (cc._setup(b.config[b.CONFIG_KEY.id]), b._runMainLoop(), b._eventHide = b._eventHide || new cc.EventCustom(b.EVENT_HIDE), b._eventHide.setUserData(b), b._eventShow = b._eventShow || new cc.EventCustom(b.EVENT_SHOW), b._eventShow.setUserData(b), b.onStart(), clearInterval(b._checkPrepare))
  492. }, 10)) : b.prepare(function () {
  493. cc._supportRender &&
  494. (cc._setup(b.config[b.CONFIG_KEY.id]), b._runMainLoop(), b._eventHide = b._eventHide || new cc.EventCustom(b.EVENT_HIDE), b._eventHide.setUserData(b), b._eventShow = b._eventShow || new cc.EventCustom(b.EVENT_SHOW), b._eventShow.setUserData(b), b.onStart())
  495. })
  496. };
  497. document.body ? c() : cc._addEventListener(window, "load", function () {
  498. this.removeEventListener("load", arguments.callee, !1);
  499. c()
  500. }, !1)
  501. }, _initConfig: function () {
  502. var a = this.CONFIG_KEY, b = function (b) {
  503. b[a.engineDir] = b[a.engineDir] || "frameworks/cocos2d-html5";
  504. null == b[a.debugMode] &&
  505. (b[a.debugMode] = 0);
  506. b[a.frameRate] = b[a.frameRate] || 60;
  507. null == b[a.renderMode] && (b[a.renderMode] = 1);
  508. return b
  509. };
  510. if (document.ccConfig)this.config = b(document.ccConfig); else try {
  511. for (var c = document.getElementsByTagName("script"), d = 0; d < c.length; d++) {
  512. var e = c[d].getAttribute("cocos");
  513. if ("" == e || e)break
  514. }
  515. var f, g, h;
  516. if (d < c.length) {
  517. if (f = c[d].src)h = /(.*)\//.exec(f)[0], cc.loader.resPath = h, f = cc.path.join(h, "project.json");
  518. g = cc.loader._loadTxtSync(f)
  519. }
  520. g || (g = cc.loader._loadTxtSync("project.json"));
  521. var k = JSON.parse(g);
  522. this.config =
  523. b(k || {})
  524. } catch (l) {
  525. cc.log("Failed to read or parse project.json"), this.config = b({})
  526. }
  527. cc._initSys(this.config, a)
  528. }, _jsAddedCache: {}, _getJsListOfModule: function (a, b, c) {
  529. var d = this._jsAddedCache;
  530. if (d[b])return null;
  531. c = c || "";
  532. var e = [], f = a[b];
  533. if (!f)throw"can not find module [" + b + "]";
  534. b = cc.path;
  535. for (var g = 0, h = f.length; g < h; g++) {
  536. var k = f[g];
  537. if (!d[k]) {
  538. var l = b.extname(k);
  539. l ? ".js" == l.toLowerCase() && e.push(b.join(c, k)) : (l = this._getJsListOfModule(a, k, c)) && (e = e.concat(l));
  540. d[k] = 1
  541. }
  542. }
  543. return e
  544. }, prepare: function (a) {
  545. var b = this,
  546. c = b.config, d = b.CONFIG_KEY, e = c[d.engineDir], f = cc.loader;
  547. if (cc._supportRender) {
  548. b._prepareCalled = !0;
  549. var g = c[d.jsList] || [];
  550. cc.Class ? f.loadJsWithImg("", g, function (c) {
  551. if (c)throw c;
  552. b._prepared = !0;
  553. a && a()
  554. }) : (d = cc.path.join(e, "moduleConfig.json"), f.loadJson(d, function (d, f) {
  555. if (d)throw d;
  556. var l = c.modules || [], m = f.module, n = [];
  557. cc._renderType == cc._RENDER_TYPE_WEBGL ? l.splice(0, 0, "shaders") : 0 > l.indexOf("core") && l.splice(0, 0, "core");
  558. for (var q = 0, r = l.length; q < r; q++) {
  559. var t = b._getJsListOfModule(m, l[q], e);
  560. t && (n = n.concat(t))
  561. }
  562. n =
  563. n.concat(g);
  564. cc.loader.loadJsWithImg(n, function (c) {
  565. if (c)throw c;
  566. b._prepared = !0;
  567. a && a()
  568. })
  569. }))
  570. } else cc.error("Can not support render!")
  571. }};
  572. cc.game._initConfig();
  573. cc.loader.loadBinary = function (a, b) {
  574. var c = this, d = this.getXMLHttpRequest(), e = "load " + a + " failed!";
  575. d.open("GET", a, !0);
  576. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "x-user-defined"), d.onreadystatechange = function () {
  577. if (4 == d.readyState && 200 == d.status) {
  578. var a = cc._convertResponseBodyToText(d.responseBody);
  579. b(null, c._str2Uint8Array(a))
  580. } else b(e)
  581. }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dx-user-defined"), d.onload = function () {
  582. 4 ==
  583. d.readyState && 200 == d.status ? b(null, c._str2Uint8Array(d.responseText)) : b(e)
  584. });
  585. d.send(null)
  586. };
  587. cc.loader._str2Uint8Array = function (a) {
  588. if (!a)return null;
  589. for (var b = new Uint8Array(a.length), c = 0; c < a.length; c++)b[c] = a.charCodeAt(c) & 255;
  590. return b
  591. };
  592. cc.loader.loadBinarySync = function (a) {
  593. var b = this.getXMLHttpRequest(), c = "load " + a + " failed!";
  594. b.open("GET", a, !1);
  595. a = null;
  596. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  597. b.setRequestHeader("Accept-Charset", "x-user-defined");
  598. b.send(null);
  599. if (200 != b.status)return cc.log(c), null;
  600. (b = cc._convertResponseBodyToText(b.responseBody)) && (a = this._str2Uint8Array(b))
  601. } else {
  602. b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dx-user-defined");
  603. b.send(null);
  604. if (200 != b.status)return cc.log(c),
  605. null;
  606. a = this._str2Uint8Array(b.responseText)
  607. }
  608. return a
  609. };
  610. var Uint8Array = Uint8Array || Array;
  611. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  612. var IEBinaryToArray_ByteStr_Script = '\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n IEBinaryToArray_ByteStr \x3d CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n Dim lastIndex\r\n lastIndex \x3d LenB(Binary)\r\n if lastIndex mod 2 Then\r\n IEBinaryToArray_ByteStr_Last \x3d Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n Else\r\n IEBinaryToArray_ByteStr_Last \x3d ""\r\n End If\r\nEnd Function\r\n', myVBScript =
  613. cc.newElement("script");
  614. myVBScript.type = "text/vbscript";
  615. myVBScript.textContent = IEBinaryToArray_ByteStr_Script;
  616. document.body.appendChild(myVBScript);
  617. cc._convertResponseBodyToText = function (a) {
  618. for (var b = {}, c = 0; 256 > c; c++)for (var d = 0; 256 > d; d++)b[String.fromCharCode(c + 256 * d)] = String.fromCharCode(c) + String.fromCharCode(d);
  619. c = IEBinaryToArray_ByteStr(a);
  620. a = IEBinaryToArray_ByteStr_Last(a);
  621. return c.replace(/[\s\S]/g, function (a) {
  622. return b[a]
  623. }) + a
  624. }
  625. }
  626. ;
  627. cc = cc || {};
  628. cc._loadingImage = "data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7";
  629. cc._fpsImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgCAYAAAD9qabkAAAKQ2lDQ1BJQ0MgcHJvZmlsZQAAeNqdU3dYk/cWPt/3ZQ9WQtjwsZdsgQAiI6wIyBBZohCSAGGEEBJAxYWIClYUFRGcSFXEgtUKSJ2I4qAouGdBiohai1VcOO4f3Ke1fXrv7e371/u855zn/M55zw+AERImkeaiagA5UoU8Otgfj09IxMm9gAIVSOAEIBDmy8JnBcUAAPADeXh+dLA//AGvbwACAHDVLiQSx+H/g7pQJlcAIJEA4CIS5wsBkFIAyC5UyBQAyBgAsFOzZAoAlAAAbHl8QiIAqg0A7PRJPgUA2KmT3BcA2KIcqQgAjQEAmShHJAJAuwBgVYFSLALAwgCgrEAiLgTArgGAWbYyRwKAvQUAdo5YkA9AYACAmUIszAAgOAIAQx4TzQMgTAOgMNK/4KlfcIW4SAEAwMuVzZdL0jMUuJXQGnfy8ODiIeLCbLFCYRcpEGYJ5CKcl5sjE0jnA0zODAAAGvnRwf44P5Dn5uTh5mbnbO/0xaL+a/BvIj4h8d/+vIwCBAAQTs/v2l/l5dYDcMcBsHW/a6lbANpWAGjf+V0z2wmgWgrQevmLeTj8QB6eoVDIPB0cCgsL7SViob0w44s+/zPhb+CLfvb8QB7+23rwAHGaQJmtwKOD/XFhbnauUo7nywRCMW735yP+x4V//Y4p0eI0sVwsFYrxWIm4UCJNx3m5UpFEIcmV4hLpfzLxH5b9CZN3DQCshk/ATrYHtctswH7uAQKLDljSdgBAfvMtjBoLkQAQZzQyefcAAJO/+Y9AKwEAzZek4wAAvOgYXKiUF0zGCAAARKCBKrBBBwzBFKzADpzBHbzAFwJhBkRADCTAPBBCBuSAHAqhGJZBGVTAOtgEtbADGqARmuEQtMExOA3n4BJcgetwFwZgGJ7CGLyGCQRByAgTYSE6iBFijtgizggXmY4EImFINJKApCDpiBRRIsXIcqQCqUJqkV1II/ItchQ5jVxA+pDbyCAyivyKvEcxlIGyUQPUAnVAuagfGorGoHPRdDQPXYCWomvRGrQePYC2oqfRS+h1dAB9io5jgNExDmaM2WFcjIdFYIlYGibHFmPlWDVWjzVjHVg3dhUbwJ5h7wgkAouAE+wIXoQQwmyCkJBHWExYQ6gl7CO0EroIVwmDhDHCJyKTqE+0JXoS+cR4YjqxkFhGrCbuIR4hniVeJw4TX5NIJA7JkuROCiElkDJJC0lrSNtILaRTpD7SEGmcTCbrkG3J3uQIsoCsIJeRt5APkE+S+8nD5LcUOsWI4kwJoiRSpJQSSjVlP+UEpZ8yQpmgqlHNqZ7UCKqIOp9aSW2gdlAvU4epEzR1miXNmxZDy6Qto9XQmmlnafdoL+l0ugndgx5Fl9CX0mvoB+nn6YP0dwwNhg2Dx0hiKBlrGXsZpxi3GS+ZTKYF05eZyFQw1zIbmWeYD5hvVVgq9ip8FZHKEpU6lVaVfpXnqlRVc1U/1XmqC1SrVQ+rXlZ9pkZVs1DjqQnUFqvVqR1Vu6k2rs5Sd1KPUM9RX6O+X/2C+mMNsoaFRqCGSKNUY7fGGY0hFsYyZfFYQtZyVgPrLGuYTWJbsvnsTHYF+xt2L3tMU0NzqmasZpFmneZxzQEOxrHg8DnZnErOIc4NznstAy0/LbHWaq1mrX6tN9p62r7aYu1y7Rbt69rvdXCdQJ0snfU6bTr3dQm6NrpRuoW623XP6j7TY+t56Qn1yvUO6d3RR/Vt9KP1F+rv1u/RHzcwNAg2kBlsMThj8MyQY+hrmGm40fCE4agRy2i6kcRoo9FJoye4Ju6HZ+M1eBc+ZqxvHGKsNN5l3Gs8YWJpMtukxKTF5L4pzZRrmma60bTTdMzMyCzcrNisyeyOOdWca55hvtm82/yNhaVFnMVKizaLx5balnzLBZZNlvesmFY+VnlW9VbXrEnWXOss623WV2xQG1ebDJs6m8u2qK2brcR2m23fFOIUjynSKfVTbtox7PzsCuya7AbtOfZh9iX2bfbPHcwcEh3WO3Q7fHJ0dcx2bHC866ThNMOpxKnD6VdnG2ehc53zNRemS5DLEpd2lxdTbaeKp26fesuV5RruutK10/Wjm7ub3K3ZbdTdzD3Ffav7TS6bG8ldwz3vQfTw91jicczjnaebp8LzkOcvXnZeWV77vR5Ps5wmntYwbcjbxFvgvct7YDo+PWX6zukDPsY+Ap96n4e+pr4i3z2+I37Wfpl+B/ye+zv6y/2P+L/hefIW8U4FYAHBAeUBvYEagbMDawMfBJkEpQc1BY0FuwYvDD4VQgwJDVkfcpNvwBfyG/ljM9xnLJrRFcoInRVaG/owzCZMHtYRjobPCN8Qfm+m+UzpzLYIiOBHbIi4H2kZmRf5fRQpKjKqLupRtFN0cXT3LNas5Fn7Z72O8Y+pjLk722q2cnZnrGpsUmxj7Ju4gLiquIF4h/hF8ZcSdBMkCe2J5MTYxD2J43MC52yaM5zkmlSWdGOu5dyiuRfm6c7Lnnc8WTVZkHw4hZgSl7I/5YMgQlAvGE/lp25NHRPyhJuFT0W+oo2iUbG3uEo8kuadVpX2ON07fUP6aIZPRnXGMwlPUit5kRmSuSPzTVZE1t6sz9lx2S05lJyUnKNSDWmWtCvXMLcot09mKyuTDeR55m3KG5OHyvfkI/lz89sVbIVM0aO0Uq5QDhZML6greFsYW3i4SL1IWtQz32b+6vkjC4IWfL2QsFC4sLPYuHhZ8eAiv0W7FiOLUxd3LjFdUrpkeGnw0n3LaMuylv1Q4lhSVfJqedzyjlKD0qWlQyuCVzSVqZTJy26u9Fq5YxVhlWRV72qX1VtWfyoXlV+scKyorviwRrjm4ldOX9V89Xlt2treSrfK7etI66Trbqz3Wb+vSr1qQdXQhvANrRvxjeUbX21K3nShemr1js20zcrNAzVhNe1bzLas2/KhNqP2ep1/XctW/a2rt77ZJtrWv913e/MOgx0VO97vlOy8tSt4V2u9RX31btLugt2PGmIbur/mft24R3dPxZ6Pe6V7B/ZF7+tqdG9s3K+/v7IJbVI2jR5IOnDlm4Bv2pvtmne1cFoqDsJB5cEn36Z8e+NQ6KHOw9zDzd+Zf7f1COtIeSvSOr91rC2jbaA9ob3v6IyjnR1eHUe+t/9+7zHjY3XHNY9XnqCdKD3x+eSCk+OnZKeenU4/PdSZ3Hn3TPyZa11RXb1nQ8+ePxd07ky3X/fJ897nj13wvHD0Ivdi2yW3S609rj1HfnD94UivW2/rZffL7Vc8rnT0Tes70e/Tf/pqwNVz1/jXLl2feb3vxuwbt24m3Ry4Jbr1+Hb27Rd3Cu5M3F16j3iv/L7a/eoH+g/qf7T+sWXAbeD4YMBgz8NZD+8OCYee/pT/04fh0kfMR9UjRiONj50fHxsNGr3yZM6T4aeypxPPyn5W/3nrc6vn3/3i+0vPWPzY8Av5i8+/rnmp83Lvq6mvOscjxx+8znk98ab8rc7bfe+477rfx70fmSj8QP5Q89H6Y8en0E/3Pud8/vwv94Tz+4A5JREAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcAgcQLxxUBNp/AAAQZ0lEQVR42u2be3QVVZbGv1N17829eRLyIKAEOiISEtPhJTJAYuyBDmhWjAEx4iAGBhxA4wABbVAMWUAeykMCM+HRTcBRWkNH2l5moS0LCCrQTkYeQWBQSCAIgYRXEpKbW/XNH5zS4noR7faPEeu31l0h4dSpvc+t/Z199jkFWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY/H9D/MR9qfKnLj/00U71aqfJn9+HCkCR/Wk36ddsgyJ/1wF4fkDfqqm9/gPsUeTnVr6a2xlQfnxdI7zs0W7irzD17Ytb2WT7EeNv/r4ox1O3Quf2QP2pgt9utwfout4FQE8AVBSlnaRmfvAURQkg2RlAbwB9AThlW5L0GaiKojhJhgOIBqDa7XaPrusdPtr5kQwF0BVAAoBIABRCKDd5aFUhRDAAw57eAOwAhKIoupft3zoqhB1AqLwuHIBut9uFt02qqvqRDJR2dAEQJj/BAOjn56dqmma+xiaECAEQAWAggLsB6A6HQ2iaZggBhBAqgEAAnQB0kzaEmT4hAITT6VQ8Ho/HJAKKECJQtr8LwD1y/A1/vcdfEUIEyfZ9AcQbYvZ942Px88L2UwlJR0dH0EMPPbRj5syZPUeNGrXR7Xb/641xIwJ1XY9NSUlZm52dfW+XLl1w8uRJzJ8//+OGhoYJqqqe1TSt1Wsm9NN1PSIqKmr12rVrR5WUlHy1bdu2AQCumWc3IYRD1/UwVVXnFRQUTIuNjUVzczN2797dWFJSkq8oymZd15sAGAEnFEUJ1nX9nzIzM1dnZmZGh4SE4OTJk5g5c+Zf29vbp9pstrMej6fVOyhIhgAYU1hY+B+hoaGoqKg4XVlZea+XTULTNFdCQsLGiRMnPuR2u3UhBOV9eeDAAWXTpk095DUe6WsoyRE5OTlr0tLSAux2O/bs2cO5c+e+pijKUpIXSHaQVAGkvPLKK++6XK4OksJLCFlXV2cvKSlJBFAjhU+x2WwhHo9nUHp6+urMzMy7wsLCUF9fjxdffPHjxsbGiTab7WuPx9NiEutOuq4PyMjI+M+srKyYqKgoHD58GDNmzNjq8XhyVFU9b/q+LH7hBAEYu3PnTlZVVRFAGgCX6f/tAHoOHDjwa0p27txp/JO9e/f+QM7cipw9nfL3kQBKt2zZQpJ87rnn6mQmoHilw2EACs+cOUOSrK+vZ1NTE0nyo48+IoBpxswoBcMJ4Ndjx471kOTFixe5d+9ekqTH42H//v13A4jyzpAURfEH0H/OnDnthu1z5sw558MmFUCPWbNmnaMP3nrrLZoyDmP8Hl68eDFJ8siRI9/Yc+zYMQKYKdtAztrTrl27xptRXV1NAKMAOAyBBBA/Y8aMdpLs6Ojgxx9//E37+++//29yvFXppwvAwMcee8xjtDHsuXLlCqOjo//ia3wsfpkoALqFhoZuIckJEyackimm3dQmEMDUmpoakmRISMhhAHOHDx/eQJIbN24kgKEyMAHAFRMTs2XXrl1saWkhSZ0kp0+ffhrAr3wEW/S8efOukORLL72kA1gKYMPWrVtJkk899dRJAHeYrgsEsIQkjx8/TgDvAPjd448/3kaSb7zxBmUa7vC6z53BwcFbSHL9+vU6Sc6aNes8gF5ewWAH0PfVV18lSQL4DMBGIcQ6AKtcLleBFC2jXtFt8ODBe0iyoqKCAJYByC8qKmJDQwOzsrK+MAmqo1OnTveHhoa+GRkZ+XZkZOSWiIiIvzgcjk9mzpypkWRmZuZpmbYbGV4AgPnNzc1sa2sjgN0A5iQmJtaSZHl5OQHcb/K3s81mW0uSTU1NBFAFYFbfvn1Pk+Tbb79NAA8IIVzW42/hByA+Pz/fLR/2ZXIda05NI/z9/TeR5J49ewhgqlxTrtI0jY2NjQQw3zTLuWJiYjaUlJToS5Ys6fjkk080kwDEeAmADcA9GzZsIElGRUW9CyAWwLApU6Y0kOSKFSsog9QICGdERMTGsrIyZmVlEcC9AB4IDw/fTpLbtm0jgN94CUAnAJmVlZVcs2aNZ/LkyRdJcvbs2b4EwAkgZfPmzTxw4AABFAN4BkC6vFeUSewcAO5duXIlSTIhIaEawGMAxgKYAmAGgCS73e5vrKVk/yGythANYEhCQsIhkly+fDkBpKqqGmL6DgIALDKN/3yZpVWQZGVlJQE8aPI3KiMjo5okV61aRQAjAPQBMPfIkSN0u90EUCBtsPiFEwpgbn19PdetW2fM5N4zQ9ekpKQqkty0aRMBpMjiWM6JEydIkoqirJUFJ6iq6pAPVy8A6cZMehMBUACEuVyuFwG8HBwcPEIWx367ZMkSjSQXLVrUJouTRorrkAHdA8BdQogsAOsKCwtJkmPGjDkvMw2bDDo/ADEjRoz4XylyFbm5uY0mAbjLyyZ/AOOrq6tZVlbWsWDBgo69e/eyoqKCgwcPPg4gSQaoIRbp27dvN7KF+tLSUr28vJwFBQXtMpvpYRIM7+wrAkDeqVOnePbsWQIoNKfzpiXPg8uXLydJJicnNwF4f+nSpW6STEtLq5fjYwhk1wkTJtSQ5Ouvv04AqTKj+N2xY8dIkgEBAW/Ie1v8wncRegwZMmQvSfbr12+3Ua33WqPfOWbMmP0kWVpaSgCDZAqcfejQIWNZsEGKgvnh9gfQb9myZd8nAEJVVZtMkUNk8CcNHTq0liR1XWdYWNhmH1mJIme80OnTp18x1rp5eXkEsNJms92Fb7e/IgEsvHz5Mp999tkmAI/l5uZeMC0B7vEqqAYAyL106RJJsra2lpWVld+sucePH38ZQG+5NncBeOrgwYMkqbe3t/Po0aOsra011wAWyl0H7x0JJ4DE+fPnu0kyPT29DsDdUrBuyNKEEAkAdpw/f/6GeoEM8GUmfwEgPCIiopwkGxsbabPZPgOw6L777vvm4p49e26VGYjFLxUhhD+ApLKyMp44ccIoVnXybgbgzkcfffRzklyzZg0BDJYCMMmoCwQFBXkLgLGWvvcWAgBToSsKwNPTp09vMR7UuLi4rwH0lgU8c/Db5ezbeeTIkRWzZ8++aMxu+fn5BPCADBwHgP4LFy701NXVEUAJgAnPP/98kyxMNgHo53A4zH77BQQETMvPz7+Um5vbBuAlAFMSExPPmdbVL0qh8Acw8fDhw5SCchVAEYAVb775JknyhRdeaJYztHfxMwLAaqNwCGC2FArv8x0hAHKNLGPKlCme5OTk/Zs3bzb7O0wKiiG8KXl5ed8IxenTp0mSR48e1UmyW7duWywBuD2xyQcgFECgoih+8H1gyJgZV5Lkyy+/3CbTRIePtl2HDBmyw1QBHyGDdXZdXR1JUghRKkXBjOMHCoBdpr0L3nvvPZLkF198wejo6O0A4lVVDTb74HQ6AwD8Wq7Jh8rgGgDgQ13XjVR8qaxJuADMbmlpYXl5uV5UVNRWUFDgfv/993Vj/ZydnU1c37eHXML4S3viAcQqitJD2l104cIFY8lTKsXSBWBMVVWVcd9yed2A1NTUQ6Zl00CvLMMOoHdubm6zFIlWOf5+PsY/Kj09vdrU11QAwwGsv3jxIk21m2DZr10I0RXAuAcffPBgaWkpV69eTYfDcdiwUxY0w6xw+flX8L1xApjevXv3lREREaW6rofB93aPDUDQpEmTMgHgtddeqwBwEd/utZvpqK6uPgEAcXFxkA94NwB9unfvjrNnz4LklwDcf08iIqv66Zs2bXrl4YcfxooVKxAbG7uqrq5uAYA2TdOEqqpGYIi2tjbl6aeffu/YsWPv5uTk7JaC1wHg4Pnz542MwoVvTx+21dbWYvjw4WLixIl+2dnZ9lGjRgmSTE1NRUpKCkwFTGiaxtTU1OXTpk3707Bhw/6g67pDipnT4biuj7qut+Lbk3Vf1tTUXI9qu91Pjq1QFEUBgJaWFgBo8yGOQ8eNGxcAAOvXr/8QwBUfYygAKL169eoCABcuXACAWtn2hOGv0+kMNO1KiPDw8F4A4rZv3/7R1KlTR0+bNu1ht9u9r1+/fqitrQXJgwDarRC6/QjPzs4+QJIffPCB9/aQmSAA43ft2mW0e1QGoi8CAPyLsZccExNTC2BlRkbGRdOyYJCP2csBIN6UAZzCd7cBbQCijYp/dXU1ExMTz6SmptaMHj36f9LS0vYlJCRsl6mxIWSdu3fv/g5J7t+/nwC2AShMTk6+SJKff/45AWRLYbD7+fndAeDf5BJnLoCCyZMnt5JkdnZ2C4B/F0KEm1Pu+Pj4rST55ZdfEsBWAK+mpaVdMo3raDn7KwDuSEpK+m+S3LBhAwG8DuCtHTt2UBbpjgC408vvcFVV15HkuXPnjMp+p5uMf0RcXNyHJNnQ0EBVVfcCWBQXF3fG+Jv0yxABPwB5LS0tRmFxN4BlTzzxxGWSXLx4sS5F3GGFy+1Hp5SUlJq6ujoWFxdTpsZ2H+0iIyMj/0iSWVlZX5mr5jfJFroPGzasxlhTnjp1iiTZ3NxMl8tlrCd9pfa9SkpKSJI5OTmnZOageLUZZqxvfVFWVkZcPwdgNwnSCKPqb17jkmR8fPzfZMDZ5CRsFBmNI7h95s2b1yhT7/MAYmStwCx4vy0uLqa3v5qmEcCfvSr1QQAeXb16NY3Cm3HQ55133iGAp+SxZTNhKSkpfzUddkrFjYevzAQCeGjp0qXfsYckY2NjTwD4leGDLCL2HTdunNtoY+zWSHFcIHdsFCtcfuZ1vO9Eqs3m7/F47sb1k2qX/f3997W2tl7BjWfpBYDOzzzzzIVJkyZh0KBBCwEsB3AJvl9AETabLcDj8dwRFRW1ctasWb8JCgpSzp07d62wsPC/Wltb8xRFadR1/ZqPXYbgAQMGbI2Pjw/+6quv9ldVVT0r01ezuPRJSUn5Y9euXXVd11WzDaqq6kePHm3+7LPPRgO4KlNuxWazhXo8nuTk5OSXMjIyEl0uFxoaGtqKior+dPXq1VdUVT0jj7r68ieoT58+vx8yZMjdx48fP1JVVTVF9m20VW02WyfZf97YsWPjXS4X6urqWvPy8jYCWCyEuEDS8FdVFKWzruv//OSTTy5OTk7uqWkaPv3007qysrJ8RVH+LI8ym8/rB3Tu3HnRI488knLo0KG2ffv2ZQI4C98vP6mqqoZqmpaclpa2cOTIkX39/f3R0NDQUVxc/G5TU9PLqqrWa5rWLH1QVFUN0TStX1JSUvH48eP7BwYG4uDBg1cKCgpeBbBe2u+2Qug2EwD5N5sMPuNtMe8XP4TT6Qxoa2sbIGeXvUKIK7d4IISiKC5d1wPljOfA9bPwzYqiXNV13dd6Uqiq6qdpml2mpe02m63d4/G4vcTF5fF47LJf71nJA6BZVVW3pmntuPHlmAD5wk6Q9NnbHp9vHaqq6tA0zU/64PZhk1FfCZB9G/23ALiqKEqzD39tpvbGUqoFwFUhRLP3yzpCCDtJpxyXDulfG27+pqRR3DXsUWVd4Yq0x/taVQjhIhksC8L+ABpM9ljBf5sKwI8pIBr75L5E4vvu+UNeG/a+hv+AL7yFH8qPtOfHjtOP6V/Bja8D6z/B2Nys/1u9Xv33tLf4GfF/LC4GCJwByWIAAAAASUVORK5CYII\x3d";
  630. var cc = cc || {}, ClassManager = {id: 0 | 998 * Math.random(), instanceId: 0 | 998 * Math.random(), compileSuper: function (a, b, c) {
  631. a = a.toString();
  632. var d = a.indexOf("("), e = a.indexOf(")"), d = a.substring(d + 1, e), d = d.trim(), e = a.indexOf("{"), f = a.lastIndexOf("}");
  633. for (a = a.substring(e + 1, f); -1 != a.indexOf("this._super");) {
  634. var e = a.indexOf("this._super"), f = a.indexOf("(", e), g = a.indexOf(")", f), g = a.substring(f + 1, g), g = (g = g.trim()) ? "," : "";
  635. a = a.substring(0, e) + "ClassManager[" + c + "]." + b + ".call(this" + g + a.substring(f + 1)
  636. }
  637. return Function(d, a)
  638. }, getNewID: function () {
  639. return this.id++
  640. },
  641. getNewInstanceId: function () {
  642. return this.instanceId++
  643. }};
  644. ClassManager.compileSuper.ClassManager = ClassManager;
  645. (function () {
  646. var a = /\b_super\b/, b = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];
  647. b && console.log("release Mode");
  648. cc.Class = function () {
  649. };
  650. cc.Class.extend = function (c) {
  651. function d() {
  652. this.__instanceId = ClassManager.getNewInstanceId();
  653. this.ctor && this.ctor.apply(this, arguments)
  654. }
  655. var e = this.prototype, f = Object.create(e), g = ClassManager.getNewID();
  656. ClassManager[g] = e;
  657. var h = {writable: !0, enumerable: !1, configurable: !0};
  658. f.__instanceId = null;
  659. d.id = g;
  660. h.value = g;
  661. Object.defineProperty(f, "__pid", h);
  662. d.prototype = f;
  663. h.value = d;
  664. Object.defineProperty(d.prototype, "constructor", h);
  665. this.__getters__ && (d.__getters__ = cc.clone(this.__getters__));
  666. this.__setters__ && (d.__setters__ = cc.clone(this.__setters__));
  667. for (var k = 0, l = arguments.length; k < l; ++k) {
  668. var m = arguments[k], n;
  669. for (n in m) {
  670. var q = "function" === typeof m[n], r = "function" === typeof e[n], t = a.test(m[n]);
  671. b && q && r && t ? (h.value = ClassManager.compileSuper(m[n], n, g), Object.defineProperty(f, n, h)) : q && r && t ? (h.value = function (a, b) {
  672. return function () {
  673. var c = this._super;
  674. this._super = e[a];
  675. var d = b.apply(this,
  676. arguments);
  677. this._super = c;
  678. return d
  679. }
  680. }(n, m[n]), Object.defineProperty(f, n, h)) : q ? (h.value = m[n], Object.defineProperty(f, n, h)) : f[n] = m[n];
  681. if (q) {
  682. var s, v;
  683. if (this.__getters__ && this.__getters__[n]) {
  684. var q = this.__getters__[n], u;
  685. for (u in this.__setters__)if (this.__setters__[u] == q) {
  686. v = u;
  687. break
  688. }
  689. cc.defineGetterSetter(f, q, m[n], m[v] ? m[v] : f[v], n, v)
  690. }
  691. if (this.__setters__ && this.__setters__[n]) {
  692. q = this.__setters__[n];
  693. for (u in this.__getters__)if (this.__getters__[u] == q) {
  694. s = u;
  695. break
  696. }
  697. cc.defineGetterSetter(f, q, m[s] ? m[s] : f[s], m[n],
  698. s, n)
  699. }
  700. }
  701. }
  702. }
  703. d.extend = cc.Class.extend;
  704. d.implement = function (a) {
  705. for (var b in a)f[b] = a[b]
  706. };
  707. return d
  708. };
  709. Function.prototype.bind = Function.prototype.bind || function (a) {
  710. var b = this;
  711. return function () {
  712. var e = Array.prototype.slice.call(arguments);
  713. return b.apply(a || null, e)
  714. }
  715. }
  716. })();
  717. cc.defineGetterSetter = function (a, b, c, d, e, f) {
  718. if (a.__defineGetter__)c && a.__defineGetter__(b, c), d && a.__defineSetter__(b, d); else if (Object.defineProperty) {
  719. var g = {enumerable: !1, configurable: !0};
  720. c && (g.get = c);
  721. d && (g.set = d);
  722. Object.defineProperty(a, b, g)
  723. } else throw Error("browser does not support getters");
  724. if (!e && !f)for (var g = null != c, h = void 0 != d, k = Object.getOwnPropertyNames(a), l = 0; l < k.length; l++) {
  725. var m = k[l];
  726. if (!((a.__lookupGetter__ ? a.__lookupGetter__(m) : Object.getOwnPropertyDescriptor(a, m)) || "function" !== typeof a[m])) {
  727. var n =
  728. a[m];
  729. if (g && n === c && (e = m, !h || f))break;
  730. if (h && n === d && (f = m, !g || e))break
  731. }
  732. }
  733. a = a.constructor;
  734. e && (a.__getters__ || (a.__getters__ = {}), a.__getters__[e] = b);
  735. f && (a.__setters__ || (a.__setters__ = {}), a.__setters__[f] = b)
  736. };
  737. cc.clone = function (a) {
  738. var b = a.constructor ? new a.constructor : {}, c;
  739. for (c in a) {
  740. var d = a[c];
  741. b[c] = "object" == typeof d && d && !(d instanceof cc.Node) && !(d instanceof HTMLElement) ? cc.clone(d) : d
  742. }
  743. return b
  744. };
  745. cc.Point = function (a, b) {
  746. this.x = a || 0;
  747. this.y = b || 0
  748. };
  749. cc.p = function (a, b) {
  750. return void 0 == a ? {x: 0, y: 0} : void 0 == b ? {x: a.x, y: a.y} : {x: a, y: b}
  751. };
  752. cc.pointEqualToPoint = function (a, b) {
  753. return a && b && a.x === b.x && a.y === b.y
  754. };
  755. cc.Size = function (a, b) {
  756. this.width = a || 0;
  757. this.height = b || 0
  758. };
  759. cc.size = function (a, b) {
  760. return void 0 === a ? {width: 0, height: 0} : void 0 === b ? {width: a.width, height: a.height} : {width: a, height: b}
  761. };
  762. cc.sizeEqualToSize = function (a, b) {
  763. return a && b && a.width == b.width && a.height == b.height
  764. };
  765. cc.Rect = function (a, b, c, d) {
  766. this.x = a || 0;
  767. this.y = b || 0;
  768. this.width = c || 0;
  769. this.height = d || 0
  770. };
  771. cc.rect = function (a, b, c, d) {
  772. return void 0 === a ? {x: 0, y: 0, width: 0, height: 0} : void 0 === b ? {x: a.x, y: a.y, width: a.width, height: a.height} : {x: a, y: b, width: c, height: d}
  773. };
  774. cc.rectEqualToRect = function (a, b) {
  775. return a && b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
  776. };
  777. cc._rectEqualToZero = function (a) {
  778. return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height
  779. };
  780. cc.rectContainsRect = function (a, b) {
  781. return!a || !b ? !1 : !(a.x >= b.x || a.y >= b.y || a.x + a.width <= b.x + b.width || a.y + a.height <= b.y + b.height)
  782. };
  783. cc.rectGetMaxX = function (a) {
  784. return a.x + a.width
  785. };
  786. cc.rectGetMidX = function (a) {
  787. return a.x + a.width / 2
  788. };
  789. cc.rectGetMinX = function (a) {
  790. return a.x
  791. };
  792. cc.rectGetMaxY = function (a) {
  793. return a.y + a.height
  794. };
  795. cc.rectGetMidY = function (a) {
  796. return a.y + a.height / 2
  797. };
  798. cc.rectGetMinY = function (a) {
  799. return a.y
  800. };
  801. cc.rectContainsPoint = function (a, b) {
  802. return b.x >= cc.rectGetMinX(a) && b.x <= cc.rectGetMaxX(a) && b.y >= cc.rectGetMinY(a) && b.y <= cc.rectGetMaxY(a)
  803. };
  804. cc.rectIntersectsRect = function (a, b) {
  805. var c = a.y + a.height, d = b.x + b.width, e = b.y + b.height;
  806. return!(a.x + a.width < b.x || d < a.x || c < b.y || e < a.y)
  807. };
  808. cc.rectOverlapsRect = function (a, b) {
  809. return!(a.x + a.width < b.x || b.x + b.width < a.x || a.y + a.height < b.y || b.y + b.height < a.y)
  810. };
  811. cc.rectUnion = function (a, b) {
  812. var c = cc.rect(0, 0, 0, 0);
  813. c.x = Math.min(a.x, b.x);
  814. c.y = Math.min(a.y, b.y);
  815. c.width = Math.max(a.x + a.width, b.x + b.width) - c.x;
  816. c.height = Math.max(a.y + a.height, b.y + b.height) - c.y;
  817. return c
  818. };
  819. cc.rectIntersection = function (a, b) {
  820. var c = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(b)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(b)), 0, 0);
  821. c.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(b)) - cc.rectGetMinX(c);
  822. c.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(b)) - cc.rectGetMinY(c);
  823. return c
  824. };
  825. cc.visibleRect = {topLeft: cc.p(0, 0), topRight: cc.p(0, 0), top: cc.p(0, 0), bottomLeft: cc.p(0, 0), bottomRight: cc.p(0, 0), bottom: cc.p(0, 0), center: cc.p(0, 0), left: cc.p(0, 0), right: cc.p(0, 0), width: 0, height: 0, init: function (a) {
  826. var b = this.width = a.width, c = this.height = a.height, d = a.x;
  827. a = a.y;
  828. var e = a + c, f = d + b;
  829. this.topLeft.x = d;
  830. this.topLeft.y = e;
  831. this.topRight.x = f;
  832. this.topRight.y = e;
  833. this.top.x = d + b / 2;
  834. this.top.y = e;
  835. this.bottomLeft.x = d;
  836. this.bottomLeft.y = a;
  837. this.bottomRight.x = f;
  838. this.bottomRight.y = a;
  839. this.bottom.x = d + b / 2;
  840. this.bottom.y =
  841. a;
  842. this.center.x = d + b / 2;
  843. this.center.y = a + c / 2;
  844. this.left.x = d;
  845. this.left.y = a + c / 2;
  846. this.right.x = f;
  847. this.right.y = a + c / 2
  848. }};
  849. cc.SAXParser = cc.Class.extend({_parser: null, _isSupportDOMParser: null, ctor: function () {
  850. window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1
  851. }, parse: function (a) {
  852. return this._parseXML(a)
  853. }, _parseXML: function (a) {
  854. var b;
  855. this._isSupportDOMParser ? b = this._parser.parseFromString(a, "text/xml") : (b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a));
  856. return b
  857. }});
  858. cc.PlistParser = cc.SAXParser.extend({parse: function (a) {
  859. a = this._parseXML(a).documentElement;
  860. if ("plist" != a.tagName)throw"Not a plist file!";
  861. for (var b = null, c = 0, d = a.childNodes.length; c < d && !(b = a.childNodes[c], 1 == b.nodeType); c++);
  862. return this._parseNode(b)
  863. }, _parseNode: function (a) {
  864. var b = null, c = a.tagName;
  865. if ("dict" == c)b = this._parseDict(a); else if ("array" == c)b = this._parseArray(a); else if ("string" == c)if (1 == a.childNodes.length)b = a.firstChild.nodeValue; else {
  866. b = "";
  867. for (c = 0; c < a.childNodes.length; c++)b += a.childNodes[c].nodeValue
  868. } else"false" ==
  869. c ? b = !1 : "true" == c ? b = !0 : "real" == c ? b = parseFloat(a.firstChild.nodeValue) : "integer" == c && (b = parseInt(a.firstChild.nodeValue, 10));
  870. return b
  871. }, _parseArray: function (a) {
  872. for (var b = [], c = 0, d = a.childNodes.length; c < d; c++) {
  873. var e = a.childNodes[c];
  874. 1 == e.nodeType && b.push(this._parseNode(e))
  875. }
  876. return b
  877. }, _parseDict: function (a) {
  878. for (var b = {}, c = null, d = 0, e = a.childNodes.length; d < e; d++) {
  879. var f = a.childNodes[d];
  880. 1 == f.nodeType && ("key" == f.tagName ? c = f.firstChild.nodeValue : b[c] = this._parseNode(f))
  881. }
  882. return b
  883. }});
  884. cc._txtLoader = {load: function (a, b, c, d) {
  885. cc.loader.loadTxt(a, d)
  886. }};
  887. cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader);
  888. cc._jsonLoader = {load: function (a, b, c, d) {
  889. cc.loader.loadJson(a, d)
  890. }};
  891. cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
  892. cc._imgLoader = {load: function (a, b, c, d) {
  893. cc.loader.cache[b] = cc.loader.loadImg(a, function (a, c) {
  894. if (a)return d(a);
  895. cc.textureCache.handleLoadedTexture(b);
  896. d(null, c)
  897. })
  898. }};
  899. cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader);
  900. cc._serverImgLoader = {load: function (a, b, c, d) {
  901. cc.loader.cache[b] = cc.loader.loadImg(c.src, function (a, c) {
  902. if (a)return d(a);
  903. cc.textureCache.handleLoadedTexture(b);
  904. d(null, c)
  905. })
  906. }};
  907. cc.loader.register(["serverImg"], cc._serverImgLoader);
  908. cc._plistLoader = {load: function (a, b, c, d) {
  909. cc.loader.loadTxt(a, function (a, b) {
  910. if (a)return d(a);
  911. d(null, cc.plistParser.parse(b))
  912. })
  913. }};
  914. cc.loader.register(["plist"], cc._plistLoader);
  915. cc._fontLoader = {TYPE: {".eot": "embedded-opentype", ".ttf": "truetype", ".woff": "woff", ".svg": "svg"}, _loadFont: function (a, b, c) {
  916. var d = document, e = cc.path, f = this.TYPE, g = cc.newElement("style");
  917. g.type = "text/css";
  918. d.body.appendChild(g);
  919. var h = "@font-face { font-family:" + a + "; src:";
  920. if (b instanceof Array)for (var k = 0, l = b.length; k < l; k++)c = e.extname(b[k]).toLowerCase(), h += "url('" + b[k] + "') format('" + f[c] + "')", h += k == l - 1 ? ";" : ","; else h += "url('" + b + "') format('" + f[c] + "');";
  921. g.textContent += h + "};";
  922. b = cc.newElement("div");
  923. c =
  924. b.style;
  925. c.fontFamily = a;
  926. b.innerHTML = ".";
  927. c.position = "absolute";
  928. c.left = "-100px";
  929. c.top = "-100px";
  930. d.body.appendChild(b)
  931. }, load: function (a, b, c, d) {
  932. b = c.type;
  933. a = c.name;
  934. b = c.srcs;
  935. "string" == typeof c ? (b = cc.path.extname(c), a = cc.path.basename(c, b), this._loadFont(a, c, b)) : this._loadFont(a, b);
  936. d(null, !0)
  937. }};
  938. cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
  939. cc._binaryLoader = {load: function (a, b, c, d) {
  940. cc.loader.loadBinary(a, d)
  941. }};
  942. window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC0";
  943. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
  944. cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
  945. cc.DIRECTOR_FPS_INTERVAL = 0.5;
  946. cc.COCOSNODE_RENDER_SUBPIXEL = 1;
  947. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
  948. cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
  949. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
  950. cc.TEXTURE_ATLAS_USE_VAO = 0;
  951. cc.TEXTURE_NPOT_SUPPORT = 0;
  952. cc.RETINA_DISPLAY_SUPPORT = 1;
  953. cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
  954. cc.USE_LA88_LABELS = 1;
  955. cc.SPRITE_DEBUG_DRAW = 0;
  956. cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
  957. cc.LABELBMFONT_DEBUG_DRAW = 0;
  958. cc.LABELATLAS_DEBUG_DRAW = 0;
  959. cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
  960. cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
  961. cc.ENABLE_STACKABLE_ACTIONS = 1;
  962. cc.ENABLE_GL_STATE_CACHE = 1;
  963. cc.$ = function (a) {
  964. var b = this == cc ? document : this;
  965. if (a = a instanceof HTMLElement ? a : b.querySelector(a))a.find = a.find || cc.$, a.hasClass = a.hasClass || function (a) {
  966. return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)"))
  967. }, a.addClass = a.addClass || function (a) {
  968. this.hasClass(a) || (this.className && (this.className += " "), this.className += a);
  969. return this
  970. }, a.removeClass = a.removeClass || function (a) {
  971. this.hasClass(a) && (this.className = this.className.replace(a, ""));
  972. return this
  973. }, a.remove = a.remove || function () {
  974. this.parentNode &&
  975. this.parentNode.removeChild(this);
  976. return this
  977. }, a.appendTo = a.appendTo || function (a) {
  978. a.appendChild(this);
  979. return this
  980. }, a.prependTo = a.prependTo || function (a) {
  981. a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this);
  982. return this
  983. }, a.transforms = a.transforms || function () {
  984. this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew);
  985. return this
  986. }, a.position = a.position || {x: 0, y: 0}, a.rotation = a.rotation || 0, a.scale = a.scale || {x: 1, y: 1}, a.skew =
  987. a.skew || {x: 0, y: 0}, a.translates = function (a, b) {
  988. this.position.x = a;
  989. this.position.y = b;
  990. this.transforms();
  991. return this
  992. }, a.rotate = function (a) {
  993. this.rotation = a;
  994. this.transforms();
  995. return this
  996. }, a.resize = function (a, b) {
  997. this.scale.x = a;
  998. this.scale.y = b;
  999. this.transforms();
  1000. return this
  1001. }, a.setSkew = function (a, b) {
  1002. this.skew.x = a;
  1003. this.skew.y = b;
  1004. this.transforms();
  1005. return this
  1006. };
  1007. return a
  1008. };
  1009. switch (cc.sys.browserType) {
  1010. case cc.sys.BROWSER_TYPE_FIREFOX:
  1011. cc.$.pfx = "Moz";
  1012. cc.$.hd = !0;
  1013. break;
  1014. case cc.sys.BROWSER_TYPE_CHROME:
  1015. case cc.sys.BROWSER_TYPE_SAFARI:
  1016. cc.$.pfx = "webkit";
  1017. cc.$.hd = !0;
  1018. break;
  1019. case cc.sys.BROWSER_TYPE_OPERA:
  1020. cc.$.pfx = "O";
  1021. cc.$.hd = !1;
  1022. break;
  1023. case cc.sys.BROWSER_TYPE_IE:
  1024. cc.$.pfx = "ms";
  1025. cc.$.hd = !1;
  1026. break;
  1027. default:
  1028. cc.$.pfx = "webkit", cc.$.hd = !0
  1029. }
  1030. cc.$.trans = cc.$.pfx + "Transform";
  1031. cc.$.translate = cc.$.hd ? function (a) {
  1032. return"translate3d(" + a.x + "px, " + a.y + "px, 0) "
  1033. } : function (a) {
  1034. return"translate(" + a.x + "px, " + a.y + "px) "
  1035. };
  1036. cc.$.rotate = cc.$.hd ? function (a) {
  1037. return"rotateZ(" + a + "deg) "
  1038. } : function (a) {
  1039. return"rotate(" + a + "deg) "
  1040. };
  1041. cc.$.scale = function (a) {
  1042. return"scale(" + a.x + ", " + a.y + ") "
  1043. };
  1044. cc.$.skew = function (a) {
  1045. return"skewX(" + -a.x + "deg) skewY(" + a.y + "deg)"
  1046. };
  1047. cc.$new = function (a) {
  1048. return cc.$(document.createElement(a))
  1049. };
  1050. cc.$.findpos = function (a) {
  1051. var b = 0, c = 0;
  1052. do b += a.offsetLeft, c += a.offsetTop; while (a = a.offsetParent);
  1053. return{x: b, y: c}
  1054. };
  1055. cc.INVALID_INDEX = -1;
  1056. cc.PI = Math.PI;
  1057. cc.FLT_MAX = parseFloat("3.402823466e+38F");
  1058. cc.FLT_MIN = parseFloat("1.175494351e-38F");
  1059. cc.RAD = cc.PI / 180;
  1060. cc.DEG = 180 / cc.PI;
  1061. cc.UINT_MAX = 4294967295;
  1062. cc.swap = function (a, b, c) {
  1063. if ("object" == typeof c && "undefined" != typeof c.x && "undefined" != typeof c.y) {
  1064. var d = c[a];
  1065. c[a] = c[b];
  1066. c[b] = d
  1067. } else cc.log(cc._LogInfos.swap)
  1068. };
  1069. cc.lerp = function (a, b, c) {
  1070. return a + (b - a) * c
  1071. };
  1072. cc.rand = function () {
  1073. return 16777215 * Math.random()
  1074. };
  1075. cc.randomMinus1To1 = function () {
  1076. return 2 * (Math.random() - 0.5)
  1077. };
  1078. cc.random0To1 = Math.random;
  1079. cc.degreesToRadians = function (a) {
  1080. return a * cc.RAD
  1081. };
  1082. cc.radiansToDegrees = function (a) {
  1083. return a * cc.DEG
  1084. };
  1085. cc.radiansToDegress = function (a) {
  1086. cc.log(cc._LogInfos.radiansToDegress);
  1087. return a * cc.DEG
  1088. };
  1089. cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
  1090. cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770;
  1091. cc.BLEND_DST = 771;
  1092. cc.nodeDrawSetup = function (a) {
  1093. a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())
  1094. };
  1095. cc.enableDefaultGLStates = function () {
  1096. };
  1097. cc.disableDefaultGLStates = function () {
  1098. };
  1099. cc.incrementGLDraws = function (a) {
  1100. cc.g_NumberOfDraws += a
  1101. };
  1102. cc.FLT_EPSILON = 1.192092896E-7;
  1103. cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function () {
  1104. return cc.director.getContentScaleFactor()
  1105. } : function () {
  1106. return 1
  1107. };
  1108. cc.pointPointsToPixels = function (a) {
  1109. var b = cc.contentScaleFactor();
  1110. return cc.p(a.x * b, a.y * b)
  1111. };
  1112. cc.pointPixelsToPoints = function (a) {
  1113. var b = cc.contentScaleFactor();
  1114. return cc.p(a.x / b, a.y / b)
  1115. };
  1116. cc._pointPixelsToPointsOut = function (a, b) {
  1117. var c = cc.contentScaleFactor();
  1118. b.x = a.x / c;
  1119. b.y = a.y / c
  1120. };
  1121. cc.sizePointsToPixels = function (a) {
  1122. var b = cc.contentScaleFactor();
  1123. return cc.size(a.width * b, a.height * b)
  1124. };
  1125. cc.sizePixelsToPoints = function (a) {
  1126. var b = cc.contentScaleFactor();
  1127. return cc.size(a.width / b, a.height / b)
  1128. };
  1129. cc._sizePixelsToPointsOut = function (a, b) {
  1130. var c = cc.contentScaleFactor();
  1131. b.width = a.width / c;
  1132. b.height = a.height / c
  1133. };
  1134. cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (a) {
  1135. var b = cc.contentScaleFactor();
  1136. return cc.rect(a.x / b, a.y / b, a.width / b, a.height / b)
  1137. } : function (a) {
  1138. return a
  1139. };
  1140. cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (a) {
  1141. var b = cc.contentScaleFactor();
  1142. return cc.rect(a.x * b, a.y * b, a.width * b, a.height * b)
  1143. } : function (a) {
  1144. return a
  1145. };
  1146. cc.ONE = 1;
  1147. cc.ZERO = 0;
  1148. cc.SRC_ALPHA = 770;
  1149. cc.SRC_ALPHA_SATURATE = 776;
  1150. cc.SRC_COLOR = 768;
  1151. cc.DST_ALPHA = 772;
  1152. cc.DST_COLOR = 774;
  1153. cc.ONE_MINUS_SRC_ALPHA = 771;
  1154. cc.ONE_MINUS_SRC_COLOR = 769;
  1155. cc.ONE_MINUS_DST_ALPHA = 773;
  1156. cc.ONE_MINUS_DST_COLOR = 775;
  1157. cc.ONE_MINUS_CONSTANT_ALPHA = 32772;
  1158. cc.ONE_MINUS_CONSTANT_COLOR = 32770;
  1159. cc.checkGLErrorDebug = function () {
  1160. if (cc.renderMode == cc._RENDER_TYPE_WEBGL) {
  1161. var a = cc._renderContext.getError();
  1162. a && cc.log(CC._localZOrder.checkGLErrorDebug, a)
  1163. }
  1164. };
  1165. cc.DEVICE_ORIENTATION_PORTRAIT = 0;
  1166. cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
  1167. cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
  1168. cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
  1169. cc.DEVICE_MAX_ORIENTATIONS = 2;
  1170. cc.VERTEX_ATTRIB_FLAG_NONE = 0;
  1171. cc.VERTEX_ATTRIB_FLAG_POSITION = 1;
  1172. cc.VERTEX_ATTRIB_FLAG_COLOR = 2;
  1173. cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4;
  1174. cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  1175. cc.GL_ALL = 0;
  1176. cc.VERTEX_ATTRIB_POSITION = 0;
  1177. cc.VERTEX_ATTRIB_COLOR = 1;
  1178. cc.VERTEX_ATTRIB_TEX_COORDS = 2;
  1179. cc.VERTEX_ATTRIB_MAX = 3;
  1180. cc.UNIFORM_PMATRIX = 0;
  1181. cc.UNIFORM_MVMATRIX = 1;
  1182. cc.UNIFORM_MVPMATRIX = 2;
  1183. cc.UNIFORM_TIME = 3;
  1184. cc.UNIFORM_SINTIME = 4;
  1185. cc.UNIFORM_COSTIME = 5;
  1186. cc.UNIFORM_RANDOM01 = 6;
  1187. cc.UNIFORM_SAMPLER = 7;
  1188. cc.UNIFORM_MAX = 8;
  1189. cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
  1190. cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
  1191. cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
  1192. cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
  1193. cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
  1194. cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
  1195. cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
  1196. cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
  1197. cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
  1198. cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
  1199. cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
  1200. cc.UNIFORM_TIME_S = "CC_Time";
  1201. cc.UNIFORM_SINTIME_S = "CC_SinTime";
  1202. cc.UNIFORM_COSTIME_S = "CC_CosTime";
  1203. cc.UNIFORM_RANDOM01_S = "CC_Random01";
  1204. cc.UNIFORM_SAMPLER_S = "CC_Texture0";
  1205. cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
  1206. cc.ATTRIBUTE_NAME_COLOR = "a_color";
  1207. cc.ATTRIBUTE_NAME_POSITION = "a_position";
  1208. cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
  1209. cc.ITEM_SIZE = 32;
  1210. cc.CURRENT_ITEM = 3233828865;
  1211. cc.ZOOM_ACTION_TAG = 3233828866;
  1212. cc.NORMAL_TAG = 8801;
  1213. cc.SELECTED_TAG = 8802;
  1214. cc.DISABLE_TAG = 8803;
  1215. cc._tmp.PrototypeColor = function () {
  1216. var a = cc.color;
  1217. a._getWhite = function () {
  1218. return a(255, 255, 255)
  1219. };
  1220. a._getYellow = function () {
  1221. return a(255, 255, 0)
  1222. };
  1223. a._getBlue = function () {
  1224. return a(0, 0, 255)
  1225. };
  1226. a._getGreen = function () {
  1227. return a(0, 255, 0)
  1228. };
  1229. a._getRed = function () {
  1230. return a(255, 0, 0)
  1231. };
  1232. a._getMagenta = function () {
  1233. return a(255, 0, 255)
  1234. };
  1235. a._getBlack = function () {
  1236. return a(0, 0, 0)
  1237. };
  1238. a._getOrange = function () {
  1239. return a(255, 127, 0)
  1240. };
  1241. a._getGray = function () {
  1242. return a(166, 166, 166)
  1243. };
  1244. cc.defineGetterSetter(a, "WHITE", a._getWhite);
  1245. cc.defineGetterSetter(a,
  1246. "YELLOW", a._getYellow);
  1247. cc.defineGetterSetter(a, "BLUE", a._getBlue);
  1248. cc.defineGetterSetter(a, "GREEN", a._getGreen);
  1249. cc.defineGetterSetter(a, "RED", a._getRed);
  1250. cc.defineGetterSetter(a, "MAGENTA", a._getMagenta);
  1251. cc.defineGetterSetter(a, "BLACK", a._getBlack);
  1252. cc.defineGetterSetter(a, "ORANGE", a._getOrange);
  1253. cc.defineGetterSetter(a, "GRAY", a._getGray)
  1254. };
  1255. cc.Color = function (a, b, c, d) {
  1256. this.r = a || 0;
  1257. this.g = b || 0;
  1258. this.b = c || 0;
  1259. this.a = d || 255
  1260. };
  1261. cc.color = function (a, b, c, d) {
  1262. return void 0 === a ? {r: 0, g: 0, b: 0, a: 255} : "string" === typeof a ? cc.hexToColor(a) : "object" === typeof a ? {r: a.r, g: a.g, b: a.b, a: a.a || 255} : {r: a, g: b, b: c, a: d || 255}
  1263. };
  1264. cc.colorEqual = function (a, b) {
  1265. return a.r === b.r && a.g === b.g && a.b === b.b
  1266. };
  1267. cc.Acceleration = function (a, b, c, d) {
  1268. this.x = a || 0;
  1269. this.y = b || 0;
  1270. this.z = c || 0;
  1271. this.timestamp = d || 0
  1272. };
  1273. cc.Vertex2F = function (a, b) {
  1274. this.x = a || 0;
  1275. this.y = b || 0
  1276. };
  1277. cc.vertex2 = function (a, b) {
  1278. return new cc.Vertex2F(a, b)
  1279. };
  1280. cc.Vertex3F = function (a, b, c) {
  1281. this.x = a || 0;
  1282. this.y = b || 0;
  1283. this.z = c || 0
  1284. };
  1285. cc.vertex3 = function (a, b, c) {
  1286. return new cc.Vertex3F(a, b, c)
  1287. };
  1288. cc.Tex2F = function (a, b) {
  1289. this.u = a || 0;
  1290. this.v = b || 0
  1291. };
  1292. cc.tex2 = function (a, b) {
  1293. return new cc.Tex2F(a, b)
  1294. };
  1295. cc.BlendFunc = function (a, b) {
  1296. this.src = a;
  1297. this.dst = b
  1298. };
  1299. cc.blendFuncDisable = function () {
  1300. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  1301. };
  1302. cc.hexToColor = function (a) {
  1303. a = a.replace(/^#?/, "0x");
  1304. a = parseInt(a);
  1305. return cc.color(a >> 16, (a >> 8) % 256, a % 256)
  1306. };
  1307. cc.colorToHex = function (a) {
  1308. var b = a.r.toString(16), c = a.g.toString(16), d = a.b.toString(16);
  1309. return"#" + (16 > a.r ? "0" + b : b) + (16 > a.g ? "0" + c : c) + (16 > a.b ? "0" + d : d)
  1310. };
  1311. cc.TEXT_ALIGNMENT_LEFT = 0;
  1312. cc.TEXT_ALIGNMENT_CENTER = 1;
  1313. cc.TEXT_ALIGNMENT_RIGHT = 2;
  1314. cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
  1315. cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
  1316. cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
  1317. cc._Dictionary = cc.Class.extend({_keyMapTb: null, _valueMapTb: null, __currId: 0, ctor: function () {
  1318. this._keyMapTb = {};
  1319. this._valueMapTb = {};
  1320. this.__currId = 2 << (0 | 10 * Math.random())
  1321. }, __getKey: function () {
  1322. this.__currId++;
  1323. return"key_" + this.__currId
  1324. }, setObject: function (a, b) {
  1325. if (null != b) {
  1326. var c = this.__getKey();
  1327. this._keyMapTb[c] = b;
  1328. this._valueMapTb[c] = a
  1329. }
  1330. }, objectForKey: function (a) {
  1331. if (null == a)return null;
  1332. var b = this._keyMapTb, c;
  1333. for (c in b)if (b[c] === a)return this._valueMapTb[c];
  1334. return null
  1335. }, valueForKey: function (a) {
  1336. return this.objectForKey(a)
  1337. },
  1338. removeObjectForKey: function (a) {
  1339. if (null != a) {
  1340. var b = this._keyMapTb, c;
  1341. for (c in b)if (b[c] === a) {
  1342. delete this._valueMapTb[c];
  1343. delete b[c];
  1344. break
  1345. }
  1346. }
  1347. }, removeObjectsForKeys: function (a) {
  1348. if (null != a)for (var b = 0; b < a.length; b++)this.removeObjectForKey(a[b])
  1349. }, allKeys: function () {
  1350. var a = [], b = this._keyMapTb, c;
  1351. for (c in b)a.push(b[c]);
  1352. return a
  1353. }, removeAllObjects: function () {
  1354. this._keyMapTb = {};
  1355. this._valueMapTb = {}
  1356. }, count: function () {
  1357. return this.allKeys().length
  1358. }});
  1359. cc.FontDefinition = function () {
  1360. this.fontName = "Arial";
  1361. this.fontSize = 12;
  1362. this.textAlign = cc.TEXT_ALIGNMENT_CENTER;
  1363. this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  1364. this.fillStyle = cc.color(255, 255, 255, 255);
  1365. this.boundingHeight = this.boundingWidth = 0;
  1366. this.strokeEnabled = !1;
  1367. this.strokeStyle = cc.color(255, 255, 255, 255);
  1368. this.lineWidth = 1;
  1369. this.shadowEnabled = !1;
  1370. this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0;
  1371. this.shadowOpacity = 1
  1372. };
  1373. cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert("function" === typeof cc._tmp.WebGLColor, cc._LogInfos.MissingFile, "CCTypesWebGL.js"), cc._tmp.WebGLColor(), delete cc._tmp.WebGLColor);
  1374. cc.assert("function" === typeof cc._tmp.PrototypeColor, cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js");
  1375. cc._tmp.PrototypeColor();
  1376. delete cc._tmp.PrototypeColor;
  1377. cc.Touches = [];
  1378. cc.TouchesIntergerDict = {};
  1379. cc.EGLView = cc.Class.extend({_delegate: null, _frameSize: null, _designResolutionSize: null, _originalDesignResolutionSize: null, _viewPortRect: null, _visibleRect: null, _retinaEnabled: !1, _autoFullScreen: !0, _devicePixelRatio: 1, _viewName: "", _resizeCallback: null, _scaleX: 1, _originalScaleX: 1, _scaleY: 1, _originalScaleY: 1, _indexBitsUsed: 0, _maxTouches: 5, _resolutionPolicy: null, _rpExactFit: null, _rpShowAll: null, _rpNoBorder: null, _rpFixedHeight: null, _rpFixedWidth: null, _initialized: !1, _captured: !1, _wnd: null, _hDC: null, _hRC: null,
  1380. _supportTouch: !1, _contentTranslateLeftTop: null, _frame: null, _frameZoomFactor: 1, __resizeWithBrowserSize: !1, _isAdjustViewPort: !0, ctor: function () {
  1381. var a = document, b = cc.ContainerStrategy, c = cc.ContentStrategy;
  1382. this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode;
  1383. this._frameSize = cc.size(0, 0);
  1384. this._initFrameSize();
  1385. var a = cc._canvas.width, d = cc._canvas.height;
  1386. this._designResolutionSize = cc.size(a, d);
  1387. this._originalDesignResolutionSize = cc.size(a, d);
  1388. this._viewPortRect = cc.rect(0, 0,
  1389. a, d);
  1390. this._visibleRect = cc.rect(0, 0, a, d);
  1391. this._contentTranslateLeftTop = {left: 0, top: 0};
  1392. this._viewName = "Cocos2dHTML5";
  1393. a = cc.sys;
  1394. this.enableRetina(a.os == a.OS_IOS || a.os == a.OS_OSX);
  1395. cc.visibleRect && cc.visibleRect.init(this._visibleRect);
  1396. this._rpExactFit = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.EXACT_FIT);
  1397. this._rpShowAll = new cc.ResolutionPolicy(b.PROPORTION_TO_FRAME, c.SHOW_ALL);
  1398. this._rpNoBorder = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.NO_BORDER);
  1399. this._rpFixedHeight = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME,
  1400. c.FIXED_HEIGHT);
  1401. this._rpFixedWidth = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_WIDTH);
  1402. this._hDC = cc._canvas;
  1403. this._hRC = cc._renderContext
  1404. }, _resizeEvent: function () {
  1405. var a = this._originalDesignResolutionSize.width, b = this._originalDesignResolutionSize.height;
  1406. this._resizeCallback && (this._initFrameSize(), this._resizeCallback.call());
  1407. 0 < a && this.setDesignResolutionSize(a, b, this._resolutionPolicy)
  1408. }, resizeWithBrowserSize: function (a) {
  1409. a ? this.__resizeWithBrowserSize || (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this),
  1410. cc._addEventListener(window, "resize", a, !1)) : this.__resizeWithBrowserSize && (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this), window.removeEventListener("resize", a, !1))
  1411. }, setResizeCallback: function (a) {
  1412. if ("function" == typeof a || null == a)this._resizeCallback = a
  1413. }, _initFrameSize: function () {
  1414. var a = this._frameSize;
  1415. a.width = this._frame.clientWidth;
  1416. a.height = this._frame.clientHeight
  1417. }, _adjustSizeKeepCanvasSize: function () {
  1418. var a = this._originalDesignResolutionSize.width, b = this._originalDesignResolutionSize.height;
  1419. 0 < a && this.setDesignResolutionSize(a, b, this._resolutionPolicy)
  1420. }, _setViewPortMeta: function (a, b) {
  1421. if (this._isAdjustViewPort) {
  1422. var c = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}, d = document.getElementsByName("viewport"), e;
  1423. 0 == d.length ? (d = cc.newElement("meta"), d.name = "viewport", d.content = "", document.head.appendChild(d)) : d = d[0];
  1424. if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX)d.content = "initial-scale:1"; else {
  1425. e = d.content;
  1426. for (var f in c)RegExp(f).test(e) || (e += ("" == e ? "" :
  1427. ",") + f + "\x3d" + c[f]);
  1428. d.content = e
  1429. }
  1430. }
  1431. }, _setScaleXYForRenderTexture: function () {
  1432. var a = cc.contentScaleFactor();
  1433. this._scaleY = this._scaleX = a
  1434. }, _resetScale: function () {
  1435. this._scaleX = this._originalScaleX;
  1436. this._scaleY = this._originalScaleY
  1437. }, _adjustSizeToBrowser: function () {
  1438. }, initialize: function () {
  1439. this._initialized = !0
  1440. }, adjustViewPort: function (a) {
  1441. this._isAdjustViewPort = a
  1442. }, enableRetina: function (a) {
  1443. this._retinaEnabled = a ? !0 : !1
  1444. }, isRetinaEnabled: function () {
  1445. return this._retinaEnabled
  1446. }, enableAutoFullScreen: function (a) {
  1447. this._autoFullScreen =
  1448. a ? !0 : !1
  1449. }, isAutoFullScreenEnabled: function () {
  1450. return this._autoFullScreen
  1451. }, end: function () {
  1452. }, isOpenGLReady: function () {
  1453. return null != this._hDC && null != this._hRC
  1454. }, setFrameZoomFactor: function (a) {
  1455. this._frameZoomFactor = a;
  1456. this.centerWindow();
  1457. cc.director.setProjection(cc.director.getProjection())
  1458. }, swapBuffers: function () {
  1459. }, setIMEKeyboardState: function (a) {
  1460. }, setContentTranslateLeftTop: function (a, b) {
  1461. this._contentTranslateLeftTop = {left: a, top: b}
  1462. }, getContentTranslateLeftTop: function () {
  1463. return this._contentTranslateLeftTop
  1464. },
  1465. getFrameSize: function () {
  1466. return cc.size(this._frameSize.width, this._frameSize.height)
  1467. }, setFrameSize: function (a, b) {
  1468. this._frameSize.width = a;
  1469. this._frameSize.height = b;
  1470. this._frame.style.width = a + "px";
  1471. this._frame.style.height = b + "px";
  1472. this._resizeEvent();
  1473. cc.director.setProjection(cc.director.getProjection())
  1474. }, centerWindow: function () {
  1475. }, getVisibleSize: function () {
  1476. return cc.size(this._visibleRect.width, this._visibleRect.height)
  1477. }, getVisibleOrigin: function () {
  1478. return cc.p(this._visibleRect.x, this._visibleRect.y)
  1479. },
  1480. canSetContentScaleFactor: function () {
  1481. return!0
  1482. }, getResolutionPolicy: function () {
  1483. return this._resolutionPolicy
  1484. }, setResolutionPolicy: function (a) {
  1485. if (a instanceof cc.ResolutionPolicy)this._resolutionPolicy = a; else {
  1486. var b = cc.ResolutionPolicy;
  1487. a === b.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit);
  1488. a === b.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll);
  1489. a === b.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder);
  1490. a === b.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight);
  1491. a === b.FIXED_WIDTH && (this._resolutionPolicy =
  1492. this._rpFixedWidth)
  1493. }
  1494. }, setDesignResolutionSize: function (a, b, c) {
  1495. if (isNaN(a) || 0 == a || isNaN(b) || 0 == b)cc.log(cc._LogInfos.EGLView_setDesignResolutionSize); else {
  1496. this.setResolutionPolicy(c);
  1497. var d = this._resolutionPolicy;
  1498. if (d) {
  1499. d.preApply(this);
  1500. var e = this._frameSize.width, f = this._frameSize.height;
  1501. cc.sys.isMobile && this._setViewPortMeta(this._frameSize.width, this._frameSize.height);
  1502. this._initFrameSize();
  1503. c == this._resolutionPolicy && a == this._originalDesignResolutionSize.width && b == this._originalDesignResolutionSize.height &&
  1504. e == this._frameSize.width && f == this._frameSize.height || (this._designResolutionSize = cc.size(a, b), this._originalDesignResolutionSize = cc.size(a, b), a = d.apply(this, this._designResolutionSize), a.scale && 2 == a.scale.length && (this._scaleX = a.scale[0], this._scaleY = a.scale[1]), a.viewport && (a = this._viewPortRect = a.viewport, b = this._visibleRect, b.width = cc._canvas.width / this._scaleX, b.height = cc._canvas.height / this._scaleY, b.x = -a.x / this._scaleX, b.y = -a.y / this._scaleY), a = cc.director, cc.winSize.width = a._winSizeInPoints.width =
  1505. this._visibleRect.width, cc.winSize.height = a._winSizeInPoints.height = this._visibleRect.height, d.postApply(this), cc._renderType == cc._RENDER_TYPE_WEBGL && (a._createStatsLabel(), a.setGLDefaultValues()), this._originalScaleX = this._scaleX, this._originalScaleY = this._scaleY, cc.DOM && cc.DOM._resetEGLViewDiv(), cc.visibleRect && cc.visibleRect.init(this._visibleRect))
  1506. } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2)
  1507. }
  1508. }, getDesignResolutionSize: function () {
  1509. return cc.size(this._designResolutionSize.width, this._designResolutionSize.height)
  1510. },
  1511. setViewPortInPoints: function (a, b, c, d) {
  1512. var e = this._frameZoomFactor, f = this._scaleX, g = this._scaleY;
  1513. cc._renderContext.viewport(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  1514. }, setScissorInPoints: function (a, b, c, d) {
  1515. var e = this._frameZoomFactor, f = this._scaleX, g = this._scaleY;
  1516. cc._renderContext.scissor(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  1517. }, isScissorEnabled: function () {
  1518. var a = cc._renderContext;
  1519. return a.isEnabled(a.SCISSOR_TEST)
  1520. }, getScissorRect: function () {
  1521. var a =
  1522. cc._renderContext, b = this._scaleX, c = this._scaleY, a = a.getParameter(a.SCISSOR_BOX);
  1523. return cc.rect((a[0] - this._viewPortRect.x) / b, (a[1] - this._viewPortRect.y) / c, a[2] / b, a[3] / c)
  1524. }, setViewName: function (a) {
  1525. null != a && 0 < a.length && (this._viewName = a)
  1526. }, getViewName: function () {
  1527. return this._viewName
  1528. }, getViewPortRect: function () {
  1529. return this._viewPortRect
  1530. }, getScaleX: function () {
  1531. return this._scaleX
  1532. }, getScaleY: function () {
  1533. return this._scaleY
  1534. }, getDevicePixelRatio: function () {
  1535. return this._devicePixelRatio
  1536. }, convertToLocationInView: function (a, b, c) {
  1537. return{x: this._devicePixelRatio * (a - c.left), y: this._devicePixelRatio * (c.top + c.height - b)}
  1538. }, _convertMouseToLocationInView: function (a, b) {
  1539. var c = this._viewPortRect;
  1540. a.x = (this._devicePixelRatio * (a.x - b.left) - c.x) / this._scaleX;
  1541. a.y = (this._devicePixelRatio * (b.top + b.height - a.y) - c.y) / this._scaleY
  1542. }, _convertTouchesWithScale: function (a) {
  1543. for (var b = this._viewPortRect, c = this._scaleX, d = this._scaleY, e, f, g, h = 0; h < a.length; h++)e = a[h], f = e._point, g = e._prevPoint, e._setPoint((f.x - b.x) / c, (f.y - b.y) / d), e._setPrevPoint((g.x -
  1544. b.x) / c, (g.y - b.y) / d)
  1545. }});
  1546. cc.EGLView._getInstance = function () {
  1547. this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize());
  1548. return this._instance
  1549. };
  1550. cc.ContainerStrategy = cc.Class.extend({preApply: function (a) {
  1551. }, apply: function (a, b) {
  1552. }, postApply: function (a) {
  1553. }, _setupContainer: function (a, b, c) {
  1554. var d = a._frame;
  1555. //cc.view._autoFullScreen && (cc.sys.isMobile && d == document.documentElement) && cc.screen.autoFullScreen(d);
  1556. var d = cc._canvas, e = cc.container;
  1557. e.style.width = d.style.width = b + "px";
  1558. e.style.height = d.style.height = c + "px";
  1559. e = a._devicePixelRatio = 1;
  1560. a.isRetinaEnabled() && (e = a._devicePixelRatio = window.devicePixelRatio || 1);
  1561. d.width = b * e;
  1562. d.height = c * e;
  1563. a = document.body;
  1564. var f;
  1565. if (a && (f = a.style))f.paddingTop = f.paddingTop || "0px", f.paddingRight = f.paddingRight || "0px", f.paddingBottom = f.paddingBottom || "0px", f.paddingLeft = f.paddingLeft || "0px", f.borderTop = f.borderTop || "0px", f.borderRight = f.borderRight || "0px", f.borderBottom = f.borderBottom || "0px", f.borderLeft = f.borderLeft || "0px", f.marginTop = f.marginTop || "0px", f.marginRight = f.marginRight || "0px", f.marginBottom = f.marginBottom || "0px", f.marginLeft = f.marginLeft || "0px"
  1566. }, _fixContainer: function () {
  1567. document.body.insertBefore(cc.container, document.body.firstChild);
  1568. var a = document.body.style;
  1569. a.width = window.innerWidth + "px";
  1570. a.height = window.innerHeight + "px";
  1571. a.overflow = "hidden";
  1572. a = cc.container.style;
  1573. a.position = "fixed";
  1574. a.left = a.top = "0px";
  1575. document.body.scrollTop = 0
  1576. cc._renderContext.webkitImageSmoothingEnabled = false;
  1577. cc._renderContext.mozImageSmoothingEnabled = false;
  1578. cc._renderContext.imageSmoothingEnabled = false; //future
  1579. }});
  1580. cc.ContentStrategy = cc.Class.extend({_result: {scale: [1, 1], viewport: null}, _buildResult: function (a, b, c, d, e, f) {
  1581. 2 > Math.abs(a - c) && (c = a);
  1582. 2 > Math.abs(b - d) && (d = b);
  1583. a = cc.rect(Math.round((a - c) / 2), Math.round((b - d) / 2), c, d);
  1584. cc._renderType == cc._RENDER_TYPE_CANVAS && cc._renderContext.translate(a.x, a.y + d);
  1585. this._result.scale = [e, f];
  1586. this._result.viewport = a;
  1587. return this._result
  1588. }, preApply: function (a) {
  1589. }, apply: function (a, b) {
  1590. return{scale: [1, 1]}
  1591. }, postApply: function (a) {
  1592. }});
  1593. (function () {
  1594. var a = cc.ContainerStrategy.extend({apply: function (a) {
  1595. this._setupContainer(a, a._frameSize.width, a._frameSize.height)
  1596. }}), b = cc.ContainerStrategy.extend({apply: function (a, b) {
  1597. var c = a._frameSize.width, d = a._frameSize.height, e = cc.container.style, m = b.width, n = b.height, q = c / m, r = d / n, t, s;
  1598. q < r ? (t = c, s = n * q) : (t = m * r, s = d);
  1599. m = Math.round((c - t) / 2);
  1600. s = Math.round((d - s) / 2);
  1601. this._setupContainer(a, c - 2 * m, d - 2 * s);
  1602. e.marginLeft = m + "px";
  1603. e.marginRight = m + "px";
  1604. e.marginTop = s + "px";
  1605. e.marginBottom = s + "px"
  1606. }});
  1607. a.extend({preApply: function (a) {
  1608. this._super(a);
  1609. a._frame = document.documentElement
  1610. }, apply: function (a) {
  1611. this._super(a);
  1612. this._fixContainer()
  1613. }});
  1614. b.extend({preApply: function (a) {
  1615. this._super(a);
  1616. a._frame = document.documentElement
  1617. }, apply: function (a, b) {
  1618. this._super(a, b);
  1619. this._fixContainer()
  1620. }});
  1621. var c = cc.ContainerStrategy.extend({apply: function (a) {
  1622. this._setupContainer(a, cc._canvas.width, cc._canvas.height)
  1623. }});
  1624. cc.ContainerStrategy.EQUAL_TO_FRAME = new a;
  1625. cc.ContainerStrategy.PROPORTION_TO_FRAME = new b;
  1626. cc.ContainerStrategy.ORIGINAL_CONTAINER = new c;
  1627. var a = cc.ContentStrategy.extend({apply: function (a, b) {
  1628. var c = cc._canvas.width, d = cc._canvas.height;
  1629. return this._buildResult(c, d, c, d, c / b.width, d / b.height)
  1630. }}), b = cc.ContentStrategy.extend({apply: function (a, b) {
  1631. var c = cc._canvas.width, d = cc._canvas.height, e = b.width, m = b.height, n = c / e, q = d / m, r = 0, t, s;
  1632. n < q ? (r = n, t = c, s = m * r) : (r = q, t = e * r, s = d);
  1633. return this._buildResult(c, d, t, s, r, r)
  1634. }}), c = cc.ContentStrategy.extend({apply: function (a, b) {
  1635. var c = cc._canvas.width, d = cc._canvas.height, e = b.width, m = b.height, n = c / e, q = d / m, r, t, s;
  1636. n < q ? (r = q, t = e * r, s = d) : (r = n, t = c, s = m * r);
  1637. return this._buildResult(c,
  1638. d, t, s, r, r)
  1639. }}), d = cc.ContentStrategy.extend({apply: function (a, b) {
  1640. var c = cc._canvas.width, d = cc._canvas.height, e = d / b.height;
  1641. return this._buildResult(c, d, c, d, e, e)
  1642. }, postApply: function (a) {
  1643. cc.director._winSizeInPoints = a.getVisibleSize()
  1644. }}), e = cc.ContentStrategy.extend({apply: function (a, b) {
  1645. var c = cc._canvas.width, d = cc._canvas.height, e = c / b.width;
  1646. return this._buildResult(c, d, c, d, e, e)
  1647. }, postApply: function (a) {
  1648. cc.director._winSizeInPoints = a.getVisibleSize()
  1649. }});
  1650. cc.ContentStrategy.EXACT_FIT = new a;
  1651. cc.ContentStrategy.SHOW_ALL =
  1652. new b;
  1653. cc.ContentStrategy.NO_BORDER = new c;
  1654. cc.ContentStrategy.FIXED_HEIGHT = new d;
  1655. cc.ContentStrategy.FIXED_WIDTH = new e
  1656. })();
  1657. cc.ResolutionPolicy = cc.Class.extend({_containerStrategy: null, _contentStrategy: null, ctor: function (a, b) {
  1658. this.setContainerStrategy(a);
  1659. this.setContentStrategy(b)
  1660. }, preApply: function (a) {
  1661. this._containerStrategy.preApply(a);
  1662. this._contentStrategy.preApply(a)
  1663. }, apply: function (a, b) {
  1664. this._containerStrategy.apply(a, b);
  1665. return this._contentStrategy.apply(a, b)
  1666. }, postApply: function (a) {
  1667. this._containerStrategy.postApply(a);
  1668. this._contentStrategy.postApply(a)
  1669. }, setContainerStrategy: function (a) {
  1670. a instanceof cc.ContainerStrategy &&
  1671. (this._containerStrategy = a)
  1672. }, setContentStrategy: function (a) {
  1673. a instanceof cc.ContentStrategy && (this._contentStrategy = a)
  1674. }});
  1675. cc.ResolutionPolicy.EXACT_FIT = 0;
  1676. cc.ResolutionPolicy.NO_BORDER = 1;
  1677. cc.ResolutionPolicy.SHOW_ALL = 2;
  1678. cc.ResolutionPolicy.FIXED_HEIGHT = 3;
  1679. cc.ResolutionPolicy.FIXED_WIDTH = 4;
  1680. cc.ResolutionPolicy.UNKNOWN = 5;
  1681. cc.UIInterfaceOrientationLandscapeLeft = -90;
  1682. cc.UIInterfaceOrientationLandscapeRight = 90;
  1683. cc.UIInterfaceOrientationPortraitUpsideDown = 180;
  1684. cc.UIInterfaceOrientationPortrait = 0;
  1685. cc.inputManager = {_mousePressed: !1, _isRegisterEvent: !1, _preTouchPoint: cc.p(0, 0), _prevMousePoint: cc.p(0, 0), _preTouchPool: [], _preTouchPoolPointer: 0, _touches: [], _touchesIntegerDict: {}, _indexBitsUsed: 0, _maxTouches: 5, _accelEnabled: !1, _accelInterval: 1 / 30, _accelMinus: 1, _accelCurTime: 0, _acceleration: null, _accelDeviceEvent: null, _getUnUsedIndex: function () {
  1686. for (var a = this._indexBitsUsed, b = 0; b < this._maxTouches; b++) {
  1687. if (!(a & 1))return this._indexBitsUsed |= 1 << b, b;
  1688. a >>= 1
  1689. }
  1690. return-1
  1691. }, _removeUsedIndexBit: function (a) {
  1692. 0 > a ||
  1693. a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a)
  1694. }, _glView: null, handleTouchesBegin: function (a) {
  1695. for (var b, c, d, e = [], f = this._touchesIntegerDict, g = 0, h = a.length; g < h; g++)b = a[g], d = b.getID(), c = f[d], null == c && (c = this._getUnUsedIndex(), -1 == c ? cc.log(cc._LogInfos.inputManager_handleTouchesBegin, c) : (b = this._touches[c] = b, f[d] = c, e.push(b)));
  1696. 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode = cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a))
  1697. }, handleTouchesMove: function (a) {
  1698. for (var b,
  1699. c, d = [], e = this._touches, f = 0, g = a.length; f < g; f++)b = a[f], c = b.getID(), c = this._touchesIntegerDict[c], null != c && e[c] && (e[c]._setPoint(b._point), e[c]._setPrevPoint(b._prevPoint), d.push(e[c]));
  1700. 0 < d.length && (this._glView._convertTouchesWithScale(d), a = new cc.EventTouch(d), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a))
  1701. }, handleTouchesEnd: function (a) {
  1702. a = this.getSetOfTouchesEndOrCancel(a);
  1703. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED,
  1704. cc.eventManager.dispatchEvent(a))
  1705. }, handleTouchesCancel: function (a) {
  1706. a = this.getSetOfTouchesEndOrCancel(a);
  1707. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a))
  1708. }, getSetOfTouchesEndOrCancel: function (a) {
  1709. for (var b, c, d, e = [], f = this._touches, g = this._touchesIntegerDict, h = 0, k = a.length; h < k; h++)b = a[h], d = b.getID(), c = g[d], null != c && f[c] && (f[c]._setPoint(b._point), f[c]._setPrevPoint(b._prevPoint), e.push(f[c]), this._removeUsedIndexBit(c),
  1710. delete g[d]);
  1711. return e
  1712. }, getHTMLElementPosition: function (a) {
  1713. var b = document.documentElement, c = window, d = null, d = "function" === typeof a.getBoundingClientRect ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? {left: 0, top: 0, width: a.width, height: a.height} : {left: 0, top: 0, width: parseInt(a.style.width), height: parseInt(a.style.height)};
  1714. return{left: d.left + c.pageXOffset - b.clientLeft, top: d.top + c.pageYOffset - b.clientTop, width: d.width, height: d.height}
  1715. }, getPreTouch: function (a) {
  1716. for (var b = null, c = this._preTouchPool,
  1717. d = a.getId(), e = c.length - 1; 0 <= e; e--)if (c[e].getId() == d) {
  1718. b = c[e];
  1719. break
  1720. }
  1721. b || (b = a);
  1722. return b
  1723. }, setPreTouch: function (a) {
  1724. for (var b = !1, c = this._preTouchPool, d = a.getId(), e = c.length - 1; 0 <= e; e--)if (c[e].getId() == d) {
  1725. c[e] = a;
  1726. b = !0;
  1727. break
  1728. }
  1729. b || (50 >= c.length ? c.push(a) : (c[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50))
  1730. }, getTouchByXY: function (a, b, c) {
  1731. var d = this._preTouchPoint;
  1732. a = this._glView.convertToLocationInView(a, b, c);
  1733. b = new cc.Touch(a.x, a.y);
  1734. b._setPrevPoint(d.x, d.y);
  1735. d.x = a.x;
  1736. d.y = a.y;
  1737. return b
  1738. }, getMouseEvent: function (a, b, c) {
  1739. var d = this._prevMousePoint;
  1740. this._glView._convertMouseToLocationInView(a, b);
  1741. b = new cc.EventMouse(c);
  1742. b.setLocation(a.x, a.y);
  1743. b._setPrevCursor(d.x, d.y);
  1744. d.x = a.x;
  1745. d.y = a.y;
  1746. return b
  1747. }, getPointByEvent: function (a, b) {
  1748. if (null != a.pageX)return{x: a.pageX, y: a.pageY};
  1749. b.left -= document.body.scrollLeft;
  1750. b.top -= document.body.scrollTop;
  1751. return{x: a.clientX, y: a.clientY}
  1752. }, getTouchesByEvent: function (a, b) {
  1753. for (var c = [], d = this._glView, e, f, g = this._preTouchPoint, h = a.changedTouches.length, k = 0; k <
  1754. h; k++)if (e = a.changedTouches[k]) {
  1755. var l;
  1756. l = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? d.convertToLocationInView(e.pageX, e.pageY, b) : d.convertToLocationInView(e.clientX, e.clientY, b);
  1757. null != e.identifier ? (e = new cc.Touch(l.x, l.y, e.identifier), f = this.getPreTouch(e).getLocation(), e._setPrevPoint(f.x, f.y), this.setPreTouch(e)) : (e = new cc.Touch(l.x, l.y), e._setPrevPoint(g.x, g.y));
  1758. g.x = l.x;
  1759. g.y = l.y;
  1760. c.push(e)
  1761. }
  1762. return c
  1763. }, registerSystemEvent: function (a) {
  1764. if (!this._isRegisterEvent) {
  1765. var b = this._glView = cc.view, c = this,
  1766. d = "touches"in cc.sys.capabilities;
  1767. "mouse"in cc.sys.capabilities && (cc._addEventListener(window, "mousedown", function () {
  1768. c._mousePressed = !0
  1769. }, !1), cc._addEventListener(window, "mouseup", function (b) {
  1770. var e = c._mousePressed;
  1771. c._mousePressed = !1;
  1772. if (e) {
  1773. var e = c.getHTMLElementPosition(a), f = c.getPointByEvent(b, e);
  1774. cc.rectContainsPoint(new cc.Rect(e.left, e.top, e.width, e.height), f) || (d || c.handleTouchesEnd([c.getTouchByXY(f.x, f.y, e)]), e = c.getMouseEvent(f, e, cc.EventMouse.UP), e.setButton(b.button), cc.eventManager.dispatchEvent(e))
  1775. }
  1776. },
  1777. !1), cc._addEventListener(a, "mousedown", function (b) {
  1778. c._mousePressed = !0;
  1779. var e = c.getHTMLElementPosition(a), f = c.getPointByEvent(b, e);
  1780. d || c.handleTouchesBegin([c.getTouchByXY(f.x, f.y, e)]);
  1781. e = c.getMouseEvent(f, e, cc.EventMouse.DOWN);
  1782. e.setButton(b.button);
  1783. cc.eventManager.dispatchEvent(e);
  1784. b.stopPropagation();
  1785. b.preventDefault();
  1786. a.focus()
  1787. }, !1), cc._addEventListener(a, "mouseup", function (b) {
  1788. c._mousePressed = !1;
  1789. var e = c.getHTMLElementPosition(a), f = c.getPointByEvent(b, e);
  1790. d || c.handleTouchesEnd([c.getTouchByXY(f.x, f.y,
  1791. e)]);
  1792. e = c.getMouseEvent(f, e, cc.EventMouse.UP);
  1793. e.setButton(b.button);
  1794. cc.eventManager.dispatchEvent(e);
  1795. b.stopPropagation();
  1796. b.preventDefault()
  1797. }, !1), cc._addEventListener(a, "mousemove", function (b) {
  1798. var e = c.getHTMLElementPosition(a), f = c.getPointByEvent(b, e);
  1799. d || c.handleTouchesMove([c.getTouchByXY(f.x, f.y, e)]);
  1800. e = c.getMouseEvent(f, e, cc.EventMouse.MOVE);
  1801. c._mousePressed ? e.setButton(b.button) : e.setButton(null);
  1802. cc.eventManager.dispatchEvent(e);
  1803. b.stopPropagation();
  1804. b.preventDefault()
  1805. }, !1), cc._addEventListener(a, "mousewheel",
  1806. function (b) {
  1807. var d = c.getHTMLElementPosition(a), e = c.getPointByEvent(b, d), d = c.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  1808. d.setButton(b.button);
  1809. d.setScrollData(0, b.wheelDelta);
  1810. cc.eventManager.dispatchEvent(d);
  1811. b.stopPropagation();
  1812. b.preventDefault()
  1813. }, !1), cc._addEventListener(a, "DOMMouseScroll", function (b) {
  1814. var d = c.getHTMLElementPosition(a), e = c.getPointByEvent(b, d), d = c.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  1815. d.setButton(b.button);
  1816. d.setScrollData(0, -120 * b.detail);
  1817. cc.eventManager.dispatchEvent(d);
  1818. b.stopPropagation();
  1819. b.preventDefault()
  1820. }, !1));
  1821. if (window.navigator.msPointerEnabled) {
  1822. var e = {MSPointerDown: c.handleTouchesBegin, MSPointerMove: c.handleTouchesMove, MSPointerUp: c.handleTouchesEnd, MSPointerCancel: c.handleTouchesCancel}, f;
  1823. for (f in e)(function (b, d) {
  1824. cc._addEventListener(a, b, function (b) {
  1825. var e = c.getHTMLElementPosition(a);
  1826. e.left -= document.documentElement.scrollLeft;
  1827. e.top -= document.documentElement.scrollTop;
  1828. d.call(c, [c.getTouchByXY(b.clientX, b.clientY, e)]);
  1829. b.stopPropagation()
  1830. }, !1)
  1831. })(f, e[f])
  1832. }
  1833. d && (cc._addEventListener(a,
  1834. "touchstart", function (b) {
  1835. if (b.changedTouches) {
  1836. var d = c.getHTMLElementPosition(a);
  1837. d.left -= document.body.scrollLeft;
  1838. d.top -= document.body.scrollTop;
  1839. c.handleTouchesBegin(c.getTouchesByEvent(b, d));
  1840. b.stopPropagation();
  1841. b.preventDefault();
  1842. a.focus()
  1843. }
  1844. }, !1), cc._addEventListener(a, "touchmove", function (b) {
  1845. if (b.changedTouches) {
  1846. var d = c.getHTMLElementPosition(a);
  1847. d.left -= document.body.scrollLeft;
  1848. d.top -= document.body.scrollTop;
  1849. c.handleTouchesMove(c.getTouchesByEvent(b, d));
  1850. b.stopPropagation();
  1851. b.preventDefault()
  1852. }
  1853. }, !1),
  1854. cc._addEventListener(a, "touchend", function (b) {
  1855. if (b.changedTouches) {
  1856. var d = c.getHTMLElementPosition(a);
  1857. d.left -= document.body.scrollLeft;
  1858. d.top -= document.body.scrollTop;
  1859. c.handleTouchesEnd(c.getTouchesByEvent(b, d));
  1860. b.stopPropagation();
  1861. b.preventDefault()
  1862. }
  1863. }, !1), cc._addEventListener(a, "touchcancel", function (d) {
  1864. if (d.changedTouches) {
  1865. var e = c.getHTMLElementPosition(a);
  1866. e.left -= document.body.scrollLeft;
  1867. e.top -= document.body.scrollTop;
  1868. b.handleTouchesCancel(c.getTouchesByEvent(d, e));
  1869. d.stopPropagation();
  1870. d.preventDefault()
  1871. }
  1872. },
  1873. !1));
  1874. this._registerKeyboardEvent();
  1875. this._registerAccelerometerEvent();
  1876. this._isRegisterEvent = !0
  1877. }
  1878. }, _registerKeyboardEvent: function () {
  1879. }, _registerAccelerometerEvent: function () {
  1880. }, update: function (a) {
  1881. this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));
  1882. this._accelCurTime += a
  1883. }};
  1884. cc.AffineTransform = function (a, b, c, d, e, f) {
  1885. this.a = a;
  1886. this.b = b;
  1887. this.c = c;
  1888. this.d = d;
  1889. this.tx = e;
  1890. this.ty = f
  1891. };
  1892. cc.AffineTransformMake = function (a, b, c, d, e, f) {
  1893. return{a: a, b: b, c: c, d: d, tx: e, ty: f}
  1894. };
  1895. cc.PointApplyAffineTransform = function (a, b) {
  1896. return{x: b.a * a.x + b.c * a.y + b.tx, y: b.b * a.x + b.d * a.y + b.ty}
  1897. };
  1898. cc._PointApplyAffineTransform = function (a, b, c) {
  1899. return{x: c.a * a + c.c * b + c.tx, y: c.b * a + c.d * b + c.ty}
  1900. };
  1901. cc.SizeApplyAffineTransform = function (a, b) {
  1902. return{width: b.a * a.width + b.c * a.height, height: b.b * a.width + b.d * a.height}
  1903. };
  1904. cc.AffineTransformMakeIdentity = function () {
  1905. return{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}
  1906. };
  1907. cc.AffineTransformIdentity = function () {
  1908. return{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}
  1909. };
  1910. cc.RectApplyAffineTransform = function (a, b) {
  1911. var c = cc.rectGetMinY(a), d = cc.rectGetMinX(a), e = cc.rectGetMaxX(a), f = cc.rectGetMaxY(a), g = cc._PointApplyAffineTransform(d, c, b), c = cc._PointApplyAffineTransform(e, c, b), d = cc._PointApplyAffineTransform(d, f, b), h = cc._PointApplyAffineTransform(e, f, b), e = Math.min(g.x, c.x, d.x, h.x), f = Math.max(g.x, c.x, d.x, h.x), k = Math.min(g.y, c.y, d.y, h.y), g = Math.max(g.y, c.y, d.y, h.y);
  1912. return cc.rect(e, k, f - e, g - k)
  1913. };
  1914. cc._RectApplyAffineTransformIn = function (a, b) {
  1915. var c = cc.rectGetMinY(a), d = cc.rectGetMinX(a), e = cc.rectGetMaxX(a), f = cc.rectGetMaxY(a), g = cc._PointApplyAffineTransform(d, c, b), c = cc._PointApplyAffineTransform(e, c, b), d = cc._PointApplyAffineTransform(d, f, b), h = cc._PointApplyAffineTransform(e, f, b), e = Math.min(g.x, c.x, d.x, h.x), f = Math.max(g.x, c.x, d.x, h.x), k = Math.min(g.y, c.y, d.y, h.y), g = Math.max(g.y, c.y, d.y, h.y);
  1916. a.x = e;
  1917. a.y = k;
  1918. a.width = f - e;
  1919. a.height = g - k;
  1920. return a
  1921. };
  1922. cc.AffineTransformTranslate = function (a, b, c) {
  1923. return{a: a.a, b: a.b, c: a.c, d: a.d, tx: a.tx + a.a * b + a.c * c, ty: a.ty + a.b * b + a.d * c}
  1924. };
  1925. cc.AffineTransformScale = function (a, b, c) {
  1926. return{a: a.a * b, b: a.b * b, c: a.c * c, d: a.d * c, tx: a.tx, ty: a.ty}
  1927. };
  1928. cc.AffineTransformRotate = function (a, b) {
  1929. var c = Math.sin(b), d = Math.cos(b);
  1930. return{a: a.a * d + a.c * c, b: a.b * d + a.d * c, c: a.c * d - a.a * c, d: a.d * d - a.b * c, tx: a.tx, ty: a.ty}
  1931. };
  1932. cc.AffineTransformConcat = function (a, b) {
  1933. return{a: a.a * b.a + a.b * b.c, b: a.a * b.b + a.b * b.d, c: a.c * b.a + a.d * b.c, d: a.c * b.b + a.d * b.d, tx: a.tx * b.a + a.ty * b.c + b.tx, ty: a.tx * b.b + a.ty * b.d + b.ty}
  1934. };
  1935. cc.AffineTransformEqualToTransform = function (a, b) {
  1936. return a.a === b.a && a.b === b.b && a.c === b.c && a.d === b.d && a.tx === b.tx && a.ty === b.ty
  1937. };
  1938. cc.AffineTransformInvert = function (a) {
  1939. var b = 1 / (a.a * a.d - a.b * a.c);
  1940. return{a: b * a.d, b: -b * a.b, c: -b * a.c, d: b * a.a, tx: b * (a.c * a.ty - a.d * a.tx), ty: b * (a.b * a.tx - a.a * a.ty)}
  1941. };
  1942. cc.POINT_EPSILON = parseFloat("1.192092896e-07F");
  1943. cc.pNeg = function (a) {
  1944. return cc.p(-a.x, -a.y)
  1945. };
  1946. cc.pAdd = function (a, b) {
  1947. return cc.p(a.x + b.x, a.y + b.y)
  1948. };
  1949. cc.pSub = function (a, b) {
  1950. return cc.p(a.x - b.x, a.y - b.y)
  1951. };
  1952. cc.pMult = function (a, b) {
  1953. return cc.p(a.x * b, a.y * b)
  1954. };
  1955. cc.pMidpoint = function (a, b) {
  1956. return cc.pMult(cc.pAdd(a, b), 0.5)
  1957. };
  1958. cc.pDot = function (a, b) {
  1959. return a.x * b.x + a.y * b.y
  1960. };
  1961. cc.pCross = function (a, b) {
  1962. return a.x * b.y - a.y * b.x
  1963. };
  1964. cc.pPerp = function (a) {
  1965. return cc.p(-a.y, a.x)
  1966. };
  1967. cc.pRPerp = function (a) {
  1968. return cc.p(a.y, -a.x)
  1969. };
  1970. cc.pProject = function (a, b) {
  1971. return cc.pMult(b, cc.pDot(a, b) / cc.pDot(b, b))
  1972. };
  1973. cc.pRotate = function (a, b) {
  1974. return cc.p(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x)
  1975. };
  1976. cc.pUnrotate = function (a, b) {
  1977. return cc.p(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y)
  1978. };
  1979. cc.pLengthSQ = function (a) {
  1980. return cc.pDot(a, a)
  1981. };
  1982. cc.pDistanceSQ = function (a, b) {
  1983. return cc.pLengthSQ(cc.pSub(a, b))
  1984. };
  1985. cc.pLength = function (a) {
  1986. return Math.sqrt(cc.pLengthSQ(a))
  1987. };
  1988. cc.pDistance = function (a, b) {
  1989. return cc.pLength(cc.pSub(a, b))
  1990. };
  1991. cc.pNormalize = function (a) {
  1992. return cc.pMult(a, 1 / cc.pLength(a))
  1993. };
  1994. cc.pForAngle = function (a) {
  1995. return cc.p(Math.cos(a), Math.sin(a))
  1996. };
  1997. cc.pToAngle = function (a) {
  1998. return Math.atan2(a.y, a.x)
  1999. };
  2000. cc.clampf = function (a, b, c) {
  2001. if (b > c) {
  2002. var d = b;
  2003. b = c;
  2004. c = d
  2005. }
  2006. return a < b ? b : a < c ? a : c
  2007. };
  2008. cc.pClamp = function (a, b, c) {
  2009. return cc.p(cc.clampf(a.x, b.x, c.x), cc.clampf(a.y, b.y, c.y))
  2010. };
  2011. cc.pFromSize = function (a) {
  2012. return cc.p(a.width, a.height)
  2013. };
  2014. cc.pCompOp = function (a, b) {
  2015. return cc.p(b(a.x), b(a.y))
  2016. };
  2017. cc.pLerp = function (a, b, c) {
  2018. return cc.pAdd(cc.pMult(a, 1 - c), cc.pMult(b, c))
  2019. };
  2020. cc.pFuzzyEqual = function (a, b, c) {
  2021. return a.x - c <= b.x && b.x <= a.x + c && a.y - c <= b.y && b.y <= a.y + c ? !0 : !1
  2022. };
  2023. cc.pCompMult = function (a, b) {
  2024. return cc.p(a.x * b.x, a.y * b.y)
  2025. };
  2026. cc.pAngleSigned = function (a, b) {
  2027. var c = cc.pNormalize(a), d = cc.pNormalize(b), c = Math.atan2(c.x * d.y - c.y * d.x, cc.pDot(c, d));
  2028. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  2029. };
  2030. cc.pAngle = function (a, b) {
  2031. var c = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(b)));
  2032. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  2033. };
  2034. cc.pRotateByAngle = function (a, b, c) {
  2035. a = cc.pSub(a, b);
  2036. var d = Math.cos(c);
  2037. c = Math.sin(c);
  2038. var e = a.x;
  2039. a.x = e * d - a.y * c + b.x;
  2040. a.y = e * c + a.y * d + b.y;
  2041. return a
  2042. };
  2043. cc.pLineIntersect = function (a, b, c, d, e) {
  2044. if (a.x == b.x && a.y == b.y || c.x == d.x && c.y == d.y)return!1;
  2045. var f = b.x - a.x;
  2046. b = b.y - a.y;
  2047. var g = d.x - c.x;
  2048. d = d.y - c.y;
  2049. var h = a.x - c.x;
  2050. a = a.y - c.y;
  2051. c = d * f - g * b;
  2052. e.x = g * a - d * h;
  2053. e.y = f * a - b * h;
  2054. if (0 == c)return 0 == e.x || 0 == e.y ? !0 : !1;
  2055. e.x /= c;
  2056. e.y /= c;
  2057. return!0
  2058. };
  2059. cc.pSegmentIntersect = function (a, b, c, d) {
  2060. var e = cc.p(0, 0);
  2061. return cc.pLineIntersect(a, b, c, d, e) && 0 <= e.x && 1 >= e.x && 0 <= e.y && 1 >= e.y ? !0 : !1
  2062. };
  2063. cc.pIntersectPoint = function (a, b, c, d) {
  2064. var e = cc.p(0, 0);
  2065. return cc.pLineIntersect(a, b, c, d, e) ? (c = cc.p(0, 0), c.x = a.x + e.x * (b.x - a.x), c.y = a.y + e.x * (b.y - a.y), c) : cc.p(0, 0)
  2066. };
  2067. cc.pSameAs = function (a, b) {
  2068. return null != a && null != b ? a.x == b.x && a.y == b.y : !1
  2069. };
  2070. cc.pZeroIn = function (a) {
  2071. a.x = 0;
  2072. a.y = 0
  2073. };
  2074. cc.pIn = function (a, b) {
  2075. a.x = b.x;
  2076. a.y = b.y
  2077. };
  2078. cc.pMultIn = function (a, b) {
  2079. a.x *= b;
  2080. a.y *= b
  2081. };
  2082. cc.pSubIn = function (a, b) {
  2083. a.x -= b.x;
  2084. a.y -= b.y
  2085. };
  2086. cc.pAddIn = function (a, b) {
  2087. a.x += b.x;
  2088. a.y += b.y
  2089. };
  2090. cc.pNormalizeIn = function (a) {
  2091. cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y))
  2092. };
  2093. cc.Touch = cc.Class.extend({_point: null, _prevPoint: null, _id: 0, _startPointCaptured: !1, _startPoint: null, ctor: function (a, b, c) {
  2094. this._point = cc.p(a || 0, b || 0);
  2095. this._id = c || 0
  2096. }, getLocation: function () {
  2097. return{x: this._point.x, y: this._point.y}
  2098. }, getLocationX: function () {
  2099. return this._point.x
  2100. }, getLocationY: function () {
  2101. return this._point.y
  2102. }, getPreviousLocation: function () {
  2103. return{x: this._prevPoint.x, y: this._prevPoint.y}
  2104. }, getStartLocation: function () {
  2105. return{x: this._startPoint.x, y: this._startPoint.y}
  2106. }, getDelta: function () {
  2107. return cc.pSub(this._point,
  2108. this._prevPoint)
  2109. }, getLocationInView: function () {
  2110. return{x: this._point.x, y: this._point.y}
  2111. }, getPreviousLocationInView: function () {
  2112. return{x: this._prevPoint.x, y: this._prevPoint.y}
  2113. }, getStartLocationInView: function () {
  2114. return{x: this._startPoint.x, y: this._startPoint.y}
  2115. }, getID: function () {
  2116. return this._id
  2117. }, getId: function () {
  2118. return this._id
  2119. }, setTouchInfo: function (a, b, c) {
  2120. this._prevPoint = this._point;
  2121. this._point = cc.p(b || 0, c || 0);
  2122. this._id = a;
  2123. this._startPointCaptured || (this._startPoint = cc.p(this._point), this._startPointCaptured = !0)
  2124. }, _setPoint: function (a, b) {
  2125. void 0 === b ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = b)
  2126. }, _setPrevPoint: function (a, b) {
  2127. this._prevPoint = void 0 === b ? cc.p(a.x, a.y) : cc.p(a || 0, b || 0)
  2128. }});
  2129. cc.Event = cc.Class.extend({_type: 0, _isStopped: !1, _currentTarget: null, _setCurrentTarget: function (a) {
  2130. this._currentTarget = a
  2131. }, ctor: function (a) {
  2132. this._type = a
  2133. }, getType: function () {
  2134. return this._type
  2135. }, stopPropagation: function () {
  2136. this._isStopped = !0
  2137. }, isStopped: function () {
  2138. return this._isStopped
  2139. }, getCurrentTarget: function () {
  2140. return this._currentTarget
  2141. }});
  2142. cc.Event.TOUCH = 0;
  2143. cc.Event.KEYBOARD = 1;
  2144. cc.Event.ACCELERATION = 2;
  2145. cc.Event.MOUSE = 3;
  2146. cc.Event.CUSTOM = 4;
  2147. cc.EventCustom = cc.Event.extend({_eventName: null, _userData: null, ctor: function (a) {
  2148. cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM);
  2149. this._eventName = a
  2150. }, setUserData: function (a) {
  2151. this._userData = a
  2152. }, getUserData: function () {
  2153. return this._userData
  2154. }, getEventName: function () {
  2155. return this._eventName
  2156. }});
  2157. cc.EventMouse = cc.Event.extend({_eventType: 0, _button: 0, _x: 0, _y: 0, _prevX: 0, _prevY: 0, _scrollX: 0, _scrollY: 0, ctor: function (a) {
  2158. cc.Event.prototype.ctor.call(this, cc.Event.MOUSE);
  2159. this._eventType = a
  2160. }, setScrollData: function (a, b) {
  2161. this._scrollX = a;
  2162. this._scrollY = b
  2163. }, getScrollX: function () {
  2164. return this._scrollX
  2165. }, getScrollY: function () {
  2166. return this._scrollY
  2167. }, setLocation: function (a, b) {
  2168. this._x = a;
  2169. this._y = b
  2170. }, getLocation: function () {
  2171. return{x: this._x, y: this._y}
  2172. }, getLocationInView: function () {
  2173. return{x: this._x, y: cc.view._designResolutionSize.height -
  2174. this._y}
  2175. }, _setPrevCursor: function (a, b) {
  2176. this._prevX = a;
  2177. this._prevY = b
  2178. }, getDelta: function () {
  2179. return{x: this._x - this._prevX, y: this._y - this._prevY}
  2180. }, getDeltaX: function () {
  2181. return this._x - this._prevX
  2182. }, getDeltaY: function () {
  2183. return this._y - this._prevY
  2184. }, setButton: function (a) {
  2185. this._button = a
  2186. }, getButton: function () {
  2187. return this._button
  2188. }, getLocationX: function () {
  2189. return this._x
  2190. }, getLocationY: function () {
  2191. return this._y
  2192. }});
  2193. cc.EventMouse.NONE = 0;
  2194. cc.EventMouse.DOWN = 1;
  2195. cc.EventMouse.UP = 2;
  2196. cc.EventMouse.MOVE = 3;
  2197. cc.EventMouse.SCROLL = 4;
  2198. cc.EventMouse.BUTTON_LEFT = 0;
  2199. cc.EventMouse.BUTTON_RIGHT = 2;
  2200. cc.EventMouse.BUTTON_MIDDLE = 1;
  2201. cc.EventMouse.BUTTON_4 = 3;
  2202. cc.EventMouse.BUTTON_5 = 4;
  2203. cc.EventMouse.BUTTON_6 = 5;
  2204. cc.EventMouse.BUTTON_7 = 6;
  2205. cc.EventMouse.BUTTON_8 = 7;
  2206. cc.EventTouch = cc.Event.extend({_eventCode: 0, _touches: null, ctor: function (a) {
  2207. cc.Event.prototype.ctor.call(this, cc.Event.TOUCH);
  2208. this._touches = a || []
  2209. }, getEventCode: function () {
  2210. return this._eventCode
  2211. }, getTouches: function () {
  2212. return this._touches
  2213. }, _setEventCode: function (a) {
  2214. this._eventCode = a
  2215. }, _setTouches: function (a) {
  2216. this._touches = a
  2217. }});
  2218. cc.EventTouch.MAX_TOUCHES = 5;
  2219. cc.EventTouch.EventCode = {BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3};
  2220. cc.EventListener = cc.Class.extend({_onEvent: null, _type: 0, _listenerID: null, _registered: !1, _fixedPriority: 0, _node: null, _paused: !1, _isEnabled: !0, ctor: function (a, b, c) {
  2221. this._onEvent = c;
  2222. this._type = a || 0;
  2223. this._listenerID = b || ""
  2224. }, _setPaused: function (a) {
  2225. this._paused = a
  2226. }, _isPaused: function () {
  2227. return this._paused
  2228. }, _setRegistered: function (a) {
  2229. this._registered = a
  2230. }, _isRegistered: function () {
  2231. return this._registered
  2232. }, _getType: function () {
  2233. return this._type
  2234. }, _getListenerID: function () {
  2235. return this._listenerID
  2236. }, _setFixedPriority: function (a) {
  2237. this._fixedPriority =
  2238. a
  2239. }, _getFixedPriority: function () {
  2240. return this._fixedPriority
  2241. }, _setSceneGraphPriority: function (a) {
  2242. this._node = a
  2243. }, _getSceneGraphPriority: function () {
  2244. return this._node
  2245. }, checkAvailable: function () {
  2246. return null != this._onEvent
  2247. }, clone: function () {
  2248. return null
  2249. }, setEnabled: function (a) {
  2250. this._isEnabled = a
  2251. }, isEnabled: function () {
  2252. return this._isEnabled
  2253. }, retain: function () {
  2254. }, release: function () {
  2255. }});
  2256. cc.EventListener.UNKNOWN = 0;
  2257. cc.EventListener.TOUCH_ONE_BY_ONE = 1;
  2258. cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
  2259. cc.EventListener.KEYBOARD = 3;
  2260. cc.EventListener.MOUSE = 4;
  2261. cc.EventListener.ACCELERATION = 5;
  2262. cc.EventListener.CUSTOM = 6;
  2263. cc._EventListenerCustom = cc.EventListener.extend({_onCustomEvent: null, ctor: function (a, b) {
  2264. this._onCustomEvent = b;
  2265. var c = this;
  2266. cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a, function (a) {
  2267. null != c._onCustomEvent && c._onCustomEvent(a)
  2268. })
  2269. }, checkAvailable: function () {
  2270. return cc.EventListener.prototype.checkAvailable.call(this) && null != this._onCustomEvent
  2271. }, clone: function () {
  2272. return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent)
  2273. }});
  2274. cc._EventListenerCustom.create = function (a, b) {
  2275. return new cc._EventListenerCustom(a, b)
  2276. };
  2277. cc._EventListenerMouse = cc.EventListener.extend({onMouseDown: null, onMouseUp: null, onMouseMove: null, onMouseScroll: null, ctor: function () {
  2278. var a = this;
  2279. cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID, function (b) {
  2280. var c = cc.EventMouse;
  2281. switch (b._eventType) {
  2282. case c.DOWN:
  2283. if (a.onMouseDown)a.onMouseDown(b);
  2284. break;
  2285. case c.UP:
  2286. if (a.onMouseUp)a.onMouseUp(b);
  2287. break;
  2288. case c.MOVE:
  2289. if (a.onMouseMove)a.onMouseMove(b);
  2290. break;
  2291. case c.SCROLL:
  2292. if (a.onMouseScroll)a.onMouseScroll(b)
  2293. }
  2294. })
  2295. },
  2296. clone: function () {
  2297. var a = new cc._EventListenerMouse;
  2298. a.onMouseDown = this.onMouseDown;
  2299. a.onMouseUp = this.onMouseUp;
  2300. a.onMouseMove = this.onMouseMove;
  2301. a.onMouseScroll = this.onMouseScroll;
  2302. return a
  2303. }, checkAvailable: function () {
  2304. return!0
  2305. }});
  2306. cc._EventListenerMouse.LISTENER_ID = "__cc_mouse";
  2307. cc._EventListenerMouse.create = function () {
  2308. return new cc._EventListenerMouse
  2309. };
  2310. cc._EventListenerTouchOneByOne = cc.EventListener.extend({_claimedTouches: null, swallowTouches: !1, onTouchBegan: null, onTouchMoved: null, onTouchEnded: null, onTouchCancelled: null, ctor: function () {
  2311. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null);
  2312. this._claimedTouches = []
  2313. }, setSwallowTouches: function (a) {
  2314. this.swallowTouches = a
  2315. }, clone: function () {
  2316. var a = new cc._EventListenerTouchOneByOne;
  2317. a.onTouchBegan = this.onTouchBegan;
  2318. a.onTouchMoved = this.onTouchMoved;
  2319. a.onTouchEnded = this.onTouchEnded;
  2320. a.onTouchCancelled = this.onTouchCancelled;
  2321. a.swallowTouches = this.swallowTouches;
  2322. return a
  2323. }, checkAvailable: function () {
  2324. return!this.onTouchBegan ? (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1) : !0
  2325. }});
  2326. cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one";
  2327. cc._EventListenerTouchOneByOne.create = function () {
  2328. return new cc._EventListenerTouchOneByOne
  2329. };
  2330. cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({onTouchesBegan: null, onTouchesMoved: null, onTouchesEnded: null, onTouchesCancelled: null, ctor: function () {
  2331. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null)
  2332. }, clone: function () {
  2333. var a = new cc._EventListenerTouchAllAtOnce;
  2334. a.onTouchesBegan = this.onTouchesBegan;
  2335. a.onTouchesMoved = this.onTouchesMoved;
  2336. a.onTouchesEnded = this.onTouchesEnded;
  2337. a.onTouchesCancelled = this.onTouchesCancelled;
  2338. return a
  2339. },
  2340. checkAvailable: function () {
  2341. return null == this.onTouchesBegan && null == this.onTouchesMoved && null == this.onTouchesEnded && null == this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0
  2342. }});
  2343. cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
  2344. cc._EventListenerTouchAllAtOnce.create = function () {
  2345. return new cc._EventListenerTouchAllAtOnce
  2346. };
  2347. cc.EventListener.create = function (a) {
  2348. cc.assert(a && a.event, cc._LogInfos.EventListener_create);
  2349. var b = a.event;
  2350. delete a.event;
  2351. var c = null;
  2352. b === cc.EventListener.TOUCH_ONE_BY_ONE ? c = new cc._EventListenerTouchOneByOne : b === cc.EventListener.TOUCH_ALL_AT_ONCE ? c = new cc._EventListenerTouchAllAtOnce : b === cc.EventListener.MOUSE ? c = new cc._EventListenerMouse : b === cc.EventListener.CUSTOM ? (c = new cc._EventListenerCustom(a.eventName, a.callback), delete a.eventName, delete a.callback) : b === cc.EventListener.KEYBOARD ? c = new cc._EventListenerKeyboard :
  2353. b === cc.EventListener.ACCELERATION && (c = new cc._EventListenerAcceleration(a.callback), delete a.callback);
  2354. for (var d in a)c[d] = a[d];
  2355. return c
  2356. };
  2357. cc.copyArray = function (a) {
  2358. var b, c = a.length, d = Array(c);
  2359. for (b = 0; b < c; b += 1)d[b] = a[b];
  2360. return d
  2361. };
  2362. cc._EventListenerVector = cc.Class.extend({_fixedListeners: null, _sceneGraphListeners: null, gt0Index: 0, ctor: function () {
  2363. this._fixedListeners = [];
  2364. this._sceneGraphListeners = []
  2365. }, size: function () {
  2366. return this._fixedListeners.length + this._sceneGraphListeners.length
  2367. }, empty: function () {
  2368. return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length
  2369. }, push: function (a) {
  2370. 0 == a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a)
  2371. }, clearSceneGraphListeners: function () {
  2372. this._sceneGraphListeners.length =
  2373. 0
  2374. }, clearFixedListeners: function () {
  2375. this._fixedListeners.length = 0
  2376. }, clear: function () {
  2377. this._sceneGraphListeners.length = 0;
  2378. this._fixedListeners.length = 0
  2379. }, getFixedPriorityListeners: function () {
  2380. return this._fixedListeners
  2381. }, getSceneGraphPriorityListeners: function () {
  2382. return this._sceneGraphListeners
  2383. }});
  2384. cc.__getListenerID = function (a) {
  2385. var b = cc.Event, c = a.getType();
  2386. if (c === b.ACCELERATION)return cc._EventListenerAcceleration.LISTENER_ID;
  2387. if (c === b.CUSTOM)return a.getEventName();
  2388. if (c === b.KEYBOARD)return cc._EventListenerKeyboard.LISTENER_ID;
  2389. if (c === b.MOUSE)return cc._EventListenerMouse.LISTENER_ID;
  2390. c === b.TOUCH && cc.log(cc._LogInfos.__getListenerID);
  2391. return""
  2392. };
  2393. cc.eventManager = {DIRTY_NONE: 0, DIRTY_FIXED_PRIORITY: 1, DIRTY_SCENE_GRAPH_PRIORITY: 2, DIRTY_ALL: 3, _listenersMap: {}, _priorityDirtyFlagMap: {}, _nodeListenersMap: {}, _nodePriorityMap: {}, _globalZOrderNodeMap: {}, _toAddedListeners: [], _dirtyNodes: [], _inDispatch: 0, _isEnabled: !1, _nodePriorityIndex: 0, _internalCustomListenerIDs: [cc.game.EVENT_HIDE, cc.game.EVENT_SHOW], _setDirtyForNode: function (a) {
  2394. null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a);
  2395. a = a.getChildren();
  2396. for (var b = 0, c = a.length; b < c; b++)this._setDirtyForNode(a[b])
  2397. },
  2398. pauseTarget: function (a, b) {
  2399. var c = this._nodeListenersMap[a.__instanceId], d, e;
  2400. if (c) {
  2401. d = 0;
  2402. for (e = c.length; d < e; d++)c[d]._setPaused(!0)
  2403. }
  2404. if (!0 === b) {
  2405. c = a.getChildren();
  2406. d = 0;
  2407. for (e = c.length; d < e; d++)this.pauseTarget(c[d], !0)
  2408. }
  2409. }, resumeTarget: function (a, b) {
  2410. var c = this._nodeListenersMap[a.__instanceId], d, e;
  2411. if (c) {
  2412. d = 0;
  2413. for (e = c.length; d < e; d++)c[d]._setPaused(!1)
  2414. }
  2415. this._setDirtyForNode(a);
  2416. if (!0 === b) {
  2417. c = a.getChildren();
  2418. d = 0;
  2419. for (e = c.length; d < e; d++)this.resumeTarget(c[d], !0)
  2420. }
  2421. }, _addListener: function (a) {
  2422. 0 === this._inDispatch ? this._forceAddEventListener(a) :
  2423. this._toAddedListeners.push(a)
  2424. }, _forceAddEventListener: function (a) {
  2425. var b = a._getListenerID(), c = this._listenersMap[b];
  2426. c || (c = new cc._EventListenerVector, this._listenersMap[b] = c);
  2427. c.push(a);
  2428. 0 == a._getFixedPriority() ? (this._setDirty(b, this.DIRTY_SCENE_GRAPH_PRIORITY), b = a._getSceneGraphPriority(), null == b && cc.log(cc._LogInfos.eventManager__forceAddEventListener), this._associateNodeAndEventListener(b, a), b.isRunning() && this.resumeTarget(b)) : this._setDirty(b, this.DIRTY_FIXED_PRIORITY)
  2429. }, _getListeners: function (a) {
  2430. return this._listenersMap[a]
  2431. },
  2432. _updateDirtyFlagForSceneGraph: function () {
  2433. if (0 != this._dirtyNodes.length) {
  2434. for (var a = this._dirtyNodes, b, c, d = this._nodeListenersMap, e = 0, f = a.length; e < f; e++)if (b = d[a[e].__instanceId])for (var g = 0, h = b.length; g < h; g++)(c = b[g]) && this._setDirty(c._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
  2435. this._dirtyNodes.length = 0
  2436. }
  2437. }, _removeAllListenersInVector: function (a) {
  2438. if (a)for (var b, c = 0; c < a.length;)b = a[c], b._setRegistered(!1), null != b._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(b._getSceneGraphPriority(),
  2439. b), b._setSceneGraphPriority(null)), 0 === this._inDispatch ? cc.arrayRemoveObject(a, b) : ++c
  2440. }, _removeListenersForListenerID: function (a) {
  2441. var b = this._listenersMap[a];
  2442. if (b) {
  2443. var c = b.getFixedPriorityListeners(), d = b.getSceneGraphPriorityListeners();
  2444. this._removeAllListenersInVector(d);
  2445. this._removeAllListenersInVector(c);
  2446. delete this._priorityDirtyFlagMap[a];
  2447. this._inDispatch || (b.clear(), delete this._listenersMap[a])
  2448. }
  2449. c = this._toAddedListeners;
  2450. for (b = 0; b < c.length;)(d = c[b]) && d._getListenerID() == a ? cc.arrayRemoveObject(c,
  2451. d) : ++b
  2452. }, _sortEventListeners: function (a) {
  2453. var b = this.DIRTY_NONE, c = this._priorityDirtyFlagMap;
  2454. c[a] && (b = c[a]);
  2455. b != this.DIRTY_NONE && (c[a] = this.DIRTY_NONE, b & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(a), b & this.DIRTY_SCENE_GRAPH_PRIORITY && ((b = cc.director.getRunningScene()) ? this._sortListenersOfSceneGraphPriority(a, b) : c[a] = this.DIRTY_SCENE_GRAPH_PRIORITY))
  2456. }, _sortListenersOfSceneGraphPriority: function (a, b) {
  2457. var c = this._getListeners(a);
  2458. if (c) {
  2459. var d = c.getSceneGraphPriorityListeners();
  2460. d && 0 !==
  2461. d.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {}, this._visitTarget(b, !0), c.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))
  2462. }
  2463. }, _sortEventListenersOfSceneGraphPriorityDes: function (a, b) {
  2464. var c = cc.eventManager._nodePriorityMap;
  2465. return c[b._getSceneGraphPriority().__instanceId] - c[a._getSceneGraphPriority().__instanceId]
  2466. }, _sortListenersOfFixedPriority: function (a) {
  2467. if (a = this._listenersMap[a]) {
  2468. var b = a.getFixedPriorityListeners();
  2469. if (b && 0 !== b.length) {
  2470. b.sort(this._sortListenersOfFixedPriorityAsc);
  2471. for (var c = 0, d = b.length; c < d && !(0 <= b[c]._getFixedPriority());)++c;
  2472. a.gt0Index = c
  2473. }
  2474. }
  2475. }, _sortListenersOfFixedPriorityAsc: function (a, b) {
  2476. return a._getFixedPriority() - b._getFixedPriority()
  2477. }, _onUpdateListeners: function (a) {
  2478. if (a = this._listenersMap[a]) {
  2479. var b = a.getFixedPriorityListeners(), c = a.getSceneGraphPriorityListeners(), d, e;
  2480. if (c)for (d = 0; d < c.length;)e = c[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(c, e);
  2481. if (b)for (d = 0; d < b.length;)e = b[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(b, e);
  2482. c && 0 === c.length && a.clearSceneGraphListeners();
  2483. b && 0 === b.length && a.clearFixedListeners()
  2484. }
  2485. }, _updateListeners: function (a) {
  2486. var b = this._inDispatch;
  2487. cc.assert(0 < b, cc._LogInfos.EventManager__updateListeners);
  2488. a.getType() == cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a));
  2489. if (!(1 < b)) {
  2490. cc.assert(1 == b, cc._LogInfos.EventManager__updateListeners_2);
  2491. a = this._listenersMap;
  2492. var b = this._priorityDirtyFlagMap, c;
  2493. for (c in a)a[c].empty() &&
  2494. (delete b[c], delete a[c]);
  2495. c = this._toAddedListeners;
  2496. if (0 !== c.length) {
  2497. a = 0;
  2498. for (b = c.length; a < b; a++)this._forceAddEventListener(c[a]);
  2499. this._toAddedListeners.length = 0
  2500. }
  2501. }
  2502. }, _onTouchEventCallback: function (a, b) {
  2503. if (!a._isRegistered)return!1;
  2504. var c = b.event, d = b.selTouch;
  2505. c._setCurrentTarget(a._node);
  2506. var e = !1, f, g = c.getEventCode(), h = cc.EventTouch.EventCode;
  2507. if (g == h.BEGAN)a.onTouchBegan && (e = a.onTouchBegan(d, c)) && a._registered && a._claimedTouches.push(d); else if (0 < a._claimedTouches.length && -1 != (f = a._claimedTouches.indexOf(d)))if (e = !0, g === h.MOVED && a.onTouchMoved)a.onTouchMoved(d, c); else if (g === h.ENDED) {
  2508. if (a.onTouchEnded)a.onTouchEnded(d, c);
  2509. a._registered && a._claimedTouches.splice(f, 1)
  2510. } else if (g === h.CANCELLED) {
  2511. if (a.onTouchCancelled)a.onTouchCancelled(d, c);
  2512. a._registered && a._claimedTouches.splice(f, 1)
  2513. }
  2514. return c.isStopped() ? (cc.eventManager._updateListeners(c), !0) : e && a._registered && a.swallowTouches ? (b.needsMutableSet && b.touches.splice(d, 1), !0) : !1
  2515. }, _dispatchTouchEvent: function (a) {
  2516. this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);
  2517. this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  2518. var b = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), c = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  2519. if (!(null == b && null == c)) {
  2520. var d = a.getTouches(), e = cc.copyArray(d), f = {event: a, needsMutableSet: b && c, touches: e, selTouch: null};
  2521. if (b)for (var g = 0; g < d.length; g++)if (f.selTouch = d[g], this._dispatchEventToListeners(b, this._onTouchEventCallback, f), a.isStopped())return;
  2522. if (c && 0 < e.length && (this._dispatchEventToListeners(c,
  2523. this._onTouchesEventCallback, {event: a, touches: e}), a.isStopped()))return;
  2524. this._updateListeners(a)
  2525. }
  2526. }, _onTouchesEventCallback: function (a, b) {
  2527. if (!a._registered)return!1;
  2528. var c = cc.EventTouch.EventCode, d = b.event, e = b.touches, f = d.getEventCode();
  2529. d._setCurrentTarget(a._node);
  2530. if (f == c.BEGAN && a.onTouchesBegan)a.onTouchesBegan(e, d); else if (f == c.MOVED && a.onTouchesMoved)a.onTouchesMoved(e, d); else if (f == c.ENDED && a.onTouchesEnded)a.onTouchesEnded(e, d); else if (f == c.CANCELLED && a.onTouchesCancelled)a.onTouchesCancelled(e,
  2531. d);
  2532. return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : !1
  2533. }, _associateNodeAndEventListener: function (a, b) {
  2534. var c = this._nodeListenersMap[a.__instanceId];
  2535. c || (c = [], this._nodeListenersMap[a.__instanceId] = c);
  2536. c.push(b)
  2537. }, _dissociateNodeAndEventListener: function (a, b) {
  2538. var c = this._nodeListenersMap[a.__instanceId];
  2539. c && (cc.arrayRemoveObject(c, b), 0 === c.length && delete this._nodeListenersMap[a.__instanceId])
  2540. }, _dispatchEventToListeners: function (a, b, c) {
  2541. var d = !1, e = a.getFixedPriorityListeners(), f = a.getSceneGraphPriorityListeners(),
  2542. g = 0, h;
  2543. if (e && 0 !== e.length)for (; g < a.gt0Index; ++g)if (h = e[g], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  2544. d = !0;
  2545. break
  2546. }
  2547. if (f && !d)for (a = 0; a < f.length; a++)if (h = f[a], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  2548. d = !0;
  2549. break
  2550. }
  2551. if (e && !d)for (; g < e.length && !(h = e[g], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)); ++g);
  2552. }, _setDirty: function (a, b) {
  2553. var c = this._priorityDirtyFlagMap;
  2554. c[a] = null == c[a] ? b : b | c[a]
  2555. }, _visitTarget: function (a, b) {
  2556. var c = a.getChildren(), d = 0, e = c.length, f = this._globalZOrderNodeMap,
  2557. g = this._nodeListenersMap;
  2558. if (0 < e) {
  2559. for (var h; d < e; d++)if ((h = c[d]) && 0 > h.getLocalZOrder())this._visitTarget(h, !1); else break;
  2560. null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  2561. for (; d < e; d++)(h = c[d]) && this._visitTarget(h, !1)
  2562. } else null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  2563. if (b) {
  2564. var c = [], k;
  2565. for (k in f)c.push(k);
  2566. c.sort(this._sortNumberAsc);
  2567. k = c.length;
  2568. h = this._nodePriorityMap;
  2569. for (d = 0; d < k; d++) {
  2570. e = f[c[d]];
  2571. for (g = 0; g < e.length; g++)h[e[g]] = ++this._nodePriorityIndex
  2572. }
  2573. this._globalZOrderNodeMap = {}
  2574. }
  2575. }, _sortNumberAsc: function (a, b) {
  2576. return a - b
  2577. }, addListener: function (a, b) {
  2578. cc.assert(a && b, cc._LogInfos.eventManager_addListener_2);
  2579. if (a instanceof cc.EventListener) {
  2580. if (a._isRegistered()) {
  2581. cc.log(cc._LogInfos.eventManager_addListener_4);
  2582. return
  2583. }
  2584. } else cc.assert("number" !== typeof b, cc._LogInfos.eventManager_addListener_3), a = cc.EventListener.create(a);
  2585. a.checkAvailable() && ("number" == typeof b ? 0 == b ? cc.log(cc._LogInfos.eventManager_addListener) :
  2586. (a._setSceneGraphPriority(null), a._setFixedPriority(b), a._setRegistered(!0), a._setPaused(!1), this._addListener(a)) : (a._setSceneGraphPriority(b), a._setFixedPriority(0), a._setRegistered(!0), this._addListener(a)))
  2587. }, addCustomListener: function (a, b) {
  2588. var c = cc._EventListenerCustom.create(a, b);
  2589. this.addListener(c, 1);
  2590. return c
  2591. }, removeListener: function (a) {
  2592. if (null != a) {
  2593. var b, c = this._listenersMap, d;
  2594. for (d in c) {
  2595. var e = c[d], f = e.getFixedPriorityListeners();
  2596. b = e.getSceneGraphPriorityListeners();
  2597. (b = this._removeListenerInVector(b,
  2598. a)) ? this._setDirty(a._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY) : (b = this._removeListenerInVector(f, a)) && this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY);
  2599. e.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete c[d]);
  2600. if (b)break
  2601. }
  2602. if (!b) {
  2603. c = this._toAddedListeners;
  2604. d = 0;
  2605. for (e = c.length; d < e; d++)if (f = c[d], f == a) {
  2606. cc.arrayRemoveObject(c, f);
  2607. break
  2608. }
  2609. }
  2610. }
  2611. }, _removeListenerInVector: function (a, b) {
  2612. if (null == a)return!1;
  2613. for (var c = 0, d = a.length; c < d; c++) {
  2614. var e = a[c];
  2615. if (e == b)return e._setRegistered(!1),
  2616. null != e._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e), e._setSceneGraphPriority(null)), 0 == this._inDispatch && cc.arrayRemoveObject(a, e), !0
  2617. }
  2618. return!1
  2619. }, removeListeners: function (a, b) {
  2620. if (a instanceof cc.Node) {
  2621. delete this._nodePriorityMap[a.__instanceId];
  2622. cc.arrayRemoveObject(this._dirtyNodes, a);
  2623. var c = this._nodeListenersMap[a.__instanceId];
  2624. if (c) {
  2625. for (var d = cc.copyArray(c), c = 0; c < d.length; c++)this.removeListener(d[c]);
  2626. d.length = 0;
  2627. d = this._toAddedListeners;
  2628. for (c = 0; c <
  2629. d.length;) {
  2630. var e = d[c];
  2631. e._getSceneGraphPriority() == a ? (e._setSceneGraphPriority(null), e._setRegistered(!1), d.splice(c, 1)) : ++c
  2632. }
  2633. if (!0 === b) {
  2634. d = a.getChildren();
  2635. c = 0;
  2636. for (e = d.length; c < e; c++)this.removeListeners(d[c], !0)
  2637. }
  2638. }
  2639. } else a == cc.EventListener.TOUCH_ONE_BY_ONE ? this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID) : a == cc.EventListener.TOUCH_ALL_AT_ONCE ? this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID) : a == cc.EventListener.MOUSE ? this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID) :
  2640. a == cc.EventListener.ACCELERATION ? this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID) : a == cc.EventListener.KEYBOARD ? this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID) : cc.log(cc._LogInfos.eventManager_removeListeners)
  2641. }, removeCustomListeners: function (a) {
  2642. this._removeListenersForListenerID(a)
  2643. }, removeAllListeners: function () {
  2644. var a = this._listenersMap, b = this._internalCustomListenerIDs, c;
  2645. for (c in a)-1 === b.indexOf(c) && this._removeListenersForListenerID(c)
  2646. }, setPriority: function (a, b) {
  2647. if (null != a) {
  2648. var c = this._listenersMap, d;
  2649. for (d in c) {
  2650. var e = c[d].getFixedPriorityListeners();
  2651. if (e && -1 != e.indexOf(a)) {
  2652. null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority);
  2653. a._getFixedPriority() !== b && (a._setFixedPriority(b), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY));
  2654. break
  2655. }
  2656. }
  2657. }
  2658. }, setEnabled: function (a) {
  2659. this._isEnabled = a
  2660. }, isEnabled: function () {
  2661. return this._isEnabled
  2662. }, dispatchEvent: function (a) {
  2663. if (this._isEnabled) {
  2664. this._updateDirtyFlagForSceneGraph();
  2665. this._inDispatch++;
  2666. if (!a || !a.getType)throw"event is undefined";
  2667. if (a.getType() == cc.Event.TOUCH)this._dispatchTouchEvent(a); else {
  2668. var b = cc.__getListenerID(a);
  2669. this._sortEventListeners(b);
  2670. b = this._listenersMap[b];
  2671. null != b && this._dispatchEventToListeners(b, this._onListenerCallback, a);
  2672. this._updateListeners(a)
  2673. }
  2674. this._inDispatch--
  2675. }
  2676. }, _onListenerCallback: function (a, b) {
  2677. b._setCurrentTarget(a._getSceneGraphPriority());
  2678. a._onEvent(b);
  2679. return b.isStopped()
  2680. }, dispatchCustomEvent: function (a, b) {
  2681. var c = new cc.EventCustom(a);
  2682. c.setUserData(b);
  2683. this.dispatchEvent(c)
  2684. }};
  2685. cc._tmp.PrototypeCCNode = function () {
  2686. var a = cc.Node.prototype;
  2687. cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX);
  2688. cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY);
  2689. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  2690. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight);
  2691. cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX);
  2692. cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY);
  2693. cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX);
  2694. cc.defineGetterSetter(a, "skewY",
  2695. a.getSkewY, a.setSkewY);
  2696. cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder);
  2697. cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ);
  2698. cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation);
  2699. cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX);
  2700. cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY);
  2701. cc.defineGetterSetter(a, "scale", a.getScale, a.setScale);
  2702. cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX);
  2703. cc.defineGetterSetter(a, "scaleY", a.getScaleY,
  2704. a.setScaleY);
  2705. cc.defineGetterSetter(a, "children", a.getChildren);
  2706. cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount);
  2707. cc.defineGetterSetter(a, "parent", a.getParent, a.setParent);
  2708. cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible);
  2709. cc.defineGetterSetter(a, "running", a.isRunning);
  2710. cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition);
  2711. cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager);
  2712. cc.defineGetterSetter(a, "scheduler",
  2713. a.getScheduler, a.setScheduler);
  2714. cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram);
  2715. cc.defineGetterSetter(a, "glServerState", a.getGLServerState, a.setGLServerState)
  2716. };
  2717. cc._tmp.PrototypeCCNodeRGBA = function () {
  2718. var a = cc.NodeRGBA.prototype;
  2719. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  2720. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  2721. cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
  2722. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  2723. cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
  2724. };
  2725. cc.NODE_TAG_INVALID = -1;
  2726. cc.s_globalOrderOfArrival = 1;
  2727. cc.Node = cc.Class.extend({_localZOrder: 0, _globalZOrder: 0, _vertexZ: 0, _rotationX: 0, _rotationY: 0, _scaleX: 1, _scaleY: 1, _position: null, _skewX: 0, _skewY: 0, _children: null, _visible: !0, _anchorPoint: null, _anchorPointInPoints: null, _contentSize: null, _running: !1, _parent: null, _ignoreAnchorPointForPosition: !1, tag: cc.NODE_TAG_INVALID, userData: null, userObject: null, _transformDirty: !0, _inverseDirty: !0, _cacheDirty: !0, _cachedParent: null, _transformGLDirty: null, _transform: null, _inverse: null, _reorderChildDirty: !1, _shaderProgram: null,
  2728. arrivalOrder: 0, _actionManager: null, _scheduler: null, _eventDispatcher: null, _initializedNode: !1, _additionalTransformDirty: !1, _additionalTransform: null, _componentContainer: null, _isTransitionFinished: !1, _rotationRadiansX: 0, _rotationRadiansY: 0, _className: "Node", _showNode: !1, _name: "", _initNode: function () {
  2729. this._anchorPoint = cc.p(0, 0);
  2730. this._anchorPointInPoints = cc.p(0, 0);
  2731. this._contentSize = cc.size(0, 0);
  2732. this._position = cc.p(0, 0);
  2733. this._children = [];
  2734. this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
  2735. var a = cc.director;
  2736. this._actionManager =
  2737. a.getActionManager();
  2738. this._scheduler = a.getScheduler();
  2739. this._initializedNode = !0;
  2740. this._additionalTransform = cc.AffineTransformMakeIdentity();
  2741. cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this))
  2742. }, init: function () {
  2743. !1 === this._initializedNode && this._initNode();
  2744. return!0
  2745. }, _arrayMakeObjectsPerformSelector: function (a, b) {
  2746. if (a && 0 !== a.length) {
  2747. var c, d = a.length, e;
  2748. c = cc.Node.StateCallbackType;
  2749. switch (b) {
  2750. case c.onEnter:
  2751. for (c = 0; c < d; c++)if (e = a[c])e.onEnter();
  2752. break;
  2753. case c.onExit:
  2754. for (c = 0; c < d; c++)if (e =
  2755. a[c])e.onExit();
  2756. break;
  2757. case c.onEnterTransitionDidFinish:
  2758. for (c = 0; c < d; c++)if (e = a[c])e.onEnterTransitionDidFinish();
  2759. break;
  2760. case c.cleanup:
  2761. for (c = 0; c < d; c++)(e = a[c]) && e.cleanup();
  2762. break;
  2763. case c.updateTransform:
  2764. for (c = 0; c < d; c++)(e = a[c]) && e.updateTransform();
  2765. break;
  2766. case c.onExitTransitionDidStart:
  2767. for (c = 0; c < d; c++)if (e = a[c])e.onExitTransitionDidStart();
  2768. break;
  2769. case c.sortAllChildren:
  2770. for (c = 0; c < d; c++)(e = a[c]) && e.sortAllChildren();
  2771. break;
  2772. default:
  2773. cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector)
  2774. }
  2775. }
  2776. }, setNodeDirty: null,
  2777. attr: function (a) {
  2778. for (var b in a)this[b] = a[b]
  2779. }, getSkewX: function () {
  2780. return this._skewX
  2781. }, setSkewX: function (a) {
  2782. this._skewX = a;
  2783. this.setNodeDirty()
  2784. }, getSkewY: function () {
  2785. return this._skewY
  2786. }, setSkewY: function (a) {
  2787. this._skewY = a;
  2788. this.setNodeDirty()
  2789. }, setLocalZOrder: function (a) {
  2790. this._localZOrder = a;
  2791. this._parent && this._parent.reorderChild(this, a);
  2792. cc.eventManager._setDirtyForNode(this)
  2793. }, _setLocalZOrder: function (a) {
  2794. this._localZOrder = a
  2795. }, getLocalZOrder: function () {
  2796. return this._localZOrder
  2797. }, getZOrder: function () {
  2798. cc.log(cc._LogInfos.Node_getZOrder);
  2799. return this.getLocalZOrder()
  2800. }, setZOrder: function (a) {
  2801. cc.log(cc._LogInfos.Node_setZOrder);
  2802. this.setLocalZOrder(a)
  2803. }, setGlobalZOrder: function (a) {
  2804. this._globalZOrder != a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this))
  2805. }, getGlobalZOrder: function () {
  2806. return this._globalZOrder
  2807. }, getVertexZ: function () {
  2808. return this._vertexZ
  2809. }, setVertexZ: function (a) {
  2810. this._vertexZ = a
  2811. }, getRotation: function () {
  2812. this._rotationX !== this._rotationY && cc.log(cc._LogInfos.Node_getRotation);
  2813. return this._rotationX
  2814. }, setRotation: function (a) {
  2815. this._rotationX =
  2816. this._rotationY = a;
  2817. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  2818. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  2819. this.setNodeDirty()
  2820. }, getRotationX: function () {
  2821. return this._rotationX
  2822. }, setRotationX: function (a) {
  2823. this._rotationX = a;
  2824. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  2825. this.setNodeDirty()
  2826. }, getRotationY: function () {
  2827. return this._rotationY
  2828. }, setRotationY: function (a) {
  2829. this._rotationY = a;
  2830. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  2831. this.setNodeDirty()
  2832. },
  2833. getScale: function () {
  2834. this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale);
  2835. return this._scaleX
  2836. }, setScale: function (a, b) {
  2837. this._scaleX = a;
  2838. this._scaleY = b || 0 === b ? b : a;
  2839. this.setNodeDirty()
  2840. }, getScaleX: function () {
  2841. return this._scaleX
  2842. }, setScaleX: function (a) {
  2843. this._scaleX = a;
  2844. this.setNodeDirty()
  2845. }, getScaleY: function () {
  2846. return this._scaleY
  2847. }, setScaleY: function (a) {
  2848. this._scaleY = a;
  2849. this.setNodeDirty()
  2850. }, setPosition: function (a, b) {
  2851. var c = this._position;
  2852. void 0 === b ? (c.x = a.x, c.y = a.y) : (c.x = a, c.y = b);
  2853. this.setNodeDirty()
  2854. },
  2855. getPosition: function () {
  2856. return cc.p(this._position)
  2857. }, getPositionX: function () {
  2858. return this._position.x
  2859. }, setPositionX: function (a) {
  2860. this._position.x = a;
  2861. this.setNodeDirty()
  2862. }, getPositionY: function () {
  2863. return this._position.y
  2864. }, setPositionY: function (a) {
  2865. this._position.y = a;
  2866. this.setNodeDirty()
  2867. }, getChildrenCount: function () {
  2868. return this._children.length
  2869. }, getChildren: function () {
  2870. return this._children
  2871. }, isVisible: function () {
  2872. return this._visible
  2873. }, setVisible: function (a) {
  2874. this._visible = a;
  2875. this.setNodeDirty()
  2876. }, getAnchorPoint: function () {
  2877. return this._anchorPoint
  2878. },
  2879. setAnchorPoint: function (a, b) {
  2880. var c = this._anchorPoint;
  2881. if (void 0 === b) {
  2882. if (a.x === c.x && a.y === c.y)return;
  2883. c.x = a.x;
  2884. c.y = a.y
  2885. } else {
  2886. if (a === c.x && b === c.y)return;
  2887. c.x = a;
  2888. c.y = b
  2889. }
  2890. var d = this._anchorPointInPoints, e = this._contentSize;
  2891. d.x = e.width * c.x;
  2892. d.y = e.height * c.y;
  2893. this.setNodeDirty()
  2894. }, _getAnchor: function () {
  2895. return this._anchorPoint
  2896. }, _setAnchor: function (a) {
  2897. var b = a.x;
  2898. a = a.y;
  2899. this._anchorPoint.x !== b && (this._anchorPoint.x = b, this._anchorPointInPoints.x = this._contentSize.width * b);
  2900. this._anchorPoint.y !== a && (this._anchorPoint.y =
  2901. a, this._anchorPointInPoints.y = this._contentSize.height * a);
  2902. this.setNodeDirty()
  2903. }, _getAnchorX: function () {
  2904. return this._anchorPoint.x
  2905. }, _setAnchorX: function (a) {
  2906. this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._anchorPointInPoints.x = this._contentSize.width * a, this.setNodeDirty())
  2907. }, _getAnchorY: function () {
  2908. return this._anchorPoint.y
  2909. }, _setAnchorY: function (a) {
  2910. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a, this.setNodeDirty())
  2911. }, getAnchorPointInPoints: function () {
  2912. return this._anchorPointInPoints
  2913. },
  2914. _getWidth: function () {
  2915. return this._contentSize.width
  2916. }, _setWidth: function (a) {
  2917. this._contentSize.width = a;
  2918. this._anchorPointInPoints.x = a * this._anchorPoint.x;
  2919. this.setNodeDirty()
  2920. }, _getHeight: function () {
  2921. return this._contentSize.height
  2922. }, _setHeight: function (a) {
  2923. this._contentSize.height = a;
  2924. this._anchorPointInPoints.y = a * this._anchorPoint.y;
  2925. this.setNodeDirty()
  2926. }, getContentSize: function () {
  2927. return this._contentSize
  2928. }, setContentSize: function (a, b) {
  2929. var c = this._contentSize;
  2930. if (void 0 === b) {
  2931. if (a.width === c.width && a.height ===
  2932. c.height)return;
  2933. c.width = a.width;
  2934. c.height = a.height
  2935. } else {
  2936. if (a === c.width && b === c.height)return;
  2937. c.width = a;
  2938. c.height = b
  2939. }
  2940. var d = this._anchorPointInPoints, e = this._anchorPoint;
  2941. d.x = c.width * e.x;
  2942. d.y = c.height * e.y;
  2943. this.setNodeDirty()
  2944. }, isRunning: function () {
  2945. return this._running
  2946. }, getParent: function () {
  2947. return this._parent
  2948. }, setParent: function (a) {
  2949. this._parent = a
  2950. }, isIgnoreAnchorPointForPosition: function () {
  2951. return this._ignoreAnchorPointForPosition
  2952. }, ignoreAnchorPointForPosition: function (a) {
  2953. a != this._ignoreAnchorPointForPosition &&
  2954. (this._ignoreAnchorPointForPosition = a, this.setNodeDirty())
  2955. }, getTag: function () {
  2956. return this.tag
  2957. }, setTag: function (a) {
  2958. this.tag = a
  2959. }, setName: function (a) {
  2960. this._name
  2961. }, getName: function () {
  2962. return this._name
  2963. }, getUserData: function () {
  2964. return this.userData
  2965. }, setUserData: function (a) {
  2966. this.userData = a
  2967. }, getUserObject: function () {
  2968. return this.userObject
  2969. }, setUserObject: function (a) {
  2970. this.userObject != a && (this.userObject = a)
  2971. }, getOrderOfArrival: function () {
  2972. return this.arrivalOrder
  2973. }, setOrderOfArrival: function (a) {
  2974. this.arrivalOrder =
  2975. a
  2976. }, getActionManager: function () {
  2977. this._actionManager || (this._actionManager = cc.director.getActionManager());
  2978. return this._actionManager
  2979. }, setActionManager: function (a) {
  2980. this._actionManager != a && (this.stopAllActions(), this._actionManager = a)
  2981. }, getScheduler: function () {
  2982. this._scheduler || (this._scheduler = cc.director.getScheduler());
  2983. return this._scheduler
  2984. }, setScheduler: function (a) {
  2985. this._scheduler != a && (this.unscheduleAllCallbacks(), this._scheduler = a)
  2986. }, getBoundingBox: function () {
  2987. var a = cc.rect(0, 0, this._contentSize.width,
  2988. this._contentSize.height);
  2989. return cc._RectApplyAffineTransformIn(a, this.nodeToParentTransform())
  2990. }, cleanup: function () {
  2991. this.stopAllActions();
  2992. this.unscheduleAllCallbacks();
  2993. cc.eventManager.removeListeners(this);
  2994. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup)
  2995. }, getChildByTag: function (a) {
  2996. var b = this._children;
  2997. if (null != b)for (var c = 0; c < b.length; c++) {
  2998. var d = b[c];
  2999. if (d && d.tag == a)return d
  3000. }
  3001. return null
  3002. }, getChildByName: function (a) {
  3003. if (!a)return cc.log("Invalid name"), null;
  3004. for (var b =
  3005. this._children, c = 0, d = b.length; c < d; c++)if (b[c]._name == a)return b[c];
  3006. return null
  3007. }, addChild: function (a, b, c) {
  3008. cc.assert(a, cc._LogInfos.Node_addChild_3);
  3009. if (a === this)cc.log(cc._LogInfos.Node_addChild); else if (null !== a._parent)cc.log(cc._LogInfos.Node_addChild_2); else if (b = null != b ? b : a._localZOrder, a.tag = null != c ? c : a.tag, this._insertChild(a, b), a._parent = this, this._cachedParent && (a._cachedParent = this._cachedParent), this._running && (a.onEnter(), this._isTransitionFinished))a.onEnterTransitionDidFinish()
  3010. }, removeFromParent: function (a) {
  3011. this._parent &&
  3012. (null == a && (a = !0), this._parent.removeChild(this, a))
  3013. }, removeFromParentAndCleanup: function (a) {
  3014. cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
  3015. this.removeFromParent(a)
  3016. }, removeChild: function (a, b) {
  3017. 0 !== this._children.length && (null == b && (b = !0), -1 < this._children.indexOf(a) && this._detachChild(a, b), this.setNodeDirty())
  3018. }, removeChildByTag: function (a, b) {
  3019. a === cc.NODE_TAG_INVALID && cc.log(cc._LogInfos.Node_removeChildByTag);
  3020. var c = this.getChildByTag(a);
  3021. null == c ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(c,
  3022. b)
  3023. }, removeAllChildrenWithCleanup: function (a) {
  3024. cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup);
  3025. this.removeAllChildren(a)
  3026. }, removeAllChildren: function (a) {
  3027. var b = this._children;
  3028. if (null != b) {
  3029. null == a && (a = !0);
  3030. for (var c = 0; c < b.length; c++) {
  3031. var d = b[c];
  3032. d && (this._running && (d.onExitTransitionDidStart(), d.onExit()), a && d.cleanup(), d.parent = null)
  3033. }
  3034. this._children.length = 0
  3035. }
  3036. }, _detachChild: function (a, b) {
  3037. this._running && (a.onExitTransitionDidStart(), a.onExit());
  3038. b && a.cleanup();
  3039. a.parent = null;
  3040. cc.arrayRemoveObject(this._children,
  3041. a)
  3042. }, _insertChild: function (a, b) {
  3043. this._reorderChildDirty = !0;
  3044. this._children.push(a);
  3045. a._setLocalZOrder(b)
  3046. }, reorderChild: function (a, b) {
  3047. cc.assert(a, cc._LogInfos.Node_reorderChild);
  3048. this._reorderChildDirty = !0;
  3049. a.arrivalOrder = cc.s_globalOrderOfArrival;
  3050. cc.s_globalOrderOfArrival++;
  3051. a._setLocalZOrder(b);
  3052. this.setNodeDirty()
  3053. }, sortAllChildren: function () {
  3054. if (this._reorderChildDirty) {
  3055. var a = this._children, b = a.length, c, d, e;
  3056. for (c = 1; c < b; c++) {
  3057. e = a[c];
  3058. for (d = c - 1; 0 <= d;) {
  3059. if (e._localZOrder < a[d]._localZOrder)a[d + 1] = a[d]; else if (e._localZOrder ===
  3060. a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder)a[d + 1] = a[d]; else break;
  3061. d--
  3062. }
  3063. a[d + 1] = e
  3064. }
  3065. this._reorderChildDirty = !1
  3066. }
  3067. }, draw: function (a) {
  3068. }, transformAncestors: function () {
  3069. null != this._parent && (this._parent.transformAncestors(), this._parent.transform())
  3070. }, onEnter: function () {
  3071. this._isTransitionFinished = !1;
  3072. this._running = !0;
  3073. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter);
  3074. this.resume()
  3075. }, onEnterTransitionDidFinish: function () {
  3076. this._isTransitionFinished = !0;
  3077. this._arrayMakeObjectsPerformSelector(this._children,
  3078. cc.Node.StateCallbackType.onEnterTransitionDidFinish)
  3079. }, onExitTransitionDidStart: function () {
  3080. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExitTransitionDidStart)
  3081. }, onExit: function () {
  3082. this._running = !1;
  3083. this.pause();
  3084. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit);
  3085. this._componentContainer && this._componentContainer.removeAll()
  3086. }, runAction: function (a) {
  3087. cc.assert(a, cc._LogInfos.Node_runAction);
  3088. this.actionManager.addAction(a, this, !this._running);
  3089. return a
  3090. }, stopAllActions: function () {
  3091. this.actionManager && this.actionManager.removeAllActionsFromTarget(this)
  3092. }, stopAction: function (a) {
  3093. this.actionManager.removeAction(a)
  3094. }, stopActionByTag: function (a) {
  3095. a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) : this.actionManager.removeActionByTag(a, this)
  3096. }, getActionByTag: function (a) {
  3097. return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this)
  3098. }, getNumberOfRunningActions: function () {
  3099. return this.actionManager.numberOfRunningActionsInTarget(this)
  3100. },
  3101. scheduleUpdate: function () {
  3102. this.scheduleUpdateWithPriority(0)
  3103. }, scheduleUpdateWithPriority: function (a) {
  3104. this.scheduler.scheduleUpdateForTarget(this, a, !this._running)
  3105. }, unscheduleUpdate: function () {
  3106. this.scheduler.unscheduleUpdateForTarget(this)
  3107. }, schedule: function (a, b, c, d) {
  3108. b = b || 0;
  3109. cc.assert(a, cc._LogInfos.Node_schedule);
  3110. cc.assert(0 <= b, cc._LogInfos.Node_schedule_2);
  3111. c = null == c ? cc.REPEAT_FOREVER : c;
  3112. this.scheduler.scheduleCallbackForTarget(this, a, b, c, d || 0, !this._running)
  3113. }, scheduleOnce: function (a, b) {
  3114. this.schedule(a,
  3115. 0, 0, b)
  3116. }, unschedule: function (a) {
  3117. a && this.scheduler.unscheduleCallbackForTarget(this, a)
  3118. }, unscheduleAllCallbacks: function () {
  3119. this.scheduler.unscheduleAllCallbacksForTarget(this)
  3120. }, resumeSchedulerAndActions: function () {
  3121. cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);
  3122. this.resume()
  3123. }, resume: function () {
  3124. this.scheduler.resumeTarget(this);
  3125. this.actionManager && this.actionManager.resumeTarget(this);
  3126. cc.eventManager.resumeTarget(this)
  3127. }, pauseSchedulerAndActions: function () {
  3128. cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
  3129. this.pause()
  3130. }, pause: function () {
  3131. this.scheduler.pauseTarget(this);
  3132. this.actionManager && this.actionManager.pauseTarget(this);
  3133. cc.eventManager.pauseTarget(this)
  3134. }, setAdditionalTransform: function (a) {
  3135. this._additionalTransform = a;
  3136. this._additionalTransformDirty = this._transformDirty = !0
  3137. }, parentToNodeTransform: function () {
  3138. this._inverseDirty && (this._inverse = cc.AffineTransformInvert(this.nodeToParentTransform()), this._inverseDirty = !1);
  3139. return this._inverse
  3140. }, nodeToWorldTransform: function () {
  3141. for (var a = this.nodeToParentTransform(),
  3142. b = this._parent; null != b; b = b.parent)a = cc.AffineTransformConcat(a, b.nodeToParentTransform());
  3143. return a
  3144. }, worldToNodeTransform: function () {
  3145. return cc.AffineTransformInvert(this.nodeToWorldTransform())
  3146. }, convertToNodeSpace: function (a) {
  3147. return cc.PointApplyAffineTransform(a, this.worldToNodeTransform())
  3148. }, convertToWorldSpace: function (a) {
  3149. a = a || cc.p(0, 0);
  3150. return cc.PointApplyAffineTransform(a, this.nodeToWorldTransform())
  3151. }, convertToNodeSpaceAR: function (a) {
  3152. return cc.pSub(this.convertToNodeSpace(a), this._anchorPointInPoints)
  3153. },
  3154. convertToWorldSpaceAR: function (a) {
  3155. a = a || cc.p(0, 0);
  3156. a = cc.pAdd(a, this._anchorPointInPoints);
  3157. return this.convertToWorldSpace(a)
  3158. }, _convertToWindowSpace: function (a) {
  3159. a = this.convertToWorldSpace(a);
  3160. return cc.director.convertToUI(a)
  3161. }, convertTouchToNodeSpace: function (a) {
  3162. a = a.getLocation();
  3163. return this.convertToNodeSpace(a)
  3164. }, convertTouchToNodeSpaceAR: function (a) {
  3165. a = a.getLocation();
  3166. a = cc.director.convertToGL(a);
  3167. return this.convertToNodeSpaceAR(a)
  3168. }, update: function (a) {
  3169. this._componentContainer && !this._componentContainer.isEmpty() &&
  3170. this._componentContainer.visit(a)
  3171. }, updateTransform: function () {
  3172. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
  3173. }, retain: function () {
  3174. }, release: function () {
  3175. }, getComponent: function (a) {
  3176. return this._componentContainer.getComponent(a)
  3177. }, addComponent: function (a) {
  3178. this._componentContainer.add(a)
  3179. }, removeComponent: function (a) {
  3180. return this._componentContainer.remove(a)
  3181. }, removeAllComponents: function () {
  3182. this._componentContainer.removeAll()
  3183. }, grid: null, ctor: null, visit: null,
  3184. transform: null, nodeToParentTransform: null, _setNodeDirtyForCache: function () {
  3185. if (!1 === this._cacheDirty) {
  3186. this._cacheDirty = !0;
  3187. var a = this._cachedParent;
  3188. a && a != this && a._setNodeDirtyForCache()
  3189. }
  3190. }, _setCachedParent: function (a) {
  3191. if (this._cachedParent != a) {
  3192. this._cachedParent = a;
  3193. for (var b = this._children, c = 0, d = b.length; c < d; c++)b[c]._setCachedParent(a)
  3194. }
  3195. }, getCamera: function () {
  3196. this._camera || (this._camera = new cc.Camera);
  3197. return this._camera
  3198. }, getGrid: function () {
  3199. return this.grid
  3200. }, setGrid: function (a) {
  3201. this.grid = a
  3202. }, getShaderProgram: function () {
  3203. return this._shaderProgram
  3204. },
  3205. setShaderProgram: function (a) {
  3206. this._shaderProgram = a
  3207. }, getGLServerState: function () {
  3208. return this._glServerState
  3209. }, setGLServerState: function (a) {
  3210. this._glServerState = a
  3211. }, getBoundingBoxToWorld: function () {
  3212. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height), b = this.nodeToWorldTransform(), a = cc.RectApplyAffineTransform(a, this.nodeToWorldTransform());
  3213. if (!this._children)return a;
  3214. for (var c = this._children, d = 0; d < c.length; d++) {
  3215. var e = c[d];
  3216. e && e._visible && (e = e._getBoundingBoxToCurrentNode(b)) && (a = cc.rectUnion(a,
  3217. e))
  3218. }
  3219. return a
  3220. }, _getBoundingBoxToCurrentNode: function (a) {
  3221. var b = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  3222. a = null == a ? this.nodeToParentTransform() : cc.AffineTransformConcat(this.nodeToParentTransform(), a);
  3223. b = cc.RectApplyAffineTransform(b, a);
  3224. if (!this._children)return b;
  3225. for (var c = this._children, d = 0; d < c.length; d++) {
  3226. var e = c[d];
  3227. e && e._visible && (e = e._getBoundingBoxToCurrentNode(a)) && (b = cc.rectUnion(b, e))
  3228. }
  3229. return b
  3230. }, _nodeToParentTransformForWebGL: function () {
  3231. if (this._transformDirty) {
  3232. var a = this._position.x,
  3233. b = this._position.y, c = this._anchorPointInPoints.x, d = -c, e = this._anchorPointInPoints.y, f = -e, g = this._scaleX, h = this._scaleY;
  3234. this._ignoreAnchorPointForPosition && (a += c, b += e);
  3235. var k = 1, l = 0, m = 1, n = 0;
  3236. if (0 !== this._rotationX || 0 !== this._rotationY)k = Math.cos(-this._rotationRadiansX), l = Math.sin(-this._rotationRadiansX), m = Math.cos(-this._rotationRadiansY), n = Math.sin(-this._rotationRadiansY);
  3237. var q = this._skewX || this._skewY;
  3238. if (!q && (0 !== c || 0 !== e))a += m * d * g + -l * f * h, b += n * d * g + k * f * h;
  3239. var r = this._transform;
  3240. r.a = m * g;
  3241. r.b = n * g;
  3242. r.c =
  3243. -l * h;
  3244. r.d = k * h;
  3245. r.tx = a;
  3246. r.ty = b;
  3247. if (q && (r = cc.AffineTransformConcat({a: 1, b: Math.tan(cc.degreesToRadians(this._skewY)), c: Math.tan(cc.degreesToRadians(this._skewX)), d: 1, tx: 0, ty: 0}, r), 0 !== c || 0 !== e))r = cc.AffineTransformTranslate(r, d, f);
  3248. this._additionalTransformDirty && (r = cc.AffineTransformConcat(r, this._additionalTransform), this._additionalTransformDirty = !1);
  3249. this._transform = r;
  3250. this._transformDirty = !1
  3251. }
  3252. return this._transform
  3253. }});
  3254. cc.Node.create = function () {
  3255. return new cc.Node
  3256. };
  3257. cc.Node.StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7};
  3258. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  3259. var _p = cc.Node.prototype;
  3260. _p.ctor = function () {
  3261. this._initNode()
  3262. };
  3263. _p.setNodeDirty = function () {
  3264. this._setNodeDirtyForCache();
  3265. !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
  3266. };
  3267. _p.visit = function (a) {
  3268. if (this._visible) {
  3269. a = a || cc._renderContext;
  3270. var b, c = this._children, d;
  3271. a.save();
  3272. this.transform(a);
  3273. var e = c.length;
  3274. if (0 < e) {
  3275. this.sortAllChildren();
  3276. for (b = 0; b < e; b++)if (d = c[b], 0 > d._localZOrder)d.visit(a); else break;
  3277. for (this.draw(a); b < e; b++)c[b].visit(a)
  3278. } else this.draw(a);
  3279. this._cacheDirty = !1;
  3280. this.arrivalOrder = 0;
  3281. a.restore()
  3282. }
  3283. };
  3284. _p.transform = function (a) {
  3285. a = a || cc._renderContext;
  3286. var b = cc.view, c = this.nodeToParentTransform();
  3287. a.transform(c.a, c.c, c.b, c.d, c.tx * b.getScaleX(), -c.ty * b.getScaleY())
  3288. };
  3289. _p.nodeToParentTransform = function () {
  3290. if (this._transformDirty) {
  3291. var a = this._transform;
  3292. a.tx = this._position.x;
  3293. a.ty = this._position.y;
  3294. var b = 1, c = 0;
  3295. this._rotationX && (b = Math.cos(this._rotationRadiansX), c = Math.sin(this._rotationRadiansX));
  3296. a.a = a.d = b;
  3297. a.b = -c;
  3298. a.c = c;
  3299. var d = this._scaleX, e = this._scaleY,
  3300. f = this._anchorPointInPoints.x, g = this._anchorPointInPoints.y, h = 1E-6 > d && -1E-6 < d ? 1E-6 : d, k = 1E-6 > e && -1E-6 < e ? 1E-6 : e;
  3301. if (this._skewX || this._skewY) {
  3302. var l = Math.tan(-this._skewX * Math.PI / 180), m = Math.tan(-this._skewY * Math.PI / 180);
  3303. Infinity === l && (l = 99999999);
  3304. Infinity === m && (m = 99999999);
  3305. var n = g * l * h, q = f * m * k;
  3306. a.a = b + -c * m;
  3307. a.b = b * l + -c;
  3308. a.c = c + b * m;
  3309. a.d = c * l + b;
  3310. a.tx += b * n + -c * q;
  3311. a.ty += c * n + b * q
  3312. }
  3313. if (1 !== d || 1 !== e)a.a *= h, a.c *= h, a.b *= k, a.d *= k;
  3314. a.tx += b * -f * h + -c * g * k;
  3315. a.ty -= c * -f * h + b * g * k;
  3316. this._ignoreAnchorPointForPosition && (a.tx += f, a.ty += g);
  3317. this._additionalTransformDirty &&
  3318. (this._transform = cc.AffineTransformConcat(a, this._additionalTransform), this._additionalTransformDirty = !1);
  3319. this._transformDirty = !1
  3320. }
  3321. return this._transform
  3322. };
  3323. _p = null
  3324. } else cc.assert("function" === typeof cc._tmp.WebGLCCNode, cc._LogInfos.MissingFile, "BaseNodesWebGL.js"), cc._tmp.WebGLCCNode(), delete cc._tmp.WebGLCCNode;
  3325. cc.assert("function" === typeof cc._tmp.PrototypeCCNode, cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
  3326. cc._tmp.PrototypeCCNode();
  3327. delete cc._tmp.PrototypeCCNode;
  3328. cc.NodeRGBA = cc.Node.extend({RGBAProtocol: !0, _displayedOpacity: 255, _realOpacity: 255, _displayedColor: null, _realColor: null, _cascadeColorEnabled: !1, _cascadeOpacityEnabled: !1, ctor: function () {
  3329. cc.Node.prototype.ctor.call(this);
  3330. this._realOpacity = this._displayedOpacity = 255;
  3331. this._displayedColor = cc.color(255, 255, 255, 255);
  3332. this._realColor = cc.color(255, 255, 255, 255);
  3333. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1
  3334. }, _updateColor: function () {
  3335. }, getOpacity: function () {
  3336. return this._realOpacity
  3337. }, getDisplayedOpacity: function () {
  3338. return this._displayedOpacity
  3339. },
  3340. setOpacity: function (a) {
  3341. this._displayedOpacity = this._realOpacity = a;
  3342. var b = 255, c = this._parent;
  3343. c && (c.RGBAProtocol && c.cascadeOpacity) && (b = c.getDisplayedOpacity());
  3344. this.updateDisplayedOpacity(b);
  3345. this._displayedColor.a = this._realColor.a = a
  3346. }, updateDisplayedOpacity: function (a) {
  3347. this._displayedOpacity = this._realOpacity * a / 255;
  3348. if (this._cascadeOpacityEnabled) {
  3349. a = this._children;
  3350. for (var b = 0; b < a.length; b++) {
  3351. var c = a[b];
  3352. c && c.RGBAProtocol && c.updateDisplayedOpacity(this._displayedOpacity)
  3353. }
  3354. }
  3355. }, isCascadeOpacityEnabled: function () {
  3356. return this._cascadeOpacityEnabled
  3357. },
  3358. setCascadeOpacityEnabled: function (a) {
  3359. this._cascadeOpacityEnabled !== a && ((this._cascadeOpacityEnabled = a) ? this._enableCascadeOpacity() : this._disableCascadeOpacity())
  3360. }, _enableCascadeOpacity: function () {
  3361. var a = 255, b = this._parent;
  3362. b && (b.RGBAProtocol && b.cascadeOpacity) && (a = b.getDisplayedOpacity());
  3363. this.updateDisplayedOpacity(a)
  3364. }, _disableCascadeOpacity: function () {
  3365. this._displayedOpacity = this._realOpacity;
  3366. for (var a = this._children, b = 0; b < a.length; b++) {
  3367. var c = a[b];
  3368. c && c.RGBAProtocol && c.updateDisplayedOpacity(255)
  3369. }
  3370. },
  3371. getColor: function () {
  3372. var a = this._realColor;
  3373. return cc.color(a.r, a.g, a.b, a.a)
  3374. }, getDisplayedColor: function () {
  3375. var a = this._displayedColor;
  3376. return cc.color(a.r, a.g, a.b, a.a)
  3377. }, setColor: function (a) {
  3378. var b = this._displayedColor, c = this._realColor;
  3379. b.r = c.r = a.r;
  3380. b.g = c.g = a.g;
  3381. b.b = c.b = a.b;
  3382. b = (b = this._parent) && b.RGBAProtocol && b.cascadeColor ? b.getDisplayedColor() : cc.color.WHITE;
  3383. this.updateDisplayedColor(b);
  3384. void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
  3385. }, updateDisplayedColor: function (a) {
  3386. var b = this._displayedColor, c = this._realColor;
  3387. b.r = 0 | c.r * a.r / 255;
  3388. b.g = 0 | c.g * a.g / 255;
  3389. b.b = 0 | c.b * a.b / 255;
  3390. if (this._cascadeColorEnabled) {
  3391. a = this._children;
  3392. for (c = 0; c < a.length; c++) {
  3393. var d = a[c];
  3394. d && d.RGBAProtocol && d.updateDisplayedColor(b)
  3395. }
  3396. }
  3397. }, isCascadeColorEnabled: function () {
  3398. return this._cascadeColorEnabled
  3399. }, setCascadeColorEnabled: function (a) {
  3400. this._cascadeColorEnabled !== a && ((this._cascadeColorEnabled = a) ? this._enableCascadeColor() : this._disableCascadeColor())
  3401. }, _enableCascadeColor: function () {
  3402. var a;
  3403. a = (a = this._parent) && a.RGBAProtocol && a.cascadeColor ? a.getDisplayedColor() :
  3404. cc.color.WHITE;
  3405. this.updateDisplayedColor(a)
  3406. }, _disableCascadeColor: function () {
  3407. var a = this._displayedColor, b = this._realColor;
  3408. a.r = b.r;
  3409. a.g = b.g;
  3410. a.b = b.b;
  3411. for (var a = this._children, b = cc.color.WHITE, c = 0; c < a.length; c++) {
  3412. var d = a[c];
  3413. d && d.RGBAProtocol && d.updateDisplayedColor(b)
  3414. }
  3415. }, addChild: function (a, b, c) {
  3416. cc.Node.prototype.addChild.call(this, a, b, c);
  3417. this._cascadeColorEnabled && this._enableCascadeColor();
  3418. this._cascadeOpacityEnabled && this._enableCascadeOpacity()
  3419. }, setOpacityModifyRGB: function (a) {
  3420. }, isOpacityModifyRGB: function () {
  3421. return!1
  3422. }});
  3423. cc.NodeRGBA.create = function () {
  3424. var a = new cc.NodeRGBA;
  3425. a.init();
  3426. return a
  3427. };
  3428. cc.assert("function" === typeof cc._tmp.PrototypeCCNodeRGBA, cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
  3429. cc._tmp.PrototypeCCNodeRGBA();
  3430. delete cc._tmp.PrototypeCCNodeRGBA;
  3431. cc.Node.ON_ENTER = 0;
  3432. cc.Node.ON_EXIT = 1;
  3433. cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
  3434. cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
  3435. cc.Node.ON_CLEAN_UP = 4;
  3436. cc._tmp.PrototypeTexture2D = function () {
  3437. var a = cc.Texture2D;
  3438. a.PVRImagesHavePremultipliedAlpha = function (a) {
  3439. cc.PVRHaveAlphaPremultiplied_ = a
  3440. };
  3441. a.PIXEL_FORMAT_RGBA8888 = 2;
  3442. a.PIXEL_FORMAT_RGB888 = 3;
  3443. a.PIXEL_FORMAT_RGB565 = 4;
  3444. a.PIXEL_FORMAT_A8 = 5;
  3445. a.PIXEL_FORMAT_I8 = 6;
  3446. a.PIXEL_FORMAT_AI88 = 7;
  3447. a.PIXEL_FORMAT_RGBA4444 = 8;
  3448. a.PIXEL_FORMAT_RGB5A1 = 7;
  3449. a.PIXEL_FORMAT_PVRTC4 = 9;
  3450. a.PIXEL_FORMAT_PVRTC2 = 10;
  3451. a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888;
  3452. var b = cc.Texture2D._M = {};
  3453. b[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888";
  3454. b[a.PIXEL_FORMAT_RGB888] =
  3455. "RGB888";
  3456. b[a.PIXEL_FORMAT_RGB565] = "RGB565";
  3457. b[a.PIXEL_FORMAT_A8] = "A8";
  3458. b[a.PIXEL_FORMAT_I8] = "I8";
  3459. b[a.PIXEL_FORMAT_AI88] = "AI88";
  3460. b[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444";
  3461. b[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1";
  3462. b[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4";
  3463. b[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2";
  3464. b = cc.Texture2D._B = {};
  3465. b[a.PIXEL_FORMAT_RGBA8888] = 32;
  3466. b[a.PIXEL_FORMAT_RGB888] = 24;
  3467. b[a.PIXEL_FORMAT_RGB565] = 16;
  3468. b[a.PIXEL_FORMAT_A8] = 8;
  3469. b[a.PIXEL_FORMAT_I8] = 8;
  3470. b[a.PIXEL_FORMAT_AI88] = 16;
  3471. b[a.PIXEL_FORMAT_RGBA4444] = 16;
  3472. b[a.PIXEL_FORMAT_RGB5A1] = 16;
  3473. b[a.PIXEL_FORMAT_PVRTC4] = 4;
  3474. b[a.PIXEL_FORMAT_PVRTC2] = 3;
  3475. b = cc.Texture2D.prototype;
  3476. cc.defineGetterSetter(b, "name", b.getName);
  3477. cc.defineGetterSetter(b, "pixelFormat", b.getPixelFormat);
  3478. cc.defineGetterSetter(b, "pixelsWidth", b.getPixelsWide);
  3479. cc.defineGetterSetter(b, "pixelsHeight", b.getPixelsHigh);
  3480. cc.defineGetterSetter(b, "width", b._getWidth);
  3481. cc.defineGetterSetter(b, "height", b._getHeight);
  3482. a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT
  3483. };
  3484. cc._tmp.PrototypeTextureAtlas = function () {
  3485. var a = cc.TextureAtlas.prototype;
  3486. cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads);
  3487. cc.defineGetterSetter(a, "capacity", a.getCapacity);
  3488. cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads)
  3489. };
  3490. cc.ALIGN_CENTER = 51;
  3491. cc.ALIGN_TOP = 19;
  3492. cc.ALIGN_TOP_RIGHT = 18;
  3493. cc.ALIGN_RIGHT = 50;
  3494. cc.ALIGN_BOTTOM_RIGHT = 34;
  3495. cc.ALIGN_BOTTOM = 35;
  3496. cc.ALIGN_BOTTOM_LEFT = 33;
  3497. cc.ALIGN_LEFT = 49;
  3498. cc.ALIGN_TOP_LEFT = 17;
  3499. cc.PVRHaveAlphaPremultiplied_ = !1;
  3500. cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.Texture2D = cc.Class.extend({_contentSize: null, _isLoaded: !1, _htmlElementObj: null, _loadedEventListeners: null, url: null, ctor: function () {
  3501. this._contentSize = cc.size(0, 0);
  3502. this._isLoaded = !1;
  3503. this._htmlElementObj = null
  3504. }, getPixelsWide: function () {
  3505. return this._contentSize.width
  3506. }, getPixelsHigh: function () {
  3507. return this._contentSize.height
  3508. }, getContentSize: function () {
  3509. var a = cc.contentScaleFactor();
  3510. return cc.size(this._contentSize.width / a, this._contentSize.height / a)
  3511. }, _getWidth: function () {
  3512. return this._contentSize.width /
  3513. cc.contentScaleFactor()
  3514. }, _getHeight: function () {
  3515. return this._contentSize.height / cc.contentScaleFactor()
  3516. }, getContentSizeInPixels: function () {
  3517. return this._contentSize
  3518. }, initWithElement: function (a) {
  3519. a && (this._htmlElementObj = a)
  3520. }, getHtmlElementObj: function () {
  3521. return this._htmlElementObj
  3522. }, isLoaded: function () {
  3523. return this._isLoaded
  3524. }, handleLoadedTexture: function () {
  3525. if (!this._isLoaded) {
  3526. if (!this._htmlElementObj) {
  3527. var a = cc.loader.getRes(this.url);
  3528. if (!a)return;
  3529. this.initWithElement(a)
  3530. }
  3531. this._isLoaded = !0;
  3532. a = this._htmlElementObj;
  3533. this._contentSize.width = a.width;
  3534. this._contentSize.height = a.height;
  3535. this._callLoadedEventCallbacks()
  3536. }
  3537. }, description: function () {
  3538. return"\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e"
  3539. }, initWithData: function (a, b, c, d, e) {
  3540. return!1
  3541. }, initWithImage: function (a) {
  3542. return!1
  3543. }, initWithString: function (a, b, c, d, e, f) {
  3544. return!1
  3545. }, releaseTexture: function () {
  3546. }, getName: function () {
  3547. return null
  3548. }, getMaxS: function () {
  3549. return 1
  3550. }, setMaxS: function (a) {
  3551. }, getMaxT: function () {
  3552. return 1
  3553. }, setMaxT: function (a) {
  3554. },
  3555. getPixelFormat: function () {
  3556. return null
  3557. }, getShaderProgram: function () {
  3558. return null
  3559. }, setShaderProgram: function (a) {
  3560. }, hasPremultipliedAlpha: function () {
  3561. return!1
  3562. }, hasMipmaps: function () {
  3563. return!1
  3564. }, releaseData: function (a) {
  3565. }, keepData: function (a, b) {
  3566. return a
  3567. }, drawAtPoint: function (a) {
  3568. }, drawInRect: function (a) {
  3569. }, initWithETCFile: function (a) {
  3570. cc.log(cc._LogInfos.Texture2D_initWithETCFile);
  3571. return!1
  3572. }, initWithPVRFile: function (a) {
  3573. cc.log(cc._LogInfos.Texture2D_initWithPVRFile);
  3574. return!1
  3575. }, initWithPVRTCData: function (a, b, c, d, e, f) {
  3576. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);
  3577. return!1
  3578. }, setTexParameters: function (a) {
  3579. }, setAntiAliasTexParameters: function () {
  3580. }, setAliasTexParameters: function () {
  3581. }, generateMipmap: function () {
  3582. }, stringForFormat: function () {
  3583. return""
  3584. }, bitsPerPixelForFormat: function (a) {
  3585. return-1
  3586. }, addLoadedEventListener: function (a, b) {
  3587. this._loadedEventListeners || (this._loadedEventListeners = []);
  3588. this._loadedEventListeners.push({eventCallback: a, eventTarget: b})
  3589. }, removeLoadedEventListener: function (a) {
  3590. if (this._loadedEventListeners)for (var b =
  3591. this._loadedEventListeners, c = 0; c < b.length; c++)b[c].eventTarget == a && b.splice(c, 1)
  3592. }, _callLoadedEventCallbacks: function () {
  3593. if (this._loadedEventListeners) {
  3594. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  3595. var d = a[b];
  3596. d.eventCallback.call(d.eventTarget, this)
  3597. }
  3598. a.length = 0
  3599. }
  3600. }}) : (cc.assert("function" === typeof cc._tmp.WebGLTexture2D, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D);
  3601. cc.assert("function" === typeof cc._tmp.PrototypeTexture2D, cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  3602. cc._tmp.PrototypeTexture2D();
  3603. delete cc._tmp.PrototypeTexture2D;
  3604. cc.textureCache = {_textures: {}, _textureColorsCache: {}, _textureKeySeq: 0 | 1E3 * Math.random(), _loadedTexturesBefore: {}, _initializingRenderer: function () {
  3605. var a, b = this._loadedTexturesBefore, c = this._textures;
  3606. for (a in b) {
  3607. var d = b[a];
  3608. d.handleLoadedTexture();
  3609. c[a] = d
  3610. }
  3611. this._loadedTexturesBefore = {}
  3612. }, addPVRTCImage: function (a) {
  3613. cc.log(cc._LogInfos.textureCache_addPVRTCImage)
  3614. }, addETCImage: function (a) {
  3615. cc.log(cc._LogInfos.textureCache_addETCImage)
  3616. }, description: function () {
  3617. return"\x3cTextureCache | Number of textures \x3d " +
  3618. this._textures.length + "\x3e"
  3619. }, textureForKey: function (a) {
  3620. return this._textures[a] || this._textures[cc.loader._aliases[a]]
  3621. }, getKeyByTexture: function (a) {
  3622. for (var b in this._textures)if (this._textures[b] == a)return b;
  3623. return null
  3624. }, _generalTextureKey: function () {
  3625. this._textureKeySeq++;
  3626. return"_textureKey_" + this._textureKeySeq
  3627. }, getTextureColors: function (a) {
  3628. var b = this.getKeyByTexture(a);
  3629. b || (b = a instanceof HTMLImageElement ? a.src : this._generalTextureKey());
  3630. this._textureColorsCache[b] || (this._textureColorsCache[b] =
  3631. cc.generateTextureCacheForColor(a));
  3632. return this._textureColorsCache[b]
  3633. }, addPVRImage: function (a) {
  3634. cc.log(cc._LogInfos.textureCache_addPVRImage)
  3635. }, removeAllTextures: function () {
  3636. var a = this._textures, b;
  3637. for (b in a)a[b] && a[b].releaseTexture();
  3638. this._textures = {}
  3639. }, removeTexture: function (a) {
  3640. if (a) {
  3641. var b = this._textures, c;
  3642. for (c in b)b[c] == a && (b[c].releaseTexture(), delete b[c])
  3643. }
  3644. }, removeTextureForKey: function (a) {
  3645. null != a && this._textures[a] && delete this._textures[a]
  3646. }, cacheImage: function (a, b) {
  3647. if (b instanceof cc.Texture2D)this._textures[a] =
  3648. b; else {
  3649. var c = new cc.Texture2D;
  3650. c.initWithElement(b);
  3651. c.handleLoadedTexture();
  3652. this._textures[a] = c
  3653. }
  3654. }, addUIImage: function (a, b) {
  3655. cc.assert(a, cc._LogInfos.textureCache_addUIImage_2);
  3656. if (b && this._textures[b])return this._textures[b];
  3657. var c = new cc.Texture2D;
  3658. c.initWithImage(a);
  3659. null != b && null != c ? this._textures[b] = c : cc.log(cc._LogInfos.textureCache_addUIImage);
  3660. return c
  3661. }, dumpCachedTextureInfo: function () {
  3662. var a = 0, b = 0, c = this._textures, d;
  3663. for (d in c) {
  3664. var e = c[d];
  3665. a++;
  3666. e.getHtmlElementObj()instanceof HTMLImageElement ? cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo,
  3667. d, e.getHtmlElementObj().src, e.pixelsWidth, e.pixelsHeight) : cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, e.pixelsWidth, e.pixelsHeight);
  3668. b += 4 * e.pixelsWidth * e.pixelsHeight
  3669. }
  3670. c = this._textureColorsCache;
  3671. for (d in c) {
  3672. var e = c[d], f;
  3673. for (f in e) {
  3674. var g = e[f];
  3675. a++;
  3676. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, g.width, g.height);
  3677. b += 4 * g.width * g.height
  3678. }
  3679. }
  3680. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, b / 1024, (b / 1048576).toFixed(2))
  3681. }, _clear: function () {
  3682. this._textures = {};
  3683. this._textureColorsCache =
  3684. {};
  3685. this._textureKeySeq = 0 | 1E3 * Math.random();
  3686. this._loadedTexturesBefore = {}
  3687. }};
  3688. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function (a) {
  3689. var b = this._textures, c = b[a];
  3690. c || (c = b[a] = new cc.Texture2D, c.url = a);
  3691. c.handleLoadedTexture()
  3692. }, _p.addImage = function (a, b, c) {
  3693. cc.assert(a, cc._LogInfos.Texture2D_addImage);
  3694. var d = this._textures, e = d[a] || d[cc.loader._aliases[a]];
  3695. if (e)return b && b.call(c), e;
  3696. e = d[a] = new cc.Texture2D;
  3697. e.url = a;
  3698. cc.loader.getRes(a) ? e.handleLoadedTexture() : cc.loader._checkIsImageURL(a) ? cc.loader.load(a, function (a) {
  3699. b && b.call(c)
  3700. }) : cc.loader.cache[a] =
  3701. cc.loader.loadImg(a, function (c, d) {
  3702. if (c)return b ? b(c) : c;
  3703. cc.textureCache.handleLoadedTexture(a);
  3704. b && b(null, d)
  3705. });
  3706. return e
  3707. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLTextureCache, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache);
  3708. cc.Scene = cc.Node.extend({_className: "Scene", ctor: function () {
  3709. cc.Node.prototype.ctor.call(this);
  3710. this._ignoreAnchorPointForPosition = !0;
  3711. this.setAnchorPoint(0.5, 0.5);
  3712. this.setContentSize(cc.director.getWinSize())
  3713. }});
  3714. cc.Scene.create = function () {
  3715. return new cc.Scene
  3716. };
  3717. cc.LoaderScene = cc.Scene.extend({_interval: null, _length: 0, _count: 0, _label: null, _className: "LoaderScene", init: function () {
  3718. var a = this, b = 200, c = a._bgLayer = cc.LayerColor.create(cc.color(32, 32, 32, 255));
  3719. c.setPosition(cc.visibleRect.bottomLeft);
  3720. a.addChild(c, 0);
  3721. var d = 24, e = -b / 2 + 100;
  3722. cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, {isCrossOrigin: !1}, function (c, d) {
  3723. b = d.height;
  3724. a._initStage(d, cc.visibleRect.center)
  3725. }), d = 14, e = -b / 2 - 10);
  3726. d = a._label = cc.LabelTTF.create("加载中... 0%", "黑体", d);
  3727. d.setPosition(cc.pAdd(cc.visibleRect.center,
  3728. cc.p(0, e)));
  3729. d.setColor(cc.color(180, 180, 180));
  3730. c.addChild(this._label, 10);
  3731. return!0
  3732. }, _initStage: function (a, b) {
  3733. var c = this._texture2d = new cc.Texture2D;
  3734. c.initWithElement(a);
  3735. c.handleLoadedTexture();
  3736. c = this._logo = cc.Sprite.create(c);
  3737. c.setScale(cc.contentScaleFactor());
  3738. c.x = b.x;
  3739. c.y = b.y;
  3740. this._bgLayer.addChild(c, 10)
  3741. }, onEnter: function () {
  3742. cc.Node.prototype.onEnter.call(this);
  3743. this.schedule(this._startLoading, 0.3)
  3744. }, onExit: function () {
  3745. cc.Node.prototype.onExit.call(this);
  3746. this._label.setString("加载中... 0%")
  3747. }, initWithResources: function (a, b) {
  3748. "string" == typeof a && (a = [a]);
  3749. this.resources = a || [];
  3750. this.cb = b
  3751. }, _startLoading: function () {
  3752. var a = this;
  3753. a.unschedule(a._startLoading);
  3754. var b = a.resources;
  3755. a._length = b.length;
  3756. a._count = 0;
  3757. cc.loader.load(b, function (b, d) {
  3758. a._count = d
  3759. }, function () {
  3760. a.cb && a.cb()
  3761. });
  3762. a.schedule(a._updatePercent)
  3763. }, _updatePercent: function () {
  3764. var a = this._count, b = this._length, c;
  3765. c = Math.min(100 * (a / b) | 0, 100);
  3766. this._label.setString("加载中... " + c + "%");
  3767. a >= b && this.unschedule(this._updatePercent)
  3768. }});
  3769. cc.LoaderScene.preload = function (a, b) {
  3770. var c = cc;
  3771. c.loaderScene || (c.loaderScene = new cc.LoaderScene, c.loaderScene.init());
  3772. c.loaderScene.initWithResources(a, b);
  3773. cc.director.runScene(c.loaderScene);
  3774. return c.loaderScene
  3775. };
  3776. cc._tmp.PrototypeLayerRGBA = function () {
  3777. var a = cc.LayerRGBA.prototype;
  3778. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  3779. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  3780. cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
  3781. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  3782. cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
  3783. };
  3784. cc._tmp.PrototypeLayerColor = function () {
  3785. var a = cc.LayerColor.prototype;
  3786. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  3787. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight)
  3788. };
  3789. cc._tmp.PrototypeLayerGradient = function () {
  3790. var a = cc.LayerGradient.prototype;
  3791. cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor);
  3792. cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor);
  3793. cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity);
  3794. cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity);
  3795. cc.defineGetterSetter(a, "vector", a.getVector, a.setVector)
  3796. };
  3797. cc.Layer = cc.Node.extend({_isBaked: !1, _bakeSprite: null, _className: "Layer", ctor: function () {
  3798. var a = cc.Node.prototype;
  3799. a.ctor.call(this);
  3800. this._ignoreAnchorPointForPosition = !0;
  3801. a.setAnchorPoint.call(this, 0.5, 0.5);
  3802. a.setContentSize.call(this, cc.winSize)
  3803. }, bake: null, unbake: null, isBaked: function () {
  3804. return this._isBaked
  3805. }, visit: null});
  3806. cc.Layer.create = function () {
  3807. return new cc.Layer
  3808. };
  3809. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  3810. var p = cc.Layer.prototype;
  3811. p.bake = function () {
  3812. if (!this._isBaked) {
  3813. this._isBaked = this._cacheDirty = !0;
  3814. this._cachedParent = this;
  3815. for (var a = this._children, b = 0, c = a.length; b < c; b++)a[b]._setCachedParent(this);
  3816. this._bakeSprite || (this._bakeSprite = new cc.BakeSprite)
  3817. }
  3818. };
  3819. p.unbake = function () {
  3820. if (this._isBaked) {
  3821. this._isBaked = !1;
  3822. this._cacheDirty = !0;
  3823. this._cachedParent = null;
  3824. for (var a = this._children, b = 0, c = a.length; b < c; b++)a[b]._setCachedParent(null)
  3825. }
  3826. };
  3827. p.visit = function (a) {
  3828. if (this._isBaked) {
  3829. a =
  3830. a || cc._renderContext;
  3831. var b, c = this._children, d = c.length;
  3832. if (this._visible && 0 !== d) {
  3833. var e = this._bakeSprite;
  3834. a.save();
  3835. this.transform(a);
  3836. if (this._cacheDirty) {
  3837. b = this._getBoundingBoxForBake();
  3838. b.width |= 0;
  3839. b.height |= 0;
  3840. var f = e.getCacheContext();
  3841. e.resetCanvasSize(b.width, b.height);
  3842. f.translate(0 - b.x, b.height + b.y);
  3843. var g = e.getAnchorPointInPoints();
  3844. e.setPosition(g.x + b.x, g.y + b.y);
  3845. this.sortAllChildren();
  3846. for (b = 0; b < d; b++)c[b].visit(f);
  3847. this._cacheDirty = !1
  3848. }
  3849. e.visit(a);
  3850. this.arrivalOrder = 0;
  3851. a.restore()
  3852. }
  3853. } else cc.Node.prototype.visit.call(this,
  3854. a)
  3855. };
  3856. p._getBoundingBoxForBake = function () {
  3857. var a = null;
  3858. if (!this._children || 0 === this._children.length)return cc.rect(0, 0, 10, 10);
  3859. for (var b = this._children, c = 0; c < b.length; c++) {
  3860. var d = b[c];
  3861. d && d._visible && (a ? (d = d._getBoundingBoxToCurrentNode()) && (a = cc.rectUnion(a, d)) : a = d._getBoundingBoxToCurrentNode())
  3862. }
  3863. return a
  3864. };
  3865. p = null
  3866. } else cc.assert("function" === typeof cc._tmp.LayerDefineForWebGL, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.LayerDefineForWebGL(), delete cc._tmp.LayerDefineForWebGL;
  3867. cc.LayerRGBA = cc.Layer.extend({RGBAProtocol: !0, _displayedOpacity: 255, _realOpacity: 255, _displayedColor: null, _realColor: null, _cascadeOpacityEnabled: !1, _cascadeColorEnabled: !1, _className: "LayerRGBA", ctor: function () {
  3868. cc.Layer.prototype.ctor.call(this);
  3869. this._displayedColor = cc.color(255, 255, 255, 255);
  3870. this._realColor = cc.color(255, 255, 255, 255)
  3871. }, init: function () {
  3872. var a = cc.Layer.prototype;
  3873. this._ignoreAnchorPointForPosition = !0;
  3874. a.setAnchorPoint.call(this, 0.5, 0.5);
  3875. a.setContentSize.call(this, cc.winSize);
  3876. this.cascadeColor =
  3877. this.cascadeOpacity = !1;
  3878. return!0
  3879. }, getOpacity: function () {
  3880. return this._realOpacity
  3881. }, getDisplayedOpacity: function () {
  3882. return this._displayedOpacity
  3883. }, setOpacity: function (a) {
  3884. this._displayedOpacity = this._realOpacity = a;
  3885. var b = 255, c = this._parent;
  3886. c && (c.RGBAProtocol && c.cascadeOpacity) && (b = c.getDisplayedOpacity());
  3887. this.updateDisplayedOpacity(b);
  3888. this._displayedColor.a = this._realColor.a = a
  3889. }, updateDisplayedOpacity: function (a) {
  3890. this._displayedOpacity = 0 | this._realOpacity * a / 255;
  3891. if (this._cascadeOpacityEnabled) {
  3892. a = this._children;
  3893. for (var b, c = 0; c < a.length; c++)(b = a[c]) && b.RGBAProtocol && b.updateDisplayedOpacity(this._displayedOpacity)
  3894. }
  3895. }, isCascadeOpacityEnabled: function () {
  3896. return this._cascadeOpacityEnabled
  3897. }, setCascadeOpacityEnabled: function (a) {
  3898. this._cascadeOpacityEnabled !== a && ((this._cascadeOpacityEnabled = a) ? this._enableCascadeOpacity() : this._disableCascadeOpacity())
  3899. }, _enableCascadeOpacity: function () {
  3900. var a = 255, b = this._parent;
  3901. b && (b.RGBAProtocol && b.cascadeOpacity) && (a = b.getDisplayedOpacity());
  3902. this.updateDisplayedOpacity(a)
  3903. }, _disableCascadeOpacity: function () {
  3904. this._displayedOpacity =
  3905. this._realOpacity;
  3906. for (var a = this._children, b, c = 0; c < a.length; c++)(b = a[c]) && b.RGBAProtocol && b.updateDisplayedOpacity(255)
  3907. }, getColor: function () {
  3908. var a = this._realColor;
  3909. return cc.color(a.r, a.g, a.b, a.a)
  3910. }, getDisplayedColor: function () {
  3911. var a = this._displayedColor;
  3912. return cc.color(a.r, a.g, a.b)
  3913. }, setColor: function (a) {
  3914. var b = this._displayedColor, c = this._realColor;
  3915. b.r = c.r = a.r;
  3916. b.g = c.g = a.g;
  3917. b.b = c.b = a.b;
  3918. b = (b = this._parent) && b.RGBAProtocol && b.cascadeColor ? b.getDisplayedColor() : cc.color.WHITE;
  3919. this.updateDisplayedColor(b);
  3920. void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
  3921. }, updateDisplayedColor: function (a) {
  3922. var b = this._displayedColor, c = this._realColor;
  3923. b.r = 0 | c.r * a.r / 255;
  3924. b.g = 0 | c.g * a.g / 255;
  3925. b.b = 0 | c.b * a.b / 255;
  3926. if (this._cascadeColorEnabled) {
  3927. a = this._children;
  3928. for (var d = 0; d < a.length; d++)(c = a[d]) && c.RGBAProtocol && c.updateDisplayedColor(b)
  3929. }
  3930. }, isCascadeColorEnabled: function () {
  3931. return this._cascadeColorEnabled
  3932. }, setCascadeColorEnabled: function (a) {
  3933. this._cascadeColorEnabled !== a && ((this._cascadeColorEnabled = a) ? this._enableCascadeColor() :
  3934. this._disableCascadeColor())
  3935. }, _enableCascadeColor: function () {
  3936. var a;
  3937. a = (a = this._parent) && a.RGBAProtocol && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
  3938. this.updateDisplayedColor(a)
  3939. }, _disableCascadeColor: function () {
  3940. var a = this._displayedColor, b = this._realColor;
  3941. a.r = b.r;
  3942. a.g = b.g;
  3943. a.b = b.b;
  3944. var a = this._children, b = cc.color.WHITE, c, d;
  3945. for (d = 0; d < a.length; d++)(c = a[d]) && c.RGBAProtocol && c.updateDisplayedColor(b)
  3946. }, addChild: function (a, b, c) {
  3947. cc.Node.prototype.addChild.call(this, a, b, c);
  3948. this._cascadeColorEnabled && this._enableCascadeColor();
  3949. this._cascadeOpacityEnabled && this._enableCascadeOpacity()
  3950. }, setOpacityModifyRGB: function (a) {
  3951. }, isOpacityModifyRGB: function () {
  3952. return!1
  3953. }});
  3954. cc.assert("function" === typeof cc._tmp.PrototypeLayerRGBA, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  3955. cc._tmp.PrototypeLayerRGBA();
  3956. delete cc._tmp.PrototypeLayerRGBA;
  3957. cc.LayerColor = cc.LayerRGBA.extend({_blendFunc: null, _className: "LayerColor", getBlendFunc: function () {
  3958. return this._blendFunc
  3959. }, changeWidthAndHeight: function (a, b) {
  3960. this.width = a;
  3961. this.height = b
  3962. }, changeWidth: function (a) {
  3963. this.width = a
  3964. }, changeHeight: function (a) {
  3965. this.height = a
  3966. }, setOpacityModifyRGB: function (a) {
  3967. }, isOpacityModifyRGB: function () {
  3968. return!1
  3969. }, setColor: function (a) {
  3970. cc.LayerRGBA.prototype.setColor.call(this, a);
  3971. this._updateColor()
  3972. }, setOpacity: function (a) {
  3973. cc.LayerRGBA.prototype.setOpacity.call(this, a);
  3974. this._updateColor()
  3975. },
  3976. _isLighterMode: !1, ctor: null, init: function (a, b, c) {
  3977. cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));
  3978. var d = cc.director.getWinSize();
  3979. a = a || cc.color(0, 0, 0, 255);
  3980. b = void 0 === b ? d.width : b;
  3981. c = void 0 === c ? d.height : c;
  3982. d = this._displayedColor;
  3983. d.r = a.r;
  3984. d.g = a.g;
  3985. d.b = a.b;
  3986. d = this._realColor;
  3987. d.r = a.r;
  3988. d.g = a.g;
  3989. d.b = a.b;
  3990. this._realOpacity = this._displayedOpacity = a.a;
  3991. a = cc.LayerColor.prototype;
  3992. a.setContentSize.call(this, b, c);
  3993. a._updateColor.call(this);
  3994. return!0
  3995. }, setBlendFunc: function (a, b) {
  3996. this._blendFunc = void 0 === b ? a : {src: a, dst: b};
  3997. cc._renderType === cc._RENDER_TYPE_CANVAS && (this._isLighterMode = this._blendFunc && 1 == this._blendFunc.src && 771 == this._blendFunc.dst)
  3998. }, _setWidth: null, _setHeight: null, _updateColor: null, updateDisplayedColor: function (a) {
  3999. cc.LayerRGBA.prototype.updateDisplayedColor.call(this, a);
  4000. this._updateColor()
  4001. }, updateDisplayedOpacity: function (a) {
  4002. cc.LayerRGBA.prototype.updateDisplayedOpacity.call(this, a);
  4003. this._updateColor()
  4004. }, draw: null});
  4005. cc.LayerColor.create = function (a, b, c) {
  4006. return new cc.LayerColor(a, b, c)
  4007. };
  4008. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerColor.prototype, _p.ctor = function (a, b, c) {
  4009. cc.LayerRGBA.prototype.ctor.call(this);
  4010. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  4011. cc.LayerColor.prototype.init.call(this, a, b, c)
  4012. }, _p._setWidth = cc.LayerRGBA.prototype._setWidth, _p._setHeight = cc.LayerRGBA.prototype._setHeight, _p._updateColor = function () {
  4013. }, _p.draw = function (a) {
  4014. a = a || cc._renderContext;
  4015. var b = cc.view, c = this._displayedColor;
  4016. a.fillStyle = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + "," + this._displayedOpacity /
  4017. 255 + ")";
  4018. a.fillRect(0, 0, this.width * b.getScaleX(), -this.height * b.getScaleY());
  4019. cc.g_NumberOfDraws++
  4020. }, _p.visit = function (a) {
  4021. if (this._isBaked) {
  4022. a = a || cc._renderContext;
  4023. var b, c = this._children, d = c.length;
  4024. if (this._visible) {
  4025. var e = this._bakeSprite;
  4026. a.save();
  4027. this.transform(a);
  4028. if (this._cacheDirty) {
  4029. b = this._getBoundingBoxForBake();
  4030. b.width |= 0;
  4031. b.height |= 0;
  4032. var f = e.getCacheContext();
  4033. e.resetCanvasSize(b.width, b.height);
  4034. var g = e.getAnchorPointInPoints(), h = this._position;
  4035. if (this._ignoreAnchorPointForPosition)f.translate(0 -
  4036. b.x + h.x, b.height + b.y - h.y), e.setPosition(g.x + b.x - h.x, g.y + b.y - h.y); else {
  4037. var k = this.getAnchorPointInPoints(), l = h.x - k.x, h = h.y - k.y;
  4038. f.translate(0 - b.x + l, b.height + b.y - h);
  4039. e.setPosition(g.x + b.x - l, g.y + b.y - h)
  4040. }
  4041. if (0 < d) {
  4042. this.sortAllChildren();
  4043. for (b = 0; b < d; b++)if (g = c[b], 0 > g._localZOrder)g.visit(f); else break;
  4044. for (this.draw(f); b < d; b++)c[b].visit(f)
  4045. } else this.draw(f);
  4046. this._cacheDirty = !1
  4047. }
  4048. e.visit(a);
  4049. this.arrivalOrder = 0;
  4050. a.restore()
  4051. }
  4052. } else cc.Node.prototype.visit.call(this, a)
  4053. }, _p._getBoundingBoxForBake = function () {
  4054. var a = cc.rect(0,
  4055. 0, this._contentSize.width, this._contentSize.height), b = this.nodeToWorldTransform(), a = cc.RectApplyAffineTransform(a, this.nodeToWorldTransform());
  4056. if (!this._children || 0 === this._children.length)return a;
  4057. for (var c = this._children, d = 0; d < c.length; d++) {
  4058. var e = c[d];
  4059. e && e._visible && (e = e._getBoundingBoxToCurrentNode(b), a = cc.rectUnion(a, e))
  4060. }
  4061. return a
  4062. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerColor, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerColor(), delete cc._tmp.WebGLLayerColor);
  4063. cc.assert("function" === typeof cc._tmp.PrototypeLayerColor, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  4064. cc._tmp.PrototypeLayerColor();
  4065. delete cc._tmp.PrototypeLayerColor;
  4066. cc.LayerGradient = cc.LayerColor.extend({_startColor: null, _endColor: null, _startOpacity: 255, _endOpacity: 255, _alongVector: null, _compressedInterpolation: !1, _gradientStartPoint: null, _gradientEndPoint: null, _className: "LayerGradient", ctor: function (a, b, c) {
  4067. cc.LayerColor.prototype.ctor.call(this);
  4068. this._startColor = cc.color(0, 0, 0, 255);
  4069. this._endColor = cc.color(0, 0, 0, 255);
  4070. this._alongVector = cc.p(0, -1);
  4071. this._endOpacity = this._startOpacity = 255;
  4072. this._gradientStartPoint = cc.p(0, 0);
  4073. this._gradientEndPoint = cc.p(0, 0);
  4074. cc.LayerGradient.prototype.init.call(this,
  4075. a, b, c)
  4076. }, init: function (a, b, c) {
  4077. a = a || cc.color(0, 0, 0, 255);
  4078. b = b || cc.color(0, 0, 0, 255);
  4079. c = c || cc.p(0, -1);
  4080. var d = this._startColor, e = this._endColor;
  4081. d.r = a.r;
  4082. d.g = a.g;
  4083. d.b = a.b;
  4084. this._startOpacity = a.a;
  4085. e.r = b.r;
  4086. e.g = b.g;
  4087. e.b = b.b;
  4088. this._endOpacity = b.a;
  4089. this._alongVector = c;
  4090. this._compressedInterpolation = !0;
  4091. this._gradientStartPoint = cc.p(0, 0);
  4092. this._gradientEndPoint = cc.p(0, 0);
  4093. cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255));
  4094. cc.LayerGradient.prototype._updateColor.call(this);
  4095. return!0
  4096. }, setContentSize: function (a, b) {
  4097. cc.LayerColor.prototype.setContentSize.call(this, a, b);
  4098. this._updateColor()
  4099. }, _setWidth: function (a) {
  4100. cc.LayerColor.prototype._setWidth.call(this, a);
  4101. this._updateColor()
  4102. }, _setHeight: function (a) {
  4103. cc.LayerColor.prototype._setHeight.call(this, a);
  4104. this._updateColor()
  4105. }, getStartColor: function () {
  4106. return this._realColor
  4107. }, setStartColor: function (a) {
  4108. this.color = a
  4109. }, setEndColor: function (a) {
  4110. this._endColor = a;
  4111. this._updateColor()
  4112. }, getEndColor: function () {
  4113. return this._endColor
  4114. }, setStartOpacity: function (a) {
  4115. this._startOpacity =
  4116. a;
  4117. this._updateColor()
  4118. }, getStartOpacity: function () {
  4119. return this._startOpacity
  4120. }, setEndOpacity: function (a) {
  4121. this._endOpacity = a;
  4122. this._updateColor()
  4123. }, getEndOpacity: function () {
  4124. return this._endOpacity
  4125. }, setVector: function (a) {
  4126. this._alongVector.x = a.x;
  4127. this._alongVector.y = a.y;
  4128. this._updateColor()
  4129. }, getVector: function () {
  4130. return cc.p(this._alongVector.x, this._alongVector.y)
  4131. }, isCompressedInterpolation: function () {
  4132. return this._compressedInterpolation
  4133. }, setCompressedInterpolation: function (a) {
  4134. this._compressedInterpolation =
  4135. a;
  4136. this._updateColor()
  4137. }, _draw: null, _updateColor: null});
  4138. cc.LayerGradient.create = function (a, b, c) {
  4139. return new cc.LayerGradient(a, b, c)
  4140. };
  4141. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerGradient.prototype, _p.draw = function (a) {
  4142. a = a || cc._renderContext;
  4143. this._isLighterMode && (a.globalCompositeOperation = "lighter");
  4144. a.save();
  4145. var b = cc.view, c = this._displayedOpacity / 255, d = this.width * b.getScaleX(), b = this.height * b.getScaleY(), e = a.createLinearGradient(this._gradientStartPoint.x, this._gradientStartPoint.y, this._gradientEndPoint.x, this._gradientEndPoint.y), f = this._displayedColor, g = this._endColor;
  4146. e.addColorStop(0, "rgba(" + Math.round(f.r) + "," + Math.round(f.g) +
  4147. "," + Math.round(f.b) + "," + (c * (this._startOpacity / 255)).toFixed(4) + ")");
  4148. e.addColorStop(1, "rgba(" + Math.round(g.r) + "," + Math.round(g.g) + "," + Math.round(g.b) + "," + (c * (this._endOpacity / 255)).toFixed(4) + ")");
  4149. a.fillStyle = e;
  4150. a.fillRect(0, 0, d, -b);
  4151. 0 != this._rotation && a.rotate(this._rotationRadians);
  4152. a.restore()
  4153. }, _p._updateColor = function () {
  4154. var a = this._alongVector, b = 0.5 * this.width, c = 0.5 * this.height;
  4155. this._gradientStartPoint.x = b * -a.x + b;
  4156. this._gradientStartPoint.y = c * a.y - c;
  4157. this._gradientEndPoint.x = b * a.x + b;
  4158. this._gradientEndPoint.y =
  4159. c * -a.y - c
  4160. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerGradient, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerGradient(), delete cc._tmp.WebGLLayerGradient);
  4161. cc.assert("function" === typeof cc._tmp.PrototypeLayerGradient, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  4162. cc._tmp.PrototypeLayerGradient();
  4163. delete cc._tmp.PrototypeLayerGradient;
  4164. cc.LayerMultiplex = cc.Layer.extend({_enabledLayer: 0, _layers: null, _className: "LayerMultiplex", ctor: function (a) {
  4165. cc.Layer.prototype.ctor.call(this);
  4166. a && cc.LayerMultiplex.prototype.initWithLayers.call(this, a)
  4167. }, initWithLayers: function (a) {
  4168. 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);
  4169. this._layers = a;
  4170. this._enabledLayer = 0;
  4171. this.addChild(this._layers[this._enabledLayer]);
  4172. return!0
  4173. }, switchTo: function (a) {
  4174. a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchTo) : (this.removeChild(this._layers[this._enabledLayer],
  4175. !0), this._enabledLayer = a, this.addChild(this._layers[a]))
  4176. }, switchToAndReleaseMe: function (a) {
  4177. a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe) : (this.removeChild(this._layers[this._enabledLayer], !0), this._layers[this._enabledLayer] = null, this._enabledLayer = a, this.addChild(this._layers[a]))
  4178. }, addLayer: function (a) {
  4179. a ? this._layers.push(a) : cc.log(cc._LogInfos.LayerMultiplex_addLayer)
  4180. }});
  4181. cc.LayerMultiplex.create = function () {
  4182. return new cc.LayerMultiplex(arguments)
  4183. };
  4184. cc._tmp.PrototypeSprite = function () {
  4185. var a = cc.Sprite.prototype;
  4186. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  4187. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  4188. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  4189. cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX);
  4190. cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY);
  4191. cc.defineGetterSetter(a, "offsetX", a._getOffsetX);
  4192. cc.defineGetterSetter(a, "offsetY", a._getOffsetY);
  4193. cc.defineGetterSetter(a,
  4194. "texture", a.getTexture, a.setTexture);
  4195. cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated);
  4196. cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode);
  4197. cc.defineGetterSetter(a, "quad", a.getQuad)
  4198. };
  4199. cc.generateTextureCacheForColor = function (a) {
  4200. function b() {
  4201. var b = cc.generateTextureCacheForColor, d = a.width, g = a.height;
  4202. c[0].width = d;
  4203. c[0].height = g;
  4204. c[1].width = d;
  4205. c[1].height = g;
  4206. c[2].width = d;
  4207. c[2].height = g;
  4208. c[3].width = d;
  4209. c[3].height = g;
  4210. b.canvas.width = d;
  4211. b.canvas.height = g;
  4212. var h = b.canvas.getContext("2d");
  4213. h.drawImage(a, 0, 0);
  4214. b.tempCanvas.width = d;
  4215. b.tempCanvas.height = g;
  4216. for (var h = h.getImageData(0, 0, d, g).data, k = 0; 4 > k; k++) {
  4217. var l = c[k].getContext("2d");
  4218. l.getImageData(0, 0, d, g).data;
  4219. b.tempCtx.drawImage(a, 0, 0);
  4220. for (var m = b.tempCtx.getImageData(0,
  4221. 0, d, g), n = m.data, q = 0; q < h.length; q += 4)n[q] = 0 === k ? h[q] : 0, n[q + 1] = 1 === k ? h[q + 1] : 0, n[q + 2] = 2 === k ? h[q + 2] : 0, n[q + 3] = h[q + 3];
  4222. l.putImageData(m, 0, 0)
  4223. }
  4224. a.onload = null
  4225. }
  4226. if (a.channelCache)return a.channelCache;
  4227. var c = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")];
  4228. try {
  4229. b()
  4230. } catch (d) {
  4231. a.onload = b
  4232. }
  4233. return a.channelCache = c
  4234. };
  4235. cc.generateTextureCacheForColor.canvas = cc.newElement("canvas");
  4236. cc.generateTextureCacheForColor.tempCanvas = cc.newElement("canvas");
  4237. cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext("2d");
  4238. cc.generateTintImage2 = function (a, b, c) {
  4239. c || (c = cc.rect(0, 0, a.width, a.height), c = cc.rectPixelsToPoints(c));
  4240. var d = cc.newElement("canvas"), e = d.getContext("2d");
  4241. d.width != c.width && (d.width = c.width);
  4242. d.height != c.height && (d.height = c.height);
  4243. e.save();
  4244. e.drawImage(a, c.x, c.y, c.width, c.height, 0, 0, c.width, c.height);
  4245. e.globalCompositeOperation = "source-in";
  4246. e.globalAlpha = b.a / 255;
  4247. e.fillStyle = "rgb(" + b.r + "," + b.g + "," + b.b + ")";
  4248. e.fillRect(0, 0, c.width, c.height);
  4249. e.restore();
  4250. return d
  4251. };
  4252. cc.generateTintImage = function (a, b, c, d, e) {
  4253. d || (d = cc.rect(0, 0, a.width, a.height));
  4254. a = c.r / 255;
  4255. var f = c.g / 255;
  4256. c = c.b / 255;
  4257. var g = Math.min(d.width, b[0].width), h = Math.min(d.height, b[0].height), k;
  4258. e ? (k = e.getContext("2d"), k.clearRect(0, 0, g, h)) : (e = cc.newElement("canvas"), e.width = g, e.height = h, k = e.getContext("2d"));
  4259. k.save();
  4260. k.globalCompositeOperation = "lighter";
  4261. var l = k.globalAlpha;
  4262. 0 < a && (k.globalAlpha = a * l, k.drawImage(b[0], d.x, d.y, g, h, 0, 0, g, h));
  4263. 0 < f && (k.globalAlpha = f * l, k.drawImage(b[1], d.x, d.y, g, h, 0, 0, g, h));
  4264. 0 < c && (k.globalAlpha =
  4265. c * l, k.drawImage(b[2], d.x, d.y, g, h, 0, 0, g, h));
  4266. 1 > a + f + c && (k.globalAlpha = l, k.drawImage(b[3], d.x, d.y, g, h, 0, 0, g, h));
  4267. k.restore();
  4268. return e
  4269. };
  4270. cc.cutRotateImageToCanvas = function (a, b) {
  4271. if (!a)return null;
  4272. if (!b)return a;
  4273. var c = cc.newElement("canvas");
  4274. c.width = b.width;
  4275. c.height = b.height;
  4276. var d = c.getContext("2d");
  4277. d.translate(c.width / 2, c.height / 2);
  4278. d.rotate(-1.5707963267948966);
  4279. d.drawImage(a, b.x, b.y, b.height, b.width, -b.height / 2, -b.width / 2, b.height, b.width);
  4280. return c
  4281. };
  4282. cc.Sprite = cc.NodeRGBA.extend({RGBAProtocol: !0, dirty: !1, atlasIndex: 0, textureAtlas: null, _batchNode: null, _recursiveDirty: null, _hasChildren: null, _shouldBeHidden: !1, _transformToBatch: null, _blendFunc: null, _texture: null, _rect: null, _rectRotated: !1, _offsetPosition: null, _unflippedOffsetPositionFromCenter: null, _opacityModifyRGB: !1, _flippedX: !1, _flippedY: !1, _textureLoaded: !1, _loadedEventListeners: null, _newTextureWhenChangeColor: null, _className: "Sprite", textureLoaded: function () {
  4283. return this._textureLoaded
  4284. }, addLoadedEventListener: function (a, b) {
  4285. this._loadedEventListeners || (this._loadedEventListeners = []);
  4286. this._loadedEventListeners.push({eventCallback: a, eventTarget: b})
  4287. }, _callLoadedEventCallbacks: function () {
  4288. if (this._loadedEventListeners) {
  4289. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  4290. var d = a[b];
  4291. d.eventCallback.call(d.eventTarget, this)
  4292. }
  4293. a.length = 0
  4294. }
  4295. }, isDirty: function () {
  4296. return this.dirty
  4297. }, setDirty: function (a) {
  4298. this.dirty = a
  4299. }, isTextureRectRotated: function () {
  4300. return this._rectRotated
  4301. }, getAtlasIndex: function () {
  4302. return this.atlasIndex
  4303. },
  4304. setAtlasIndex: function (a) {
  4305. this.atlasIndex = a
  4306. }, getTextureRect: function () {
  4307. return cc.rect(this._rect.x, this._rect.y, this._rect.width, this._rect.height)
  4308. }, getTextureAtlas: function () {
  4309. return this.textureAtlas
  4310. }, setTextureAtlas: function (a) {
  4311. this.textureAtlas = a
  4312. }, getOffsetPosition: function () {
  4313. return this._offsetPosition
  4314. }, _getOffsetX: function () {
  4315. return this._offsetPosition.x
  4316. }, _getOffsetY: function () {
  4317. return this._offsetPosition.y
  4318. }, getBlendFunc: function () {
  4319. return this._blendFunc
  4320. }, initWithSpriteFrame: function (a) {
  4321. cc.assert(a,
  4322. cc._LogInfos.Sprite_initWithSpriteFrame);
  4323. a.textureLoaded() || (this._textureLoaded = !1, a.addLoadedEventListener(this._spriteFrameLoadedCallback, this));
  4324. var b = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated, b = this.initWithTexture(a.getTexture(), a.getRect(), b);
  4325. this.setSpriteFrame(a);
  4326. return b
  4327. }, _spriteFrameLoadedCallback: null, initWithSpriteFrameName: function (a) {
  4328. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName);
  4329. var b = cc.spriteFrameCache.getSpriteFrame(a);
  4330. cc.assert(b, a + cc._LogInfos.Sprite_initWithSpriteFrameName1);
  4331. return this.initWithSpriteFrame(b)
  4332. }, useBatchNode: function (a) {
  4333. this.textureAtlas = a.textureAtlas;
  4334. this._batchNode = a
  4335. }, setVertexRect: function (a) {
  4336. this._rect.x = a.x;
  4337. this._rect.y = a.y;
  4338. this._rect.width = a.width;
  4339. this._rect.height = a.height
  4340. }, sortAllChildren: function () {
  4341. if (this._reorderChildDirty) {
  4342. var a = this._children, b = a.length, c, d, e;
  4343. for (c = 1; c < b; c++) {
  4344. e = a[c];
  4345. for (d = c - 1; 0 <= d;) {
  4346. if (e._localZOrder < a[d]._localZOrder)a[d + 1] = a[d]; else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder)a[d + 1] = a[d]; else break;
  4347. d--
  4348. }
  4349. a[d + 1] = e
  4350. }
  4351. this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node.StateCallbackType.sortAllChildren);
  4352. this._reorderChildDirty = !1
  4353. }
  4354. }, reorderChild: function (a, b) {
  4355. cc.assert(a, cc._LogInfos.Sprite_reorderChild_2);
  4356. -1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.Sprite_reorderChild) : b !== a.zIndex && (this._batchNode && !this._reorderChildDirty && (this._setReorderChildDirtyRecursively(), this._batchNode.reorderBatch(!0)), cc.Node.prototype.reorderChild.call(this, a, b))
  4357. }, removeChild: function (a, b) {
  4358. this._batchNode &&
  4359. this._batchNode.removeSpriteFromAtlas(a);
  4360. cc.Node.prototype.removeChild.call(this, a, b)
  4361. }, removeAllChildren: function (a) {
  4362. var b = this._children, c = this._batchNode;
  4363. if (c && null != b)for (var d = 0, e = b.length; d < e; d++)c.removeSpriteFromAtlas(b[d]);
  4364. cc.Node.prototype.removeAllChildren.call(this, a);
  4365. this._hasChildren = !1
  4366. }, setDirtyRecursively: function (a) {
  4367. this.dirty = this._recursiveDirty = a;
  4368. a = this._children;
  4369. for (var b, c = a ? a.length : 0, d = 0; d < c; d++)b = a[d], b instanceof cc.Sprite && b.setDirtyRecursively(!0)
  4370. }, setNodeDirty: function (a) {
  4371. cc.Node.prototype.setNodeDirty.call(this);
  4372. !a && (this._batchNode && !this._recursiveDirty) && (this._hasChildren ? this.setDirtyRecursively(!0) : this.dirty = this._recursiveDirty = !0)
  4373. }, ignoreAnchorPointForPosition: function (a) {
  4374. this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a)
  4375. }, setFlippedX: function (a) {
  4376. this._flippedX != a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  4377. }, setFlippedY: function (a) {
  4378. this._flippedY != a &&
  4379. (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  4380. }, isFlippedX: function () {
  4381. return this._flippedX
  4382. }, isFlippedY: function () {
  4383. return this._flippedY
  4384. }, setOpacityModifyRGB: null, isOpacityModifyRGB: function () {
  4385. return this._opacityModifyRGB
  4386. }, updateDisplayedOpacity: null, setDisplayFrameWithAnimationName: function (a, b) {
  4387. cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
  4388. var c = cc.animationCache.getAnimation(a);
  4389. c ? (c = c.getFrames()[b]) ? this.setSpriteFrame(c.getSpriteFrame()) :
  4390. cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)
  4391. }, getBatchNode: function () {
  4392. return this._batchNode
  4393. }, _setReorderChildDirtyRecursively: function () {
  4394. if (!this._reorderChildDirty) {
  4395. this._reorderChildDirty = !0;
  4396. for (var a = this._parent; a && a != this._batchNode;)a._setReorderChildDirtyRecursively(), a = a.parent
  4397. }
  4398. }, getTexture: function () {
  4399. return this._texture
  4400. }, _quad: null, _quadWebBuffer: null, _quadDirty: !1, _colorized: !1, _isLighterMode: !1, _originalTexture: null,
  4401. _textureRect_Canvas: null, _drawSize_Canvas: null, ctor: null, _softInit: function (a, b, c) {
  4402. if (void 0 === a)cc.Sprite.prototype.init.call(this); else if ("string" === typeof a)"#" === a[0] ? (a = a.substr(1, a.length - 1), a = cc.spriteFrameCache.getSpriteFrame(a), this.initWithSpriteFrame(a)) : cc.Sprite.prototype.init.call(this, a, b); else if ("object" === typeof a)if (a instanceof cc.Texture2D)this.initWithTexture(a, b, c); else if (a instanceof cc.SpriteFrame)this.initWithSpriteFrame(a); else if (a instanceof HTMLImageElement || a instanceof
  4403. HTMLCanvasElement)b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.initWithTexture(b)
  4404. }, getQuad: function () {
  4405. return this._quad
  4406. }, setBlendFunc: null, init: null, initWithFile: function (a, b) {
  4407. cc.assert(a, cc._LogInfos.Sprite_initWithFile);
  4408. var c = cc.textureCache.textureForKey(a);
  4409. if (c) {
  4410. if (!b) {
  4411. var d = c.getContentSize();
  4412. b = cc.rect(0, 0, d.width, d.height)
  4413. }
  4414. return this.initWithTexture(c, b)
  4415. }
  4416. c = cc.textureCache.addImage(a);
  4417. return this.initWithTexture(c, b || cc.rect(0, 0, c._contentSize.width, c._contentSize.height))
  4418. },
  4419. initWithTexture: null, _textureLoadedCallback: null, setTextureRect: null, updateTransform: null, addChild: null, updateColor: function () {
  4420. var a = this._displayedColor, b = this._displayedOpacity, a = {r: a.r, g: a.g, b: a.b, a: b};
  4421. this._opacityModifyRGB && (a.r *= b / 255, a.g *= b / 255, a.b *= b / 255);
  4422. b = this._quad;
  4423. b.bl.colors = a;
  4424. b.br.colors = a;
  4425. b.tl.colors = a;
  4426. b.tr.colors = a;
  4427. this._batchNode && (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED ? this.textureAtlas.updateQuad(b, this.atlasIndex) : this.dirty = !0);
  4428. this._quadDirty = !0
  4429. }, setOpacity: null, setColor: null,
  4430. updateDisplayedColor: null, setSpriteFrame: null, setDisplayFrame: function (a) {
  4431. cc.log(cc._LogInfos.Sprite_setDisplayFrame);
  4432. this.setSpriteFrame(a)
  4433. }, isFrameDisplayed: null, displayFrame: function () {
  4434. return cc.SpriteFrame.create(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize))
  4435. }, setBatchNode: null, setTexture: null, _updateBlendFunc: function () {
  4436. this._batchNode ? cc.log(cc._LogInfos.Sprite__updateBlendFunc) :
  4437. !this._texture || !this._texture.hasPremultipliedAlpha() ? (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA, this.opacityModifyRGB = !1) : (this._blendFunc.src = cc.BLEND_SRC, this._blendFunc.dst = cc.BLEND_DST, this.opacityModifyRGB = !0)
  4438. }, _changeTextureColor: function () {
  4439. var a, b = this._texture, c = this._textureRect_Canvas;
  4440. if (b && (c.validRect && this._originalTexture) && (a = b.getHtmlElementObj()))if (b = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()))this._colorized = !0,
  4441. a instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.generateTintImage(a, b, this._displayedColor, c, a) : (a = cc.generateTintImage(a, b, this._displayedColor, c), b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.texture = b)
  4442. }, _setTextureCoords: function (a) {
  4443. a = cc.rectPointsToPixels(a);
  4444. var b = this._batchNode ? this.textureAtlas.texture : this._texture;
  4445. if (b) {
  4446. var c = b.pixelsWidth, d = b.pixelsHeight, e, f = this._quad;
  4447. this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ?
  4448. (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.height - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.width - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.height) / c, e = a.y / d, a = (a.y + a.width) / d), this._flippedX && (d = e, e = a, a = d), this._flippedY && (d = b, b = c, c = d), f.bl.texCoords.u = b, f.bl.texCoords.v = e, f.br.texCoords.u = b, f.br.texCoords.v = a, f.tl.texCoords.u = c, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.width - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.height - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.width) /
  4449. c, e = a.y / d, a = (a.y + a.height) / d), this._flippedX && (d = b, b = c, c = d), this._flippedY && (d = e, e = a, a = d), f.bl.texCoords.u = b, f.bl.texCoords.v = a, f.br.texCoords.u = c, f.br.texCoords.v = a, f.tl.texCoords.u = b, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = e);
  4450. this._quadDirty = !0
  4451. }
  4452. }, draw: null});
  4453. cc.Sprite.create = function (a, b, c) {
  4454. return new cc.Sprite(a, b, c)
  4455. };
  4456. cc.Sprite.INDEX_NOT_INITIALIZED = -1;
  4457. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Sprite.prototype, _p._spriteFrameLoadedCallback = function (a) {
  4458. this.setNodeDirty(!0);
  4459. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  4460. a = this.color;
  4461. (255 !== a.r || 255 !== a.g || 255 !== a.b) && this._changeTextureColor();
  4462. this._callLoadedEventCallbacks()
  4463. }, _p.setOpacityModifyRGB = function (a) {
  4464. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.setNodeDirty(!0))
  4465. }, _p.updateDisplayedOpacity = function (a) {
  4466. cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this,
  4467. a);
  4468. this._setNodeDirtyForCache()
  4469. }, _p.ctor = function (a, b, c) {
  4470. cc.NodeRGBA.prototype.ctor.call(this);
  4471. this._shouldBeHidden = !1;
  4472. this._offsetPosition = cc.p(0, 0);
  4473. this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
  4474. this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST};
  4475. this._rect = cc.rect(0, 0, 0, 0);
  4476. this._newTextureWhenChangeColor = !1;
  4477. this._textureLoaded = !0;
  4478. this._textureRect_Canvas = {x: 0, y: 0, width: 0, height: 0, validRect: !1};
  4479. this._drawSize_Canvas = cc.size(0, 0);
  4480. this._softInit(a, b, c)
  4481. }, _p.setBlendFunc = function (a, b) {
  4482. var c = this._blendFunc;
  4483. void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b);
  4484. this._isLighterMode = c && (c.src == cc.SRC_ALPHA && c.dst == cc.ONE || c.src == cc.ONE && c.dst == cc.ONE)
  4485. }, _p.init = function () {
  4486. if (0 < arguments.length)return this.initWithFile(arguments[0], arguments[1]);
  4487. cc.NodeRGBA.prototype.init.call(this);
  4488. this.dirty = this._recursiveDirty = !1;
  4489. this._opacityModifyRGB = !0;
  4490. this._blendFunc.src = cc.BLEND_SRC;
  4491. this._blendFunc.dst = cc.BLEND_DST;
  4492. this.texture = null;
  4493. this._textureLoaded = !0;
  4494. this._flippedX = this._flippedY = !1;
  4495. this.anchorY = this.anchorX =
  4496. 0.5;
  4497. this._offsetPosition.x = 0;
  4498. this._offsetPosition.y = 0;
  4499. this._hasChildren = !1;
  4500. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  4501. return!0
  4502. }, _p.initWithTexture = function (a, b, c) {
  4503. cc.assert(0 != arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
  4504. if ((c = c || !1) && a.isLoaded()) {
  4505. var d = a.getHtmlElementObj(), d = cc.cutRotateImageToCanvas(d, b), e = new cc.Texture2D;
  4506. e.initWithElement(d);
  4507. e.handleLoadedTexture();
  4508. a = e;
  4509. this._rect = cc.rect(0, 0, b.width, b.height)
  4510. }
  4511. if (!cc.NodeRGBA.prototype.init.call(this))return!1;
  4512. this._batchNode = null;
  4513. this.dirty = this._recursiveDirty = !1;
  4514. this._opacityModifyRGB = !0;
  4515. this._blendFunc.src = cc.BLEND_SRC;
  4516. this._blendFunc.dst = cc.BLEND_DST;
  4517. this._flippedX = this._flippedY = !1;
  4518. this.anchorY = this.anchorX = 0.5;
  4519. this._offsetPosition.x = 0;
  4520. this._offsetPosition.y = 0;
  4521. this._hasChildren = !1;
  4522. this._textureLoaded = d = a.isLoaded();
  4523. if (!d)return this._rectRotated = c, b && (this._rect.x = b.x, this._rect.y = b.y, this._rect.width = b.width, this._rect.height = b.height), a.addLoadedEventListener(this._textureLoadedCallback, this), !0;
  4524. b || (b = cc.rect(0, 0, a.width, a.height));
  4525. a && (d = b.y + b.height, b.x + b.width > a.width && cc.error(cc._LogInfos.RectWidth, a.url), d > a.height && cc.error(cc._LogInfos.RectHeight, a.url));
  4526. this.texture = this._originalTexture = a;
  4527. this.setTextureRect(b, c);
  4528. this.batchNode = null;
  4529. return!0
  4530. }, _p._textureLoadedCallback = function (a) {
  4531. if (!this._textureLoaded) {
  4532. this._textureLoaded = !0;
  4533. var b = this._rect;
  4534. b ? cc._rectEqualToZero(b) && (b.width = a.width, b.height = a.height) : b = cc.rect(0, 0, a.width, a.height);
  4535. this.texture = this._originalTexture = a;
  4536. this.setTextureRect(b,
  4537. this._rectRotated);
  4538. this.batchNode = this._batchNode;
  4539. this._callLoadedEventCallbacks()
  4540. }
  4541. }, _p.setTextureRect = function (a, b, c) {
  4542. this._rectRotated = b || !1;
  4543. this.setContentSize(c || a);
  4544. this.setVertexRect(a);
  4545. b = this._textureRect_Canvas;
  4546. c = cc.contentScaleFactor();
  4547. b.x = 0 | a.x * c;
  4548. b.y = 0 | a.y * c;
  4549. b.width = 0 | a.width * c;
  4550. b.height = 0 | a.height * c;
  4551. b.validRect = !(0 === b.width || 0 === b.height || 0 > b.x || 0 > b.y);
  4552. a = this._unflippedOffsetPositionFromCenter;
  4553. this._flippedX && (a.x = -a.x);
  4554. this._flippedY && (a.y = -a.y);
  4555. this._offsetPosition.x = a.x + (this._contentSize.width -
  4556. this._rect.width) / 2;
  4557. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  4558. this._batchNode && (this.dirty = !0)
  4559. }, _p.updateTransform = function () {
  4560. if (this.dirty) {
  4561. var a = this._parent;
  4562. !this._visible || a && a != this._batchNode && a._shouldBeHidden ? this._shouldBeHidden = !0 : (this._shouldBeHidden = !1, this._transformToBatch = !a || a == this._batchNode ? this.nodeToParentTransform() : cc.AffineTransformConcat(this.nodeToParentTransform(), a._transformToBatch));
  4563. this.dirty = this._recursiveDirty = !1
  4564. }
  4565. this._hasChildren &&
  4566. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
  4567. }, _p.addChild = function (a, b, c) {
  4568. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2);
  4569. null == b && (b = a._localZOrder);
  4570. null == c && (c = a.tag);
  4571. cc.NodeRGBA.prototype.addChild.call(this, a, b, c);
  4572. this._hasChildren = !0
  4573. }, _p.setOpacity = function (a) {
  4574. cc.NodeRGBA.prototype.setOpacity.call(this, a);
  4575. this._setNodeDirtyForCache()
  4576. }, _p.setColor = function (a) {
  4577. var b = this.color;
  4578. b.r === a.r && b.g === a.g && b.b === a.b || (cc.NodeRGBA.prototype.setColor.call(this,
  4579. a), this._changeTextureColor(), this._setNodeDirtyForCache())
  4580. }, _p.updateDisplayedColor = function (a) {
  4581. var b = this.color;
  4582. cc.NodeRGBA.prototype.updateDisplayedColor.call(this, a);
  4583. a = this._displayedColor;
  4584. b.r === a.r && b.g === a.g && b.b === a.b || (this._changeTextureColor(), this._setNodeDirtyForCache())
  4585. }, _p.setSpriteFrame = function (a) {
  4586. var b = this;
  4587. "string" == typeof a && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame));
  4588. b.setNodeDirty(!0);
  4589. var c = a.getOffset();
  4590. b._unflippedOffsetPositionFromCenter.x =
  4591. c.x;
  4592. b._unflippedOffsetPositionFromCenter.y = c.y;
  4593. b._rectRotated = a.isRotated();
  4594. var c = a.getTexture(), d = a.textureLoaded();
  4595. d || (b._textureLoaded = !1, a.addLoadedEventListener(function (a) {
  4596. b._textureLoaded = !0;
  4597. var c = a.getTexture();
  4598. c != b._texture && (b.texture = c);
  4599. b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  4600. b._callLoadedEventCallbacks()
  4601. }, b));
  4602. c != b._texture && (b.texture = c);
  4603. b._rectRotated && (b._originalTexture = c);
  4604. b.setTextureRect(a.getRect(), b._rectRotated, a.getOriginalSize());
  4605. b._colorized = !1;
  4606. d && (a =
  4607. b.color, (255 !== a.r || 255 !== a.g || 255 !== a.b) && b._changeTextureColor())
  4608. }, _p.isFrameDisplayed = function (a) {
  4609. return a.getTexture() != this._texture ? !1 : cc.rectEqualToRect(a.getRect(), this._rect)
  4610. }, _p.setBatchNode = function (a) {
  4611. (this._batchNode = a) ? (this._transformToBatch = cc.AffineTransformIdentity(), this.textureAtlas = this._batchNode.textureAtlas) : (this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED, this.textureAtlas = null, this.dirty = this._recursiveDirty = !1)
  4612. }, _p.setTexture = function (a) {
  4613. a && "string" === typeof a ? (a = cc.textureCache.addImage(a),
  4614. this.setTexture(a), a = a.getContentSize(), this.setTextureRect(cc.rect(0, 0, a.width, a.height))) : (cc.assert(!a || a instanceof cc.Texture2D, cc._LogInfos.CCSpriteBatchNode_setTexture), this._texture != a && (a && a.getHtmlElementObj()instanceof HTMLImageElement && (this._originalTexture = a), this._texture = a))
  4615. }, _p.draw = function (a) {
  4616. if (this._textureLoaded) {
  4617. a = a || cc._renderContext;
  4618. this._isLighterMode && (a.globalCompositeOperation = "lighter");
  4619. var b = cc.view.getScaleX(), c = cc.view.getScaleY();
  4620. a.globalAlpha = this._displayedOpacity /
  4621. 255;
  4622. var d = this._rect, e = this._contentSize, f = this._offsetPosition, g = this._drawSize_Canvas, h = 0 | f.x, k = -f.y - d.height, l = this._textureRect_Canvas;
  4623. g.width = d.width * b;
  4624. g.height = d.height * c;
  4625. if (this._flippedX || this._flippedY)a.save(), this._flippedX && (h = -f.x - d.width, a.scale(-1, 1)), this._flippedY && (k = f.y, a.scale(1, -1));
  4626. h *= b;
  4627. k *= c;
  4628. this._texture && l.validRect ? (e = this._texture.getHtmlElementObj(), this._colorized ? a.drawImage(e, 0, 0, l.width, l.height, h, k, g.width, g.height) : a.drawImage(e, l.x, l.y, l.width, l.height, h, k, g.width,
  4629. g.height)) : !this._texture && l.validRect && (g = this.color, a.fillStyle = "rgba(" + g.r + "," + g.g + "," + g.b + ",1)", a.fillRect(h, k, e.width * b, e.height * c));
  4630. 1 === cc.SPRITE_DEBUG_DRAW || this._showNode ? (a.strokeStyle = "rgba(0,255,0,1)", h /= b, k = -(k / c), h = [cc.p(h, k), cc.p(h + d.width, k), cc.p(h + d.width, k - d.height), cc.p(h, k - d.height)], cc._drawingUtil.drawPoly(h, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (a.strokeStyle = "rgba(0,255,0,1)", b = this._rect, k = -k, h = [cc.p(h, k), cc.p(h + b.width, k), cc.p(h + b.width, k - b.height), cc.p(h, k - b.height)], cc._drawingUtil.drawPoly(h,
  4631. 4, !0));
  4632. (this._flippedX || this._flippedY) && a.restore();
  4633. cc.g_NumberOfDraws++
  4634. }
  4635. }, delete _p) : (cc.assert("function" === typeof cc._tmp.WebGLSprite, cc._LogInfos.MissingFile, "SpritesWebGL.js"), cc._tmp.WebGLSprite(), delete cc._tmp.WebGLSprite);
  4636. cc.assert("function" === typeof cc._tmp.PrototypeSprite, cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
  4637. cc._tmp.PrototypeSprite();
  4638. delete cc._tmp.PrototypeSprite;
  4639. cc.AnimationFrame = cc.Class.extend({_spriteFrame: null, _delayPerUnit: 0, _userInfo: null, ctor: function (a, b, c) {
  4640. this._spriteFrame = a || null;
  4641. this._delayPerUnit = b || 0;
  4642. this._userInfo = c || null
  4643. }, clone: function () {
  4644. var a = new cc.AnimationFrame;
  4645. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  4646. return a
  4647. }, copyWithZone: function (a) {
  4648. return cc.clone(this)
  4649. }, copy: function (a) {
  4650. a = new cc.AnimationFrame;
  4651. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  4652. return a
  4653. }, initWithSpriteFrame: function (a, b, c) {
  4654. this._spriteFrame = a;
  4655. this._delayPerUnit = b;
  4656. this._userInfo = c;
  4657. return!0
  4658. }, getSpriteFrame: function () {
  4659. return this._spriteFrame
  4660. }, setSpriteFrame: function (a) {
  4661. this._spriteFrame = a
  4662. }, getDelayUnits: function () {
  4663. return this._delayPerUnit
  4664. }, setDelayUnits: function (a) {
  4665. this._delayPerUnit = a
  4666. }, getUserInfo: function () {
  4667. return this._userInfo
  4668. }, setUserInfo: function (a) {
  4669. this._userInfo = a
  4670. }});
  4671. cc.AnimationFrame.create = function (a, b, c) {
  4672. return new cc.AnimationFrame(a, b, c)
  4673. };
  4674. cc.Animation = cc.Class.extend({_frames: null, _loops: 0, _restoreOriginalFrame: !1, _duration: 0, _delayPerUnit: 0, _totalDelayUnits: 0, ctor: function (a, b, c) {
  4675. this._frames = [];
  4676. if (void 0 === a)this.initWithSpriteFrames(null, 0); else {
  4677. var d = a[0];
  4678. d && (d instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, b, c) : d instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, b, c))
  4679. }
  4680. }, getFrames: function () {
  4681. return this._frames
  4682. }, setFrames: function (a) {
  4683. this._frames = a
  4684. }, addSpriteFrame: function (a) {
  4685. var b = new cc.AnimationFrame;
  4686. b.initWithSpriteFrame(a,
  4687. 1, null);
  4688. this._frames.push(b);
  4689. this._totalDelayUnits++
  4690. }, addSpriteFrameWithFile: function (a) {
  4691. a = cc.textureCache.addImage(a);
  4692. var b = cc.rect(0, 0, 0, 0);
  4693. b.width = a.width;
  4694. b.height = a.height;
  4695. a = cc.SpriteFrame.create(a, b);
  4696. this.addSpriteFrame(a)
  4697. }, addSpriteFrameWithTexture: function (a, b) {
  4698. var c = cc.SpriteFrame.create(a, b);
  4699. this.addSpriteFrame(c)
  4700. }, initWithAnimationFrames: function (a, b, c) {
  4701. cc.arrayVerifyType(a, cc.AnimationFrame);
  4702. this._delayPerUnit = b;
  4703. this._loops = void 0 === c ? 1 : c;
  4704. this._totalDelayUnits = 0;
  4705. b = this._frames;
  4706. for (c = b.length =
  4707. 0; c < a.length; c++) {
  4708. var d = a[c];
  4709. b.push(d);
  4710. this._totalDelayUnits += d.getDelayUnits()
  4711. }
  4712. return!0
  4713. }, clone: function () {
  4714. var a = new cc.Animation;
  4715. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  4716. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  4717. return a
  4718. }, copyWithZone: function (a) {
  4719. a = new cc.Animation;
  4720. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  4721. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  4722. return a
  4723. }, _copyFrames: function () {
  4724. for (var a = [], b = 0; b < this._frames.length; b++)a.push(this._frames[b].clone());
  4725. return a
  4726. }, copy: function (a) {
  4727. return this.copyWithZone(null)
  4728. }, getLoops: function () {
  4729. return this._loops
  4730. }, setLoops: function (a) {
  4731. this._loops = a
  4732. }, setRestoreOriginalFrame: function (a) {
  4733. this._restoreOriginalFrame = a
  4734. }, getRestoreOriginalFrame: function () {
  4735. return this._restoreOriginalFrame
  4736. }, getDuration: function () {
  4737. return this._totalDelayUnits * this._delayPerUnit
  4738. }, getDelayPerUnit: function () {
  4739. return this._delayPerUnit
  4740. }, setDelayPerUnit: function (a) {
  4741. this._delayPerUnit = a
  4742. }, getTotalDelayUnits: function () {
  4743. return this._totalDelayUnits
  4744. },
  4745. initWithSpriteFrames: function (a, b, c) {
  4746. cc.arrayVerifyType(a, cc.SpriteFrame);
  4747. this._loops = void 0 === c ? 1 : c;
  4748. this._delayPerUnit = b || 0;
  4749. this._totalDelayUnits = 0;
  4750. b = this._frames;
  4751. b.length = 0;
  4752. if (a) {
  4753. for (c = 0; c < a.length; c++) {
  4754. var d = a[c], e = new cc.AnimationFrame;
  4755. e.initWithSpriteFrame(d, 1, null);
  4756. b.push(e)
  4757. }
  4758. this._totalDelayUnits += a.length
  4759. }
  4760. return!0
  4761. }, retain: function () {
  4762. }, release: function () {
  4763. }});
  4764. cc.Animation.create = function (a, b, c) {
  4765. return new cc.Animation(a, b, c)
  4766. };
  4767. cc.animationCache = {_animations: {}, addAnimation: function (a, b) {
  4768. this._animations[b] = a
  4769. }, removeAnimation: function (a) {
  4770. a && this._animations[a] && delete this._animations[a]
  4771. }, getAnimation: function (a) {
  4772. return this._animations[a] ? this._animations[a] : null
  4773. }, _addAnimationsWithDictionary: function (a, b) {
  4774. var c = a.animations;
  4775. if (c) {
  4776. var d = 1, e = a.properties;
  4777. if (e)for (var d = null != e.format ? parseInt(e.format) : d, e = e.spritesheets, f = cc.spriteFrameCache, g = cc.path, h = 0; h < e.length; h++)f.addSpriteFrames(g.changeBasename(b, e[h]));
  4778. switch (d) {
  4779. case 1:
  4780. this._parseVersion1(c);
  4781. break;
  4782. case 2:
  4783. this._parseVersion2(c);
  4784. break;
  4785. default:
  4786. cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)
  4787. }
  4788. } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)
  4789. }, addAnimations: function (a) {
  4790. cc.assert(a, cc._LogInfos.animationCache_addAnimations_2);
  4791. var b = cc.loader.getRes(a);
  4792. b ? this._addAnimationsWithDictionary(b, a) : cc.log(cc._LogInfos.animationCache_addAnimations)
  4793. }, _parseVersion1: function (a) {
  4794. var b = cc.spriteFrameCache, c;
  4795. for (c in a) {
  4796. var d = a[c], e = d.frames, d = parseFloat(d.delay) ||
  4797. 0, f = null;
  4798. if (e) {
  4799. for (var f = [], g = 0; g < e.length; g++) {
  4800. var h = b.getSpriteFrame(e[g]);
  4801. if (h) {
  4802. var k = new cc.AnimationFrame;
  4803. k.initWithSpriteFrame(h, 1, null);
  4804. f.push(k)
  4805. } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, c, e[g])
  4806. }
  4807. 0 === f.length ? cc.log(cc._LogInfos.animationCache__parseVersion1_3, c) : (f.length != e.length && cc.log(cc._LogInfos.animationCache__parseVersion1_4, c), f = cc.Animation.create(f, d, 1), cc.animationCache.addAnimation(f, c))
  4808. } else cc.log(cc._LogInfos.animationCache__parseVersion1, c)
  4809. }
  4810. }, _parseVersion2: function (a) {
  4811. var b =
  4812. cc.spriteFrameCache, c;
  4813. for (c in a) {
  4814. var d = a[c], e = d.loop, f = parseInt(d.loops), e = e ? cc.REPEAT_FOREVER : isNaN(f) ? 1 : f, f = d.restoreOriginalFrame && !0 == d.restoreOriginalFrame ? !0 : !1, g = d.frames;
  4815. if (g) {
  4816. for (var h = [], k = 0; k < g.length; k++) {
  4817. var l = g[k], m = l.spriteframe, n = b.getSpriteFrame(m);
  4818. if (n) {
  4819. var m = parseFloat(l.delayUnits) || 0, l = l.notification, q = new cc.AnimationFrame;
  4820. q.initWithSpriteFrame(n, m, l);
  4821. h.push(q)
  4822. } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, c, m)
  4823. }
  4824. d = parseFloat(d.delayPerUnit) || 0;
  4825. g = new cc.Animation;
  4826. g.initWithAnimationFrames(h,
  4827. d, e);
  4828. g.setRestoreOriginalFrame(f);
  4829. cc.animationCache.addAnimation(g, c)
  4830. } else cc.log(cc._LogInfos.animationCache__parseVersion2, c)
  4831. }
  4832. }, _clear: function () {
  4833. this._animations = {}
  4834. }};
  4835. cc.SpriteFrame = cc.Class.extend({_offset: null, _originalSize: null, _rectInPixels: null, _rotated: !1, _rect: null, _offsetInPixels: null, _originalSizeInPixels: null, _texture: null, _textureFilename: "", _textureLoaded: !1, _eventListeners: null, ctor: function (a, b, c, d, e) {
  4836. this._offset = cc.p(0, 0);
  4837. this._offsetInPixels = cc.p(0, 0);
  4838. this._originalSize = cc.size(0, 0);
  4839. this._rotated = !1;
  4840. this._originalSizeInPixels = cc.size(0, 0);
  4841. this._textureFilename = "";
  4842. this._texture = null;
  4843. this._textureLoaded = !1;
  4844. void 0 !== a && void 0 !== b && (void 0 === c || void 0 ===
  4845. d || void 0 === e ? this.initWithTexture(a, b) : this.initWithTexture(a, b, c, d, e))
  4846. }, textureLoaded: function () {
  4847. return this._textureLoaded
  4848. }, addLoadedEventListener: function (a, b) {
  4849. null == this._eventListeners && (this._eventListeners = []);
  4850. this._eventListeners.push({eventCallback: a, eventTarget: b})
  4851. }, _callLoadedEventCallbacks: function () {
  4852. var a = this._eventListeners;
  4853. if (a) {
  4854. for (var b = 0, c = a.length; b < c; b++) {
  4855. var d = a[b];
  4856. d.eventCallback.call(d.eventTarget, this)
  4857. }
  4858. a.length = 0
  4859. }
  4860. }, getRectInPixels: function () {
  4861. var a = this._rectInPixels;
  4862. return cc.rect(a.x,
  4863. a.y, a.width, a.height)
  4864. }, setRectInPixels: function (a) {
  4865. this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0));
  4866. this._rectInPixels.x = a.x;
  4867. this._rectInPixels.y = a.y;
  4868. this._rectInPixels.width = a.width;
  4869. this._rectInPixels.height = a.height;
  4870. this._rect = cc.rectPixelsToPoints(a)
  4871. }, isRotated: function () {
  4872. return this._rotated
  4873. }, setRotated: function (a) {
  4874. this._rotated = a
  4875. }, getRect: function () {
  4876. var a = this._rect;
  4877. return cc.rect(a.x, a.y, a.width, a.height)
  4878. }, setRect: function (a) {
  4879. this._rect || (this._rect = cc.rect(0, 0, 0, 0));
  4880. this._rect.x = a.x;
  4881. this._rect.y = a.y;
  4882. this._rect.width = a.width;
  4883. this._rect.height = a.height;
  4884. this._rectInPixels = cc.rectPointsToPixels(this._rect)
  4885. }, getOffsetInPixels: function () {
  4886. return this._offsetInPixels
  4887. }, setOffsetInPixels: function (a) {
  4888. this._offsetInPixels.x = a.x;
  4889. this._offsetInPixels.y = a.y;
  4890. cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset)
  4891. }, getOriginalSizeInPixels: function () {
  4892. return this._originalSizeInPixels
  4893. }, setOriginalSizeInPixels: function (a) {
  4894. this._originalSizeInPixels.width = a.width;
  4895. this._originalSizeInPixels.height =
  4896. a.height
  4897. }, getOriginalSize: function () {
  4898. return this._originalSize
  4899. }, setOriginalSize: function (a) {
  4900. this._originalSize.width = a.width;
  4901. this._originalSize.height = a.height
  4902. }, getTexture: function () {
  4903. if (this._texture)return this._texture;
  4904. if ("" !== this._textureFilename) {
  4905. var a = cc.textureCache.addImage(this._textureFilename);
  4906. a && (this._textureLoaded = a.isLoaded());
  4907. return a
  4908. }
  4909. return null
  4910. }, setTexture: function (a) {
  4911. if (this._texture != a) {
  4912. var b = a.isLoaded();
  4913. this._textureLoaded = b;
  4914. this._texture = a;
  4915. b || a.addLoadedEventListener(function (a) {
  4916. this._textureLoaded = !0;
  4917. if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) {
  4918. var b = a.getHtmlElementObj(), b = cc.cutRotateImageToCanvas(b, this.getRect()), e = new cc.Texture2D;
  4919. e.initWithElement(b);
  4920. e.handleLoadedTexture();
  4921. this.setTexture(e);
  4922. b = this.getRect();
  4923. this.setRect(cc.rect(0, 0, b.width, b.height))
  4924. }
  4925. b = this._rect;
  4926. 0 === b.width && 0 === b.height && (b = a.width, a = a.height, this._rect.width = b, this._rect.height = a, this._rectInPixels = cc.rectPointsToPixels(this._rect), this._originalSizeInPixels.width = this._rectInPixels.width, this._originalSizeInPixels.height =
  4927. this._rectInPixels.height, this._originalSize.width = b, this._originalSize.height = a);
  4928. this._callLoadedEventCallbacks()
  4929. }, this)
  4930. }
  4931. }, getOffset: function () {
  4932. return this._offset
  4933. }, setOffset: function (a) {
  4934. this._offset.x = a.x;
  4935. this._offset.y = a.y
  4936. }, clone: function () {
  4937. var a = new cc.SpriteFrame;
  4938. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  4939. a.setTexture(this._texture);
  4940. return a
  4941. }, copyWithZone: function () {
  4942. var a = new cc.SpriteFrame;
  4943. a.initWithTexture(this._textureFilename,
  4944. this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  4945. a.setTexture(this._texture);
  4946. return a
  4947. }, copy: function () {
  4948. return this.copyWithZone()
  4949. }, initWithTexture: function (a, b, c, d, e) {
  4950. 2 === arguments.length && (b = cc.rectPointsToPixels(b));
  4951. d = d || cc.p(0, 0);
  4952. e = e || b;
  4953. c = c || !1;
  4954. "string" == typeof a ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a);
  4955. if (a = this.getTexture()) {
  4956. var f, g;
  4957. c ? (f = b.x + b.height, g = b.y + b.width) : (f = b.x + b.width, g = b.y + b.height);
  4958. f > a.width && cc.error(cc._LogInfos.RectWidth,
  4959. a.url);
  4960. g > a.height && cc.error(cc._LogInfos.RectHeight, a.url)
  4961. }
  4962. this._rectInPixels = b;
  4963. this._rect = cc.rectPixelsToPoints(b);
  4964. this._offsetInPixels.x = d.x;
  4965. this._offsetInPixels.y = d.y;
  4966. cc._pointPixelsToPointsOut(d, this._offset);
  4967. this._originalSizeInPixels.width = e.width;
  4968. this._originalSizeInPixels.height = e.height;
  4969. cc._sizePixelsToPointsOut(e, this._originalSize);
  4970. this._rotated = c;
  4971. return!0
  4972. }});
  4973. cc.SpriteFrame.create = function (a, b, c, d, e) {
  4974. return new cc.SpriteFrame(a, b, c, d, e)
  4975. };
  4976. cc.SpriteFrame._frameWithTextureForCanvas = function (a, b, c, d, e) {
  4977. var f = new cc.SpriteFrame;
  4978. f._texture = a;
  4979. f._rectInPixels = b;
  4980. f._rect = cc.rectPixelsToPoints(b);
  4981. f._offsetInPixels.x = d.x;
  4982. f._offsetInPixels.y = d.y;
  4983. cc._pointPixelsToPointsOut(f._offsetInPixels, f._offset);
  4984. f._originalSizeInPixels.width = e.width;
  4985. f._originalSizeInPixels.height = e.height;
  4986. cc._sizePixelsToPointsOut(f._originalSizeInPixels, f._originalSize);
  4987. f._rotated = c;
  4988. return f
  4989. };
  4990. cc.spriteFrameCache = {_CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/, _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/, _spriteFrames: {}, _spriteFramesAliases: {}, _frameConfigCache: {}, _rectFromString: function (a) {
  4991. a = this._CCNS_REG2.exec(a);
  4992. return!a ? cc.rect(0, 0, 0, 0) : cc.rect(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]), parseFloat(a[4]))
  4993. }, _pointFromString: function (a) {
  4994. a = this._CCNS_REG1.exec(a);
  4995. return!a ? cc.p(0, 0) : cc.p(parseFloat(a[1]), parseFloat(a[2]))
  4996. }, _sizeFromString: function (a) {
  4997. a = this._CCNS_REG1.exec(a);
  4998. return!a ? cc.size(0, 0) : cc.size(parseFloat(a[1]), parseFloat(a[2]))
  4999. }, _getFrameConfig: function (a) {
  5000. var b = cc.loader.getRes(a);
  5001. cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a);
  5002. cc.loader.release(a);
  5003. if (b._inited)return this._frameConfigCache[a] = b;
  5004. var c = b.frames, d = b.metadata || b.meta, b = {}, e = {}, f = 0;
  5005. d && (f = d.format, f = 1 >= f.length ? parseInt(f) : f, e.image = d.textureFileName || d.textureFileName ||
  5006. d.image);
  5007. for (var g in c) {
  5008. var h = c[g];
  5009. if (h) {
  5010. d = {};
  5011. if (0 == f) {
  5012. d.rect = cc.rect(h.x, h.y, h.width, h.height);
  5013. d.rotated = !1;
  5014. d.offset = cc.p(h.offsetX, h.offsetY);
  5015. var k = h.originalWidth, h = h.originalHeight;
  5016. (!k || !h) && cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);
  5017. k = Math.abs(k);
  5018. h = Math.abs(h);
  5019. d.size = cc.size(k, h)
  5020. } else if (1 == f || 2 == f)d.rect = this._rectFromString(h.frame), d.rotated = h.rotated || !1, d.offset = this._pointFromString(h.offset), d.size = this._sizeFromString(h.sourceSize); else if (3 == f) {
  5021. var k = this._sizeFromString(h.spriteSize),
  5022. l = this._rectFromString(h.textureRect);
  5023. k && (l = cc.rect(l.x, l.y, k.width, k.height));
  5024. d.rect = l;
  5025. d.rotated = h.textureRotated || !1;
  5026. d.offset = this._pointFromString(h.spriteOffset);
  5027. d.size = this._sizeFromString(h.spriteSourceSize);
  5028. d.aliases = h.aliases
  5029. } else k = h.frame, l = h.sourceSize, g = h.filename || g, d.rect = cc.rect(k.x, k.y, k.w, k.h), d.rotated = h.rotated || !1, d.offset = cc.p(0, 0), d.size = cc.size(l.w, l.h);
  5030. b[g] = d
  5031. }
  5032. }
  5033. return this._frameConfigCache[a] = {_inited: !0, frames: b, meta: e}
  5034. }, addSpriteFrames: function (a, b) {
  5035. cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
  5036. var c = this._frameConfigCache[a] || cc.loader.getRes(a);
  5037. if (c && c.frames) {
  5038. var d = this._frameConfigCache[a] || this._getFrameConfig(a), c = d.frames, d = d.meta;
  5039. b ? b instanceof cc.Texture2D || ("string" == typeof b ? b = cc.textureCache.addImage(b) : cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3)) : (d = cc.path.changeBasename(a, d.image || ".png"), b = cc.textureCache.addImage(d));
  5040. var d = this._spriteFramesAliases, e = this._spriteFrames, f;
  5041. for (f in c) {
  5042. var g = c[f], h = e[f];
  5043. if (!h) {
  5044. h = cc.SpriteFrame.create(b, g.rect, g.rotated, g.offset,
  5045. g.size);
  5046. if (g = g.aliases)for (var k = 0, l = g.length; k < l; k++) {
  5047. var m = g[k];
  5048. d[m] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, m);
  5049. d[m] = f
  5050. }
  5051. cc._renderType === cc._RENDER_TYPE_CANVAS && h.isRotated() && h.getTexture().isLoaded() && (g = h.getTexture().getHtmlElementObj(), g = cc.cutRotateImageToCanvas(g, h.getRectInPixels()), k = new cc.Texture2D, k.initWithElement(g), k.handleLoadedTexture(), h.setTexture(k), g = h._rect, h.setRect(cc.rect(0, 0, g.width, g.height)));
  5052. e[f] = h
  5053. }
  5054. }
  5055. }
  5056. }, _checkConflict: function (a) {
  5057. a = a.frames;
  5058. for (var b in a)this._spriteFrames[b] &&
  5059. cc.log(cc._LogInfos.spriteFrameCache__checkConflict, b)
  5060. }, addSpriteFrame: function (a, b) {
  5061. this._spriteFrames[b] = a
  5062. }, removeSpriteFrames: function () {
  5063. this._spriteFrames = {};
  5064. this._spriteFramesAliases = {}
  5065. }, removeSpriteFrameByName: function (a) {
  5066. a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a])
  5067. }, removeSpriteFramesFromFile: function (a) {
  5068. var b = this._spriteFrames, c = this._spriteFramesAliases;
  5069. if (a = this._frameConfigCache[a]) {
  5070. a = a.frames;
  5071. for (var d in a)if (b[d]) {
  5072. delete b[d];
  5073. for (var e in c)c[e] == d && delete c[e]
  5074. }
  5075. }
  5076. }, removeSpriteFramesFromTexture: function (a) {
  5077. var b = this._spriteFrames, c = this._spriteFramesAliases, d;
  5078. for (d in b) {
  5079. var e = b[d];
  5080. if (e && e.getTexture() == a) {
  5081. delete b[d];
  5082. for (var f in c)c[f] == d && delete c[f]
  5083. }
  5084. }
  5085. }, getSpriteFrame: function (a) {
  5086. var b = this._spriteFrames[a];
  5087. if (!b) {
  5088. var c = this._spriteFramesAliases[a];
  5089. c && ((b = this._spriteFrames[c.toString()]) || delete this._spriteFramesAliases[a])
  5090. }
  5091. b || cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame, a);
  5092. return b
  5093. }, _clear: function () {
  5094. this._spriteFrames =
  5095. {};
  5096. this._spriteFramesAliases = {};
  5097. this._frameConfigCache = {}
  5098. }};
  5099. cc.g_NumberOfDraws = 0;
  5100. cc.GLToClipTransform = function (a) {
  5101. var b = new cc.kmMat4;
  5102. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, b);
  5103. var c = new cc.kmMat4;
  5104. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, c);
  5105. cc.kmMat4Multiply(a, b, c)
  5106. };
  5107. cc.Director = cc.Class.extend({_landscape: !1, _nextDeltaTimeZero: !1, _paused: !1, _purgeDirectorInNextLoop: !1, _sendCleanupToScene: !1, _animationInterval: 0, _oldAnimationInterval: 0, _projection: 0, _accumDt: 0, _contentScaleFactor: 1, _displayStats: !1, _deltaTime: 0, _frameRate: 0, _FPSLabel: null, _SPFLabel: null, _drawsLabel: null, _winSizeInPoints: null, _lastUpdate: null, _nextScene: null, _notificationNode: null, _openGLView: null, _scenesStack: null, _projectionDelegate: null, _runningScene: null, _frames: 0, _totalFrames: 0, _secondsPerFrame: 0,
  5108. _dirtyRegion: null, _scheduler: null, _actionManager: null, _eventProjectionChanged: null, _eventAfterDraw: null, _eventAfterVisit: null, _eventAfterUpdate: null, ctor: function () {
  5109. var a = this;
  5110. a._lastUpdate = Date.now();
  5111. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () {
  5112. a._lastUpdate = Date.now()
  5113. })
  5114. }, init: function () {
  5115. this._oldAnimationInterval = this._animationInterval = 1 / cc.defaultFPS;
  5116. this._scenesStack = [];
  5117. this._projection = cc.Director.PROJECTION_DEFAULT;
  5118. this._projectionDelegate = null;
  5119. this._frameRate = this._accumDt =
  5120. 0;
  5121. this._displayStats = !1;
  5122. this._totalFrames = this._frames = 0;
  5123. this._lastUpdate = Date.now();
  5124. this._purgeDirectorInNextLoop = this._paused = !1;
  5125. this._winSizeInPoints = cc.size(0, 0);
  5126. this._openGLView = null;
  5127. this._contentScaleFactor = 1;
  5128. this._scheduler = new cc.Scheduler;
  5129. this._actionManager = cc.ActionManager ? new cc.ActionManager : null;
  5130. this._scheduler.scheduleUpdateForTarget(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
  5131. this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
  5132. this._eventAfterDraw.setUserData(this);
  5133. this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);
  5134. this._eventAfterVisit.setUserData(this);
  5135. this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);
  5136. this._eventAfterUpdate.setUserData(this);
  5137. this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);
  5138. this._eventProjectionChanged.setUserData(this);
  5139. return!0
  5140. }, calculateDeltaTime: function () {
  5141. var a = Date.now();
  5142. this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime =
  5143. (a - this._lastUpdate) / 1E3;
  5144. 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60);
  5145. this._lastUpdate = a
  5146. }, drawScene: function () {
  5147. this.calculateDeltaTime();
  5148. this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate));
  5149. this._clear();
  5150. this._nextScene && this.setNextScene();
  5151. this._beforeVisitScene && this._beforeVisitScene();
  5152. this._runningScene && (this._runningScene.visit(), cc.eventManager.dispatchEvent(this._eventAfterVisit));
  5153. this._notificationNode &&
  5154. this._notificationNode.visit();
  5155. this._displayStats && this._showStats();
  5156. this._afterVisitScene && this._afterVisitScene();
  5157. cc.eventManager.dispatchEvent(this._eventAfterDraw);
  5158. this._totalFrames++;
  5159. this._displayStats && this._calculateMPF()
  5160. }, _beforeVisitScene: null, _afterVisitScene: null, end: function () {
  5161. this._purgeDirectorInNextLoop = !0
  5162. }, getContentScaleFactor: function () {
  5163. return this._contentScaleFactor
  5164. }, getNotificationNode: function () {
  5165. return this._notificationNode
  5166. }, getWinSize: function () {
  5167. return this._winSizeInPoints
  5168. },
  5169. getWinSizeInPixels: function () {
  5170. return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor)
  5171. }, pause: function () {
  5172. this._paused || (this._oldAnimationInterval = this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0)
  5173. }, popScene: function () {
  5174. cc.assert(this._runningScene, cc._LogInfos.Director_popScene);
  5175. this._scenesStack.pop();
  5176. var a = this._scenesStack.length;
  5177. 0 == a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a -
  5178. 1])
  5179. }, purgeCachedData: function () {
  5180. cc.animationCache._clear();
  5181. cc.spriteFrameCache._clear();
  5182. cc.textureCache._clear()
  5183. }, purgeDirector: function () {
  5184. this.getScheduler().unscheduleAllCallbacks();
  5185. cc.eventManager && cc.eventManager.setEnabled(!1);
  5186. this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup());
  5187. this._nextScene = this._runningScene = null;
  5188. this._scenesStack.length = 0;
  5189. this.stopAnimation();
  5190. this.purgeCachedData();
  5191. cc.checkGLErrorDebug()
  5192. }, pushScene: function (a) {
  5193. cc.assert(a,
  5194. cc._LogInfos.Director_pushScene);
  5195. this._sendCleanupToScene = !1;
  5196. this._scenesStack.push(a);
  5197. this._nextScene = a
  5198. }, runScene: function (a) {
  5199. cc.assert(a, cc._LogInfos.Director_pushScene);
  5200. if (this._runningScene) {
  5201. var b = this._scenesStack.length;
  5202. 0 === b ? (this._sendCleanupToScene = !0, this._scenesStack[b] = a) : (this._sendCleanupToScene = !0, this._scenesStack[b - 1] = a);
  5203. this._nextScene = a
  5204. } else this.pushScene(a), this.startAnimation()
  5205. }, resume: function () {
  5206. this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate =
  5207. Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0)
  5208. }, setContentScaleFactor: function (a) {
  5209. a != this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel())
  5210. }, setDefaultValues: function () {
  5211. }, setNextDeltaTimeZero: function (a) {
  5212. this._nextDeltaTimeZero = a
  5213. }, setNextScene: function () {
  5214. var a = !1, b = !1;
  5215. cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, b = this._nextScene ? this._nextScene instanceof cc.TransitionScene : !1);
  5216. if (!b) {
  5217. if (b =
  5218. this._runningScene)b.onExitTransitionDidStart(), b.onExit();
  5219. this._sendCleanupToScene && b && b.cleanup()
  5220. }
  5221. this._runningScene = this._nextScene;
  5222. this._nextScene = null;
  5223. !a && null != this._runningScene && (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish())
  5224. }, setNotificationNode: function (a) {
  5225. this._notificationNode = a
  5226. }, getDelegate: function () {
  5227. return this._projectionDelegate
  5228. }, setDelegate: function (a) {
  5229. this._projectionDelegate = a
  5230. }, _showStats: function () {
  5231. this._frames++;
  5232. this._accumDt += this._deltaTime;
  5233. this._FPSLabel &&
  5234. this._SPFLabel && this._drawsLabel ? (this._accumDt > cc.DIRECTOR_FPS_INTERVAL && (this._SPFLabel.string = this._secondsPerFrame.toFixed(3), this._frameRate = this._frames / this._accumDt, this._accumDt = this._frames = 0, this._FPSLabel.string = this._frameRate.toFixed(1), this._drawsLabel.string = (0 | cc.g_NumberOfDraws).toString()), this._FPSLabel.visit(), this._SPFLabel.visit(), this._drawsLabel.visit()) : this._createStatsLabel();
  5235. cc.g_NumberOfDraws = 0
  5236. }, isSendCleanupToScene: function () {
  5237. return this._sendCleanupToScene
  5238. }, getRunningScene: function () {
  5239. return this._runningScene
  5240. },
  5241. getAnimationInterval: function () {
  5242. return this._animationInterval
  5243. }, isDisplayStats: function () {
  5244. return this._displayStats
  5245. }, setDisplayStats: function (a) {
  5246. this._displayStats = a
  5247. }, getSecondsPerFrame: function () {
  5248. return this._secondsPerFrame
  5249. }, isNextDeltaTimeZero: function () {
  5250. return this._nextDeltaTimeZero
  5251. }, isPaused: function () {
  5252. return this._paused
  5253. }, getTotalFrames: function () {
  5254. return this._totalFrames
  5255. }, popToRootScene: function () {
  5256. this.popToSceneStackLevel(1)
  5257. }, popToSceneStackLevel: function (a) {
  5258. cc.assert(this._runningScene,
  5259. cc._LogInfos.Director_popToSceneStackLevel_2);
  5260. var b = this._scenesStack, c = b.length;
  5261. if (0 == c)this.end(); else if (!(a > c)) {
  5262. for (; c > a;) {
  5263. var d = b.pop();
  5264. d.running && (d.onExitTransitionDidStart(), d.onExit());
  5265. d.cleanup();
  5266. c--
  5267. }
  5268. this._nextScene = b[b.length - 1];
  5269. this._sendCleanupToScene = !1
  5270. }
  5271. }, getScheduler: function () {
  5272. return this._scheduler
  5273. }, setScheduler: function (a) {
  5274. this._scheduler != a && (this._scheduler = a)
  5275. }, getActionManager: function () {
  5276. return this._actionManager
  5277. }, setActionManager: function (a) {
  5278. this._actionManager != a && (this._actionManager =
  5279. a)
  5280. }, getDeltaTime: function () {
  5281. return this._deltaTime
  5282. }, _createStatsLabel: null, _calculateMPF: function () {
  5283. this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3
  5284. }});
  5285. cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
  5286. cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
  5287. cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
  5288. cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
  5289. cc.DisplayLinkDirector = cc.Director.extend({invalid: !1, startAnimation: function () {
  5290. this._nextDeltaTimeZero = !0;
  5291. this.invalid = !1
  5292. }, mainLoop: function () {
  5293. this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene()
  5294. }, stopAnimation: function () {
  5295. this.invalid = !0
  5296. }, setAnimationInterval: function (a) {
  5297. this._animationInterval = a;
  5298. this.invalid || (this.stopAnimation(), this.startAnimation())
  5299. }});
  5300. cc.Director.sharedDirector = null;
  5301. cc.Director.firstUseDirector = !0;
  5302. cc.Director._getInstance = function () {
  5303. cc.Director.firstUseDirector && (cc.Director.firstUseDirector = !1, cc.Director.sharedDirector = new cc.DisplayLinkDirector, cc.Director.sharedDirector.init());
  5304. return cc.Director.sharedDirector
  5305. };
  5306. cc.defaultFPS = 60;
  5307. cc.Director.PROJECTION_2D = 0;
  5308. cc.Director.PROJECTION_3D = 1;
  5309. cc.Director.PROJECTION_CUSTOM = 3;
  5310. cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
  5311. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Director.prototype, _p.setProjection = function (a) {
  5312. this._projection = a;
  5313. cc.eventManager.dispatchEvent(this._eventProjectionChanged)
  5314. }, _p.setDepthTest = function () {
  5315. }, _p.setOpenGLView = function (a) {
  5316. this._winSizeInPoints.width = cc._canvas.width;
  5317. this._winSizeInPoints.height = cc._canvas.height;
  5318. this._openGLView = a || cc.view;
  5319. cc.eventManager && cc.eventManager.setEnabled(!0)
  5320. }, _p._clear = function () {
  5321. var a = this._openGLView.getViewPortRect();
  5322. cc._renderContext.fillRect(-a.x, a.y,
  5323. a.width, -a.height)
  5324. }, _p._createStatsLabel = function () {
  5325. var a = 0, a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | 24 * (this._winSizeInPoints.height / 320) : 0 | 24 * (this._winSizeInPoints.width / 320);
  5326. this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
  5327. this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
  5328. this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
  5329. a = cc.DIRECTOR_STATS_POSITION;
  5330. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  5331. this._SPFLabel.setPosition(this._SPFLabel.width /
  5332. 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  5333. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  5334. }, _p.getVisibleSize = function () {
  5335. return this.getWinSize()
  5336. }, _p.getVisibleOrigin = function () {
  5337. return cc.p(0, 0)
  5338. }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load", function () {
  5339. cc.Director._fpsImageLoaded = !0
  5340. }), cc._fpsImage && (cc.Director._fpsImage.src = cc._fpsImage), cc.assert("function" === typeof cc._tmp.DirectorWebGL, cc._LogInfos.MissingFile, "CCDirectorWebGL.js"),
  5341. cc._tmp.DirectorWebGL(), delete cc._tmp.DirectorWebGL);
  5342. cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1;
  5343. cc.arrayVerifyType = function (a, b) {
  5344. if (a && 0 < a.length)for (var c = 0; c < a.length; c++)if (!(a[c]instanceof b))return cc.log(cc._LogInfos.arrayVerifyType), !1;
  5345. return!0
  5346. };
  5347. cc.arrayRemoveObject = function (a, b) {
  5348. for (var c = 0, d = a.length; c < d; c++)if (a[c] == b) {
  5349. a.splice(c, 1);
  5350. break
  5351. }
  5352. };
  5353. cc.arrayRemoveArray = function (a, b) {
  5354. for (var c = 0, d = b.length; c < d; c++)cc.arrayRemoveObject(a, b[c])
  5355. };
  5356. cc.arrayAppendObjectsToIndex = function (a, b, c) {
  5357. a.splice.apply(a, [c, 0].concat(b));
  5358. return a
  5359. };
  5360. cc.ListEntry = function (a, b, c, d, e, f) {
  5361. this.prev = a;
  5362. this.next = b;
  5363. this.target = c;
  5364. this.priority = d;
  5365. this.paused = e;
  5366. this.markedForDeletion = f
  5367. };
  5368. cc.HashUpdateEntry = function (a, b, c, d) {
  5369. this.list = a;
  5370. this.entry = b;
  5371. this.target = c;
  5372. this.hh = d
  5373. };
  5374. cc.HashTimerEntry = function (a, b, c, d, e, f, g) {
  5375. this.timers = a;
  5376. this.target = b;
  5377. this.timerIndex = c;
  5378. this.currentTimer = d;
  5379. this.currentTimerSalvaged = e;
  5380. this.paused = f;
  5381. this.hh = g
  5382. };
  5383. cc.Timer = cc.Class.extend({_interval: 0, _callback: null, _target: null, _elapsed: 0, _runForever: !1, _useDelay: !1, _timesExecuted: 0, _repeat: 0, _delay: 0, getInterval: function () {
  5384. return this._interval
  5385. }, setInterval: function (a) {
  5386. this._interval = a
  5387. }, getCallback: function () {
  5388. return this._callback
  5389. }, ctor: function (a, b, c, d, e) {
  5390. this._target = a;
  5391. this._callback = b;
  5392. this._elapsed = -1;
  5393. this._interval = c || 0;
  5394. this._delay = e || 0;
  5395. this._useDelay = 0 < this._delay;
  5396. this._repeat = null == d ? cc.REPEAT_FOREVER : d;
  5397. this._runForever = this._repeat == cc.REPEAT_FOREVER
  5398. },
  5399. _doCallback: function () {
  5400. if ("string" == typeof this._callback)this._target[this._callback](this._elapsed); else this._callback.call(this._target, this._elapsed)
  5401. }, update: function (a) {
  5402. if (-1 == this._elapsed)this._timesExecuted = this._elapsed = 0; else {
  5403. var b = this._target, c = this._callback;
  5404. this._elapsed += a;
  5405. this._runForever && !this._useDelay ? this._elapsed >= this._interval && (b && c && this._doCallback(), this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (b && c && this._doCallback(), this._elapsed -= this._delay, this._timesExecuted +=
  5406. 1, this._useDelay = !1) : this._elapsed >= this._interval && (b && c && this._doCallback(), this._elapsed = 0, this._timesExecuted += 1), this._timesExecuted > this._repeat && cc.director.getScheduler().unscheduleCallbackForTarget(b, c))
  5407. }
  5408. }});
  5409. cc.Scheduler = cc.Class.extend({_timeScale: 1, _updates: null, _hashForUpdates: null, _arrayForUpdates: null, _hashForTimers: null, _arrayForTimes: null, _currentTarget: null, _currentTargetSalvaged: !1, _updateHashLocked: !1, ctor: function () {
  5410. this._timeScale = 1;
  5411. this._updates = [
  5412. [],
  5413. [],
  5414. []
  5415. ];
  5416. this._hashForUpdates = {};
  5417. this._arrayForUpdates = [];
  5418. this._hashForTimers = {};
  5419. this._arrayForTimers = [];
  5420. this._currentTarget = null;
  5421. this._updateHashLocked = this._currentTargetSalvaged = !1
  5422. }, _removeHashElement: function (a) {
  5423. delete this._hashForTimers[a.target.__instanceId];
  5424. cc.arrayRemoveObject(this._arrayForTimers, a);
  5425. a.Timer = null;
  5426. a.target = null
  5427. }, _removeUpdateFromHash: function (a) {
  5428. if (a = this._hashForUpdates[a.target.__instanceId])cc.arrayRemoveObject(a.list, a.entry), delete this._hashForUpdates[a.target.__instanceId], cc.arrayRemoveObject(this._arrayForUpdates, a), a.entry = null, a.target = null
  5429. }, _priorityIn: function (a, b, c, d) {
  5430. d = new cc.ListEntry(null, null, b, c, d, !1);
  5431. if (a) {
  5432. for (var e = a.length - 1, f = 0; f <= e && !(c < a[f].priority); f++);
  5433. a.splice(f, 0, d)
  5434. } else a = [], a.push(d);
  5435. c = new cc.HashUpdateEntry(a,
  5436. d, b, null);
  5437. this._arrayForUpdates.push(c);
  5438. this._hashForUpdates[b.__instanceId] = c;
  5439. return a
  5440. }, _appendIn: function (a, b, c) {
  5441. c = new cc.ListEntry(null, null, b, 0, c, !1);
  5442. a.push(c);
  5443. a = new cc.HashUpdateEntry(a, c, b, null);
  5444. this._arrayForUpdates.push(a);
  5445. this._hashForUpdates[b.__instanceId] = a
  5446. }, setTimeScale: function (a) {
  5447. this._timeScale = a
  5448. }, getTimeScale: function () {
  5449. return this._timeScale
  5450. }, update: function (a) {
  5451. var b = this._updates, c = this._arrayForTimers, d, e, f;
  5452. this._updateHashLocked = !0;
  5453. 1 != this._timeScale && (a *= this._timeScale);
  5454. e = 0;
  5455. for (f = b.length; e < f && 0 <= e; e++)for (var g = this._updates[e], h = 0, k = g.length; h < k; h++)d = g[h], !d.paused && !d.markedForDeletion && d.target.update(a);
  5456. e = 0;
  5457. for (f = c.length; e < f; e++) {
  5458. d = c[e];
  5459. if (!d)break;
  5460. this._currentTarget = d;
  5461. this._currentTargetSalvaged = !1;
  5462. if (!d.paused)for (d.timerIndex = 0; d.timerIndex < d.timers.length; d.timerIndex++)d.currentTimer = d.timers[d.timerIndex], d.currentTimerSalvaged = !1, d.currentTimer.update(a), d.currentTimer = null;
  5463. this._currentTargetSalvaged && 0 == d.timers.length && (this._removeHashElement(d), e--)
  5464. }
  5465. e =
  5466. 0;
  5467. for (f = b.length; e < f; e++) {
  5468. g = this._updates[e];
  5469. h = 0;
  5470. for (k = g.length; h < k;) {
  5471. d = g[h];
  5472. if (!d)break;
  5473. d.markedForDeletion ? this._removeUpdateFromHash(d) : h++
  5474. }
  5475. }
  5476. this._updateHashLocked = !1;
  5477. this._currentTarget = null
  5478. }, scheduleCallbackForTarget: function (a, b, c, d, e, f) {
  5479. cc.assert(b, cc._LogInfos.Scheduler_scheduleCallbackForTarget_2);
  5480. cc.assert(a, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
  5481. c = c || 0;
  5482. d = null == d ? cc.REPEAT_FOREVER : d;
  5483. e = e || 0;
  5484. f = f || !1;
  5485. var g = this._hashForTimers[a.__instanceId];
  5486. g || (g = new cc.HashTimerEntry(null, a,
  5487. 0, null, null, f, null), this._arrayForTimers.push(g), this._hashForTimers[a.__instanceId] = g);
  5488. if (null == g.timers)g.timers = []; else for (var h = 0; h < g.timers.length; h++)if (f = g.timers[h], b == f._callback) {
  5489. cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, f.getInterval().toFixed(4), c.toFixed(4));
  5490. f._interval = c;
  5491. return
  5492. }
  5493. f = new cc.Timer(a, b, c, d, e);
  5494. g.timers.push(f)
  5495. }, scheduleUpdateForTarget: function (a, b, c) {
  5496. if (null !== a) {
  5497. var d = this._updates, e = this._hashForUpdates[a.__instanceId];
  5498. e ? e.entry.markedForDeletion = !1 : 0 == b ? this._appendIn(d[1],
  5499. a, c) : 0 > b ? d[0] = this._priorityIn(d[0], a, b, c) : d[2] = this._priorityIn(d[2], a, b, c)
  5500. }
  5501. }, unscheduleCallbackForTarget: function (a, b) {
  5502. if (!(null == a || null == b)) {
  5503. var c = this._hashForTimers[a.__instanceId];
  5504. if (c)for (var d = c.timers, e = 0, f = d.length; e < f; e++) {
  5505. var g = d[e];
  5506. if (b == g._callback) {
  5507. g == c.currentTimer && !c.currentTimerSalvaged && (c.currentTimerSalvaged = !0);
  5508. d.splice(e, 1);
  5509. c.timerIndex >= e && c.timerIndex--;
  5510. 0 == d.length && (this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c));
  5511. break
  5512. }
  5513. }
  5514. }
  5515. }, unscheduleUpdateForTarget: function (a) {
  5516. null !=
  5517. a && (a = this._hashForUpdates[a.__instanceId], null != a && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry)))
  5518. }, unscheduleAllCallbacksForTarget: function (a) {
  5519. if (null != a) {
  5520. var b = this._hashForTimers[a.__instanceId];
  5521. if (b) {
  5522. var c = b.timers;
  5523. !b.currentTimerSalvaged && 0 <= c.indexOf(b.currentTimer) && (b.currentTimerSalvaged = !0);
  5524. c.length = 0;
  5525. this._currentTarget == b ? this._currentTargetSalvaged = !0 : this._removeHashElement(b)
  5526. }
  5527. this.unscheduleUpdateForTarget(a)
  5528. }
  5529. }, unscheduleAllCallbacks: function () {
  5530. this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  5531. },
  5532. unscheduleAllCallbacksWithMinPriority: function (a) {
  5533. for (var b = this._arrayForTimers, c = this._updates, d = 0, e = b.length; d < e; d++)this.unscheduleAllCallbacksForTarget(b[d].target);
  5534. for (d = 2; 0 <= d; d--)if (!(1 == d && 0 < a || 0 == d && 0 <= a))for (var b = c[d], e = 0, f = b.length; e < f; e++)this.unscheduleUpdateForTarget(b[e].target)
  5535. }, pauseAllTargets: function () {
  5536. return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  5537. }, pauseAllTargetsWithMinPriority: function (a) {
  5538. a = [];
  5539. for (var b, c = this._arrayForTimers, d = this._updates, e = 0, f =
  5540. c.length; e < f; e++)if (b = c[e])b.paused = !0, a.push(b.target);
  5541. e = 0;
  5542. for (f = d.length; e < f; e++)for (var c = d[e], g = 0, h = c.length; g < h; g++)if (b = c[g])b.paused = !0, a.push(b.target);
  5543. return a
  5544. }, resumeTargets: function (a) {
  5545. if (a)for (var b = 0; b < a.length; b++)this.resumeTarget(a[b])
  5546. }, pauseTarget: function (a) {
  5547. cc.assert(a, cc._LogInfos.Scheduler_pauseTarget);
  5548. var b = this._hashForTimers[a.__instanceId];
  5549. b && (b.paused = !0);
  5550. if (a = this._hashForUpdates[a.__instanceId])a.entry.paused = !0
  5551. }, resumeTarget: function (a) {
  5552. cc.assert(a, cc._LogInfos.Scheduler_resumeTarget);
  5553. var b = this._hashForTimers[a.__instanceId];
  5554. b && (b.paused = !1);
  5555. if (a = this._hashForUpdates[a.__instanceId])a.entry.paused = !1
  5556. }, isTargetPaused: function (a) {
  5557. cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused);
  5558. return(a = this._hashForTimers[a.__instanceId]) ? a.paused : !1
  5559. }});
  5560. cc.Scheduler.PRIORITY_SYSTEM = -2147483648;
  5561. cc._tmp.PrototypeLabelTTF = function () {
  5562. var a = cc.LabelTTF.prototype;
  5563. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  5564. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  5565. cc.defineGetterSetter(a, "string", a.getString, a.setString);
  5566. cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment);
  5567. cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment);
  5568. cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize);
  5569. cc.defineGetterSetter(a,
  5570. "fontName", a.getFontName, a.setFontName);
  5571. cc.defineGetterSetter(a, "font", a._getFont, a._setFont);
  5572. cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth);
  5573. cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight);
  5574. cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor);
  5575. cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle);
  5576. cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth);
  5577. cc.defineGetterSetter(a, "shadowOffsetX",
  5578. a._getShadowOffsetX, a._setShadowOffsetX);
  5579. cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY);
  5580. cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity);
  5581. cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur)
  5582. };
  5583. cc.LabelTTF = cc.Sprite.extend({_dimensions: null, _hAlignment: cc.TEXT_ALIGNMENT_CENTER, _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP, _fontName: null, _fontSize: 0, _string: "", _originalText: null, _isMultiLine: !1, _fontStyleStr: null, _shadowEnabled: !1, _shadowOffset: null, _shadowOpacity: 0, _shadowBlur: 0, _shadowColorStr: null, _strokeEnabled: !1, _strokeColor: null, _strokeSize: 0, _strokeColorStr: null, _textFillColor: null, _fillColorStr: null, _strokeShadowOffsetX: 0, _strokeShadowOffsetY: 0, _needUpdateTexture: !1, _labelCanvas: null,
  5584. _labelContext: null, _lineWidths: null, _className: "LabelTTF", ctor: function (a, b, c, d, e, f) {
  5585. cc.Sprite.prototype.ctor.call(this);
  5586. this._dimensions = cc.size(0, 0);
  5587. this._hAlignment = cc.TEXT_ALIGNMENT_LEFT;
  5588. this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  5589. this._opacityModifyRGB = !1;
  5590. this._fontStyleStr = "";
  5591. this._fontName = "Arial";
  5592. this._shadowEnabled = this._isMultiLine = !1;
  5593. this._shadowOffset = cc.p(0, 0);
  5594. this._shadowBlur = this._shadowOpacity = 0;
  5595. this._shadowColorStr = "rgba(128, 128, 128, 0.5)";
  5596. this._strokeEnabled = !1;
  5597. this._strokeColor =
  5598. cc.color(255, 255, 255, 255);
  5599. this._strokeSize = 0;
  5600. this._strokeColorStr = "";
  5601. this._textFillColor = cc.color(255, 255, 255, 255);
  5602. this._fillColorStr = "rgba(255,255,255,1)";
  5603. this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0;
  5604. this._needUpdateTexture = !1;
  5605. this._lineWidths = [];
  5606. this._setColorsString();
  5607. b && b instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, b) : cc.LabelTTF.prototype.initWithString.call(this, a, b, c, d, e, f)
  5608. }, init: function () {
  5609. return this.initWithString(" ", this._fontName, this._fontSize)
  5610. }, _measureConfig: function () {
  5611. this._getLabelContext().font =
  5612. this._fontStyleStr
  5613. }, _measure: function (a) {
  5614. return this._getLabelContext().measureText(a).width
  5615. }, _checkNextline: function (a, b) {
  5616. var c = this._measure(a), d = Math.floor(a.length * b / c), e = a.indexOf("\n");
  5617. if (0.8 * d >= e && 0 < e)return e + 1;
  5618. if (c < b)return a.length;
  5619. for (var c = !1, f = b + 1, e = -1, g = d, h, k = cc.LabelTTF._checkRegEx, l = cc.LabelTTF._reverseCheckRegEx, m = cc.LabelTTF._checkEnRegEx, n = a.substr(d); h = k.exec(n);) {
  5620. g += h[0].length;
  5621. f = a.substr(0, g);
  5622. f = this._measure(f);
  5623. if ("\n" == h[2] && f < b) {
  5624. c = !0;
  5625. e = g;
  5626. break
  5627. }
  5628. if (f > b) {
  5629. -1 != e && (c = !0);
  5630. break
  5631. }
  5632. e =
  5633. g;
  5634. n = a.substr(g)
  5635. }
  5636. if (c)return e;
  5637. n = a.substr(0, d);
  5638. for (e = d; h = l.exec(n);)if (e = h[1].length, n = h[1], f = this._measure(n), f < b) {
  5639. m.test(h[2]) && e++;
  5640. break
  5641. }
  5642. return e || 1
  5643. }, description: function () {
  5644. return"\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) + "\x3e"
  5645. }, setColor: null, _setColorsString: null, updateDisplayedColor: null, setOpacity: null, updateDisplayedOpacity: null, updateDisplayedOpacityForCanvas: function (a) {
  5646. cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, a);
  5647. this._setColorsString()
  5648. },
  5649. getString: function () {
  5650. return this._string
  5651. }, getHorizontalAlignment: function () {
  5652. return this._hAlignment
  5653. }, getVerticalAlignment: function () {
  5654. return this._vAlignment
  5655. }, getDimensions: function () {
  5656. return cc.size(this._dimensions.width, this._dimensions.height)
  5657. }, getFontSize: function () {
  5658. return this._fontSize
  5659. }, getFontName: function () {
  5660. return this._fontName
  5661. }, initWithString: function (a, b, c, d, e, f) {
  5662. a = a ? a + "" : "";
  5663. c = c || 16;
  5664. d = d || cc.size(0, c);
  5665. e = e || cc.TEXT_ALIGNMENT_LEFT;
  5666. f = f || cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  5667. this._opacityModifyRGB = !1;
  5668. this._dimensions = cc.size(d.width, d.height);
  5669. this._fontName = b || "Arial";
  5670. this._hAlignment = e;
  5671. this._vAlignment = f;
  5672. this._fontSize = c;
  5673. this._fontStyleStr = this._fontSize + "px '" + b + "'";
  5674. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(b, this._fontSize);
  5675. this.string = a;
  5676. this._setColorsString();
  5677. this._updateTexture();
  5678. this._needUpdateTexture = !1;
  5679. return!0
  5680. }, initWithStringAndTextDefinition: null, setTextDefinition: function (a) {
  5681. a && this._updateWithTextDefinition(a, !0)
  5682. }, getTextDefinition: function () {
  5683. return this._prepareTextDefinition(!1)
  5684. },
  5685. enableShadow: function (a, b, c, d) {
  5686. c = c || 0.5;
  5687. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5688. var e = this._shadowOffset;
  5689. if (e && e.x != a || e._y != b)e.x = a, e.y = b;
  5690. this._shadowOpacity != c && (this._shadowOpacity = c);
  5691. this._setColorsString();
  5692. this._shadowBlur != d && (this._shadowBlur = d);
  5693. this._needUpdateTexture = !0
  5694. }, _getShadowOffsetX: function () {
  5695. return this._shadowOffset.x
  5696. }, _setShadowOffsetX: function (a) {
  5697. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5698. this._shadowOffset.x != a && (this._shadowOffset.x = a, this._needUpdateTexture = !0)
  5699. }, _getShadowOffsetY: function () {
  5700. return this._shadowOffset._y
  5701. }, _setShadowOffsetY: function (a) {
  5702. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5703. this._shadowOffset._y != a && (this._shadowOffset._y = a, this._needUpdateTexture = !0)
  5704. }, _getShadowOffset: function () {
  5705. return cc.p(this._shadowOffset.x, this._shadowOffset.y)
  5706. }, _setShadowOffset: function (a) {
  5707. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5708. if (this._shadowOffset.x != a.x || this._shadowOffset.y != a.y)this._shadowOffset.x = a.x, this._shadowOffset.y = a.y, this._needUpdateTexture = !0
  5709. }, _getShadowOpacity: function () {
  5710. return this._shadowOpacity
  5711. }, _setShadowOpacity: function (a) {
  5712. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5713. this._shadowOpacity != a && (this._shadowOpacity = a, this._setColorsString(), this._needUpdateTexture = !0)
  5714. }, _getShadowBlur: function () {
  5715. return this._shadowBlur
  5716. }, _setShadowBlur: function (a) {
  5717. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  5718. this._shadowBlur != a && (this._shadowBlur = a, this._needUpdateTexture = !0)
  5719. }, disableShadow: function () {
  5720. this._shadowEnabled && (this._shadowEnabled = !1, this._needUpdateTexture = !0)
  5721. }, enableStroke: function (a, b) {
  5722. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  5723. var c = this._strokeColor;
  5724. if (c.r !== a.r || c.g !== a.g || c.b !== a.b)c.r = a.r, c.g = a.g, c.b = a.b, this._setColorsString();
  5725. this._strokeSize !== b && (this._strokeSize = b || 0);
  5726. this._needUpdateTexture = !0
  5727. }, _getStrokeStyle: function () {
  5728. return this._strokeColor
  5729. }, _setStrokeStyle: function (a) {
  5730. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  5731. var b = this._strokeColor;
  5732. if (b.r !== a.r || b.g !== a.g || b.b !== a.b)b.r = a.r, b.g = a.g, b.b =
  5733. a.b, this._setColorsString(), this._needUpdateTexture = !0
  5734. }, _getLineWidth: function () {
  5735. return this._strokeSize
  5736. }, _setLineWidth: function (a) {
  5737. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  5738. this._strokeSize !== a && (this._strokeSize = a || 0, this._needUpdateTexture = !0)
  5739. }, disableStroke: function () {
  5740. this._strokeEnabled && (this._strokeEnabled = !1, this._needUpdateTexture = !0)
  5741. }, setFontFillColor: null, _getFillStyle: function () {
  5742. return this._textFillColor
  5743. }, _updateWithTextDefinition: function (a, b) {
  5744. a.fontDimensions ? (this._dimensions.width =
  5745. a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0);
  5746. this._hAlignment = a.textAlign;
  5747. this._vAlignment = a.verticalAlign;
  5748. this._fontName = a.fontName;
  5749. this._fontSize = a.fontSize || 12;
  5750. this._fontStyleStr = this._fontSize + "px '" + this._fontName + "'";
  5751. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize);
  5752. a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur);
  5753. a.strokeEnabled && this.enableStroke(a.strokeStyle,
  5754. a.lineWidth);
  5755. this.setFontFillColor(a.fillStyle);
  5756. b && this._updateTexture()
  5757. }, _prepareTextDefinition: function (a) {
  5758. var b = new cc.FontDefinition;
  5759. a ? (b.fontSize = this._fontSize, b.boundingWidth = cc.contentScaleFactor() * this._dimensions.width, b.boundingHeight = cc.contentScaleFactor() * this._dimensions.height) : (b.fontSize = this._fontSize, b.boundingWidth = this._dimensions.width, b.boundingHeight = this._dimensions.height);
  5760. b.fontName = this._fontName;
  5761. b.textAlign = this._hAlignment;
  5762. b.verticalAlign = this._vAlignment;
  5763. if (this._strokeEnabled) {
  5764. b.strokeEnabled = !0;
  5765. var c = this._strokeColor;
  5766. b.strokeStyle = cc.color(c.r, c.g, c.b);
  5767. b.lineWidth = this._strokeSize
  5768. } else b.strokeEnabled = !1;
  5769. this._shadowEnabled ? (b.shadowEnabled = !0, b.shadowBlur = this._shadowBlur, b.shadowOpacity = this._shadowOpacity, b.shadowOffsetX = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.x, b.shadowOffsetY = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.y) : b._shadowEnabled = !1;
  5770. a = this._textFillColor;
  5771. b.fillStyle = cc.color(a.r, a.g, a.b);
  5772. return b
  5773. }, _fontClientHeight: 18, setString: function (a) {
  5774. a = String(a);
  5775. this._originalText !=
  5776. a && (this._originalText = a + "", this._updateString(), this._needUpdateTexture = !0)
  5777. }, _updateString: function () {
  5778. this._string = this._originalText
  5779. }, setHorizontalAlignment: function (a) {
  5780. a !== this._hAlignment && (this._hAlignment = a, this._needUpdateTexture = !0)
  5781. }, setVerticalAlignment: function (a) {
  5782. a != this._vAlignment && (this._vAlignment = a, this._needUpdateTexture = !0)
  5783. }, setDimensions: function (a) {
  5784. if (a.width != this._dimensions.width || a.height != this._dimensions.height)this._dimensions = a, this._updateString(), this._needUpdateTexture = !0
  5785. }, _getBoundingWidth: function () {
  5786. return this._dimensions.width
  5787. }, _setBoundingWidth: function (a) {
  5788. a != this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._needUpdateTexture = !0)
  5789. }, _getBoundingHeight: function () {
  5790. return this._dimensions.height
  5791. }, _setBoundingHeight: function (a) {
  5792. a != this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._needUpdateTexture = !0)
  5793. }, setFontSize: function (a) {
  5794. this._fontSize !== a && (this._fontSize = a, this._fontStyleStr = a + "px '" + this._fontName + "'",
  5795. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, a), this._needUpdateTexture = !0)
  5796. }, setFontName: function (a) {
  5797. this._fontName && this._fontName != a && (this._fontName = a, this._fontStyleStr = this._fontSize + "px '" + a + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a, this._fontSize), this._needUpdateTexture = !0)
  5798. }, _getFont: function () {
  5799. return this._fontStyleStr
  5800. }, _setFont: function (a) {
  5801. var b = cc.LabelTTF._fontStyleRE.exec(a);
  5802. b && (this._fontSize = parseInt(b[1]), this._fontName = b[2], this._fontStyleStr =
  5803. a, this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize), this._needUpdateTexture = !0)
  5804. }, _drawTTFInCanvas: function (a) {
  5805. if (a) {
  5806. var b = this._strokeShadowOffsetX, c = this._strokeShadowOffsetY, d = this._contentSize.height - c, e = this._vAlignment, f = this._hAlignment, g = this._fontClientHeight, h = this._strokeSize;
  5807. a.setTransform(1, 0, 0, 1, 0 + 0.5 * b, d + 0.5 * c);
  5808. a.font != this._fontStyleStr && (a.font = this._fontStyleStr);
  5809. a.fillStyle = this._fillColorStr;
  5810. var k = c = 0, l = this._strokeEnabled;
  5811. l && (a.lineWidth = 2 *
  5812. h, a.strokeStyle = this._strokeColorStr);
  5813. this._shadowEnabled && (h = this._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = h.x, a.shadowOffsetY = -h.y, a.shadowBlur = this._shadowBlur);
  5814. a.textBaseline = cc.LabelTTF._textBaseline[e];
  5815. a.textAlign = cc.LabelTTF._textAlign[f];
  5816. b = this._contentSize.width - b;
  5817. c = f === cc.TEXT_ALIGNMENT_RIGHT ? c + b : f === cc.TEXT_ALIGNMENT_CENTER ? c + b / 2 : c + 0;
  5818. if (this._isMultiLine) {
  5819. f = this._strings.length;
  5820. e === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? k = g + d - g * f : e === cc.VERTICAL_TEXT_ALIGNMENT_CENTER &&
  5821. (k = g / 2 + (d - g * f) / 2);
  5822. for (e = 0; e < f; e++)b = this._strings[e], h = -d + g * e + k, l && a.strokeText(b, c, h), a.fillText(b, c, h)
  5823. } else e !== cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM && (k = e === cc.VERTICAL_TEXT_ALIGNMENT_TOP ? k - d : k - 0.5 * d), l && a.strokeText(this._string, c, k), a.fillText(this._string, c, k)
  5824. }
  5825. }, _getLabelContext: function () {
  5826. if (this._labelContext)return this._labelContext;
  5827. if (!this._labelCanvas) {
  5828. var a = cc.newElement("canvas"), b = new cc.Texture2D;
  5829. b.initWithElement(a);
  5830. this.texture = b;
  5831. this._labelCanvas = a
  5832. }
  5833. return this._labelContext = this._labelCanvas.getContext("2d")
  5834. },
  5835. _updateTTF: function () {
  5836. var a = this._dimensions.width, b, c, d = this._lineWidths;
  5837. d.length = 0;
  5838. this._isMultiLine = !1;
  5839. this._measureConfig();
  5840. if (0 !== a) {
  5841. var e = this._string;
  5842. this._strings = [];
  5843. b = 0;
  5844. for (c = this._string.length; b < c;) {
  5845. var f = this._checkNextline(e.substr(b), a), g = e.substr(b, f);
  5846. this._strings.push(g);
  5847. b += f
  5848. }
  5849. } else {
  5850. this._strings = this._string.split("\n");
  5851. b = 0;
  5852. for (c = this._strings.length; b < c; b++)d.push(this._measure(this._strings[b]))
  5853. }
  5854. 0 < this._strings.length && (this._isMultiLine = !0);
  5855. c = b = 0;
  5856. this._strokeEnabled && (b = c = 2 * this._strokeSize);
  5857. this._shadowEnabled && (e = this._shadowOffset, b += 2 * Math.abs(e.x), c += 2 * Math.abs(e.y));
  5858. a = 0 === a ? this._isMultiLine ? cc.size(0 | Math.max.apply(Math, d) + b, 0 | this._fontClientHeight * this._strings.length + c) : cc.size(0 | this._measure(this._string) + b, 0 | this._fontClientHeight + c) : 0 === this._dimensions.height ? this._isMultiLine ? cc.size(0 | a + b, 0 | this._fontClientHeight * this._strings.length + c) : cc.size(0 | a + b, 0 | this._fontClientHeight + c) : cc.size(0 | a + b, 0 | this._dimensions.height + c);
  5859. this.setContentSize(a);
  5860. this._strokeShadowOffsetX =
  5861. b;
  5862. this._strokeShadowOffsetY = c;
  5863. d = this._anchorPoint;
  5864. this._anchorPointInPoints.x = 0.5 * b + (a.width - b) * d.x;
  5865. this._anchorPointInPoints.y = 0.5 * c + (a.height - c) * d.y
  5866. }, getContentSize: function () {
  5867. this._needUpdateTexture && this._updateTTF();
  5868. return cc.Sprite.prototype.getContentSize.call(this)
  5869. }, _getWidth: function () {
  5870. this._needUpdateTexture && this._updateTTF();
  5871. return cc.Sprite.prototype._getWidth.call(this)
  5872. }, _getHeight: function () {
  5873. this._needUpdateTexture && this._updateTTF();
  5874. return cc.Sprite.prototype._getHeight.call(this)
  5875. },
  5876. _updateTexture: function () {
  5877. var a = this._getLabelContext(), b = this._labelCanvas, c = this._contentSize;
  5878. if (0 === this._string.length)return b.width = 1, b.height = c.height, this.setTextureRect(cc.rect(0, 0, 1, c.height)), !0;
  5879. a.font = this._fontStyleStr;
  5880. this._updateTTF();
  5881. var d = c.width, c = c.height, e = b.width == d && b.height == c;
  5882. b.width = d;
  5883. b.height = c;
  5884. e && a.clearRect(0, 0, d, c);
  5885. this._drawTTFInCanvas(a);
  5886. this._texture && this._texture.handleLoadedTexture();
  5887. this.setTextureRect(cc.rect(0, 0, d, c));
  5888. return!0
  5889. }, visit: function (a) {
  5890. this._string &&
  5891. "" != this._string && (this._needUpdateTexture && (this._needUpdateTexture = !1, this._updateTexture()), cc.Sprite.prototype.visit.call(this, a || cc._renderContext))
  5892. }, draw: null, _setTextureCoords: function (a) {
  5893. var b = this._batchNode ? this.textureAtlas.texture : this._texture;
  5894. if (b) {
  5895. var c = b.pixelsWidth, d = b.pixelsHeight, e, f = this._quad;
  5896. this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.height - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.width - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.height) / c, e = a.y / d, a = (a.y + a.width) /
  5897. d), this._flippedX && (d = e, e = a, a = d), this._flippedY && (d = b, b = c, c = d), f.bl.texCoords.u = b, f.bl.texCoords.v = e, f.br.texCoords.u = b, f.br.texCoords.v = a, f.tl.texCoords.u = c, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.width - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.height - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.width) / c, e = a.y / d, a = (a.y + a.height) / d), this._flippedX && (d = b, b = c, c = d), this._flippedY && (d = e, e = a, a = d), f.bl.texCoords.u = b, f.bl.texCoords.v = a, f.br.texCoords.u =
  5898. c, f.br.texCoords.v = a, f.tl.texCoords.u = b, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = e);
  5899. this._quadDirty = !0
  5900. }
  5901. }});
  5902. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LabelTTF.prototype, _p.setColor = function (a) {
  5903. cc.NodeRGBA.prototype.setColor.call(this, a);
  5904. this._setColorsString()
  5905. }, _p._setColorsString = function () {
  5906. this._needUpdateTexture = !0;
  5907. var a = this._displayedColor, b = this._displayedOpacity, c = this._strokeColor, d = this._textFillColor;
  5908. this._shadowColorStr = "rgba(" + (0 | 0.5 * a.r) + "," + (0 | 0.5 * a.g) + "," + (0 | 0.5 * a.b) + "," + this._shadowOpacity + ")";
  5909. this._fillColorStr = "rgba(" + (0 | a.r / 255 * d.r) + "," + (0 | a.g / 255 * d.g) + "," + (0 | a.b / 255 * d.b) + ", " + b /
  5910. 255 + ")";
  5911. this._strokeColorStr = "rgba(" + (0 | a.r / 255 * c.r) + "," + (0 | a.g / 255 * c.g) + "," + (0 | a.b / 255 * c.b) + ", " + b / 255 + ")"
  5912. }, _p.updateDisplayedColor = function (a) {
  5913. cc.NodeRGBA.prototype.updateDisplayedColor.call(this, a);
  5914. this._setColorsString()
  5915. }, _p.setOpacity = function (a) {
  5916. this._opacity !== a && (cc.Sprite.prototype.setOpacity.call(this, a), this._setColorsString(), this._needUpdateTexture = !0)
  5917. }, _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity, _p.initWithStringAndTextDefinition = function (a, b) {
  5918. this._updateWithTextDefinition(b,
  5919. !1);
  5920. this.string = a;
  5921. return!0
  5922. }, _p.setFontFillColor = function (a) {
  5923. var b = this._textFillColor;
  5924. if (b.r != a.r || b.g != a.g || b.b != a.b)b.r = a.r, b.g = a.g, b.b = a.b, this._setColorsString(), this._needUpdateTexture = !0
  5925. }, _p.draw = cc.Sprite.prototype.draw, _p.setTextureRect = function (a, b, c) {
  5926. this._rectRotated = b || !1;
  5927. this.setContentSize(c || a);
  5928. this.setVertexRect(a);
  5929. b = this._textureRect_Canvas;
  5930. b.x = a.x;
  5931. b.y = a.y;
  5932. b.width = a.width;
  5933. b.height = a.height;
  5934. b.validRect = !(0 === b.width || 0 === b.height || 0 > b.x || 0 > b.y);
  5935. a = this._unflippedOffsetPositionFromCenter;
  5936. this._flippedX && (a.x = -a.x);
  5937. this._flippedY && (a.y = -a.y);
  5938. this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
  5939. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  5940. this._batchNode && (this.dirty = !0)
  5941. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLabelTTF, cc._LogInfos.MissingFile, "LabelTTFWebGL.js"), cc._tmp.WebGLLabelTTF(), delete cc._tmp.WebGLLabelTTF);
  5942. cc.assert("function" === typeof cc._tmp.PrototypeLabelTTF, cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js");
  5943. cc._tmp.PrototypeLabelTTF();
  5944. delete cc._tmp.PrototypeLabelTTF;
  5945. cc.LabelTTF._textAlign = ["left", "center", "right"];
  5946. cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
  5947. cc.LabelTTF._checkRegEx = /(.+?)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/;
  5948. cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/;
  5949. cc.LabelTTF._checkEnRegEx = /[\s\-\/\\\:]/;
  5950. cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
  5951. cc.LabelTTF.create = function (a, b, c, d, e, f) {
  5952. return new cc.LabelTTF(a, b, c, d, e, f)
  5953. };
  5954. cc.LabelTTF._SHADER_PROGRAM = cc.USE_LA88_LABELS ? cc.SHADER_POSITION_TEXTURECOLOR : cc.SHADER_POSITION_TEXTUREA8COLOR;
  5955. cc.LabelTTF.__labelHeightDiv = cc.newElement("div");
  5956. cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial";
  5957. cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
  5958. cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
  5959. cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
  5960. cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
  5961. document.body ? document.body.appendChild(cc.LabelTTF.__labelHeightDiv) : cc._addEventListener(window, "load", function () {
  5962. this.removeEventListener("load", arguments.callee, !1);
  5963. document.body.appendChild(cc.LabelTTF.__labelHeightDiv)
  5964. }, !1);
  5965. cc.LabelTTF.__getFontHeightByDiv = function (a, b) {
  5966. var c = cc.LabelTTF.__fontHeightCache[a + "." + b];
  5967. if (0 < c)return c;
  5968. var d = cc.LabelTTF.__labelHeightDiv;
  5969. d.innerHTML = "ajghl~!";
  5970. d.style.fontFamily = a;
  5971. d.style.fontSize = b + "px";
  5972. c = d.clientHeight;
  5973. cc.LabelTTF.__fontHeightCache[a + "." + b] = c;
  5974. d.innerHTML = "";
  5975. return c
  5976. };
  5977. cc.LabelTTF.__fontHeightCache = {};cc.ACTION_TAG_INVALID = -1;
  5978. cc.Action = cc.Class.extend({originalTarget: null, target: null, tag: cc.ACTION_TAG_INVALID, ctor: function () {
  5979. this.originalTarget = null;
  5980. this.target = null;
  5981. this.tag = cc.ACTION_TAG_INVALID
  5982. }, copy: function () {
  5983. cc.log("copy is deprecated. Please use clone instead.");
  5984. return this.clone()
  5985. }, clone: function () {
  5986. var action = new cc.Action;
  5987. action.originalTarget = null;
  5988. action.target = null;
  5989. action.tag = this.tag;
  5990. return action
  5991. }, isDone: function () {
  5992. return true
  5993. }, startWithTarget: function (target) {
  5994. this.originalTarget = target;
  5995. this.target = target
  5996. },
  5997. stop: function () {
  5998. this.target = null
  5999. }, step: function (dt) {
  6000. cc.log("[Action step]. override me")
  6001. }, update: function (time) {
  6002. cc.log("[Action update]. override me")
  6003. }, getTarget: function () {
  6004. return this.target
  6005. }, setTarget: function (target) {
  6006. this.target = target
  6007. }, getOriginalTarget: function () {
  6008. return this.originalTarget
  6009. }, setOriginalTarget: function (originalTarget) {
  6010. this.originalTarget = originalTarget
  6011. }, getTag: function () {
  6012. return this.tag
  6013. }, setTag: function (tag) {
  6014. this.tag = tag
  6015. }, retain: function () {
  6016. }, release: function () {
  6017. }});
  6018. cc.Action.create = function () {
  6019. return new cc.Action
  6020. };
  6021. cc.FiniteTimeAction = cc.Action.extend({_duration: 0, ctor: function () {
  6022. cc.Action.prototype.ctor.call(this);
  6023. this._duration = 0
  6024. }, getDuration: function () {
  6025. return this._duration * (this._times || 1)
  6026. }, setDuration: function (duration) {
  6027. this._duration = duration
  6028. }, reverse: function () {
  6029. cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");
  6030. return null
  6031. }, clone: function () {
  6032. return new cc.FiniteTimeAction
  6033. }});
  6034. cc.Speed = cc.Action.extend({_speed: 0, _innerAction: null, ctor: function (action, speed) {
  6035. cc.Action.prototype.ctor.call(this);
  6036. this._speed = 0;
  6037. this._innerAction = null;
  6038. action && this.initWithAction(action, speed)
  6039. }, getSpeed: function () {
  6040. return this._speed
  6041. }, setSpeed: function (speed) {
  6042. this._speed = speed
  6043. }, initWithAction: function (action, speed) {
  6044. if (!action)throw"cc.Speed.initWithAction(): action must be non nil";
  6045. this._innerAction = action;
  6046. this._speed = speed;
  6047. return true
  6048. }, clone: function () {
  6049. var action = new cc.Speed;
  6050. action.initWithAction(this._innerAction.clone(),
  6051. this._speed);
  6052. return action
  6053. }, startWithTarget: function (target) {
  6054. cc.Action.prototype.startWithTarget.call(this, target);
  6055. this._innerAction.startWithTarget(target)
  6056. }, stop: function () {
  6057. this._innerAction.stop();
  6058. cc.Action.prototype.stop.call(this)
  6059. }, step: function (dt) {
  6060. this._innerAction.step(dt * this._speed)
  6061. }, isDone: function () {
  6062. return this._innerAction.isDone()
  6063. }, reverse: function () {
  6064. return cc.Speed.create(this._innerAction.reverse(), this._speed)
  6065. }, setInnerAction: function (action) {
  6066. if (this._innerAction != action)this._innerAction =
  6067. action
  6068. }, getInnerAction: function () {
  6069. return this._innerAction
  6070. }});
  6071. cc.Speed.create = function (action, speed) {
  6072. return new cc.Speed(action, speed)
  6073. };
  6074. cc.Follow = cc.Action.extend({_followedNode: null, _boundarySet: false, _boundaryFullyCovered: false, _halfScreenSize: null, _fullScreenSize: null, leftBoundary: 0, rightBoundary: 0, topBoundary: 0, bottomBoundary: 0, _worldRect: null, ctor: function (followedNode, rect) {
  6075. cc.Action.prototype.ctor.call(this);
  6076. this._followedNode = null;
  6077. this._boundarySet = false;
  6078. this._boundaryFullyCovered = false;
  6079. this._halfScreenSize = null;
  6080. this._fullScreenSize = null;
  6081. this.leftBoundary = 0;
  6082. this.rightBoundary = 0;
  6083. this.topBoundary = 0;
  6084. this.bottomBoundary = 0;
  6085. this._worldRect =
  6086. cc.rect(0, 0, 0, 0);
  6087. if (followedNode)rect ? this.initWithTarget(followedNode, rect) : this.initWithTarget(followedNode)
  6088. }, clone: function () {
  6089. var action = new cc.Follow;
  6090. var locRect = this._worldRect;
  6091. var rect = new cc.Rect(locRect.x, locRect.y, locRect.width, locRect.height);
  6092. action.initWithTarget(this._followedNode, rect);
  6093. return action
  6094. }, isBoundarySet: function () {
  6095. return this._boundarySet
  6096. }, setBoudarySet: function (value) {
  6097. this._boundarySet = value
  6098. }, initWithTarget: function (followedNode, rect) {
  6099. if (!followedNode)throw"cc.Follow.initWithAction(): followedNode must be non nil";
  6100. var _this = this;
  6101. rect = rect || cc.rect(0, 0, 0, 0);
  6102. _this._followedNode = followedNode;
  6103. _this._worldRect = rect;
  6104. _this._boundarySet = !cc._rectEqualToZero(rect);
  6105. _this._boundaryFullyCovered = false;
  6106. var winSize = cc.director.getWinSize();
  6107. _this._fullScreenSize = cc.p(winSize.width, winSize.height);
  6108. _this._halfScreenSize = cc.pMult(_this._fullScreenSize, 0.5);
  6109. if (_this._boundarySet) {
  6110. _this.leftBoundary = -(rect.x + rect.width - _this._fullScreenSize.x);
  6111. _this.rightBoundary = -rect.x;
  6112. _this.topBoundary = -rect.y;
  6113. _this.bottomBoundary = -(rect.y +
  6114. rect.height - _this._fullScreenSize.y);
  6115. if (_this.rightBoundary < _this.leftBoundary)_this.rightBoundary = _this.leftBoundary = (_this.leftBoundary + _this.rightBoundary) / 2;
  6116. if (_this.topBoundary < _this.bottomBoundary)_this.topBoundary = _this.bottomBoundary = (_this.topBoundary + _this.bottomBoundary) / 2;
  6117. if (_this.topBoundary == _this.bottomBoundary && _this.leftBoundary == _this.rightBoundary)_this._boundaryFullyCovered = true
  6118. }
  6119. return true
  6120. }, step: function (dt) {
  6121. var tempPosX = this._followedNode.x;
  6122. var tempPosY = this._followedNode.y;
  6123. tempPosX = this._halfScreenSize.x - tempPosX;
  6124. tempPosY = this._halfScreenSize.y - tempPosY;
  6125. if (this._boundarySet) {
  6126. if (this._boundaryFullyCovered)return;
  6127. this.target.setPosition(cc.clampf(tempPosX, this.leftBoundary, this.rightBoundary), cc.clampf(tempPosY, this.bottomBoundary, this.topBoundary))
  6128. } else this.target.setPosition(tempPosX, tempPosY)
  6129. }, isDone: function () {
  6130. return!this._followedNode.running
  6131. }, stop: function () {
  6132. this.target = null;
  6133. cc.Action.prototype.stop.call(this)
  6134. }});
  6135. cc.Follow.create = function (followedNode, rect) {
  6136. return new cc.Follow(followedNode, rect)
  6137. };
  6138. cc.ActionInterval = cc.FiniteTimeAction.extend({_elapsed: 0, _firstTick: false, _easeList: null, _times: 1, _repeatForever: false, _repeatMethod: false, _speed: 1, _speedMethod: false, ctor: function (d) {
  6139. this._speed = 1;
  6140. this._times = 1;
  6141. this._repeatForever = false;
  6142. this.MAX_VALUE = 2;
  6143. this._repeatMethod = false;
  6144. this._speedMethod = false;
  6145. cc.FiniteTimeAction.prototype.ctor.call(this);
  6146. d !== undefined && this.initWithDuration(d)
  6147. }, getElapsed: function () {
  6148. return this._elapsed
  6149. }, initWithDuration: function (d) {
  6150. this._duration = d === 0 ? cc.FLT_EPSILON : d;
  6151. this._elapsed = 0;
  6152. this._firstTick = true;
  6153. return true
  6154. }, isDone: function () {
  6155. return this._elapsed >= this._duration
  6156. }, _cloneDecoration: function (action) {
  6157. action._repeatForever = this._repeatForever;
  6158. action._speed = this._speed;
  6159. action._times = this._times;
  6160. action._easeList = this._easeList;
  6161. action._speedMethod = this._speedMethod;
  6162. action._repeatMethod = this._repeatMethod
  6163. }, _reverseEaseList: function (action) {
  6164. if (this._easeList) {
  6165. action._easeList = [];
  6166. for (var i = 0; i < this._easeList.length; i++)action._easeList.push(this._easeList[i].reverse())
  6167. }
  6168. },
  6169. clone: function () {
  6170. var action = new cc.ActionInterval(this._duration);
  6171. this._cloneDecoration(action);
  6172. return action
  6173. }, easing: function (easeObj) {
  6174. if (this._easeList)this._easeList.length = 0; else this._easeList = [];
  6175. for (var i = 0; i < arguments.length; i++)this._easeList.push(arguments[i]);
  6176. return this
  6177. }, _computeEaseTime: function (dt) {
  6178. var locList = this._easeList;
  6179. if (!locList || locList.length === 0)return dt;
  6180. for (var i = 0, n = locList.length; i < n; i++)dt = locList[i].easing(dt);
  6181. return dt
  6182. }, step: function (dt) {
  6183. if (this._firstTick) {
  6184. this._firstTick =
  6185. false;
  6186. this._elapsed = 0
  6187. } else this._elapsed += dt;
  6188. var t = this._elapsed / (this._duration > 1.192092896E-7 ? this._duration : 1.192092896E-7);
  6189. t = 1 > t ? t : 1;
  6190. this.update(t > 0 ? t : 0);
  6191. if (this._repeatMethod && this._times > 1 && this.isDone()) {
  6192. if (!this._repeatForever)this._times--;
  6193. this.startWithTarget(this.target);
  6194. this.step(this._elapsed - this._duration)
  6195. }
  6196. }, startWithTarget: function (target) {
  6197. cc.Action.prototype.startWithTarget.call(this, target);
  6198. this._elapsed = 0;
  6199. this._firstTick = true
  6200. }, reverse: function () {
  6201. cc.log("cc.IntervalAction: reverse not implemented.");
  6202. return null
  6203. }, setAmplitudeRate: function (amp) {
  6204. cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")
  6205. }, getAmplitudeRate: function () {
  6206. cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
  6207. return 0
  6208. }, speed: function (speed) {
  6209. if (speed <= 0) {
  6210. cc.log("The speed parameter error");
  6211. return this
  6212. }
  6213. this._speedMethod = true;
  6214. this._speed *= speed;
  6215. return this
  6216. }, getSpeed: function () {
  6217. return this._speed
  6218. }, setSpeed: function (speed) {
  6219. this._speed = speed;
  6220. return this
  6221. }, repeat: function (times) {
  6222. times =
  6223. Math.round(times);
  6224. if (isNaN(times) || times < 1) {
  6225. cc.log("The repeat parameter error");
  6226. return this
  6227. }
  6228. this._repeatMethod = true;
  6229. this._times *= times;
  6230. return this
  6231. }, repeatForever: function () {
  6232. this._repeatMethod = true;
  6233. this._times = this.MAX_VALUE;
  6234. this._repeatForever = true;
  6235. return this
  6236. }});
  6237. cc.ActionInterval.create = function (d) {
  6238. return new cc.ActionInterval(d)
  6239. };
  6240. cc.Sequence = cc.ActionInterval.extend({_actions: null, _split: null, _last: 0, ctor: function (tempArray) {
  6241. cc.ActionInterval.prototype.ctor.call(this);
  6242. this._actions = [];
  6243. var paramArray = tempArray instanceof Array ? tempArray : arguments;
  6244. var last = paramArray.length - 1;
  6245. if (last >= 0 && paramArray[last] == null)cc.log("parameters should not be ending with null in Javascript");
  6246. if (last >= 0) {
  6247. var prev = paramArray[0], action1;
  6248. for (var i = 1; i < last; i++)if (paramArray[i]) {
  6249. action1 = prev;
  6250. prev = cc.Sequence._actionOneTwo(action1, paramArray[i])
  6251. }
  6252. this.initWithTwoActions(prev,
  6253. paramArray[last])
  6254. }
  6255. }, initWithTwoActions: function (actionOne, actionTwo) {
  6256. if (!actionOne || !actionTwo)throw"cc.Sequence.initWithTwoActions(): arguments must all be non nil";
  6257. var d = actionOne._duration + actionTwo._duration;
  6258. this.initWithDuration(d);
  6259. this._actions[0] = actionOne;
  6260. this._actions[1] = actionTwo;
  6261. return true
  6262. }, clone: function () {
  6263. var action = new cc.Sequence;
  6264. this._cloneDecoration(action);
  6265. action.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
  6266. return action
  6267. }, startWithTarget: function (target) {
  6268. cc.ActionInterval.prototype.startWithTarget.call(this,
  6269. target);
  6270. this._split = this._actions[0]._duration / this._duration;
  6271. this._last = -1
  6272. }, stop: function () {
  6273. if (this._last !== -1)this._actions[this._last].stop();
  6274. cc.Action.prototype.stop.call(this)
  6275. }, update: function (time) {
  6276. time = this._computeEaseTime(time);
  6277. var new_t, found = 0;
  6278. var locSplit = this._split, locActions = this._actions, locLast = this._last;
  6279. if (time < locSplit) {
  6280. new_t = locSplit !== 0 ? time / locSplit : 1;
  6281. if (found === 0 && locLast === 1) {
  6282. locActions[1].update(0);
  6283. locActions[1].stop()
  6284. }
  6285. } else {
  6286. found = 1;
  6287. new_t = locSplit === 1 ? 1 : (time - locSplit) / (1 -
  6288. locSplit);
  6289. if (locLast === -1) {
  6290. locActions[0].startWithTarget(this.target);
  6291. locActions[0].update(1);
  6292. locActions[0].stop()
  6293. }
  6294. if (!locLast) {
  6295. locActions[0].update(1);
  6296. locActions[0].stop()
  6297. }
  6298. }
  6299. if (locLast === found && locActions[found].isDone())return;
  6300. if (locLast !== found)locActions[found].startWithTarget(this.target);
  6301. locActions[found].update(new_t);
  6302. this._last = found
  6303. }, reverse: function () {
  6304. var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
  6305. this._cloneDecoration(action);
  6306. this._reverseEaseList(action);
  6307. return action
  6308. }});
  6309. cc.Sequence.create = function (tempArray) {
  6310. var paramArray = tempArray instanceof Array ? tempArray : arguments;
  6311. if (paramArray.length > 0 && paramArray[paramArray.length - 1] == null)cc.log("parameters should not be ending with null in Javascript");
  6312. var prev = paramArray[0];
  6313. for (var i = 1; i < paramArray.length; i++)if (paramArray[i])prev = cc.Sequence._actionOneTwo(prev, paramArray[i]);
  6314. return prev
  6315. };
  6316. cc.Sequence._actionOneTwo = function (actionOne, actionTwo) {
  6317. var sequence = new cc.Sequence;
  6318. sequence.initWithTwoActions(actionOne, actionTwo);
  6319. return sequence
  6320. };
  6321. cc.Repeat = cc.ActionInterval.extend({_times: 0, _total: 0, _nextDt: 0, _actionInstant: false, _innerAction: null, ctor: function (action, times) {
  6322. cc.ActionInterval.prototype.ctor.call(this);
  6323. times !== undefined && this.initWithAction(action, times)
  6324. }, initWithAction: function (action, times) {
  6325. var duration = action._duration * times;
  6326. if (this.initWithDuration(duration)) {
  6327. this._times = times;
  6328. this._innerAction = action;
  6329. if (action instanceof cc.ActionInstant) {
  6330. this._actionInstant = true;
  6331. this._times -= 1
  6332. }
  6333. this._total = 0;
  6334. return true
  6335. }
  6336. return false
  6337. },
  6338. clone: function () {
  6339. var action = new cc.Repeat;
  6340. this._cloneDecoration(action);
  6341. action.initWithAction(this._innerAction.clone(), this._times);
  6342. return action
  6343. }, startWithTarget: function (target) {
  6344. this._total = 0;
  6345. this._nextDt = this._innerAction._duration / this._duration;
  6346. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6347. this._innerAction.startWithTarget(target)
  6348. }, stop: function () {
  6349. this._innerAction.stop();
  6350. cc.Action.prototype.stop.call(this)
  6351. }, update: function (time) {
  6352. time = this._computeEaseTime(time);
  6353. var locInnerAction =
  6354. this._innerAction;
  6355. var locDuration = this._duration;
  6356. var locTimes = this._times;
  6357. var locNextDt = this._nextDt;
  6358. if (time >= locNextDt) {
  6359. while (time > locNextDt && this._total < locTimes) {
  6360. locInnerAction.update(1);
  6361. this._total++;
  6362. locInnerAction.stop();
  6363. locInnerAction.startWithTarget(this.target);
  6364. locNextDt += locInnerAction._duration / locDuration;
  6365. this._nextDt = locNextDt
  6366. }
  6367. if (time >= 1 && this._total < locTimes)this._total++;
  6368. if (!this._actionInstant)if (this._total === locTimes) {
  6369. locInnerAction.update(1);
  6370. locInnerAction.stop()
  6371. } else locInnerAction.update(time -
  6372. (locNextDt - locInnerAction._duration / locDuration))
  6373. } else locInnerAction.update(time * locTimes % 1)
  6374. }, isDone: function () {
  6375. return this._total == this._times
  6376. }, reverse: function () {
  6377. var action = cc.Repeat.create(this._innerAction.reverse(), this._times);
  6378. this._cloneDecoration(action);
  6379. this._reverseEaseList(action);
  6380. return action
  6381. }, setInnerAction: function (action) {
  6382. if (this._innerAction != action)this._innerAction = action
  6383. }, getInnerAction: function () {
  6384. return this._innerAction
  6385. }});
  6386. cc.Repeat.create = function (action, times) {
  6387. return new cc.Repeat(action, times)
  6388. };
  6389. cc.RepeatForever = cc.ActionInterval.extend({_innerAction: null, ctor: function (action) {
  6390. cc.ActionInterval.prototype.ctor.call(this);
  6391. this._innerAction = null;
  6392. action && this.initWithAction(action)
  6393. }, initWithAction: function (action) {
  6394. if (!action)throw"cc.RepeatForever.initWithAction(): action must be non null";
  6395. this._innerAction = action;
  6396. return true
  6397. }, clone: function () {
  6398. var action = new cc.RepeatForever;
  6399. this._cloneDecoration(action);
  6400. action.initWithAction(this._innerAction.clone());
  6401. return action
  6402. }, startWithTarget: function (target) {
  6403. cc.ActionInterval.prototype.startWithTarget.call(this,
  6404. target);
  6405. this._innerAction.startWithTarget(target)
  6406. }, step: function (dt) {
  6407. var locInnerAction = this._innerAction;
  6408. locInnerAction.step(dt);
  6409. if (locInnerAction.isDone()) {
  6410. locInnerAction.startWithTarget(this.target);
  6411. locInnerAction.step(locInnerAction.getElapsed() - locInnerAction._duration)
  6412. }
  6413. }, isDone: function () {
  6414. return false
  6415. }, reverse: function () {
  6416. var action = cc.RepeatForever.create(this._innerAction.reverse());
  6417. this._cloneDecoration(action);
  6418. this._reverseEaseList(action);
  6419. return action
  6420. }, setInnerAction: function (action) {
  6421. if (this._innerAction !=
  6422. action)this._innerAction = action
  6423. }, getInnerAction: function () {
  6424. return this._innerAction
  6425. }});
  6426. cc.RepeatForever.create = function (action) {
  6427. return new cc.RepeatForever(action)
  6428. };
  6429. cc.Spawn = cc.ActionInterval.extend({_one: null, _two: null, ctor: function (tempArray) {
  6430. cc.ActionInterval.prototype.ctor.call(this);
  6431. this._one = null;
  6432. this._two = null;
  6433. var paramArray = tempArray instanceof Array ? tempArray : arguments;
  6434. var last = paramArray.length - 1;
  6435. if (last >= 0 && paramArray[last] == null)cc.log("parameters should not be ending with null in Javascript");
  6436. if (last >= 0) {
  6437. var prev = paramArray[0], action1;
  6438. for (var i = 1; i < last; i++)if (paramArray[i]) {
  6439. action1 = prev;
  6440. prev = cc.Spawn._actionOneTwo(action1, paramArray[i])
  6441. }
  6442. this.initWithTwoActions(prev,
  6443. paramArray[last])
  6444. }
  6445. }, initWithTwoActions: function (action1, action2) {
  6446. if (!action1 || !action2)throw"cc.Spawn.initWithTwoActions(): arguments must all be non null";
  6447. var ret = false;
  6448. var d1 = action1._duration;
  6449. var d2 = action2._duration;
  6450. if (this.initWithDuration(Math.max(d1, d2))) {
  6451. this._one = action1;
  6452. this._two = action2;
  6453. if (d1 > d2)this._two = cc.Sequence._actionOneTwo(action2, cc.DelayTime.create(d1 - d2)); else if (d1 < d2)this._one = cc.Sequence._actionOneTwo(action1, cc.DelayTime.create(d2 - d1));
  6454. ret = true
  6455. }
  6456. return ret
  6457. }, clone: function () {
  6458. var action =
  6459. new cc.Spawn;
  6460. this._cloneDecoration(action);
  6461. action.initWithTwoActions(this._one.clone(), this._two.clone());
  6462. return action
  6463. }, startWithTarget: function (target) {
  6464. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6465. this._one.startWithTarget(target);
  6466. this._two.startWithTarget(target)
  6467. }, stop: function () {
  6468. this._one.stop();
  6469. this._two.stop();
  6470. cc.Action.prototype.stop.call(this)
  6471. }, update: function (time) {
  6472. time = this._computeEaseTime(time);
  6473. if (this._one)this._one.update(time);
  6474. if (this._two)this._two.update(time)
  6475. }, reverse: function () {
  6476. var action =
  6477. cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
  6478. this._cloneDecoration(action);
  6479. this._reverseEaseList(action);
  6480. return action
  6481. }});
  6482. cc.Spawn.create = function (tempArray) {
  6483. var paramArray = tempArray instanceof Array ? tempArray : arguments;
  6484. if (paramArray.length > 0 && paramArray[paramArray.length - 1] == null)cc.log("parameters should not be ending with null in Javascript");
  6485. var prev = paramArray[0];
  6486. for (var i = 1; i < paramArray.length; i++)if (paramArray[i] != null)prev = cc.Spawn._actionOneTwo(prev, paramArray[i]);
  6487. return prev
  6488. };
  6489. cc.Spawn._actionOneTwo = function (action1, action2) {
  6490. var pSpawn = new cc.Spawn;
  6491. pSpawn.initWithTwoActions(action1, action2);
  6492. return pSpawn
  6493. };
  6494. cc.RotateTo = cc.ActionInterval.extend({_dstAngleX: 0, _startAngleX: 0, _diffAngleX: 0, _dstAngleY: 0, _startAngleY: 0, _diffAngleY: 0, ctor: function (duration, deltaAngleX, deltaAngleY) {
  6495. cc.ActionInterval.prototype.ctor.call(this);
  6496. deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY)
  6497. }, initWithDuration: function (duration, deltaAngleX, deltaAngleY) {
  6498. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6499. this._dstAngleX = deltaAngleX || 0;
  6500. this._dstAngleY = deltaAngleY || this._dstAngleX;
  6501. return true
  6502. }
  6503. return false
  6504. }, clone: function () {
  6505. var action = new cc.RotateTo;
  6506. this._cloneDecoration(action);
  6507. action.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
  6508. return action
  6509. }, startWithTarget: function (target) {
  6510. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6511. var locStartAngleX = target.rotationX % 360;
  6512. var locDiffAngleX = this._dstAngleX - locStartAngleX;
  6513. if (locDiffAngleX > 180)locDiffAngleX -= 360;
  6514. if (locDiffAngleX < -180)locDiffAngleX += 360;
  6515. this._startAngleX = locStartAngleX;
  6516. this._diffAngleX =
  6517. locDiffAngleX;
  6518. this._startAngleY = target.rotationY % 360;
  6519. var locDiffAngleY = this._dstAngleY - this._startAngleY;
  6520. if (locDiffAngleY > 180)locDiffAngleY -= 360;
  6521. if (locDiffAngleY < -180)locDiffAngleY += 360;
  6522. this._diffAngleY = locDiffAngleY
  6523. }, reverse: function () {
  6524. cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")
  6525. }, update: function (time) {
  6526. time = this._computeEaseTime(time);
  6527. if (this.target) {
  6528. this.target.rotationX = this._startAngleX + this._diffAngleX * time;
  6529. this.target.rotationY = this._startAngleY + this._diffAngleY * time
  6530. }
  6531. }});
  6532. cc.RotateTo.create = function (duration, deltaAngleX, deltaAngleY) {
  6533. return new cc.RotateTo(duration, deltaAngleX, deltaAngleY)
  6534. };
  6535. cc.RotateBy = cc.ActionInterval.extend({_angleX: 0, _startAngleX: 0, _angleY: 0, _startAngleY: 0, ctor: function (duration, deltaAngleX, deltaAngleY) {
  6536. cc.ActionInterval.prototype.ctor.call(this);
  6537. deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY)
  6538. }, initWithDuration: function (duration, deltaAngleX, deltaAngleY) {
  6539. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6540. this._angleX = deltaAngleX || 0;
  6541. this._angleY = deltaAngleY || this._angleX;
  6542. return true
  6543. }
  6544. return false
  6545. }, clone: function () {
  6546. var action =
  6547. new cc.RotateBy;
  6548. this._cloneDecoration(action);
  6549. action.initWithDuration(this._duration, this._angleX, this._angleY);
  6550. return action
  6551. }, startWithTarget: function (target) {
  6552. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6553. this._startAngleX = target.rotationX;
  6554. this._startAngleY = target.rotationY
  6555. }, update: function (time) {
  6556. time = this._computeEaseTime(time);
  6557. if (this.target) {
  6558. this.target.rotationX = this._startAngleX + this._angleX * time;
  6559. this.target.rotationY = this._startAngleY + this._angleY * time
  6560. }
  6561. }, reverse: function () {
  6562. var action =
  6563. cc.RotateBy.create(this._duration, -this._angleX, -this._angleY);
  6564. this._cloneDecoration(action);
  6565. this._reverseEaseList(action);
  6566. return action
  6567. }});
  6568. cc.RotateBy.create = function (duration, deltaAngleX, deltaAngleY) {
  6569. var rotateBy = new cc.RotateBy;
  6570. rotateBy.initWithDuration(duration, deltaAngleX, deltaAngleY);
  6571. return rotateBy
  6572. };
  6573. cc.MoveBy = cc.ActionInterval.extend({_positionDelta: null, _startPosition: null, _previousPosition: null, ctor: function (duration, deltaPos, deltaY) {
  6574. cc.ActionInterval.prototype.ctor.call(this);
  6575. this._positionDelta = cc.p(0, 0);
  6576. this._startPosition = cc.p(0, 0);
  6577. this._previousPosition = cc.p(0, 0);
  6578. deltaPos !== undefined && this.initWithDuration(duration, deltaPos, deltaY)
  6579. }, initWithDuration: function (duration, position, y) {
  6580. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6581. if (position.x !== undefined) {
  6582. y = position.y;
  6583. position = position.x
  6584. }
  6585. this._positionDelta.x = position;
  6586. this._positionDelta.y = y;
  6587. return true
  6588. }
  6589. return false
  6590. }, clone: function () {
  6591. var action = new cc.MoveBy;
  6592. this._cloneDecoration(action);
  6593. action.initWithDuration(this._duration, this._positionDelta);
  6594. return action
  6595. }, startWithTarget: function (target) {
  6596. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6597. var locPosX = target.getPositionX();
  6598. var locPosY = target.getPositionY();
  6599. this._previousPosition.x = locPosX;
  6600. this._previousPosition.y = locPosY;
  6601. this._startPosition.x = locPosX;
  6602. this._startPosition.y = locPosY
  6603. }, update: function (time) {
  6604. time = this._computeEaseTime(time);
  6605. if (this.target) {
  6606. var x = this._positionDelta.x * time;
  6607. var y = this._positionDelta.y * time;
  6608. var locStartPosition = this._startPosition;
  6609. if (cc.ENABLE_STACKABLE_ACTIONS) {
  6610. var targetX = this.target.getPositionX();
  6611. var targetY = this.target.getPositionY();
  6612. var locPreviousPosition = this._previousPosition;
  6613. locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
  6614. locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
  6615. x = x + locStartPosition.x;
  6616. y = y + locStartPosition.y;
  6617. locPreviousPosition.x = x;
  6618. locPreviousPosition.y = y;
  6619. this.target.setPosition(x, y)
  6620. } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y)
  6621. }
  6622. }, reverse: function () {
  6623. var action = cc.MoveBy.create(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
  6624. this._cloneDecoration(action);
  6625. this._reverseEaseList(action);
  6626. return action
  6627. }});
  6628. cc.MoveBy.create = function (duration, deltaPos, deltaY) {
  6629. return new cc.MoveBy(duration, deltaPos, deltaY)
  6630. };
  6631. cc.MoveTo = cc.MoveBy.extend({_endPosition: null, ctor: function (duration, position, y) {
  6632. cc.MoveBy.prototype.ctor.call(this);
  6633. this._endPosition = cc.p(0, 0);
  6634. position !== undefined && this.initWithDuration(duration, position, y)
  6635. }, initWithDuration: function (duration, position, y) {
  6636. if (cc.MoveBy.prototype.initWithDuration.call(this, duration, position, y)) {
  6637. if (position.x !== undefined) {
  6638. y = position.y;
  6639. position = position.x
  6640. }
  6641. this._endPosition.x = position;
  6642. this._endPosition.y = y;
  6643. return true
  6644. }
  6645. return false
  6646. }, clone: function () {
  6647. var action = new cc.MoveTo;
  6648. this._cloneDecoration(action);
  6649. action.initWithDuration(this._duration, this._endPosition);
  6650. return action
  6651. }, startWithTarget: function (target) {
  6652. cc.MoveBy.prototype.startWithTarget.call(this, target);
  6653. this._positionDelta.x = this._endPosition.x - target.getPositionX();
  6654. this._positionDelta.y = this._endPosition.y - target.getPositionY()
  6655. }});
  6656. cc.MoveTo.create = function (duration, position, y) {
  6657. return new cc.MoveTo(duration, position, y)
  6658. };
  6659. cc.SkewTo = cc.ActionInterval.extend({_skewX: 0, _skewY: 0, _startSkewX: 0, _startSkewY: 0, _endSkewX: 0, _endSkewY: 0, _deltaX: 0, _deltaY: 0, ctor: function (t, sx, sy) {
  6660. cc.ActionInterval.prototype.ctor.call(this);
  6661. sy !== undefined && this.initWithDuration(t, sx, sy)
  6662. }, initWithDuration: function (t, sx, sy) {
  6663. var ret = false;
  6664. if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
  6665. this._endSkewX = sx;
  6666. this._endSkewY = sy;
  6667. ret = true
  6668. }
  6669. return ret
  6670. }, clone: function () {
  6671. var action = new cc.SkewTo;
  6672. this._cloneDecoration(action);
  6673. action.initWithDuration(this._duration,
  6674. this._endSkewX, this._endSkewY);
  6675. return action
  6676. }, startWithTarget: function (target) {
  6677. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6678. this._startSkewX = target.skewX % 180;
  6679. this._deltaX = this._endSkewX - this._startSkewX;
  6680. if (this._deltaX > 180)this._deltaX -= 360;
  6681. if (this._deltaX < -180)this._deltaX += 360;
  6682. this._startSkewY = target.skewY % 360;
  6683. this._deltaY = this._endSkewY - this._startSkewY;
  6684. if (this._deltaY > 180)this._deltaY -= 360;
  6685. if (this._deltaY < -180)this._deltaY += 360
  6686. }, update: function (t) {
  6687. t = this._computeEaseTime(t);
  6688. this.target.skewX =
  6689. this._startSkewX + this._deltaX * t;
  6690. this.target.skewY = this._startSkewY + this._deltaY * t
  6691. }});
  6692. cc.SkewTo.create = function (t, sx, sy) {
  6693. return new cc.SkewTo(t, sx, sy)
  6694. };
  6695. cc.SkewBy = cc.SkewTo.extend({ctor: function (t, sx, sy) {
  6696. cc.SkewTo.prototype.ctor.call(this);
  6697. sy !== undefined && this.initWithDuration(t, sx, sy)
  6698. }, initWithDuration: function (t, deltaSkewX, deltaSkewY) {
  6699. var ret = false;
  6700. if (cc.SkewTo.prototype.initWithDuration.call(this, t, deltaSkewX, deltaSkewY)) {
  6701. this._skewX = deltaSkewX;
  6702. this._skewY = deltaSkewY;
  6703. ret = true
  6704. }
  6705. return ret
  6706. }, clone: function () {
  6707. var action = new cc.SkewBy;
  6708. this._cloneDecoration(action);
  6709. action.initWithDuration(this._duration, this._skewX, this._skewY);
  6710. return action
  6711. }, startWithTarget: function (target) {
  6712. cc.SkewTo.prototype.startWithTarget.call(this,
  6713. target);
  6714. this._deltaX = this._skewX;
  6715. this._deltaY = this._skewY;
  6716. this._endSkewX = this._startSkewX + this._deltaX;
  6717. this._endSkewY = this._startSkewY + this._deltaY
  6718. }, reverse: function () {
  6719. var action = cc.SkewBy.create(this._duration, -this._skewX, -this._skewY);
  6720. this._cloneDecoration(action);
  6721. this._reverseEaseList(action);
  6722. return action
  6723. }});
  6724. cc.SkewBy.create = function (t, sx, sy) {
  6725. var skewBy = new cc.SkewBy;
  6726. if (skewBy)skewBy.initWithDuration(t, sx, sy);
  6727. return skewBy
  6728. };
  6729. cc.JumpBy = cc.ActionInterval.extend({_startPosition: null, _delta: null, _height: 0, _jumps: 0, _previousPosition: null, ctor: function (duration, position, y, height, jumps) {
  6730. cc.ActionInterval.prototype.ctor.call(this);
  6731. this._startPosition = cc.p(0, 0);
  6732. this._previousPosition = cc.p(0, 0);
  6733. this._delta = cc.p(0, 0);
  6734. height !== undefined && this.initWithDuration(duration, position, y, height, jumps)
  6735. }, initWithDuration: function (duration, position, y, height, jumps) {
  6736. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6737. if (jumps ===
  6738. undefined) {
  6739. jumps = height;
  6740. height = y;
  6741. y = position.y;
  6742. position = position.x
  6743. }
  6744. this._delta.x = position;
  6745. this._delta.y = y;
  6746. this._height = height;
  6747. this._jumps = jumps;
  6748. return true
  6749. }
  6750. return false
  6751. }, clone: function () {
  6752. var action = new cc.JumpBy;
  6753. this._cloneDecoration(action);
  6754. action.initWithDuration(this._duration, this._delta, this._height, this._jumps);
  6755. return action
  6756. }, startWithTarget: function (target) {
  6757. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6758. var locPosX = target.getPositionX();
  6759. var locPosY = target.getPositionY();
  6760. this._previousPosition.x =
  6761. locPosX;
  6762. this._previousPosition.y = locPosY;
  6763. this._startPosition.x = locPosX;
  6764. this._startPosition.y = locPosY
  6765. }, update: function (time) {
  6766. time = this._computeEaseTime(time);
  6767. if (this.target) {
  6768. var frac = time * this._jumps % 1;
  6769. var y = this._height * 4 * frac * (1 - frac);
  6770. y += this._delta.y * time;
  6771. var x = this._delta.x * time;
  6772. var locStartPosition = this._startPosition;
  6773. if (cc.ENABLE_STACKABLE_ACTIONS) {
  6774. var targetX = this.target.getPositionX();
  6775. var targetY = this.target.getPositionY();
  6776. var locPreviousPosition = this._previousPosition;
  6777. locStartPosition.x = locStartPosition.x +
  6778. targetX - locPreviousPosition.x;
  6779. locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
  6780. x = x + locStartPosition.x;
  6781. y = y + locStartPosition.y;
  6782. locPreviousPosition.x = x;
  6783. locPreviousPosition.y = y;
  6784. this.target.setPosition(x, y)
  6785. } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y)
  6786. }
  6787. }, reverse: function () {
  6788. var action = cc.JumpBy.create(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
  6789. this._cloneDecoration(action);
  6790. this._reverseEaseList(action);
  6791. return action
  6792. }});
  6793. cc.JumpBy.create = function (duration, position, y, height, jumps) {
  6794. return new cc.JumpBy(duration, position, y, height, jumps)
  6795. };
  6796. cc.JumpTo = cc.JumpBy.extend({_endPosition: null, ctor: function (duration, position, y, height, jumps) {
  6797. cc.JumpBy.prototype.ctor.call(this);
  6798. this._endPosition = cc.p(0, 0);
  6799. height !== undefined && this.initWithDuration(duration, position, y, height, jumps)
  6800. }, initWithDuration: function (duration, position, y, height, jumps) {
  6801. if (cc.JumpBy.prototype.initWithDuration.call(this, duration, position, y, height, jumps)) {
  6802. if (jumps === undefined) {
  6803. y = position.y;
  6804. position = position.x
  6805. }
  6806. this._endPosition.x = position;
  6807. this._endPosition.y = y;
  6808. return true
  6809. }
  6810. return false
  6811. },
  6812. startWithTarget: function (target) {
  6813. cc.JumpBy.prototype.startWithTarget.call(this, target);
  6814. this._delta.x = this._endPosition.x - this._startPosition.x;
  6815. this._delta.y = this._endPosition.y - this._startPosition.y
  6816. }, clone: function () {
  6817. var action = new cc.JumpTo;
  6818. this._cloneDecoration(action);
  6819. action.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
  6820. return action
  6821. }});
  6822. cc.JumpTo.create = function (duration, position, y, height, jumps) {
  6823. return new cc.JumpTo(duration, position, y, height, jumps)
  6824. };
  6825. cc.bezierAt = function (a, b, c, d, t) {
  6826. return Math.pow(1 - t, 3) * a + 3 * t * Math.pow(1 - t, 2) * b + 3 * Math.pow(t, 2) * (1 - t) * c + Math.pow(t, 3) * d
  6827. };
  6828. cc.BezierBy = cc.ActionInterval.extend({_config: null, _startPosition: null, _previousPosition: null, ctor: function (t, c) {
  6829. cc.ActionInterval.prototype.ctor.call(this);
  6830. this._config = [];
  6831. this._startPosition = cc.p(0, 0);
  6832. this._previousPosition = cc.p(0, 0);
  6833. c && this.initWithDuration(t, c)
  6834. }, initWithDuration: function (t, c) {
  6835. if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
  6836. this._config = c;
  6837. return true
  6838. }
  6839. return false
  6840. }, clone: function () {
  6841. var action = new cc.BezierBy;
  6842. this._cloneDecoration(action);
  6843. var newConfigs = [];
  6844. for (var i =
  6845. 0; i < this._config.length; i++) {
  6846. var selConf = this._config[i];
  6847. newConfigs.push(cc.p(selConf.x, selConf.y))
  6848. }
  6849. action.initWithDuration(this._duration, newConfigs);
  6850. return action
  6851. }, startWithTarget: function (target) {
  6852. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6853. var locPosX = target.getPositionX();
  6854. var locPosY = target.getPositionY();
  6855. this._previousPosition.x = locPosX;
  6856. this._previousPosition.y = locPosY;
  6857. this._startPosition.x = locPosX;
  6858. this._startPosition.y = locPosY
  6859. }, update: function (time) {
  6860. time = this._computeEaseTime(time);
  6861. if (this.target) {
  6862. var locConfig = this._config;
  6863. var xa = 0;
  6864. var xb = locConfig[0].x;
  6865. var xc = locConfig[1].x;
  6866. var xd = locConfig[2].x;
  6867. var ya = 0;
  6868. var yb = locConfig[0].y;
  6869. var yc = locConfig[1].y;
  6870. var yd = locConfig[2].y;
  6871. var x = cc.bezierAt(xa, xb, xc, xd, time);
  6872. var y = cc.bezierAt(ya, yb, yc, yd, time);
  6873. var locStartPosition = this._startPosition;
  6874. if (cc.ENABLE_STACKABLE_ACTIONS) {
  6875. var targetX = this.target.getPositionX();
  6876. var targetY = this.target.getPositionY();
  6877. var locPreviousPosition = this._previousPosition;
  6878. locStartPosition.x = locStartPosition.x +
  6879. targetX - locPreviousPosition.x;
  6880. locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
  6881. x = x + locStartPosition.x;
  6882. y = y + locStartPosition.y;
  6883. locPreviousPosition.x = x;
  6884. locPreviousPosition.y = y;
  6885. this.target.setPosition(x, y)
  6886. } else this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y)
  6887. }
  6888. }, reverse: function () {
  6889. var locConfig = this._config;
  6890. var r = [cc.pAdd(locConfig[1], cc.pNeg(locConfig[2])), cc.pAdd(locConfig[0], cc.pNeg(locConfig[2])), cc.pNeg(locConfig[2])];
  6891. var action = cc.BezierBy.create(this._duration,
  6892. r);
  6893. this._cloneDecoration(action);
  6894. this._reverseEaseList(action);
  6895. return action
  6896. }});
  6897. cc.BezierBy.create = function (t, c) {
  6898. return new cc.BezierBy(t, c)
  6899. };
  6900. cc.BezierTo = cc.BezierBy.extend({_toConfig: null, ctor: function (t, c) {
  6901. cc.BezierBy.prototype.ctor.call(this);
  6902. this._toConfig = [];
  6903. c && this.initWithDuration(t, c)
  6904. }, initWithDuration: function (t, c) {
  6905. if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
  6906. this._toConfig = c;
  6907. return true
  6908. }
  6909. return false
  6910. }, clone: function () {
  6911. var action = new cc.BezierTo;
  6912. this._cloneDecoration(action);
  6913. action.initWithDuration(this._duration, this._toConfig);
  6914. return action
  6915. }, startWithTarget: function (target) {
  6916. cc.BezierBy.prototype.startWithTarget.call(this,
  6917. target);
  6918. var locStartPos = this._startPosition;
  6919. var locToConfig = this._toConfig;
  6920. var locConfig = this._config;
  6921. locConfig[0] = cc.pSub(locToConfig[0], locStartPos);
  6922. locConfig[1] = cc.pSub(locToConfig[1], locStartPos);
  6923. locConfig[2] = cc.pSub(locToConfig[2], locStartPos)
  6924. }});
  6925. cc.BezierTo.create = function (t, c) {
  6926. return new cc.BezierTo(t, c)
  6927. };
  6928. cc.ScaleTo = cc.ActionInterval.extend({_scaleX: 1, _scaleY: 1, _startScaleX: 1, _startScaleY: 1, _endScaleX: 0, _endScaleY: 0, _deltaX: 0, _deltaY: 0, ctor: function (duration, sx, sy) {
  6929. cc.ActionInterval.prototype.ctor.call(this);
  6930. sx !== undefined && this.initWithDuration(duration, sx, sy)
  6931. }, initWithDuration: function (duration, sx, sy) {
  6932. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6933. this._endScaleX = sx;
  6934. this._endScaleY = sy != null ? sy : sx;
  6935. return true
  6936. }
  6937. return false
  6938. }, clone: function () {
  6939. var action = new cc.ScaleTo;
  6940. this._cloneDecoration(action);
  6941. action.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
  6942. return action
  6943. }, startWithTarget: function (target) {
  6944. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  6945. this._startScaleX = target.scaleX;
  6946. this._startScaleY = target.scaleY;
  6947. this._deltaX = this._endScaleX - this._startScaleX;
  6948. this._deltaY = this._endScaleY - this._startScaleY
  6949. }, update: function (time) {
  6950. time = this._computeEaseTime(time);
  6951. if (this.target) {
  6952. this.target.scaleX = this._startScaleX + this._deltaX * time;
  6953. this.target.scaleY = this._startScaleY +
  6954. this._deltaY * time
  6955. }
  6956. }});
  6957. cc.ScaleTo.create = function (duration, sx, sy) {
  6958. var scaleTo = new cc.ScaleTo;
  6959. scaleTo.initWithDuration(duration, sx, sy);
  6960. return scaleTo
  6961. };
  6962. cc.ScaleBy = cc.ScaleTo.extend({startWithTarget: function (target) {
  6963. cc.ScaleTo.prototype.startWithTarget.call(this, target);
  6964. this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
  6965. this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY
  6966. }, reverse: function () {
  6967. var action = cc.ScaleBy.create(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
  6968. this._cloneDecoration(action);
  6969. this._reverseEaseList(action);
  6970. return action
  6971. }, clone: function () {
  6972. var action = new cc.ScaleBy;
  6973. this._cloneDecoration(action);
  6974. action.initWithDuration(this._duration,
  6975. this._endScaleX, this._endScaleY);
  6976. return action
  6977. }});
  6978. cc.ScaleBy.create = function (duration, sx, sy) {
  6979. return new cc.ScaleBy(duration, sx, sy)
  6980. };
  6981. cc.Blink = cc.ActionInterval.extend({_times: 0, _originalState: false, ctor: function (duration, blinks) {
  6982. cc.ActionInterval.prototype.ctor.call(this);
  6983. blinks !== undefined && this.initWithDuration(duration, blinks)
  6984. }, initWithDuration: function (duration, blinks) {
  6985. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  6986. this._times = blinks;
  6987. return true
  6988. }
  6989. return false
  6990. }, clone: function () {
  6991. var action = new cc.Blink;
  6992. this._cloneDecoration(action);
  6993. action.initWithDuration(this._duration, this._times);
  6994. return action
  6995. }, update: function (time) {
  6996. time =
  6997. this._computeEaseTime(time);
  6998. if (this.target && !this.isDone()) {
  6999. var slice = 1 / this._times;
  7000. var m = time % slice;
  7001. this.target.visible = m > slice / 2
  7002. }
  7003. }, startWithTarget: function (target) {
  7004. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7005. this._originalState = target.visible
  7006. }, stop: function () {
  7007. this.target.visible = this._originalState;
  7008. cc.ActionInterval.prototype.stop.call(this)
  7009. }, reverse: function () {
  7010. var action = cc.Blink.create(this._duration, this._times);
  7011. this._cloneDecoration(action);
  7012. this._reverseEaseList(action);
  7013. return action
  7014. }});
  7015. cc.Blink.create = function (duration, blinks) {
  7016. var blink = new cc.Blink;
  7017. blink.initWithDuration(duration, blinks);
  7018. return blink
  7019. };
  7020. cc.FadeTo = cc.ActionInterval.extend({_toOpacity: 0, _fromOpacity: 0, ctor: function (duration, opacity) {
  7021. cc.ActionInterval.prototype.ctor.call(this);
  7022. opacity !== undefined && this.initWithDuration(duration, opacity)
  7023. }, initWithDuration: function (duration, opacity) {
  7024. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  7025. this._toOpacity = opacity;
  7026. return true
  7027. }
  7028. return false
  7029. }, clone: function () {
  7030. var action = new cc.FadeTo;
  7031. this._cloneDecoration(action);
  7032. action.initWithDuration(this._duration, this._toOpacity);
  7033. return action
  7034. },
  7035. update: function (time) {
  7036. time = this._computeEaseTime(time);
  7037. if (this.target.RGBAProtocol) {
  7038. var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255;
  7039. this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time
  7040. }
  7041. }, startWithTarget: function (target) {
  7042. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7043. if (this.target.RGBAProtocol)this._fromOpacity = target.opacity
  7044. }});
  7045. cc.FadeTo.create = function (duration, opacity) {
  7046. return new cc.FadeTo(duration, opacity)
  7047. };
  7048. cc.FadeIn = cc.FadeTo.extend({_reverseAction: null, reverse: function () {
  7049. var action = new cc.FadeOut;
  7050. action.initWithDuration(this._duration, 0);
  7051. this._cloneDecoration(action);
  7052. this._reverseEaseList(action);
  7053. return action
  7054. }, clone: function () {
  7055. var action = new cc.FadeIn;
  7056. this._cloneDecoration(action);
  7057. action.initWithDuration(this._duration, this._toOpacity);
  7058. return action
  7059. }, startWithTarget: function (target) {
  7060. if (this._reverseAction)this._toOpacity = this._reverseAction._fromOpacity;
  7061. cc.FadeTo.prototype.startWithTarget.call(this,
  7062. target)
  7063. }});
  7064. cc.FadeIn.create = function (duration) {
  7065. return new cc.FadeIn(duration, 255)
  7066. };
  7067. cc.FadeOut = cc.FadeTo.extend({reverse: function () {
  7068. var action = new cc.FadeIn;
  7069. action._reverseAction = this;
  7070. action.initWithDuration(this._duration, 255);
  7071. this._cloneDecoration(action);
  7072. this._reverseEaseList(action);
  7073. return action
  7074. }, clone: function () {
  7075. var action = new cc.FadeOut;
  7076. this._cloneDecoration(action);
  7077. action.initWithDuration(this._duration, this._toOpacity);
  7078. return action
  7079. }});
  7080. cc.FadeOut.create = function (d) {
  7081. var action = new cc.FadeOut;
  7082. action.initWithDuration(d, 0);
  7083. return action
  7084. };
  7085. cc.TintTo = cc.ActionInterval.extend({_to: null, _from: null, ctor: function (duration, red, green, blue) {
  7086. cc.ActionInterval.prototype.ctor.call(this);
  7087. this._to = cc.color(0, 0, 0);
  7088. this._from = cc.color(0, 0, 0);
  7089. blue !== undefined && this.initWithDuration(duration, red, green, blue)
  7090. }, initWithDuration: function (duration, red, green, blue) {
  7091. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  7092. this._to = cc.color(red, green, blue);
  7093. return true
  7094. }
  7095. return false
  7096. }, clone: function () {
  7097. var action = new cc.TintTo;
  7098. this._cloneDecoration(action);
  7099. var locTo = this._to;
  7100. action.initWithDuration(this._duration, locTo.r, locTo.g, locTo.b);
  7101. return action
  7102. }, startWithTarget: function (target) {
  7103. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7104. if (this.target.RGBAProtocol)this._from = this.target.color
  7105. }, update: function (time) {
  7106. time = this._computeEaseTime(time);
  7107. var locFrom = this._from, locTo = this._to;
  7108. if (locFrom && this.target.RGBAProtocol)this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * time, locFrom.g + (locTo.g - locFrom.g) * time, locFrom.b + (locTo.b - locFrom.b) *
  7109. time)
  7110. }});
  7111. cc.TintTo.create = function (duration, red, green, blue) {
  7112. return new cc.TintTo(duration, red, green, blue)
  7113. };
  7114. cc.TintBy = cc.ActionInterval.extend({_deltaR: 0, _deltaG: 0, _deltaB: 0, _fromR: 0, _fromG: 0, _fromB: 0, ctor: function (duration, deltaRed, deltaGreen, deltaBlue) {
  7115. cc.ActionInterval.prototype.ctor.call(this);
  7116. deltaBlue !== undefined && this.initWithDuration(duration, deltaRed, deltaGreen, deltaBlue)
  7117. }, initWithDuration: function (duration, deltaRed, deltaGreen, deltaBlue) {
  7118. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  7119. this._deltaR = deltaRed;
  7120. this._deltaG = deltaGreen;
  7121. this._deltaB = deltaBlue;
  7122. return true
  7123. }
  7124. return false
  7125. },
  7126. clone: function () {
  7127. var action = new cc.TintBy;
  7128. this._cloneDecoration(action);
  7129. action.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
  7130. return action
  7131. }, startWithTarget: function (target) {
  7132. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7133. if (target.RGBAProtocol) {
  7134. var color = target.color;
  7135. this._fromR = color.r;
  7136. this._fromG = color.g;
  7137. this._fromB = color.b
  7138. }
  7139. }, update: function (time) {
  7140. time = this._computeEaseTime(time);
  7141. if (this.target.RGBAProtocol)this.target.color = cc.color(this._fromR + this._deltaR *
  7142. time, this._fromG + this._deltaG * time, this._fromB + this._deltaB * time)
  7143. }, reverse: function () {
  7144. var action = cc.TintBy.create(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
  7145. this._cloneDecoration(action);
  7146. this._reverseEaseList(action);
  7147. return action
  7148. }});
  7149. cc.TintBy.create = function (duration, deltaRed, deltaGreen, deltaBlue) {
  7150. return new cc.TintBy(duration, deltaRed, deltaGreen, deltaBlue)
  7151. };
  7152. cc.DelayTime = cc.ActionInterval.extend({update: function (time) {
  7153. }, reverse: function () {
  7154. var action = cc.DelayTime.create(this._duration);
  7155. this._cloneDecoration(action);
  7156. this._reverseEaseList(action);
  7157. return action
  7158. }, clone: function () {
  7159. var action = new cc.DelayTime;
  7160. this._cloneDecoration(action);
  7161. action.initWithDuration(this._duration);
  7162. return action
  7163. }});
  7164. cc.DelayTime.create = function (d) {
  7165. return new cc.DelayTime(d)
  7166. };
  7167. cc.ReverseTime = cc.ActionInterval.extend({_other: null, ctor: function (action) {
  7168. cc.ActionInterval.prototype.ctor.call(this);
  7169. this._other = null;
  7170. action && this.initWithAction(action)
  7171. }, initWithAction: function (action) {
  7172. if (!action)throw"cc.ReverseTime.initWithAction(): action must be non null";
  7173. if (action == this._other)throw"cc.ReverseTime.initWithAction(): the action was already passed in.";
  7174. if (cc.ActionInterval.prototype.initWithDuration.call(this, action._duration)) {
  7175. this._other = action;
  7176. return true
  7177. }
  7178. return false
  7179. }, clone: function () {
  7180. var action =
  7181. new cc.ReverseTime;
  7182. this._cloneDecoration(action);
  7183. action.initWithAction(this._other.clone());
  7184. return action
  7185. }, startWithTarget: function (target) {
  7186. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7187. this._other.startWithTarget(target)
  7188. }, update: function (time) {
  7189. time = this._computeEaseTime(time);
  7190. if (this._other)this._other.update(1 - time)
  7191. }, reverse: function () {
  7192. return this._other.clone()
  7193. }, stop: function () {
  7194. this._other.stop();
  7195. cc.Action.prototype.stop.call(this)
  7196. }});
  7197. cc.ReverseTime.create = function (action) {
  7198. return new cc.ReverseTime(action)
  7199. };
  7200. cc.Animate = cc.ActionInterval.extend({_animation: null, _nextFrame: 0, _origFrame: null, _executedLoops: 0, _splitTimes: null, ctor: function (animation) {
  7201. cc.ActionInterval.prototype.ctor.call(this);
  7202. this._splitTimes = [];
  7203. animation && this.initWithAnimation(animation)
  7204. }, getAnimation: function () {
  7205. return this._animation
  7206. }, setAnimation: function (animation) {
  7207. this._animation = animation
  7208. }, initWithAnimation: function (animation) {
  7209. if (!animation)throw"cc.Animate.initWithAnimation(): animation must be non-NULL";
  7210. var singleDuration = animation.getDuration();
  7211. if (this.initWithDuration(singleDuration * animation.getLoops())) {
  7212. this._nextFrame = 0;
  7213. this.setAnimation(animation);
  7214. this._origFrame = null;
  7215. this._executedLoops = 0;
  7216. var locTimes = this._splitTimes;
  7217. locTimes.length = 0;
  7218. var accumUnitsOfTime = 0;
  7219. var newUnitOfTimeValue = singleDuration / animation.getTotalDelayUnits();
  7220. var frames = animation.getFrames();
  7221. cc.arrayVerifyType(frames, cc.AnimationFrame);
  7222. for (var i = 0; i < frames.length; i++) {
  7223. var frame = frames[i];
  7224. var value = accumUnitsOfTime * newUnitOfTimeValue / singleDuration;
  7225. accumUnitsOfTime +=
  7226. frame.getDelayUnits();
  7227. locTimes.push(value)
  7228. }
  7229. return true
  7230. }
  7231. return false
  7232. }, clone: function () {
  7233. var action = new cc.Animate;
  7234. this._cloneDecoration(action);
  7235. action.initWithAnimation(this._animation.clone());
  7236. return action
  7237. }, startWithTarget: function (target) {
  7238. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7239. if (this._animation.getRestoreOriginalFrame())this._origFrame = target.displayFrame();
  7240. this._nextFrame = 0;
  7241. this._executedLoops = 0
  7242. }, update: function (time) {
  7243. time = this._computeEaseTime(time);
  7244. if (time < 1) {
  7245. time *= this._animation.getLoops();
  7246. var loopNumber = 0 | time;
  7247. if (loopNumber > this._executedLoops) {
  7248. this._nextFrame = 0;
  7249. this._executedLoops++
  7250. }
  7251. time = time % 1
  7252. }
  7253. var frames = this._animation.getFrames();
  7254. var numberOfFrames = frames.length, locSplitTimes = this._splitTimes;
  7255. for (var i = this._nextFrame; i < numberOfFrames; i++)if (locSplitTimes[i] <= time) {
  7256. this.target.setSpriteFrame(frames[i].getSpriteFrame());
  7257. this._nextFrame = i + 1
  7258. } else break
  7259. }, reverse: function () {
  7260. var locAnimation = this._animation;
  7261. var oldArray = locAnimation.getFrames();
  7262. var newArray = [];
  7263. cc.arrayVerifyType(oldArray,
  7264. cc.AnimationFrame);
  7265. if (oldArray.length > 0)for (var i = oldArray.length - 1; i >= 0; i--) {
  7266. var element = oldArray[i];
  7267. if (!element)break;
  7268. newArray.push(element.clone())
  7269. }
  7270. var newAnim = cc.Animation.create(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops());
  7271. newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame());
  7272. var action = cc.Animate.create(newAnim);
  7273. this._cloneDecoration(action);
  7274. this._reverseEaseList(action);
  7275. return action
  7276. }, stop: function () {
  7277. if (this._animation.getRestoreOriginalFrame() && this.target)this.target.setSpriteFrame(this._origFrame);
  7278. cc.Action.prototype.stop.call(this)
  7279. }});
  7280. cc.Animate.create = function (animation) {
  7281. return new cc.Animate(animation)
  7282. };
  7283. cc.TargetedAction = cc.ActionInterval.extend({_action: null, _forcedTarget: null, ctor: function (target, action) {
  7284. cc.ActionInterval.prototype.ctor.call(this);
  7285. action && this.initWithTarget(target, action)
  7286. }, initWithTarget: function (target, action) {
  7287. if (this.initWithDuration(action._duration)) {
  7288. this._forcedTarget = target;
  7289. this._action = action;
  7290. return true
  7291. }
  7292. return false
  7293. }, clone: function () {
  7294. var action = new cc.TargetedAction;
  7295. this._cloneDecoration(action);
  7296. action.initWithTarget(this._forcedTarget, this._action.clone());
  7297. return action
  7298. },
  7299. startWithTarget: function (target) {
  7300. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  7301. this._action.startWithTarget(this._forcedTarget)
  7302. }, stop: function () {
  7303. this._action.stop()
  7304. }, update: function (time) {
  7305. time = this._computeEaseTime(time);
  7306. this._action.update(time)
  7307. }, getForcedTarget: function () {
  7308. return this._forcedTarget
  7309. }, setForcedTarget: function (forcedTarget) {
  7310. if (this._forcedTarget != forcedTarget)this._forcedTarget = forcedTarget
  7311. }});
  7312. cc.TargetedAction.create = function (target, action) {
  7313. return new cc.TargetedAction(target, action)
  7314. };
  7315. cc.ActionInstant = cc.FiniteTimeAction.extend({isDone: function () {
  7316. return true
  7317. }, step: function (dt) {
  7318. this.update(1)
  7319. }, update: function (time) {
  7320. }, reverse: function () {
  7321. return this.clone()
  7322. }, clone: function () {
  7323. return new cc.ActionInstant
  7324. }});
  7325. cc.Show = cc.ActionInstant.extend({update: function (time) {
  7326. this.target.visible = true
  7327. }, reverse: function () {
  7328. return cc.Hide.create()
  7329. }, clone: function () {
  7330. return new cc.Show
  7331. }});
  7332. cc.Show.create = function () {
  7333. return new cc.Show
  7334. };
  7335. cc.Hide = cc.ActionInstant.extend({update: function (time) {
  7336. this.target.visible = false
  7337. }, reverse: function () {
  7338. return cc.Show.create()
  7339. }, clone: function () {
  7340. return new cc.Hide
  7341. }});
  7342. cc.Hide.create = function () {
  7343. return new cc.Hide
  7344. };
  7345. cc.ToggleVisibility = cc.ActionInstant.extend({update: function (time) {
  7346. this.target.visible = !this.target.visible
  7347. }, reverse: function () {
  7348. return new cc.ToggleVisibility
  7349. }, clone: function () {
  7350. return new cc.ToggleVisibility
  7351. }});
  7352. cc.ToggleVisibility.create = function () {
  7353. return new cc.ToggleVisibility
  7354. };
  7355. cc.RemoveSelf = cc.ActionInstant.extend({_isNeedCleanUp: true, ctor: function (isNeedCleanUp) {
  7356. cc.FiniteTimeAction.prototype.ctor.call(this);
  7357. isNeedCleanUp !== undefined && this.init(isNeedCleanUp)
  7358. }, update: function (time) {
  7359. this.target.removeFromParent(this._isNeedCleanUp)
  7360. }, init: function (isNeedCleanUp) {
  7361. this._isNeedCleanUp = isNeedCleanUp;
  7362. return true
  7363. }, reverse: function () {
  7364. return new cc.RemoveSelf(this._isNeedCleanUp)
  7365. }, clone: function () {
  7366. return new cc.RemoveSelf(this._isNeedCleanUp)
  7367. }});
  7368. cc.RemoveSelf.create = function (isNeedCleanUp) {
  7369. return new cc.RemoveSelf(isNeedCleanUp)
  7370. };
  7371. cc.FlipX = cc.ActionInstant.extend({_flippedX: false, ctor: function (flip) {
  7372. cc.FiniteTimeAction.prototype.ctor.call(this);
  7373. this._flippedX = false;
  7374. flip !== undefined && this.initWithFlipX(flip)
  7375. }, initWithFlipX: function (flip) {
  7376. this._flippedX = flip;
  7377. return true
  7378. }, update: function (time) {
  7379. this.target.flippedX = this._flippedX
  7380. }, reverse: function () {
  7381. return cc.FlipX.create(!this._flippedX)
  7382. }, clone: function () {
  7383. var action = new cc.FlipX;
  7384. action.initWithFlipX(this._flippedX);
  7385. return action
  7386. }});
  7387. cc.FlipX.create = function (flip) {
  7388. return new cc.FlipX(flip)
  7389. };
  7390. cc.FlipY = cc.ActionInstant.extend({_flippedY: false, ctor: function (flip) {
  7391. cc.FiniteTimeAction.prototype.ctor.call(this);
  7392. this._flippedY = false;
  7393. flip !== undefined && this.initWithFlipY(flip)
  7394. }, initWithFlipY: function (flip) {
  7395. this._flippedY = flip;
  7396. return true
  7397. }, update: function (time) {
  7398. this.target.flippedY = this._flippedY
  7399. }, reverse: function () {
  7400. return cc.FlipY.create(!this._flippedY)
  7401. }, clone: function () {
  7402. var action = new cc.FlipY;
  7403. action.initWithFlipY(this._flippedY);
  7404. return action
  7405. }});
  7406. cc.FlipY.create = function (flip) {
  7407. return new cc.FlipY(flip)
  7408. };
  7409. cc.Place = cc.ActionInstant.extend({_x: 0, _y: 0, ctor: function (pos, y) {
  7410. cc.FiniteTimeAction.prototype.ctor.call(this);
  7411. this._x = 0;
  7412. this._y = 0;
  7413. if (pos !== undefined) {
  7414. if (pos.x !== undefined) {
  7415. y = pos.y;
  7416. pos = pos.x
  7417. }
  7418. this.initWithPosition(pos, y)
  7419. }
  7420. }, initWithPosition: function (x, y) {
  7421. this._x = x;
  7422. this._y = y;
  7423. return true
  7424. }, update: function (time) {
  7425. this.target.setPosition(this._x, this._y)
  7426. }, clone: function () {
  7427. var action = new cc.Place;
  7428. action.initWithPosition(this._x, this._y);
  7429. return action
  7430. }});
  7431. cc.Place.create = function (pos, y) {
  7432. return new cc.Place(pos, y)
  7433. };
  7434. cc.CallFunc = cc.ActionInstant.extend({_selectorTarget: null, _callFunc: null, _function: null, _data: null, ctor: function (selector, selectorTarget, data) {
  7435. cc.FiniteTimeAction.prototype.ctor.call(this);
  7436. if (selector !== undefined)if (selectorTarget === undefined)this.initWithFunction(selector); else this.initWithFunction(selector, selectorTarget, data)
  7437. }, initWithFunction: function (selector, selectorTarget, data) {
  7438. if (selectorTarget) {
  7439. this._data = data;
  7440. this._callFunc = selector;
  7441. this._selectorTarget = selectorTarget
  7442. } else if (selector)this._function =
  7443. selector;
  7444. return true
  7445. }, execute: function () {
  7446. if (this._callFunc != null)this._callFunc.call(this._selectorTarget, this.target, this._data); else if (this._function)this._function.call(null, this.target)
  7447. }, update: function (time) {
  7448. this.execute()
  7449. }, getTargetCallback: function () {
  7450. return this._selectorTarget
  7451. }, setTargetCallback: function (sel) {
  7452. if (sel != this._selectorTarget) {
  7453. if (this._selectorTarget)this._selectorTarget = null;
  7454. this._selectorTarget = sel
  7455. }
  7456. }, clone: function () {
  7457. var action = new cc.CallFunc;
  7458. if (this._selectorTarget)action.initWithFunction(this._callFunc,
  7459. this._selectorTarget, this._data); else if (this._function)action.initWithFunction(this._function);
  7460. return action
  7461. }});
  7462. cc.CallFunc.create = function (selector, selectorTarget, data) {
  7463. return new cc.CallFunc(selector, selectorTarget, data)
  7464. };
  7465. cc.ActionCamera = cc.ActionInterval.extend({_centerXOrig: 0, _centerYOrig: 0, _centerZOrig: 0, _eyeXOrig: 0, _eyeYOrig: 0, _eyeZOrig: 0, _upXOrig: 0, _upYOrig: 0, _upZOrig: 0, ctor: function () {
  7466. var _t = this;
  7467. cc.ActionInterval.prototype.ctor.call(_t);
  7468. _t._centerXOrig = 0;
  7469. _t._centerYOrig = 0;
  7470. _t._centerZOrig = 0;
  7471. _t._eyeXOrig = 0;
  7472. _t._eyeYOrig = 0;
  7473. _t._eyeZOrig = 0;
  7474. _t._upXOrig = 0;
  7475. _t._upYOrig = 0;
  7476. _t._upZOrig = 0
  7477. }, startWithTarget: function (target) {
  7478. var _t = this;
  7479. cc.ActionInterval.prototype.startWithTarget.call(_t, target);
  7480. var camera = target.getCamera();
  7481. var centerXYZ = camera.getCenter();
  7482. _t._centerXOrig = centerXYZ.x;
  7483. _t._centerYOrig = centerXYZ.y;
  7484. _t._centerZOrig = centerXYZ.z;
  7485. var eyeXYZ = camera.getEye();
  7486. _t._eyeXOrig = eyeXYZ.x;
  7487. _t._eyeYOrig = eyeXYZ.y;
  7488. _t._eyeZOrig = eyeXYZ.z;
  7489. var upXYZ = camera.getUp();
  7490. _t._upXOrig = upXYZ.x;
  7491. _t._upYOrig = upXYZ.y;
  7492. _t._upZOrig = upXYZ.z
  7493. }, clone: function () {
  7494. return new cc.ActionCamera
  7495. }, reverse: function () {
  7496. return cc.ReverseTime.create(this)
  7497. }});
  7498. cc.OrbitCamera = cc.ActionCamera.extend({_radius: 0, _deltaRadius: 0, _angleZ: 0, _deltaAngleZ: 0, _angleX: 0, _deltaAngleX: 0, _radZ: 0, _radDeltaZ: 0, _radX: 0, _radDeltaX: 0, ctor: function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) {
  7499. cc.ActionCamera.prototype.ctor.call(this);
  7500. deltaAngleX !== undefined && this.initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)
  7501. }, initWithDuration: function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) {
  7502. if (cc.ActionInterval.prototype.initWithDuration.call(this,
  7503. t)) {
  7504. var _t = this;
  7505. _t._radius = radius;
  7506. _t._deltaRadius = deltaRadius;
  7507. _t._angleZ = angleZ;
  7508. _t._deltaAngleZ = deltaAngleZ;
  7509. _t._angleX = angleX;
  7510. _t._deltaAngleX = deltaAngleX;
  7511. _t._radDeltaZ = cc.degreesToRadians(deltaAngleZ);
  7512. _t._radDeltaX = cc.degreesToRadians(deltaAngleX);
  7513. return true
  7514. }
  7515. return false
  7516. }, sphericalRadius: function () {
  7517. var newRadius, zenith, azimuth;
  7518. var camera = this.target.getCamera();
  7519. var eyeXYZ = camera.getEye();
  7520. var centerXYZ = camera.getCenter();
  7521. var x = eyeXYZ.x - centerXYZ.x, y = eyeXYZ.y - centerXYZ.y, z = eyeXYZ.z - centerXYZ.z;
  7522. var r =
  7523. Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
  7524. var s = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
  7525. if (s === 0)s = cc.FLT_EPSILON;
  7526. if (r === 0)r = cc.FLT_EPSILON;
  7527. zenith = Math.acos(z / r);
  7528. if (x < 0)azimuth = Math.PI - Math.asin(y / s); else azimuth = Math.asin(y / s);
  7529. newRadius = r / cc.Camera.getZEye();
  7530. return{newRadius: newRadius, zenith: zenith, azimuth: azimuth}
  7531. }, startWithTarget: function (target) {
  7532. var _t = this;
  7533. cc.ActionInterval.prototype.startWithTarget.call(_t, target);
  7534. var retValue = _t.sphericalRadius();
  7535. if (isNaN(_t._radius))_t._radius = retValue.newRadius;
  7536. if (isNaN(_t._angleZ))_t._angleZ = cc.radiansToDegrees(retValue.zenith);
  7537. if (isNaN(_t._angleX))_t._angleX = cc.radiansToDegrees(retValue.azimuth);
  7538. _t._radZ = cc.degreesToRadians(_t._angleZ);
  7539. _t._radX = cc.degreesToRadians(_t._angleX)
  7540. }, clone: function () {
  7541. var a = new cc.OrbitCamera, _t = this;
  7542. a.initWithDuration(_t._duration, _t._radius, _t._deltaRadius, _t._angleZ, _t._deltaAngleZ, _t._angleX, _t._deltaAngleX);
  7543. return a
  7544. }, update: function (dt) {
  7545. dt = this._computeEaseTime(dt);
  7546. var r = (this._radius + this._deltaRadius * dt) * cc.Camera.getZEye();
  7547. var za = this._radZ + this._radDeltaZ * dt;
  7548. var xa = this._radX + this._radDeltaX * dt;
  7549. var i = Math.sin(za) * Math.cos(xa) * r + this._centerXOrig;
  7550. var j = Math.sin(za) * Math.sin(xa) * r + this._centerYOrig;
  7551. var k = Math.cos(za) * r + this._centerZOrig;
  7552. this.target.getCamera().setEye(i, j, k)
  7553. }});
  7554. cc.OrbitCamera.create = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) {
  7555. return new cc.OrbitCamera(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)
  7556. };
  7557. cc.ActionEase = cc.ActionInterval.extend({_inner: null, ctor: function (action) {
  7558. cc.ActionInterval.prototype.ctor.call(this);
  7559. action && this.initWithAction(action)
  7560. }, initWithAction: function (action) {
  7561. if (!action)throw"cc.ActionEase.initWithAction(): action must be non nil";
  7562. if (this.initWithDuration(action.getDuration())) {
  7563. this._inner = action;
  7564. return true
  7565. }
  7566. return false
  7567. }, clone: function () {
  7568. var action = new cc.ActionEase;
  7569. action.initWithAction(this._inner.clone());
  7570. return action
  7571. }, startWithTarget: function (target) {
  7572. cc.ActionInterval.prototype.startWithTarget.call(this,
  7573. target);
  7574. this._inner.startWithTarget(this.target)
  7575. }, stop: function () {
  7576. this._inner.stop();
  7577. cc.ActionInterval.prototype.stop.call(this)
  7578. }, update: function (time1) {
  7579. this._inner.update(time1)
  7580. }, reverse: function () {
  7581. return cc.ActionEase.create(this._inner.reverse())
  7582. }, getInnerAction: function () {
  7583. return this._inner
  7584. }});
  7585. cc.ActionEase.create = function (action) {
  7586. return new cc.ActionEase(action)
  7587. };
  7588. cc.EaseRateAction = cc.ActionEase.extend({_rate: 0, ctor: function (action, rate) {
  7589. cc.ActionEase.prototype.ctor.call(this);
  7590. rate !== undefined && this.initWithAction(action, rate)
  7591. }, setRate: function (rate) {
  7592. this._rate = rate
  7593. }, getRate: function () {
  7594. return this._rate
  7595. }, initWithAction: function (action, rate) {
  7596. if (cc.ActionEase.prototype.initWithAction.call(this, action)) {
  7597. this._rate = rate;
  7598. return true
  7599. }
  7600. return false
  7601. }, clone: function () {
  7602. var action = new cc.EaseRateAction;
  7603. action.initWithAction(this._inner.clone(), this._rate);
  7604. return action
  7605. },
  7606. reverse: function () {
  7607. return cc.EaseRateAction.create(this._inner.reverse(), 1 / this._rate)
  7608. }});
  7609. cc.EaseRateAction.create = function (action, rate) {
  7610. return new cc.EaseRateAction(action, rate)
  7611. };
  7612. cc.EaseIn = cc.EaseRateAction.extend({update: function (time1) {
  7613. this._inner.update(Math.pow(time1, this._rate))
  7614. }, reverse: function () {
  7615. return cc.EaseIn.create(this._inner.reverse(), 1 / this._rate)
  7616. }, clone: function () {
  7617. var action = new cc.EaseIn;
  7618. action.initWithAction(this._inner.clone(), this._rate);
  7619. return action
  7620. }});
  7621. cc.EaseIn.create = function (action, rate) {
  7622. return new cc.EaseIn(action, rate)
  7623. };
  7624. cc.easeIn = function (rate) {
  7625. return{_rate: rate, easing: function (dt) {
  7626. return Math.pow(dt, this._rate)
  7627. }, reverse: function () {
  7628. return cc.easeIn(1 / this._rate)
  7629. }}
  7630. };
  7631. cc.EaseOut = cc.EaseRateAction.extend({update: function (time1) {
  7632. this._inner.update(Math.pow(time1, 1 / this._rate))
  7633. }, reverse: function () {
  7634. return cc.EaseOut.create(this._inner.reverse(), 1 / this._rate)
  7635. }, clone: function () {
  7636. var action = new cc.EaseOut;
  7637. action.initWithAction(this._inner.clone(), this._rate);
  7638. return action
  7639. }});
  7640. cc.EaseOut.create = function (action, rate) {
  7641. return new cc.EaseOut(action, rate)
  7642. };
  7643. cc.easeOut = function (rate) {
  7644. return{_rate: rate, easing: function (dt) {
  7645. return Math.pow(dt, 1 / this._rate)
  7646. }, reverse: function () {
  7647. return cc.easeOut(1 / this._rate)
  7648. }}
  7649. };
  7650. cc.EaseInOut = cc.EaseRateAction.extend({update: function (time1) {
  7651. time1 *= 2;
  7652. if (time1 < 1)this._inner.update(0.5 * Math.pow(time1, this._rate)); else this._inner.update(1 - 0.5 * Math.pow(2 - time1, this._rate))
  7653. }, clone: function () {
  7654. var action = new cc.EaseInOut;
  7655. action.initWithAction(this._inner.clone(), this._rate);
  7656. return action
  7657. }, reverse: function () {
  7658. return cc.EaseInOut.create(this._inner.reverse(), this._rate)
  7659. }});
  7660. cc.EaseInOut.create = function (action, rate) {
  7661. return new cc.EaseInOut(action, rate)
  7662. };
  7663. cc.easeInOut = function (rate) {
  7664. return{_rate: rate, easing: function (dt) {
  7665. dt *= 2;
  7666. if (dt < 1)return 0.5 * Math.pow(dt, this._rate); else return 1 - 0.5 * Math.pow(2 - dt, this._rate)
  7667. }, reverse: function () {
  7668. return cc.easeInOut(this._rate)
  7669. }}
  7670. };
  7671. cc.EaseExponentialIn = cc.ActionEase.extend({update: function (time1) {
  7672. this._inner.update(time1 === 0 ? 0 : Math.pow(2, 10 * (time1 - 1)))
  7673. }, reverse: function () {
  7674. return cc.EaseExponentialOut.create(this._inner.reverse())
  7675. }, clone: function () {
  7676. var action = new cc.EaseExponentialIn;
  7677. action.initWithAction(this._inner.clone());
  7678. return action
  7679. }});
  7680. cc.EaseExponentialIn.create = function (action) {
  7681. return new cc.EaseExponentialIn(action)
  7682. };
  7683. cc._easeExponentialInObj = {easing: function (dt) {
  7684. return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1))
  7685. }, reverse: function () {
  7686. return cc._easeExponentialOutObj
  7687. }};
  7688. cc.easeExponentialIn = function () {
  7689. return cc._easeExponentialInObj
  7690. };
  7691. cc.EaseExponentialOut = cc.ActionEase.extend({update: function (time1) {
  7692. this._inner.update(time1 == 1 ? 1 : -Math.pow(2, -10 * time1) + 1)
  7693. }, reverse: function () {
  7694. return cc.EaseExponentialIn.create(this._inner.reverse())
  7695. }, clone: function () {
  7696. var action = new cc.EaseExponentialOut;
  7697. action.initWithAction(this._inner.clone());
  7698. return action
  7699. }});
  7700. cc.EaseExponentialOut.create = function (action) {
  7701. return new cc.EaseExponentialOut(action)
  7702. };
  7703. cc._easeExponentialOutObj = {easing: function (dt) {
  7704. return dt == 1 ? 1 : -Math.pow(2, -10 * dt) + 1
  7705. }, reverse: function () {
  7706. return cc._easeExponentialInObj
  7707. }};
  7708. cc.easeExponentialOut = function () {
  7709. return cc._easeExponentialOutObj
  7710. };
  7711. cc.EaseExponentialInOut = cc.ActionEase.extend({update: function (time) {
  7712. if (time != 1 && time !== 0) {
  7713. time *= 2;
  7714. if (time < 1)time = 0.5 * Math.pow(2, 10 * (time - 1)); else time = 0.5 * (-Math.pow(2, -10 * (time - 1)) + 2)
  7715. }
  7716. this._inner.update(time)
  7717. }, reverse: function () {
  7718. return cc.EaseExponentialInOut.create(this._inner.reverse())
  7719. }, clone: function () {
  7720. var action = new cc.EaseExponentialInOut;
  7721. action.initWithAction(this._inner.clone());
  7722. return action
  7723. }});
  7724. cc.EaseExponentialInOut.create = function (action) {
  7725. return new cc.EaseExponentialInOut(action)
  7726. };
  7727. cc._easeExponentialInOutObj = {easing: function (dt) {
  7728. if (dt !== 1 && dt !== 0) {
  7729. dt *= 2;
  7730. if (dt < 1)return 0.5 * Math.pow(2, 10 * (dt - 1)); else return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2)
  7731. }
  7732. return dt
  7733. }, reverse: function () {
  7734. return cc._easeExponentialInOutObj
  7735. }};
  7736. cc.easeExponentialInOut = function () {
  7737. return cc._easeExponentialInOutObj
  7738. };
  7739. cc.EaseSineIn = cc.ActionEase.extend({update: function (time1) {
  7740. time1 = time1 === 0 || time1 === 1 ? time1 : -1 * Math.cos(time1 * Math.PI / 2) + 1;
  7741. this._inner.update(time1)
  7742. }, reverse: function () {
  7743. return cc.EaseSineOut.create(this._inner.reverse())
  7744. }, clone: function () {
  7745. var action = new cc.EaseSineIn;
  7746. action.initWithAction(this._inner.clone());
  7747. return action
  7748. }});
  7749. cc.EaseSineIn.create = function (action) {
  7750. return new cc.EaseSineIn(action)
  7751. };
  7752. cc._easeSineInObj = {easing: function (dt) {
  7753. return dt === 0 || dt === 1 ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1
  7754. }, reverse: function () {
  7755. return cc._easeSineOutObj
  7756. }};
  7757. cc.easeSineIn = function () {
  7758. return cc._easeSineInObj
  7759. };
  7760. cc.EaseSineOut = cc.ActionEase.extend({update: function (time1) {
  7761. time1 = time1 === 0 || time1 === 1 ? time1 : Math.sin(time1 * Math.PI / 2);
  7762. this._inner.update(time1)
  7763. }, reverse: function () {
  7764. return cc.EaseSineIn.create(this._inner.reverse())
  7765. }, clone: function () {
  7766. var action = new cc.EaseSineOut;
  7767. action.initWithAction(this._inner.clone());
  7768. return action
  7769. }});
  7770. cc.EaseSineOut.create = function (action) {
  7771. return new cc.EaseSineOut(action)
  7772. };
  7773. cc._easeSineOutObj = {easing: function (dt) {
  7774. return dt === 0 || dt == 1 ? dt : Math.sin(dt * Math.PI / 2)
  7775. }, reverse: function () {
  7776. return cc._easeSineInObj
  7777. }};
  7778. cc.easeSineOut = function () {
  7779. return cc._easeSineOutObj
  7780. };
  7781. cc.EaseSineInOut = cc.ActionEase.extend({update: function (time1) {
  7782. time1 = time1 === 0 || time1 === 1 ? time1 : -0.5 * (Math.cos(Math.PI * time1) - 1);
  7783. this._inner.update(time1)
  7784. }, clone: function () {
  7785. var action = new cc.EaseSineInOut;
  7786. action.initWithAction(this._inner.clone());
  7787. return action
  7788. }, reverse: function () {
  7789. return cc.EaseSineInOut.create(this._inner.reverse())
  7790. }});
  7791. cc.EaseSineInOut.create = function (action) {
  7792. return new cc.EaseSineInOut(action)
  7793. };
  7794. cc._easeSineInOutObj = {easing: function (dt) {
  7795. return dt === 0 || dt === 1 ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1)
  7796. }, reverse: function () {
  7797. return cc._easeSineInOutObj
  7798. }};
  7799. cc.easeSineInOut = function () {
  7800. return cc._easeSineInOutObj
  7801. };
  7802. cc.EaseElastic = cc.ActionEase.extend({_period: 0.3, ctor: function (action, period) {
  7803. cc.ActionEase.prototype.ctor.call(this);
  7804. action && this.initWithAction(action, period)
  7805. }, getPeriod: function () {
  7806. return this._period
  7807. }, setPeriod: function (period) {
  7808. this._period = period
  7809. }, initWithAction: function (action, period) {
  7810. cc.ActionEase.prototype.initWithAction.call(this, action);
  7811. this._period = period == null ? 0.3 : period;
  7812. return true
  7813. }, reverse: function () {
  7814. cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
  7815. return null
  7816. },
  7817. clone: function () {
  7818. var action = new cc.EaseElastic;
  7819. action.initWithAction(this._inner.clone(), this._period);
  7820. return action
  7821. }});
  7822. cc.EaseElastic.create = function (action, period) {
  7823. return new cc.EaseElastic(action, period)
  7824. };
  7825. cc.EaseElasticIn = cc.EaseElastic.extend({update: function (time1) {
  7826. var newT = 0;
  7827. if (time1 === 0 || time1 === 1)newT = time1; else {
  7828. var s = this._period / 4;
  7829. time1 = time1 - 1;
  7830. newT = -Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period)
  7831. }
  7832. this._inner.update(newT)
  7833. }, reverse: function () {
  7834. return cc.EaseElasticOut.create(this._inner.reverse(), this._period)
  7835. }, clone: function () {
  7836. var action = new cc.EaseElasticIn;
  7837. action.initWithAction(this._inner.clone(), this._period);
  7838. return action
  7839. }});
  7840. cc.EaseElasticIn.create = function (action, period) {
  7841. return new cc.EaseElasticIn(action, period)
  7842. };
  7843. cc._easeElasticInObj = {easing: function (dt) {
  7844. if (dt === 0 || dt === 1)return dt;
  7845. dt = dt - 1;
  7846. return-Math.pow(2, 10 * dt) * Math.sin((dt - 0.3 / 4) * Math.PI * 2 / 0.3)
  7847. }, reverse: function () {
  7848. return cc._easeElasticOutObj
  7849. }};
  7850. cc.easeElasticIn = function (period) {
  7851. if (period && period !== 0.3)return{_period: period, easing: function (dt) {
  7852. if (dt === 0 || dt === 1)return dt;
  7853. dt = dt - 1;
  7854. return-Math.pow(2, 10 * dt) * Math.sin((dt - this._period / 4) * Math.PI * 2 / this._period)
  7855. }, reverse: function () {
  7856. return cc.easeElasticOut(this._period)
  7857. }};
  7858. return cc._easeElasticInObj
  7859. };
  7860. cc.EaseElasticOut = cc.EaseElastic.extend({update: function (time1) {
  7861. var newT = 0;
  7862. if (time1 === 0 || time1 == 1)newT = time1; else {
  7863. var s = this._period / 4;
  7864. newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period) + 1
  7865. }
  7866. this._inner.update(newT)
  7867. }, reverse: function () {
  7868. return cc.EaseElasticIn.create(this._inner.reverse(), this._period)
  7869. }, clone: function () {
  7870. var action = new cc.EaseElasticOut;
  7871. action.initWithAction(this._inner.clone(), this._period);
  7872. return action
  7873. }});
  7874. cc.EaseElasticOut.create = function (action, period) {
  7875. return new cc.EaseElasticOut(action, period)
  7876. };
  7877. cc._easeElasticOutObj = {easing: function (dt) {
  7878. return dt === 0 || dt === 1 ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - 0.3 / 4) * Math.PI * 2 / 0.3) + 1
  7879. }, reverse: function () {
  7880. return cc._easeElasticInObj
  7881. }};
  7882. cc.easeElasticOut = function (period) {
  7883. if (period && period !== 0.3)return{_period: period, easing: function (dt) {
  7884. return dt === 0 || dt === 1 ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - this._period / 4) * Math.PI * 2 / this._period) + 1
  7885. }, reverse: function () {
  7886. return cc.easeElasticIn(this._period)
  7887. }};
  7888. return cc._easeElasticOutObj
  7889. };
  7890. cc.EaseElasticInOut = cc.EaseElastic.extend({update: function (time1) {
  7891. var newT = 0;
  7892. var locPeriod = this._period;
  7893. if (time1 === 0 || time1 == 1)newT = time1; else {
  7894. time1 = time1 * 2;
  7895. if (!locPeriod)locPeriod = this._period = 0.3 * 1.5;
  7896. var s = locPeriod / 4;
  7897. time1 = time1 - 1;
  7898. if (time1 < 0)newT = -0.5 * Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / locPeriod); else newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / locPeriod) * 0.5 + 1
  7899. }
  7900. this._inner.update(newT)
  7901. }, reverse: function () {
  7902. return cc.EaseElasticInOut.create(this._inner.reverse(), this._period)
  7903. },
  7904. clone: function () {
  7905. var action = new cc.EaseElasticInOut;
  7906. action.initWithAction(this._inner.clone(), this._period);
  7907. return action
  7908. }});
  7909. cc.EaseElasticInOut.create = function (action, period) {
  7910. return new cc.EaseElasticInOut(action, period)
  7911. };
  7912. cc.easeElasticInOut = function (period) {
  7913. period = period || 0.3;
  7914. return{_period: period, easing: function (dt) {
  7915. var newT = 0;
  7916. var locPeriod = this._period;
  7917. if (dt === 0 || dt === 1)newT = dt; else {
  7918. dt = dt * 2;
  7919. if (!locPeriod)locPeriod = this._period = 0.3 * 1.5;
  7920. var s = locPeriod / 4;
  7921. dt = dt - 1;
  7922. if (dt < 0)newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod); else newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1
  7923. }
  7924. return newT
  7925. }, reverse: function () {
  7926. return cc.easeElasticInOut(this._period)
  7927. }}
  7928. };
  7929. cc.EaseBounce = cc.ActionEase.extend({bounceTime: function (time1) {
  7930. if (time1 < 1 / 2.75)return 7.5625 * time1 * time1; else if (time1 < 2 / 2.75) {
  7931. time1 -= 1.5 / 2.75;
  7932. return 7.5625 * time1 * time1 + 0.75
  7933. } else if (time1 < 2.5 / 2.75) {
  7934. time1 -= 2.25 / 2.75;
  7935. return 7.5625 * time1 * time1 + 0.9375
  7936. }
  7937. time1 -= 2.625 / 2.75;
  7938. return 7.5625 * time1 * time1 + 0.984375
  7939. }, clone: function () {
  7940. var action = new cc.EaseBounce;
  7941. action.initWithAction(this._inner.clone());
  7942. return action
  7943. }, reverse: function () {
  7944. return cc.EaseBounce.create(this._inner.reverse())
  7945. }});
  7946. cc.EaseBounce.create = function (action) {
  7947. return new cc.EaseBounce(action)
  7948. };
  7949. cc.EaseBounceIn = cc.EaseBounce.extend({update: function (time1) {
  7950. var newT = 1 - this.bounceTime(1 - time1);
  7951. this._inner.update(newT)
  7952. }, reverse: function () {
  7953. return cc.EaseBounceOut.create(this._inner.reverse())
  7954. }, clone: function () {
  7955. var action = new cc.EaseBounceIn;
  7956. action.initWithAction(this._inner.clone());
  7957. return action
  7958. }});
  7959. cc.EaseBounceIn.create = function (action) {
  7960. return new cc.EaseBounceIn(action)
  7961. };
  7962. cc._bounceTime = function (time1) {
  7963. if (time1 < 1 / 2.75)return 7.5625 * time1 * time1; else if (time1 < 2 / 2.75) {
  7964. time1 -= 1.5 / 2.75;
  7965. return 7.5625 * time1 * time1 + 0.75
  7966. } else if (time1 < 2.5 / 2.75) {
  7967. time1 -= 2.25 / 2.75;
  7968. return 7.5625 * time1 * time1 + 0.9375
  7969. }
  7970. time1 -= 2.625 / 2.75;
  7971. return 7.5625 * time1 * time1 + 0.984375
  7972. };
  7973. cc._easeBounceInObj = {easing: function (dt) {
  7974. return 1 - cc._bounceTime(1 - dt)
  7975. }, reverse: function () {
  7976. return cc._easeBounceOutObj
  7977. }};
  7978. cc.easeBounceIn = function () {
  7979. return cc._easeBounceInObj
  7980. };
  7981. cc.EaseBounceOut = cc.EaseBounce.extend({update: function (time1) {
  7982. var newT = this.bounceTime(time1);
  7983. this._inner.update(newT)
  7984. }, reverse: function () {
  7985. return cc.EaseBounceIn.create(this._inner.reverse())
  7986. }, clone: function () {
  7987. var action = new cc.EaseBounceOut;
  7988. action.initWithAction(this._inner.clone());
  7989. return action
  7990. }});
  7991. cc.EaseBounceOut.create = function (action) {
  7992. return new cc.EaseBounceOut(action)
  7993. };
  7994. cc._easeBounceOutObj = {easing: function (dt) {
  7995. return cc._bounceTime(dt)
  7996. }, reverse: function () {
  7997. return cc._easeBounceInObj
  7998. }};
  7999. cc.easeBounceOut = function () {
  8000. return cc._easeBounceOutObj
  8001. };
  8002. cc.EaseBounceInOut = cc.EaseBounce.extend({update: function (time1) {
  8003. var newT = 0;
  8004. if (time1 < 0.5) {
  8005. time1 = time1 * 2;
  8006. newT = (1 - this.bounceTime(1 - time1)) * 0.5
  8007. } else newT = this.bounceTime(time1 * 2 - 1) * 0.5 + 0.5;
  8008. this._inner.update(newT)
  8009. }, clone: function () {
  8010. var action = new cc.EaseBounceInOut;
  8011. action.initWithAction(this._inner.clone());
  8012. return action
  8013. }, reverse: function () {
  8014. return cc.EaseBounceInOut.create(this._inner.reverse())
  8015. }});
  8016. cc.EaseBounceInOut.create = function (action) {
  8017. return new cc.EaseBounceInOut(action)
  8018. };
  8019. cc._easeBounceInOutObj = {easing: function (time1) {
  8020. var newT;
  8021. if (time1 < 0.5) {
  8022. time1 = time1 * 2;
  8023. newT = (1 - cc._bounceTime(1 - time1)) * 0.5
  8024. } else newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5;
  8025. return newT
  8026. }, reverse: function () {
  8027. return cc._easeBounceInOutObj
  8028. }};
  8029. cc.easeBounceInOut = function () {
  8030. return cc._easeBounceInOutObj
  8031. };
  8032. cc.EaseBackIn = cc.ActionEase.extend({update: function (time1) {
  8033. var overshoot = 1.70158;
  8034. time1 = time1 === 0 || time1 == 1 ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot);
  8035. this._inner.update(time1)
  8036. }, reverse: function () {
  8037. return cc.EaseBackOut.create(this._inner.reverse())
  8038. }, clone: function () {
  8039. var action = new cc.EaseBackIn;
  8040. action.initWithAction(this._inner.clone());
  8041. return action
  8042. }});
  8043. cc.EaseBackIn.create = function (action) {
  8044. return new cc.EaseBackIn(action)
  8045. };
  8046. cc._easeBackInObj = {easing: function (time1) {
  8047. var overshoot = 1.70158;
  8048. return time1 === 0 || time1 === 1 ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot)
  8049. }, reverse: function () {
  8050. return cc._easeBackOutObj
  8051. }};
  8052. cc.easeBackIn = function () {
  8053. return cc._easeBackInObj
  8054. };
  8055. cc.EaseBackOut = cc.ActionEase.extend({update: function (time1) {
  8056. var overshoot = 1.70158;
  8057. time1 = time1 - 1;
  8058. this._inner.update(time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1)
  8059. }, reverse: function () {
  8060. return cc.EaseBackIn.create(this._inner.reverse())
  8061. }, clone: function () {
  8062. var action = new cc.EaseBackOut;
  8063. action.initWithAction(this._inner.clone());
  8064. return action
  8065. }});
  8066. cc.EaseBackOut.create = function (action) {
  8067. return new cc.EaseBackOut(action)
  8068. };
  8069. cc._easeBackOutObj = {easing: function (time1) {
  8070. var overshoot = 1.70158;
  8071. time1 = time1 - 1;
  8072. return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1
  8073. }, reverse: function () {
  8074. return cc._easeBackInObj
  8075. }};
  8076. cc.easeBackOut = function () {
  8077. return cc._easeBackOutObj
  8078. };
  8079. cc.EaseBackInOut = cc.ActionEase.extend({update: function (time1) {
  8080. var overshoot = 1.70158 * 1.525;
  8081. time1 = time1 * 2;
  8082. if (time1 < 1)this._inner.update(time1 * time1 * ((overshoot + 1) * time1 - overshoot) / 2); else {
  8083. time1 = time1 - 2;
  8084. this._inner.update(time1 * time1 * ((overshoot + 1) * time1 + overshoot) / 2 + 1)
  8085. }
  8086. }, clone: function () {
  8087. var action = new cc.EaseBackInOut;
  8088. action.initWithAction(this._inner.clone());
  8089. return action
  8090. }, reverse: function () {
  8091. return cc.EaseBackInOut.create(this._inner.reverse())
  8092. }});
  8093. cc.EaseBackInOut.create = function (action) {
  8094. return new cc.EaseBackInOut(action)
  8095. };
  8096. cc._easeBackInOutObj = {easing: function (time1) {
  8097. var overshoot = 1.70158 * 1.525;
  8098. time1 = time1 * 2;
  8099. if (time1 < 1)return time1 * time1 * ((overshoot + 1) * time1 - overshoot) / 2; else {
  8100. time1 = time1 - 2;
  8101. return time1 * time1 * ((overshoot + 1) * time1 + overshoot) / 2 + 1
  8102. }
  8103. }, reverse: function () {
  8104. return cc._easeBackInOutObj
  8105. }};
  8106. cc.easeBackInOut = function () {
  8107. return cc._easeBackInOutObj
  8108. };
  8109. cc.EaseBezierAction = cc.ActionEase.extend({_p0: null, _p1: null, _p2: null, _p3: null, ctor: function (action) {
  8110. cc.ActionEase.prototype.ctor.call(this, action)
  8111. }, _updateTime: function (a, b, c, d, t) {
  8112. return Math.pow(1 - t, 3) * a + 3 * t * Math.pow(1 - t, 2) * b + 3 * Math.pow(t, 2) * (1 - t) * c + Math.pow(t, 3) * d
  8113. }, update: function (time) {
  8114. var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, time);
  8115. this._inner.update(t)
  8116. }, clone: function () {
  8117. var action = new cc.EaseBezierAction;
  8118. action.initWithAction(this._inner.clone());
  8119. action.setBezierParamer(this._p0,
  8120. this._p1, this._p2, this._p3);
  8121. return action
  8122. }, reverse: function () {
  8123. var action = cc.EaseBezierAction.create(this._inner.reverse());
  8124. action.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
  8125. return action
  8126. }, setBezierParamer: function (p0, p1, p2, p3) {
  8127. this._p0 = p0 || 0;
  8128. this._p1 = p1 || 0;
  8129. this._p2 = p2 || 0;
  8130. this._p3 = p3 || 0
  8131. }});
  8132. cc.EaseBezierAction.create = function (action) {
  8133. return new cc.EaseBezierAction(action)
  8134. };
  8135. cc.easeBezierAction = function (p0, p1, p2, p3) {
  8136. return{easing: function (time) {
  8137. return cc.EaseBezierAction.prototype._updateTime(p0, p1, p2, p3, time)
  8138. }, reverse: function () {
  8139. return cc.easeBezierAction(p3, p2, p1, p0)
  8140. }}
  8141. };
  8142. cc.EaseQuadraticActionIn = cc.ActionEase.extend({_updateTime: function (time) {
  8143. return Math.pow(time, 2)
  8144. }, update: function (time) {
  8145. this._inner.update(this._updateTime(time))
  8146. }, clone: function () {
  8147. var action = new cc.EaseQuadraticActionIn;
  8148. action.initWithAction(this._inner.clone());
  8149. return action
  8150. }, reverse: function () {
  8151. return cc.EaseQuadraticActionIn.create(this._inner.reverse())
  8152. }});
  8153. cc.EaseQuadraticActionIn.create = function (action) {
  8154. return new cc.EaseQuadraticActionIn(action)
  8155. };
  8156. cc._easeQuadraticActionIn = {easing: cc.EaseQuadraticActionIn.prototype._updateTime, reverse: function () {
  8157. return cc._easeQuadraticActionIn
  8158. }};
  8159. cc.easeQuadraticActionIn = function () {
  8160. return cc._easeQuadraticActionIn
  8161. };
  8162. cc.EaseQuadraticActionOut = cc.ActionEase.extend({_updateTime: function (time) {
  8163. return-time * (time - 2)
  8164. }, update: function (time) {
  8165. this._inner.update(this._updateTime(time))
  8166. }, clone: function () {
  8167. var action = new cc.EaseQuadraticActionOut;
  8168. action.initWithAction();
  8169. return action
  8170. }, reverse: function () {
  8171. return cc.EaseQuadraticActionOut.create(this._inner.reverse())
  8172. }});
  8173. cc.EaseQuadraticActionOut.create = function (action) {
  8174. return new cc.EaseQuadraticActionOut(action)
  8175. };
  8176. cc._easeQuadraticActionOut = {easing: cc.EaseQuadraticActionOut.prototype._updateTime, reverse: function () {
  8177. return cc._easeQuadraticActionOut
  8178. }};
  8179. cc.easeQuadraticActionOut = function () {
  8180. return cc._easeQuadraticActionOut
  8181. };
  8182. cc.EaseQuadraticActionInOut = cc.ActionEase.extend({_updateTime: function (time) {
  8183. var resultTime = time;
  8184. time *= 2;
  8185. if (time < 1)resultTime = time * time * 0.5; else {
  8186. --time;
  8187. resultTime = -0.5 * (time * (time - 2) - 1)
  8188. }
  8189. return resultTime
  8190. }, update: function (time) {
  8191. this._inner.update(this._updateTime(time))
  8192. }, clone: function () {
  8193. var action = new cc.EaseQuadraticActionInOut;
  8194. action.initWithAction(this._inner.clone());
  8195. return action
  8196. }, reverse: function () {
  8197. return cc.EaseQuadraticActionInOut.create(this._inner.reverse())
  8198. }});
  8199. cc.EaseQuadraticActionInOut.create = function (action) {
  8200. return new cc.EaseQuadraticActionInOut(action)
  8201. };
  8202. cc._easeQuadraticActionInOut = {easing: cc.EaseQuadraticActionInOut.prototype._updateTime, reverse: function () {
  8203. return cc._easeQuadraticActionInOut
  8204. }};
  8205. cc.easeQuadraticActionInOut = function () {
  8206. return cc._easeQuadraticActionInOut
  8207. };
  8208. cc.EaseQuarticActionIn = cc.ActionEase.extend({_updateTime: function (time) {
  8209. return time * time * time * time
  8210. }, update: function (time) {
  8211. this._inner.update(this._updateTime(time))
  8212. }, clone: function () {
  8213. var action = new cc.EaseQuarticActionIn;
  8214. action.initWithAction(this._inner.clone());
  8215. return action
  8216. }, reverse: function () {
  8217. return cc.EaseQuarticActionIn.create(this._inner.reverse())
  8218. }});
  8219. cc.EaseQuarticActionIn.create = function (action) {
  8220. return new cc.EaseQuarticActionIn(action)
  8221. };
  8222. cc._easeQuarticActionIn = {easing: cc.EaseQuarticActionIn.prototype._updateTime, reverse: function () {
  8223. return cc._easeQuarticActionIn
  8224. }};
  8225. cc.easeQuarticActionIn = function () {
  8226. return cc._easeQuarticActionIn
  8227. };
  8228. cc.EaseQuarticActionOut = cc.ActionEase.extend({_updateTime: function (time) {
  8229. time -= 1;
  8230. return-(time * time * time * time - 1)
  8231. }, update: function (time) {
  8232. this._inner.update(this._updateTime(time))
  8233. }, clone: function () {
  8234. var action = new cc.EaseQuarticActionOut;
  8235. action.initWithAction(this._inner.clone());
  8236. return action
  8237. }, reverse: function () {
  8238. return cc.EaseQuarticActionOut.create(this._inner.reverse())
  8239. }});
  8240. cc.EaseQuarticActionOut.create = function (action) {
  8241. return new cc.EaseQuarticActionOut(action)
  8242. };
  8243. cc._easeQuarticActionOut = {easing: cc.EaseQuarticActionOut.prototype._updateTime, reverse: function () {
  8244. return cc._easeQuarticActionOut
  8245. }};
  8246. cc.easeQuarticActionOut = function () {
  8247. return cc._easeQuarticActionOut
  8248. };
  8249. cc.EaseQuarticActionInOut = cc.ActionEase.extend({_updateTime: function (time) {
  8250. time = time * 2;
  8251. if (time < 1)return 0.5 * time * time * time * time;
  8252. time -= 2;
  8253. return-0.5 * (time * time * time * time - 2)
  8254. }, update: function (time) {
  8255. this._inner.update(this._updateTime(time))
  8256. }, clone: function () {
  8257. var action = new cc.EaseQuarticActionInOut;
  8258. action.initWithAction(this._inner.clone());
  8259. return action
  8260. }, reverse: function () {
  8261. return cc.EaseQuarticActionInOut.create(this._inner.reverse())
  8262. }});
  8263. cc.EaseQuarticActionInOut.create = function (action) {
  8264. return new cc.EaseQuarticActionInOut(action)
  8265. };
  8266. cc._easeQuarticActionInOut = {easing: cc.EaseQuarticActionInOut.prototype._updateTime, reverse: function () {
  8267. return cc._easeQuarticActionInOut
  8268. }};
  8269. cc.easeQuarticActionInOut = function () {
  8270. return cc._easeQuarticActionInOut
  8271. };
  8272. cc.EaseQuinticActionIn = cc.ActionEase.extend({_updateTime: function (time) {
  8273. return time * time * time * time * time
  8274. }, update: function (time) {
  8275. this._inner.update(this._updateTime(time))
  8276. }, clone: function () {
  8277. var action = new cc.EaseQuinticActionIn;
  8278. action.initWithAction(this._inner.clone());
  8279. return action
  8280. }, reverse: function () {
  8281. return cc.EaseQuinticActionIn.create(this._inner.reverse())
  8282. }});
  8283. cc.EaseQuinticActionIn.create = function (action) {
  8284. return new cc.EaseQuinticActionIn(action)
  8285. };
  8286. cc._easeQuinticActionIn = {easing: cc.EaseQuinticActionIn.prototype._updateTime, reverse: function () {
  8287. return cc._easeQuinticActionIn
  8288. }};
  8289. cc.easeQuinticActionIn = function () {
  8290. return cc._easeQuinticActionIn
  8291. };
  8292. cc.EaseQuinticActionOut = cc.ActionEase.extend({_updateTime: function (time) {
  8293. time -= 1;
  8294. return time * time * time * time * time + 1
  8295. }, update: function (time) {
  8296. this._inner.update(this._updateTime(time))
  8297. }, clone: function () {
  8298. var action = new cc.EaseQuinticActionOut;
  8299. action.initWithAction(this._inner.clone());
  8300. return action
  8301. }, reverse: function () {
  8302. return cc.EaseQuinticActionOut.create(this._inner.reverse())
  8303. }});
  8304. cc.EaseQuinticActionOut.create = function (action) {
  8305. return new cc.EaseQuinticActionOut(action)
  8306. };
  8307. cc._easeQuinticActionOut = {easing: cc.EaseQuinticActionOut.prototype._updateTime, reverse: function () {
  8308. return cc._easeQuinticActionOut
  8309. }};
  8310. cc.easeQuinticActionOut = function () {
  8311. return cc._easeQuinticActionOut
  8312. };
  8313. cc.EaseQuinticActionInOut = cc.ActionEase.extend({_updateTime: function (time) {
  8314. time = time * 2;
  8315. if (time < 1)return 0.5 * time * time * time * time * time;
  8316. time -= 2;
  8317. return 0.5 * (time * time * time * time * time + 2)
  8318. }, update: function (time) {
  8319. this._inner.update(this._updateTime(time))
  8320. }, clone: function () {
  8321. var action = new cc.EaseQuinticActionInOut;
  8322. action.initWithAction(this._inner.clone());
  8323. return action
  8324. }, reverse: function () {
  8325. return cc.EaseQuinticActionInOut.create(this._inner.reverse())
  8326. }});
  8327. cc.EaseQuinticActionInOut.create = function (action) {
  8328. return new cc.EaseQuinticActionInOut(action)
  8329. };
  8330. cc._easeQuinticActionInOut = {easing: cc.EaseQuinticActionInOut.prototype._updateTime, reverse: function () {
  8331. return cc._easeQuinticActionInOut
  8332. }};
  8333. cc.easeQuinticActionInOut = function () {
  8334. return cc._easeQuinticActionInOut
  8335. };
  8336. cc.EaseCircleActionIn = cc.ActionEase.extend({_updateTime: function (time) {
  8337. return-1 * (Math.sqrt(1 - time * time) - 1)
  8338. }, update: function (time) {
  8339. this._inner.update(this._updateTime(time))
  8340. }, clone: function () {
  8341. var action = new cc.EaseCircleActionIn;
  8342. action.initWithAction(this._inner.clone());
  8343. return action
  8344. }, reverse: function () {
  8345. return cc.EaseCircleActionIn.create(this._inner.reverse())
  8346. }});
  8347. cc.EaseCircleActionIn.create = function (action) {
  8348. return new cc.EaseCircleActionIn(action)
  8349. };
  8350. cc._easeCircleActionIn = {easing: cc.EaseCircleActionIn.prototype._updateTime, reverse: function () {
  8351. return cc._easeCircleActionIn
  8352. }};
  8353. cc.easeCircleActionIn = function () {
  8354. return cc._easeCircleActionIn
  8355. };
  8356. cc.EaseCircleActionOut = cc.ActionEase.extend({_updateTime: function (time) {
  8357. time = time - 1;
  8358. return Math.sqrt(1 - time * time)
  8359. }, update: function (time) {
  8360. this._inner.update(this._updateTime(time))
  8361. }, clone: function () {
  8362. var action = new cc.EaseCircleActionOut;
  8363. action.initWithAction(this._inner.clone());
  8364. return action
  8365. }, reverse: function () {
  8366. return cc.EaseCircleActionOut.create(this._inner.reverse())
  8367. }});
  8368. cc.EaseCircleActionOut.create = function (action) {
  8369. return new cc.EaseCircleActionOut(action)
  8370. };
  8371. cc._easeCircleActionOut = {easing: cc.EaseCircleActionOut.prototype._updateTime, reverse: function () {
  8372. return cc._easeCircleActionOut
  8373. }};
  8374. cc.easeCircleActionOut = function () {
  8375. return cc._easeCircleActionOut
  8376. };
  8377. cc.EaseCircleActionInOut = cc.ActionEase.extend({_updateTime: function (time) {
  8378. time = time * 2;
  8379. if (time < 1)return-0.5 * (Math.sqrt(1 - time * time) - 1);
  8380. time -= 2;
  8381. return 0.5 * (Math.sqrt(1 - time * time) + 1)
  8382. }, update: function (time) {
  8383. this._inner.update(this._updateTime(time))
  8384. }, clone: function () {
  8385. var action = new cc.EaseCircleActionInOut;
  8386. action.initWithAction(this._inner.clone());
  8387. return action
  8388. }, reverse: function () {
  8389. return cc.EaseCircleActionInOut.create(this._inner.reverse())
  8390. }});
  8391. cc.EaseCircleActionInOut.create = function (action) {
  8392. return new cc.EaseCircleActionInOut(action)
  8393. };
  8394. cc._easeCircleActionInOut = {easing: cc.EaseCircleActionInOut.prototype._updateTime, reverse: function () {
  8395. return cc._easeCircleActionInOut
  8396. }};
  8397. cc.easeCircleActionInOut = function () {
  8398. return cc._easeCircleActionInOut
  8399. };
  8400. cc.EaseCubicActionIn = cc.ActionEase.extend({_updateTime: function (time) {
  8401. return time * time * time
  8402. }, update: function (time) {
  8403. this._inner.update(this._updateTime(time))
  8404. }, clone: function () {
  8405. var action = new cc.EaseCubicActionIn;
  8406. action.initWithAction(this._inner.clone());
  8407. return action
  8408. }, reverse: function () {
  8409. return cc.EaseCubicActionIn.create(this._inner.reverse())
  8410. }});
  8411. cc.EaseCubicActionIn.create = function (action) {
  8412. return new cc.EaseCubicActionIn(action)
  8413. };
  8414. cc._easeCubicActionIn = {easing: cc.EaseCubicActionIn.prototype._updateTime, reverse: function () {
  8415. return cc._easeCubicActionIn
  8416. }};
  8417. cc.easeCubicActionIn = function () {
  8418. return cc._easeCubicActionIn
  8419. };
  8420. cc.EaseCubicActionOut = cc.ActionEase.extend({_updateTime: function (time) {
  8421. time -= 1;
  8422. return time * time * time + 1
  8423. }, update: function (time) {
  8424. this._inner.update(this._updateTime(time))
  8425. }, clone: function () {
  8426. var action = new cc.EaseCubicActionOut;
  8427. action.initWithAction(this._inner.clone());
  8428. return action
  8429. }, reverse: function () {
  8430. return cc.EaseCubicActionOut.create(this._inner.reverse())
  8431. }});
  8432. cc.EaseCubicActionOut.create = function (action) {
  8433. return new cc.EaseCubicActionOut(action)
  8434. };
  8435. cc._easeCubicActionOut = {easing: cc.EaseCubicActionOut.prototype._updateTime, reverse: function () {
  8436. return cc._easeCubicActionOut
  8437. }};
  8438. cc.easeCubicActionOut = function () {
  8439. return cc._easeCubicActionOut
  8440. };
  8441. cc.EaseCubicActionInOut = cc.ActionEase.extend({_updateTime: function (time) {
  8442. time = time * 2;
  8443. if (time < 1)return 0.5 * time * time * time;
  8444. time -= 2;
  8445. return 0.5 * (time * time * time + 2)
  8446. }, update: function (time) {
  8447. this._inner.update(this._updateTime(time))
  8448. }, clone: function () {
  8449. var action = new cc.EaseCubicActionInOut;
  8450. action.initWithAction(this._inner.clone());
  8451. return action
  8452. }, reverse: function () {
  8453. return cc.EaseCubicActionInOut.create(this._inner.reverse())
  8454. }});
  8455. cc.EaseCubicActionInOut.create = function (action) {
  8456. return new cc.EaseCubicActionInOut(action)
  8457. };
  8458. cc._easeCubicActionInOut = {easing: cc.EaseCubicActionInOut.prototype._updateTime, reverse: function () {
  8459. return cc._easeCubicActionInOut
  8460. }};
  8461. cc.easeCubicActionInOut = function () {
  8462. return cc._easeCubicActionInOut
  8463. };
  8464. cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
  8465. var t2 = t * t;
  8466. var t3 = t2 * t;
  8467. var s = (1 - tension) / 2;
  8468. var b1 = s * (-t3 + 2 * t2 - t);
  8469. var b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1);
  8470. var b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2);
  8471. var b4 = s * (t3 - t2);
  8472. var x = p0.x * b1 + p1.x * b2 + p2.x * b3 + p3.x * b4;
  8473. var y = p0.y * b1 + p1.y * b2 + p2.y * b3 + p3.y * b4;
  8474. return cc.p(x, y)
  8475. };
  8476. cc.reverseControlPoints = function (controlPoints) {
  8477. var newArray = [];
  8478. for (var i = controlPoints.length - 1; i >= 0; i--)newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
  8479. return newArray
  8480. };
  8481. cc.copyControlPoints = function (controlPoints) {
  8482. var newArray = [];
  8483. for (var i = 0; i < controlPoints.length; i++)newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
  8484. return newArray
  8485. };
  8486. cc.getControlPointAt = function (controlPoints, pos) {
  8487. var p = Math.min(controlPoints.length - 1, Math.max(pos, 0));
  8488. return controlPoints[p]
  8489. };
  8490. cc.reverseControlPointsInline = function (controlPoints) {
  8491. var len = controlPoints.length;
  8492. var mid = 0 | len / 2;
  8493. for (var i = 0; i < mid; ++i) {
  8494. var temp = controlPoints[i];
  8495. controlPoints[i] = controlPoints[len - i - 1];
  8496. controlPoints[len - i - 1] = temp
  8497. }
  8498. };
  8499. cc.CardinalSplineTo = cc.ActionInterval.extend({_points: null, _deltaT: 0, _tension: 0, _previousPosition: null, _accumulatedDiff: null, ctor: function (duration, points, tension) {
  8500. cc.ActionInterval.prototype.ctor.call(this);
  8501. this._points = [];
  8502. tension !== undefined && this.initWithDuration(duration, points, tension)
  8503. }, initWithDuration: function (duration, points, tension) {
  8504. if (!points || points.length == 0)throw"Invalid configuration. It must at least have one control point";
  8505. if (cc.ActionInterval.prototype.initWithDuration.call(this,
  8506. duration)) {
  8507. this.setPoints(points);
  8508. this._tension = tension;
  8509. return true
  8510. }
  8511. return false
  8512. }, clone: function () {
  8513. var action = new cc.CardinalSplineTo;
  8514. action.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  8515. return action
  8516. }, startWithTarget: function (target) {
  8517. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  8518. this._deltaT = 1 / (this._points.length - 1);
  8519. this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
  8520. this._accumulatedDiff = cc.p(0, 0)
  8521. }, update: function (time) {
  8522. time =
  8523. this._computeEaseTime(time);
  8524. var p, lt;
  8525. var ps = this._points;
  8526. if (time == 1) {
  8527. p = ps.length - 1;
  8528. lt = 1
  8529. } else {
  8530. var locDT = this._deltaT;
  8531. p = 0 | time / locDT;
  8532. lt = (time - locDT * p) / locDT
  8533. }
  8534. var newPos = cc.cardinalSplineAt(cc.getControlPointAt(ps, p - 1), cc.getControlPointAt(ps, p - 0), cc.getControlPointAt(ps, p + 1), cc.getControlPointAt(ps, p + 2), this._tension, lt);
  8535. if (cc.ENABLE_STACKABLE_ACTIONS) {
  8536. var tempX, tempY;
  8537. tempX = this.target.getPositionX() - this._previousPosition.x;
  8538. tempY = this.target.getPositionY() - this._previousPosition.y;
  8539. if (tempX != 0 || tempY !=
  8540. 0) {
  8541. var locAccDiff = this._accumulatedDiff;
  8542. tempX = locAccDiff.x + tempX;
  8543. tempY = locAccDiff.y + tempY;
  8544. locAccDiff.x = tempX;
  8545. locAccDiff.y = tempY;
  8546. newPos.x += tempX;
  8547. newPos.y += tempY
  8548. }
  8549. }
  8550. this.updatePosition(newPos)
  8551. }, reverse: function () {
  8552. var reversePoints = cc.reverseControlPoints(this._points);
  8553. return cc.CardinalSplineTo.create(this._duration, reversePoints, this._tension)
  8554. }, updatePosition: function (newPos) {
  8555. this.target.setPosition(newPos);
  8556. this._previousPosition = newPos
  8557. }, getPoints: function () {
  8558. return this._points
  8559. }, setPoints: function (points) {
  8560. this._points =
  8561. points
  8562. }});
  8563. cc.CardinalSplineTo.create = function (duration, points, tension) {
  8564. return new cc.CardinalSplineTo(duration, points, tension)
  8565. };
  8566. cc.CardinalSplineBy = cc.CardinalSplineTo.extend({_startPosition: null, ctor: function (duration, points, tension) {
  8567. cc.CardinalSplineTo.prototype.ctor.call(this);
  8568. this._startPosition = cc.p(0, 0);
  8569. tension !== undefined && this.initWithDuration(duration, points, tension)
  8570. }, startWithTarget: function (target) {
  8571. cc.CardinalSplineTo.prototype.startWithTarget.call(this, target);
  8572. this._startPosition.x = target.getPositionX();
  8573. this._startPosition.y = target.getPositionY()
  8574. }, reverse: function () {
  8575. var copyConfig = this._points.slice();
  8576. var current;
  8577. var p = copyConfig[0];
  8578. for (var i = 1; i < copyConfig.length; ++i) {
  8579. current = copyConfig[i];
  8580. copyConfig[i] = cc.pSub(current, p);
  8581. p = current
  8582. }
  8583. var reverseArray = cc.reverseControlPoints(copyConfig);
  8584. p = reverseArray[reverseArray.length - 1];
  8585. reverseArray.pop();
  8586. p.x = -p.x;
  8587. p.y = -p.y;
  8588. reverseArray.unshift(p);
  8589. for (var i = 1; i < reverseArray.length; ++i) {
  8590. current = reverseArray[i];
  8591. current.x = -current.x;
  8592. current.y = -current.y;
  8593. current.x += p.x;
  8594. current.y += p.y;
  8595. reverseArray[i] = current;
  8596. p = current
  8597. }
  8598. return cc.CardinalSplineBy.create(this._duration, reverseArray,
  8599. this._tension)
  8600. }, updatePosition: function (newPos) {
  8601. var pos = this._startPosition;
  8602. var posX = newPos.x + pos.x;
  8603. var posY = newPos.y + pos.y;
  8604. this._previousPosition.x = posX;
  8605. this._previousPosition.y = posY;
  8606. this.target.setPosition(posX, posY)
  8607. }, clone: function () {
  8608. var a = new cc.CardinalSplineBy;
  8609. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  8610. return a
  8611. }});
  8612. cc.CardinalSplineBy.create = function (duration, points, tension) {
  8613. return new cc.CardinalSplineBy(duration, points, tension)
  8614. };
  8615. cc.CatmullRomTo = cc.CardinalSplineTo.extend({ctor: function (dt, points) {
  8616. points && this.initWithDuration(dt, points)
  8617. }, initWithDuration: function (dt, points) {
  8618. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5)
  8619. }, clone: function () {
  8620. var action = new cc.CatmullRomTo;
  8621. action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  8622. return action
  8623. }});
  8624. cc.CatmullRomTo.create = function (dt, points) {
  8625. return new cc.CatmullRomTo(dt, points)
  8626. };
  8627. cc.CatmullRomBy = cc.CardinalSplineBy.extend({ctor: function (dt, points) {
  8628. cc.CardinalSplineBy.prototype.ctor.call(this);
  8629. points && this.initWithDuration(dt, points)
  8630. }, initWithDuration: function (dt, points) {
  8631. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5)
  8632. }, clone: function () {
  8633. var action = new cc.CatmullRomBy;
  8634. action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  8635. return action
  8636. }});
  8637. cc.CatmullRomBy.create = function (dt, points) {
  8638. return new cc.CatmullRomBy(dt, points)
  8639. };
  8640. cc.ActionTweenDelegate = cc.Class.extend({updateTweenAction: function (value, key) {
  8641. }});
  8642. cc.ActionTween = cc.ActionInterval.extend({key: "", from: 0, to: 0, delta: 0, ctor: function (duration, key, from, to) {
  8643. cc.ActionInterval.prototype.ctor.call(this);
  8644. this.key = "";
  8645. to !== undefined && this.initWithDuration(duration, key, from, to)
  8646. }, initWithDuration: function (duration, key, from, to) {
  8647. if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
  8648. this.key = key;
  8649. this.to = to;
  8650. this.from = from;
  8651. return true
  8652. }
  8653. return false
  8654. }, startWithTarget: function (target) {
  8655. if (!target || !target.updateTweenAction)throw"cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
  8656. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  8657. this.delta = this.to - this.from
  8658. }, update: function (dt) {
  8659. this.target.updateTweenAction(this.to - this.delta * (1 - dt), this.key)
  8660. }, reverse: function () {
  8661. return cc.ActionTween.create(this.duration, this.key, this.to, this.from)
  8662. }, clone: function () {
  8663. var action = new cc.ActionTween;
  8664. action.initWithDuration(this._duration, this.key, this.from, this.to);
  8665. return action
  8666. }});
  8667. cc.ActionTween.create = function (duration, key, from, to) {
  8668. var ret = new cc.ActionTween;
  8669. if (ret.initWithDuration(duration, key, from, to))return ret;
  8670. return null
  8671. };
  8672. cc.action = cc.Action.create;
  8673. cc.speed = cc.Speed.create;
  8674. cc.follow = cc.Follow.create;
  8675. cc.orbitCamera = cc.OrbitCamera.create;
  8676. cc.cardinalSplineTo = cc.CardinalSplineTo.create;
  8677. cc.cardinalSplineBy = cc.CardinalSplineBy.create;
  8678. cc.catmullRomTo = cc.CatmullRomTo.create;
  8679. cc.catmullRomBy = cc.CatmullRomBy.create;
  8680. cc.show = cc.Show.create;
  8681. cc.hide = cc.Hide.create;
  8682. cc.toggleVisibility = cc.ToggleVisibility.create;
  8683. cc.removeSelf = cc.RemoveSelf.create;
  8684. cc.flipX = cc.FlipX.create;
  8685. cc.flipY = cc.FlipY.create;
  8686. cc.place = cc.Place.create;
  8687. cc.callFunc = cc.CallFunc.create;
  8688. cc.actionInterval = cc.ActionInterval.create;
  8689. cc.sequence = cc.Sequence.create;
  8690. cc.repeat = cc.Repeat.create;
  8691. cc.repeatForever = cc.RepeatForever.create;
  8692. cc.spawn = cc.Spawn.create;
  8693. cc.rotateTo = cc.RotateTo.create;
  8694. cc.rotateBy = cc.RotateBy.create;
  8695. cc.moveBy = cc.MoveBy.create;
  8696. cc.moveTo = cc.MoveTo.create;
  8697. cc.skewTo = cc.SkewTo.create;
  8698. cc.skewBy = cc.SkewBy.create;
  8699. cc.jumpBy = cc.JumpBy.create;
  8700. cc.jumpTo = cc.JumpTo.create;
  8701. cc.bezierBy = cc.BezierBy.create;
  8702. cc.bezierTo = cc.BezierTo.create;
  8703. cc.scaleTo = cc.ScaleTo.create;
  8704. cc.scaleBy = cc.ScaleBy.create;
  8705. cc.blink = cc.Blink.create;
  8706. cc.fadeTo = cc.FadeTo.create;
  8707. cc.fadeIn = cc.FadeIn.create;
  8708. cc.fadeOut = cc.FadeOut.create;
  8709. cc.tintTo = cc.TintTo.create;
  8710. cc.tintBy = cc.TintBy.create;
  8711. cc.delayTime = cc.DelayTime.create;
  8712. cc.reverseTime = cc.ReverseTime.create;
  8713. cc.animate = cc.Animate.create;
  8714. cc.targetedAction = cc.TargetedAction.create;
  8715. cc.actionTween = cc.ActionTween.create;
  8716. /****************************************************************************
  8717. Copyright (c) 2008-2010 Ricardo Quesada
  8718. Copyright (c) 2011-2012 cocos2d-x.org
  8719. Copyright (c) 2013-2014 Chukong Technologies Inc.
  8720. http://www.cocos2d-x.org
  8721. Permission is hereby granted, free of charge, to any person obtaining a copy
  8722. of this software and associated documentation files (the "Software"), to deal
  8723. in the Software without restriction, including without limitation the rights
  8724. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8725. copies of the Software, and to permit persons to whom the Software is
  8726. furnished to do so, subject to the following conditions:
  8727. The above copyright notice and this permission notice shall be included in
  8728. all copies or substantial portions of the Software.
  8729. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8730. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8731. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8732. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8733. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8734. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8735. THE SOFTWARE.
  8736. ****************************************************************************/
  8737. /**
  8738. * @class
  8739. * @extends cc.Class
  8740. */
  8741. cc.HashElement = cc.Class.extend(/** @lends cc.HashElement# */{
  8742. actions:null,
  8743. target:null, //ccobject
  8744. actionIndex:0,
  8745. currentAction:null, //CCAction
  8746. currentActionSalvaged:false,
  8747. paused:false,
  8748. hh:null, //ut hash handle
  8749. /**
  8750. * Constructor
  8751. */
  8752. ctor:function () {
  8753. this.actions = [];
  8754. this.target = null;
  8755. this.actionIndex = 0;
  8756. this.currentAction = null; //CCAction
  8757. this.currentActionSalvaged = false;
  8758. this.paused = false;
  8759. this.hh = null; //ut hash handle
  8760. }
  8761. });
  8762. cc.ActionManager = cc.Class.extend({
  8763. _hashTargets:null,
  8764. _arrayTargets:null,
  8765. _currentTarget:null,
  8766. _currentTargetSalvaged:false,
  8767. _searchElementByTarget:function (arr, target) {
  8768. for (var k = 0; k < arr.length; k++) {
  8769. if (target == arr[k].target)
  8770. return arr[k];
  8771. }
  8772. return null;
  8773. },
  8774. ctor:function () {
  8775. this._hashTargets = {};
  8776. this._arrayTargets = [];
  8777. this._currentTarget = null;
  8778. this._currentTargetSalvaged = false;
  8779. },
  8780. addAction:function (action, target, paused) {
  8781. if(!action)
  8782. throw "cc.ActionManager.addAction(): action must be non-null";
  8783. if(!target)
  8784. throw "cc.ActionManager.addAction(): action must be non-null";
  8785. //check if the action target already exists
  8786. var element = this._hashTargets[target.__instanceId];
  8787. //if doesnt exists, create a hashelement and push in mpTargets
  8788. if (!element) {
  8789. element = new cc.HashElement();
  8790. element.paused = paused;
  8791. element.target = target;
  8792. this._hashTargets[target.__instanceId] = element;
  8793. this._arrayTargets.push(element);
  8794. }
  8795. //creates a array for that eleemnt to hold the actions
  8796. this._actionAllocWithHashElement(element);
  8797. element.actions.push(action);
  8798. action.startWithTarget(target);
  8799. },
  8800. removeAllActions:function () {
  8801. var locTargets = this._arrayTargets;
  8802. for (var i = 0; i < locTargets.length; i++) {
  8803. var element = locTargets[i];
  8804. if (element)
  8805. this.removeAllActionsFromTarget(element.target, true);
  8806. }
  8807. },
  8808. removeAllActionsFromTarget:function (target, forceDelete) {
  8809. // explicit null handling
  8810. if (target == null)
  8811. return;
  8812. var element = this._hashTargets[target.__instanceId];
  8813. if (element) {
  8814. if (element.actions.indexOf(element.currentAction) !== -1 && !(element.currentActionSalvaged))
  8815. element.currentActionSalvaged = true;
  8816. element.actions.length = 0;
  8817. if (this._currentTarget == element && !forceDelete) {
  8818. this._currentTargetSalvaged = true;
  8819. } else {
  8820. this._deleteHashElement(element);
  8821. }
  8822. }
  8823. },
  8824. removeAction:function (action) {
  8825. // explicit null handling
  8826. if (action == null)
  8827. return;
  8828. var target = action.getOriginalTarget();
  8829. var element = this._hashTargets[target.__instanceId];
  8830. if (element) {
  8831. for (var i = 0; i < element.actions.length; i++) {
  8832. if (element.actions[i] == action) {
  8833. element.actions.splice(i, 1);
  8834. break;
  8835. }
  8836. }
  8837. } else {
  8838. cc.log(cc._LogInfos.ActionManager_removeAction);
  8839. }
  8840. },
  8841. removeActionByTag:function (tag, target) {
  8842. if(tag == cc.ACTION_TAG_INVALID)
  8843. cc.log(cc._LogInfos.ActionManager_addAction);
  8844. cc.assert(target, cc._LogInfos.ActionManager_addAction);
  8845. var element = this._hashTargets[target.__instanceId];
  8846. if (element) {
  8847. var limit = element.actions.length;
  8848. for (var i = 0; i < limit; ++i) {
  8849. var action = element.actions[i];
  8850. if (action && action.getTag() === tag && action.getOriginalTarget() == target) {
  8851. this._removeActionAtIndex(i, element);
  8852. break;
  8853. }
  8854. }
  8855. }
  8856. },
  8857. getActionByTag:function (tag, target) {
  8858. if(tag == cc.ACTION_TAG_INVALID)
  8859. cc.log(cc._LogInfos.ActionManager_getActionByTag);
  8860. var element = this._hashTargets[target.__instanceId];
  8861. if (element) {
  8862. if (element.actions != null) {
  8863. for (var i = 0; i < element.actions.length; ++i) {
  8864. var action = element.actions[i];
  8865. if (action && action.getTag() === tag)
  8866. return action;
  8867. }
  8868. }
  8869. cc.log(cc._LogInfos.ActionManager_getActionByTag_2, tag);
  8870. }
  8871. return null;
  8872. },
  8873. numberOfRunningActionsInTarget:function (target) {
  8874. var element = this._hashTargets[target.__instanceId];
  8875. if (element)
  8876. return (element.actions) ? element.actions.length : 0;
  8877. return 0;
  8878. },
  8879. pauseTarget:function (target) {
  8880. var element = this._hashTargets[target.__instanceId];
  8881. if (element)
  8882. element.paused = true;
  8883. },
  8884. resumeTarget:function (target) {
  8885. var element = this._hashTargets[target.__instanceId];
  8886. if (element)
  8887. element.paused = false;
  8888. },
  8889. pauseAllRunningActions:function(){
  8890. var idsWithActions = [];
  8891. var locTargets = this._arrayTargets;
  8892. for(var i = 0; i< locTargets.length; i++){
  8893. var element = locTargets[i];
  8894. if(element && !element.paused){
  8895. element.paused = true;
  8896. idsWithActions.push(element.target);
  8897. }
  8898. }
  8899. return idsWithActions;
  8900. },
  8901. resumeTargets:function(targetsToResume){
  8902. if(!targetsToResume)
  8903. return;
  8904. for(var i = 0 ; i< targetsToResume.length; i++){
  8905. if(targetsToResume[i])
  8906. this.resumeTarget(targetsToResume[i]);
  8907. }
  8908. },
  8909. purgeSharedManager:function () {
  8910. cc.director.getScheduler().unscheduleUpdateForTarget(this);
  8911. },
  8912. _removeActionAtIndex:function (index, element) {
  8913. var action = element.actions[index];
  8914. if ((action == element.currentAction) && (!element.currentActionSalvaged))
  8915. element.currentActionSalvaged = true;
  8916. element.actions.splice(index, 1);
  8917. if (element.actionIndex >= index)
  8918. element.actionIndex--;
  8919. if (element.actions.length == 0) {
  8920. if (this._currentTarget == element) {
  8921. this._currentTargetSalvaged = true;
  8922. } else {
  8923. this._deleteHashElement(element);
  8924. }
  8925. }
  8926. },
  8927. _deleteHashElement:function (element) {
  8928. if (element) {
  8929. delete this._hashTargets[element.target.__instanceId];
  8930. cc.arrayRemoveObject(this._arrayTargets, element);
  8931. element.actions = null;
  8932. element.target = null;
  8933. }
  8934. },
  8935. _actionAllocWithHashElement:function (element) {
  8936. // 4 actions per Node by default
  8937. if (element.actions == null) {
  8938. element.actions = [];
  8939. }
  8940. },
  8941. update:function (dt) {
  8942. var locTargets = this._arrayTargets , locCurrTarget;
  8943. for (var elt = 0; elt < locTargets.length; elt++) {
  8944. this._currentTarget = locTargets[elt];
  8945. locCurrTarget = this._currentTarget;
  8946. //this._currentTargetSalvaged = false;
  8947. if (!locCurrTarget.paused) {
  8948. // The 'actions' CCMutableArray may change while inside this loop.
  8949. for (locCurrTarget.actionIndex = 0; locCurrTarget.actionIndex < locCurrTarget.actions.length;
  8950. locCurrTarget.actionIndex++) {
  8951. locCurrTarget.currentAction = locCurrTarget.actions[locCurrTarget.actionIndex];
  8952. if (!locCurrTarget.currentAction)
  8953. continue;
  8954. locCurrTarget.currentActionSalvaged = false;
  8955. //use for speed
  8956. locCurrTarget.currentAction.step(dt * ( locCurrTarget.currentAction._speedMethod ? locCurrTarget.currentAction._speed : 1 ) );
  8957. if (locCurrTarget.currentActionSalvaged) {
  8958. // The currentAction told the node to remove it. To prevent the action from
  8959. // accidentally deallocating itself before finishing its step, we retained
  8960. // it. Now that step is done, it's safe to release it.
  8961. locCurrTarget.currentAction = null;//release
  8962. } else if (locCurrTarget.currentAction.isDone()) {
  8963. locCurrTarget.currentAction.stop();
  8964. var action = locCurrTarget.currentAction;
  8965. // Make currentAction nil to prevent removeAction from salvaging it.
  8966. locCurrTarget.currentAction = null;
  8967. this.removeAction(action);
  8968. }
  8969. locCurrTarget.currentAction = null;
  8970. }
  8971. }
  8972. // elt, at this moment, is still valid
  8973. // so it is safe to ask this here (issue #490)
  8974. // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
  8975. if (this._currentTargetSalvaged && locCurrTarget.actions.length === 0) {
  8976. this._deleteHashElement(locCurrTarget);
  8977. }
  8978. }
  8979. }
  8980. });