From 92e86494e33264ba792985bf76e647c099727167 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 12 Sep 2013 15:39:52 +0100 Subject: [PATCH] Tilemap Collision in and working :) Needs testing against Groups now. --- Docs/Screen Shots/phaser_mario_combo.png | Bin 0 -> 17593 bytes build/phaser-min.js | 2 +- build/phaser.js | 8693 ++++++++++++-------- examples/js.php | 8 +- examples/mapcollide.php | 92 + examples/mariocombo.php | 48 + examples/mariocombo/assets/mario1.json | 39 + examples/mariocombo/assets/mario1.png | Bin 0 -> 3181 bytes examples/mariocombo/assets/phaser.png | Bin 0 -> 809 bytes examples/mariocombo/assets/smb_level1.json | 39 + examples/mariocombo/assets/smb_tiles.png | Bin 0 -> 3740 bytes examples/mariocombo/index.php | 65 + examples/mariotogether.php | 45 + src/gameobjects/GameObjectFactory.js | 2 +- src/math/Math.js | 6 +- src/physics/arcade/ArcadePhysics.js | 198 + src/physics/arcade/Body.js | 14 + src/tilemap/Tilemap.js | 19 +- src/tilemap/TilemapLayer.js | 23 +- src/time/Time.js | 22 + src/utils/Debug.js | 16 + 21 files changed, 6084 insertions(+), 3247 deletions(-) create mode 100644 Docs/Screen Shots/phaser_mario_combo.png create mode 100644 examples/mapcollide.php create mode 100644 examples/mariocombo.php create mode 100644 examples/mariocombo/assets/mario1.json create mode 100644 examples/mariocombo/assets/mario1.png create mode 100644 examples/mariocombo/assets/phaser.png create mode 100644 examples/mariocombo/assets/smb_level1.json create mode 100644 examples/mariocombo/assets/smb_tiles.png create mode 100644 examples/mariocombo/index.php create mode 100644 examples/mariotogether.php diff --git a/Docs/Screen Shots/phaser_mario_combo.png b/Docs/Screen Shots/phaser_mario_combo.png new file mode 100644 index 0000000000000000000000000000000000000000..5de840fab66bab6ec04fb5c2ed9d919d95c8f1d4 GIT binary patch literal 17593 zcmeIZc~nzZ_cwk42b>COod5|ql(tH#wTQ?NoB)f86QBkX6%{2yM2bj45?TkG7#u1p zNQyXs43QxTQxfY0I1o`tlt_Y15kiO%ZbA~0yypgLwNKyY`>c2U*808cUC$p`N$%Ze zpS?eOIQyQn@2L&zeI|{!8V^Cxq&2>)HbIb?9R!(fH6H`6Ts{2jLGWb~y~$?y?jCd6#QxfhXsViP(Bce0!0(SjrVzAtZUT_wmAM@R z-TTqh99&NN$IFCwX*f#UY3FDbehs^5=kv=!fdZv>qCzJNXkOWh_ zAZY1L<<3Er{vArM^fwIn$DX>14Jj?Sg4SN*2UZK>gherLtz3iX@=N)$h*yp=)|;A@ zm{FDxwEiY}klb#+Y*h$-iIBkdnZ0;BE?LK-YFWKiG4a<(1vzJ2L-kn0`Cz|z87zJo z>6fG3xe79YTDJ7>RMn4_SdHEu@?pCWIi1J(De3tK|S2}#Fa=3@`Fqg zQ2m{8ymenL_0GHv=6=T|C*5DJwMv>$zl6w$iO`KqJm5*c1exBeK9k;wGiU@0@Pr%p z;?;MBoMMlT2Ndm-u?FRDZNj*wpk!&1OsAZSQ)5zXg#2pU`(F0-!es0HKmfm{pys+C ztEis% z_v6YR&-a7tFBzT$U|w+!C5t4Dz>`AlPmc<`g zXuLQBhNhHm0k8vFOjjjfS3dqaV>dNiGKsaqw}1-dr$;-S%t}t^r|k zCc`DDrM!P9i_EZ)vr6fr%P%-hs`6>yw`!FEWo@Jmj1;s z3GoAuBe<8L4HrhI+~11U`=;EhMxyEW{Hy_m-&dR^A9oBevxc z*Q4)Xt(BMMzA}nXgRw*anc~6~B~ec}yI^-zYVHbO<>eBcb3JaOHcE1cp}gN&V&>3v zkQ-WL4=3G?RZwp^yM(mBv!isc!#iOIk@ONa1jI;Xxyp1D@5|~Pq71n@Wzq>!wVQ}X z$5z^^-BSv~aDB7d)w&+3kF=4FhL_InY78(nzk8;v#fH4`SfIyu(sksnF^2aKj<)Hl zm{@Ldp~SUYQY?WVz>;brDG9GQ$RkM(_K{2kfw{kJnf@=hoR$q1d4cA zv8}>;A-sp`RwzS(FCl-~tG+o2kOih9>Q!X@PA716q3*=pFG=0AmmcA!; z&LppA<5$guWg+5M7(?C^uY|;c@?TEaNWOZqvGui|tk1RL4{@}DS5A^Y$9K=3;Ne=R ziw6p2zE-SjH+x%>%KfFT0~y&M}x0Q zK`OHe?TW^9`;qw7sw`GrkOL5JzthF22L}jO+3D}MIbEtstBO)3KgZ&ftkCX^3?Hpp zMA9v*$P9fXc|kb=mqcibsr#R8LT(1%{KYhvk{6ZlJXUhj(!ajj*aK7#M!Q;@j2f&x=Mw3%VaFN& z@wScv|GE{B2?f|FY<|LkYC_c%lTq)NwSLvxIj-m3)RiZt4q@QlO86@ZkGgQdTQ|}3 zsjpu>lLp}rv%xK}*q-rr>APv&p6!Bj*|@`>S3#K_B5u>vUNN`3w@$XM>W<63o17kk zaC_wSdznfOCFya4lIf%sMnxEMz!&op;9{QuxinfIX%v0`r(fL5&WzD@CyguVCJ}`e zbYI9M@KpMdZ~`&gy4}Ntmr@H;F@3PB~3AR_EhnMS>x>P zeHAyir+FeCM@O~z`U!3~38aMTg)poUF7hL@DN7fF3IV$84VGx=7RU@x!hU4o++p?q z;N>F~Xnh)2E5sQj21`U$$(aw6?UCvP%KXmsq&NYBpw0hdo%O#dzeX-ck3(^XfPX;{ zFLoRXDQWILMj4)p$%aLDNUJ~85D{Fg1KanQ?HaaBt5F}oq~Ih3Dt2%b zTe0ib)|D9#QeKDZVsQ6vpHk$+V)Kit6)X8@8?Wnw=T<*V=iWE-%I|n4m6SXxD(e_b zl3(L~xYGJ|)+t4{AXC|Gkjf2x_M|E*fp+iqNz%@Y2{K*ZrKPbe;<-M$ThRFn?J8D# zdZH*}amUrV3W_Jj_Cks+_f6-}ao$wPbKeXUTUi=JJ#lKujhaUKKuYg^9<7OWladBa>0X_EJH(4nccqR)@f7mgV)10cy2aPXx`Q{A zZ*$PB%tqYG)yzk)8?0wEsl64qu||bn6Af?ku#jt)5jAlE%yxeMvl4!At|>ZO|CSg? zoiy#u^w6}X6>j3Wa4NYpF>qbBiu&KQPP6-)5gXOBATF%#quI>e%@XnVV zJ@1ja9`8?r1sgUtMzQrH7WfYasP3;my=Z5Hpl(}1ms~b=@Jo!GMrxd3=MaLXMM(Q9 z864Iv1ni}oNS@E8OLjX2A9D{Qk+WRH?7!5g9F=;wKlAY9zdZ93j9cS<<0xm{^SCp< zTcPv`p>wav&#C^JitvS9%u7u79Ab1GFp1&~)0P{C*7J}VGbVh)OF9<@hh5%h=FMc0 z)zNM^ZFHXCPYcE7$sHq;NMiSnPe<2@^;I9nwYvMpVUbx+oFSDeJo@!)vMH_gy(Cet z5w-GjE{LSlzJu5?1s$f3>xtDJ+v6r5xu}>?R}hPhKQHq9#lPOof#1}oey5fA&QU#C zLnPx@kqNh-mB#48#FXTifj-GljNbI1XBd@Iqp39W{W5V-e{S_|KvVZ6{!OudQ2$KG zD{9@kw14mnh_yN#R5!nObr^+mQl70(BYjodnqlX@T`bH60p%H^bq%zg>NA@P0t(@3 z8|S}Fs(28K8RA`C6CQQV&V3U?*~lQbDx>p>2W+B-8a*X+#f*gL9M!GGp6Ga%#AQ+K z`T9{QeAVIZwHN^x*zGINYJQvKy+*X;IS?BoCE-mIfUg;dzY$H^|9}a=*%ruU4Of_jR3vr8Cl^%n>S1=o z)%{Wpi?8C3f7}9#pdX?UGHrZ33Ve|t@56|MJUb39k zJ}>1oLYvDfWQcZZQk)1`M|!jg88_WkGA84|XN-35_kmT%4NA!gfTlAa5{5B`SZUgz&Q%b(z7bo`E6ECc_-_uYw-8~YjXlfnN zfUFd0;)MJwH>L~5-Jc7yE%w~1V9sT7mDi#S&C=ptQEgRVvwl5J?m^3?ED3X`go|gT za4VK*<%)-%Jsvw6n0J(9oJ(X*j2iA|^DMrIQ7X71>$)R`J7i3^F3}tnY(NZ73`lcM zn@VE56=`()3Q;n)igKxdCVnF&X?Nc$kfM>G$e*G89%bHdVn57uao|3@6IwgevH<|V z5}`%IQQ{*|F}tRP@P!!-c^yhV4Nt|lQr>9P*Vr7E|K6qwy|H#D7Fp13$8!oz7zKC8 zV!;{f@DK_+UamO0@|tc)Of(!xGe#vUL@c}&6uk}ankBy^6iThHloFT}N*G-(y8xWl zXzU_v&x3fonz6?=2=6qh$OT)o3fMzE|IF#owy@|Q#EvYMfVKO+{(mP`ovtackt3Hr zoW%H!i{+@)e`M8B^aM7w%8w28w`fw3_|GfLFUqJ%Jksyk^bg7@ez8MYu87DB7pt6i z9cL>0ONOzhN_A}^#za8{;`Mrd`m6_7-X$WQ)Gx_^CB8l#QkrcofC>A!aw zQ47))v#Y0@8OSceJgN$^7>$!0G2#!moYt)lMYbnWYxRYOFmM5MX282FqGm>QSLCPR8J@N>DkfUx3;rhEqUm!_LPw?ph~$fdJ+rU7jKQw9$qth2bERS!9@R;uZBFPk#k*H>^k-R7y8PmG zHl;lGnf{WSB!%2pOQXh9ANG}`Z9Styi#v2~l2_|+ zQqCRmPPbjjc~YI=Eu%o$C?}|M_a?%e;=?$~{Uzwl8R7uKv+PV))fJl91_+adHLaMZw{C={ZgCtBpch1pTf-P|>i&p)0(DU8%z~yHa~E`0IvB zB0Bp@ZUj+avZ7!6$NligwFx0%eMvI!9+0|@d+z}3S(Asp4O+oRQ# z2g`5)l?LLWN^z8yW?v_n&%VkaDgxM7W0f^(npoVwd7Z0X%5YVZbmb1=c}=QXIMI-3 z-liQ&NNX?KUU}2#7dX{B$F!@R?ZNZKbc*49u!nW0xWeGc=EP< z5n#Be=WsS#C1R~=Zj906IlxQi#NUvsdTaWEV2i@O-xylLylQrv=j+Y#x3aEA(aZGP zw}Z5Wy&eYXus1y|;=-B&y`UoP3p<&~hi1-79UrE#Jyl}Iv_70eM{~cfo5!H$O;Qk= zsWhzEEf84(N(3rp?c!h&JzAfCURr<_==o;CY0g0cCA~ZxbLU;#Im`YU4K}3GaHm2R zBqNlelpA=jltb$nT$gHJj8O6ZZP;`nDdxbXXjV+jchn?I|K{f@swb*uqAt*YZ_YBA z$LUN=M;+GPD=E;&?-ynn!J#?4Jpc4HovcZX=VHaSOP+CK3}hl%egsJ^#+V{iRs~7k zZgUiXrKUVuxNE49p~Gi3O((va8^WgM^5|V62D`#pTc}gNRPNR8w19(?6t2pR5fke9 znNoK7_Lw12G%e(Ssj^wgM_J>h?^htAC6PlKb)u<^-!wSs7ZdE>bw7yk?3qt$ zAb?6rDqZt7dX_5Y2hW9Kx`37V5v{!+(aQWz{>qimdtNGo9m_+tyLu4Gl7Yb@N2h#? z=SbyS1$j~#OQSd++hjq?m4s*Tic*M8(QKEXyks${x8#hBvuw%Ja$&`?H11;+9QY3{9mZEeKx#bNSYB<$EsxYhjhG)+Rl9KzC2}o1W(?O zEPdV>jwdQk91bQF#zr@&sdzE#I&%{+@Fz>OI?HyC(dRQC%4$`;%wDcPonFnGY*dns z-_EQSh&-*!pS^MQ!9LlM-b6mvhR4YA#7_IGaTHE8*H+eFzC))(Vy!_XR?l1dYJp{=Ucjg ziE)uB5A|_Bqu|aw<}B~ zpv(&rGZA#?ln9b^Dk#`T0|n%QkMcy2{1ABrOqORB7W#KX6HRt^t-J07YmNeXF$=+@ zse%GT&y&Mr!55mVPt>ofXa2Z+U^Mtk#Uc`b8W{nM4kR*@3QxVvS=xXM`Q&D`%1EHU ztdXOC{cUQ;ZoGppxMIlAV86Z$mb1n@dW4aJ5=mCc6Be$sB&({H)BSObkx`Ty5X4sPcT_4@@87Sfj^9XUUTzaA7DBu+u$ zIQpef(31gW{ABH}@8?p~wKP49I-WWMoWDZ{t(@Zre)XAutm-SIndsHl@u*o#RxtON zcRhc!$k=3K|6sLKLOjdRQO!f|Ht)lv3XlwQaD4WM$v^B4Hm#xQU(v->SnXJYM@|@* z9{0-`ocvw*2Vb#CyAO3ta?eyR>=|&Jb?=+t6|09%WRIKu4LJ7dZ!$7}H|1N7sc$^a zQ0H@!c@aIqj_!j9|7G~yvhk?C>f)Cvv=XPIfPA}=JZnrUc5qOi9fXsa*5Hk;PRH}0 zm!nd?B)@S=7*=6(*{Cyvvd03kN!OT^eqqW19-Zxa#ox%5WA<3Ujr=WZ?n>`{4-&b@ z^u!SFoL||*h#;dud}kpoSkS3J6)F$(4$fX;KUdpea7U*I8=S6$qkno)yN6u z(xjmX?=feW92>a*QNx=jQn8k`hu^h18@a7NamH#@Q_Ex`!v^#+K`o`>uR(W3+@ycA zI#_h+ItZ6wW!r7U9A!^cW-zKe-4Z#qyqnolbkxGa9vPiC@ji_Fm?8=#*2pLxy-H#R z9^!RMIrWEbL!{jO_t@&BCjYHewd-T*5pzV0tvAWPi{?m(KXXd>xNuK*03ihBPqBDH z)jy!>y0SDWTmu0;3l=EvB<}}<^OoJ3?GjG!zI+%6bSJbaicw(g<+*Tp*m;v1p8KLv z#^cN#H+@Wf&x)sP7Zp$zCB*xV%r+*KVbPf#MGH1`4U47O`I}eP1k8+6 z41;qT>bGgO++@FZxvpmZ=CsOmiKh!^BzPTpH$P34$Uic_r8++w2qmFaXls49}>97Dk zW70lv7^UB=y!f75Qy%A1tMome04GJHYdxvJp2rRhhDjEPEwdtz!U}b_xH)%U@nzZXWm8Z0L=YZd$XCW;@e3=NgWg zFZuh4^&%@c3`4#g48~A9G()bBE~8|yJ*mr{{M>BFO@Pxa%0Eoy>-5?5*bL8fM2cF~ zgB_kTDYauChc_6Sv8Zp;KtSQj^rW>KtIeolf%}cb`m$KMyjSryZEPaqD?84|o9A03 zrf4X?#~`_A9|90O!$!Z zHmw=@!PV$Z7j{Ek9(F%`mCz%ZW(4>9+PNn49uvknhS4oH8umf1L>)a4c;8n>r`U1c zX!GR9Y!X?PLXUvT18ClDp5^-YMi*K;C*f_RKLgDfZzpZSu%mz*Bn;muUXpOODKECr z0^Af$_41ZA-WE_3Q$f1=zW>HB2?&kz&Y_nw*qmt!;54cYve(O4%W+eOMO)+k zEP`A%w5o`=OAKp{1W&RL+Sy)f^s~#Wpt!S8f3Pva>OQ&jLv{Wz`p-0h=ip6b;^OUp5ogGA9|Ic)M#sWb+htsa%i32Ok( zRT^pxj;}y8b=gNfH*0qj+_ssD6GHvZRE7af9{L31%T=}$kx0Hb5A4f0TdBsuu3sVg z-*J?qJQ@rmdm}f#mh+Kldgz{k?H{*>!vYAix&->%YBO1AZ)Lx zhwgh$H>l;*=zrHo3Q$(>)C!S-CG%Qk6$4|6fPUC_2!!%BdRrQNaAO4SPk zQ!q{11IboNn+->F{C}_@FNZtc&SFG9V<5Am$vL_{I1~CIoZdjlGkjt1e6n=s?h$}S zvLVsvlI>~gtNCKi&eg+Mok}b!ut=nRt=!gAiA7cC+P8mu_U(w=rZu5p z_2W;ncTV`xzP-Vuy*O&@`-0J#?`Q@!jXv=BKwnq&;YuBApc5+d3HBS6svT!1xx3_8 z#*&1GV}{;YP|F4tG(&tJ*TBQso`=7YJX7b14SJQ>%_8#~Qy)@(@2nNAOCu$Q8=-DY z*x#T@iH+(t!#s+)G3is+cpVEiHyCa5EQ)v}8`CWhbwg8j+U;Ii18qd*6i2L?G}9j8 z{&c-Ii}lrOKd1O1EzQu+qUzc_?dK)GJFFM$mDC}b3s+4=w+<#pJloKhhSuF)5SPr7 ztuVivSazb+g2WzsPbrx%4@6&eQig!t1a==RncuCV<0jf=#U9F7eqhUqUnhPs>+9~7 z0h6reZlfKl%ivb@JVO!jzp_hB+AXMYk&rr#s&4Zcle%PggKmnLr2`$00l_PYfH@P{ zf6PNYpP?;eHgZIR8pRY?D*$dgFCqA;=3;c`P~)C3{R_<0o||J*%~8CGc9T6vrAj}X zyIzny*(;%-)#|(j-p?WqZwrabJv%NBT4@Uff)ZHQNXX-ALbqm3n!~=(HgQ+z4`1#+ zSmU)3Wf%TpX04HNKyQuc>JFz_UUPnKfTl!{0RP#}39Ez-HsYcrQ}ctz%1*Q&6<$rO z`hFxL9&@B{b8(06sHVDm@v-31=Pd1S7!mLqLBMR)M+BZ+69Ad#ukapXW{*jAzoi;) z*C$N2@;apVU&;x!9&OoT9yMv3wk7TFkrca|j3f*r!aQ=`Ej4@RaGE?FU{URAZkP1= z&~PZXI{LL+LaBm!zi+ni>jcQ>B>p6H2yN0%4qo9aZ(n+Jsrlj&yl(x4R~3D%Wu~K< zug9eanbdI}roL_l2gCeM27<7?P|C1n(tJN9Y4G>94kO6?KEhdHe9_DEhi zv}89AdRd3!PErp*n^b=BV&w$8dx24tY7>hX7KgK=s zC$7=@Z$$z#a~{~d9SXXeInApd_s0}3(0y2rxI!q#w&hY2Cai$2>vL8%=TK|+WoX*K zZVal}vm?WmI!!J$ITn^@GS4tAKWsF@VN@!v!&M}mI^s*AeijF_mEG5*E5X81B=^=8 zY$V;(muWVSO}+Te&g|i)viG?rbK5gukL`#Ren@EN{`#BAye8#DJ2idB9_SR)Xy3VO z&#v(GPma}_VIDf~mOTgoM|{S7^E#Hz$@CXf=~%;blXi22$DG{{32x!gse^aJpi|<* z4bXW7^$D=cm8@Nk5>F5)K1|QI7F`OqeiC)z4AU*SJZ zH}Z~BlX(w+*=l&dMSt$jP+Jh3bw^*6zr`>!u*S7J;~SLM3WDR^+vc<2!2%^Xh8aqZ zN|2nw_qdHtjbB0xVn^(CGr56K=GvZRGwx-2o9yOskJ*~sxMtX_pR(-U##SrgnAE{I zzpq`dd(uu()NSe7raF@+PWRbbI(+I+1|7S#FEJB(azWlxc@eYPH%8eA zXbQyKQ09WdB6cE!glf5S1x^dg5}9fKweWv=86^}69aKHsO#l2DUZ*p%>#ls~@HS1f zeTTpE0mN`zojH6YeoGzAFdn=q@gY7c>3L$w&BRiS#ld$cHBUX}**=zkNOGcY$<6u`5ze!`hGM-Skza7A;@yGgE3q?^ z+^*~U7j8i{aEE$XRKtahhFB8$o{`lqo$B&{^WIY2rJizwpp=Cz!b0C1N?sOrXY9^l z3+dhLAh|sP_cc&fJSr$Dh9nkMn4iQfcd7R zCxGr<3)jr_U}RJhTV>+;m=O0~T%zxhQnxfzGgX>Mq&nN`l<=ji&$Y#mNH-DrCjZdg zXWh!O2U+*9elP+Q%pZag^oL{Lr-4S+;hQ!iF(}K{&qtnmJ|7RSeQc6xv{5hEF89bYYW{47P$ZSQYL)295u2V?{e%S5NVwOA z#?hfETv?9Eyg%_}dA^<9g`jpI`T&WZ0_p~%MfYUKfwzOxqSCe{n8^oI`*lN-qKPr{{IioSD#EFR>hABkQbx5I(n~i`c^t@Ni z!`OC*A=r6DkO`bYS0)>*$cKkKJpXjcj|w!jxjZDS1SwB8)F%XG;V_4M*tVrN?)UU< zR3)q`1r_KnAvg(;CehJO>W9S7TqfMiSHEB@Z#i~Ru@2si7dL*(3 zMhtqMM&k1by#XYXZ;Ug~^12?uL(CsICUsx*uy=nFtvyoQD=bn=025a3d8$o}{WE>E zvNsLKrExLu-zr*=U`*b%BY?kVSVVS-`U*UxJdWPykxh||&B4@hbiACA{4>H}NkT)Y zdX~wJI{D18M>5MEN0NVcd-+CS$a&rQT8TxerVeMT5o#;1?kJm25_LXw$kVijGio^T zd{oTi#GmUjmwW6BB%b~ojsJH1(sfQKG2)A&rR7caYRE8n^H>64NNlyL_xwK$R`zyC?J4hHZjhQ7DjfmOei&Y@Aqh<_0aMb}N|j0B z)&C&=?|f2#VI32K>sUvAr(0;$skDf`7TQnH(h4ri1F|oitUkybNIfhy`Oan|$SOgq zv!}p<04k^gxuN%eOv~*1izu#wetWL!cQNzkMDwvK6?2^3L+3fDI=*}R@%pm4-2hK# zSwQkIR}8a?dZhaEOm#YSvN1=ebg)f*jkSD+At$sdGc;|ix_+hpe9oz+TRMYQWssmL zy#rKXo*wT;6po8$mMzIAAM{ft6J!V;=x;kuM#$mjLrNLdoBf&X874PupYqJ@V)S#9 z`<|9hv*_(Q_u<^tCUc8iriE-HP56#z@?&eoUHF$?-!PmZdsjM=+TQvP7YZXe87b+b zj3qrP>MX9VV504OD44$))hquw_Q*c>V46w$f@3#COf%a2!qKKRYI8g7l+RMkL_2uq z7bN}s0dtVleTL=_JdOM9UAFr}K}@5P4;;j}!wXxg> zk6dN7;I$H|`^)?b|DHELuH5_{sGp2=28C`#H}Cf5mA;ea6xx5NZ?#JOKPm(O zyF;$D{;aBTsIVW0vcb!y8y-5_p&nndZ2{Xrli@HNm9YgCPK{5BK*20<$wBb>s$_f~ z`2jpXX8u_qERoLSX804n^nB?Lo_GPf9m5X-VU1vsO*swLN3cYNiS=QB<80)XdGQeH>q0XOsy7+5`lG*Pf+bo|t@~^l0L3!AmEsNMDtJpD zJ4s%qk4k+p2?b71tfFQQXC6TcSuI^R8G>5W{e~xzptQmP|g6?Gk13B_X&bbYa!^i82ZcrUJ>M`tWP7}6qkqn?1 zP+bZD{jB8v?~Q+igsDqwfcz)PkRCIQqz|3g6*z*=yJJ1Uhi z6>RAv_k^NNhyfTfM?k_2Vnf9*KE0BMLkRTE-JlJ`$DxqSR{k{H!0@*p)eYhyH#_|F zyQ_dPwcA0zNs|C{eF!+0h%j3T%q(Zn;a)gaH~(kw9-bp|#y0ZGVJGN7p$VG$!#Id9 za0ILqh>NH+e9!=)D@W!feYFJ}W1lCV3m>2i+}nGJuIB!{-8)I4}&TD&I;C0_SkhYw!{(c%`yjo3bN9 z?R@qxB>cehm2gSC5Xd^#i=_H64+`*tPR#YY(spM)w@*fB%p{ z7hn;4>2m(|12m+hQ^)RpZh8q(b3~@U!!Kg%3qef_j{A;-!-+qS?t_7sD7Itt&(i)? zSacAW_Ym(GB9NHb2sX)$&Jsw)UI#EogYBf_$RJh(vYYuAjbT5W1{MFf@44yU@CMMa z5r434;2s8?Hzfh@6XQWs6V?A;;n&crLv)k#F?>$_$-ms^@9;}!OXcIip$>!@euXpE zFgf3md&1}k!-xlorI?k#W9R_}UD^x5T6e44NUHj)mk2nI0eKB>#mDX<#GOD35-@FS z9(R_P?X@x`+_V6(7YhE{57cI=LY|Pn?H=&O&t2j#`1zFrF`V`SI0n=B0_qyQP^_mi Yp7$r2Sw`r9?9iIk>sJ-7*zxQC0_q=jod5s; literal 0 HcmV?d00001 diff --git a/build/phaser-min.js b/build/phaser-min.js index af0d8e1e..cdcb062b 100644 --- a/build/phaser-min.js +++ b/build/phaser-min.js @@ -1 +1 @@ -var PIXI=PIXI||{};var Phaser=Phaser||{VERSION:"1.0.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2};PIXI.InteractionManager=function(c){};Phaser.Utils={isPlainObject:function(d){if(typeof(d)!=="object"||d.nodeType||d===d.window){return false}try{if(d.constructor&&!hasOwn.call(d.constructor.prototype,"isPrototypeOf")){return false}}catch(c){return false}return true},extend:function(){var n,e,c,d,k,l,j=arguments[0]||{},h=1,f=arguments.length,m=false;if(typeof j==="boolean"){m=j;j=arguments[1]||{};h=2}if(f===h){j=this;--h}for(;h>16&255)/255,(c>>8&255)/255,(c&255)/255]}if(typeof Function.prototype.bind!="function"){Function.prototype.bind=(function(){var c=Array.prototype.slice;return function(d){var h=this,i=c.call(arguments,1);if(typeof h!="function"){throw new TypeError()}function e(){var j=i.concat(c.call(arguments));h.apply(this instanceof e?this:d,j)}e.prototype=(function f(j){j&&(f.prototype=j);if(!(this instanceof f)){return new f}})(h.prototype);return e}})()}function determineMatrixArrayType(){PIXI.Matrix=(typeof Float32Array!=="undefined")?Float32Array:Array;return PIXI.Matrix}determineMatrixArrayType();PIXI.mat3={};PIXI.mat3.create=function(){var c=new PIXI.Matrix(9);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};PIXI.mat3.identity=function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};PIXI.mat4={};PIXI.mat4.create=function(){var c=new PIXI.Matrix(16);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};PIXI.mat3.multiply=function(t,j,k){if(!k){k=t}var A=t[0],z=t[1],w=t[2],i=t[3],h=t[4],f=t[5],q=t[6],p=t[7],o=t[8],n=j[0],m=j[1],l=j[2],v=j[3],u=j[4],s=j[5],e=j[6],d=j[7],c=j[8];k[0]=n*A+m*i+l*q;k[1]=n*z+m*h+l*p;k[2]=n*w+m*f+l*o;k[3]=v*A+u*i+s*q;k[4]=v*z+u*h+s*p;k[5]=v*w+u*f+s*o;k[6]=e*A+d*i+c*q;k[7]=e*z+d*h+c*p;k[8]=e*w+d*f+c*o;return k};PIXI.mat3.clone=function(d){var c=new PIXI.Matrix(9);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];return c};PIXI.mat3.transpose=function(e,d){if(!d||e===d){var h=e[1],f=e[2],c=e[5];e[1]=e[3];e[2]=e[6];e[3]=h;e[5]=e[7];e[6]=f;e[7]=c;return e}d[0]=e[0];d[1]=e[3];d[2]=e[6];d[3]=e[1];d[4]=e[4];d[5]=e[7];d[6]=e[2];d[7]=e[5];d[8]=e[8];return d};PIXI.mat3.toMat4=function(d,c){if(!c){c=PIXI.mat4.create()}c[15]=1;c[14]=0;c[13]=0;c[12]=0;c[11]=0;c[10]=d[8];c[9]=d[7];c[8]=d[6];c[7]=0;c[6]=d[5];c[5]=d[4];c[4]=d[3];c[3]=0;c[2]=d[2];c[1]=d[1];c[0]=d[0];return c};PIXI.mat4.create=function(){var c=new PIXI.Matrix(16);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};PIXI.mat4.transpose=function(f,e){if(!e||f===e){var k=f[1],i=f[2],h=f[3],c=f[6],j=f[7],d=f[11];f[1]=f[4];f[2]=f[8];f[3]=f[12];f[4]=k;f[6]=f[9];f[7]=f[13];f[8]=i;f[9]=c;f[11]=f[14];f[12]=h;f[13]=j;f[14]=d;return f}e[0]=f[0];e[1]=f[4];e[2]=f[8];e[3]=f[12];e[4]=f[1];e[5]=f[5];e[6]=f[9];e[7]=f[13];e[8]=f[2];e[9]=f[6];e[10]=f[10];e[11]=f[14];e[12]=f[3];e[13]=f[7];e[14]=f[11];e[15]=f[15];return e};PIXI.mat4.multiply=function(s,k,m){if(!m){m=s}var A=s[0],z=s[1],v=s[2],t=s[3];var j=s[4],h=s[5],e=s[6],c=s[7];var q=s[8],p=s[9],o=s[10],n=s[11];var C=s[12],B=s[13],w=s[14],u=s[15];var l=k[0],i=k[1],f=k[2],d=k[3];m[0]=l*A+i*j+f*q+d*C;m[1]=l*z+i*h+f*p+d*B;m[2]=l*v+i*e+f*o+d*w;m[3]=l*t+i*c+f*n+d*u;l=k[4];i=k[5];f=k[6];d=k[7];m[4]=l*A+i*j+f*q+d*C;m[5]=l*z+i*h+f*p+d*B;m[6]=l*v+i*e+f*o+d*w;m[7]=l*t+i*c+f*n+d*u;l=k[8];i=k[9];f=k[10];d=k[11];m[8]=l*A+i*j+f*q+d*C;m[9]=l*z+i*h+f*p+d*B;m[10]=l*v+i*e+f*o+d*w;m[11]=l*t+i*c+f*n+d*u;l=k[12];i=k[13];f=k[14];d=k[15];m[12]=l*A+i*j+f*q+d*C;m[13]=l*z+i*h+f*p+d*B;m[14]=l*v+i*e+f*o+d*w;m[15]=l*t+i*c+f*n+d*u;return m};PIXI.Point=function(c,d){this.x=c||0;this.y=d||0};PIXI.Point.prototype.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.prototype.constructor=PIXI.Point;PIXI.Rectangle=function(d,f,e,c){this.x=d||0;this.y=f||0;this.width=e||0;this.height=c||0};PIXI.Rectangle.prototype.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.prototype.contains=function(c,f){if(this.width<=0||this.height<=0){return false}var d=this.x;if(c>=d&&c<=d+this.width){var e=this.y;if(f>=e&&f<=e+this.height){return true}}return false};PIXI.Rectangle.prototype.constructor=PIXI.Rectangle;PIXI.DisplayObject=function(){this.last=this;this.first=this;this.position=new PIXI.Point();this.scale=new PIXI.Point(1,1);this.pivot=new PIXI.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.hitArea=null;this.buttonMode=false;this.renderable=false;this.parent=null;this.stage=null;this.worldAlpha=1;this._interactive=false;this.worldTransform=PIXI.mat3.create();this.localTransform=PIXI.mat3.create();this.color=[];this.dynamic=true;this._sr=0;this._cr=1};PIXI.DisplayObject.prototype.constructor=PIXI.DisplayObject;PIXI.DisplayObject.prototype.setInteractive=function(c){this.interactive=c};Object.defineProperty(PIXI.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(c){this._interactive=c;if(this.stage){this.stage.dirty=true}}});Object.defineProperty(PIXI.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(c){this._mask=c;if(c){this.addFilter(c)}else{this.removeFilter()}}});PIXI.DisplayObject.prototype.addFilter=function(l){if(this.filter){return}this.filter=true;var c=new PIXI.FilterBlock();var f=new PIXI.FilterBlock();c.mask=l;f.mask=l;c.first=c.last=this;f.first=f.last=this;c.open=true;var e=c;var h=c;var k;var j;j=this.first._iPrev;if(j){k=j._iNext;e._iPrev=j;j._iNext=e}else{k=this}if(k){k._iPrev=h;h._iNext=k}var e=f;var h=f;var k=null;var j=null;j=this.last;k=j._iNext;if(k){k._iPrev=h;h._iNext=k}e._iPrev=j;j._iNext=e;var d=this;var i=this.last;while(d){if(d.last==i){d.last=f}d=d.parent}this.first=c;if(this.__renderGroup){this.__renderGroup.addFilterBlocks(c,f)}l.renderable=false};PIXI.DisplayObject.prototype.removeFilter=function(){if(!this.filter){return}this.filter=false;var e=this.first;var i=e._iNext;var j=e._iPrev;if(i){i._iPrev=j}if(j){j._iNext=i}this.first=e._iNext;var f=this.last;var i=f._iNext;var j=f._iPrev;if(i){i._iPrev=j}j._iNext=i;var h=f._iPrev;var d=this;while(d.last==f){d.last=h;d=d.parent;if(!d){break}}var c=e.mask;c.renderable=true;if(this.__renderGroup){this.__renderGroup.removeFilterBlocks(e,f)}};PIXI.DisplayObject.prototype.updateTransform=function(){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}var u=this.localTransform;var h=this.parent.worldTransform;var c=this.worldTransform;u[0]=this._cr*this.scale.x;u[1]=-this._sr*this.scale.y;u[3]=this._sr*this.scale.x;u[4]=this._cr*this.scale.y;var p=this.pivot.x;var o=this.pivot.y;var k=u[0],j=u[1],i=this.position.x-u[0]*p-o*u[1],t=u[3],s=u[4],q=this.position.y-u[4]*o-p*u[3],n=h[0],m=h[1],l=h[2],f=h[3],e=h[4],d=h[5];u[2]=i;u[5]=q;c[0]=n*k+m*t;c[1]=n*j+m*s;c[2]=n*i+m*q+l;c[3]=f*k+e*t;c[4]=f*j+e*s;c[5]=f*i+e*q+d;this.worldAlpha=this.alpha*this.parent.worldAlpha;this.vcount=PIXI.visibleCount};PIXI.visibleCount=0;PIXI.DisplayObjectContainer=function(){PIXI.DisplayObject.call(this);this.children=[]};PIXI.DisplayObjectContainer.prototype=Object.create(PIXI.DisplayObject.prototype);PIXI.DisplayObjectContainer.prototype.constructor=PIXI.DisplayObjectContainer;PIXI.DisplayObjectContainer.prototype.addChild=function(k){if(k.parent!=undefined){k.parent.removeChild(k)}k.parent=this;this.children.push(k);if(this.stage){var h=k;do{if(h.interactive){this.stage.dirty=true}h.stage=this.stage;h=h._iNext}while(h)}var f=k.first;var e=k.last;var i;var j;if(this.filter){j=this.last._iPrev}else{j=this.last}i=j._iNext;var d=this;var c=j;while(d){if(d.last==c){d.last=k.last}d=d.parent}if(i){i._iPrev=e;e._iNext=i}f._iPrev=j;j._iNext=f;if(this.__renderGroup){if(k.__renderGroup){k.__renderGroup.removeDisplayObjectAndChildren(k)}this.__renderGroup.addDisplayObjectAndChildren(k)}};PIXI.DisplayObjectContainer.prototype.addChildAt=function(d,h){if(h>=0&&h<=this.children.length){if(d.parent!=undefined){d.parent.removeChild(d)}d.parent=this;if(this.stage){var f=d;do{if(f.interactive){this.stage.dirty=true}f.stage=this.stage;f=f._iNext}while(f)}var e=d.first;var i=d.last;var l;var k;if(h==this.children.length){k=this.last;var c=this;var j=this.last;while(c){if(c.last==j){c.last=d.last}c=c.parent}}else{if(h==0){k=this}else{k=this.children[h-1].last}}l=k._iNext;if(l){l._iPrev=i;i._iNext=l}e._iPrev=k;k._iNext=e;this.children.splice(h,0,d);if(this.__renderGroup){if(d.__renderGroup){d.__renderGroup.removeDisplayObjectAndChildren(d)}this.__renderGroup.addDisplayObjectAndChildren(d)}}else{throw new Error(d+" The index "+h+" supplied is out of bounds "+this.children.length)}};PIXI.DisplayObjectContainer.prototype.swapChildren=function(d,c){return};PIXI.DisplayObjectContainer.prototype.getChildAt=function(c){if(c>=0&&c=this.textures.length){this.gotoAndStop(this.textures.length-1);if(this.onComplete){this.onComplete()}}}};PIXI.Stage=function(d,c){PIXI.DisplayObjectContainer.call(this);this.worldTransform=PIXI.mat3.create();this.interactive=c;this.interactionManager=new PIXI.InteractionManager(this);this.dirty=true;this.__childrenAdded=[];this.__childrenRemoved=[];this.stage=this;this.stage.hitArea=new PIXI.Rectangle(0,0,100000,100000);this.setBackgroundColor(d);this.worldVisible=true};PIXI.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Stage.prototype.constructor=PIXI.Stage;PIXI.Stage.prototype.updateTransform=function(){this.worldAlpha=1;this.vcount=PIXI.visibleCount;for(var d=0,c=this.children.length;d1){k=1}var e=Math.sqrt(d.x*d.x+d.y*d.y);var h=this.texture.height/2;d.x/=e;d.y/=e;d.x*=h;d.y*=h;c[j]=o.x+d.x;c[j+1]=o.y+d.y;c[j+2]=o.x-d.x;c[j+3]=o.y-d.y;n=o}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.Rope.prototype.setTexture=function(c){this.texture=c;this.updateFrame=true};PIXI.Spine=function(d){PIXI.DisplayObjectContainer.call(this);this.spineData=PIXI.AnimCache[d];if(!this.spineData){throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+d)}this.skeleton=new spine.Skeleton(this.spineData);this.skeleton.updateWorldTransform();this.stateData=new spine.AnimationStateData(this.spineData);this.state=new spine.AnimationState(this.stateData);this.slotContainers=[];for(var h=0,l=this.skeleton.drawOrder.length;h>>1;while(true){if(d[(h+1)*e]<=i){c=h+1}else{f=h}if(c==f){return(c+1)*e}h=(c+f)>>>1}};spine.linearSearch=function(c,h,f){for(var d=0,e=c.length-f;d<=e;d+=f){if(c[d]>h){return d}}return -1};spine.Curves=function(c){this.curves=[];this.curves.length=(c-1)*6};spine.Curves.prototype={setLinear:function(c){this.curves[c*6]=0},setStepped:function(c){this.curves[c*6]=-1},setCurve:function(l,o,v,n,u){var p=1/10;var k=p*p;var j=k*p;var e=3*p;var d=3*k;var c=6*k;var w=6*j;var t=-o*2+n;var s=-v*2+u;var h=(o-n)*3+1;var f=(v-u)*3+1;var q=l*6;var m=this.curves;m[q]=o*e+t*d+h*j;m[q+1]=v*e+s*d+f*j;m[q+2]=t*c+h*w;m[q+3]=s*c+f*w;m[q+4]=h*w;m[q+5]=f*w},getCurvePercent:function(f,m){m=m<0?0:(m>1?1:m);var k=f*6;var s=this.curves;var c=s[k];if(!c){return m}if(c==-1){return 0}var t=s[k+1];var q=s[k+2];var p=s[k+3];var j=s[k+4];var h=s[k+5];var o=c,n=t;var l=10-2;while(true){if(o>=m){var e=o-c;var d=n-t;return d+(n-d)*(m-e)/(o-e)}if(l==0){break}l--;c+=q;t+=p;q+=j;p+=h;o+=c;n+=t}return n+(1-n)*(m-o)/(1-o)}};spine.RotateTimeline=function(c){this.curves=new spine.Curves(c);this.frames=[];this.frames.length=c*2};spine.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(e,c,d){e*=2;this.frames[e]=c;this.frames[e+1]=d},apply:function(e,d,f){var l=this.frames;if(d=l[l.length-2]){var h=m.data.rotation+l[l.length-1]-m.rotation;while(h>180){h-=360}while(h<-180){h+=360}m.rotation+=h*f;return}var c=spine.binarySearch(l,d,2);var i=l[c-1];var k=l[c];var j=1-(d-k)/(l[c-2]-k);j=this.curves.getCurvePercent(c/2-1,j);var h=l[c+1]-i;while(h>180){h-=360}while(h<-180){h+=360}h=m.data.rotation+(i+h*j)-m.rotation;while(h>180){h-=360}while(h<-180){h+=360}m.rotation+=h*f}};spine.TranslateTimeline=function(c){this.curves=new spine.Curves(c);this.frames=[];this.frames.length=c*3};spine.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(f,d,c,e){f*=3;this.frames[f]=d;this.frames[f+1]=c;this.frames[f+2]=e},apply:function(e,d,f){var l=this.frames;if(d=l[l.length-3]){m.x+=(m.data.x+l[l.length-2]-m.x)*f;m.y+=(m.data.y+l[l.length-1]-m.y)*f;return}var c=spine.binarySearch(l,d,3);var i=l[c-2];var h=l[c-1];var k=l[c];var j=1-(d-k)/(l[c+-3]-k);j=this.curves.getCurvePercent(c/3-1,j);m.x+=(m.data.x+i+(l[c+1]-i)*j-m.x)*f;m.y+=(m.data.y+h+(l[c+2]-h)*j-m.y)*f}};spine.ScaleTimeline=function(c){this.curves=new spine.Curves(c);this.frames=[];this.frames.length=c*3};spine.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(f,d,c,e){f*=3;this.frames[f]=d;this.frames[f+1]=c;this.frames[f+2]=e},apply:function(e,d,f){var l=this.frames;if(d=l[l.length-3]){m.scaleX+=(m.data.scaleX-1+l[l.length-2]-m.scaleX)*f;m.scaleY+=(m.data.scaleY-1+l[l.length-1]-m.scaleY)*f;return}var c=spine.binarySearch(l,d,3);var i=l[c-2];var h=l[c-1];var k=l[c];var j=1-(d-k)/(l[c+-3]-k);j=this.curves.getCurvePercent(c/3-1,j);m.scaleX+=(m.data.scaleX-1+i+(l[c+1]-i)*j-m.scaleX)*f;m.scaleY+=(m.data.scaleY-1+h+(l[c+2]-h)*j-m.scaleY)*f}};spine.ColorTimeline=function(c){this.curves=new spine.Curves(c);this.frames=[];this.frames.length=c*5};spine.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(f,d,c,e){f*=5;this.frames[f]=d;this.frames[f+1]=r;this.frames[f+2]=g;this.frames[f+3]=b;this.frames[f+4]=a},apply:function(h,f,j){var q=this.frames;if(f=q[q.length-5]){var k=q.length-1;v.r=q[k-3];v.g=q[k-2];v.b=q[k-1];v.a=q[k];return}var d=spine.binarySearch(q,f,5);var u=q[d-4];var e=q[d-3];var l=q[d-2];var n=q[d-1];var p=q[d];var o=1-(f-p)/(q[d-5]-p);o=this.curves.getCurvePercent(d/5-1,o);var c=u+(q[d+1]-u)*o;var m=e+(q[d+2]-e)*o;var s=l+(q[d+3]-l)*o;var t=n+(q[d+4]-n)*o;if(j<1){v.r+=(c-v.r)*j;v.g+=(m-v.g)*j;v.b+=(s-v.b)*j;v.a+=(t-v.a)*j}else{v.r=c;v.g=m;v.b=s;v.a=t}}};spine.AttachmentTimeline=function(c){this.curves=new spine.Curves(c);this.frames=[];this.frames.length=c;this.attachmentNames=[];this.attachmentNames.length=c};spine.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(e,d,c){this.frames[e]=d;this.attachmentNames[e]=c},apply:function(f,e,d){var h=this.frames;if(e=h[h.length-1]){i=h.length-1}else{i=spine.binarySearch(h,e,1)-1}var c=this.attachmentNames[i];f.slots[this.slotIndex].setAttachment(!c?null:f.getAttachmentBySlotIndex(this.slotIndex,c))}};spine.SkeletonData=function(){this.bones=[];this.slots=[];this.skins=[];this.animations=[]};spine.SkeletonData.prototype={defaultSkin:null,findBone:function(e){var c=this.bones;for(var d=0,f=c.length;d0){var c=this.queue[0];if(this.currentTime>=c.delay){this._setAnimation(c.animation,c.loop);this.queue.shift()}}},apply:function(d){if(!this.current){return}if(this.previous){this.previous.apply(d,this.previousTime,this.previousLoop);var c=this.mixTime/this.mixDuration;if(c>=1){c=1;this.previous=null}this.current.mix(d,this.currentTime,this.currentLoop,c)}else{this.current.apply(d,this.currentTime,this.currentLoop)}},clearAnimation:function(){this.previous=null;this.current=null;this.queue.length=0},_setAnimation:function(d,c){this.previous=null;if(d&&this.current){this.mixDuration=this.data.getMix(this.current,d);if(this.mixDuration>0){this.mixTime=0;this.previous=this.current;this.previousTime=this.currentTime;this.previousLoop=this.currentLoop}}this.current=d;this.currentLoop=c;this.currentTime=0},setAnimationByName:function(d,c){var e=this.data.skeletonData.findAnimation(d);if(!e){throw"Animation not found: "+d}this.setAnimation(e,c)},setAnimation:function(d,c){this.queue.length=0;this._setAnimation(d,c)},addAnimationByName:function(e,c,d){var f=this.data.skeletonData.findAnimation(e);if(!f){throw"Animation not found: "+e}this.addAnimation(f,c,d)},addAnimation:function(h,c,e){var f={};f.animation=h;f.loop=c;if(!e||e<=0){var d=this.queue.length==0?this.current:this.queue[this.queue.length-1].animation;if(d!=null){e=d.duration-this.data.getMix(d,h)+(e||0)}else{e=0}}f.delay=e;this.queue.push(f)},isComplete:function(){return !this.current||this.currentTime>=this.current.duration}};spine.SkeletonJson=function(c){this.attachmentLoader=c};spine.SkeletonJson.prototype={scale:1,readSkeletonData:function(u){var c=new spine.SkeletonData();var B=u.bones;for(var z=0,s=B.length;z=this.lines.length){return null}return this.lines[this.index++]},readValue:function(){var c=this.readLine();var d=c.indexOf(":");if(d==-1){throw"Invalid line: "+c}return this.trim(c.substring(d+1))},readTuple:function(d){var e=this.readLine();var h=e.indexOf(":");if(h==-1){throw"Invalid line: "+e}var f=0,j=h+1;for(;f<3;f++){var c=e.indexOf(",",j);if(c==-1){if(f==0){throw"Invalid line: "+e}break}d[f]=this.trim(e.substr(j,c-j));j=c+1}d[f]=this.trim(e.substring(j));return f+1}};spine.AtlasAttachmentLoader=function(c){this.atlas=c};spine.AtlasAttachmentLoader.prototype={newAttachment:function(f,d,c){switch(d){case spine.AttachmentType.region:var e=this.atlas.findRegion(c);if(!e){throw"Region not found in atlas: "+c+" ("+d+")"}var h=new spine.RegionAttachment(c);h.rendererObject=e;h.setUVs(e.u,e.v,e.u2,e.v2,e.rotate);h.regionOffsetX=e.offsetX;h.regionOffsetY=e.offsetY;h.regionWidth=e.width;h.regionHeight=e.height;h.regionOriginalWidth=e.originalWidth;h.regionOriginalHeight=e.originalHeight;return h}throw"Unknown attachment type: "+d}};PIXI.AnimCache={};spine.Bone.yDown=true;PIXI.TilingSprite=function(e,d,c){PIXI.DisplayObjectContainer.call(this);this.texture=e;this.width=d;this.height=c;this.tileScale=new PIXI.Point(1,1);this.tilePosition=new PIXI.Point(0,0);this.renderable=true;this.blendMode=PIXI.blendModes.NORMAL};PIXI.TilingSprite.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.TilingSprite.prototype.constructor=PIXI.TilingSprite;PIXI.TilingSprite.prototype.setTexture=function(c){this.texture=c;this.updateFrame=true};PIXI.TilingSprite.prototype.onTextureUpdate=function(c){this.updateFrame=true};PIXI.FilterBlock=function(c){this.graphics=c;this.visible=true;this.renderable=true};PIXI.MaskFilter=function(c){this.graphics};PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Graphics.prototype.constructor=PIXI.Graphics;PIXI.Graphics.prototype.lineStyle=function(c,d,e){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.lineWidth=c||0;this.lineColor=d||0;this.lineAlpha=(e==undefined)?1:e;this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.moveTo=function(c,d){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.currentPath.points.push(c,d);this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.lineTo=function(c,d){this.currentPath.points.push(c,d);this.dirty=true};PIXI.Graphics.prototype.beginFill=function(c,d){this.filling=true;this.fillColor=c||0;this.fillAlpha=(d==undefined)?1:d};PIXI.Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1};PIXI.Graphics.prototype.drawRect=function(d,f,e,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[d,f,e,c],type:PIXI.Graphics.RECT};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawCircle=function(d,e,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[d,e,c,c],type:PIXI.Graphics.CIRC};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawElipse=function(d,f,e,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[d,f,e,c],type:PIXI.Graphics.ELIP};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[]};PIXI.Graphics.POLY=0;PIXI.Graphics.RECT=1;PIXI.Graphics.CIRC=2;PIXI.Graphics.ELIP=3;PIXI.CanvasGraphics=function(){};PIXI.CanvasGraphics.renderGraphics=function(A,d){var s=A.worldAlpha;for(var v=0;v1){z=1;console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")}for(var v=0;v<1;v++){var D=B.graphicsData[v];var u=D.points;if(D.type==PIXI.Graphics.POLY){d.beginPath();d.moveTo(u[0],u[1]);for(var t=1;t0){PIXI.Texture.frameUpdates=[]}};PIXI.CanvasRenderer.prototype.resize=function(d,c){this.width=d;this.height=c;this.view.width=d;this.view.height=c};PIXI.CanvasRenderer.prototype.renderDisplayObject=function(j){var f;var h=this.context;h.globalCompositeOperation="source-over";var e=j.last._iNext;j=j.first;do{f=j.worldTransform;if(!j.visible){j=j.last._iNext;continue}if(!j.renderable){j=j._iNext;continue}if(j instanceof PIXI.Sprite){var i=j.texture.frame;if(i){h.globalAlpha=j.worldAlpha;h.setTransform(f[0],f[3],f[1],f[4],f[2],f[5]);h.drawImage(j.texture.baseTexture.source,i.x,i.y,i.width,i.height,(j.anchor.x)*-i.width,(j.anchor.y)*-i.height,i.width,i.height)}}else{if(j instanceof PIXI.Strip){h.setTransform(f[0],f[3],f[1],f[4],f[2],f[5]);this.renderStrip(j)}else{if(j instanceof PIXI.TilingSprite){h.setTransform(f[0],f[3],f[1],f[4],f[2],f[5]);this.renderTilingSprite(j)}else{if(j instanceof PIXI.CustomRenderable){j.renderCanvas(this)}else{if(j instanceof PIXI.Graphics){h.setTransform(f[0],f[3],f[1],f[4],f[2],f[5]);PIXI.CanvasGraphics.renderGraphics(j,h)}else{if(j instanceof PIXI.FilterBlock){if(j.open){h.save();var d=j.mask.alpha;var c=j.mask.worldTransform;h.setTransform(c[0],c[3],c[1],c[4],c[2],c[5]);j.mask.worldAlpha=0.5;h.worldAlpha=0;PIXI.CanvasGraphics.renderGraphicsMask(j.mask,h);h.clip();j.mask.worldAlpha=d}else{h.restore()}}}}}}}j=j._iNext}while(j!=e)};PIXI.CanvasRenderer.prototype.renderStripFlat=function(e){var f=this.context;var h=e.verticies;var l=e.uvs;var j=h.length/2;this.count++;f.beginPath();for(var m=1;m3){PIXI.WebGLGraphics.buildPoly(e,c._webGL)}}if(e.lineWidth>0){PIXI.WebGLGraphics.buildLine(e,c._webGL)}}else{if(e.type==PIXI.Graphics.RECT){PIXI.WebGLGraphics.buildRectangle(e,c._webGL)}else{if(e.type==PIXI.Graphics.CIRC||e.type==PIXI.Graphics.ELIP){PIXI.WebGLGraphics.buildCircle(e,c._webGL)}}}}c._webGL.lastIndex=c.graphicsData.length;var f=PIXI.gl;c._webGL.glPoints=new Float32Array(c._webGL.points);f.bindBuffer(f.ARRAY_BUFFER,c._webGL.buffer);f.bufferData(f.ARRAY_BUFFER,c._webGL.glPoints,f.STATIC_DRAW);c._webGL.glIndicies=new Uint16Array(c._webGL.indices);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c._webGL.indexBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,c._webGL.glIndicies,f.STATIC_DRAW)};PIXI.WebGLGraphics.buildRectangle=function(s,i){var f=s.points;var n=f[0];var m=f[1];var d=f[2];var q=f[3];if(s.fill){var h=HEXtoRGB(s.fillColor);var e=s.fillAlpha;var c=h[0]*e;var j=h[1]*e;var l=h[2]*e;var o=i.points;var p=i.indices;var k=o.length/6;o.push(n,m);o.push(c,j,l,e);o.push(n+d,m);o.push(c,j,l,e);o.push(n,m+q);o.push(c,j,l,e);o.push(n+d,m+q);o.push(c,j,l,e);p.push(k,k,k+1,k+2,k+3,k+3)}if(s.lineWidth){s.points=[n,m,n+d,m,n+d,m+q,n,m+q,n,m];PIXI.WebGLGraphics.buildLine(s,i)}};PIXI.WebGLGraphics.buildCircle=function(k,w){var f=k.points;var j=f[0];var h=f[1];var o=f[2];var n=f[3];var l=40;var t=(Math.PI*2)/l;if(k.fill){var p=HEXtoRGB(k.fillColor);var d=k.fillAlpha;var m=p[0]*d;var s=p[1]*d;var u=p[2]*d;var v=w.points;var e=w.indices;var c=v.length/6;e.push(c);for(var q=0;q140*140){h=L-z;f=K-w;m=Math.sqrt(h*h+f*f);h/=m;f/=m;h*=c;f*=c;S.push(B-h,A-f);S.push(M,T,W,Q);S.push(B+h,A+f);S.push(M,T,W,Q);S.push(B-h,A-f);S.push(M,T,W,Q);q++}else{S.push(px,py);S.push(M,T,W,Q);S.push(B-(px-B),A-(py-A));S.push(M,T,W,Q)}}J=H[(u-2)*2];I=H[(u-2)*2+1];B=H[(u-1)*2];A=H[(u-1)*2+1];L=-(I-A);K=J-B;m=Math.sqrt(L*L+K*K);L/=m;K/=m;L*=c;K*=c;S.push(B-L,A-K);S.push(M,T,W,Q);S.push(B+L,A+K);S.push(M,T,W,Q);l.push(U);for(var R=0;R>16&255)/255,(c>>8&255)/255,(c&255)/255]}PIXI._defaultFrame=new PIXI.Rectangle(0,0,1,1);PIXI.gl;PIXI.WebGLRenderer=function(i,c,f,l,d){this.transparent=!!l;this.width=i||800;this.height=c||600;this.view=f||document.createElement("canvas");this.view.width=this.width;this.view.height=this.height;var h=this;this.view.addEventListener("webglcontextlost",function(e){h.handleContextLost(e)},false);this.view.addEventListener("webglcontextrestored",function(e){h.handleContextRestored(e)},false);this.batchs=[];try{PIXI.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!d,premultipliedAlpha:false,stencil:true})}catch(j){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}PIXI.initPrimitiveShader();PIXI.initDefaultShader();PIXI.initDefaultStripShader();PIXI.activateDefaultShader();var k=this.gl;PIXI.WebGLRenderer.gl=k;this.batch=new PIXI.WebGLBatch(k);k.disable(k.DEPTH_TEST);k.disable(k.CULL_FACE);k.enable(k.BLEND);k.colorMask(true,true,true,this.transparent);PIXI.projection=new PIXI.Point(400,300);this.resize(this.width,this.height);this.contextLost=false;this.stageRenderGroup=new PIXI.WebGLRenderGroup(this.gl)};PIXI.WebGLRenderer.prototype.constructor=PIXI.WebGLRenderer;PIXI.WebGLRenderer.getBatch=function(){if(PIXI._batchs.length==0){return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl)}else{return PIXI._batchs.pop()}};PIXI.WebGLRenderer.returnBatch=function(c){c.clean();PIXI._batchs.push(c)};PIXI.WebGLRenderer.prototype.render=function(c){if(this.contextLost){return}if(this.__stage!==c){this.__stage=c;this.stageRenderGroup.setRenderable(c)}PIXI.WebGLRenderer.updateTextures();PIXI.visibleCount++;c.updateTransform();var e=this.gl;e.colorMask(true,true,true,this.transparent);e.viewport(0,0,this.width,this.height);e.bindFramebuffer(e.FRAMEBUFFER,null);e.clearColor(c.backgroundColorSplit[0],c.backgroundColorSplit[1],c.backgroundColorSplit[2],!this.transparent);e.clear(e.COLOR_BUFFER_BIT);this.stageRenderGroup.backgroundColor=c.backgroundColorSplit;this.stageRenderGroup.render(PIXI.projection);if(c.interactive){if(!c._interactiveEventsAdded){c._interactiveEventsAdded=true;c.interactionManager.setTarget(this)}}if(PIXI.Texture.frameUpdates.length>0){for(var d=0;d0){p=p.children[p.children.length-1];if(p.renderable){c=p}}if(c instanceof PIXI.Sprite){d=c.batch;var n=d.head;if(n==c){k=0}else{k=1;while(n.__next!=c){k++;n=n.__next}}}else{d=c}if(o==d){if(o instanceof PIXI.WebGLBatch){o.render(s,k+1)}else{this.renderSpecial(o,l)}return}e=this.batchs.indexOf(o);t=this.batchs.indexOf(d);if(o instanceof PIXI.WebGLBatch){o.render(s)}else{this.renderSpecial(o,l)}for(var f=e+1;f=2?parseInt(c[c.length-2],10):PIXI.BitmapText.fonts[this.fontName].size;this.dirty=true};PIXI.BitmapText.prototype.updateText=function(){var k=PIXI.BitmapText.fonts[this.fontName];var o=new PIXI.Point();var l=null;var n=[];var t=0;var f=[];var s=0;var h=this.fontSize/k.size;for(var j=0;j0){this.removeChild(this.getChildAt(0))}this.updateText();this.dirty=false}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.BitmapText.fonts={};PIXI.Text=function(d,c){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");PIXI.Sprite.call(this,PIXI.Texture.fromCanvas(this.canvas));this.setText(d);this.setStyle(c);this.updateText();this.dirty=false};PIXI.Text.prototype=Object.create(PIXI.Sprite.prototype);PIXI.Text.prototype.constructor=PIXI.Text;PIXI.Text.prototype.setStyle=function(c){c=c||{};c.font=c.font||"bold 20pt Arial";c.fill=c.fill||"black";c.align=c.align||"left";c.stroke=c.stroke||"black";c.strokeThickness=c.strokeThickness||0;c.wordWrap=c.wordWrap||false;c.wordWrapWidth=c.wordWrapWidth||100;this.style=c;this.dirty=true};PIXI.Sprite.prototype.setText=function(c){this.text=c.toString()||" ";this.dirty=true};PIXI.Text.prototype.updateText=function(){this.context.font=this.style.font;var j=this.text;if(this.style.wordWrap){j=this.wordWrap(this.text)}var h=j.split(/(?:\r\n|\r|\n)/);var e=[];var d=0;for(var k=0;kl){return m}else{return arguments.callee(k,n,m,i,l)}}else{return arguments.callee(k,n,o,m,l)}};var h=function(i,l,k){if(i.measureText(l).width<=k||l.length<1){return l}var m=f(i,l,0,l.length,k);return l.substring(0,m)+"\n"+arguments.callee(i,l.substring(m),k)};var c="";var d=j.split("\n");for(var e=0;ethis.baseTexture.width||c.y+c.height>this.baseTexture.height){throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this)}this.updateFrame=true;PIXI.Texture.frameUpdates.push(this)};PIXI.Texture.fromImage=function(d,c){var e=PIXI.TextureCache[d];if(!e){e=new PIXI.Texture(PIXI.BaseTexture.fromImage(d,c));PIXI.TextureCache[d]=e}return e};PIXI.Texture.fromFrame=function(d){var c=PIXI.TextureCache[d];if(!c){throw new Error("The frameId '"+d+"' does not exist in the texture cache "+this)}return c};PIXI.Texture.fromCanvas=function(c){var d=new PIXI.BaseTexture(c);return new PIXI.Texture(d)};PIXI.Texture.addTextureToCache=function(c,d){PIXI.TextureCache[d]=c};PIXI.Texture.removeTextureFromCache=function(d){var c=PIXI.TextureCache[d];PIXI.TextureCache[d]=null;return c};PIXI.Texture.frameUpdates=[];PIXI.RenderTexture=function(d,c){PIXI.EventTarget.call(this);this.width=d||100;this.height=c||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};PIXI.RenderTexture.prototype=Object.create(PIXI.Texture.prototype);PIXI.RenderTexture.prototype.constructor=PIXI.RenderTexture;PIXI.RenderTexture.prototype.initWebGL=function(){var c=PIXI.gl;this.glFramebuffer=c.createFramebuffer();c.bindFramebuffer(c.FRAMEBUFFER,this.glFramebuffer);this.glFramebuffer.width=this.width;this.glFramebuffer.height=this.height;this.baseTexture=new PIXI.BaseTexture();this.baseTexture.width=this.width;this.baseTexture.height=this.height;this.baseTexture._glTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);this.baseTexture.isRender=true;c.bindFramebuffer(c.FRAMEBUFFER,this.glFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new PIXI.Point(this.width/2,this.height/2);this.render=this.renderWebGL};PIXI.RenderTexture.prototype.resize=function(d,c){this.width=d;this.height=c;if(PIXI.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var e=PIXI.gl;e.bindTexture(e.TEXTURE_2D,this.baseTexture._glTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null)}else{this.frame.width=this.width;this.frame.height=this.height;this.renderer.resize(this.width,this.height)}};PIXI.RenderTexture.prototype.initCanvas=function(){this.renderer=new PIXI.CanvasRenderer(this.width,this.height,null,0);this.baseTexture=new PIXI.BaseTexture(this.renderer.view);this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.render=this.renderCanvas};PIXI.RenderTexture.prototype.renderWebGL=function(m,k,l){var h=PIXI.gl;h.colorMask(true,true,true,true);h.viewport(0,0,this.width,this.height);h.bindFramebuffer(h.FRAMEBUFFER,this.glFramebuffer);if(l){h.clearColor(0,0,0,0);h.clear(h.COLOR_BUFFER_BIT)}var d=m.children;var c=m.worldTransform;m.worldTransform=PIXI.mat3.create();m.worldTransform[4]=-1;m.worldTransform[5]=this.projection.y*2;if(k){m.worldTransform[2]=k.x;m.worldTransform[5]-=k.y}PIXI.visibleCount++;m.vcount=PIXI.visibleCount;for(var f=0,e=d.length;f>1;if(m<3){return[]}var z=[];var k=[];for(var v=0;v3){var t=k[(v+0)%s];var q=k[(v+1)%s];var o=k[(v+2)%s];var h=l[2*t],e=l[2*t+1];var A=l[2*q],w=l[2*q+1];var d=l[2*o],c=l[2*o+1];var f=false;if(PIXI.PolyK._convex(h,e,A,w,d,c,C)){f=true;for(var u=0;u3*s){if(C){var z=[];k=[];for(var v=0;v=0)&&(o>=0)&&(p+o<1)};PIXI.PolyK._convex=function(f,e,i,h,c,j,d){return((e-h)*(c-i)+(i-f)*(j-h)>=0)==d};Phaser.Camera=function(e,i,d,h,f,c){this.game=e;this.world=e.world;this.id=0;this.view=new Phaser.Rectangle(d,h,f,c);this.screenView=new Phaser.Rectangle(d,h,f,c)};Phaser.Camera.FOLLOW_LOCKON=0;Phaser.Camera.FOLLOW_PLATFORMER=1;Phaser.Camera.FOLLOW_TOPDOWN=2;Phaser.Camera.FOLLOW_TOPDOWN_TIGHT=3;Phaser.Camera.prototype={game:null,world:null,id:0,view:null,deadzone:null,visible:true,target:null,follow:function(i,e){if(typeof e==="undefined"){e=Phaser.Camera.FOLLOW_LOCKON}this.target=i;var f;switch(e){case Phaser.Types.CAMERA_FOLLOW_PLATFORMER:var c=this.width/8;var d=this.height/3;this.deadzone=new Phaser.Rectangle((this.width-c)/2,(this.height-d)/2-d*0.25,c,d);break;case Phaser.Types.CAMERA_FOLLOW_TOPDOWN:f=Math.max(this.width,this.height)/4;this.deadzone=new Phaser.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT:f=Math.max(this.width,this.height)/8;this.deadzone=new Phaser.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case Phaser.Types.CAMERA_FOLLOW_LOCKON:default:this.deadzone=null;break}},focusOnXY:function(c,d){c+=(c>0)?1e-7:-1e-7;d+=(d>0)?1e-7:-1e-7;this.view.x=Math.round(c-this.view.halfWidth);this.view.y=Math.round(d-this.view.halfHeight)},update:function(){if(this.target!==null){if(this.deadzone==null){this.focusOnXY(this.target.x,this.target.y)}else{var e;var d=this.target.x+((this.target.x>0)?1e-7:-1e-7);var c=this.target.y+((this.target.y>0)?1e-7:-1e-7);e=d-this.deadzone.x;if(this.view.x>e){this.view.x=e}e=d+this.target.width-this.deadzone.x-this.deadzone.width;if(this.view.xe){this.view.y=e}e=c+this.target.height-this.deadzone.y-this.deadzone.height;if(this.view.ythis.world.bounds.right-this.width){this.view.x=(this.world.bounds.right-this.width)+1}if(this.view.ythis.world.bounds.bottom-this.height){this.view.y=(this.world.bounds.bottom-this.height)+1}this.view.floor()},setPosition:function(c,d){this.view.x=c;this.view.y=d},setSize:function(d,c){this.view.width=d;this.view.height=c}};Object.defineProperty(Phaser.Camera.prototype,"x",{get:function(){return this.view.x},set:function(c){this.view.x=c},enumerable:true,configurable:true});Object.defineProperty(Phaser.Camera.prototype,"y",{get:function(){return this.view.y},set:function(c){this.view.y=c},enumerable:true,configurable:true});Object.defineProperty(Phaser.Camera.prototype,"width",{get:function(){return this.view.width},set:function(c){this.view.width=c},enumerable:true,configurable:true});Object.defineProperty(Phaser.Camera.prototype,"height",{get:function(){return this.view.height},set:function(c){this.view.height=c},enumerable:true,configurable:true});Phaser.State=function(){};Phaser.State.prototype={link:function(c){this.game=c;this.cache=c.cache;this.load=c.load;this.math=c.math;this.time=c.time;this.tweens=c.tweens},preload:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}};Phaser.StateManager=function(d,c){this.game=d;this.states={};if(c!==null){this._pendingState=c}};Phaser.StateManager.prototype={game:null,_pendingState:null,_created:false,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){if(this._pendingState!==null){if(typeof this._pendingState==="string"){this.start(this._pendingState,false,false)}else{this.add("default",this._pendingState,true)}}},add:function(d,e,c){if(typeof c==="undefined"){c=false}var f;if(e instanceof Phaser.State){f=e;f.link(this.game)}else{if(typeof e==="object"){f=e}else{if(typeof e==="function"){f=new e(this.game)}}}this.states[d]=f;if(c){if(this.game.isBooted){this.start(d)}else{this._pendingState=d}}return f},remove:function(c){if(this.current==c){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null}delete this.states[c]},start:function(d,c,e){if(typeof c==="undefined"){c=true}if(typeof e==="undefined"){e=false}if(this.game.isBooted==false){this._pendingState=d;return}if(this.checkState(d)==false){return}else{if(this.current){this.onShutDownCallback.call(this.callbackContext)}if(c){if(e==true){this.game.cache.destroy()}}this.setCurrentState(d)}if(this.onPreloadCallback){this.game.load.reset();this.onPreloadCallback.call(this.callbackContext);if(this.game.load.queueSize==0){this.game.loadComplete();if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true}else{this.game.load.start()}}else{if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true;this.game.loadComplete()}},dummy:function(){},checkState:function(c){if(this.states[c]){var d=false;if(this.states[c]["preload"]){d=true}if(d==false&&this.states[c]["loadRender"]){d=true}if(d==false&&this.states[c]["loadUpdate"]){d=true}if(d==false&&this.states[c]["create"]){d=true}if(d==false&&this.states[c]["update"]){d=true}if(d==false&&this.states[c]["preRender"]){d=true}if(d==false&&this.states[c]["render"]){d=true}if(d==false&&this.states[c]["paused"]){d=true}if(d==false){console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");return false}return true}else{console.warn("Phaser.StateManager - No state found with the key: "+c);return false}},setCurrentState:function(c){this.callbackContext=this.states[c];this.onInitCallback=this.states[c]["init"]||this.dummy;this.onPreloadCallback=this.states[c]["preload"]||null;this.onLoadRenderCallback=this.states[c]["loadRender"]||null;this.onLoadUpdateCallback=this.states[c]["loadUpdate"]||null;this.onCreateCallback=this.states[c]["create"]||null;this.onUpdateCallback=this.states[c]["update"]||null;this.onPreRenderCallback=this.states[c]["preRender"]||null;this.onRenderCallback=this.states[c]["render"]||null;this.onPausedCallback=this.states[c]["paused"]||null;this.onShutDownCallback=this.states[c]["shutdown"]||this.dummy;this.current=c;this._created=false;this.onInitCallback.call(this.callbackContext)},loadComplete:function(){if(this._created==false&&this.onCreateCallback){this.onCreateCallback.call(this.callbackContext);this._created=true}},update:function(){if(this._created&&this.onUpdateCallback){this.onUpdateCallback.call(this.callbackContext)}else{if(this.onLoadUpdateCallback){this.onLoadUpdateCallback.call(this.callbackContext)}}},preRender:function(){if(this.onPreRenderCallback){this.onPreRenderCallback.call(this.callbackContext)}},render:function(){if(this._created&&this.onRenderCallback){this.onRenderCallback.call(this.callbackContext)}else{if(this.onLoadRenderCallback){this.onLoadRenderCallback.call(this.callbackContext)}}},destroy:function(){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null;this.game=null;this.states={};this._pendingState=null}};Phaser.LinkedList=function(){};Phaser.LinkedList.prototype={next:null,prev:null,first:null,last:null,total:0,sprite:{name:"HD"},add:function(c){if(this.total==0&&this.first==null&&this.last==null){this.first=c;this.last=c;this.next=c;c.prev=this;this.total++;return}this.last.next=c;c.prev=this.last;this.last=c;this.total++;return c},remove:function(d){if(this.first==null&&this.last==null){return}this.total--;if(this.first==d&&this.last==d){this.first=null;this.last=null;this.next=null;d.next=null;d.prev=null;return}var c=d.prev;if(d.next){d.next.prev=d.prev}c.next=d.next},dump:function(){console.log("\nNode\t\t|\t\tNext\t\t|\t\tPrev\t\t|\t\tFirst\t\t|\t\tLast");console.log("\t\t\t|\t\t\t\t\t|\t\t\t\t\t|\t\t\t\t\t|");var h="-";var j="-";var d="-";var i="-";if(this.next){h=this.next.sprite.name}if(this.prev){j=this.prev.sprite.name}if(this.first){d=this.first.sprite.name}if(this.last){i=this.last.sprite.name}if(typeof h==="undefined"){h="-"}if(typeof j==="undefined"){j="-"}if(typeof d==="undefined"){d="-"}if(typeof i==="undefined"){i="-"}console.log("HD\t\t\t|\t\t"+h+"\t\t\t|\t\t"+j+"\t\t\t|\t\t"+d+"\t\t\t|\t\t"+i);var c=this;var f=c.last.next;c=c.first;do{var e=c.sprite.name||"*";var h="-";var j="-";var d="-";var i="-";if(c.next){h=c.next.sprite.name}if(c.prev){j=c.prev.sprite.name}if(c.first){d=c.first.sprite.name}if(c.last){i=c.last.sprite.name}if(typeof h==="undefined"){h="-"}if(typeof j==="undefined"){j="-"}if(typeof d==="undefined"){d="-"}if(typeof i==="undefined"){i="-"}console.log(e+"\t\t\t|\t\t"+h+"\t\t\t|\t\t"+j+"\t\t\t|\t\t"+d+"\t\t\t|\t\t"+i);c=c.next}while(c!=f)}};Phaser.Signal=function(){this._bindings=[];this._prevParams=null;var c=this;this.dispatch=function(){Phaser.Signal.prototype.dispatch.apply(c,arguments)}};Phaser.Signal.prototype={memorize:false,_shouldPropagate:true,active:true,validateListener:function(c,d){if(typeof c!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",d))}},_registerListener:function(h,e,f,d){var c=this._indexOfListener(h,f),i;if(c!==-1){i=this._bindings[c];if(i.isOnce()!==e){throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(!e?"":"Once")+"() the same listener without removing the relationship first.")}}else{i=new Phaser.SignalBinding(this,h,e,f,d);this._addBinding(i)}if(this.memorize&&this._prevParams){i.execute(this._prevParams)}return i},_addBinding:function(c){var d=this._bindings.length;do{--d}while(this._bindings[d]&&c._priority<=this._bindings[d]._priority);this._bindings.splice(d+1,0,c)},_indexOfListener:function(d,c){var f=this._bindings.length,e;while(f--){e=this._bindings[f];if(e._listener===d&&e.context===c){return f}}return -1},has:function(d,c){return this._indexOfListener(d,c)!==-1},add:function(e,d,c){this.validateListener(e,"add");return this._registerListener(e,false,d,c)},addOnce:function(e,d,c){this.validateListener(e,"addOnce");return this._registerListener(e,true,d,c)},remove:function(e,d){this.validateListener(e,"remove");var c=this._indexOfListener(e,d);if(c!==-1){this._bindings[c]._destroy();this._bindings.splice(c,1)}return e},removeAll:function(){var c=this._bindings.length;while(c--){this._bindings[c]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(d){if(!this.active){return}var c=Array.prototype.slice.call(arguments),f=this._bindings.length,e;if(this.memorize){this._prevParams=c}if(!f){return}e=this._bindings.slice();this._shouldPropagate=true;do{f--}while(e[f]&&this._shouldPropagate&&e[f].execute(c)!==false)},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Phaser.SignalBinding=function(h,f,d,e,c){this._listener=f;this._isOnce=d;this.context=e;this._signal=h;this._priority=c||0};Phaser.SignalBinding.prototype={active:true,params:null,execute:function(c){var e,d;if(this.active&&!!this._listener){d=this.params?this.params.concat(c):c;e=this._listener.apply(this.context,d);if(this._isOnce){this.detach()}}return e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return(!!this._signal&&!!this._listener)},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};Phaser.Plugin=function(c,d){this.game=c;this.parent=d;this.active=false;this.visible=false;this.hasPreUpdate=false;this.hasUpdate=false;this.hasPostUpdate=false;this.hasPreRender=false;this.hasRender=false;this.hasPostRender=false};Phaser.Plugin.prototype={preUpdate:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=false;this.visible=false}};Phaser.PluginManager=function(c,d){this.game=c;this._parent=d;this.plugins=[];this._pluginsLength=0};Phaser.PluginManager.prototype={add:function(d){var c=false;if(typeof d==="function"){d=new d(this.game,this._parent)}else{d.game=this.game;d.parent=this._parent}if(typeof d.preUpdate==="function"){d.hasPreUpdate=true;c=true}if(typeof d.update==="function"){d.hasUpdate=true;c=true}if(typeof d.postUpdate==="function"){d.hasPostUpdate=true;c=true}if(typeof d.preRender==="function"){d.hasPreRender=true;c=true}if(typeof d.render==="function"){d.hasRender=true;c=true}if(typeof d.postRender==="function"){d.hasPostRender=true;c=true}if(c){if(d.hasPreUpdate||d.hasUpdate||d.hasPostUpdate){d.active=true}if(d.hasPreRender||d.hasRender||d.hasPostRender){d.visible=true}this._pluginsLength=this.plugins.push(d);return d}else{return null}},remove:function(c){this._pluginsLength--},preUpdate:function(){if(this._pluginsLength==0){return}for(this._p=0;this._p0)},removeBetween:function(e,d){if(e>d||e<0||d>this._container.children.length){return false}for(var c=e;c0;c--){if(this["pointer"+c]===null){d=c}}if(d==0){console.warn("You can only have 10 Pointer objects");return null}else{this["pointer"+d]=new Phaser.Pointer(this.game,d);return this["pointer"+d]}},update:function(){if(this.pollRate>0&&this._pollCounter0&&this._pollCounter=this.game.input.holdRate){if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onHold.dispatch(this)}this._holdSent=true}if(this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop){this._nextDrop=this.game.time.now+this.game.input.recordRate;this._history.push({x:this.position.x,y:this.position.y});if(this._history.length>this.game.input.recordLimit){this._history.shift()}}}},move:function(d){if(this.game.input.pollLocked){return}if(d.button){this.button=d.button}this.clientX=d.clientX;this.clientY=d.clientY;this.pageX=d.pageX;this.pageY=d.pageY;this.screenX=d.screenX;this.screenY=d.screenY;this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x;this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y;this.position.setTo(this.x,this.y);this.circle.x=this.x;this.circle.y=this.y;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.activePointer=this;this.game.input.x=this.x;this.game.input.y=this.y;this.game.input.position.setTo(this.game.input.x,this.game.input.y);this.game.input.circle.x=this.game.input.x;this.game.input.circle.y=this.game.input.y}if(this.game.paused){return this}if(this.targetObject!==null&&this.targetObject.isDragged==true){if(this.targetObject.update(this)==false){this.targetObject=null}return this}this._highestRenderOrderID=-1;this._highestRenderObject=null;this._highestInputPriorityID=-1;if(this.game.input.interactiveItems.total>0){var c=this.game.input.interactiveItems.next;do{if(c.priorityID>this._highestInputPriorityID||(c.priorityID==this._highestInputPriorityID&&c.sprite.renderOrderID>this._highestRenderOrderID)){if(c.checkPointerOver(this)){this._highestRenderOrderID=c.sprite.renderOrderID;this._highestInputPriorityID=c.priorityID;this._highestRenderObject=c}}c=c.next}while(c!=null)}if(this._highestRenderObject==null){if(this.targetObject){this.targetObject._pointerOutHandler(this);this.targetObject=null}}else{if(this.targetObject==null){this.targetObject=this._highestRenderObject;this._highestRenderObject._pointerOverHandler(this)}else{if(this.targetObject==this._highestRenderObject){if(this._highestRenderObject.update(this)==false){this.targetObject=null}}else{this.targetObject._pointerOutHandler(this);this.targetObject=this._highestRenderObject;this.targetObject._pointerOverHandler(this)}}}return this},leave:function(c){this.withinGame=false;this.move(c)},stop:function(d){if(this._stateReset){d.preventDefault();return}this.timeUp=this.game.time.now;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onUp.dispatch(this);if(this.duration>=0&&this.duration<=this.game.input.tapRate){if(this.timeUp-this.previousTapTime0){this.active=false}this.withinGame=false;this.isDown=false;this.isUp=true;if(this.isMouse==false){this.game.input.currentPointers--}if(this.game.input.interactiveItems.total>0){var c=this.game.input.interactiveItems.next;do{if(c){c._releasedHandler(this)}c=c.next}while(c!=null)}if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null;return this},justPressed:function(c){c=c||this.game.input.justPressedRate;return(this.isDown===true&&(this.timeDown+c)>this.game.time.now)},justReleased:function(c){c=c||this.game.input.justReleasedRate;return(this.isUp===true&&(this.timeUp+c)>this.game.time.now)},reset:function(){if(this.isMouse==false){this.active=false}this.identifier=null;this.isDown=false;this.isUp=true;this.totalTouches=0;this._holdSent=false;this._history.length=0;this._stateReset=true;if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}};Object.defineProperty(Phaser.Pointer.prototype,"duration",{get:function(){if(this.isUp){return -1}return this.game.time.now-this.timeDown},enumerable:true,configurable:true});Object.defineProperty(Phaser.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x},enumerable:true,configurable:true});Object.defineProperty(Phaser.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y},enumerable:true,configurable:true});Phaser.Touch=function(c){this.game=c;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null};Phaser.Touch.prototype={game:null,disabled:false,_onTouchStart:null,_onTouchMove:null,_onTouchEnd:null,_onTouchEnter:null,_onTouchLeave:null,_onTouchCancel:null,_onTouchMove:null,start:function(){var c=this;if(this.game.device.touch){this._onTouchStart=function(d){return c.onTouchStart(d)};this._onTouchMove=function(d){return c.onTouchMove(d)};this._onTouchEnd=function(d){return c.onTouchEnd(d)};this._onTouchEnter=function(d){return c.onTouchEnter(d)};this._onTouchLeave=function(d){return c.onTouchLeave(d)};this._onTouchCancel=function(d){return c.onTouchCancel(d)};this._documentTouchMove=function(d){return c.consumeTouchMove(d)};this.game.stage.canvas.addEventListener("touchstart",this._onTouchStart,false);this.game.stage.canvas.addEventListener("touchmove",this._onTouchMove,false);this.game.stage.canvas.addEventListener("touchend",this._onTouchEnd,false);this.game.stage.canvas.addEventListener("touchenter",this._onTouchEnter,false);this.game.stage.canvas.addEventListener("touchleave",this._onTouchLeave,false);this.game.stage.canvas.addEventListener("touchcancel",this._onTouchCancel,false);document.addEventListener("touchmove",this._documentTouchMove,false)}},consumeTouchMove:function(c){c.preventDefault()},onTouchStart:function(d){if(this.touchStartCallback){this.touchStartCallback.call(this.callbackContext,d)}if(this.game.input.disabled||this.disabled){return}d.preventDefault();for(var c=0;cd&&this._tempPoint.xe&&this._tempPoint.ythis.boundsRect.right){this.sprite.x=this.boundsRect.right-this.sprite.width}}if(this.sprite.ythis.boundsRect.bottom){this.sprite.y=this.boundsRect.bottom-this.sprite.height}}},checkBoundsSprite:function(){if(this.sprite.x(this.boundsSprite.x+this.boundsSprite.width)){this.sprite.x=(this.boundsSprite.x+this.boundsSprite.width)-this.sprite.width}}if(this.sprite.y(this.boundsSprite.y+this.boundsSprite.height)){this.sprite.y=(this.boundsSprite.y+this.boundsSprite.height)-this.sprite.height}}}};Phaser.Canvas={getOffset:function(d,c){if(typeof c==="undefined"){c=new Phaser.Point}var e=d.getBoundingClientRect();var j=d.clientTop||document.body.clientTop||0;var i=d.clientLeft||document.body.clientLeft||0;var f=window.pageYOffset||d.scrollTop||document.body.scrollTop;var h=window.pageXOffset||d.scrollLeft||document.body.scrollLeft;c.x=e.left+h-i;c.y=e.top+f-j;return c},getAspectRatio:function(c){return c.width/c.height},setBackgroundColor:function(d,c){if(typeof c==="undefined"){c="rgb(0,0,0)"}d.style.backgroundColor=c;return d},setTouchAction:function(c,d){if(typeof d==="undefined"){d="none"}c.style.msTouchAction=d;c.style["ms-touch-action"]=d;c.style["touch-action"]=d;return c},addToDOM:function(c,d,e){if(typeof d==="undefined"){d=""}if(typeof e==="undefined"){e=true}if((d!==""||d!==null)&&document.getElementById(d)){document.getElementById(d).appendChild(c);if(e){document.getElementById(d).style.overflow="hidden"}}else{document.body.appendChild(c)}return c},setTransform:function(h,j,i,e,c,f,d){h.setTransform(e,f,d,c,j,i);return h},setSmoothingEnabled:function(c,d){c.imageSmoothingEnabled=d;c.mozImageSmoothingEnabled=d;c.oImageSmoothingEnabled=d;c.webkitImageSmoothingEnabled=d;c.msImageSmoothingEnabled=d;return c},setImageRenderingCrisp:function(c){c.style["image-rendering"]="crisp-edges";c.style["image-rendering"]="-moz-crisp-edges";c.style["image-rendering"]="-webkit-optimize-contrast";c.style.msInterpolationMode="nearest-neighbor";return c},setImageRenderingBicubic:function(c){c.style["image-rendering"]="auto";c.style.msInterpolationMode="bicubic";return c}};Phaser.Events=function(c){this.parent=c;this.onAddedToGroup=new Phaser.Signal;this.onRemovedFromGroup=new Phaser.Signal;this.onKilled=new Phaser.Signal;this.onRevived=new Phaser.Signal;this.onOutOfBounds=new Phaser.Signal;this.onInputOver=null;this.onInputOut=null;this.onInputDown=null;this.onInputUp=null;this.onDragStart=null;this.onDragStop=null};Phaser.GameObjectFactory=function(c){this.game=c;this.world=this.game.world};Phaser.GameObjectFactory.prototype={game:null,world:null,sprite:function(c,f,d,e){return this.world.add(new Phaser.Sprite(this.game,c,f,d,e))},child:function(e,c,i,d,f){var h=this.world.add(new Phaser.Sprite(this.game,c,i,d,f));e.addChild(h);return h},tween:function(d,c){return this.game.tweens.create(d,c)},group:function(d,c){return new Phaser.Group(this.game,d,c)},audio:function(d,e,c){return this.game.sound.add(d,e,c)},tileSprite:function(d,i,f,c,e,h){return this.world.add(new Phaser.TileSprite(this.game,d,i,f,c,e,h))},text:function(c,f,e,d){return this.world.add(new Phaser.Text(this.game,c,f,e,d))}};Phaser.Sprite=function(d,c,h,e,f){c=c||0;h=h||0;e=e||null;f=f||null;this.game=d;this.exists=true;this.alive=true;this.group=null;this.name="";this.renderOrderID=-1;if(e){PIXI.Sprite.call(this,PIXI.TextureCache[e])}else{PIXI.Sprite.call(this)}this.events=new Phaser.Events(this);this.animations=new Phaser.AnimationManager(this);if(this.game.cache.isSpriteSheet(e)){this.animations.loadFrameData(this.game.cache.getFrameData(e));if(f!==null){if(typeof f==="string"){this.frameName=f}else{this.frame=f}}}else{this.currentFrame=this.game.cache.getFrame(e)}this.input=new Phaser.InputHandler(this);this.anchor=new Phaser.Point();this.x=c;this.y=h;this.position.x=c;this.position.y=h;this.autoCull=false;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:c,a10:0,a11:1,a12:h,id:1,i01:0,i10:0,idi:1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),frameID:this.currentFrame.uuid,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:true};this.offset=new Phaser.Point;this.center=new Phaser.Point(c+Math.floor(this._cache.width/2),h+Math.floor(this._cache.height/2));this.topLeft=new Phaser.Point(c,h);this.topRight=new Phaser.Point(c+this._cache.width,h);this.bottomRight=new Phaser.Point(c+this._cache.width,h+this._cache.height);this.bottomLeft=new Phaser.Point(c,h+this._cache.height);this.bounds=new Phaser.Rectangle(c,h,this._cache.width,this._cache.height);this.body=new Phaser.Physics.Arcade.Body(this)};Phaser.Sprite.prototype=Object.create(PIXI.Sprite.prototype);Phaser.Sprite.prototype.constructor=Phaser.Sprite;Phaser.Sprite.prototype.update=function(){if(!this.exists){this.renderOrderID=-1;return}this._cache.dirty=false;if(this.animations.update()){this._cache.dirty=true}this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}if(this.visible){this.renderOrderID=this.game.world.currentRenderOrderID++;if(this.worldTransform[0]!=this._cache.a00||this.worldTransform[1]!=this._cache.a01){this._cache.a00=this.worldTransform[0];this._cache.a01=this.worldTransform[1];this._cache.i01=this.worldTransform[1];this._cache.scaleX=Math.sqrt((this._cache.a00*this._cache.a00)+(this._cache.a01*this._cache.a01));this._cache.a01*=-1;this._cache.dirty=true}if(this.worldTransform[3]!=this._cache.a10||this.worldTransform[4]!=this._cache.a11){this._cache.a10=this.worldTransform[3];this._cache.i10=this.worldTransform[3];this._cache.a11=this.worldTransform[4];this._cache.scaleY=Math.sqrt((this._cache.a10*this._cache.a10)+(this._cache.a11*this._cache.a11));this._cache.a10*=-1;this._cache.dirty=true}if(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12){this._cache.a02=this.worldTransform[2];this._cache.a12=this.worldTransform[5];this._cache.dirty=true}if(this.currentFrame.uuid!=this._cache.frameID){this._cache.frameWidth=this.texture.frame.width;this._cache.frameHeight=this.texture.frame.height;this._cache.frameID=this.currentFrame.uuid;this._cache.dirty=true}if(this._cache.dirty){this._cache.width=Math.floor(this.currentFrame.sourceSizeW*this._cache.scaleX);this._cache.height=Math.floor(this.currentFrame.sourceSizeH*this._cache.scaleY);this._cache.halfWidth=Math.floor(this._cache.width/2);this._cache.halfHeight=Math.floor(this._cache.height/2);this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10);this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10);this.updateBounds()}}else{if(this._cache.dirty&&this.visible==false){this.bounds.x-=this._cache.boundsX-this._cache.x;this._cache.boundsX=this._cache.x;this.bounds.y-=this._cache.boundsy-this._cache.y;this._cache.boundsY=this._cache.y}}if(this._cache.dirty){this._cache.cameraVisible=Phaser.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0);if(this.autoCull==true){this.visible=this._cache.cameraVisible}this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)}this.body.update()};Phaser.Sprite.prototype.postUpdate=function(){this.body.postUpdate()};Phaser.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-(this.anchor.x*this._cache.width),this._cache.a12-(this.anchor.y*this._cache.height));this.getLocalPosition(this.center,this.offset.x+this._cache.halfWidth,this.offset.y+this._cache.halfHeight);this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y);this.getLocalPosition(this.topRight,this.offset.x+this._cache.width,this.offset.y);this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this._cache.height);this.getLocalPosition(this.bottomRight,this.offset.x+this._cache.width,this.offset.y+this._cache.height);this._cache.left=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.right=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.top=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this._cache.bottom=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top);this._cache.boundsX=this._cache.x;this._cache.boundsY=this._cache.y};Phaser.Sprite.prototype.getLocalPosition=function(d,c,e){d.x=((this._cache.a11*this._cache.id*c+-this._cache.a01*this._cache.id*e+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this._cache.scaleX)+this._cache.a02;d.y=((this._cache.a00*this._cache.id*e+-this._cache.a10*this._cache.id*c+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this._cache.scaleY)+this._cache.a12;return d};Phaser.Sprite.prototype.getLocalUnmodifiedPosition=function(d,c,e){d.x=this._cache.a11*this._cache.idi*c+-this._cache.i01*this._cache.idi*e+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi;d.y=this._cache.a00*this._cache.idi*e+-this._cache.i10*this._cache.idi*c+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi;return d};Phaser.Sprite.prototype.bringToTop=function(){if(this.group){this.group.bringToTop(this)}else{this.game.world.bringToTop(this)}};Phaser.Sprite.prototype.getBounds=function(e){e=e||new Phaser.Rectangle;var h=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var d=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var f=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);var c=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);e.x=h;e.y=f;e.width=d-h;e.height=c-f;return e};Object.defineProperty(Phaser.Sprite.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(c){this.rotation=Phaser.Math.degToRad(c)}});Object.defineProperty(Phaser.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(c){this.animations.frame=c}});Object.defineProperty(Phaser.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(c){this.animations.frameName=c}});Object.defineProperty(Phaser.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}});Object.defineProperty(Phaser.Sprite.prototype,"inputEnabled",{get:function(){return(this.input.enabled)},set:function(c){if(c){if(this.input.enabled==false){this.input.start()}}else{if(this.input.enabled){this.input.stop()}}}});Phaser.TileSprite=function(e,d,j,h,c,f,i){d=d||0;j=j||0;h=h||256;c=c||256;f=f||null;i=i||null;Phaser.Sprite.call(this,e,d,j,f,i);this.texture=PIXI.TextureCache[f];PIXI.TilingSprite.call(this,this.texture,h,c);this.tileScale=new Phaser.Point(1,1);this.tilePosition=new Phaser.Point(0,0)};Phaser.TileSprite.prototype=Phaser.Utils.extend(true,PIXI.TilingSprite.prototype,Phaser.Sprite.prototype);Phaser.TileSprite.prototype.constructor=Phaser.TileSprite;Phaser.Text=function(d,c,i,h,e){c=c||0;i=i||0;h=h||"";e=e||"";this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");var f=d.rnd.uuid();PIXI.TextureCache[f]=new PIXI.Texture(new PIXI.BaseTexture(this.canvas));Phaser.Sprite.call(this,d,c,i,f);this.setText(h);this.setStyle(e);this.updateText();this.dirty=false};Phaser.Text.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Text.prototype);Phaser.Text.prototype.constructor=Phaser.Text;Phaser.Canvas={getOffset:function(d,c){if(typeof c==="undefined"){c=new Phaser.Point}var e=d.getBoundingClientRect();var j=d.clientTop||document.body.clientTop||0;var i=d.clientLeft||document.body.clientLeft||0;var f=window.pageYOffset||d.scrollTop||document.body.scrollTop;var h=window.pageXOffset||d.scrollLeft||document.body.scrollLeft;c.x=e.left+h-i;c.y=e.top+f-j;return c},getAspectRatio:function(c){return c.width/c.height},setBackgroundColor:function(d,c){if(typeof c==="undefined"){c="rgb(0,0,0)"}d.style.backgroundColor=c;return d},setTouchAction:function(c,d){if(typeof d==="undefined"){d="none"}c.style.msTouchAction=d;c.style["ms-touch-action"]=d;c.style["touch-action"]=d;return c},addToDOM:function(c,d,e){if(typeof d==="undefined"){d=""}if(typeof e==="undefined"){e=true}if((d!==""||d!==null)&&document.getElementById(d)){document.getElementById(d).appendChild(c);if(e){document.getElementById(d).style.overflow="hidden"}}else{document.body.appendChild(c)}return c},setTransform:function(h,j,i,e,c,f,d){h.setTransform(e,f,d,c,j,i);return h},setSmoothingEnabled:function(c,d){c.imageSmoothingEnabled=d;c.mozImageSmoothingEnabled=d;c.oImageSmoothingEnabled=d;c.webkitImageSmoothingEnabled=d;c.msImageSmoothingEnabled=d;return c},setImageRenderingCrisp:function(c){c.style["image-rendering"]="crisp-edges";c.style["image-rendering"]="-moz-crisp-edges";c.style["image-rendering"]="-webkit-optimize-contrast";c.style.msInterpolationMode="nearest-neighbor";return c},setImageRenderingBicubic:function(c){c.style["image-rendering"]="auto";c.style.msInterpolationMode="bicubic";return c}};Phaser.Device=function(){this.patchAndroidClearRectBug=false;this.desktop=false;this.iOS=false;this.android=false;this.chromeOS=false;this.linux=false;this.macOS=false;this.windows=false;this.canvas=false;this.file=false;this.fileSystem=false;this.localStorage=false;this.webGL=false;this.worker=false;this.touch=false;this.mspointer=false;this.css3D=false;this.arora=false;this.chrome=false;this.epiphany=false;this.firefox=false;this.ie=false;this.ieVersion=0;this.mobileSafari=false;this.midori=false;this.opera=false;this.safari=false;this.webApp=false;this.audioData=false;this.webAudio=false;this.ogg=false;this.opus=false;this.mp3=false;this.wav=false;this.m4a=false;this.webm=false;this.iPhone=false;this.iPhone4=false;this.iPad=false;this.pixelRatio=0;this._checkAudio();this._checkBrowser();this._checkCSS3D();this._checkDevice();this._checkFeatures();this._checkOS()};Phaser.Device.prototype={_checkOS:function(){var c=navigator.userAgent;if(/Android/.test(c)){this.android=true}else{if(/CrOS/.test(c)){this.chromeOS=true}else{if(/iP[ao]d|iPhone/i.test(c)){this.iOS=true}else{if(/Linux/.test(c)){this.linux=true}else{if(/Mac OS/.test(c)){this.macOS=true}else{if(/Windows/.test(c)){this.windows=true}}}}}}if(this.windows||this.macOS||this.linux){this.desktop=true}},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(c){this.localStorage=false}this.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob;this.fileSystem=!!window.requestFileSystem;this.webGL=(function(){try{return !!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(d){return false}})();this.worker=!!window.Worker;if("ontouchstart" in document.documentElement||window.navigator.msPointerEnabled){this.touch=true}if(window.navigator.msPointerEnabled){this.mspointer=true}},_checkBrowser:function(){var c=navigator.userAgent;if(/Arora/.test(c)){this.arora=true}else{if(/Chrome/.test(c)){this.chrome=true}else{if(/Epiphany/.test(c)){this.epiphany=true}else{if(/Firefox/.test(c)){this.firefox=true}else{if(/Mobile Safari/.test(c)){this.mobileSafari=true}else{if(/MSIE (\d+\.\d+);/.test(c)){this.ie=true;this.ieVersion=parseInt(RegExp.$1)}else{if(/Midori/.test(c)){this.midori=true}else{if(/Opera/.test(c)){this.opera=true}else{if(/Safari/.test(c)){this.safari=true}}}}}}}}}if(navigator.standalone){this.webApp=true}},_checkAudio:function(){this.audioData=!!(window.Audio);this.webAudio=!!(window.webkitAudioContext||window.AudioContext);var f=document.createElement("audio");var c=false;try{if(c=!!f.canPlayType){if(f.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")){this.ogg=true}if(f.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")){this.opus=true}if(f.canPlayType("audio/mpeg;").replace(/^no$/,"")){this.mp3=true}if(f.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")){this.wav=true}if(f.canPlayType("audio/x-m4a;")||f.canPlayType("audio/aac;").replace(/^no$/,"")){this.m4a=true}if(f.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")){this.webm=true}}}catch(d){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1;this.iPhone=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1;this.iPhone4=(this.pixelRatio==2&&this.iPhone);this.iPad=navigator.userAgent.toLowerCase().indexOf("ipad")!=-1},_checkCSS3D:function(){var e=document.createElement("p");var f;var d={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(e,null);for(var c in d){if(e.style[c]!==undefined){e.style[c]="translate3d(1px,1px,1px)";f=window.getComputedStyle(e).getPropertyValue(d[c])}}document.body.removeChild(e);this.css3D=(f!==undefined&&f.length>0&&f!=="none")},canPlayAudio:function(c){if(c=="mp3"&&this.mp3){return true}else{if(c=="ogg"&&(this.ogg||this.opus)){return true}else{if(c=="m4a"&&this.m4a){return true}else{if(c=="wav"&&this.wav){return true}else{if(c=="webm"&&this.webm){return true}}}}}return false},isConsoleOpen:function(){if(window.console&&window.console.firebug){return true}if(window.console){console.profile();console.profileEnd();if(console.clear){console.clear()}return console.profiles.length>0}return false}};Phaser.RequestAnimationFrame=function(d){this.game=d;this._isSetTimeOut=false;this.isRunning=false;var e=["ms","moz","webkit","o"];for(var c=0;c>>0;d-=f;d*=f;f=d>>>0;d-=f;f+=d*4294967296}return(f>>>0)*2.3283064365386963e-10},integer:function(){return this.rnd.apply(this)*4294967296},frac:function(){return this.rnd.apply(this)+(this.rnd.apply(this)*2097152|0)*1.1102230246251565e-16},real:function(){return this.integer()+this.frac()},integerInRange:function(d,c){return Math.floor(this.realInRange(d,c))},realInRange:function(d,c){d=d||0;c=c||0;return this.frac()*(c-d)+d},normal:function(){return 1-2*this.frac()},uuid:function(){var d,c;for(c=d="";d++<36;c+=~d%5|d*3&4?(d^15?8^this.frac()*(d^20?16:4):4).toString(16):"-"){}return c},pick:function(c){return c[this.integerInRange(0,c.length)]},weightedPick:function(c){return c[~~(Math.pow(this.frac(),2)*c.length)]},timestamp:function(d,c){return this.realInRange(d||946684800000,c||1577862000000)},angle:function(){return this.integerInRange(-180,180)}};Phaser.Math={PI2:Math.PI*2,fuzzyEqual:function(d,c,e){if(typeof e==="undefined"){e=0.0001}return Math.abs(d-c)c-e},fuzzyCeil:function(c,d){if(typeof d==="undefined"){d=0.0001}return Math.ceil(c-d)},fuzzyFloor:function(c,d){if(typeof d==="undefined"){d=0.0001}return Math.floor(c+d)},average:function(){var c=[];for(var e=0;e<(arguments.length-0);e++){c[e]=arguments[e+0]}var f=0;for(var d=0;d0)?Math.floor(c):Math.ceil(c)},shear:function(c){return c%1},snapTo:function(c,e,d){if(typeof d==="undefined"){d=0}if(e==0){return c}c-=d;c=e*Math.round(c/e);return d+c},snapToFloor:function(c,e,d){if(typeof d==="undefined"){d=0}if(e==0){return c}c-=d;c=e*Math.floor(c/e);return d+c},snapToCeil:function(c,e,d){if(typeof d==="undefined"){d=0}if(e==0){return c}c-=d;c=e*Math.ceil(c/e);return d+c},snapToInArray:function(e,d,h){if(typeof h==="undefined"){h=true}if(h){d.sort()}if(ee/2){d+=e*2}if(c<-e/2&&d>e/2){c+=e*2}return c-d},interpolateAngles:function(d,c,e,f,h){if(typeof f==="undefined"){f=true}if(typeof h==="undefined"){h=null}d=this.normalizeAngle(d,f);c=this.normalizeAngleToAnother(c,d,f);return(typeof h==="function")?h(e,d,c-d,1):this.interpolateFloat(d,c,e)},chanceRoll:function(c){if(typeof c==="undefined"){c=50}if(c<=0){return false}else{if(c>=100){return true}else{if(Math.random()*100>=c){return false}else{return true}}}},maxAdd:function(e,d,c){e+=d;if(e>c){e=c}return e},minSub:function(e,d,c){e-=d;if(e0.5)?1:-1},isOdd:function(c){return(c&1)},isEven:function(c){if(c&1){return false}else{return true}},max:function(){for(var e=1,d=0,c=arguments.length;e=-180&&d<=180){return d}c=(d+180)%360;if(c<0){c+=360}return c-180},angleLimit:function(f,e,d){var c=f;if(f>d){c=d}else{if(f1){return this.linear(e[c],e[c-1],c-j)}return this.linear(e[h],e[h+1>c?c:h+1],j-h)},bezierInterpolation:function(e,d){var c=0;var h=e.length-1;for(var f=0;f<=h;f++){c+=Math.pow(1-d,h-f)*Math.pow(d,f)*e[f]*this.bernstein(h,f)}return c},catmullRomInterpolation:function(e,d){var c=e.length-1;var j=c*d;var h=Math.floor(j);if(e[0]===e[c]){if(d<0){h=Math.floor(j=c*(1+d))}return this.catmullRom(e[(h-1+c)%c],e[h],e[(h+1)%c],e[(h+2)%c],j-h)}else{if(d<0){return e[0]-(this.catmullRom(e[0],e[0],e[1],e[1],-j)-e[0])}if(d>1){return e[c]-(this.catmullRom(e[c],e[c],e[c-1],e[c-1],j-c)-e[c])}return this.catmullRom(e[h?h-1:0],e[h],e[ce.length-f)){c=e.length-f}if(c>0){return e[f+Math.floor(Math.random()*c)]}}return null},floor:function(c){var d=c|0;return(c>0)?(d):((d!=c)?(d-1):(d))},ceil:function(c){var d=c|0;return(c>0)?((d!=c)?(d+1):(d)):(d)},sinCosGenerator:function(d,l,e,j){if(typeof l==="undefined"){l=1}if(typeof e==="undefined"){e=1}if(typeof j==="undefined"){j=1}var k=l;var n=e;var h=j*Math.PI/d;var f=[];var m=[];for(var i=0;i0;e--){var d=Math.floor(Math.random()*(e+1));var c=f[e];f[e]=f[d];f[d]=c}return f},distance:function(f,i,e,h){var d=f-e;var c=i-h;return Math.sqrt(d*d+c*c)},distanceRounded:function(d,f,c,e){return Math.round(Phaser.Math.distance(d,f,c,e))},clamp:function(d,e,c){return(dc)?c:d)},clampBottom:function(c,d){return c=c){return 1}d=(d-e)/(c-e);return d*d*(3-2*d)},smootherstep:function(d,e,c){if(d<=e){return 0}if(d>=c){return 1}d=(d-e)/(c-e);return d*d*d*(d*(d*6-15)+10)},sign:function(c){return(c<0)?-1:((c>0)?1:0)},degToRad:function(){var c=Math.PI/180;return function(d){return d*c}}(),radToDeg:function(){var c=180/Math.PI;return function(d){return d*c}}()};Phaser.QuadTree=function(i,d,k,h,c,f,e,j){this.physicsManager=i;this.ID=i.quadTreeID;i.quadTreeID++;this.maxObjects=f||10;this.maxLevels=e||4;this.level=j||0;this.bounds={x:Math.round(d),y:Math.round(k),width:h,height:c,subWidth:Math.floor(h/2),subHeight:Math.floor(c/2),right:Math.round(d)+Math.floor(h/2),bottom:Math.round(k)+Math.floor(c/2)};this.objects=[];this.nodes=[]};Phaser.QuadTree.prototype={split:function(){this.level++;this.nodes[0]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[1]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[2]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[3]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(c){var e=0;var d;if(this.nodes[0]!=null){d=this.getIndex(c);if(d!==-1){this.nodes[d].insert(c);return}}this.objects.push(c);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom)){c=2}}}else{if(d.x>this.bounds.right){if((d.ythis.bounds.bottom)){c=3}}}}return c},retrieve:function(c){var d=this.objects;c.body.quadTreeIndex=this.getIndex(c.body);c.body.quadTreeIDs.push(this.ID);if(this.nodes[0]){if(c.body.quadTreeIndex!==-1){d=d.concat(this.nodes[c.body.quadTreeIndex].retrieve(c))}else{d=d.concat(this.nodes[0].retrieve(c));d=d.concat(this.nodes[1].retrieve(c));d=d.concat(this.nodes[2].retrieve(c));d=d.concat(this.nodes[3].retrieve(c))}}return d},clear:function(){this.objects=[];for(var d=0,c=this.nodes.length;d0){this._diameter=c;this._radius=c*0.5}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Circle.prototype,"radius",{get:function(){return this._radius},set:function(c){if(c>0){this._radius=c;this._diameter=c*2}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(c){if(c>this.x){this._radius=0;this._diameter=0}else{this.radius=this.x-c}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(c){if(cthis.y){this._radius=0;this._diameter=0}else{this.radius=this.y-c}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(c){if(c0){return Math.PI*this._radius*this._radius}else{return 0}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Circle.prototype,"empty",{get:function(){return(this._diameter==0)},set:function(c){this.setTo(0,0,0)},enumerable:true,configurable:true});Phaser.Circle.contains=function(e,c,h){if(c>=e.left&&c<=e.right&&h>=e.top&&h<=e.bottom){var f=(e.x-c)*(e.x-c);var d=(e.y-h)*(e.y-h);return(f+d)<=(e.radius*e.radius)}return false};Phaser.Circle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.diameter==c.diameter)};Phaser.Circle.intersects=function(d,c){return(Phaser.Math.distance(d.x,d.y,c.x,c.y)<=(d.radius+c.radius))};Phaser.Circle.circumferencePoint=function(c,f,e,d){if(typeof e==="undefined"){e=false}if(typeof d==="undefined"){d=new Phaser.Point()}if(e===true){f=Phaser.Math.radToDeg(f)}d.x=c.x+c.radius*Math.cos(f);d.y=c.y+c.radius*Math.sin(f);return d};Phaser.Circle.intersectsRectangle=function(o,e){var i=Math.abs(o.x-e.x-e.halfWidth);var n=e.halfWidth+o.radius;if(i>n){return false}var h=Math.abs(o.y-e.y-e.halfHeight);var l=e.halfHeight+o.radius;if(h>l){return false}if(i<=e.halfWidth||h<=e.halfHeight){return true}var j=i-e.halfWidth;var f=h-e.halfHeight;var m=j*j;var d=f*f;var k=o.radius*o.radius;return m+d<=k};Phaser.Point=function(c,d){if(typeof c==="undefined"){c=0}if(typeof d==="undefined"){d=0}this.x=c;this.y=d};Phaser.Point.prototype={copyFrom:function(c){return this.setTo(c.x,c.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(c,d){this.x=c;this.y=d;return this},add:function(c,d){this.x+=c;this.y+=d;return this},subtract:function(c,d){this.x-=c;this.y-=d;return this},multiply:function(c,d){this.x*=c;this.y*=d;return this},divide:function(c,d){this.x/=c;this.y/=d;return this},clampX:function(d,c){this.x=Phaser.Math.clamp(this.x,d,c);return this},clampY:function(d,c){this.y=Phaser.Math.clamp(this.y,d,c);return this},clamp:function(d,c){this.x=Phaser.Math.clamp(this.x,d,c);this.y=Phaser.Math.clamp(this.y,d,c);return this},clone:function(c){if(typeof c==="undefined"){c=new Phaser.Point}return c.setTo(this.x,this.y)},copyFrom:function(c){return this.setTo(c.x,c.y)},copyTo:function(c){c[x]=this.x;c[y]=this.y;return c},distance:function(d,c){return Phaser.Point.distance(this,d,c)},equals:function(c){return(c.x==this.x&&c.y==this.y)},rotate:function(c,h,e,d,f){return Phaser.Point.rotate(this,c,h,e,d,f)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};Phaser.Point.add=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x+c.x;e.y=d.y+c.y;return e};Phaser.Point.subtract=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x-c.x;e.y=d.y-c.y;return e};Phaser.Point.multiply=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x*c.x;e.y=d.y*c.y;return e};Phaser.Point.divide=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x/c.x;e.y=d.y/c.y;return e};Phaser.Point.equals=function(d,c){return(d.x==c.x&&d.y==c.y)};Phaser.Point.distance=function(d,c,e){if(typeof e==="undefined"){e=false}if(e){return Phaser.Math.distanceRound(d.x,d.y,c.x,c.y)}else{return Phaser.Math.distance(d.x,d.y,c.x,c.y)}},Phaser.Point.rotate=function(d,c,i,f,e,h){e=e||false;h=h||null;if(e){f=Phaser.Math.radToDeg(f)}if(h===null){h=Math.sqrt(((c-d.x)*(c-d.x))+((i-d.y)*(i-d.y)))}return d.setTo(c+h*Math.cos(f),i+h*Math.sin(f))};Phaser.Rectangle=function(d,f,e,c){d=d||0;f=f||0;e=e||0;c=c||0;this.x=d;this.y=f;this.width=e;this.height=c};Phaser.Rectangle.prototype={x:0,y:0,width:0,height:0,offset:function(d,c){this.x+=d;this.y+=c;return this},offsetPoint:function(c){return this.offset(c.x,c.y)},setTo:function(d,f,e,c){this.x=d;this.y=f;this.width=e;this.height=c;return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},copyFrom:function(c){return this.setTo(c.x,c.y,c.width,c.height)},copyTo:function(c){c.x=this.x;c.y=this.y;c.width=this.width;c.height=this.height;return c},inflate:function(d,c){return Phaser.Rectangle.inflate(this,d,c)},size:function(c){return Phaser.Rectangle.size(this,c)},clone:function(c){return Phaser.Rectangle.clone(this,c)},contains:function(c,d){return Phaser.Rectangle.contains(this,c,d)},containsRect:function(c){return Phaser.Rectangle.containsRect(this,c)},equals:function(c){return Phaser.Rectangle.equals(this,c)},intersection:function(c,d){return Phaser.Rectangle.intersection(this,c,output)},intersects:function(c,d){return Phaser.Rectangle.intersects(this,c,d)},intersectsRaw:function(h,e,f,d,c){return Phaser.Rectangle.intersectsRaw(this,h,e,f,d,c)},union:function(c,d){return Phaser.Rectangle.union(this,c,d)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(Phaser.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(c){if(c<=this.y){this.height=0}else{this.height=(this.y-c)}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"bottomRight",{get:function(){return new Phaser.Point(this.right,this.bottom)},set:function(c){this.right=c.x;this.bottom=c.y},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"left",{get:function(){return this.x},set:function(c){if(c>=this.right){this.width=0}else{this.width=this.right-c}this.x=c},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(c){if(c<=this.x){this.width=0}else{this.width=this.x+c}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"volume",{get:function(){return this.width*this.height},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"perimeter",{get:function(){return(this.width*2)+(this.height*2)},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(c){this.x=c-this.halfWidth},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(c){this.y=c-this.halfHeight},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"top",{get:function(){return this.y},set:function(c){if(c>=this.bottom){this.height=0;this.y=c}else{this.height=(this.bottom-c)}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"topLeft",{get:function(){return new Phaser.Point(this.x,this.y)},set:function(c){this.x=c.x;this.y=c.y},enumerable:true,configurable:true});Object.defineProperty(Phaser.Rectangle.prototype,"empty",{get:function(){return(!this.width||!this.height)},set:function(c){this.setTo(0,0,0,0)},enumerable:true,configurable:true});Phaser.Rectangle.inflate=function(d,e,c){d.x-=e;d.width+=2*e;d.y-=c;d.height+=2*c;return d};Phaser.Rectangle.inflatePoint=function(d,c){return Phaser.Phaser.Rectangle.inflate(d,c.x,c.y)};Phaser.Rectangle.size=function(c,d){if(typeof d==="undefined"){d=new Phaser.Point()}return d.setTo(c.width,c.height)};Phaser.Rectangle.clone=function(c,d){if(typeof d==="undefined"){d=new Phaser.Rectangle()}return d.setTo(c.x,c.y,c.width,c.height)};Phaser.Rectangle.contains=function(d,c,e){return(c>=d.x&&c<=d.right&&e>=d.y&&e<=d.bottom)};Phaser.Rectangle.containsPoint=function(d,c){return Phaser.Phaser.Rectangle.contains(d,c.x,c.y)};Phaser.Rectangle.containsRect=function(d,c){if(d.volume>c.volume){return false}return(d.x>=c.x&&d.y>=c.y&&d.right<=c.right&&d.bottom<=c.bottom)};Phaser.Rectangle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.width==c.width&&d.height==c.height)};Phaser.Rectangle.intersection=function(d,c,e){e=e||new Phaser.Rectangle;if(Phaser.Rectangle.intersects(d,c)){e.x=Math.max(d.x,c.x);e.y=Math.max(d.y,c.y);e.width=Math.min(d.right,c.right)-e.x;e.height=Math.min(d.bottom,c.bottom)-e.y}return e};Phaser.Rectangle.intersects=function(d,c,e){e=e||0;return !(d.left>c.right+e||d.rightc.bottom+e||d.bottomc.right+d||fc.bottom+d||e1){if(h&&h==this.decodeURI(e[0])){return this.decodeURI(e[1])}else{d[this.decodeURI(e[0])]=this.decodeURI(e[1])}}}return d},decodeURI:function(c){return decodeURIComponent(c.replace(/\+/g," "))}};Phaser.TweenManager=function(c){this.game=c;this._tweens=[]};Phaser.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(c){this._tweens.push(c)},create:function(c,d){if(typeof d==="undefined"){d=false}if(d){c.tween=new Phaser.Tween(c,this.game);return c.tween}else{return new Phaser.Tween(c,this.game)}},remove:function(d){var c=this._tweens.indexOf(d);if(c!==-1){this._tweens.splice(c,1)}},update:function(){if(this._tweens.length===0){return false}var c=0,d=this._tweens.length;while(c=0;c--){this._tweens[c].pause()}},resumeAll:function(){for(var c=this._tweens.length-1;c>=0;c--){this._tweens[c].resume()}}};Phaser.Tween=function(d,c){this._object=d;this.game=c;this._manager=this.game.tweens;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1000;this._repeat=0;this._yoyo=false;this._reversed=false;this._delayTime=0;this._startTime=null;this._easingFunction=Phaser.Easing.Linear.None;this._interpolationFunction=Phaser.Math.linearInterpolation;this._chainedTweens=[];this._onStartCallback=null;this._onStartCallbackFired=false;this._onUpdateCallback=null;this._onCompleteCallback=null;this._pausedTime=0;for(var e in d){this._valuesStart[e]=parseFloat(d[e],10)}this.onStart=new Phaser.Signal();this.onComplete=new Phaser.Signal();this.isRunning=false};Phaser.Tween.prototype={to:function(e,i,j,d,c,h,f){i=i||1000;j=j||null;d=d||false;c=c||0;h=h||0;f=f||false;this._repeat=h;this._duration=i;this._valuesEnd=e;if(j!==null){this._easingFunction=j}if(c>0){this._delayTime=c}this._yoyo=f;if(d){return this.start()}else{return this}},start:function(d){if(this.game===null||this._object===null){return}this._manager.add(this);this.onStart.dispatch(this._object);this.isRunning=true;this._onStartCallbackFired=false;this._startTime=this.game.time.now+this._delayTime;for(var c in this._valuesEnd){if(this._valuesEnd[c] instanceof Array){if(this._valuesEnd[c].length===0){continue}this._valuesEnd[c]=[this._object[c]].concat(this._valuesEnd[c])}this._valuesStart[c]=this._object[c];if((this._valuesStart[c] instanceof Array)===false){this._valuesStart[c]*=1}this._valuesStartRepeat[c]=this._valuesStart[c]||0}return this},stop:function(){this._manager.remove(this);this.isRunning=false;return this},delay:function(c){this._delayTime=c;return this},repeat:function(c){this._repeat=c;return this},yoyo:function(c){this._yoyo=c;return this},easing:function(c){this._easingFunction=c;return this},interpolation:function(c){this._interpolationFunction=c;return this},chain:function(){this._chainedTweens=arguments;return this},onStart:function(c){this._onStartCallback=c;return this},onUpdate:function(c){this._onUpdateCallback=c;return this},onComplete:function(c){this._onCompleteCallback=c;return this},pause:function(){this._paused=true},resume:function(){this._paused=false;this._startTime+=this.game.time.pauseDuration},update:function(d){if(this._paused||d1?1:m;var k=this._easingFunction(m);for(l in this._valuesEnd){var c=this._valuesStart[l]||0;var e=this._valuesEnd[l];if(e instanceof Array){this._object[l]=this._interpolationFunction(e,k)}else{if(typeof(e)==="string"){e=c+parseFloat(e,10)}if(typeof(e)==="number"){this._object[l]=c+(e-c)*k}}}if(this._onUpdateCallback!==null){this._onUpdateCallback.call(this._object,k)}if(m==1){if(this._repeat>0){if(isFinite(this._repeat)){this._repeat--}for(l in this._valuesStartRepeat){if(typeof(this._valuesEnd[l])==="string"){this._valuesStartRepeat[l]=this._valuesStartRepeat[l]+parseFloat(this._valuesEnd[l],10)}if(this._yoyo){var f=this._valuesStartRepeat[l];this._valuesStartRepeat[l]=this._valuesEnd[l];this._valuesEnd[l]=f;this._reversed=!this._reversed}this._valuesStart[l]=this._valuesStartRepeat[l]}this._startTime=d+this._delayTime;this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}return true}else{this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}for(var h=0,j=this._chainedTweens.length;hthis._timeLastSecond+1000){this.fps=Math.round((this.frames*1000)/(this.now-this._timeLastSecond));this.fpsMin=Math.min(this.fpsMin,this.fps);this.fpsMax=Math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0}this.time=this.now;this.lastTime=c+this.timeToCall;this.physicsElapsed=1*(this.elapsed/1000);if(this.game.paused){this.pausedTime=this.now-this._pauseStarted}},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.elapsed=0;this.physicsElapsed=0;this.time=Date.now();this.pauseDuration=this.pausedTime},elapsedSince:function(c){return this.now-c},elapsedSecondsSince:function(c){return(this.now-c)*0.001},reset:function(){this._started=this.now}};Phaser.AnimationManager=function(c){this._frameData=null;this.currentFrame=null;this._parent=c;this.game=c.game;this._anims={}};Phaser.AnimationManager.prototype={updateIfVisible:true,loadFrameData:function(c){this._frameData=c;this.frame=0},add:function(f,h,e,d,c){h=h||null;e=e||60;d=d||false;c=c||true;if(this._frameData==null){console.warn("No frameData available for Phaser.Animation "+f);return}if(h==null){h=this._frameData.getFrameIndexes()}else{if(this.validateFrames(h,c)==false){console.warn("Invalid frames given to Phaser.Animation "+f);return}}if(c==false){h=this._frameData.getFrameIndexesByName(h)}this._anims[f]=new Phaser.Animation(this.game,this._parent,this._frameData,f,h,e,d);this.currentAnim=this._anims[f];this.currentFrame=this.currentAnim.currentFrame;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this._anims[f]},validateFrames:function(e,c){for(var d=0;dthis._frameData.total){return false}}else{if(this._frameData.checkFrameName(e[d])==false){return false}}}return true},play:function(e,d,c){d=d||null;c=c||null;if(this._anims[e]){if(this.currentAnim==this._anims[e]){if(this.currentAnim.isPlaying==false){return this.currentAnim.play(d,c)}}else{this.currentAnim=this._anims[e];return this.currentAnim.play(d,c)}}},stop:function(c){if(this._anims[c]){this.currentAnim=this._anims[c];this.currentAnim.stop()}},update:function(){if(this.updateIfVisible&&this._parent.visible==false){return false}if(this.currentAnim&&this.currentAnim.update()==true){this.currentFrame=this.currentAnim.currentFrame;this._parent.currentFrame=this.currentFrame;return true}return false},destroy:function(){this._anims={};this._frameData=null;this._frameIndex=0;this.currentAnim=null;this.currentFrame=null}};Object.defineProperty(Phaser.AnimationManager.prototype,"frameData",{get:function(){return this._frameData},enumerable:true,configurable:true});Object.defineProperty(Phaser.AnimationManager.prototype,"frameTotal",{get:function(){if(this._frameData){return this._frameData.total}else{return -1}},enumerable:true,configurable:true});Object.defineProperty(Phaser.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame){return this._frameIndex}},set:function(c){if(this._frameData&&this._frameData.getFrame(c)!==null){this.currentFrame=this._frameData.getFrame(c);this._frameIndex=c;this._parent.currentFrame=this.currentFrame;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}},enumerable:true,configurable:true});Object.defineProperty(Phaser.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame){return this.currentFrame.name}},set:function(c){if(this._frameData&&this._frameData.getFrameByName(c)){this.currentFrame=this._frameData.getFrameByName(c);this._frameIndex=this.currentFrame.index;this._parent.currentFrame=this.currentFrame;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{console.warn("Cannot set frameName: "+c)}},enumerable:true,configurable:true});Phaser.Animation=function(d,i,h,f,j,e,c){this.game=d;this._parent=i;this._frames=j;this._frameData=h;this.name=f;this.delay=1000/e;this.looped=c;this.isFinished=false;this.isPlaying=false;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])};Phaser.Animation.prototype={play:function(d,c){d=d||null;c=c||null;if(d!==null){this.delay=1000/d}if(c!==null){this.looped=c}this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this},restart:function(){this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(){this.isPlaying=false;this.isFinished=true},update:function(){if(this.isPlaying==true&&this.game.time.now>=this._timeNextFrame){this._frameIndex++;if(this._frameIndex==this._frames.length){if(this.looped){this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{this.onComplete()}}else{this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;return true}return false},destroy:function(){this.game=null;this._parent=null;this._frames=null;this._frameData=null;this.currentFrame=null;this.isPlaying=false},onComplete:function(){this.isPlaying=false;this.isFinished=true}};Object.defineProperty(Phaser.Animation.prototype,"frameTotal",{get:function(){return this._frames.length},enumerable:true,configurable:true});Object.defineProperty(Phaser.Animation.prototype,"frame",{get:function(){if(this.currentFrame!==null){return this.currentFrame.index}else{return this._frameIndex}},set:function(c){this.currentFrame=this._frameData.getFrame(c);if(this.currentFrame!==null){this._frameIndex=c;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}},enumerable:true,configurable:true});Phaser.Animation.Frame=function(d,i,h,c,e,f){this.x=d;this.y=i;this.width=h;this.height=c;this.sourceSizeW=h;this.sourceSizeH=c;this.centerX=Math.floor(h/2);this.centerY=Math.floor(c/2);this.name=e;this.uuid=f;this.distance=Phaser.Math.distance(0,0,h,c)};Phaser.Animation.Frame.prototype={uuid:"",x:0,y:0,width:0,height:0,centerX:0,centerY:0,distance:0,index:0,name:"",rotated:false,rotationDirection:"cw",trimmed:false,sourceSizeW:0,sourceSizeH:0,spriteSourceSizeX:0,spriteSourceSizeY:0,spriteSourceSizeW:0,spriteSourceSizeH:0,setTrim:function(h,f,j,d,c,e,i){this.trimmed=h;if(h){this.width=f;this.height=j;this.sourceSizeW=f;this.sourceSizeH=j;this.centerX=Math.floor(f/2);this.centerY=Math.floor(j/2);this.spriteSourceSizeX=d;this.spriteSourceSizeY=c;this.spriteSourceSizeW=e;this.spriteSourceSizeH=i}}};Phaser.Animation.FrameData=function(){};Phaser.Animation.FrameData.prototype={_frames:[],_frameNames:[],addFrame:function(c){c.index=this._frames.length;this._frames.push(c);if(c.name!==""){this._frameNames[c.name]=c.index}return c},getFrame:function(c){if(this._frames[c]){return this._frames[c]}return null},getFrameByName:function(c){if(this._frameNames[c]!==""){return this._frames[this._frameNames[c]]}return null},checkFrameName:function(c){if(this._frameNames[c]==null){return false}return true},getFrameRange:function(f,c,d){if(typeof d==="undefined"){d=[]}for(var e=f;e<=c;e++){d.push(this._frames[e])}return d},getFrameIndexes:function(c){if(typeof c==="undefined"){c=[]}for(var d=0;d tag")}var e=new Phaser.Animation.FrameData();var l=j.getElementsByTagName("SubTexture");var h;for(var f=0;f0){this._progressChunk=100/this._keys.length;this.loadFile()}else{this.progress=100;this.hasLoaded=true;this.onLoadComplete.dispatch()}},loadFile:function(){var c=this._fileList[this._keys.shift()];var d=this;switch(c.type){case"image":case"spritesheet":case"textureatlas":c.data=new Image();c.data.name=c.key;c.data.onload=function(){return d.fileComplete(c.key)};c.data.onerror=function(){return d.fileError(c.key)};c.data.crossOrigin=this.crossOrigin;c.data.src=this.baseURL+c.url;break;case"audio":c.url=this.getAudioURL(c.url);if(c.url!==null){if(this.game.sound.usingWebAudio){this._xhr.open("GET",this.baseURL+c.url,true);this._xhr.responseType="arraybuffer";this._xhr.onload=function(){return d.fileComplete(c.key)};this._xhr.onerror=function(){return d.fileError(c.key)};this._xhr.send()}else{if(this.game.sound.usingAudioTag){if(this.game.sound.touchLocked){c.data=new Audio();c.data.name=c.key;c.data.preload="auto";c.data.src=this.baseURL+c.url;this.fileComplete(c.key)}else{c.data=new Audio();c.data.name=c.key;c.data.onerror=function(){return d.fileError(c.key)};c.data.preload="auto";c.data.src=this.baseURL+c.url;c.data.addEventListener("canplaythrough",Phaser.GAMES[this.game.id].load.fileComplete(c.key),false);c.data.load()}}}}break;case"text":this._xhr.open("GET",this.baseURL+c.url,true);this._xhr.responseType="text";this._xhr.onload=function(){return d.fileComplete(c.key)};this._xhr.onerror=function(){return d.fileError(c.key)};this._xhr.send();break}},getAudioURL:function(d){var e;for(var c=0;c100){this.progress=100}this.onFileComplete.dispatch(this.progress,c,d,this.queueSize-this._keys.length,this.queueSize);if(this._keys.length>0){this.loadFile()}else{this.hasLoaded=true;this.isLoading=false;this.removeAll();this.onLoadComplete.dispatch()}}};Phaser.Sound=function(d,e,f,c){f=f||1;c=c||false;this.game=d;this.key=e;this._volume=f;this.loop=c;this.usingWebAudio=this.game.sound.usingWebAudio;this.usingAudioTag=this.game.sound.usingAudioTag;if(this.usingWebAudio){this.context=this.game.sound.context;this.masterGainNode=this.game.sound.masterGain;if(typeof this.context.createGain==="undefined"){this.gainNode=this.context.createGainNode()}else{this.gainNode=this.context.createGain()}this.gainNode.gain.value=f*this.game.sound.volume;this.gainNode.connect(this.masterGainNode)}else{if(this.game.cache.getSound(e)&&this.game.cache.getSound(e).locked==false){this._sound=this.game.cache.getSoundData(e);this.totalDuration=this._sound.duration}else{this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)}}this.onDecoded=new Phaser.Signal;this.onPlay=new Phaser.Signal;this.onPause=new Phaser.Signal;this.onResume=new Phaser.Signal;this.onLoop=new Phaser.Signal;this.onStop=new Phaser.Signal;this.onMute=new Phaser.Signal;this.onMarkerComplete=new Phaser.Signal};Phaser.Sound.prototype={game:null,context:null,_buffer:null,_muted:false,key:"",name:"",markers:{},usingWebAudio:false,usingAudioTag:false,autoplay:false,totalDuration:0,startTime:0,currentTime:0,duration:0,stopTime:0,paused:false,loop:false,isPlaying:false,currentMarker:"",pendingPlayback:false,override:false,onDecoded:null,onPlay:null,onPause:null,onResume:null,onLoop:null,onStop:null,onMute:null,onMarkerComplete:null,soundHasUnlocked:function(c){if(c==this.key){this._sound=this.game.cache.getSoundData(this.key);this.totalDuration=this._sound.duration;console.log("sound has unlocked",this._sound)}},addMarker:function(d,h,e,f,c){f=f||1;c=c||false;this.markers[d]={name:d,start:h,stop:e,volume:f,duration:e-h,loop:c}},removeMarker:function(c){delete this.markers[c]},update:function(){if(this.pendingPlayback&&this.game.cache.isSoundReady(this.key)){this.pendingPlayback=false;this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)}if(this.isPlaying){this.currentTime=this.game.time.now-this.startTime;if(this.currentTime>=this.duration){if(this.usingWebAudio){if(this.loop){this.onLoop.dispatch(this);if(this.currentMarker==""){this.currentTime=0;this.startTime=this.game.time.now}else{this.play(this.currentMarker,0,this.volume,true,true)}}else{this.stop()}}else{if(this.loop){this.onLoop.dispatch(this);this.play(this.currentMarker,0,this.volume,true,true)}else{this.stop()}}}}},play:function(e,c,h,d,f){e=e||"";c=c||0;h=h||1;d=d||false;f=f||false;console.log("play",e,"current is",this.currentMarker);if(this.isPlaying==true&&f==false&&this.override==false){return}if(this.isPlaying&&this.override){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.currentMarker=e;if(e!==""&&this.markers[e]){this.position=this.markers[e].start;this.volume=this.markers[e].volume;this.loop=this.markers[e].loop;this.duration=this.markers[e].duration*1000;this._tempMarker=e;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else{this.position=c;this.volume=h;this.loop=d;this.duration=0;this._tempMarker=e;this._tempPosition=c;this._tempVolume=h;this._tempLoop=d}if(this.usingWebAudio){if(this.game.cache.isSoundDecoded(this.key)){if(this._buffer==null){this._buffer=this.game.cache.getSoundData(this.key)}this._sound=this.context.createBufferSource();this._sound.buffer=this._buffer;this._sound.connect(this.gainNode);this.totalDuration=this._sound.buffer.duration;if(this.duration==0){this.duration=this.totalDuration*1000}if(this.loop&&e==""){this._sound.loop=true}if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration/1000)}else{this._sound.start(0,this.position,this.duration/1000)}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true;if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).isDecoding==false){this.game.sound.decode(this.key,this)}}}else{if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked){this.game.cache.reloadSound(this.key);this.pendingPlayback=true}else{if(this._sound&&this._sound.readyState==4){if(this.duration==0){this.duration=this.totalDuration*1000}this._sound.currentTime=this.position;this._sound.muted=this._muted;if(this._muted){this._sound.volume=0}else{this._sound.volume=this._volume}this._sound.play();this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true}}}},restart:function(e,c,f,d){e=e||"";c=c||0;f=f||1;d=d||false;this.play(e,c,f,d,true)},pause:function(){if(this.isPlaying&&this._sound){this.stop();this.isPlaying=false;this.paused=true;this.onPause.dispatch(this)}},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration)}else{this._sound.start(0,this.position,this.duration)}}else{this._sound.play()}this.isPlaying=true;this.paused=false;this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.isPlaying=false;var c=this.currentMarker;this.currentMarker="";this.onStop.dispatch(this,c)}};Object.defineProperty(Phaser.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding},enumerable:true,configurable:true});Object.defineProperty(Phaser.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)},enumerable:true,configurable:true});Object.defineProperty(Phaser.Sound.prototype,"mute",{get:function(){return this._muted},set:function(c){c=c||null;if(c){this._muted=true;if(this.usingWebAudio){this._muteVolume=this.gainNode.gain.value;this.gainNode.gain.value=0}else{if(this.usingAudioTag&&this._sound){this._muteVolume=this._sound.volume;this._sound.volume=0}}}else{this._muted=false;if(this.usingWebAudio){this.gainNode.gain.value=this._muteVolume}else{if(this.usingAudioTag&&this._sound){this._sound.volume=this._muteVolume}}}this.onMute.dispatch(this)},enumerable:true,configurable:true});Object.defineProperty(Phaser.Sound.prototype,"volume",{get:function(){return this._volume},set:function(c){this._volume=c;if(this.usingWebAudio){this.gainNode.gain.value=c}else{if(this.usingAudioTag&&this._sound){this._sound.volume=c}}},enumerable:true,configurable:true});Phaser.SoundManager=function(c){this.game=c;this.onSoundDecode=new Phaser.Signal;if(this.game.device.iOS&&this.game.device.webAudio==false){this.channels=1}if(c.device.iOS||(window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)){this.game.input.touch.callbackContext=this;this.game.input.touch.touchStartCallback=this.unlock;this.game.input.mouse.callbackContext=this;this.game.input.mouse.mouseDownCallback=this.unlock;this.touchLocked=true}else{this.touchLocked=false}if(window.PhaserGlobal){if(window.PhaserGlobal.disableAudio==true){this.usingWebAudio=false;this.noAudio=true;return}if(window.PhaserGlobal.disableWebAudio==true){this.usingWebAudio=false;this.usingAudioTag=true;this.noAudio=false;return}}if(!!window.AudioContext){this.context=new window.AudioContext()}else{if(!!window.webkitAudioContext){this.context=new window.webkitAudioContext()}else{if(!!window.Audio){this.usingWebAudio=false;this.usingAudioTag=true}else{this.usingWebAudio=false;this.noAudio=true}}}if(this.context!==null){if(typeof this.context.createGain==="undefined"){this.masterGain=this.context.createGainNode()}else{this.masterGain=this.context.createGain()}this.masterGain.gain.value=1;this.masterGain.connect(this.context.destination)}};Phaser.SoundManager.prototype={game:null,_muted:false,_unlockSource:null,_volume:1,_muted:false,_sounds:[],context:null,usingWebAudio:true,usingAudioTag:false,noAudio:false,touchLocked:false,onSoundDecode:null,channels:32,unlock:function(){if(this.touchLocked==false){return}console.log("SoundManager touch unlocked");if(this.game.device.webAudio&&(window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio==false)){var c=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=c;this._unlockSource.connect(this.context.destination);this._unlockSource.noteOn(0)}else{this.touchLocked=false;this._unlockSource=null;this.game.input.touch.callbackContext=null;this.game.input.touch.touchStartCallback=null;this.game.input.mouse.callbackContext=null;this.game.input.mouse.mouseDownCallback=null}},stopAll:function(){for(var c=0;c0){i=i-this._drag}else{if(i+this._drag<0){i+=this._drag}else{i=0}}}}if(i!=0){if(i>c){i=c}else{if(i<-c){i=-c}}}return i},preUpdate:function(){this.quadTree.clear();this.quadTreeID=0;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},collide:function(d,e,c){return this.overlap(d,null,e,this.separate,c)},collideGroup:function(k,h,e){h=h||null;e=e||h;for(var j=0,c=k.length;j0)?d.deltaX():0),d.lastY,d.width+((d.deltaX()>0)?d.deltaX():-d.deltaX()),d.height);this._obj2Bounds.setTo(c.x-((c.deltaX()>0)?c.deltaX():0),c.lastY,c.width+((c.deltaX()>0)?c.deltaX():-c.deltaX()),c.height);if((this._obj1Bounds.right>this._obj2Bounds.x)&&(this._obj1Bounds.xthis._obj2Bounds.y)&&(this._obj1Bounds.yc.deltaX()){this._overlap=d.x+d.width-c.x;if((this._overlap>this._maxOverlap)||d.allowCollision.right==false||c.allowCollision.left==false){this._overlap=0}else{d.touching.right=true;c.touching.left=true}}else{if(d.deltaX()this._maxOverlap)||d.allowCollision.left==false||c.allowCollision.right==false){this._overlap=0}else{d.touching.left=true;c.touching.right=true}}}}}if(this._overlap!=0){this._obj1Velocity=d.velocity.x;this._obj2Velocity=c.velocity.x;if(!d.immovable&&!c.immovable){this._overlap*=0.5;d.x=d.x-this._overlap;c.x+=this._overlap;this._obj1NewVelocity=Math.sqrt((this._obj2Velocity*this._obj2Velocity*c.mass)/d.mass)*((this._obj2Velocity>0)?1:-1);this._obj2NewVelocity=Math.sqrt((this._obj1Velocity*this._obj1Velocity*d.mass)/c.mass)*((this._obj1Velocity>0)?1:-1);this._average=(this._obj1NewVelocity+this._obj2NewVelocity)*0.5;this._obj1NewVelocity-=this._average;this._obj2NewVelocity-=this._average;d.velocity.x=this._average+this._obj1NewVelocity*d.bounce.x;c.velocity.x=this._average+this._obj2NewVelocity*c.bounce.x}else{if(!d.immovable){d.x=d.x-this._overlap;d.velocity.x=this._obj2Velocity-this._obj1Velocity*d.bounce.x}else{if(!c.immovable){c.x+=this._overlap;c.velocity.x=this._obj1Velocity-this._obj2Velocity*c.bounce.x}}}return true}else{return false}},separateY:function(d,c){if(d.immovable&&c.immovable){return false}this._overlap=0;if(d.deltaY()!=c.deltaY()){this._obj1Bounds.setTo(d.x,d.y-((d.deltaY()>0)?d.deltaY():0),d.width,d.height+d.deltaAbsY());this._obj2Bounds.setTo(c.x,c.y-((c.deltaY()>0)?c.deltaY():0),c.width,c.height+c.deltaAbsY());if((this._obj1Bounds.right>this._obj2Bounds.x)&&(this._obj1Bounds.xthis._obj2Bounds.y)&&(this._obj1Bounds.yc.deltaY()){this._overlap=d.y+d.height-c.y;if((this._overlap>this._maxOverlap)||d.allowCollision.down==false||c.allowCollision.up==false){this._overlap=0}else{d.touching.down=true;c.touching.up=true}}else{if(d.deltaY()this._maxOverlap)||d.allowCollision.up==false||c.allowCollision.down==false){this._overlap=0}else{d.touching.up=true;c.touching.down=true}}}}}if(this._overlap!=0){this._obj1Velocity=d.velocity.y;this._obj2Velocity=c.velocity.y;if(!d.immovable&&!c.immovable){this._overlap*=0.5;d.y=d.y-this._overlap;c.y+=this._overlap;this._obj1NewVelocity=Math.sqrt((this._obj2Velocity*this._obj2Velocity*c.mass)/d.mass)*((this._obj2Velocity>0)?1:-1);this._obj2NewVelocity=Math.sqrt((this._obj1Velocity*this._obj1Velocity*d.mass)/c.mass)*((this._obj1Velocity>0)?1:-1);this._average=(this._obj1NewVelocity+this._obj2NewVelocity)*0.5;this._obj1NewVelocity-=this._average;this._obj2NewVelocity-=this._average;d.velocity.y=this._average+this._obj1NewVelocity*d.bounce.y;c.velocity.y=this._average+this._obj2NewVelocity*c.bounce.y}else{if(!d.immovable){d.y=d.y-this._overlap;d.velocity.y=this._obj2Velocity-this._obj1Velocity*d.bounce.y;if(c.active&&c.moves&&(d.deltaY()>c.deltaY())){d.x+=c.x-c.lastX}}else{if(!c.immovable){c.y+=this._overlap;c.velocity.y=this._obj1Velocity-this._obj2Velocity*c.bounce.y;if(d.sprite.active&&d.moves&&(d.deltaY()0){var j=this.distanceBetween(i,f);h=j/(e/1000)}i.body.velocity.x=Math.cos(c)*h;i.body.velocity.y=Math.sin(c)*h},accelerateTowardsObject:function(h,e,f,c,i){c=c||1000;i=i||1000;var d=this.angleBetween(h,e);h.body.velocity.x=0;h.body.velocity.y=0;h.body.acceleration.x=Math.cos(d)*f;h.body.acceleration.y=Math.sin(d)*f;h.body.maxVelocity.x=c;h.body.maxVelocity.y=i},moveTowardsMouse:function(h,f,e){f=f||60;e=e||0;var c=this.angleBetweenMouse(h);if(e>0){var i=this.distanceToMouse(h);f=i/(e/1000)}h.body.velocity.x=Math.cos(c)*f;h.body.velocity.y=Math.sin(c)*f},accelerateTowardsMouse:function(f,e,c,h){c=c||1000;h=h||1000;var d=this.angleBetweenMouse(f);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(d)*e;f.body.acceleration.y=Math.sin(d)*e;f.body.maxVelocity.x=c;f.body.maxVelocity.y=h},moveTowardsPoint:function(h,i,f,e){f=f||60;e=e||0;var c=this.angleBetweenPoint(h,i);if(e>0){var j=this.distanceToPoint(h,i);f=j/(e/1000)}h.body.velocity.x=Math.cos(c)*f;h.body.velocity.y=Math.sin(c)*f},accelerateTowardsPoint:function(f,h,e,c,i){c=c||1000;i=i||1000;var d=this.angleBetweenPoint(f,h);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(d)*e;f.body.acceleration.y=Math.sin(d)*e;f.body.maxVelocity.x=c;f.body.maxVelocity.y=i},distanceBetween:function(e,c){var f=e.center.x-c.center.x;var d=e.center.y-c.center.y;return Math.sqrt(f*f+d*d)},distanceToPoint:function(d,f){var e=d.center.x-f.x;var c=d.center.y-f.y;return Math.sqrt(e*e+c*c)},distanceToMouse:function(d){var e=d.center.x-this.game.input.x;var c=d.center.y-this.game.input.y;return Math.sqrt(e*e+c*c)},angleBetweenPoint:function(d,h,f){f=f||false;var e=h.x-d.center.x;var c=h.y-d.center.y;if(f){return this.game.math.radToDeg(Math.atan2(c,e))}else{return Math.atan2(c,e)}},angleBetween:function(e,c,h){h=h||false;var f=c.center.x-e.center.x;var d=c.center.y-e.center.y;if(h){return this.game.math.radToDeg(Math.atan2(d,f))}else{return Math.atan2(d,f)}},velocityFromFacing:function(c,d){},angleBetweenMouse:function(d,f){f=f||false;var e=this.game.input.x-d.bounds.x;var c=this.game.input.y-d.bounds.y;if(f){return this.game.math.radToDeg(Math.atan2(c,e))}else{return Math.atan2(c,e)}}};Phaser.Physics.Arcade.Body=function(c){this.sprite=c;this.game=c.game;this.offset=new Phaser.Point;this.x=c.x;this.y=c.y;this.sourceWidth=c.currentFrame.sourceSizeW;this.sourceHeight=c.currentFrame.sourceSizeH;this.width=c.currentFrame.sourceSizeW;this.height=c.currentFrame.sourceSizeH;this.halfWidth=Math.floor(c.currentFrame.sourceSizeW/2);this.halfHeight=Math.floor(c.currentFrame.sourceSizeH/2);this._sx=c.scale.x;this._sy=c.scale.y;this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1;this.quadTreeIDs=[];this.quadTreeIndex=-1;this.allowCollision={none:false,any:true,up:true,down:true,left:true,right:true};this.touching={none:true,up:false,down:false,left:false,right:false};this.wasTouching={none:true,up:false,down:false,left:false,right:false};this.immovable=false;this.moves=true;this.rotation=0;this.allowRotation=true;this.allowGravity=true;this.collideWorldBounds=false;this.lastX=c.x;this.lastY=c.y};Phaser.Physics.Arcade.Body.prototype={updateBounds:function(f,e,d,c){if(d!=this._sx||c!=this._sy){this.width=this.sourceWidth*d;this.height=this.sourceHeight*c;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this._sx=d;this._sy=c}},update:function(){this.wasTouching.none=this.touching.none;this.wasTouching.up=this.touching.up;this.wasTouching.down=this.touching.down;this.wasTouching.left=this.touching.left;this.wasTouching.right=this.touching.right;this.touching.none=true;this.touching.up=false;this.touching.down=false;this.touching.left=false;this.touching.right=false;this.lastX=this.x;this.lastY=this.y;this.rotation=this.sprite.angle;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;if(this.moves){this.game.physics.updateMotion(this)}if(this.collideWorldBounds){this.checkWorldBounds()}if(this.allowCollision.none==false&&this.sprite.visible&&this.sprite.alive){this.quadTreeIDs=[];this.quadTreeIndex=-1;this.game.physics.quadTree.insert(this)}this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},postUpdate:function(){this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},checkWorldBounds:function(){if(this.xthis.game.world.bounds.right){this.x=this.game.world.bounds.right-this.width;this.velocity.x*=-this.bounce.x}}if(this.ythis.game.world.bounds.bottom){this.y=this.game.world.bounds.bottom-this.height;this.velocity.y*=-this.bounce.y}}},setSize:function(e,d,c,f){c=c||this.offset.x;f=f||this.offset.y;this.sourceWidth=e;this.sourceHeight=d;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(c,f)},deltaAbsX:function(){return(this.deltaX()>0?this.deltaX():-this.deltaX())},deltaAbsY:function(){return(this.deltaY()>0?this.deltaY():-this.deltaY())},deltaX:function(){return this.x-this.lastX},deltaY:function(){return this.y-this.lastY}};Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(c){if(c<=this.y){this.height=0}else{this.height=(this.y-c)}},enumerable:true,configurable:true});Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(c){if(c<=this.x){this.width=0}else{this.width=this.x+c}},enumerable:true,configurable:true}); \ No newline at end of file +var PIXI=PIXI||{};var Phaser=Phaser||{VERSION:"1.0.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2};PIXI.InteractionManager=function(b){};Phaser.Utils={pad:function(g,b,f,c){if(typeof(b)=="undefined"){var b=0}if(typeof(f)=="undefined"){var f=" "}if(typeof(c)=="undefined"){var c=3}if(b+1>=g.length){switch(c){case 1:g=Array(b+1-g.length).join(f)+g;break;case 3:var d=Math.ceil((padlen=b-g.length)/2);var e=padlen-d;g=Array(e+1).join(f)+g+Array(d+1).join(f);break;default:g=g+Array(b+1-g.length).join(f);break}}return g},isPlainObject:function(c){if(typeof(c)!=="object"||c.nodeType||c===c.window){return false}try{if(c.constructor&&!hasOwn.call(c.constructor.prototype,"isPrototypeOf")){return false}}catch(b){return false}return true},extend:function(){var l,d,b,c,h,j,g=arguments[0]||{},f=1,e=arguments.length,k=false;if(typeof g==="boolean"){k=g;g=arguments[1]||{};f=2}if(e===f){g=this;--f}for(;f>16&255)/255,(b>>8&255)/255,(b&255)/255]}if(typeof Function.prototype.bind!="function"){Function.prototype.bind=(function(){var b=Array.prototype.slice;return function(c){var f=this,g=b.call(arguments,1);if(typeof f!="function"){throw new TypeError()}function d(){var h=g.concat(b.call(arguments));f.apply(this instanceof d?this:c,h)}d.prototype=(function e(h){h&&(e.prototype=h);if(!(this instanceof e)){return new e}})(f.prototype);return d}})()}function determineMatrixArrayType(){PIXI.Matrix=(typeof Float32Array!=="undefined")?Float32Array:Array;return PIXI.Matrix}determineMatrixArrayType();PIXI.mat3={};PIXI.mat3.create=function(){var b=new PIXI.Matrix(9);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat3.identity=function(b){b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat4={};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat3.multiply=function(q,h,i){if(!i){i=q}var v=q[0],u=q[1],t=q[2],g=q[3],f=q[4],e=q[5],o=q[6],n=q[7],m=q[8],l=h[0],k=h[1],j=h[2],s=h[3],r=h[4],p=h[5],d=h[6],c=h[7],b=h[8];i[0]=l*v+k*g+j*o;i[1]=l*u+k*f+j*n;i[2]=l*t+k*e+j*m;i[3]=s*v+r*g+p*o;i[4]=s*u+r*f+p*n;i[5]=s*t+r*e+p*m;i[6]=d*v+c*g+b*o;i[7]=d*u+c*f+b*n;i[8]=d*t+c*e+b*m;return i};PIXI.mat3.clone=function(c){var b=new PIXI.Matrix(9);b[0]=c[0];b[1]=c[1];b[2]=c[2];b[3]=c[3];b[4]=c[4];b[5]=c[5];b[6]=c[6];b[7]=c[7];b[8]=c[8];return b};PIXI.mat3.transpose=function(d,c){if(!c||d===c){var f=d[1],e=d[2],b=d[5];d[1]=d[3];d[2]=d[6];d[3]=f;d[5]=d[7];d[6]=e;d[7]=b;return d}c[0]=d[0];c[1]=d[3];c[2]=d[6];c[3]=d[1];c[4]=d[4];c[5]=d[7];c[6]=d[2];c[7]=d[5];c[8]=d[8];return c};PIXI.mat3.toMat4=function(c,b){if(!b){b=PIXI.mat4.create()}b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=c[8];b[9]=c[7];b[8]=c[6];b[7]=0;b[6]=c[5];b[5]=c[4];b[4]=c[3];b[3]=0;b[2]=c[2];b[1]=c[1];b[0]=c[0];return b};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat4.transpose=function(e,d){if(!d||e===d){var i=e[1],g=e[2],f=e[3],b=e[6],h=e[7],c=e[11];e[1]=e[4];e[2]=e[8];e[3]=e[12];e[4]=i;e[6]=e[9];e[7]=e[13];e[8]=g;e[9]=b;e[11]=e[14];e[12]=f;e[13]=h;e[14]=c;return e}d[0]=e[0];d[1]=e[4];d[2]=e[8];d[3]=e[12];d[4]=e[1];d[5]=e[5];d[6]=e[9];d[7]=e[13];d[8]=e[2];d[9]=e[6];d[10]=e[10];d[11]=e[14];d[12]=e[3];d[13]=e[7];d[14]=e[11];d[15]=e[15];return d};PIXI.mat4.multiply=function(p,i,k){if(!k){k=p}var v=p[0],u=p[1],s=p[2],q=p[3];var h=p[4],f=p[5],d=p[6],b=p[7];var o=p[8],n=p[9],m=p[10],l=p[11];var z=p[12],w=p[13],t=p[14],r=p[15];var j=i[0],g=i[1],e=i[2],c=i[3];k[0]=j*v+g*h+e*o+c*z;k[1]=j*u+g*f+e*n+c*w;k[2]=j*s+g*d+e*m+c*t;k[3]=j*q+g*b+e*l+c*r;j=i[4];g=i[5];e=i[6];c=i[7];k[4]=j*v+g*h+e*o+c*z;k[5]=j*u+g*f+e*n+c*w;k[6]=j*s+g*d+e*m+c*t;k[7]=j*q+g*b+e*l+c*r;j=i[8];g=i[9];e=i[10];c=i[11];k[8]=j*v+g*h+e*o+c*z;k[9]=j*u+g*f+e*n+c*w;k[10]=j*s+g*d+e*m+c*t;k[11]=j*q+g*b+e*l+c*r;j=i[12];g=i[13];e=i[14];c=i[15];k[12]=j*v+g*h+e*o+c*z;k[13]=j*u+g*f+e*n+c*w;k[14]=j*s+g*d+e*m+c*t;k[15]=j*q+g*b+e*l+c*r;return k};PIXI.Point=function(b,c){this.x=b||0;this.y=c||0};PIXI.Point.prototype.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.prototype.constructor=PIXI.Point;PIXI.Rectangle=function(c,e,d,b){this.x=c||0;this.y=e||0;this.width=d||0;this.height=b||0};PIXI.Rectangle.prototype.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.prototype.contains=function(b,e){if(this.width<=0||this.height<=0){return false}var c=this.x;if(b>=c&&b<=c+this.width){var d=this.y;if(e>=d&&e<=d+this.height){return true}}return false};PIXI.Rectangle.prototype.constructor=PIXI.Rectangle;PIXI.DisplayObject=function(){this.last=this;this.first=this;this.position=new PIXI.Point();this.scale=new PIXI.Point(1,1);this.pivot=new PIXI.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.hitArea=null;this.buttonMode=false;this.renderable=false;this.parent=null;this.stage=null;this.worldAlpha=1;this._interactive=false;this.worldTransform=PIXI.mat3.create();this.localTransform=PIXI.mat3.create();this.color=[];this.dynamic=true;this._sr=0;this._cr=1};PIXI.DisplayObject.prototype.constructor=PIXI.DisplayObject;PIXI.DisplayObject.prototype.setInteractive=function(b){this.interactive=b};Object.defineProperty(PIXI.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(b){this._interactive=b;if(this.stage){this.stage.dirty=true}}});Object.defineProperty(PIXI.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(b){this._mask=b;if(b){this.addFilter(b)}else{this.removeFilter()}}});PIXI.DisplayObject.prototype.addFilter=function(j){if(this.filter){return}this.filter=true;var b=new PIXI.FilterBlock();var e=new PIXI.FilterBlock();b.mask=j;e.mask=j;b.first=b.last=this;e.first=e.last=this;b.open=true;var d=b;var f=b;var i;var h;h=this.first._iPrev;if(h){i=h._iNext;d._iPrev=h;h._iNext=d}else{i=this}if(i){i._iPrev=f;f._iNext=i}var d=e;var f=e;var i=null;var h=null;h=this.last;i=h._iNext;if(i){i._iPrev=f;f._iNext=i}d._iPrev=h;h._iNext=d;var c=this;var g=this.last;while(c){if(c.last==g){c.last=e}c=c.parent}this.first=b;if(this.__renderGroup){this.__renderGroup.addFilterBlocks(b,e)}j.renderable=false};PIXI.DisplayObject.prototype.removeFilter=function(){if(!this.filter){return}this.filter=false;var d=this.first;var g=d._iNext;var h=d._iPrev;if(g){g._iPrev=h}if(h){h._iNext=g}this.first=d._iNext;var e=this.last;var g=e._iNext;var h=e._iPrev;if(g){g._iPrev=h}h._iNext=g;var f=e._iPrev;var c=this;while(c.last==e){c.last=f;c=c.parent;if(!c){break}}var b=d.mask;b.renderable=true;if(this.__renderGroup){this.__renderGroup.removeFilterBlocks(d,e)}};PIXI.DisplayObject.prototype.updateTransform=function(){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}var r=this.localTransform;var f=this.parent.worldTransform;var b=this.worldTransform;r[0]=this._cr*this.scale.x;r[1]=-this._sr*this.scale.y;r[3]=this._sr*this.scale.x;r[4]=this._cr*this.scale.y;var n=this.pivot.x;var m=this.pivot.y;var i=r[0],h=r[1],g=this.position.x-r[0]*n-m*r[1],q=r[3],p=r[4],o=this.position.y-r[4]*m-n*r[3],l=f[0],k=f[1],j=f[2],e=f[3],d=f[4],c=f[5];r[2]=g;r[5]=o;b[0]=l*i+k*q;b[1]=l*h+k*p;b[2]=l*g+k*o+j;b[3]=e*i+d*q;b[4]=e*h+d*p;b[5]=e*g+d*o+c;this.worldAlpha=this.alpha*this.parent.worldAlpha;this.vcount=PIXI.visibleCount};PIXI.visibleCount=0;PIXI.DisplayObjectContainer=function(){PIXI.DisplayObject.call(this);this.children=[]};PIXI.DisplayObjectContainer.prototype=Object.create(PIXI.DisplayObject.prototype);PIXI.DisplayObjectContainer.prototype.constructor=PIXI.DisplayObjectContainer;PIXI.DisplayObjectContainer.prototype.addChild=function(i){if(i.parent!=undefined){i.parent.removeChild(i)}i.parent=this;this.children.push(i);if(this.stage){var f=i;do{if(f.interactive){this.stage.dirty=true}f.stage=this.stage;f=f._iNext}while(f)}var e=i.first;var d=i.last;var g;var h;if(this.filter){h=this.last._iPrev}else{h=this.last}g=h._iNext;var c=this;var b=h;while(c){if(c.last==b){c.last=i.last}c=c.parent}if(g){g._iPrev=d;d._iNext=g}e._iPrev=h;h._iNext=e;if(this.__renderGroup){if(i.__renderGroup){i.__renderGroup.removeDisplayObjectAndChildren(i)}this.__renderGroup.addDisplayObjectAndChildren(i)}};PIXI.DisplayObjectContainer.prototype.addChildAt=function(c,f){if(f>=0&&f<=this.children.length){if(c.parent!=undefined){c.parent.removeChild(c)}c.parent=this;if(this.stage){var e=c;do{if(e.interactive){this.stage.dirty=true}e.stage=this.stage;e=e._iNext}while(e)}var d=c.first;var g=c.last;var j;var i;if(f==this.children.length){i=this.last;var b=this;var h=this.last;while(b){if(b.last==h){b.last=c.last}b=b.parent}}else{if(f==0){i=this}else{i=this.children[f-1].last}}j=i._iNext;if(j){j._iPrev=g;g._iNext=j}d._iPrev=i;i._iNext=d;this.children.splice(f,0,c);if(this.__renderGroup){if(c.__renderGroup){c.__renderGroup.removeDisplayObjectAndChildren(c)}this.__renderGroup.addDisplayObjectAndChildren(c)}}else{throw new Error(c+" The index "+f+" supplied is out of bounds "+this.children.length)}};PIXI.DisplayObjectContainer.prototype.swapChildren=function(c,b){return};PIXI.DisplayObjectContainer.prototype.getChildAt=function(b){if(b>=0&&b1){h=1}var d=Math.sqrt(c.x*c.x+c.y*c.y);var f=this.texture.height/2;c.x/=d;c.y/=d;c.x*=f;c.y*=f;b[g]=m.x+c.x;b[g+1]=m.y+c.y;b[g+2]=m.x-c.x;b[g+3]=m.y-c.y;l=m}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.Rope.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite=function(d,c,b){PIXI.DisplayObjectContainer.call(this);this.texture=d;this.width=c;this.height=b;this.tileScale=new PIXI.Point(1,1);this.tilePosition=new PIXI.Point(0,0);this.renderable=true;this.blendMode=PIXI.blendModes.NORMAL};PIXI.TilingSprite.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.TilingSprite.prototype.constructor=PIXI.TilingSprite;PIXI.TilingSprite.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite.prototype.onTextureUpdate=function(b){this.updateFrame=true};PIXI.FilterBlock=function(b){this.graphics=b;this.visible=true;this.renderable=true};PIXI.MaskFilter=function(b){this.graphics};PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Graphics.prototype.constructor=PIXI.Graphics;PIXI.Graphics.prototype.lineStyle=function(b,c,d){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.lineWidth=b||0;this.lineColor=c||0;this.lineAlpha=(d==undefined)?1:d;this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.moveTo=function(b,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.currentPath.points.push(b,c);this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.lineTo=function(b,c){this.currentPath.points.push(b,c);this.dirty=true};PIXI.Graphics.prototype.beginFill=function(b,c){this.filling=true;this.fillColor=b||0;this.fillAlpha=(c==undefined)?1:c};PIXI.Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1};PIXI.Graphics.prototype.drawRect=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.RECT};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawCircle=function(c,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,d,b,b],type:PIXI.Graphics.CIRC};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawElipse=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.ELIP};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[]};PIXI.Graphics.POLY=0;PIXI.Graphics.RECT=1;PIXI.Graphics.CIRC=2;PIXI.Graphics.ELIP=3;PIXI.CanvasGraphics=function(){};PIXI.CanvasGraphics.renderGraphics=function(u,c){var p=u.worldAlpha;for(var s=0;s1){t=1;console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")}for(var s=0;s<1;s++){var A=v.graphicsData[s];var r=A.points;if(A.type==PIXI.Graphics.POLY){c.beginPath();c.moveTo(r[0],r[1]);for(var q=1;q0){PIXI.Texture.frameUpdates=[]}};PIXI.CanvasRenderer.prototype.resize=function(c,b){this.width=c;this.height=b;this.view.width=c;this.view.height=b};PIXI.CanvasRenderer.prototype.renderDisplayObject=function(h){var e;var f=this.context;f.globalCompositeOperation="source-over";var d=h.last._iNext;h=h.first;do{e=h.worldTransform;if(!h.visible){h=h.last._iNext;continue}if(!h.renderable){h=h._iNext;continue}if(h instanceof PIXI.Sprite){var g=h.texture.frame;if(g){f.globalAlpha=h.worldAlpha;f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);f.drawImage(h.texture.baseTexture.source,g.x,g.y,g.width,g.height,(h.anchor.x)*-g.width,(h.anchor.y)*-g.height,g.width,g.height)}}else{if(h instanceof PIXI.Strip){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderStrip(h)}else{if(h instanceof PIXI.TilingSprite){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderTilingSprite(h)}else{if(h instanceof PIXI.CustomRenderable){h.renderCanvas(this)}else{if(h instanceof PIXI.Graphics){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);PIXI.CanvasGraphics.renderGraphics(h,f)}else{if(h instanceof PIXI.FilterBlock){if(h.open){f.save();var c=h.mask.alpha;var b=h.mask.worldTransform;f.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);h.mask.worldAlpha=0.5;f.worldAlpha=0;PIXI.CanvasGraphics.renderGraphicsMask(h.mask,f);f.clip();h.mask.worldAlpha=c}else{f.restore()}}}}}}}h=h._iNext}while(h!=d)};PIXI.CanvasRenderer.prototype.renderStripFlat=function(d){var e=this.context;var f=d.verticies;var j=d.uvs;var g=f.length/2;this.count++;e.beginPath();for(var k=1;k3){PIXI.WebGLGraphics.buildPoly(d,b._webGL)}}if(d.lineWidth>0){PIXI.WebGLGraphics.buildLine(d,b._webGL)}}else{if(d.type==PIXI.Graphics.RECT){PIXI.WebGLGraphics.buildRectangle(d,b._webGL)}else{if(d.type==PIXI.Graphics.CIRC||d.type==PIXI.Graphics.ELIP){PIXI.WebGLGraphics.buildCircle(d,b._webGL)}}}}b._webGL.lastIndex=b.graphicsData.length;var e=PIXI.gl;b._webGL.glPoints=new Float32Array(b._webGL.points);e.bindBuffer(e.ARRAY_BUFFER,b._webGL.buffer);e.bufferData(e.ARRAY_BUFFER,b._webGL.glPoints,e.STATIC_DRAW);b._webGL.glIndicies=new Uint16Array(b._webGL.indices);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,b._webGL.indexBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,b._webGL.glIndicies,e.STATIC_DRAW)};PIXI.WebGLGraphics.buildRectangle=function(s,i){var f=s.points;var n=f[0];var m=f[1];var d=f[2];var q=f[3];if(s.fill){var h=HEXtoRGB(s.fillColor);var e=s.fillAlpha;var c=h[0]*e;var j=h[1]*e;var l=h[2]*e;var o=i.points;var p=i.indices;var k=o.length/6;o.push(n,m);o.push(c,j,l,e);o.push(n+d,m);o.push(c,j,l,e);o.push(n,m+q);o.push(c,j,l,e);o.push(n+d,m+q);o.push(c,j,l,e);p.push(k,k,k+1,k+2,k+3,k+3)}if(s.lineWidth){s.points=[n,m,n+d,m,n+d,m+q,n,m+q,n,m];PIXI.WebGLGraphics.buildLine(s,i)}};PIXI.WebGLGraphics.buildCircle=function(k,w){var f=k.points;var j=f[0];var h=f[1];var o=f[2];var n=f[3];var l=40;var t=(Math.PI*2)/l;if(k.fill){var p=HEXtoRGB(k.fillColor);var d=k.fillAlpha;var m=p[0]*d;var s=p[1]*d;var u=p[2]*d;var v=w.points;var e=w.indices;var c=v.length/6;e.push(c);for(var q=0;q140*140){h=L-z;f=K-w;m=Math.sqrt(h*h+f*f);h/=m;f/=m;h*=c;f*=c;S.push(B-h,A-f);S.push(M,T,W,Q);S.push(B+h,A+f);S.push(M,T,W,Q);S.push(B-h,A-f);S.push(M,T,W,Q);q++}else{S.push(px,py);S.push(M,T,W,Q);S.push(B-(px-B),A-(py-A));S.push(M,T,W,Q)}}J=H[(u-2)*2];I=H[(u-2)*2+1];B=H[(u-1)*2];A=H[(u-1)*2+1];L=-(I-A);K=J-B;m=Math.sqrt(L*L+K*K);L/=m;K/=m;L*=c;K*=c;S.push(B-L,A-K);S.push(M,T,W,Q);S.push(B+L,A+K);S.push(M,T,W,Q);l.push(U);for(var R=0;R>16&255)/255,(b>>8&255)/255,(b&255)/255]}PIXI._defaultFrame=new PIXI.Rectangle(0,0,1,1);PIXI.gl;PIXI.WebGLRenderer=function(g,b,d,j,c){this.transparent=!!j;this.width=g||800;this.height=b||600;this.view=d||document.createElement("canvas");this.view.width=this.width;this.view.height=this.height;var f=this;this.view.addEventListener("webglcontextlost",function(e){f.handleContextLost(e)},false);this.view.addEventListener("webglcontextrestored",function(e){f.handleContextRestored(e)},false);this.batchs=[];try{PIXI.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!c,premultipliedAlpha:false,stencil:true})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}PIXI.initPrimitiveShader();PIXI.initDefaultShader();PIXI.initDefaultStripShader();PIXI.activateDefaultShader();var i=this.gl;PIXI.WebGLRenderer.gl=i;this.batch=new PIXI.WebGLBatch(i);i.disable(i.DEPTH_TEST);i.disable(i.CULL_FACE);i.enable(i.BLEND);i.colorMask(true,true,true,this.transparent);PIXI.projection=new PIXI.Point(400,300);this.resize(this.width,this.height);this.contextLost=false;this.stageRenderGroup=new PIXI.WebGLRenderGroup(this.gl)};PIXI.WebGLRenderer.prototype.constructor=PIXI.WebGLRenderer;PIXI.WebGLRenderer.getBatch=function(){if(PIXI._batchs.length==0){return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl)}else{return PIXI._batchs.pop()}};PIXI.WebGLRenderer.returnBatch=function(b){b.clean();PIXI._batchs.push(b)};PIXI.WebGLRenderer.prototype.render=function(b){if(this.contextLost){return}if(this.__stage!==b){this.__stage=b;this.stageRenderGroup.setRenderable(b)}PIXI.WebGLRenderer.updateTextures();PIXI.visibleCount++;b.updateTransform();var d=this.gl;d.colorMask(true,true,true,this.transparent);d.viewport(0,0,this.width,this.height);d.bindFramebuffer(d.FRAMEBUFFER,null);d.clearColor(b.backgroundColorSplit[0],b.backgroundColorSplit[1],b.backgroundColorSplit[2],!this.transparent);d.clear(d.COLOR_BUFFER_BIT);this.stageRenderGroup.backgroundColor=b.backgroundColorSplit;this.stageRenderGroup.render(PIXI.projection);if(b.interactive){if(!b._interactiveEventsAdded){b._interactiveEventsAdded=true;b.interactionManager.setTarget(this)}}if(PIXI.Texture.frameUpdates.length>0){for(var c=0;c0){n=n.children[n.children.length-1];if(n.renderable){b=n}}if(b instanceof PIXI.Sprite){c=b.batch;var l=c.head;if(l==b){h=0}else{h=1;while(l.__next!=b){h++;l=l.__next}}}else{c=b}if(m==c){if(m instanceof PIXI.WebGLBatch){m.render(p,h+1)}else{this.renderSpecial(m,j)}return}d=this.batchs.indexOf(m);q=this.batchs.indexOf(c);if(m instanceof PIXI.WebGLBatch){m.render(p)}else{this.renderSpecial(m,j)}for(var e=d+1;e=2?parseInt(b[b.length-2],10):PIXI.BitmapText.fonts[this.fontName].size;this.dirty=true};PIXI.BitmapText.prototype.updateText=function(){var h=PIXI.BitmapText.fonts[this.fontName];var m=new PIXI.Point();var j=null;var l=[];var q=0;var e=[];var p=0;var f=this.fontSize/h.size;for(var g=0;g0){this.removeChild(this.getChildAt(0))}this.updateText();this.dirty=false}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.BitmapText.fonts={};PIXI.Text=function(c,b){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");PIXI.Sprite.call(this,PIXI.Texture.fromCanvas(this.canvas));this.setText(c);this.setStyle(b);this.updateText();this.dirty=false};PIXI.Text.prototype=Object.create(PIXI.Sprite.prototype);PIXI.Text.prototype.constructor=PIXI.Text;PIXI.Text.prototype.setStyle=function(b){b=b||{};b.font=b.font||"bold 20pt Arial";b.fill=b.fill||"black";b.align=b.align||"left";b.stroke=b.stroke||"black";b.strokeThickness=b.strokeThickness||0;b.wordWrap=b.wordWrap||false;b.wordWrapWidth=b.wordWrapWidth||100;this.style=b;this.dirty=true};PIXI.Sprite.prototype.setText=function(b){this.text=b.toString()||" ";this.dirty=true};PIXI.Text.prototype.updateText=function(){this.context.font=this.style.font;var g=this.text;if(this.style.wordWrap){g=this.wordWrap(this.text)}var f=g.split(/(?:\r\n|\r|\n)/);var d=[];var c=0;for(var h=0;hj){return k}else{return arguments.callee(i,l,k,h,j)}}else{return arguments.callee(i,l,m,k,j)}};var f=function(h,j,i){if(h.measureText(j).width<=i||j.length<1){return j}var k=e(h,j,0,j.length,i);return j.substring(0,k)+"\n"+arguments.callee(h,j.substring(k),i)};var b="";var c=g.split("\n");for(var d=0;dthis.baseTexture.width||b.y+b.height>this.baseTexture.height){throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this)}this.updateFrame=true;PIXI.Texture.frameUpdates.push(this)};PIXI.Texture.fromImage=function(c,b){var d=PIXI.TextureCache[c];if(!d){d=new PIXI.Texture(PIXI.BaseTexture.fromImage(c,b));PIXI.TextureCache[c]=d}return d};PIXI.Texture.fromFrame=function(c){var b=PIXI.TextureCache[c];if(!b){throw new Error("The frameId '"+c+"' does not exist in the texture cache "+this)}return b};PIXI.Texture.fromCanvas=function(b){var c=new PIXI.BaseTexture(b);return new PIXI.Texture(c)};PIXI.Texture.addTextureToCache=function(b,c){PIXI.TextureCache[c]=b};PIXI.Texture.removeTextureFromCache=function(c){var b=PIXI.TextureCache[c];PIXI.TextureCache[c]=null;return b};PIXI.Texture.frameUpdates=[];PIXI.RenderTexture=function(c,b){PIXI.EventTarget.call(this);this.width=c||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};PIXI.RenderTexture.prototype=Object.create(PIXI.Texture.prototype);PIXI.RenderTexture.prototype.constructor=PIXI.RenderTexture;PIXI.RenderTexture.prototype.initWebGL=function(){var b=PIXI.gl;this.glFramebuffer=b.createFramebuffer();b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);this.glFramebuffer.width=this.width;this.glFramebuffer.height=this.height;this.baseTexture=new PIXI.BaseTexture();this.baseTexture.width=this.width;this.baseTexture.height=this.height;this.baseTexture._glTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,this.baseTexture._glTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,this.width,this.height,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);this.baseTexture.isRender=true;b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new PIXI.Point(this.width/2,this.height/2);this.render=this.renderWebGL};PIXI.RenderTexture.prototype.resize=function(c,b){this.width=c;this.height=b;if(PIXI.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var d=PIXI.gl;d.bindTexture(d.TEXTURE_2D,this.baseTexture._glTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,this.width,this.height,0,d.RGBA,d.UNSIGNED_BYTE,null)}else{this.frame.width=this.width;this.frame.height=this.height;this.renderer.resize(this.width,this.height)}};PIXI.RenderTexture.prototype.initCanvas=function(){this.renderer=new PIXI.CanvasRenderer(this.width,this.height,null,0);this.baseTexture=new PIXI.BaseTexture(this.renderer.view);this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.render=this.renderCanvas};PIXI.RenderTexture.prototype.renderWebGL=function(k,g,h){var f=PIXI.gl;f.colorMask(true,true,true,true);f.viewport(0,0,this.width,this.height);f.bindFramebuffer(f.FRAMEBUFFER,this.glFramebuffer);if(h){f.clearColor(0,0,0,0);f.clear(f.COLOR_BUFFER_BIT)}var c=k.children;var b=k.worldTransform;k.worldTransform=PIXI.mat3.create();k.worldTransform[4]=-1;k.worldTransform[5]=this.projection.y*2;if(g){k.worldTransform[2]=g.x;k.worldTransform[5]-=g.y}PIXI.visibleCount++;k.vcount=PIXI.visibleCount;for(var e=0,d=c.length;e>1;if(k<3){return[]}var u=[];var g=[];for(var s=0;s3){var q=g[(s+0)%o];var m=g[(s+1)%o];var l=g[(s+2)%o];var f=h[2*q],d=h[2*q+1];var v=h[2*m],t=h[2*m+1];var c=h[2*l],b=h[2*l+1];var e=false;if(PIXI.PolyK._convex(f,d,v,t,c,b,z)){e=true;for(var r=0;r3*o){if(z){var u=[];g=[];for(var s=0;s=0)&&(m>=0)&&(n+m<1)};PIXI.PolyK._convex=function(e,d,g,f,b,h,c){return((d-f)*(b-g)+(g-e)*(h-f)>=0)==c};Phaser.Camera=function(d,g,c,f,e,b){this.game=d;this.world=d.world;this.id=0;this.view=new Phaser.Rectangle(c,f,e,b);this.screenView=new Phaser.Rectangle(c,f,e,b);this.deadzone=null;this.visible=true;this.atLimit={x:false,y:false};this.target=null;this._edge=0};Phaser.Camera.FOLLOW_LOCKON=0;Phaser.Camera.FOLLOW_PLATFORMER=1;Phaser.Camera.FOLLOW_TOPDOWN=2;Phaser.Camera.FOLLOW_TOPDOWN_TIGHT=3;Phaser.Camera.prototype={follow:function(f,d){if(typeof d==="undefined"){d=Phaser.Camera.FOLLOW_LOCKON}this.target=f;var e;switch(d){case Phaser.Camera.FOLLOW_PLATFORMER:var b=this.width/8;var c=this.height/3;this.deadzone=new Phaser.Rectangle((this.width-b)/2,(this.height-c)/2-c*0.25,b,c);break;case Phaser.Camera.FOLLOW_TOPDOWN:e=Math.max(this.width,this.height)/4;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:e=Math.max(this.width,this.height)/8;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_LOCKON:default:this.deadzone=null;break}},focusOnXY:function(b,c){this.view.x=Math.round(b-this.view.halfWidth);this.view.y=Math.round(c-this.view.halfHeight)},update:function(){if(this.target!==null){if(this.deadzone){this._edge=this.target.x-this.deadzone.x;if(this.view.x>this._edge){this.view.x=this._edge}this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width;if(this.view.xthis._edge){this.view.y=this._edge}this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height;if(this.view.ythis.world.bounds.right-this.width){this.atLimit.x=true;this.view.x=(this.world.bounds.right-this.width)+1}if(this.view.ythis.world.bounds.bottom-this.height){this.atLimit.y=true;this.view.y=(this.world.bounds.bottom-this.height)+1}this.view.floor()},setPosition:function(b,c){this.view.x=b;this.view.y=c;this.checkWorldBounds()},setSize:function(c,b){this.view.width=c;this.view.height=b}};Object.defineProperty(Phaser.Camera.prototype,"x",{get:function(){return this.view.x},set:function(b){this.view.x=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"y",{get:function(){return this.view.y},set:function(b){this.view.y=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"width",{get:function(){return this.view.width},set:function(b){this.view.width=b}});Object.defineProperty(Phaser.Camera.prototype,"height",{get:function(){return this.view.height},set:function(b){this.view.height=b}});Phaser.State=function(){this.game=null;this.add=null;this.camera=null;this.cache=null;this.input=null;this.load=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.particles=null;this.physics=null};Phaser.State.prototype={link:function(b){this.game=b;this.add=b.add;this.camera=b.camera;this.cache=b.cache;this.input=b.input;this.load=b.load;this.sound=b.sound;this.stage=b.stage;this.time=b.time;this.tweens=b.tweens;this.world=b.world;this.particles=b.particles;this.physics=b.physics},preload:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}};Phaser.StateManager=function(c,b){this.game=c;this.states={};if(b!==null){this._pendingState=b}};Phaser.StateManager.prototype={game:null,_pendingState:null,_created:false,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){if(this._pendingState!==null){if(typeof this._pendingState==="string"){this.start(this._pendingState,false,false)}else{this.add("default",this._pendingState,true)}}},add:function(c,d,b){if(typeof b==="undefined"){b=false}var e;if(d instanceof Phaser.State){e=d;e.link(this.game)}else{if(typeof d==="object"){e=d}else{if(typeof d==="function"){e=new d(this.game)}}}this.states[c]=e;if(b){if(this.game.isBooted){this.start(c)}else{this._pendingState=c}}return e},remove:function(b){if(this.current==b){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null}delete this.states[b]},start:function(c,b,d){if(typeof b==="undefined"){b=true}if(typeof d==="undefined"){d=false}if(this.game.isBooted==false){this._pendingState=c;return}if(this.checkState(c)==false){return}else{if(this.current){this.onShutDownCallback.call(this.callbackContext)}if(b){if(d==true){this.game.cache.destroy()}}this.setCurrentState(c)}if(this.onPreloadCallback){this.game.load.reset();this.onPreloadCallback.call(this.callbackContext);if(this.game.load.queueSize==0){this.game.loadComplete();if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true}else{this.game.load.start()}}else{if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true;this.game.loadComplete()}},dummy:function(){},checkState:function(b){if(this.states[b]){var c=false;if(this.states[b]["preload"]){c=true}if(c==false&&this.states[b]["loadRender"]){c=true}if(c==false&&this.states[b]["loadUpdate"]){c=true}if(c==false&&this.states[b]["create"]){c=true}if(c==false&&this.states[b]["update"]){c=true}if(c==false&&this.states[b]["preRender"]){c=true}if(c==false&&this.states[b]["render"]){c=true}if(c==false&&this.states[b]["paused"]){c=true}if(c==false){console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");return false}return true}else{console.warn("Phaser.StateManager - No state found with the key: "+b);return false}},setCurrentState:function(b){this.callbackContext=this.states[b];this.onInitCallback=this.states[b]["init"]||this.dummy;this.onPreloadCallback=this.states[b]["preload"]||null;this.onLoadRenderCallback=this.states[b]["loadRender"]||null;this.onLoadUpdateCallback=this.states[b]["loadUpdate"]||null;this.onCreateCallback=this.states[b]["create"]||null;this.onUpdateCallback=this.states[b]["update"]||null;this.onPreRenderCallback=this.states[b]["preRender"]||null;this.onRenderCallback=this.states[b]["render"]||null;this.onPausedCallback=this.states[b]["paused"]||null;this.onShutDownCallback=this.states[b]["shutdown"]||this.dummy;this.current=b;this._created=false;this.onInitCallback.call(this.callbackContext)},loadComplete:function(){if(this._created==false&&this.onCreateCallback){this.onCreateCallback.call(this.callbackContext);this._created=true}},update:function(){if(this._created&&this.onUpdateCallback){this.onUpdateCallback.call(this.callbackContext)}else{if(this.onLoadUpdateCallback){this.onLoadUpdateCallback.call(this.callbackContext)}}},preRender:function(){if(this.onPreRenderCallback){this.onPreRenderCallback.call(this.callbackContext)}},render:function(){if(this._created&&this.onRenderCallback){this.onRenderCallback.call(this.callbackContext)}else{if(this.onLoadRenderCallback){this.onLoadRenderCallback.call(this.callbackContext)}}},destroy:function(){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null;this.game=null;this.states={};this._pendingState=null}};Phaser.LinkedList=function(){this.next=null;this.prev=null;this.first=null;this.last=null;this.total=0};Phaser.LinkedList.prototype={add:function(b){if(this.total==0&&this.first==null&&this.last==null){this.first=b;this.last=b;this.next=b;b.prev=this;this.total++;return}this.last.next=b;b.prev=this.last;this.last=b;this.total++;return b},remove:function(c){if(this.first==null&&this.last==null){return}this.total--;if(this.first==c&&this.last==c){this.first=null;this.last=null;this.next=null;c.next=null;c.prev=null;return}var b=c.prev;if(c.next){c.next.prev=c.prev}b.next=c.next},callAll:function(c){var b=this.first;do{if(b[c]){b[c].call(b)}b=b.next}while(b!=this.last.next)},dump:function(){var j=20;var e="\n"+Phaser.Utils.pad("Node",j)+"|"+Phaser.Utils.pad("Next",j)+"|"+Phaser.Utils.pad("Previous",j)+"|"+Phaser.Utils.pad("First",j)+"|"+Phaser.Utils.pad("Last",j);console.log(e);var e=Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j);console.log(e);var g=this;var c=g.last.next;g=g.first;do{var d=g.sprite.name||"*";var f="-";var b="-";var h="-";var i="-";if(g.next){f=g.next.sprite.name}if(g.prev){b=g.prev.sprite.name}if(g.first){h=g.first.sprite.name}if(g.last){i=g.last.sprite.name}if(typeof f==="undefined"){f="-"}if(typeof b==="undefined"){b="-"}if(typeof h==="undefined"){h="-"}if(typeof i==="undefined"){i="-"}var e=Phaser.Utils.pad(d,j)+"|"+Phaser.Utils.pad(f,j)+"|"+Phaser.Utils.pad(b,j)+"|"+Phaser.Utils.pad(h,j)+"|"+Phaser.Utils.pad(i,j);console.log(e);g=g.next}while(g!=c)}};Phaser.Signal=function(){this._bindings=[];this._prevParams=null;var b=this;this.dispatch=function(){Phaser.Signal.prototype.dispatch.apply(b,arguments)}};Phaser.Signal.prototype={memorize:false,_shouldPropagate:true,active:true,validateListener:function(b,c){if(typeof b!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",c))}},_registerListener:function(f,d,e,c){var b=this._indexOfListener(f,e),g;if(b!==-1){g=this._bindings[b];if(g.isOnce()!==d){throw new Error("You cannot add"+(d?"":"Once")+"() then add"+(!d?"":"Once")+"() the same listener without removing the relationship first.")}}else{g=new Phaser.SignalBinding(this,f,d,e,c);this._addBinding(g)}if(this.memorize&&this._prevParams){g.execute(this._prevParams)}return g},_addBinding:function(b){var c=this._bindings.length;do{--c}while(this._bindings[c]&&b._priority<=this._bindings[c]._priority);this._bindings.splice(c+1,0,b)},_indexOfListener:function(c,b){var e=this._bindings.length,d;while(e--){d=this._bindings[e];if(d._listener===c&&d.context===b){return e}}return -1},has:function(c,b){return this._indexOfListener(c,b)!==-1},add:function(d,c,b){this.validateListener(d,"add");return this._registerListener(d,false,c,b)},addOnce:function(d,c,b){this.validateListener(d,"addOnce");return this._registerListener(d,true,c,b)},remove:function(d,c){this.validateListener(d,"remove");var b=this._indexOfListener(d,c);if(b!==-1){this._bindings[b]._destroy();this._bindings.splice(b,1)}return d},removeAll:function(){var b=this._bindings.length;while(b--){this._bindings[b]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(c){if(!this.active){return}var b=Array.prototype.slice.call(arguments),e=this._bindings.length,d;if(this.memorize){this._prevParams=b}if(!e){return}d=this._bindings.slice();this._shouldPropagate=true;do{e--}while(d[e]&&this._shouldPropagate&&d[e].execute(b)!==false)},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Phaser.SignalBinding=function(f,e,c,d,b){this._listener=e;this._isOnce=c;this.context=d;this._signal=f;this._priority=b||0};Phaser.SignalBinding.prototype={active:true,params:null,execute:function(b){var d,c;if(this.active&&!!this._listener){c=this.params?this.params.concat(b):b;d=this._listener.apply(this.context,c);if(this._isOnce){this.detach()}}return d},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return(!!this._signal&&!!this._listener)},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};Phaser.Plugin=function(b,c){this.game=b;this.parent=c;this.active=false;this.visible=false;this.hasPreUpdate=false;this.hasUpdate=false;this.hasRender=false;this.hasPostRender=false};Phaser.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=false;this.visible=false}};Phaser.PluginManager=function(b,c){this.game=b;this._parent=c;this.plugins=[];this._pluginsLength=0};Phaser.PluginManager.prototype={add:function(c){var b=false;if(typeof c==="function"){c=new c(this.game,this._parent)}else{c.game=this.game;c.parent=this._parent}if(typeof c.preUpdate==="function"){c.hasPreUpdate=true;b=true}if(typeof c.update==="function"){c.hasUpdate=true;b=true}if(typeof c.render==="function"){c.hasRender=true;b=true}if(typeof c.postRender==="function"){c.hasPostRender=true;b=true}if(b){if(c.hasPreUpdate||c.hasUpdate){c.active=true}if(c.hasRender||c.hasPostRender){c.visible=true}this._pluginsLength=this.plugins.push(c);return c}else{return null}},remove:function(b){this._pluginsLength--},preUpdate:function(){if(this._pluginsLength==0){return}for(this._p=0;this._p0)},removeBetween:function(d,c){if(d>c||d<0||c>this._container.children.length){return false}for(var b=d;b=this.game.width){this.bounds.width=c}if(b>=this.game.height){this.bounds.height=b}}};Object.defineProperty(Phaser.World.prototype,"width",{get:function(){return this.bounds.width},set:function(b){this.bounds.width=b}});Object.defineProperty(Phaser.World.prototype,"height",{get:function(){return this.bounds.height},set:function(b){this.bounds.height=b}});Object.defineProperty(Phaser.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}});Object.defineProperty(Phaser.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}});Object.defineProperty(Phaser.World.prototype,"randomX",{get:function(){return Math.round(Math.random()*this.bounds.width)}});Object.defineProperty(Phaser.World.prototype,"randomY",{get:function(){return Math.round(Math.random()*this.bounds.height)}});Phaser.Game=function(e,b,g,d,f,h,c){e=e||800;b=b||600;g=g||Phaser.AUTO;d=d||"";f=f||null;h=h||false;c=c||true;this.id=Phaser.GAMES.push(this)-1;this.parent=d;this.width=e;this.height=b;this.transparent=h;this.antialias=c;this.renderer=null;this.state=new Phaser.StateManager(this,f);this._paused=false;this.renderType=g;this._loadComplete=false;this.isBooted=false;this.isRunning=false;this.raf=null;this.add=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.net=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.physics=null;this.rnd=null;this.device=null;this.camera=null;this.canvas=null;this.context=null;this.debug=null;this.particles=null;var i=this;this._onBoot=function(){return i.boot()};if(document.readyState==="complete"||document.readyState==="interactive"){window.setTimeout(this._onBoot,0)}else{document.addEventListener("DOMContentLoaded",this._onBoot,false);window.addEventListener("load",this._onBoot,false)}return this};Phaser.Game.prototype={boot:function(){if(this.isBooted){return}if(!document.body){window.setTimeout(this._onBoot,20)}else{document.removeEventListener("DOMContentLoaded",this._onBoot);window.removeEventListener("load",this._onBoot);this.onPause=new Phaser.Signal;this.onResume=new Phaser.Signal;this.isBooted=true;this.device=new Phaser.Device();this.math=Phaser.Math;this.rnd=new Phaser.RandomDataGenerator([(Date.now()*Math.random()).toString()]);this.stage=new Phaser.Stage(this,this.width,this.height);this.setUpRenderer();this.world=new Phaser.World(this);this.add=new Phaser.GameObjectFactory(this);this.cache=new Phaser.Cache(this);this.load=new Phaser.Loader(this);this.time=new Phaser.Time(this);this.tweens=new Phaser.TweenManager(this);this.input=new Phaser.Input(this);this.sound=new Phaser.SoundManager(this);this.physics=new Phaser.Physics.Arcade(this);this.particles=new Phaser.Particles(this);this.plugins=new Phaser.PluginManager(this,this);this.net=new Phaser.Net(this);this.debug=new Phaser.Utils.Debug(this);this.load.onLoadComplete.add(this.loadComplete,this);this.stage.boot();this.world.boot();this.state.boot();this.input.boot();this.sound.boot();if(this.renderType==Phaser.CANVAS){console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000")}else{console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000")}this.isRunning=true;this._loadComplete=false;this.raf=new Phaser.RequestAnimationFrame(this);this.raf.start()}},setUpRenderer:function(){if(this.renderType===Phaser.CANVAS||(this.renderType===Phaser.AUTO&&this.device.webGL==false)){if(this.device.canvas){this.renderType=Phaser.CANVAS;this.renderer=new PIXI.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent);Phaser.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias);this.canvas=this.renderer.view;this.context=this.renderer.context}else{throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.")}}else{this.renderType=Phaser.WEBGL;this.renderer=new PIXI.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias);this.canvas=this.renderer.view;this.context=null}Phaser.Canvas.addToDOM(this.renderer.view,this.parent,true);Phaser.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=true;this.state.loadComplete()},update:function(b){this.time.update(b);if(!this._paused){this.plugins.preUpdate();this.physics.preUpdate();this.input.update();this.tweens.update();this.sound.update();this.world.update();this.particles.update();this.state.update();this.plugins.update();this.renderer.render(this.stage._stage);this.plugins.render();this.state.render();this.plugins.postRender()}},destroy:function(){this.state.destroy();this.state=null;this.cache=null;this.input=null;this.load=null;this.sound=null;this.stage=null;this.time=null;this.world=null;this.isBooted=false}};Object.defineProperty(Phaser.Game.prototype,"paused",{get:function(){return this._paused},set:function(b){if(b===true){if(this._paused==false){this._paused=true;this.onPause.dispatch(this)}}else{if(this._paused){this._paused=false;this.onResume.dispatch(this)}}}});Phaser.Input=function(b){this.game=b;this.hitCanvas=null;this.hitContext=null};Phaser.Input.MOUSE_OVERRIDES_TOUCH=0;Phaser.Input.TOUCH_OVERRIDES_MOUSE=1;Phaser.Input.MOUSE_TOUCH_COMBINE=2;Phaser.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:false,multiInputOverride:Phaser.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2000,justPressedRate:200,justReleasedRate:200,recordPointerHistory:false,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new Phaser.LinkedList(),boot:function(){this.mousePointer=new Phaser.Pointer(this.game,0);this.pointer1=new Phaser.Pointer(this.game,1);this.pointer2=new Phaser.Pointer(this.game,2);this.mouse=new Phaser.Mouse(this.game);this.keyboard=new Phaser.Keyboard(this.game);this.touch=new Phaser.Touch(this.game);this.mspointer=new Phaser.MSPointer(this.game);this.onDown=new Phaser.Signal();this.onUp=new Phaser.Signal();this.onTap=new Phaser.Signal();this.onHold=new Phaser.Signal();this.scale=new Phaser.Point(1,1);this.speed=new Phaser.Point();this.position=new Phaser.Point();this._oldPosition=new Phaser.Point();this.circle=new Phaser.Circle(0,0,44);this.activePointer=this.mousePointer;this.currentPointers=0;this.hitCanvas=document.createElement("canvas");this.hitCanvas.width=1;this.hitCanvas.height=1;this.hitContext=this.hitCanvas.getContext("2d");this.mouse.start();this.keyboard.start();this.touch.start();this.mspointer.start();this.mousePointer.active=true},addPointer:function(){var c=0;for(var b=10;b>0;b--){if(this["pointer"+b]===null){c=b}}if(c==0){console.warn("You can only have 10 Pointer objects");return null}else{this["pointer"+c]=new Phaser.Pointer(this.game,c);return this["pointer"+c]}},update:function(){if(this.pollRate>0&&this._pollCounter0&&this._pollCounter=this.game.input.holdRate){if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onHold.dispatch(this)}this._holdSent=true}if(this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop){this._nextDrop=this.game.time.now+this.game.input.recordRate;this._history.push({x:this.position.x,y:this.position.y});if(this._history.length>this.game.input.recordLimit){this._history.shift()}}}},move:function(c){if(this.game.input.pollLocked){return}if(c.button){this.button=c.button}this.clientX=c.clientX;this.clientY=c.clientY;this.pageX=c.pageX;this.pageY=c.pageY;this.screenX=c.screenX;this.screenY=c.screenY;this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x;this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y;this.position.setTo(this.x,this.y);this.circle.x=this.x;this.circle.y=this.y;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.activePointer=this;this.game.input.x=this.x;this.game.input.y=this.y;this.game.input.position.setTo(this.game.input.x,this.game.input.y);this.game.input.circle.x=this.game.input.x;this.game.input.circle.y=this.game.input.y}if(this.game.paused){return this}if(this.targetObject!==null&&this.targetObject.isDragged==true){if(this.targetObject.update(this)==false){this.targetObject=null}return this}this._highestRenderOrderID=-1;this._highestRenderObject=null;this._highestInputPriorityID=-1;if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b.priorityID>this._highestInputPriorityID||(b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)){if(b.checkPointerOver(this)){this._highestRenderOrderID=b.sprite.renderOrderID;this._highestInputPriorityID=b.priorityID;this._highestRenderObject=b}}b=b.next}while(b!=null)}if(this._highestRenderObject==null){if(this.targetObject){this.targetObject._pointerOutHandler(this);this.targetObject=null}}else{if(this.targetObject==null){this.targetObject=this._highestRenderObject;this._highestRenderObject._pointerOverHandler(this)}else{if(this.targetObject==this._highestRenderObject){if(this._highestRenderObject.update(this)==false){this.targetObject=null}}else{this.targetObject._pointerOutHandler(this);this.targetObject=this._highestRenderObject;this.targetObject._pointerOverHandler(this)}}}return this},leave:function(b){this.withinGame=false;this.move(b)},stop:function(c){if(this._stateReset){c.preventDefault();return}this.timeUp=this.game.time.now;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onUp.dispatch(this);if(this.duration>=0&&this.duration<=this.game.input.tapRate){if(this.timeUp-this.previousTapTime0){this.active=false}this.withinGame=false;this.isDown=false;this.isUp=true;if(this.isMouse==false){this.game.input.currentPointers--}if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b){b._releasedHandler(this)}b=b.next}while(b!=null)}if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null;return this},justPressed:function(b){b=b||this.game.input.justPressedRate;return(this.isDown===true&&(this.timeDown+b)>this.game.time.now)},justReleased:function(b){b=b||this.game.input.justReleasedRate;return(this.isUp===true&&(this.timeUp+b)>this.game.time.now)},reset:function(){if(this.isMouse==false){this.active=false}this.identifier=null;this.isDown=false;this.isUp=true;this.totalTouches=0;this._holdSent=false;this._history.length=0;this._stateReset=true;if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}};Object.defineProperty(Phaser.Pointer.prototype,"duration",{get:function(){if(this.isUp){return -1}return this.game.time.now-this.timeDown}});Object.defineProperty(Phaser.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}});Object.defineProperty(Phaser.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}});Phaser.Touch=function(b){this.game=b;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null;this.preventDefault=true};Phaser.Touch.prototype={game:null,disabled:false,_onTouchStart:null,_onTouchMove:null,_onTouchEnd:null,_onTouchEnter:null,_onTouchLeave:null,_onTouchCancel:null,_onTouchMove:null,start:function(){var b=this;if(this.game.device.touch){this._onTouchStart=function(c){return b.onTouchStart(c)};this._onTouchMove=function(c){return b.onTouchMove(c)};this._onTouchEnd=function(c){return b.onTouchEnd(c)};this._onTouchEnter=function(c){return b.onTouchEnter(c)};this._onTouchLeave=function(c){return b.onTouchLeave(c)};this._onTouchCancel=function(c){return b.onTouchCancel(c)};this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,false);this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,false);this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,false);this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,false);this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,false);this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,false)}},consumeDocumentTouches:function(){this._documentTouchMove=function(b){b.preventDefault()};document.addEventListener("touchmove",this._documentTouchMove,false)},onTouchStart:function(c){if(this.touchStartCallback){this.touchStartCallback.call(this.callbackContext,c)}if(this.game.input.disabled||this.disabled){return}if(this.preventDefault){c.preventDefault()}for(var b=0;bb&&this._tempPoint.xc&&this._tempPoint.y=this.pixelPerfectAlpha){return true}}return false},update:function(b){if(this.enabled==false||this.sprite.visible==false){this._pointerOutHandler(b);return false}if(this.draggable&&this._draggedPointerID==b.id){return this.updateDrag(b)}else{if(this._pointerData[b.id].isOver==true){if(this.checkPointerOver(b)){this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;return true}else{this._pointerOutHandler(b);return false}}}},_pointerOverHandler:function(b){if(this._pointerData[b.id].isOver==false){this._pointerData[b.id].isOver=true;this._pointerData[b.id].isOut=false;this._pointerData[b.id].timeOver=this.game.time.now;this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="pointer"}this.sprite.events.onInputOver.dispatch(this.sprite,b)}},_pointerOutHandler:function(b){this._pointerData[b.id].isOver=false;this._pointerData[b.id].isOut=true;this._pointerData[b.id].timeOut=this.game.time.now;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="default"}this.sprite.events.onInputOut.dispatch(this.sprite,b)},_touchedHandler:function(b){if(this._pointerData[b.id].isDown==false&&this._pointerData[b.id].isOver==true){this._pointerData[b.id].isDown=true;this._pointerData[b.id].isUp=false;this._pointerData[b.id].timeDown=this.game.time.now;this.sprite.events.onInputDown.dispatch(this.sprite,b);if(this.draggable&&this.isDragged==false){this.startDrag(b)}if(this.bringToTop){this.sprite.bringToTop()}}return this.consumePointerEvent},_releasedHandler:function(b){if(this._pointerData[b.id].isDown&&b.isUp){this._pointerData[b.id].isDown=false;this._pointerData[b.id].isUp=true;this._pointerData[b.id].timeUp=this.game.time.now;this._pointerData[b.id].downDuration=this._pointerData[b.id].timeUp-this._pointerData[b.id].timeDown;if(this.checkPointerOver(b)){this.sprite.events.onInputUp.dispatch(this.sprite,b)}else{if(this.useHandCursor){this.game.stage.canvas.style.cursor="default"}}if(this.draggable&&this.isDragged&&this._draggedPointerID==b.id){this.stopDrag(b)}}},updateDrag:function(b){if(b.isUp){this.stopDrag(b);return false}if(this.allowHorizontalDrag){this.sprite.x=b.x+this._dragPoint.x+this.dragOffset.x}if(this.allowVerticalDrag){this.sprite.y=b.y+this._dragPoint.y+this.dragOffset.y}if(this.boundsRect){this.checkBoundsRect()}if(this.boundsSprite){this.checkBoundsSprite()}if(this.snapOnDrag){this.sprite.x=Math.floor(this.sprite.x/this.snapX)*this.snapX;this.sprite.y=Math.floor(this.sprite.y/this.snapY)*this.snapY}return true},justOver:function(c,b){c=c||0;b=b||500;return(this._pointerData[c].isOver&&this.overDuration(c)this.boundsRect.right){this.sprite.x=this.boundsRect.right-this.sprite.width}}if(this.sprite.ythis.boundsRect.bottom){this.sprite.y=this.boundsRect.bottom-this.sprite.height}}},checkBoundsSprite:function(){if(this.sprite.x(this.boundsSprite.x+this.boundsSprite.width)){this.sprite.x=(this.boundsSprite.x+this.boundsSprite.width)-this.sprite.width}}if(this.sprite.y(this.boundsSprite.y+this.boundsSprite.height)){this.sprite.y=(this.boundsSprite.y+this.boundsSprite.height)-this.sprite.height}}}};Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";d=d||true;if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b)}else{document.body.appendChild(b)}if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.Events=function(b){this.parent=b;this.onAddedToGroup=new Phaser.Signal;this.onRemovedFromGroup=new Phaser.Signal;this.onKilled=new Phaser.Signal;this.onRevived=new Phaser.Signal;this.onOutOfBounds=new Phaser.Signal;this.onInputOver=null;this.onInputOut=null;this.onInputDown=null;this.onInputUp=null;this.onDragStart=null;this.onDragStop=null;this.onAnimationStart=null;this.onAnimationComplete=null;this.onAnimationLoop=null};Phaser.GameObjectFactory=function(b){this.game=b;this.world=this.game.world};Phaser.GameObjectFactory.prototype={game:null,world:null,existing:function(b){return this.world.group.add(b)},sprite:function(b,e,c,d){return this.world.group.add(new Phaser.Sprite(this.game,b,e,c,d))},child:function(d,b,g,c,e){var f=this.world.group.add(new Phaser.Sprite(this.game,b,g,c,e));d.addChild(f);return f},tween:function(b){return this.game.tweens.create(b)},group:function(c,b){return new Phaser.Group(this.game,c,b)},audio:function(c,d,b){return this.game.sound.add(c,d,b)},tileSprite:function(c,g,e,b,d,f){return this.world.group.add(new Phaser.TileSprite(this.game,c,g,e,b,d,f))},text:function(b,e,d,c){return this.world.group.add(new Phaser.Text(this.game,b,e,d,c))},button:function(b,i,g,h,e,d,f,c){return this.world.group.add(new Phaser.Button(this.game,b,i,g,h,e,d,f,c))},graphics:function(b,c){return this.world.group.add(new Phaser.Graphics(this.game,b,c))},emitter:function(b,d,c){return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game,b,d,c))},bitmapText:function(b,e,d,c){return this.world.group.add(new Phaser.BitmapText(this.game,b,e,d,c))},tilemap:function(b,g,d,e,f,c){return this.world.group.add(new Phaser.Tilemap(this.game,d,b,g,e,f,c))},renderTexture:function(c,d,b){var e=new Phaser.RenderTexture(this.game,c,d,b);this.game.cache.addRenderTexture(c,e);return e}};Phaser.Sprite=function(c,b,f,d,e){b=b||0;f=f||0;d=d||null;e=e||null;this.game=c;this.exists=true;this.alive=true;this.group=null;this.name="";this.renderOrderID=-1;this.lifespan=0;this.events=new Phaser.Events(this);this.animations=new Phaser.AnimationManager(this);this.input=new Phaser.InputHandler(this);this.key=d;if(d instanceof Phaser.RenderTexture){PIXI.Sprite.call(this,d);this.currentFrame=this.game.cache.getTextureFrame(d.name)}else{if(d==null||this.game.cache.checkImageKey(d)==false){d="__default"}PIXI.Sprite.call(this,PIXI.TextureCache[d]);if(this.game.cache.isSpriteSheet(d)){this.animations.loadFrameData(this.game.cache.getFrameData(d));if(e!==null){if(typeof e==="string"){this.frameName=e}else{this.frame=e}}}else{this.currentFrame=this.game.cache.getFrame(d)}}this.anchor=new Phaser.Point();this._cropUUID=null;this._cropRect=null;this.x=b;this.y=f;this.position.x=b;this.position.y=f;this.autoCull=false;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,i01:0,i10:0,idi:1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),frameID:this.currentFrame.uuid,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:true};this.offset=new Phaser.Point;this.center=new Phaser.Point(b+Math.floor(this._cache.width/2),f+Math.floor(this._cache.height/2));this.topLeft=new Phaser.Point(b,f);this.topRight=new Phaser.Point(b+this._cache.width,f);this.bottomRight=new Phaser.Point(b+this._cache.width,f+this._cache.height);this.bottomLeft=new Phaser.Point(b,f+this._cache.height);this.bounds=new Phaser.Rectangle(b,f,this._cache.width,this._cache.height);this.body=new Phaser.Physics.Arcade.Body(this);this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds);this.inWorldThreshold=0;this._outOfBoundsFired=false};Phaser.Sprite.prototype=Object.create(PIXI.Sprite.prototype);Phaser.Sprite.prototype.constructor=Phaser.Sprite;Phaser.Sprite.prototype.preUpdate=function(){if(!this.exists){this.renderOrderID=-1;return}if(this.lifespan>0){this.lifespan-=this.game.time.elapsed;if(this.lifespan<=0){this.kill();return}}this._cache.dirty=false;if(this.animations.update()){this._cache.dirty=true}this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}if(this.visible){this.renderOrderID=this.game.world.currentRenderOrderID++;if(this.worldTransform[0]!=this._cache.a00||this.worldTransform[1]!=this._cache.a01){this._cache.a00=this.worldTransform[0];this._cache.a01=this.worldTransform[1];this._cache.i01=this.worldTransform[1];this._cache.scaleX=Math.sqrt((this._cache.a00*this._cache.a00)+(this._cache.a01*this._cache.a01));this._cache.a01*=-1;this._cache.dirty=true}if(this.worldTransform[3]!=this._cache.a10||this.worldTransform[4]!=this._cache.a11){this._cache.a10=this.worldTransform[3];this._cache.i10=this.worldTransform[3];this._cache.a11=this.worldTransform[4];this._cache.scaleY=Math.sqrt((this._cache.a10*this._cache.a10)+(this._cache.a11*this._cache.a11));this._cache.a10*=-1;this._cache.dirty=true}if(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12){this._cache.a02=this.worldTransform[2];this._cache.a12=this.worldTransform[5];this._cache.dirty=true}if(this.currentFrame.uuid!=this._cache.frameID){this._cache.frameWidth=this.texture.frame.width;this._cache.frameHeight=this.texture.frame.height;this._cache.frameID=this.currentFrame.uuid;this._cache.dirty=true}if(this._cache.dirty){this._cache.width=Math.floor(this.currentFrame.sourceSizeW*this._cache.scaleX);this._cache.height=Math.floor(this.currentFrame.sourceSizeH*this._cache.scaleY);this._cache.halfWidth=Math.floor(this._cache.width/2);this._cache.halfHeight=Math.floor(this._cache.height/2);this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10);this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10);this.updateBounds()}}else{if(this._cache.dirty&&this.visible==false){this.bounds.x-=this._cache.boundsX-this._cache.x;this._cache.boundsX=this._cache.x;this.bounds.y-=this._cache.boundsy-this._cache.y;this._cache.boundsY=this._cache.y}}if(this._cache.dirty){this._cache.cameraVisible=Phaser.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0);if(this.autoCull==true){this.visible=this._cache.cameraVisible}this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)}this.body.update()};Phaser.Sprite.prototype.revive=function(){this.alive=true;this.exists=true;this.visible=true;this.events.onRevived.dispatch(this)};Phaser.Sprite.prototype.kill=function(){this.alive=false;this.exists=false;this.visible=false;this.events.onKilled.dispatch(this)};Phaser.Sprite.prototype.reset=function(b,c){this.x=b;this.y=c;this.position.x=b;this.position.y=c;this.alive=true;this.exists=true;this.visible=true;this._outOfBoundsFired=false;this.body.reset()};Phaser.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-(this.anchor.x*this._cache.width),this._cache.a12-(this.anchor.y*this._cache.height));this.getLocalPosition(this.center,this.offset.x+this._cache.halfWidth,this.offset.y+this._cache.halfHeight);this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y);this.getLocalPosition(this.topRight,this.offset.x+this._cache.width,this.offset.y);this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this._cache.height);this.getLocalPosition(this.bottomRight,this.offset.x+this._cache.width,this.offset.y+this._cache.height);this._cache.left=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.right=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.top=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this._cache.bottom=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top);this._cache.boundsX=this._cache.x;this._cache.boundsY=this._cache.y;if(this.inWorld==false){this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld){this._outOfBoundsFired=false}}else{this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld==false){this.events.onOutOfBounds.dispatch(this);this._outOfBoundsFired=true}}};Phaser.Sprite.prototype.getLocalPosition=function(c,b,d){c.x=((this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*d+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this._cache.scaleX)+this._cache.a02;c.y=((this._cache.a00*this._cache.id*d+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this._cache.scaleY)+this._cache.a12;return c};Phaser.Sprite.prototype.getLocalUnmodifiedPosition=function(c,b,d){c.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*d+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi;c.y=this._cache.a00*this._cache.idi*d+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi;return c};Phaser.Sprite.prototype.bringToTop=function(){if(this.group){this.group.bringToTop(this)}else{this.game.world.bringToTop(this)}};Phaser.Sprite.prototype.getBounds=function(d){d=d||new Phaser.Rectangle;var f=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var c=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var e=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);var b=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);d.x=f;d.y=e;d.width=c-f;d.height=b-e;return d};Object.defineProperty(Phaser.Sprite.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(b){this.animations.frame=b}});Object.defineProperty(Phaser.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(b){this.animations.frameName=b}});Object.defineProperty(Phaser.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}});Object.defineProperty(Phaser.Sprite.prototype,"crop",{get:function(){return this._cropRect},set:function(b){if(b instanceof Phaser.Rectangle){if(this._cropUUID==null){this._cropUUID=this.game.rnd.uuid();PIXI.TextureCache[this._cropUUID]=new PIXI.Texture(PIXI.BaseTextureCache[this.key],{x:b.x,y:b.y,width:b.width,height:b.height})}else{PIXI.TextureCache[this._cropUUID].frame=b}this._cropRect=b;this.setTexture(PIXI.TextureCache[this._cropUUID])}}});Object.defineProperty(Phaser.Sprite.prototype,"inputEnabled",{get:function(){return(this.input.enabled)},set:function(b){if(b){if(this.input.enabled==false){this.input.start()}}else{if(this.input.enabled){this.input.stop()}}}});Phaser.TileSprite=function(d,c,h,f,b,e,g){c=c||0;h=h||0;f=f||256;b=b||256;e=e||null;g=g||null;Phaser.Sprite.call(this,d,c,h,e,g);this.texture=PIXI.TextureCache[e];PIXI.TilingSprite.call(this,this.texture,f,b);this.tileScale=new Phaser.Point(1,1);this.tilePosition=new Phaser.Point(0,0)};Phaser.TileSprite.prototype=Phaser.Utils.extend(true,PIXI.TilingSprite.prototype,Phaser.Sprite.prototype);Phaser.TileSprite.prototype.constructor=Phaser.TileSprite;Phaser.Text=function(c,b,g,f,d){b=b||0;g=g||0;f=f||"";d=d||"";this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");var e=c.rnd.uuid();PIXI.TextureCache[e]=new PIXI.Texture(new PIXI.BaseTexture(this.canvas));Phaser.Sprite.call(this,c,b,g,e);this.setText(f);this.setStyle(d);this.updateText();this.dirty=false};Phaser.Text.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Text.prototype);Phaser.Text.prototype.constructor=Phaser.Text;Phaser.Button=function(j,g,f,h,i,c,d,b,e){g=g||0;f=f||0;h=h||null;i=i||null;c=c||this;Phaser.Sprite.call(this,j,g,f,h,b);this._onOverFrameName=null;this._onOutFrameName=null;this._onDownFrameName=null;this._onUpFrameName=null;this._onOverFrameID=null;this._onOutFrameID=null;this._onDownFrameID=null;this._onUpFrameID=null;this.onInputOver=new Phaser.Signal;this.onInputOut=new Phaser.Signal;this.onInputDown=new Phaser.Signal;this.onInputUp=new Phaser.Signal;this.setFrames(d,b,e);if(i!==null){this.onInputUp.add(i,c)}this.input.start(0,false,true);this.events.onInputOver.add(this.onInputOverHandler,this);this.events.onInputOut.add(this.onInputOutHandler,this);this.events.onInputDown.add(this.onInputDownHandler,this);this.events.onInputUp.add(this.onInputUpHandler,this)};Phaser.Button.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Sprite.prototype);Phaser.Button.prototype.constructor=Phaser.Button;Phaser.Button.prototype.setFrames=function(c,d,b){if(c!==null){if(typeof c==="string"){this._onOverFrameName=c}else{this._onOverFrameID=c}}if(d!==null){if(typeof d==="string"){this._onOutFrameName=d;this._onUpFrameName=d}else{this._onOutFrameID=d;this._onUpFrameID=d}}if(b!==null){if(typeof b==="string"){this._onDownFrameName=b}else{this._onDownFrameID=b}}};Phaser.Button.prototype.onInputOverHandler=function(b){if(this._onOverFrameName!=null){this.frameName=this._onOverFrameName}else{if(this._onOverFrameID!=null){this.frame=this._onOverFrameID}}if(this.onInputOver){this.onInputOver.dispatch(this,b)}};Phaser.Button.prototype.onInputOutHandler=function(b){if(this._onOutFrameName!=null){this.frameName=this._onOutFrameName}else{if(this._onOutFrameID!=null){this.frame=this._onOutFrameID}}if(this.onInputOut){this.onInputOut.dispatch(this,b)}};Phaser.Button.prototype.onInputDownHandler=function(b){if(this._onDownFrameName!=null){this.frameName=this._onDownFrameName}else{if(this._onDownFrameID!=null){this.frame=this._onDownFrameID}}if(this.onInputDown){this.onInputDown.dispatch(this,b)}};Phaser.Button.prototype.onInputUpHandler=function(b){if(this._onUpFrameName!=null){this.frameName=this._onUpFrameName}else{if(this._onUpFrameID!=null){this.frame=this._onUpFrameID}}if(this.onInputUp){this.onInputUp.dispatch(this,b)}};Phaser.Graphics=function(c,b,d){this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.DisplayObjectContainer.call(this);this.position.x=b;this.position.y=d;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:d,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};Phaser.Graphics.prototype=Phaser.Utils.extend(true,PIXI.Graphics.prototype,PIXI.DisplayObjectContainer.prototype,Phaser.Sprite.prototype);Phaser.Graphics.prototype.constructor=Phaser.Graphics;Phaser.Graphics.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}};Object.defineProperty(Phaser.Graphics.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.RenderTexture=function(c,d,e,b){this.game=c;this.name=d;PIXI.EventTarget.call(this);this.width=e||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};Phaser.RenderTexture.prototype=Phaser.Utils.extend(true,PIXI.RenderTexture.prototype);Phaser.RenderTexture.prototype.constructor=Phaser.RenderTexture;Phaser.BitmapText=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.BitmapText.call(this,e,d);this.position.x=b;this.position.y=f;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.BitmapText.prototype=Phaser.Utils.extend(true,PIXI.BitmapText.prototype);Phaser.BitmapText.prototype.constructor=Phaser.BitmapText;Phaser.BitmapText.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}};Object.defineProperty(Phaser.BitmapText.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";d=d||true;if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b)}else{document.body.appendChild(b)}if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.StageScaleMode=function(c,d,b){this._startHeight=0;this.forceLandscape=false;this.forcePortrait=false;this.incorrectOrientation=false;this.pageAlignHorizontally=false;this.pageAlignVeritcally=false;this.minWidth=null;this.maxWidth=null;this.minHeight=null;this.maxHeight=null;this.width=0;this.height=0;this.maxIterations=5;this.game=c;this.enterLandscape=new Phaser.Signal();this.enterPortrait=new Phaser.Signal();if(window.orientation){this.orientation=window.orientation}else{if(window.outerWidth>window.outerHeight){this.orientation=90}else{this.orientation=0}}this.scaleFactor=new Phaser.Point(1,1);this.aspectRatio=0;var e=this;window.addEventListener("orientationchange",function(f){return e.checkOrientation(f)},false);window.addEventListener("resize",function(f){return e.checkResize(f)},false)};Phaser.StageScaleMode.EXACT_FIT=0;Phaser.StageScaleMode.NO_SCALE=1;Phaser.StageScaleMode.SHOW_ALL=2;Phaser.StageScaleMode.prototype={startFullScreen:function(){if(this.isFullScreen){return}var b=this.game.canvas;if(b.requestFullScreen){b.requestFullScreen()}else{if(b.mozRequestFullScreen){b.mozRequestFullScreen()}else{if(b.webkitRequestFullScreen){b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}}}this.game.stage.canvas.style.width="100%";this.game.stage.canvas.style.height="100%"},stopFullScreen:function(){if(document.cancelFullScreen){document.cancelFullScreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}}}},checkOrientationState:function(){if(this.incorrectOrientation){if((this.forceLandscape&&window.innerWidth>window.innerHeight)||(this.forcePortrait&&window.innerHeight>window.innerWidth)){this.game.paused=false;this.incorrectOrientation=false;this.refresh()}}else{if((this.forceLandscape&&window.innerWidthwindow.outerHeight){this.orientation=90}else{this.orientation=0}if(this.isLandscape){this.enterLandscape.dispatch(this.orientation,true,false)}else{this.enterPortrait.dispatch(this.orientation,false,true)}if(this.game.stage.scaleMode!==Phaser.StageScaleMode.NO_SCALE){this.refresh()}},refresh:function(){var b=this;if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}if(this._check==null&&this.maxIterations>0){this._iterations=this.maxIterations;this._check=window.setInterval(function(){return b.setScreenSize()},10);this.setScreenSize()}},setScreenSize:function(b){if(typeof b=="undefined"){b=false}if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}this._iterations--;if(b||window.innerHeight>this._startHeight||this._iterations<0){document.documentElement.style.minHeight=window.innerHeight+"px";if(this.incorrectOrientation==true){this.setMaximum()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.EXACT_FIT){this.setExactFit()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.SHOW_ALL){this.setShowAll()}}}this.setSize();clearInterval(this._check);this._check=null}},setSize:function(){if(this.incorrectOrientation==false){if(this.maxWidth&&this.width>this.maxWidth){this.width=this.maxWidth}if(this.maxHeight&&this.height>this.maxHeight){this.height=this.maxHeight}if(this.minWidth&&this.widththis.maxWidth){this.width=this.maxWidth}else{this.width=b}if(this.maxHeight&&c>this.maxHeight){this.height=this.maxHeight}else{this.height=c}console.log("setExactFit",this.width,this.height,this.game.stage.offset)}};Object.defineProperty(Phaser.StageScaleMode.prototype,"isFullScreen",{get:function(){if(document.fullscreenElement===null||document.mozFullScreenElement===null||document.webkitFullscreenElement===null){return false}return true}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isPortrait",{get:function(){return this.orientation==0||this.orientation==180}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isLandscape",{get:function(){return this.orientation===90||this.orientation===-90}});Phaser.Device=function(){this.patchAndroidClearRectBug=false;this.desktop=false;this.iOS=false;this.android=false;this.chromeOS=false;this.linux=false;this.macOS=false;this.windows=false;this.canvas=false;this.file=false;this.fileSystem=false;this.localStorage=false;this.webGL=false;this.worker=false;this.touch=false;this.mspointer=false;this.css3D=false;this.pointerLock=false;this.arora=false;this.chrome=false;this.epiphany=false;this.firefox=false;this.ie=false;this.ieVersion=0;this.mobileSafari=false;this.midori=false;this.opera=false;this.safari=false;this.webApp=false;this.audioData=false;this.webAudio=false;this.ogg=false;this.opus=false;this.mp3=false;this.wav=false;this.m4a=false;this.webm=false;this.iPhone=false;this.iPhone4=false;this.iPad=false;this.pixelRatio=0;this._checkAudio();this._checkBrowser();this._checkCSS3D();this._checkDevice();this._checkFeatures();this._checkOS()};Phaser.Device.prototype={_checkOS:function(){var b=navigator.userAgent;if(/Android/.test(b)){this.android=true}else{if(/CrOS/.test(b)){this.chromeOS=true}else{if(/iP[ao]d|iPhone/i.test(b)){this.iOS=true}else{if(/Linux/.test(b)){this.linux=true}else{if(/Mac OS/.test(b)){this.macOS=true}else{if(/Windows/.test(b)){this.windows=true}}}}}}if(this.windows||this.macOS||this.linux){this.desktop=true}},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(b){this.localStorage=false}this.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob;this.fileSystem=!!window.requestFileSystem;this.webGL=(function(){try{return !!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(c){return false}})();this.worker=!!window.Worker;if("ontouchstart" in document.documentElement||window.navigator.msPointerEnabled){this.touch=true}if(window.navigator.msPointerEnabled){this.mspointer=true}this.pointerLock="pointerLockElement" in document||"mozPointerLockElement" in document||"webkitPointerLockElement" in document},_checkBrowser:function(){var b=navigator.userAgent;if(/Arora/.test(b)){this.arora=true}else{if(/Chrome/.test(b)){this.chrome=true}else{if(/Epiphany/.test(b)){this.epiphany=true}else{if(/Firefox/.test(b)){this.firefox=true}else{if(/Mobile Safari/.test(b)){this.mobileSafari=true}else{if(/MSIE (\d+\.\d+);/.test(b)){this.ie=true;this.ieVersion=parseInt(RegExp.$1)}else{if(/Midori/.test(b)){this.midori=true}else{if(/Opera/.test(b)){this.opera=true}else{if(/Safari/.test(b)){this.safari=true}}}}}}}}}if(navigator.standalone){this.webApp=true}},_checkAudio:function(){this.audioData=!!(window.Audio);this.webAudio=!!(window.webkitAudioContext||window.AudioContext);var d=document.createElement("audio");var b=false;try{if(b=!!d.canPlayType){if(d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")){this.ogg=true}if(d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")){this.opus=true}if(d.canPlayType("audio/mpeg;").replace(/^no$/,"")){this.mp3=true}if(d.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")){this.wav=true}if(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/aac;").replace(/^no$/,"")){this.m4a=true}if(d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")){this.webm=true}}}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1;this.iPhone=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1;this.iPhone4=(this.pixelRatio==2&&this.iPhone);this.iPad=navigator.userAgent.toLowerCase().indexOf("ipad")!=-1},_checkCSS3D:function(){var d=document.createElement("p");var e;var c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(d,null);for(var b in c){if(d.style[b]!==undefined){d.style[b]="translate3d(1px,1px,1px)";e=window.getComputedStyle(d).getPropertyValue(c[b])}}document.body.removeChild(d);this.css3D=(e!==undefined&&e.length>0&&e!=="none")},canPlayAudio:function(b){if(b=="mp3"&&this.mp3){return true}else{if(b=="ogg"&&(this.ogg||this.opus)){return true}else{if(b=="m4a"&&this.m4a){return true}else{if(b=="wav"&&this.wav){return true}else{if(b=="webm"&&this.webm){return true}}}}}return false},isConsoleOpen:function(){if(window.console&&window.console.firebug){return true}if(window.console){console.profile();console.profileEnd();if(console.clear){console.clear()}return console.profiles.length>0}return false}};Phaser.RequestAnimationFrame=function(c){this.game=c;this._isSetTimeOut=false;this.isRunning=false;var d=["ms","moz","webkit","o"];for(var b=0;b>>0;c-=e;c*=e;e=c>>>0;c-=e;e+=c*4294967296}return(e>>>0)*2.3283064365386963e-10},integer:function(){return this.rnd.apply(this)*4294967296},frac:function(){return this.rnd.apply(this)+(this.rnd.apply(this)*2097152|0)*1.1102230246251565e-16},real:function(){return this.integer()+this.frac()},integerInRange:function(c,b){return Math.floor(this.realInRange(c,b))},realInRange:function(c,b){c=c||0;b=b||0;return this.frac()*(b-c)+c},normal:function(){return 1-2*this.frac()},uuid:function(){var d,c;for(c=d="";d++<36;c+=~d%5|d*3&4?(d^15?8^this.frac()*(d^20?16:4):4).toString(16):"-"){}return c},pick:function(b){return b[this.integerInRange(0,b.length)]},weightedPick:function(b){return b[~~(Math.pow(this.frac(),2)*b.length)]},timestamp:function(d,c){return this.realInRange(d||946684800000,c||1577862000000)},angle:function(){return this.integerInRange(-180,180)}};Phaser.Math={PI2:Math.PI*2,fuzzyEqual:function(d,c,e){if(typeof e==="undefined"){e=0.0001}return Math.abs(d-c)c-e},fuzzyCeil:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.ceil(b-c)},fuzzyFloor:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.floor(b+c)},average:function(){var b=[];for(var d=0;d<(arguments.length-0);d++){b[d]=arguments[d+0]}var e=0;for(var c=0;c0)?Math.floor(b):Math.ceil(b)},shear:function(b){return b%1},snapTo:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.round(b/d);return c+b},snapToFloor:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.floor(b/d);return c+b},snapToCeil:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.ceil(b/d);return c+b},snapToInArray:function(d,c,f){if(typeof f==="undefined"){f=true}if(f){c.sort()}if(dd/2){c+=d*2}if(b<-d/2&&c>d/2){b+=d*2}return b-c},interpolateAngles:function(c,b,d,e,f){if(typeof e==="undefined"){e=true}if(typeof f==="undefined"){f=null}c=this.normalizeAngle(c,e);b=this.normalizeAngleToAnother(b,c,e);return(typeof f==="function")?f(d,c,b-c,1):this.interpolateFloat(c,b,d)},chanceRoll:function(b){if(typeof b==="undefined"){b=50}if(b<=0){return false}else{if(b>=100){return true}else{if(Math.random()*100>=b){return false}else{return true}}}},maxAdd:function(d,c,b){d+=c;if(d>b){d=b}return d},minSub:function(d,c,b){d-=c;if(d0.5)?1:-1},isOdd:function(b){return(b&1)},isEven:function(b){if(b&1){return false}else{return true}},max:function(){for(var d=1,c=0,b=arguments.length;d=-180&&c<=180){return c}b=(c+180)%360;if(b<0){b+=360}return b-180},angleLimit:function(e,d,c){var b=e;if(e>c){b=c}else{if(e1){return this.linear(d[b],d[b-1],b-g)}return this.linear(d[e],d[e+1>b?b:e+1],g-e)},bezierInterpolation:function(e,d){var c=0;var g=e.length-1;for(var f=0;f<=g;f++){c+=Math.pow(1-d,g-f)*Math.pow(d,f)*e[f]*this.bernstein(g,f)}return c},catmullRomInterpolation:function(d,c){var b=d.length-1;var g=b*c;var e=Math.floor(g);if(d[0]===d[b]){if(c<0){e=Math.floor(g=b*(1+c))}return this.catmullRom(d[(e-1+b)%b],d[e],d[(e+1)%b],d[(e+2)%b],g-e)}else{if(c<0){return d[0]-(this.catmullRom(d[0],d[0],d[1],d[1],-g)-d[0])}if(c>1){return d[b]-(this.catmullRom(d[b],d[b],d[b-1],d[b-1],g-b)-d[b])}return this.catmullRom(d[e?e-1:0],d[e],d[bd.length-e)){b=d.length-e}if(b>0){return d[e+Math.floor(Math.random()*b)]}}return null},floor:function(b){var c=b|0;return(b>0)?(c):((c!=b)?(c-1):(c))},ceil:function(b){var c=b|0;return(b>0)?((c!=b)?(c+1):(c)):(c)},sinCosGenerator:function(b,j,d,h){if(typeof j==="undefined"){j=1}if(typeof d==="undefined"){d=1}if(typeof h==="undefined"){h=1}var i=j;var l=d;var f=h*Math.PI/b;var e=[];var k=[];for(var g=0;g0;d--){var c=Math.floor(Math.random()*(d+1));var b=e[d];e[d]=e[c];e[c]=b}return e},distance:function(e,g,d,f){var c=e-d;var b=g-f;return Math.sqrt(c*c+b*b)},distanceRounded:function(c,e,b,d){return Math.round(Phaser.Math.distance(c,e,b,d))},clamp:function(d,e,c){return(dc)?c:d)},clampBottom:function(b,c){return b=b){return 1}c=(c-d)/(b-d);return c*c*(3-2*c)},smootherstep:function(c,d,b){if(c<=d){return 0}if(c>=b){return 1}c=(c-d)/(b-d);return c*c*c*(c*(c*6-15)+10)},sign:function(b){return(b<0)?-1:((b>0)?1:0)},degToRad:function(){var b=Math.PI/180;return function(c){return c*b}}(),radToDeg:function(){var b=180/Math.PI;return function(c){return c*b}}()};Phaser.QuadTree=function(g,c,i,f,b,e,d,h){this.physicsManager=g;this.ID=g.quadTreeID;g.quadTreeID++;this.maxObjects=e||10;this.maxLevels=d||4;this.level=h||0;this.bounds={x:Math.round(c),y:Math.round(i),width:f,height:b,subWidth:Math.floor(f/2),subHeight:Math.floor(b/2),right:Math.round(c)+Math.floor(f/2),bottom:Math.round(i)+Math.floor(b/2)};this.objects=[];this.nodes=[]};Phaser.QuadTree.prototype={split:function(){this.level++;this.nodes[0]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[1]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[2]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[3]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(b){var d=0;var c;if(this.nodes[0]!=null){c=this.getIndex(b);if(c!==-1){this.nodes[c].insert(b);return}}this.objects.push(b);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom)){b=2}}}else{if(c.x>this.bounds.right){if((c.ythis.bounds.bottom)){b=3}}}}return b},retrieve:function(b){var c=this.objects;b.body.quadTreeIndex=this.getIndex(b.body);b.body.quadTreeIDs.push(this.ID);if(this.nodes[0]){if(b.body.quadTreeIndex!==-1){c=c.concat(this.nodes[b.body.quadTreeIndex].retrieve(b))}else{c=c.concat(this.nodes[0].retrieve(b));c=c.concat(this.nodes[1].retrieve(b));c=c.concat(this.nodes[2].retrieve(b));c=c.concat(this.nodes[3].retrieve(b))}}return c},clear:function(){this.objects=[];for(var c=0,b=this.nodes.length;c0){this._radius=c*0.5}else{this._radius=0}};Phaser.Circle.prototype={circumference:function(){return 2*(Math.PI*this._radius)},setTo:function(b,d,c){this.x=b;this.y=d;this._diameter=c;this._radius=c*0.5;return this},copyFrom:function(b){return this.setTo(b.x,b.y,b.diameter)},copyTo:function(b){b[x]=this.x;b[y]=this.y;b[diameter]=this._diameter;return b},distance:function(c,b){if(typeof b==="undefined"){b=false}if(b){return Phaser.Math.distanceRound(this.x,this.y,c.x,c.y)}else{return Phaser.Math.distance(this.x,this.y,c.x,c.y)}},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Circle()}return b.setTo(a.x,a.y,a.diameter)},contains:function(b,c){return Phaser.Circle.contains(this,b,c)},circumferencePoint:function(d,c,b){return Phaser.Circle.circumferencePoint(this,d,c,b)},offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}};Object.defineProperty(Phaser.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(b){if(b>0){this._diameter=b;this._radius=b*0.5}}});Object.defineProperty(Phaser.Circle.prototype,"radius",{get:function(){return this._radius},set:function(b){if(b>0){this._radius=b;this._diameter=b*2}}});Object.defineProperty(Phaser.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(b){if(b>this.x){this._radius=0;this._diameter=0}else{this.radius=this.x-b}}});Object.defineProperty(Phaser.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(b){if(bthis.y){this._radius=0;this._diameter=0}else{this.radius=this.y-b}}});Object.defineProperty(Phaser.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(b){if(b0){return Math.PI*this._radius*this._radius}else{return 0}}});Object.defineProperty(Phaser.Circle.prototype,"empty",{get:function(){return(this._diameter==0)},set:function(b){this.setTo(0,0,0)}});Phaser.Circle.contains=function(d,b,f){if(b>=d.left&&b<=d.right&&f>=d.top&&f<=d.bottom){var e=(d.x-b)*(d.x-b);var c=(d.y-f)*(d.y-f);return(e+c)<=(d.radius*d.radius)}return false};Phaser.Circle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.diameter==c.diameter)};Phaser.Circle.intersects=function(d,c){return(Phaser.Math.distance(d.x,d.y,c.x,c.y)<=(d.radius+c.radius))};Phaser.Circle.circumferencePoint=function(b,e,d,c){if(typeof d==="undefined"){d=false}if(typeof c==="undefined"){c=new Phaser.Point()}if(d===true){e=Phaser.Math.radToDeg(e)}c.x=b.x+b.radius*Math.cos(e);c.y=b.y+b.radius*Math.sin(e);return c};Phaser.Circle.intersectsRectangle=function(m,d){var g=Math.abs(m.x-d.x-d.halfWidth);var l=d.halfWidth+m.radius;if(g>l){return false}var f=Math.abs(m.y-d.y-d.halfHeight);var j=d.halfHeight+m.radius;if(f>j){return false}if(g<=d.halfWidth||f<=d.halfHeight){return true}var h=g-d.halfWidth;var e=f-d.halfHeight;var k=h*h;var b=e*e;var i=m.radius*m.radius;return k+b<=i};Phaser.Point=function(b,c){b=b||0;c=c||0;this.x=b;this.y=c};Phaser.Point.prototype={copyFrom:function(b){return this.setTo(b.x,b.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(b,c){this.x=b;this.y=c;return this},add:function(b,c){this.x+=b;this.y+=c;return this},subtract:function(b,c){this.x-=b;this.y-=c;return this},multiply:function(b,c){this.x*=b;this.y*=c;return this},divide:function(b,c){this.x/=b;this.y/=c;return this},clampX:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);return this},clampY:function(c,b){this.y=Phaser.Math.clamp(this.y,c,b);return this},clamp:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);this.y=Phaser.Math.clamp(this.y,c,b);return this},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Point}return b.setTo(this.x,this.y)},copyFrom:function(b){return this.setTo(b.x,b.y)},copyTo:function(b){b[x]=this.x;b[y]=this.y;return b},distance:function(c,b){return Phaser.Point.distance(this,c,b)},equals:function(b){return(b.x==this.x&&b.y==this.y)},rotate:function(b,f,d,c,e){return Phaser.Point.rotate(this,b,f,d,c,e)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};Phaser.Point.add=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x+c.x;e.y=d.y+c.y;return e};Phaser.Point.subtract=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x-c.x;e.y=d.y-c.y;return e};Phaser.Point.multiply=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x*c.x;e.y=d.y*c.y;return e};Phaser.Point.divide=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x/c.x;e.y=d.y/c.y;return e};Phaser.Point.equals=function(d,c){return(d.x==c.x&&d.y==c.y)};Phaser.Point.distance=function(d,c,e){if(typeof e==="undefined"){e=false}if(e){return Phaser.Math.distanceRound(d.x,d.y,c.x,c.y)}else{return Phaser.Math.distance(d.x,d.y,c.x,c.y)}},Phaser.Point.rotate=function(c,b,g,e,d,f){d=d||false;f=f||null;if(d){e=Phaser.Math.radToDeg(e)}if(f===null){f=Math.sqrt(((b-c.x)*(b-c.x))+((g-c.y)*(g-c.y)))}return c.setTo(b+f*Math.cos(e),g+f*Math.sin(e))};Phaser.Rectangle=function(c,e,d,b){c=c||0;e=e||0;d=d||0;b=b||0;this.x=c;this.y=e;this.width=d;this.height=b};Phaser.Rectangle.prototype={offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},setTo:function(c,e,d,b){this.x=c;this.y=e;this.width=d;this.height=b;return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},copyFrom:function(b){return this.setTo(b.x,b.y,b.width,b.height)},copyTo:function(b){b.x=this.x;b.y=this.y;b.width=this.width;b.height=this.height;return b},inflate:function(c,b){return Phaser.Rectangle.inflate(this,c,b)},size:function(b){return Phaser.Rectangle.size(this,b)},clone:function(b){return Phaser.Rectangle.clone(this,b)},contains:function(b,c){return Phaser.Rectangle.contains(this,b,c)},containsRect:function(c){return Phaser.Rectangle.containsRect(this,c)},equals:function(c){return Phaser.Rectangle.equals(this,c)},intersection:function(c,d){return Phaser.Rectangle.intersection(this,c,output)},intersects:function(c,d){return Phaser.Rectangle.intersects(this,c,d)},intersectsRaw:function(f,d,e,c,b){return Phaser.Rectangle.intersectsRaw(this,f,d,e,c,b)},union:function(c,d){return Phaser.Rectangle.union(this,c,d)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(Phaser.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"bottomRight",{get:function(){return new Phaser.Point(this.right,this.bottom)},set:function(b){this.right=b.x;this.bottom=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"left",{get:function(){return this.x},set:function(b){if(b>=this.right){this.width=0}else{this.width=this.right-b}this.x=b}});Object.defineProperty(Phaser.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Object.defineProperty(Phaser.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(Phaser.Rectangle.prototype,"perimeter",{get:function(){return(this.width*2)+(this.height*2)}});Object.defineProperty(Phaser.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(b){this.x=b-this.halfWidth}});Object.defineProperty(Phaser.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(b){this.y=b-this.halfHeight}});Object.defineProperty(Phaser.Rectangle.prototype,"top",{get:function(){return this.y},set:function(b){if(b>=this.bottom){this.height=0;this.y=b}else{this.height=(this.bottom-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"topLeft",{get:function(){return new Phaser.Point(this.x,this.y)},set:function(b){this.x=b.x;this.y=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"empty",{get:function(){return(!this.width||!this.height)},set:function(b){this.setTo(0,0,0,0)}});Phaser.Rectangle.inflate=function(c,d,b){c.x-=d;c.width+=2*d;c.y-=b;c.height+=2*b;return c};Phaser.Rectangle.inflatePoint=function(c,b){return Phaser.Phaser.Rectangle.inflate(c,b.x,b.y)};Phaser.Rectangle.size=function(b,c){if(typeof c==="undefined"){c=new Phaser.Point()}return c.setTo(b.width,b.height)};Phaser.Rectangle.clone=function(b,c){if(typeof c==="undefined"){c=new Phaser.Rectangle()}return c.setTo(b.x,b.y,b.width,b.height)};Phaser.Rectangle.contains=function(c,b,d){return(b>=c.x&&b<=c.right&&d>=c.y&&d<=c.bottom)};Phaser.Rectangle.containsPoint=function(c,b){return Phaser.Phaser.Rectangle.contains(c,b.x,b.y)};Phaser.Rectangle.containsRect=function(d,c){if(d.volume>c.volume){return false}return(d.x>=c.x&&d.y>=c.y&&d.right<=c.right&&d.bottom<=c.bottom)};Phaser.Rectangle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.width==c.width&&d.height==c.height)};Phaser.Rectangle.intersection=function(d,c,e){e=e||new Phaser.Rectangle;if(Phaser.Rectangle.intersects(d,c)){e.x=Math.max(d.x,c.x);e.y=Math.max(d.y,c.y);e.width=Math.min(d.right,c.right)-e.x;e.height=Math.min(d.bottom,c.bottom)-e.y}return e};Phaser.Rectangle.intersects=function(d,c,e){e=e||0;return !(d.left>c.right+e||d.rightc.bottom+e||d.bottomb.right+c||eb.bottom+c||d1){if(f&&f==this.decodeURI(d[0])){return this.decodeURI(d[1])}else{c[this.decodeURI(d[0])]=this.decodeURI(d[1])}}}return c},decodeURI:function(b){return decodeURIComponent(b.replace(/\+/g," "))}};Phaser.TweenManager=function(b){this.game=b;this._tweens=[];this.game.onPause.add(this.pauseAll,this);this.game.onResume.add(this.resumeAll,this)};Phaser.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(b){this._tweens.push(b)},create:function(b){return new Phaser.Tween(b,this.game)},remove:function(c){var b=this._tweens.indexOf(c);if(b!==-1){this._tweens.splice(b,1)}},update:function(){if(this._tweens.length===0){return false}var b=0,c=this._tweens.length;while(b=0;b--){this._tweens[b].pause()}},resumeAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].resume()}}};Phaser.Tween=function(c,b){this._object=c;this.game=b;this._manager=this.game.tweens;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1000;this._repeat=0;this._yoyo=false;this._reversed=false;this._delayTime=0;this._startTime=null;this._easingFunction=Phaser.Easing.Linear.None;this._interpolationFunction=Phaser.Math.linearInterpolation;this._chainedTweens=[];this._onStartCallback=null;this._onStartCallbackFired=false;this._onUpdateCallback=null;this._onCompleteCallback=null;this._pausedTime=0;for(var d in c){this._valuesStart[d]=parseFloat(c[d],10)}this.onStart=new Phaser.Signal();this.onComplete=new Phaser.Signal();this.isRunning=false};Phaser.Tween.prototype={to:function(d,g,h,c,b,f,e){g=g||1000;h=h||null;c=c||false;b=b||0;f=f||0;e=e||false;this._repeat=f;this._duration=g;this._valuesEnd=d;if(h!==null){this._easingFunction=h}if(b>0){this._delayTime=b}this._yoyo=e;if(c){return this.start()}else{return this}},start:function(c){if(this.game===null||this._object===null){return}this._manager.add(this);this.onStart.dispatch(this._object);this.isRunning=true;this._onStartCallbackFired=false;this._startTime=this.game.time.now+this._delayTime;for(var b in this._valuesEnd){if(this._valuesEnd[b] instanceof Array){if(this._valuesEnd[b].length===0){continue}this._valuesEnd[b]=[this._object[b]].concat(this._valuesEnd[b])}this._valuesStart[b]=this._object[b];if((this._valuesStart[b] instanceof Array)===false){this._valuesStart[b]*=1}this._valuesStartRepeat[b]=this._valuesStart[b]||0}return this},stop:function(){this._manager.remove(this);this.isRunning=false;return this},delay:function(b){this._delayTime=b;return this},repeat:function(b){this._repeat=b;return this},yoyo:function(b){this._yoyo=b;return this},easing:function(b){this._easingFunction=b;return this},interpolation:function(b){this._interpolationFunction=b;return this},chain:function(){this._chainedTweens=arguments;return this},onStart:function(b){this._onStartCallback=b;return this},onUpdate:function(b){this._onUpdateCallback=b;return this},onComplete:function(b){this._onCompleteCallback=b;return this},pause:function(){this._paused=true},resume:function(){this._paused=false;this._startTime+=this.game.time.pauseDuration},update:function(c){if(this._paused||c1?1:k;var h=this._easingFunction(k);for(j in this._valuesEnd){var b=this._valuesStart[j]||0;var d=this._valuesEnd[j];if(d instanceof Array){this._object[j]=this._interpolationFunction(d,h)}else{if(typeof(d)==="string"){d=b+parseFloat(d,10)}if(typeof(d)==="number"){this._object[j]=b+(d-b)*h}}}if(this._onUpdateCallback!==null){this._onUpdateCallback.call(this._object,h)}if(k==1){if(this._repeat>0){if(isFinite(this._repeat)){this._repeat--}for(j in this._valuesStartRepeat){if(typeof(this._valuesEnd[j])==="string"){this._valuesStartRepeat[j]=this._valuesStartRepeat[j]+parseFloat(this._valuesEnd[j],10)}if(this._yoyo){var e=this._valuesStartRepeat[j];this._valuesStartRepeat[j]=this._valuesEnd[j];this._valuesEnd[j]=e;this._reversed=!this._reversed}this._valuesStart[j]=this._valuesStartRepeat[j]}this._startTime=c+this._delayTime;this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}return true}else{this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}for(var f=0,g=this._chainedTweens.length;fthis._timeLastSecond+1000){this.fps=Math.round((this.frames*1000)/(this.now-this._timeLastSecond));this.fpsMin=Math.min(this.fpsMin,this.fps);this.fpsMax=Math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0}this.time=this.now;this.lastTime=b+this.timeToCall;this.physicsElapsed=1*(this.elapsed/1000);if(this.game.paused){this.pausedTime=this.now-this._pauseStarted}},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.elapsed=0;this.physicsElapsed=0;this.pauseDuration=this.pausedTime},elapsedSince:function(b){return this.now-b},elapsedSecondsSince:function(b){return(this.now-b)*0.001},reset:function(){this._started=this.now}};Phaser.AnimationManager=function(b){this._frameData=null;this.currentFrame=null;this.sprite=b;this.game=b.game;this._anims={};this.updateIfVisible=true};Phaser.AnimationManager.prototype={loadFrameData:function(b){this._frameData=b;this.frame=0},add:function(e,f,d,c,b){f=f||null;d=d||60;c=c||false;b=b||true;if(this._frameData==null){console.warn("No frameData available for Phaser.Animation "+e);return}if(this.sprite.events.onAnimationStart==null){this.sprite.events.onAnimationStart=new Phaser.Signal();this.sprite.events.onAnimationComplete=new Phaser.Signal();this.sprite.events.onAnimationLoop=new Phaser.Signal()}if(f==null){f=this._frameData.getFrameIndexes()}else{if(this.validateFrames(f,b)==false){console.warn("Invalid frames given to Phaser.Animation "+e);return}}if(b==false){f=this._frameData.getFrameIndexesByName(f)}this._anims[e]=new Phaser.Animation(this.game,this.sprite,this._frameData,e,f,d,c);this.currentAnim=this._anims[e];this.currentFrame=this.currentAnim.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this._anims[e]},validateFrames:function(d,b){for(var c=0;cthis._frameData.total){return false}}else{if(this._frameData.checkFrameName(d[c])==false){return false}}}return true},play:function(d,c,b){c=c||null;b=b||null;if(this._anims[d]){if(this.currentAnim==this._anims[d]){if(this.currentAnim.isPlaying==false){return this.currentAnim.play(c,b)}}else{this.currentAnim=this._anims[d];return this.currentAnim.play(c,b)}}},stop:function(b){if(this._anims[b]){this.currentAnim=this._anims[b];this.currentAnim.stop()}},update:function(){if(this.updateIfVisible&&this.sprite.visible==false){return false}if(this.currentAnim&&this.currentAnim.update()==true){this.currentFrame=this.currentAnim.currentFrame;this.sprite.currentFrame=this.currentFrame;return true}return false},destroy:function(){this._anims={};this._frameData=null;this._frameIndex=0;this.currentAnim=null;this.currentFrame=null}};Object.defineProperty(Phaser.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameTotal",{get:function(){if(this._frameData){return this._frameData.total}else{return -1}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame){return this._frameIndex}},set:function(b){if(this._frameData&&this._frameData.getFrame(b)!==null){this.currentFrame=this._frameData.getFrame(b);this._frameIndex=b;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame){return this.currentFrame.name}},set:function(b){if(this._frameData&&this._frameData.getFrameByName(b)){this.currentFrame=this._frameData.getFrameByName(b);this._frameIndex=this.currentFrame.index;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{console.warn("Cannot set frameName: "+b)}}});Phaser.Animation=function(c,g,f,e,h,d,b){this.game=c;this._parent=g;this._frames=h;this._frameData=f;this.name=e;this.delay=1000/d;this.looped=b;this.isFinished=false;this.isPlaying=false;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])};Phaser.Animation.prototype={play:function(c,b){c=c||null;b=b||null;if(c!==null){this.delay=1000/c}if(b!==null){this.looped=b}this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationStart.dispatch(this._parent,this);return this},restart:function(){this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(){this.isPlaying=false;this.isFinished=true},update:function(){if(this.isPlaying==true&&this.game.time.now>=this._timeNextFrame){this._frameIndex++;if(this._frameIndex==this._frames.length){if(this.looped){this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationLoop.dispatch(this._parent,this)}else{this.onComplete()}}else{this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;return true}return false},destroy:function(){this.game=null;this._parent=null;this._frames=null;this._frameData=null;this.currentFrame=null;this.isPlaying=false},onComplete:function(){this.isPlaying=false;this.isFinished=true;this._parent.events.onAnimationComplete.dispatch(this._parent,this)}};Object.defineProperty(Phaser.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}});Object.defineProperty(Phaser.Animation.prototype,"frame",{get:function(){if(this.currentFrame!==null){return this.currentFrame.index}else{return this._frameIndex}},set:function(b){this.currentFrame=this._frameData.getFrame(b);if(this.currentFrame!==null){this._frameIndex=b;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Phaser.Animation.Frame=function(c,g,f,b,d,e){this.x=c;this.y=g;this.width=f;this.height=b;this.centerX=Math.floor(f/2);this.centerY=Math.floor(b/2);this.index=0;this.name=d;this.uuid=e;this.distance=Phaser.Math.distance(0,0,f,b);this.rotated=false;this.rotationDirection="cw";this.trimmed=false;this.sourceSizeW=f;this.sourceSizeH=b;this.spriteSourceSizeX=0;this.spriteSourceSizeY=0;this.spriteSourceSizeW=0;this.spriteSourceSizeH=0};Phaser.Animation.Frame.prototype={setTrim:function(f,e,h,c,b,d,g){this.trimmed=f;if(f){this.width=e;this.height=h;this.sourceSizeW=e;this.sourceSizeH=h;this.centerX=Math.floor(e/2);this.centerY=Math.floor(h/2);this.spriteSourceSizeX=c;this.spriteSourceSizeY=b;this.spriteSourceSizeW=d;this.spriteSourceSizeH=g}}};Phaser.Animation.FrameData=function(){this._frames=[];this._frameNames=[]};Phaser.Animation.FrameData.prototype={addFrame:function(b){b.index=this._frames.length;this._frames.push(b);if(b.name!==""){this._frameNames[b.name]=b.index}return b},getFrame:function(b){if(this._frames[b]){return this._frames[b]}return null},getFrameByName:function(b){if(this._frameNames[b]!==""){return this._frames[this._frameNames[b]]}return null},checkFrameName:function(b){if(this._frameNames[b]==null){return false}return true},getFrameRange:function(e,b,c){if(typeof c==="undefined"){c=[]}for(var d=e;d<=b;d++){c.push(this._frames[d])}return c},getFrameIndexes:function(b){if(typeof b==="undefined"){b=[]}for(var c=0;c tag");return}var d=new Phaser.Animation.FrameData();var j=g.getElementsByTagName("SubTexture");var f;for(var e=0;e0){this._progressChunk=100/this._keys.length;this.loadFile()}else{this.progress=100;this.hasLoaded=true;this.onLoadComplete.dispatch()}},loadFile:function(){var b=this._fileList[this._keys.shift()];var c=this;switch(b.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tilemap":b.data=new Image();b.data.name=b.key;b.data.onload=function(){return c.fileComplete(b.key)};b.data.onerror=function(){return c.fileError(b.key)};b.data.crossOrigin=this.crossOrigin;b.data.src=this.baseURL+b.url;break;case"audio":b.url=this.getAudioURL(b.url);if(b.url!==null){if(this.game.sound.usingWebAudio){this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="arraybuffer";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send()}else{if(this.game.sound.usingAudioTag){if(this.game.sound.touchLocked){b.data=new Audio();b.data.name=b.key;b.data.preload="auto";b.data.src=this.baseURL+b.url;this.fileComplete(b.key)}else{b.data=new Audio();b.data.name=b.key;b.data.onerror=function(){return c.fileError(b.key)};b.data.preload="auto";b.data.src=this.baseURL+b.url;b.data.addEventListener("canplaythrough",Phaser.GAMES[this.game.id].load.fileComplete(b.key),false);b.data.load()}}}}else{this.fileError(b.key)}break;case"text":this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="text";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send();break}},getAudioURL:function(c){var d;for(var b=0;b100){this.progress=100}this.onFileComplete.dispatch(this.progress,b,c,this.queueSize-this._keys.length,this.queueSize);if(this._keys.length>0){this.loadFile()}else{this.hasLoaded=true;this.isLoading=false;this.removeAll();this.onLoadComplete.dispatch()}}};Phaser.Loader.Parser={bitmapFont:function(q,h,l){if(!h.getElementsByTagName("font")){console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag");return}var m=PIXI.TextureCache[l];var e={};var c=h.getElementsByTagName("info")[0];var j=h.getElementsByTagName("common")[0];e.font=c.attributes.getNamedItem("face").nodeValue;e.size=parseInt(c.attributes.getNamedItem("size").nodeValue,10);e.lineHeight=parseInt(j.attributes.getNamedItem("lineHeight").nodeValue,10);e.chars={};var k=h.getElementsByTagName("char");for(var d=0;d=this.duration){if(this.usingWebAudio){if(this.loop){this.onLoop.dispatch(this);if(this.currentMarker==""){this.currentTime=0;this.startTime=this.game.time.now}else{this.play(this.currentMarker,0,this.volume,true,true)}}else{this.stop()}}else{if(this.loop){this.onLoop.dispatch(this);this.play(this.currentMarker,0,this.volume,true,true)}else{this.stop()}}}}},play:function(d,b,f,c,e){d=d||"";b=b||0;f=f||1;c=c||false;e=e||false;if(this.isPlaying==true&&e==false&&this.override==false){return}if(this.isPlaying&&this.override){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.currentMarker=d;if(d!==""&&this.markers[d]){this.position=this.markers[d].start;this.volume=this.markers[d].volume;this.loop=this.markers[d].loop;this.duration=this.markers[d].duration*1000;this._tempMarker=d;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else{this.position=b;this.volume=f;this.loop=c;this.duration=0;this._tempMarker=d;this._tempPosition=b;this._tempVolume=f;this._tempLoop=c}if(this.usingWebAudio){if(this.game.cache.isSoundDecoded(this.key)){if(this._buffer==null){this._buffer=this.game.cache.getSoundData(this.key)}this._sound=this.context.createBufferSource();this._sound.buffer=this._buffer;this._sound.connect(this.gainNode);this.totalDuration=this._sound.buffer.duration;if(this.duration==0){this.duration=this.totalDuration*1000}if(this.loop&&d==""){this._sound.loop=true}if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration/1000)}else{this._sound.start(0,this.position,this.duration/1000)}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true;if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).isDecoding==false){this.game.sound.decode(this.key,this)}}}else{if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked){this.game.cache.reloadSound(this.key);this.pendingPlayback=true}else{if(this._sound&&this._sound.readyState==4){this._sound.play();this.totalDuration=this._sound.duration;if(this.duration==0){this.duration=this.totalDuration*1000}this._sound.currentTime=this.position;this._sound.muted=this._muted;if(this._muted){this._sound.volume=0}else{this._sound.volume=this._volume}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true}}}},restart:function(d,b,e,c){d=d||"";b=b||0;e=e||1;c=c||false;this.play(d,b,e,c,true)},pause:function(){if(this.isPlaying&&this._sound){this.stop();this.isPlaying=false;this.paused=true;this.onPause.dispatch(this)}},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration)}else{this._sound.start(0,this.position,this.duration)}}else{this._sound.play()}this.isPlaying=true;this.paused=false;this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.isPlaying=false;var b=this.currentMarker;this.currentMarker="";this.onStop.dispatch(this,b)}};Object.defineProperty(Phaser.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}});Object.defineProperty(Phaser.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}});Object.defineProperty(Phaser.Sound.prototype,"mute",{get:function(){return this._muted},set:function(b){b=b||null;if(b){this._muted=true;if(this.usingWebAudio){this._muteVolume=this.gainNode.gain.value;this.gainNode.gain.value=0}else{if(this.usingAudioTag&&this._sound){this._muteVolume=this._sound.volume;this._sound.volume=0}}}else{this._muted=false;if(this.usingWebAudio){this.gainNode.gain.value=this._muteVolume}else{if(this.usingAudioTag&&this._sound){this._sound.volume=this._muteVolume}}}this.onMute.dispatch(this)}});Object.defineProperty(Phaser.Sound.prototype,"volume",{get:function(){return this._volume},set:function(b){if(this.usingWebAudio){this._volume=b;this.gainNode.gain.value=b}else{if(this.usingAudioTag&&this._sound){if(b>=0&&b<=1){this._volume=b;this._sound.volume=b}}}}});Phaser.SoundManager=function(b){this.game=b;this.onSoundDecode=new Phaser.Signal;this._muted=false;this._unlockSource=null;this._volume=1;this._muted=false;this._sounds=[];this.context=null;this.usingWebAudio=true;this.usingAudioTag=false;this.noAudio=false;this.touchLocked=false;this.channels=32};Phaser.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio==false){this.channels=1}if(this.game.device.iOS||(window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)){this.game.input.touch.callbackContext=this;this.game.input.touch.touchStartCallback=this.unlock;this.game.input.mouse.callbackContext=this;this.game.input.mouse.mouseDownCallback=this.unlock;this.touchLocked=true}else{this.touchLocked=false}if(window.PhaserGlobal){if(window.PhaserGlobal.disableAudio==true){this.usingWebAudio=false;this.noAudio=true;return}if(window.PhaserGlobal.disableWebAudio==true){this.usingWebAudio=false;this.usingAudioTag=true;this.noAudio=false;return}}if(!!window.AudioContext){this.context=new window.AudioContext()}else{if(!!window.webkitAudioContext){this.context=new window.webkitAudioContext()}else{if(!!window.Audio){this.usingWebAudio=false;this.usingAudioTag=true}else{this.usingWebAudio=false;this.noAudio=true}}}if(this.context!==null){if(typeof this.context.createGain==="undefined"){this.masterGain=this.context.createGainNode()}else{this.masterGain=this.context.createGain()}this.masterGain.gain.value=1;this.masterGain.connect(this.context.destination)}},unlock:function(){if(this.touchLocked==false){return}if(this.game.device.webAudio==false||(window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio==true)){this.touchLocked=false;this._unlockSource=null;this.game.input.touch.callbackContext=null;this.game.input.touch.touchStartCallback=null;this.game.input.mouse.callbackContext=null;this.game.input.mouse.mouseDownCallback=null}else{var b=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=b;this._unlockSource.connect(this.context.destination);this._unlockSource.noteOn(0)}},stopAll:function(){for(var b=0;b255){return Phaser.Color.getColor(255,255,255)}if(d>c){return Phaser.Color.getColor(255,255,255)}var f=d+Math.round(Math.random()*(c-d));var e=d+Math.round(Math.random()*(c-d));var b=d+Math.round(Math.random()*(c-d));return Phaser.Color.getColor32(g,f,e,b)},getRGB:function(b){return{alpha:b>>>24,red:b>>16&255,green:b>>8&255,blue:b&255}},getWebRGB:function(c){var f=(c>>>24)/255;var e=c>>16&255;var d=c>>8&255;var b=c&255;return"rgba("+e.toString()+","+d.toString()+","+b.toString()+","+f.toString()+")"},getAlpha:function(b){return b>>>24},getAlphaFloat:function(b){return(b>>>24)/255},getRed:function(b){return b>>16&255},getGreen:function(b){return b>>8&255},getBlue:function(b){return b&255}};Phaser.Physics={};Phaser.Physics.Arcade=function(b){this.game=b;this.gravity=new Phaser.Point;this.bounds=new Phaser.Rectangle(0,0,b.world.width,b.world.height);this.maxObjects=10;this.maxLevels=4;this.OVERLAP_BIAS=4;this.TILE_OVERLAP=false;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this.quadTreeID=0;this._obj1Bounds=new Phaser.Rectangle;this._obj2Bounds=new Phaser.Rectangle;this._overlap=0;this._maxOverlap=0;this._obj1Velocity=0;this._obj2Velocity=0;this._obj1NewVelocity=0;this._obj2NewVelocity=0;this._average=0};Phaser.Physics.Arcade.prototype={updateMotion:function(b){this._velocityDelta=(this.computeVelocity(0,false,b.angularVelocity,b.angularAcceleration,b.angularDrag,b.maxAngular)-b.angularVelocity)/2;b.angularVelocity+=this._velocityDelta;b.rotation+=b.angularVelocity*this.game.time.physicsElapsed;this._velocityDelta=(this.computeVelocity(1,b,b.velocity.x,b.acceleration.x,b.drag.x)-b.velocity.x)/2;b.velocity.x+=this._velocityDelta;this._delta=b.velocity.x*this.game.time.physicsElapsed;b.x+=this._delta;this._velocityDelta=(this.computeVelocity(2,b,b.velocity.y,b.acceleration.y,b.drag.y)-b.velocity.y)/2;b.velocity.y+=this._velocityDelta;this._delta=b.velocity.y*this.game.time.physicsElapsed;b.y+=this._delta},computeVelocity:function(e,c,g,f,d,b){b=b||10000;if(e==1&&c.allowGravity){g+=this.gravity.x+c.gravity.x}else{if(e==2&&c.allowGravity){g+=this.gravity.y+c.gravity.y}}if(f!==0){g+=f*this.game.time.physicsElapsed}else{if(d!==0){this._drag=d*this.game.time.physicsElapsed;if(g-this._drag>0){g=g-this._drag}else{if(g+this._drag<0){g+=this._drag}else{g=0}}}}if(g!=0){if(g>b){g=b}else{if(g<-b){g=-b}}}return g},preUpdate:function(){this.quadTree.clear();this.quadTreeID=0;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},collide:function(c,d,b){return this.overlap(c,null,d,this.separate,b)},collideGroup:function(j,f,d){f=f||null;d=d||f;for(var h=0,b=j.length;h0)?c.deltaX():0),c.lastY,c.width+((c.deltaX()>0)?c.deltaX():-c.deltaX()),c.height);this._obj2Bounds.setTo(b.x-((b.deltaX()>0)?b.deltaX():0),b.lastY,b.width+((b.deltaX()>0)?b.deltaX():-b.deltaX()),b.height);if((this._obj1Bounds.right>this._obj2Bounds.x)&&(this._obj1Bounds.xthis._obj2Bounds.y)&&(this._obj1Bounds.yb.deltaX()){this._overlap=c.x+c.width-b.x;if((this._overlap>this._maxOverlap)||c.allowCollision.right==false||b.allowCollision.left==false){this._overlap=0}else{c.touching.right=true;b.touching.left=true}}else{if(c.deltaX()this._maxOverlap)||c.allowCollision.left==false||b.allowCollision.right==false){this._overlap=0}else{c.touching.left=true;b.touching.right=true}}}}}if(this._overlap!=0){this._obj1Velocity=c.velocity.x;this._obj2Velocity=b.velocity.x;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.x=c.x-this._overlap;b.x+=this._overlap;this._obj1NewVelocity=Math.sqrt((this._obj2Velocity*this._obj2Velocity*b.mass)/c.mass)*((this._obj2Velocity>0)?1:-1);this._obj2NewVelocity=Math.sqrt((this._obj1Velocity*this._obj1Velocity*c.mass)/b.mass)*((this._obj1Velocity>0)?1:-1);this._average=(this._obj1NewVelocity+this._obj2NewVelocity)*0.5;this._obj1NewVelocity-=this._average;this._obj2NewVelocity-=this._average;c.velocity.x=this._average+this._obj1NewVelocity*c.bounce.x;b.velocity.x=this._average+this._obj2NewVelocity*b.bounce.x}else{if(!c.immovable){c.x=c.x-this._overlap;c.velocity.x=this._obj2Velocity-this._obj1Velocity*c.bounce.x}else{if(!b.immovable){b.x+=this._overlap;b.velocity.x=this._obj1Velocity-this._obj2Velocity*b.bounce.x}}}return true}else{return false}},separateY:function(c,b){if(c.immovable&&b.immovable){return false}this._overlap=0;if(c.deltaY()!=b.deltaY()){this._obj1Bounds.setTo(c.x,c.y-((c.deltaY()>0)?c.deltaY():0),c.width,c.height+c.deltaAbsY());this._obj2Bounds.setTo(b.x,b.y-((b.deltaY()>0)?b.deltaY():0),b.width,b.height+b.deltaAbsY());if((this._obj1Bounds.right>this._obj2Bounds.x)&&(this._obj1Bounds.xthis._obj2Bounds.y)&&(this._obj1Bounds.yb.deltaY()){this._overlap=c.y+c.height-b.y;if((this._overlap>this._maxOverlap)||c.allowCollision.down==false||b.allowCollision.up==false){this._overlap=0}else{c.touching.down=true;b.touching.up=true}}else{if(c.deltaY()this._maxOverlap)||c.allowCollision.up==false||b.allowCollision.down==false){this._overlap=0}else{c.touching.up=true;b.touching.down=true}}}}}if(this._overlap!=0){this._obj1Velocity=c.velocity.y;this._obj2Velocity=b.velocity.y;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.y=c.y-this._overlap;b.y+=this._overlap;this._obj1NewVelocity=Math.sqrt((this._obj2Velocity*this._obj2Velocity*b.mass)/c.mass)*((this._obj2Velocity>0)?1:-1);this._obj2NewVelocity=Math.sqrt((this._obj1Velocity*this._obj1Velocity*c.mass)/b.mass)*((this._obj1Velocity>0)?1:-1);this._average=(this._obj1NewVelocity+this._obj2NewVelocity)*0.5;this._obj1NewVelocity-=this._average;this._obj2NewVelocity-=this._average;c.velocity.y=this._average+this._obj1NewVelocity*c.bounce.y;b.velocity.y=this._average+this._obj2NewVelocity*b.bounce.y}else{if(!c.immovable){c.y=c.y-this._overlap;c.velocity.y=this._obj2Velocity-this._obj1Velocity*c.bounce.y;if(b.active&&b.moves&&(c.deltaY()>b.deltaY())){c.x+=b.x-b.lastX}}else{if(!b.immovable){b.y+=this._overlap;b.velocity.y=this._obj1Velocity-this._obj2Velocity*b.bounce.y;if(c.sprite.active&&c.moves&&(c.deltaY()0){var h=this.distanceBetween(g,e);f=h/(c/1000)}g.body.velocity.x=Math.cos(b)*f;g.body.velocity.y=Math.sin(b)*f},accelerateTowardsObject:function(f,d,e,b,g){b=b||1000;g=g||1000;var c=this.angleBetween(f,d);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(c)*e;f.body.acceleration.y=Math.sin(c)*e;f.body.maxVelocity.x=b;f.body.maxVelocity.y=g},moveTowardsMouse:function(f,e,c){e=e||60;c=c||0;var b=this.angleBetweenMouse(f);if(c>0){var g=this.distanceToMouse(f);e=g/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsMouse:function(e,d,b,f){b=b||1000;f=f||1000;var c=this.angleBetweenMouse(e);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=f},moveTowardsPoint:function(f,g,e,c){e=e||60;c=c||0;var b=this.angleBetweenPoint(f,g);if(c>0){var h=this.distanceToPoint(f,g);e=h/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsPoint:function(e,f,d,b,g){b=b||1000;g=g||1000;var c=this.angleBetweenPoint(e,f);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=g},distanceBetween:function(e,c){var f=e.center.x-c.center.x;var d=e.center.y-c.center.y;return Math.sqrt(f*f+d*d)},distanceToPoint:function(c,e){var d=c.center.x-e.x;var b=c.center.y-e.y;return Math.sqrt(d*d+b*b)},distanceToMouse:function(c){var d=c.center.x-this.game.input.x;var b=c.center.y-this.game.input.y;return Math.sqrt(d*d+b*b)},angleBetweenPoint:function(c,f,e){e=e||false;var d=f.x-c.center.x;var b=f.y-c.center.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}},angleBetween:function(e,c,g){g=g||false;var f=c.center.x-e.center.x;var d=c.center.y-e.center.y;if(g){return this.game.math.radToDeg(Math.atan2(d,f))}else{return Math.atan2(d,f)}},velocityFromFacing:function(b,c){},angleBetweenMouse:function(c,e){e=e||false;var d=this.game.input.x-c.bounds.x;var b=this.game.input.y-c.bounds.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}}};Phaser.Physics.Arcade.Body=function(b){this.sprite=b;this.game=b.game;this.offset=new Phaser.Point;this.x=b.x;this.y=b.y;this.sourceWidth=b.currentFrame.sourceSizeW;this.sourceHeight=b.currentFrame.sourceSizeH;this.width=b.currentFrame.sourceSizeW;this.height=b.currentFrame.sourceSizeH;this.halfWidth=Math.floor(b.currentFrame.sourceSizeW/2);this.halfHeight=Math.floor(b.currentFrame.sourceSizeH/2);this._sx=b.scale.x;this._sy=b.scale.y;this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1;this.quadTreeIDs=[];this.quadTreeIndex=-1;this.allowCollision={none:false,any:true,up:true,down:true,left:true,right:true};this.touching={none:true,up:false,down:false,left:false,right:false};this.wasTouching={none:true,up:false,down:false,left:false,right:false};this.immovable=false;this.moves=true;this.rotation=0;this.allowRotation=true;this.allowGravity=true;this.collideWorldBounds=false;this.lastX=b.x;this.lastY=b.y};Phaser.Physics.Arcade.Body.prototype={updateBounds:function(e,d,c,b){if(c!=this._sx||b!=this._sy){this.width=this.sourceWidth*c;this.height=this.sourceHeight*b;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this._sx=c;this._sy=b}},update:function(){this.wasTouching.none=this.touching.none;this.wasTouching.up=this.touching.up;this.wasTouching.down=this.touching.down;this.wasTouching.left=this.touching.left;this.wasTouching.right=this.touching.right;this.touching.none=true;this.touching.up=false;this.touching.down=false;this.touching.left=false;this.touching.right=false;this.lastX=this.x;this.lastY=this.y;this.rotation=this.sprite.angle;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;if(this.moves){this.game.physics.updateMotion(this)}if(this.collideWorldBounds){this.checkWorldBounds()}if(this.allowCollision.none==false&&this.sprite.visible&&this.sprite.alive){this.quadTreeIDs=[];this.quadTreeIndex=-1;this.game.physics.quadTree.insert(this)}this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},postUpdate:function(){this.sprite.x=(this.x-this.offset.x+(this.sprite.anchor.x*this.width))-(this.game.world.camera.x*this.sprite.scrollFactor.x);this.sprite.y=(this.y-this.offset.y+(this.sprite.anchor.y*this.height))-(this.game.world.camera.y*this.sprite.scrollFactor.y);if(this.allowRotation){this.sprite.angle=this.rotation}},checkWorldBounds:function(){if(this.xthis.game.world.bounds.right){this.x=this.game.world.bounds.right-this.width;this.velocity.x*=-this.bounce.x}}if(this.ythis.game.world.bounds.bottom){this.y=this.game.world.bounds.bottom-this.height;this.velocity.y*=-this.bounce.y}}},setSize:function(d,c,b,e){b=b||this.offset.x;e=e||this.offset.y;this.sourceWidth=d;this.sourceHeight=c;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(b,e)},reset:function(){this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1},deltaAbsX:function(){return(this.deltaX()>0?this.deltaX():-this.deltaX())},deltaAbsY:function(){return(this.deltaY()>0?this.deltaY():-this.deltaY())},deltaX:function(){return this.x-this.lastX},deltaY:function(){return this.y-this.lastY}};Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Phaser.Particles=function(b){this.emitters={};this.ID=0};Phaser.Particles.prototype={emitters:null,add:function(b){this.emitters[b.name]=b;return b},remove:function(b){delete this.emitters[b.name]},update:function(){for(var b in this.emitters){if(this.emitters[b].exists){this.emitters[b].update()}}}};Phaser.Particles.Arcade={};Phaser.Particles.Arcade.Emitter=function(c,b,e,d){d=d||50;Phaser.Group.call(this,c);this.name="emitter"+this.game.particles.ID++;this.x=b;this.y=e;this.width=1;this.height=1;this.minParticleSpeed=new Phaser.Point(-100,-100);this.maxParticleSpeed=new Phaser.Point(100,100);this.minParticleScale=1;this.maxParticleScale=1;this.minRotation=-360;this.maxRotation=360;this.gravity=2;this.particleClass=null;this.particleDrag=new Phaser.Point();this.frequency=100;this.maxParticles=d;this.lifespan=2000;this.bounce=0;this._quantity=0;this._timer=0;this._counter=0;this._explode=true;this.on=false;this.exists=true;this.emitX=0;this.emitY=0};Phaser.Particles.Arcade.Emitter.prototype=Object.create(Phaser.Group.prototype);Phaser.Particles.Arcade.Emitter.prototype.constructor=Phaser.Particles.Arcade.Emitter;Phaser.Particles.Arcade.Emitter.prototype.update=function(){if(this.on){if(this._explode){this._counter=0;do{this.emitParticle();this._counter++}while(this._counter=this._timer){this.emitParticle();this._counter++;if(this._quantity>0){if(this._counter>=this._quantity){this.on=false}}this._timer=this.game.time.now+this.frequency}}}};Phaser.Particles.Arcade.Emitter.prototype.makeParticles=function(d,h,f,e){if(typeof h=="undefined"){h=0}f=f||this.maxParticles;e=e||0;var j;var b=0;var c=d;var g=0;while(b0){j.body.allowCollision.any=true}else{j.body.allowCollision.none=true}j.exists=false;j.visible=false;j.anchor.setTo(0.5,0.5);this.add(j);b++}return this};Phaser.Particles.Arcade.Emitter.prototype.kill=function(){this.on=false;this.alive=false;this.exists=false};Phaser.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=true;this.exists=true};Phaser.Particles.Arcade.Emitter.prototype.start=function(b,e,d,c){if(typeof b!=="boolean"){b=true}e=e||0;d=d||250;c=c||0;this.revive();this.visible=true;this.on=true;this._explode=b;this.lifespan=e;this.frequency=d;this._quantity+=c;this._counter=0;this._timer=this.game.time.now+d};Phaser.Particles.Arcade.Emitter.prototype.emitParticle=function(){var c=this.getFirstExists(false);if(c==null){return}if(this.width>1||this.height>1){c.reset(this.x-this.game.rnd.integerInRange(this.left,this.right),this.y-this.game.rnd.integerInRange(this.top,this.bottom))}else{c.reset(this.emitX,this.emitY)}c.lifespan=this.lifespan;c.body.bounce.setTo(this.bounce,this.bounce);if(this.minParticleSpeed.x!=this.maxParticleSpeed.x){c.body.velocity.x=this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x)}else{c.body.velocity.x=this.minParticleSpeed.x}if(this.minParticleSpeed.y!=this.maxParticleSpeed.y){c.body.velocity.y=this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y)}else{c.body.velocity.y=this.minParticleSpeed.y}c.body.gravity.y=this.gravity;if(this.minRotation!=this.maxRotation){c.body.angularVelocity=this.game.rnd.integerInRange(this.minRotation,this.maxRotation)}else{c.body.angularVelocity=this.minRotation}if(this.minParticleScale!==1||this.maxParticleScale!==1){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);c.scale.setTo(b,b)}c.body.drag.x=this.particleDrag.x;c.body.drag.y=this.particleDrag.y};Phaser.Particles.Arcade.Emitter.prototype.setSize=function(c,b){this.width=c;this.height=b};Phaser.Particles.Arcade.Emitter.prototype.setXSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.x=c;this.maxParticleSpeed.x=b};Phaser.Particles.Arcade.Emitter.prototype.setYSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.y=c;this.maxParticleSpeed.y=b};Phaser.Particles.Arcade.Emitter.prototype.setRotation=function(c,b){c=c||0;b=b||0;this.minRotation=c;this.maxRotation=b};Phaser.Particles.Arcade.Emitter.prototype.at=function(b){this.emitX=b.center.x;this.emitY=b.center.y};Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(b){this._container.alpha=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(b){this._container.visible=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-(this.height/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+(this.height/2))}});Phaser.Tilemap=function(d,e,b,i,g,h,c){if(typeof g==="undefined"){g=true}if(typeof h==="undefined"){h=0}if(typeof c==="undefined"){c=0}this.game=d;this.group=null;this.name="";this.key=e;this.renderOrderID=0;this.collisionCallback=null;this.exists=true;this.visible=true;this.tiles=[];this.layers=[];var f=this.game.cache.getTilemap(e);PIXI.DisplayObjectContainer.call(this);this.position.x=b;this.position.y=i;this.renderer=new Phaser.TilemapRenderer(this.game);this.mapFormat=f.format;switch(this.mapFormat){case Phaser.Tilemap.CSV:this.parseCSV(f.mapData,e,h,c);break;case Phaser.Tilemap.JSON:this.parseTiledJSON(f.mapData,e);break}if(this.currentLayer&&g){this.game.world.setSize(this.currentLayer.widthInPixels,this.currentLayer.heightInPixels,true)}};Phaser.Tilemap.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);Phaser.Tilemap.prototype.constructor=Phaser.Tilemap;Phaser.Tilemap.CSV=0;Phaser.Tilemap.JSON=1;Phaser.Tilemap.prototype.parseCSV=function(d,j,h,g){var f=new Phaser.TilemapLayer(this,0,j,Phaser.Tilemap.CSV,"TileLayerCSV"+this.layers.length.toString(),h,g);d=d.trim();var k=d.split("\n");for(var e=0;e0){f.addColumn(c)}}f.updateBounds();f.createCanvas();var b=f.parseTileOffsets();this.currentLayer=f;this.collisionLayer=f;this.layers.push(f);this.generateTiles(b)};Phaser.Tilemap.prototype.parseTiledJSON=function(g,f){for(var e=0;e0){this.collisionCallback.call(this.collisionCallbackContext,b,this._tempCollisionData)}return true}else{return false}};Phaser.Tilemap.prototype.putTile=function(b,e,c,d){if(typeof d==="undefined"){d=this.currentLayer.ID}this.layers[d].putTile(b,e,c)};Phaser.Tilemap.prototype.update=function(){this.renderer.render(this)};Phaser.Tilemap.prototype.destroy=function(){this.tiles.length=0;this.layers.length=0};Object.defineProperty(Phaser.Tilemap.prototype,"widthInPixels",{get:function(){return this.currentLayer.widthInPixels}});Object.defineProperty(Phaser.Tilemap.prototype,"heightInPixels",{get:function(){return this.currentLayer.heightInPixels}});Phaser.TilemapLayer=function(f,i,e,d,c,h,b){this.exists=true;this.visible=true;this.widthInTiles=0;this.heightInTiles=0;this.widthInPixels=0;this.heightInPixels=0;this.tileMargin=0;this.tileSpacing=0;this.parent=f;this.game=f.game;this.ID=i;this.name=c;this.key=e;this.mapFormat=d;this.tileWidth=h;this.tileHeight=b;this.boundsInTiles=new Phaser.Rectangle();var g=this.game.cache.getTilemap(e);this.tileset=g.data;this._alpha=1;this.canvas=null;this.context=null;this.baseTexture=null;this.texture=null;this.sprite=null;this.mapData=[];this._tempTileBlock=[]};Phaser.TilemapLayer.prototype={putTileWorldXY:function(b,d,c){b=this.game.math.snapToFloor(b,this.tileWidth)/this.tileWidth;d=this.game.math.snapToFloor(d,this.tileHeight)/this.tileHeight;if(d>=0&&d=0&&b=0&&d=0&&bthis.widthInPixels||b.body.bounds.y<0||b.body.bounds.bottom>this.heightInPixels){return}this._tempTileX=this.game.math.snapToFloor(b.body.bounds.x,this.tileWidth)/this.tileWidth;this._tempTileY=this.game.math.snapToFloor(b.body.bounds.y,this.tileHeight)/this.tileHeight;this._tempTileW=(this.game.math.snapToCeil(b.body.bounds.width,this.tileWidth)+this.tileWidth)/this.tileWidth;this._tempTileH=(this.game.math.snapToCeil(b.body.bounds.height,this.tileHeight)+this.tileHeight)/this.tileHeight;this._tempBlockResults=[];this.getTempBlock(this._tempTileX,this._tempTileY,this._tempTileW,this._tempTileH,true);return this._tempBlockResults},getTempBlock:function(d,h,g,c,f){if(typeof f==="undefined"){f=false}if(d<0){d=0}if(h<0){h=0}if(g>this.widthInTiles){g=this.widthInTiles}if(c>this.heightInTiles){c=this.heightInTiles}this._tempTileBlock=[];for(var b=h;b=0&&c=0&&bb.widthInTiles){this._maxX=b.widthInTiles}if(this._maxY>b.heightInTiles){this._maxY=b.heightInTiles}if(this._startX+this._maxX>b.widthInTiles){this._startX=b.widthInTiles-this._maxX}if(this._startY+this._maxY>b.heightInTiles){this._startY=b.heightInTiles-this._maxY}this._dx=-(this.game.camera.x-(this._startX*b.tileWidth));this._dy=-(this.game.camera.y-(this._startY*b.tileHeight));this._tx=this._dx;this._ty=this._dy;if(b.alpha!==1){this._ga=b.context.globalAlpha;b.context.globalAlpha=b.alpha}b.context.clearRect(0,0,b.canvas.width,b.canvas.height);for(var f=this._startY;f-1){b.context.globalAlpha=this._ga}if(this.game.renderType==Phaser.WEBGL){PIXI.texturesToUpdate.push(b.baseTexture)}}return true}}; \ No newline at end of file diff --git a/build/phaser.js b/build/phaser.js index 833b9c05..63ca0e21 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -1,19 +1,19 @@ /** * Phaser - http://www.phaser.io * -* v1.0.0 - Built at: Sun, 08 Sep 2013 22:41:33 +0000 +* v1.0.0 - Built at: Thu, 12 Sep 2013 10:23:43 +0000 * * @author Richard Davey http://www.photonstorm.com @photonstorm * * A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and * constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm). * -* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23 +* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23. * * Follow Phaser development progress at http://www.photonstorm.com * * Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser -* and my love of game development tools originate. +* and my love of game development originate. * * "If you want your children to be intelligent, read them fairy tales." * "If you want them to be more intelligent, read them more fairy tales." @@ -46,8 +46,45 @@ PIXI.InteractionManager = function (dummy) { // We don't need this in Pixi, so we've removed it to save space // however the Stage object expects a reference to it, so here is a dummy entry. }; + Phaser.Utils = { + /** + * Javascript string pad + * http://www.webtoolkit.info/ + * pad = the string to pad it out with (defaults to a space) + * dir = 1 (left), 2 (right), 3 (both) + **/ + pad: function (str, len, pad, dir) { + + if (typeof(len) == "undefined") { var len = 0; } + if (typeof(pad) == "undefined") { var pad = ' '; } + if (typeof(dir) == "undefined") { var dir = 3; } + + if (len + 1 >= str.length) + { + switch (dir) + { + case 1: + str = Array(len + 1 - str.length).join(pad) + str; + break; + + case 3: + var right = Math.ceil((padlen = len - str.length) / 2); + var left = padlen - right; + str = Array(left+1).join(pad) + str + Array(right+1).join(pad); + break; + + default: + str = str + Array(len + 1 - str.length).join(pad); + break; + } + } + + return str; + + }, + // This is a slightly modified version of jQuery.isPlainObject isPlainObject: function (obj) { @@ -1655,7 +1692,7 @@ PIXI.Sprite.prototype.setTexture = function(texture) PIXI.Sprite.prototype.onTextureUpdate = function(event) { //this.texture.removeEventListener( 'update', this.onTextureUpdateBind ); -console.log('pot'); + // so if _width is 0 then width was not set.. if(this._width)this.scale.x = this._width / this.texture.frame.width; if(this._height)this.scale.y = this._height / this.texture.frame.height; @@ -1699,155 +1736,6 @@ PIXI.Sprite.fromImage = function(imageId) } -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - */ - -/** - * A MovieClip is a simple way to display an animation depicted by a list of textures. - * - * @class MovieClip - * @extends Sprite - * @constructor - * @param textures {Array} an array of {Texture} objects that make up the animation - */ -PIXI.MovieClip = function(textures) -{ - PIXI.Sprite.call(this, textures[0]); - - /** - * The array of textures that make up the animation - * - * @property textures - * @type Array - */ - this.textures = textures; - - /** - * The speed that the MovieClip will play at. Higher is faster, lower is slower - * - * @property animationSpeed - * @type Number - * @default 1 - */ - this.animationSpeed = 1; - - /** - * Whether or not the movie clip repeats after playing. - * - * @property loop - * @type Boolean - * @default true - */ - this.loop = true; - - /** - * Function to call when a MovieClip finishes playing - * - * @property onComplete - * @type Function - */ - this.onComplete = null; - - /** - * [read-only] The index MovieClips current frame (this may not have to be a whole number) - * - * @property currentFrame - * @type Number - * @default 0 - * @readOnly - */ - this.currentFrame = 0; - - /** - * [read-only] Indicates if the MovieClip is currently playing - * - * @property playing - * @type Boolean - * @readOnly - */ - this.playing = false; -} - -// constructor -PIXI.MovieClip.prototype = Object.create( PIXI.Sprite.prototype ); -PIXI.MovieClip.prototype.constructor = PIXI.MovieClip; - -/** - * Stops the MovieClip - * - * @method stop - */ -PIXI.MovieClip.prototype.stop = function() -{ - this.playing = false; -} - -/** - * Plays the MovieClip - * - * @method play - */ -PIXI.MovieClip.prototype.play = function() -{ - this.playing = true; -} - -/** - * Stops the MovieClip and goes to a specific frame - * - * @method gotoAndStop - * @param frameNumber {Number} frame index to stop at - */ -PIXI.MovieClip.prototype.gotoAndStop = function(frameNumber) -{ - this.playing = false; - this.currentFrame = frameNumber; - var round = (this.currentFrame + 0.5) | 0; - this.setTexture(this.textures[round % this.textures.length]); -} - -/** - * Goes to a specific frame and begins playing the MovieClip - * - * @method gotoAndPlay - * @param frameNumber {Number} frame index to start at - */ -PIXI.MovieClip.prototype.gotoAndPlay = function(frameNumber) -{ - this.currentFrame = frameNumber; - this.playing = true; -} - -/* - * Updates the object transform for rendering - * - * @method updateTransform - * @private - */ -PIXI.MovieClip.prototype.updateTransform = function() -{ - PIXI.Sprite.prototype.updateTransform.call(this); - - if(!this.playing)return; - - this.currentFrame += this.animationSpeed; - - var round = (this.currentFrame + 0.5) | 0; - - if(this.loop || round < this.textures.length) - { - this.setTexture(this.textures[round % this.textures.length]); - } - else if(round >= this.textures.length) - { - this.gotoAndStop(this.textures.length - 1); - if(this.onComplete) - { - this.onComplete(); - } - } -} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -2295,1467 +2183,6 @@ PIXI.Rope.prototype.setTexture = function(texture) -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * based on pixi impact spine implementation made by Eemeli Kelokorpi (@ekelokorpi) https://github.com/ekelokorpi - * - * Awesome JS run time provided by EsotericSoftware - * https://github.com/EsotericSoftware/spine-runtimes - * - */ - -/** - * A class that enables the you to import and run your spine animations in pixi. - * Spine animation data needs to be loaded using the PIXI.AssetLoader or PIXI.SpineLoader before it can be used by this class - * See example 12 (http://www.goodboydigital.com/pixijs/examples/12/) to see a working example and check out the source - * - * @class Spine - * @extends DisplayObjectContainer - * @constructor - * @param url {String} The url of the spine anim file to be used - */ -PIXI.Spine = function (url) { - PIXI.DisplayObjectContainer.call(this); - - this.spineData = PIXI.AnimCache[url]; - - if (!this.spineData) { - throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: " + url); - } - - this.skeleton = new spine.Skeleton(this.spineData); - this.skeleton.updateWorldTransform(); - - this.stateData = new spine.AnimationStateData(this.spineData); - this.state = new spine.AnimationState(this.stateData); - - this.slotContainers = []; - - for (var i = 0, n = this.skeleton.drawOrder.length; i < n; i++) { - var slot = this.skeleton.drawOrder[i]; - var attachment = slot.attachment; - var slotContainer = new PIXI.DisplayObjectContainer(); - this.slotContainers.push(slotContainer); - this.addChild(slotContainer); - if (!(attachment instanceof spine.RegionAttachment)) { - continue; - } - var spriteName = attachment.rendererObject.name; - var sprite = this.createSprite(slot, attachment.rendererObject); - slot.currentSprite = sprite; - slot.currentSpriteName = spriteName; - slotContainer.addChild(sprite); - } -}; - -PIXI.Spine.prototype = Object.create(PIXI.DisplayObjectContainer.prototype); -PIXI.Spine.prototype.constructor = PIXI.Spine; - -/* - * Updates the object transform for rendering - * - * @method updateTransform - * @private - */ -PIXI.Spine.prototype.updateTransform = function () { - this.lastTime = this.lastTime || Date.now(); - var timeDelta = (Date.now() - this.lastTime) * 0.001; - this.lastTime = Date.now(); - this.state.update(timeDelta); - this.state.apply(this.skeleton); - this.skeleton.updateWorldTransform(); - - var drawOrder = this.skeleton.drawOrder; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = drawOrder[i]; - var attachment = slot.attachment; - var slotContainer = this.slotContainers[i]; - if (!(attachment instanceof spine.RegionAttachment)) { - slotContainer.visible = false; - continue; - } - - if (attachment.rendererObject) { - if (!slot.currentSpriteName || slot.currentSpriteName != attachment.name) { - var spriteName = attachment.rendererObject.name; - if (slot.currentSprite !== undefined) { - slot.currentSprite.visible = false; - } - slot.sprites = slot.sprites || {}; - if (slot.sprites[spriteName] !== undefined) { - slot.sprites[spriteName].visible = true; - } else { - var sprite = this.createSprite(slot, attachment.rendererObject); - slotContainer.addChild(sprite); - } - slot.currentSprite = slot.sprites[spriteName]; - slot.currentSpriteName = spriteName; - } - } - slotContainer.visible = true; - - var bone = slot.bone; - - slotContainer.position.x = bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01; - slotContainer.position.y = bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11; - slotContainer.scale.x = bone.worldScaleX; - slotContainer.scale.y = bone.worldScaleY; - - slotContainer.rotation = -(slot.bone.worldRotation * Math.PI / 180); - } - - PIXI.DisplayObjectContainer.prototype.updateTransform.call(this); -}; - - -PIXI.Spine.prototype.createSprite = function (slot, descriptor) { - var name = PIXI.TextureCache[descriptor.name] ? descriptor.name : descriptor.name + ".png"; - var sprite = new PIXI.Sprite(PIXI.Texture.fromFrame(name)); - sprite.scale = descriptor.scale; - sprite.rotation = descriptor.rotation; - sprite.anchor.x = sprite.anchor.y = 0.5; - - slot.sprites = slot.sprites || {}; - slot.sprites[descriptor.name] = sprite; - return sprite; -}; - -/* - * Awesome JS run time provided by EsotericSoftware - * - * https://github.com/EsotericSoftware/spine-runtimes - * - */ - -var spine = {}; - -spine.BoneData = function (name, parent) { - this.name = name; - this.parent = parent; -}; -spine.BoneData.prototype = { - length: 0, - x: 0, y: 0, - rotation: 0, - scaleX: 1, scaleY: 1 -}; - -spine.SlotData = function (name, boneData) { - this.name = name; - this.boneData = boneData; -}; -spine.SlotData.prototype = { - r: 1, g: 1, b: 1, a: 1, - attachmentName: null -}; - -spine.Bone = function (boneData, parent) { - this.data = boneData; - this.parent = parent; - this.setToSetupPose(); -}; -spine.Bone.yDown = false; -spine.Bone.prototype = { - x: 0, y: 0, - rotation: 0, - scaleX: 1, scaleY: 1, - m00: 0, m01: 0, worldX: 0, // a b x - m10: 0, m11: 0, worldY: 0, // c d y - worldRotation: 0, - worldScaleX: 1, worldScaleY: 1, - updateWorldTransform: function (flipX, flipY) { - var parent = this.parent; - if (parent != null) { - this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX; - this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY; - this.worldScaleX = parent.worldScaleX * this.scaleX; - this.worldScaleY = parent.worldScaleY * this.scaleY; - this.worldRotation = parent.worldRotation + this.rotation; - } else { - this.worldX = this.x; - this.worldY = this.y; - this.worldScaleX = this.scaleX; - this.worldScaleY = this.scaleY; - this.worldRotation = this.rotation; - } - var radians = this.worldRotation * Math.PI / 180; - var cos = Math.cos(radians); - var sin = Math.sin(radians); - this.m00 = cos * this.worldScaleX; - this.m10 = sin * this.worldScaleX; - this.m01 = -sin * this.worldScaleY; - this.m11 = cos * this.worldScaleY; - if (flipX) { - this.m00 = -this.m00; - this.m01 = -this.m01; - } - if (flipY) { - this.m10 = -this.m10; - this.m11 = -this.m11; - } - if (spine.Bone.yDown) { - this.m10 = -this.m10; - this.m11 = -this.m11; - } - }, - setToSetupPose: function () { - var data = this.data; - this.x = data.x; - this.y = data.y; - this.rotation = data.rotation; - this.scaleX = data.scaleX; - this.scaleY = data.scaleY; - } -}; - -spine.Slot = function (slotData, skeleton, bone) { - this.data = slotData; - this.skeleton = skeleton; - this.bone = bone; - this.setToSetupPose(); -}; -spine.Slot.prototype = { - r: 1, g: 1, b: 1, a: 1, - _attachmentTime: 0, - attachment: null, - setAttachment: function (attachment) { - this.attachment = attachment; - this._attachmentTime = this.skeleton.time; - }, - setAttachmentTime: function (time) { - this._attachmentTime = this.skeleton.time - time; - }, - getAttachmentTime: function () { - return this.skeleton.time - this._attachmentTime; - }, - setToSetupPose: function () { - var data = this.data; - this.r = data.r; - this.g = data.g; - this.b = data.b; - this.a = data.a; - - var slotDatas = this.skeleton.data.slots; - for (var i = 0, n = slotDatas.length; i < n; i++) { - if (slotDatas[i] == data) { - this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachmentBySlotIndex(i, data.attachmentName)); - break; - } - } - } -}; - -spine.Skin = function (name) { - this.name = name; - this.attachments = {}; -}; -spine.Skin.prototype = { - addAttachment: function (slotIndex, name, attachment) { - this.attachments[slotIndex + ":" + name] = attachment; - }, - getAttachment: function (slotIndex, name) { - return this.attachments[slotIndex + ":" + name]; - }, - _attachAll: function (skeleton, oldSkin) { - for (var key in oldSkin.attachments) { - var colon = key.indexOf(":"); - var slotIndex = parseInt(key.substring(0, colon)); - var name = key.substring(colon + 1); - var slot = skeleton.slots[slotIndex]; - if (slot.attachment && slot.attachment.name == name) { - var attachment = this.getAttachment(slotIndex, name); - if (attachment) slot.setAttachment(attachment); - } - } - } -}; - -spine.Animation = function (name, timelines, duration) { - this.name = name; - this.timelines = timelines; - this.duration = duration; -}; -spine.Animation.prototype = { - apply: function (skeleton, time, loop) { - if (loop && this.duration != 0) time %= this.duration; - var timelines = this.timelines; - for (var i = 0, n = timelines.length; i < n; i++) - timelines[i].apply(skeleton, time, 1); - }, - mix: function (skeleton, time, loop, alpha) { - if (loop && this.duration != 0) time %= this.duration; - var timelines = this.timelines; - for (var i = 0, n = timelines.length; i < n; i++) - timelines[i].apply(skeleton, time, alpha); - } -}; - -spine.binarySearch = function (values, target, step) { - var low = 0; - var high = Math.floor(values.length / step) - 2; - if (high == 0) return step; - var current = high >>> 1; - while (true) { - if (values[(current + 1) * step] <= target) - low = current + 1; - else - high = current; - if (low == high) return (low + 1) * step; - current = (low + high) >>> 1; - } -}; -spine.linearSearch = function (values, target, step) { - for (var i = 0, last = values.length - step; i <= last; i += step) - if (values[i] > target) return i; - return -1; -}; - -spine.Curves = function (frameCount) { - this.curves = []; // dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... - this.curves.length = (frameCount - 1) * 6; -}; -spine.Curves.prototype = { - setLinear: function (frameIndex) { - this.curves[frameIndex * 6] = 0/*LINEAR*/; - }, - setStepped: function (frameIndex) { - this.curves[frameIndex * 6] = -1/*STEPPED*/; - }, - /** Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. - * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of - * the difference between the keyframe's values. */ - setCurve: function (frameIndex, cx1, cy1, cx2, cy2) { - var subdiv_step = 1 / 10/*BEZIER_SEGMENTS*/; - var subdiv_step2 = subdiv_step * subdiv_step; - var subdiv_step3 = subdiv_step2 * subdiv_step; - var pre1 = 3 * subdiv_step; - var pre2 = 3 * subdiv_step2; - var pre4 = 6 * subdiv_step2; - var pre5 = 6 * subdiv_step3; - var tmp1x = -cx1 * 2 + cx2; - var tmp1y = -cy1 * 2 + cy2; - var tmp2x = (cx1 - cx2) * 3 + 1; - var tmp2y = (cy1 - cy2) * 3 + 1; - var i = frameIndex * 6; - var curves = this.curves; - curves[i] = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; - curves[i + 1] = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; - curves[i + 2] = tmp1x * pre4 + tmp2x * pre5; - curves[i + 3] = tmp1y * pre4 + tmp2y * pre5; - curves[i + 4] = tmp2x * pre5; - curves[i + 5] = tmp2y * pre5; - }, - getCurvePercent: function (frameIndex, percent) { - percent = percent < 0 ? 0 : (percent > 1 ? 1 : percent); - var curveIndex = frameIndex * 6; - var curves = this.curves; - var dfx = curves[curveIndex]; - if (!dfx/*LINEAR*/) return percent; - if (dfx == -1/*STEPPED*/) return 0; - var dfy = curves[curveIndex + 1]; - var ddfx = curves[curveIndex + 2]; - var ddfy = curves[curveIndex + 3]; - var dddfx = curves[curveIndex + 4]; - var dddfy = curves[curveIndex + 5]; - var x = dfx, y = dfy; - var i = 10/*BEZIER_SEGMENTS*/ - 2; - while (true) { - if (x >= percent) { - var lastX = x - dfx; - var lastY = y - dfy; - return lastY + (y - lastY) * (percent - lastX) / (x - lastX); - } - if (i == 0) break; - i--; - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - x += dfx; - y += dfy; - } - return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1. - } -}; - -spine.RotateTimeline = function (frameCount) { - this.curves = new spine.Curves(frameCount); - this.frames = []; // time, angle, ... - this.frames.length = frameCount * 2; -}; -spine.RotateTimeline.prototype = { - boneIndex: 0, - getFrameCount: function () { - return this.frames.length / 2; - }, - setFrame: function (frameIndex, time, angle) { - frameIndex *= 2; - this.frames[frameIndex] = time; - this.frames[frameIndex + 1] = angle; - }, - apply: function (skeleton, time, alpha) { - var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. - - var bone = skeleton.bones[this.boneIndex]; - - if (time >= frames[frames.length - 2]) { // Time is after last frame. - var amount = bone.data.rotation + frames[frames.length - 1] - bone.rotation; - while (amount > 180) - amount -= 360; - while (amount < -180) - amount += 360; - bone.rotation += amount * alpha; - return; - } - - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 2); - var lastFrameValue = frames[frameIndex - 1]; - var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*LAST_FRAME_TIME*/] - frameTime); - percent = this.curves.getCurvePercent(frameIndex / 2 - 1, percent); - - var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue; - while (amount > 180) - amount -= 360; - while (amount < -180) - amount += 360; - amount = bone.data.rotation + (lastFrameValue + amount * percent) - bone.rotation; - while (amount > 180) - amount -= 360; - while (amount < -180) - amount += 360; - bone.rotation += amount * alpha; - } -}; - -spine.TranslateTimeline = function (frameCount) { - this.curves = new spine.Curves(frameCount); - this.frames = []; // time, x, y, ... - this.frames.length = frameCount * 3; -}; -spine.TranslateTimeline.prototype = { - boneIndex: 0, - getFrameCount: function () { - return this.frames.length / 3; - }, - setFrame: function (frameIndex, time, x, y) { - frameIndex *= 3; - this.frames[frameIndex] = time; - this.frames[frameIndex + 1] = x; - this.frames[frameIndex + 2] = y; - }, - apply: function (skeleton, time, alpha) { - var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. - - var bone = skeleton.bones[this.boneIndex]; - - if (time >= frames[frames.length - 3]) { // Time is after last frame. - bone.x += (bone.data.x + frames[frames.length - 2] - bone.x) * alpha; - bone.y += (bone.data.y + frames[frames.length - 1] - bone.y) * alpha; - return; - } - - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 3); - var lastFrameX = frames[frameIndex - 2]; - var lastFrameY = frames[frameIndex - 1]; - var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); - percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); - - bone.x += (bone.data.x + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.x) * alpha; - bone.y += (bone.data.y + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.y) * alpha; - } -}; - -spine.ScaleTimeline = function (frameCount) { - this.curves = new spine.Curves(frameCount); - this.frames = []; // time, x, y, ... - this.frames.length = frameCount * 3; -}; -spine.ScaleTimeline.prototype = { - boneIndex: 0, - getFrameCount: function () { - return this.frames.length / 3; - }, - setFrame: function (frameIndex, time, x, y) { - frameIndex *= 3; - this.frames[frameIndex] = time; - this.frames[frameIndex + 1] = x; - this.frames[frameIndex + 2] = y; - }, - apply: function (skeleton, time, alpha) { - var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. - - var bone = skeleton.bones[this.boneIndex]; - - if (time >= frames[frames.length - 3]) { // Time is after last frame. - bone.scaleX += (bone.data.scaleX - 1 + frames[frames.length - 2] - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - 1 + frames[frames.length - 1] - bone.scaleY) * alpha; - return; - } - - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 3); - var lastFrameX = frames[frameIndex - 2]; - var lastFrameY = frames[frameIndex - 1]; - var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); - percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); - - bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha; - } -}; - -spine.ColorTimeline = function (frameCount) { - this.curves = new spine.Curves(frameCount); - this.frames = []; // time, r, g, b, a, ... - this.frames.length = frameCount * 5; -}; -spine.ColorTimeline.prototype = { - slotIndex: 0, - getFrameCount: function () { - return this.frames.length / 2; - }, - setFrame: function (frameIndex, time, x, y) { - frameIndex *= 5; - this.frames[frameIndex] = time; - this.frames[frameIndex + 1] = r; - this.frames[frameIndex + 2] = g; - this.frames[frameIndex + 3] = b; - this.frames[frameIndex + 4] = a; - }, - apply: function (skeleton, time, alpha) { - var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. - - var slot = skeleton.slots[this.slotIndex]; - - if (time >= frames[frames.length - 5]) { // Time is after last frame. - var i = frames.length - 1; - slot.r = frames[i - 3]; - slot.g = frames[i - 2]; - slot.b = frames[i - 1]; - slot.a = frames[i]; - return; - } - - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 5); - var lastFrameR = frames[frameIndex - 4]; - var lastFrameG = frames[frameIndex - 3]; - var lastFrameB = frames[frameIndex - 2]; - var lastFrameA = frames[frameIndex - 1]; - var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex - 5/*LAST_FRAME_TIME*/] - frameTime); - percent = this.curves.getCurvePercent(frameIndex / 5 - 1, percent); - - var r = lastFrameR + (frames[frameIndex + 1/*FRAME_R*/] - lastFrameR) * percent; - var g = lastFrameG + (frames[frameIndex + 2/*FRAME_G*/] - lastFrameG) * percent; - var b = lastFrameB + (frames[frameIndex + 3/*FRAME_B*/] - lastFrameB) * percent; - var a = lastFrameA + (frames[frameIndex + 4/*FRAME_A*/] - lastFrameA) * percent; - if (alpha < 1) { - slot.r += (r - slot.r) * alpha; - slot.g += (g - slot.g) * alpha; - slot.b += (b - slot.b) * alpha; - slot.a += (a - slot.a) * alpha; - } else { - slot.r = r; - slot.g = g; - slot.b = b; - slot.a = a; - } - } -}; - -spine.AttachmentTimeline = function (frameCount) { - this.curves = new spine.Curves(frameCount); - this.frames = []; // time, ... - this.frames.length = frameCount; - this.attachmentNames = []; // time, ... - this.attachmentNames.length = frameCount; -}; -spine.AttachmentTimeline.prototype = { - slotIndex: 0, - getFrameCount: function () { - return this.frames.length; - }, - setFrame: function (frameIndex, time, attachmentName) { - this.frames[frameIndex] = time; - this.attachmentNames[frameIndex] = attachmentName; - }, - apply: function (skeleton, time, alpha) { - var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. - - var frameIndex; - if (time >= frames[frames.length - 1]) // Time is after last frame. - frameIndex = frames.length - 1; - else - frameIndex = spine.binarySearch(frames, time, 1) - 1; - - var attachmentName = this.attachmentNames[frameIndex]; - skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName)); - } -}; - -spine.SkeletonData = function () { - this.bones = []; - this.slots = []; - this.skins = []; - this.animations = []; -}; -spine.SkeletonData.prototype = { - defaultSkin: null, - /** @return May be null. */ - findBone: function (boneName) { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].name == boneName) return bones[i]; - return null; - }, - /** @return -1 if the bone was not found. */ - findBoneIndex: function (boneName) { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].name == boneName) return i; - return -1; - }, - /** @return May be null. */ - findSlot: function (slotName) { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - if (slots[i].name == slotName) return slot[i]; - } - return null; - }, - /** @return -1 if the bone was not found. */ - findSlotIndex: function (slotName) { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].name == slotName) return i; - return -1; - }, - /** @return May be null. */ - findSkin: function (skinName) { - var skins = this.skins; - for (var i = 0, n = skins.length; i < n; i++) - if (skins[i].name == skinName) return skins[i]; - return null; - }, - /** @return May be null. */ - findAnimation: function (animationName) { - var animations = this.animations; - for (var i = 0, n = animations.length; i < n; i++) - if (animations[i].name == animationName) return animations[i]; - return null; - } -}; - -spine.Skeleton = function (skeletonData) { - this.data = skeletonData; - - this.bones = []; - for (var i = 0, n = skeletonData.bones.length; i < n; i++) { - var boneData = skeletonData.bones[i]; - var parent = !boneData.parent ? null : this.bones[skeletonData.bones.indexOf(boneData.parent)]; - this.bones.push(new spine.Bone(boneData, parent)); - } - - this.slots = []; - this.drawOrder = []; - for (var i = 0, n = skeletonData.slots.length; i < n; i++) { - var slotData = skeletonData.slots[i]; - var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)]; - var slot = new spine.Slot(slotData, this, bone); - this.slots.push(slot); - this.drawOrder.push(slot); - } -}; -spine.Skeleton.prototype = { - x: 0, y: 0, - skin: null, - r: 1, g: 1, b: 1, a: 1, - time: 0, - flipX: false, flipY: false, - /** Updates the world transform for each bone. */ - updateWorldTransform: function () { - var flipX = this.flipX; - var flipY = this.flipY; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - bones[i].updateWorldTransform(flipX, flipY); - }, - /** Sets the bones and slots to their setup pose values. */ - setToSetupPose: function () { - this.setBonesToSetupPose(); - this.setSlotsToSetupPose(); - }, - setBonesToSetupPose: function () { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - bones[i].setToSetupPose(); - }, - setSlotsToSetupPose: function () { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - slots[i].setToSetupPose(i); - }, - /** @return May return null. */ - getRootBone: function () { - return this.bones.length == 0 ? null : this.bones[0]; - }, - /** @return May be null. */ - findBone: function (boneName) { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].data.name == boneName) return bones[i]; - return null; - }, - /** @return -1 if the bone was not found. */ - findBoneIndex: function (boneName) { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].data.name == boneName) return i; - return -1; - }, - /** @return May be null. */ - findSlot: function (slotName) { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].data.name == slotName) return slots[i]; - return null; - }, - /** @return -1 if the bone was not found. */ - findSlotIndex: function (slotName) { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].data.name == slotName) return i; - return -1; - }, - setSkinByName: function (skinName) { - var skin = this.data.findSkin(skinName); - if (!skin) throw "Skin not found: " + skinName; - this.setSkin(skin); - }, - /** Sets the skin used to look up attachments not found in the {@link SkeletonData#getDefaultSkin() default skin}. Attachments - * from the new skin are attached if the corresponding attachment from the old skin was attached. - * @param newSkin May be null. */ - setSkin: function (newSkin) { - if (this.skin && newSkin) newSkin._attachAll(this, this.skin); - this.skin = newSkin; - }, - /** @return May be null. */ - getAttachmentBySlotName: function (slotName, attachmentName) { - return this.getAttachmentBySlotIndex(this.data.findSlotIndex(slotName), attachmentName); - }, - /** @return May be null. */ - getAttachmentBySlotIndex: function (slotIndex, attachmentName) { - if (this.skin) { - var attachment = this.skin.getAttachment(slotIndex, attachmentName); - if (attachment) return attachment; - } - if (this.data.defaultSkin) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); - return null; - }, - /** @param attachmentName May be null. */ - setAttachment: function (slotName, attachmentName) { - var slots = this.slots; - for (var i = 0, n = slots.size; i < n; i++) { - var slot = slots[i]; - if (slot.data.name == slotName) { - var attachment = null; - if (attachmentName) { - attachment = this.getAttachment(i, attachmentName); - if (attachment == null) throw "Attachment not found: " + attachmentName + ", for slot: " + slotName; - } - slot.setAttachment(attachment); - return; - } - } - throw "Slot not found: " + slotName; - }, - update: function (delta) { - time += delta; - } -}; - -spine.AttachmentType = { - region: 0 -}; - -spine.RegionAttachment = function () { - this.offset = []; - this.offset.length = 8; - this.uvs = []; - this.uvs.length = 8; -}; -spine.RegionAttachment.prototype = { - x: 0, y: 0, - rotation: 0, - scaleX: 1, scaleY: 1, - width: 0, height: 0, - rendererObject: null, - regionOffsetX: 0, regionOffsetY: 0, - regionWidth: 0, regionHeight: 0, - regionOriginalWidth: 0, regionOriginalHeight: 0, - setUVs: function (u, v, u2, v2, rotate) { - var uvs = this.uvs; - if (rotate) { - uvs[2/*X2*/] = u; - uvs[3/*Y2*/] = v2; - uvs[4/*X3*/] = u; - uvs[5/*Y3*/] = v; - uvs[6/*X4*/] = u2; - uvs[7/*Y4*/] = v; - uvs[0/*X1*/] = u2; - uvs[1/*Y1*/] = v2; - } else { - uvs[0/*X1*/] = u; - uvs[1/*Y1*/] = v2; - uvs[2/*X2*/] = u; - uvs[3/*Y2*/] = v; - uvs[4/*X3*/] = u2; - uvs[5/*Y3*/] = v; - uvs[6/*X4*/] = u2; - uvs[7/*Y4*/] = v2; - } - }, - updateOffset: function () { - var regionScaleX = this.width / this.regionOriginalWidth * this.scaleX; - var regionScaleY = this.height / this.regionOriginalHeight * this.scaleY; - var localX = -this.width / 2 * this.scaleX + this.regionOffsetX * regionScaleX; - var localY = -this.height / 2 * this.scaleY + this.regionOffsetY * regionScaleY; - var localX2 = localX + this.regionWidth * regionScaleX; - var localY2 = localY + this.regionHeight * regionScaleY; - var radians = this.rotation * Math.PI / 180; - var cos = Math.cos(radians); - var sin = Math.sin(radians); - var localXCos = localX * cos + this.x; - var localXSin = localX * sin; - var localYCos = localY * cos + this.y; - var localYSin = localY * sin; - var localX2Cos = localX2 * cos + this.x; - var localX2Sin = localX2 * sin; - var localY2Cos = localY2 * cos + this.y; - var localY2Sin = localY2 * sin; - var offset = this.offset; - offset[0/*X1*/] = localXCos - localYSin; - offset[1/*Y1*/] = localYCos + localXSin; - offset[2/*X2*/] = localXCos - localY2Sin; - offset[3/*Y2*/] = localY2Cos + localXSin; - offset[4/*X3*/] = localX2Cos - localY2Sin; - offset[5/*Y3*/] = localY2Cos + localX2Sin; - offset[6/*X4*/] = localX2Cos - localYSin; - offset[7/*Y4*/] = localYCos + localX2Sin; - }, - computeVertices: function (x, y, bone, vertices) { - x += bone.worldX; - y += bone.worldY; - var m00 = bone.m00; - var m01 = bone.m01; - var m10 = bone.m10; - var m11 = bone.m11; - var offset = this.offset; - vertices[0/*X1*/] = offset[0/*X1*/] * m00 + offset[1/*Y1*/] * m01 + x; - vertices[1/*Y1*/] = offset[0/*X1*/] * m10 + offset[1/*Y1*/] * m11 + y; - vertices[2/*X2*/] = offset[2/*X2*/] * m00 + offset[3/*Y2*/] * m01 + x; - vertices[3/*Y2*/] = offset[2/*X2*/] * m10 + offset[3/*Y2*/] * m11 + y; - vertices[4/*X3*/] = offset[4/*X3*/] * m00 + offset[5/*X3*/] * m01 + x; - vertices[5/*X3*/] = offset[4/*X3*/] * m10 + offset[5/*X3*/] * m11 + y; - vertices[6/*X4*/] = offset[6/*X4*/] * m00 + offset[7/*Y4*/] * m01 + x; - vertices[7/*Y4*/] = offset[6/*X4*/] * m10 + offset[7/*Y4*/] * m11 + y; - } -} - -spine.AnimationStateData = function (skeletonData) { - this.skeletonData = skeletonData; - this.animationToMixTime = {}; -}; -spine.AnimationStateData.prototype = { - defaultMix: 0, - setMixByName: function (fromName, toName, duration) { - var from = this.skeletonData.findAnimation(fromName); - if (!from) throw "Animation not found: " + fromName; - var to = this.skeletonData.findAnimation(toName); - if (!to) throw "Animation not found: " + toName; - this.setMix(from, to, duration); - }, - setMix: function (from, to, duration) { - this.animationToMixTime[from.name + ":" + to.name] = duration; - }, - getMix: function (from, to) { - var time = this.animationToMixTime[from.name + ":" + to.name]; - return time ? time : this.defaultMix; - } -}; - -spine.AnimationState = function (stateData) { - this.data = stateData; - this.queue = []; -}; -spine.AnimationState.prototype = { - current: null, - previous: null, - currentTime: 0, - previousTime: 0, - currentLoop: false, - previousLoop: false, - mixTime: 0, - mixDuration: 0, - update: function (delta) { - this.currentTime += delta; - this.previousTime += delta; - this.mixTime += delta; - - if (this.queue.length > 0) { - var entry = this.queue[0]; - if (this.currentTime >= entry.delay) { - this._setAnimation(entry.animation, entry.loop); - this.queue.shift(); - } - } - }, - apply: function (skeleton) { - if (!this.current) return; - if (this.previous) { - this.previous.apply(skeleton, this.previousTime, this.previousLoop); - var alpha = this.mixTime / this.mixDuration; - if (alpha >= 1) { - alpha = 1; - this.previous = null; - } - this.current.mix(skeleton, this.currentTime, this.currentLoop, alpha); - } else - this.current.apply(skeleton, this.currentTime, this.currentLoop); - }, - clearAnimation: function () { - this.previous = null; - this.current = null; - this.queue.length = 0; - }, - _setAnimation: function (animation, loop) { - this.previous = null; - if (animation && this.current) { - this.mixDuration = this.data.getMix(this.current, animation); - if (this.mixDuration > 0) { - this.mixTime = 0; - this.previous = this.current; - this.previousTime = this.currentTime; - this.previousLoop = this.currentLoop; - } - } - this.current = animation; - this.currentLoop = loop; - this.currentTime = 0; - }, - /** @see #setAnimation(Animation, Boolean) */ - setAnimationByName: function (animationName, loop) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (!animation) throw "Animation not found: " + animationName; - this.setAnimation(animation, loop); - }, - /** Set the current animation. Any queued animations are cleared and the current animation time is set to 0. - * @param animation May be null. */ - setAnimation: function (animation, loop) { - this.queue.length = 0; - this._setAnimation(animation, loop); - }, - /** @see #addAnimation(Animation, Boolean, Number) */ - addAnimationByName: function (animationName, loop, delay) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (!animation) throw "Animation not found: " + animationName; - this.addAnimation(animation, loop, delay); - }, - /** Adds an animation to be played delay seconds after the current or last queued animation. - * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay. */ - addAnimation: function (animation, loop, delay) { - var entry = {}; - entry.animation = animation; - entry.loop = loop; - - if (!delay || delay <= 0) { - var previousAnimation = this.queue.length == 0 ? this.current : this.queue[this.queue.length - 1].animation; - if (previousAnimation != null) - delay = previousAnimation.duration - this.data.getMix(previousAnimation, animation) + (delay || 0); - else - delay = 0; - } - entry.delay = delay; - - this.queue.push(entry); - }, - /** Returns true if no animation is set or if the current time is greater than the animation duration, regardless of looping. */ - isComplete: function () { - return !this.current || this.currentTime >= this.current.duration; - } -}; - -spine.SkeletonJson = function (attachmentLoader) { - this.attachmentLoader = attachmentLoader; -}; -spine.SkeletonJson.prototype = { - scale: 1, - readSkeletonData: function (root) { - var skeletonData = new spine.SkeletonData(); - - // Bones. - var bones = root["bones"]; - for (var i = 0, n = bones.length; i < n; i++) { - var boneMap = bones[i]; - var parent = null; - if (boneMap["parent"]) { - parent = skeletonData.findBone(boneMap["parent"]); - if (!parent) throw "Parent bone not found: " + boneMap["parent"]; - } - var boneData = new spine.BoneData(boneMap["name"], parent); - boneData.length = (boneMap["length"] || 0) * this.scale; - boneData.x = (boneMap["x"] || 0) * this.scale; - boneData.y = (boneMap["y"] || 0) * this.scale; - boneData.rotation = (boneMap["rotation"] || 0); - boneData.scaleX = boneMap["scaleX"] || 1; - boneData.scaleY = boneMap["scaleY"] || 1; - skeletonData.bones.push(boneData); - } - - // Slots. - var slots = root["slots"]; - for (var i = 0, n = slots.length; i < n; i++) { - var slotMap = slots[i]; - var boneData = skeletonData.findBone(slotMap["bone"]); - if (!boneData) throw "Slot bone not found: " + slotMap["bone"]; - var slotData = new spine.SlotData(slotMap["name"], boneData); - - var color = slotMap["color"]; - if (color) { - slotData.r = spine.SkeletonJson.toColor(color, 0); - slotData.g = spine.SkeletonJson.toColor(color, 1); - slotData.b = spine.SkeletonJson.toColor(color, 2); - slotData.a = spine.SkeletonJson.toColor(color, 3); - } - - slotData.attachmentName = slotMap["attachment"]; - - skeletonData.slots.push(slotData); - } - - // Skins. - var skins = root["skins"]; - for (var skinName in skins) { - if (!skins.hasOwnProperty(skinName)) continue; - var skinMap = skins[skinName]; - var skin = new spine.Skin(skinName); - for (var slotName in skinMap) { - if (!skinMap.hasOwnProperty(slotName)) continue; - var slotIndex = skeletonData.findSlotIndex(slotName); - var slotEntry = skinMap[slotName]; - for (var attachmentName in slotEntry) { - if (!slotEntry.hasOwnProperty(attachmentName)) continue; - var attachment = this.readAttachment(skin, attachmentName, slotEntry[attachmentName]); - if (attachment != null) skin.addAttachment(slotIndex, attachmentName, attachment); - } - } - skeletonData.skins.push(skin); - if (skin.name == "default") skeletonData.defaultSkin = skin; - } - - // Animations. - var animations = root["animations"]; - for (var animationName in animations) { - if (!animations.hasOwnProperty(animationName)) continue; - this.readAnimation(animationName, animations[animationName], skeletonData); - } - - return skeletonData; - }, - readAttachment: function (skin, name, map) { - name = map["name"] || name; - - var type = spine.AttachmentType[map["type"] || "region"]; - - if (type == spine.AttachmentType.region) { - var attachment = new spine.RegionAttachment(); - attachment.x = (map["x"] || 0) * this.scale; - attachment.y = (map["y"] || 0) * this.scale; - attachment.scaleX = map["scaleX"] || 1; - attachment.scaleY = map["scaleY"] || 1; - attachment.rotation = map["rotation"] || 0; - attachment.width = (map["width"] || 32) * this.scale; - attachment.height = (map["height"] || 32) * this.scale; - attachment.updateOffset(); - - attachment.rendererObject = {}; - attachment.rendererObject.name = name; - attachment.rendererObject.scale = {}; - attachment.rendererObject.scale.x = attachment.scaleX; - attachment.rendererObject.scale.y = attachment.scaleY; - attachment.rendererObject.rotation = -attachment.rotation * Math.PI / 180; - return attachment; - } - - throw "Unknown attachment type: " + type; - }, - - readAnimation: function (name, map, skeletonData) { - var timelines = []; - var duration = 0; - - var bones = map["bones"]; - for (var boneName in bones) { - if (!bones.hasOwnProperty(boneName)) continue; - var boneIndex = skeletonData.findBoneIndex(boneName); - if (boneIndex == -1) throw "Bone not found: " + boneName; - var boneMap = bones[boneName]; - - for (var timelineName in boneMap) { - if (!boneMap.hasOwnProperty(timelineName)) continue; - var values = boneMap[timelineName]; - if (timelineName == "rotate") { - var timeline = new spine.RotateTimeline(values.length); - timeline.boneIndex = boneIndex; - - var frameIndex = 0; - for (var i = 0, n = values.length; i < n; i++) { - var valueMap = values[i]; - timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]); - - } else if (timelineName == "translate" || timelineName == "scale") { - var timeline; - var timelineScale = 1; - if (timelineName == "scale") - timeline = new spine.ScaleTimeline(values.length); - else { - timeline = new spine.TranslateTimeline(values.length); - timelineScale = this.scale; - } - timeline.boneIndex = boneIndex; - - var frameIndex = 0; - for (var i = 0, n = values.length; i < n; i++) { - var valueMap = values[i]; - var x = (valueMap["x"] || 0) * timelineScale; - var y = (valueMap["y"] || 0) * timelineScale; - timeline.setFrame(frameIndex, valueMap["time"], x, y); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 3 - 3]); - - } else - throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"; - } - } - var slots = map["slots"]; - for (var slotName in slots) { - if (!slots.hasOwnProperty(slotName)) continue; - var slotMap = slots[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - - for (var timelineName in slotMap) { - if (!slotMap.hasOwnProperty(timelineName)) continue; - var values = slotMap[timelineName]; - if (timelineName == "color") { - var timeline = new spine.ColorTimeline(values.length); - timeline.slotIndex = slotIndex; - - var frameIndex = 0; - for (var i = 0, n = values.length; i < n; i++) { - var valueMap = values[i]; - var color = valueMap["color"]; - var r = spine.SkeletonJson.toColor(color, 0); - var g = spine.SkeletonJson.toColor(color, 1); - var b = spine.SkeletonJson.toColor(color, 2); - var a = spine.SkeletonJson.toColor(color, 3); - timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]); - - } else if (timelineName == "attachment") { - var timeline = new spine.AttachmentTimeline(values.length); - timeline.slotIndex = slotIndex; - - var frameIndex = 0; - for (var i = 0, n = values.length; i < n; i++) { - var valueMap = values[i]; - timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - - } else - throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"; - } - } - skeletonData.animations.push(new spine.Animation(name, timelines, duration)); - } -}; -spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) { - var curve = valueMap["curve"]; - if (!curve) return; - if (curve == "stepped") - timeline.curves.setStepped(frameIndex); - else if (curve instanceof Array) - timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); -}; -spine.SkeletonJson.toColor = function (hexString, colorIndex) { - if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString; - return parseInt(hexString.substring(colorIndex * 2, 2), 16) / 255; -}; - -spine.Atlas = function (atlasText, textureLoader) { - this.textureLoader = textureLoader; - this.pages = []; - this.regions = []; - - var reader = new spine.AtlasReader(atlasText); - var tuple = []; - tuple.length = 4; - var page = null; - while (true) { - var line = reader.readLine(); - if (line == null) break; - line = reader.trim(line); - if (line.length == 0) - page = null; - else if (!page) { - page = new spine.AtlasPage(); - page.name = line; - - page.format = spine.Atlas.Format[reader.readValue()]; - - reader.readTuple(tuple); - page.minFilter = spine.Atlas.TextureFilter[tuple[0]]; - page.magFilter = spine.Atlas.TextureFilter[tuple[1]]; - - var direction = reader.readValue(); - page.uWrap = spine.Atlas.TextureWrap.clampToEdge; - page.vWrap = spine.Atlas.TextureWrap.clampToEdge; - if (direction == "x") - page.uWrap = spine.Atlas.TextureWrap.repeat; - else if (direction == "y") - page.vWrap = spine.Atlas.TextureWrap.repeat; - else if (direction == "xy") - page.uWrap = page.vWrap = spine.Atlas.TextureWrap.repeat; - - textureLoader.load(page, line); - - this.pages.push(page); - - } else { - var region = new spine.AtlasRegion(); - region.name = line; - region.page = page; - - region.rotate = reader.readValue() == "true"; - - reader.readTuple(tuple); - var x = parseInt(tuple[0]); - var y = parseInt(tuple[1]); - - reader.readTuple(tuple); - var width = parseInt(tuple[0]); - var height = parseInt(tuple[1]); - - region.u = x / page.width; - region.v = y / page.height; - if (region.rotate) { - region.u2 = (x + height) / page.width; - region.v2 = (y + width) / page.height; - } else { - region.u2 = (x + width) / page.width; - region.v2 = (y + height) / page.height; - } - region.x = x; - region.y = y; - region.width = Math.abs(width); - region.height = Math.abs(height); - - if (reader.readTuple(tuple) == 4) { // split is optional - region.splits = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])]; - - if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits - region.pads = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])]; - - reader.readTuple(tuple); - } - } - - region.originalWidth = parseInt(tuple[0]); - region.originalHeight = parseInt(tuple[1]); - - reader.readTuple(tuple); - region.offsetX = parseInt(tuple[0]); - region.offsetY = parseInt(tuple[1]); - - region.index = parseInt(reader.readValue()); - - this.regions.push(region); - } - } -}; -spine.Atlas.prototype = { - findRegion: function (name) { - var regions = this.regions; - for (var i = 0, n = regions.length; i < n; i++) - if (regions[i].name == name) return regions[i]; - return null; - }, - dispose: function () { - var pages = this.pages; - for (var i = 0, n = pages.length; i < n; i++) - this.textureLoader.unload(pages[i].rendererObject); - }, - updateUVs: function (page) { - var regions = this.regions; - for (var i = 0, n = regions.length; i < n; i++) { - var region = regions[i]; - if (region.page != page) continue; - region.u = region.x / page.width; - region.v = region.y / page.height; - if (region.rotate) { - region.u2 = (region.x + region.height) / page.width; - region.v2 = (region.y + region.width) / page.height; - } else { - region.u2 = (region.x + region.width) / page.width; - region.v2 = (region.y + region.height) / page.height; - } - } - } -}; - -spine.Atlas.Format = { - alpha: 0, - intensity: 1, - luminanceAlpha: 2, - rgb565: 3, - rgba4444: 4, - rgb888: 5, - rgba8888: 6 -}; - -spine.Atlas.TextureFilter = { - nearest: 0, - linear: 1, - mipMap: 2, - mipMapNearestNearest: 3, - mipMapLinearNearest: 4, - mipMapNearestLinear: 5, - mipMapLinearLinear: 6 -}; - -spine.Atlas.TextureWrap = { - mirroredRepeat: 0, - clampToEdge: 1, - repeat: 2 -}; - -spine.AtlasPage = function () {}; -spine.AtlasPage.prototype = { - name: null, - format: null, - minFilter: null, - magFilter: null, - uWrap: null, - vWrap: null, - rendererObject: null, - width: 0, - height: 0 -}; - -spine.AtlasRegion = function () {}; -spine.AtlasRegion.prototype = { - page: null, - name: null, - x: 0, y: 0, - width: 0, height: 0, - u: 0, v: 0, u2: 0, v2: 0, - offsetX: 0, offsetY: 0, - originalWidth: 0, originalHeight: 0, - index: 0, - rotate: false, - splits: null, - pads: null, -}; - -spine.AtlasReader = function (text) { - this.lines = text.split(/\r\n|\r|\n/); -}; -spine.AtlasReader.prototype = { - index: 0, - trim: function (value) { - return value.replace(/^\s+|\s+$/g, ""); - }, - readLine: function () { - if (this.index >= this.lines.length) return null; - return this.lines[this.index++]; - }, - readValue: function () { - var line = this.readLine(); - var colon = line.indexOf(":"); - if (colon == -1) throw "Invalid line: " + line; - return this.trim(line.substring(colon + 1)); - }, - /** Returns the number of tuple values read (2 or 4). */ - readTuple: function (tuple) { - var line = this.readLine(); - var colon = line.indexOf(":"); - if (colon == -1) throw "Invalid line: " + line; - var i = 0, lastMatch= colon + 1; - for (; i < 3; i++) { - var comma = line.indexOf(",", lastMatch); - if (comma == -1) { - if (i == 0) throw "Invalid line: " + line; - break; - } - tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch)); - lastMatch = comma + 1; - } - tuple[i] = this.trim(line.substring(lastMatch)); - return i + 1; - } -} - -spine.AtlasAttachmentLoader = function (atlas) { - this.atlas = atlas; -} -spine.AtlasAttachmentLoader.prototype = { - newAttachment: function (skin, type, name) { - switch (type) { - case spine.AttachmentType.region: - var region = this.atlas.findRegion(name); - if (!region) throw "Region not found in atlas: " + name + " (" + type + ")"; - var attachment = new spine.RegionAttachment(name); - attachment.rendererObject = region; - attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate); - attachment.regionOffsetX = region.offsetX; - attachment.regionOffsetY = region.offsetY; - attachment.regionWidth = region.width; - attachment.regionHeight = region.height; - attachment.regionOriginalWidth = region.originalWidth; - attachment.regionOriginalHeight = region.originalHeight; - return attachment; - } - throw "Unknown attachment type: " + type; - } -} - -PIXI.AnimCache = {}; -spine.Bone.yDown = true; - /** * @author Mat Groves http://matgroves.com/ */ @@ -8703,9 +7130,44 @@ Phaser.Camera = function (game, id, x, y, width, height) { // The view into the world we wish to render (by default the game dimensions) // The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render // Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?) + + /** + * Camera view. + * @type {Rectangle} + */ this.view = new Phaser.Rectangle(x, y, width, height); + + /** + * Used by Sprites to work out Camera culling. + * @type {Rectangle} + */ this.screenView = new Phaser.Rectangle(x, y, width, height); + /** + * Sprite moving inside this Rectangle will not cause camera moving. + * @type {Rectangle} + */ + this.deadzone = null; + + /** + * Whether this camera is visible or not. (default is true) + * @type {bool} + */ + this.visible = true; + + /** + * Whether this camera is flush with the World Bounds or not. + * @type {bool} + */ + this.atLimit = { x: false, y: false }; + + /** + * If the camera is tracking a Sprite, this is a reference to it, otherwise null + * @type {Sprite} + */ + this.target = null; + + this._edge = 0; }; @@ -8717,35 +7179,6 @@ Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3; Phaser.Camera.prototype = { - game: null, - world: null, - - id: 0, - - /** - * Camera view. - * @type {Rectangle} - */ - view: null, - - /** - * Sprite moving inside this Rectangle will not cause camera moving. - * @type {Rectangle} - */ - deadzone: null, - - /** - * Whether this camera is visible or not. (default is true) - * @type {bool} - */ - visible: true, - - /** - * If the camera is tracking a Sprite, this is a reference to it, otherwise null - * @type {Sprite} - */ - target: null, - /** * Tells this camera which sprite to follow. * @param target {Sprite} The object you want the camera to track. Set to null to not follow anything. @@ -8761,23 +7194,23 @@ Phaser.Camera.prototype = { switch (style) { - case Phaser.Types.CAMERA_FOLLOW_PLATFORMER: + case Phaser.Camera.FOLLOW_PLATFORMER: var w = this.width / 8; var h = this.height / 3; this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h); break; - case Phaser.Types.CAMERA_FOLLOW_TOPDOWN: + case Phaser.Camera.FOLLOW_TOPDOWN: helper = Math.max(this.width, this.height) / 4; this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); break; - case Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT: + case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT: helper = Math.max(this.width, this.height) / 8; this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); break; - case Phaser.Types.CAMERA_FOLLOW_LOCKON: + case Phaser.Camera.FOLLOW_LOCKON: default: this.deadzone = null; break; @@ -8792,9 +7225,6 @@ Phaser.Camera.prototype = { */ focusOnXY: function (x, y) { - x += (x > 0) ? 0.0000001 : -0.0000001; - y += (y > 0) ? 0.0000001 : -0.0000001; - this.view.x = Math.round(x - this.view.halfWidth); this.view.y = Math.round(y - this.view.halfHeight); @@ -8805,83 +7235,89 @@ Phaser.Camera.prototype = { */ update: function () { - // this.plugins.preUpdate(); - // Add dirty flag if (this.target !== null) { - if (this.deadzone == null) + if (this.deadzone) { - this.focusOnXY(this.target.x, this.target.y); + this._edge = this.target.x - this.deadzone.x; + + if (this.view.x > this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width; + + if (this.view.x < this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.y - this.deadzone.y; + + if (this.view.y > this._edge) + { + this.view.y = this._edge; + } + + this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height; + + if (this.view.y < this._edge) + { + this.view.y = this._edge; + } } else { - var edge; - var targetX = this.target.x + ((this.target.x > 0) ? 0.0000001 : -0.0000001); - var targetY = this.target.y + ((this.target.y > 0) ? 0.0000001 : -0.0000001); - - edge = targetX - this.deadzone.x; - - if (this.view.x > edge) - { - this.view.x = edge; - } - - edge = targetX + this.target.width - this.deadzone.x - this.deadzone.width; - - if (this.view.x < edge) - { - this.view.x = edge; - } - - edge = targetY - this.deadzone.y; - - if (this.view.y > edge) - { - this.view.y = edge; - } - - edge = targetY + this.target.height - this.deadzone.y - this.deadzone.height; - - if (this.view.y < edge) - { - this.view.y = edge; - } + this.focusOnXY(this.target.x, this.target.y); } } + this.checkWorldBounds(); + + }, + + checkWorldBounds: function () { + + this.atLimit.x = false; + this.atLimit.y = false; + // Make sure we didn't go outside the cameras worldBounds if (this.view.x < this.world.bounds.left) { + this.atLimit.x = true; this.view.x = this.world.bounds.left; } if (this.view.x > this.world.bounds.right - this.width) { + this.atLimit.x = true; this.view.x = (this.world.bounds.right - this.width) + 1; } if (this.view.y < this.world.bounds.top) { + this.atLimit.y = true; this.view.y = this.world.bounds.top; } if (this.view.y > this.world.bounds.bottom - this.height) { + this.atLimit.y = true; this.view.y = (this.world.bounds.bottom - this.height) + 1; } this.view.floor(); - // this.plugins.update(); - }, setPosition: function (x, y) { this.view.x = x; this.view.y = y; + this.checkWorldBounds(); }, @@ -8902,10 +7338,9 @@ Object.defineProperty(Phaser.Camera.prototype, "x", { set: function (value) { this.view.x = value; - }, + this.checkWorldBounds(); + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Camera.prototype, "y", { @@ -8916,10 +7351,9 @@ Object.defineProperty(Phaser.Camera.prototype, "y", { set: function (value) { this.view.y = value; - }, + this.checkWorldBounds(); + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Camera.prototype, "width", { @@ -8930,10 +7364,8 @@ Object.defineProperty(Phaser.Camera.prototype, "width", { set: function (value) { this.view.width = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Camera.prototype, "height", { @@ -8944,10 +7376,8 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { set: function (value) { this.view.height = value; - }, + } - enumerable: true, - configurable: true }); /** @@ -8963,6 +7393,22 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { */ Phaser.State = function () { + + this.game = null; + this.add = null; + this.camera = null; + this.cache = null; + this.input = null; + this.load = null; + // this.math = null; + this.sound = null; + this.stage = null; + this.time = null; + this.tweens = null; + this.world = null; + this.particles = null; + this.physics = null; + }; Phaser.State.prototype = { @@ -8970,17 +7416,19 @@ Phaser.State.prototype = { link: function (game) { this.game = game; - // this.add = game.add; - // this.camera = game.camera; + this.add = game.add; + this.camera = game.camera; this.cache = game.cache; - // this.input = game.input; + this.input = game.input; this.load = game.load; - this.math = game.math; - // this.sound = game.sound; - // this.stage = game.stage; + // this.math = game.math; + this.sound = game.sound; + this.stage = game.stage; this.time = game.time; this.tweens = game.tweens; - // this.world = game.world; + this.world = game.world; + this.particles = game.particles; + this.physics = game.physics; }, @@ -9459,16 +7907,17 @@ Phaser.StateManager.prototype = { }; Phaser.LinkedList = function () { + + this.next = null; + this.prev = null; + this.first = null; + this.last = null; + this.total = 0; + }; Phaser.LinkedList.prototype = { - next: null, - prev: null, - first: null, - last: null, - total: 0, - sprite: { name: 'HD' }, add: function (child) { @@ -9528,59 +7977,35 @@ Phaser.LinkedList.prototype = { childPrev.next = child.next; + }, + + callAll: function (callback) { + + var entity = this.first; + + do + { + if (entity[callback]) + { + entity[callback].call(entity); + } + + entity = entity.next; + + } + while(entity != this.last.next) + }, dump: function () { - console.log("\nNode\t\t|\t\tNext\t\t|\t\tPrev\t\t|\t\tFirst\t\t|\t\tLast"); - console.log("\t\t\t|\t\t\t\t\t|\t\t\t\t\t|\t\t\t\t\t|"); + var spacing = 20; - var nameNext = '-'; - var namePrev = '-'; - var nameFirst = '-'; - var nameLast = '-'; + var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); + console.log(output); - if (this.next) - { - nameNext = this.next.sprite.name; - } - - if (this.prev) - { - namePrev = this.prev.sprite.name; - } - - if (this.first) - { - nameFirst = this.first.sprite.name; - } - - if (this.last) - { - nameLast = this.last.sprite.name; - } - - if (typeof nameNext === 'undefined') - { - nameNext = '-'; - } - - if (typeof namePrev === 'undefined') - { - namePrev = '-'; - } - - if (typeof nameFirst === 'undefined') - { - nameFirst = '-'; - } - - if (typeof nameLast === 'undefined') - { - nameLast = '-'; - } - - console.log('HD' + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast); + var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); + console.log(output); var entity = this; @@ -9635,7 +8060,8 @@ Phaser.LinkedList.prototype = { nameLast = '-'; } - console.log(name + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast); + var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); + console.log(output); entity = entity.next; @@ -9723,7 +8149,7 @@ Phaser.Signal.prototype = { this._addBinding(binding); } - if(this.memorize && this._prevParams){ + if (this.memorize && this._prevParams){ binding.execute(this._prevParams); } @@ -10060,8 +8486,6 @@ Phaser.Plugin = function (game, parent) { this.hasPreUpdate = false; this.hasUpdate = false; - this.hasPostUpdate = false; - this.hasPreRender = false; this.hasRender = false; this.hasPostRender = false; @@ -10070,42 +8494,28 @@ Phaser.Plugin = function (game, parent) { Phaser.Plugin.prototype = { /** - * Pre-update is called at the start of the update cycle, before any other updates have taken place. + * Pre-update is called at the start of the update cycle, before any other updates have taken place (including Physics). * It is only called if active is set to true. */ preUpdate: function () { }, /** - * Pre-update is called at the start of the update cycle, before any other updates have taken place. + * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. * It is only called if active is set to true. */ update: function () { }, /** - * Post-update is called at the end of the objects update cycle, after other update logic has taken place. - * It is only called if active is set to true. - */ - postUpdate: function () { - }, - - /** - * Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run. - * It is only called if visible is set to true. - */ - preRender: function () { - }, - - /** - * Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run. + * Render is called right after the Game Renderer completes, but before the State.render. * It is only called if visible is set to true. */ render: function () { }, /** - * Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run. + * Post-render is called after the Game Renderer and State.render have run. * It is only called if visible is set to true. */ postRender: function () { @@ -10163,52 +8573,45 @@ Phaser.PluginManager.prototype = { } // Check for methods now to avoid having to do this every loop - if (typeof plugin['preUpdate'] === 'function') { + if (typeof plugin['preUpdate'] === 'function') + { plugin.hasPreUpdate = true; result = true; } - if (typeof plugin['update'] === 'function') { + if (typeof plugin['update'] === 'function') + { plugin.hasUpdate = true; result = true; } - if (typeof plugin['postUpdate'] === 'function') { - plugin.hasPostUpdate = true; - result = true; - } - - if (typeof plugin['preRender'] === 'function') { - plugin.hasPreRender = true; - result = true; - } - - if (typeof plugin['render'] === 'function') { + if (typeof plugin['render'] === 'function') + { plugin.hasRender = true; result = true; } - if (typeof plugin['postRender'] === 'function') { + if (typeof plugin['postRender'] === 'function') + { plugin.hasPostRender = true; result = true; } // The plugin must have at least one of the above functions to be added to the PluginManager. - if (result) { - - if (plugin.hasPreUpdate || plugin.hasUpdate || plugin.hasPostUpdate) + if (result) + { + if (plugin.hasPreUpdate || plugin.hasUpdate) { plugin.active = true; } - if (plugin.hasPreRender || plugin.hasRender || plugin.hasPostRender) + if (plugin.hasRender || plugin.hasPostRender) { plugin.visible = true; } this._pluginsLength = this.plugins.push(plugin); return plugin; - } else { @@ -10230,8 +8633,10 @@ Phaser.PluginManager.prototype = { return; } - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate) { + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate) + { this.plugins[this._p].preUpdate(); } } @@ -10245,44 +8650,16 @@ Phaser.PluginManager.prototype = { return; } - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate) { + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate) + { this.plugins[this._p].update(); } } }, - postUpdate: function () { - - if (this._pluginsLength == 0) - { - return; - } - - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate) { - this.plugins[this._p].postUpdate(); - } - } - - }, - - preRender: function () { - - if (this._pluginsLength == 0) - { - return; - } - - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - if (this.plugins[this._p].visible && this.plugins[this._p].hasPreRender) { - this.plugins[this._p].preRender(); - } - } - - }, - render: function () { if (this._pluginsLength == 0) @@ -10290,8 +8667,10 @@ Phaser.PluginManager.prototype = { return; } - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - if (this.plugins[this._p].visible && this.plugins[this._p].hasRender) { + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].visible && this.plugins[this._p].hasRender) + { this.plugins[this._p].render(); } } @@ -10305,9 +8684,10 @@ Phaser.PluginManager.prototype = { return; } - for (this._p = 0; this._p < this._pluginsLength; this._p++) { - - if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender) { + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender) + { this.plugins[this._p].postRender(); } } @@ -10336,41 +8716,55 @@ Phaser.PluginManager.prototype = { * @copyright 2013 Photon Storm Ltd. * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License */ -Phaser.Stage = function (game) { +Phaser.Stage = function (game, width, height) { this.game = game; - this.canvas = game.renderer.view; + + /** + * Background color of the stage (defaults to black). Set via the public backgroundColor property. + * @type {string} + */ + this._backgroundColor = 'rgb(0,0,0)'; // Get the offset values (for input and other things) this.offset = new Phaser.Point; - Phaser.Canvas.getOffset(this.canvas, this.offset); + this.canvas = Phaser.Canvas.create(width, height); + this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; - this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height); - - var _this = this; - - this._onChange = function (event) { - return _this.visibilityChange(event); - } - - document.addEventListener('visibilitychange', this._onChange, false); - document.addEventListener('webkitvisibilitychange', this._onChange, false); - document.addEventListener('pagehide', this._onChange, false); - document.addEventListener('pageshow', this._onChange, false); - - window.onblur = this._onChange; - window.onfocus = this._onChange; + // The Pixi Stage which is hooked to the renderer + this._stage = new PIXI.Stage(0x000000, false); + this._stage.name = '_stage_root'; + + this.scaleMode = Phaser.StageScaleMode.NO_SCALE; + this.scale = new Phaser.StageScaleMode(this.game, width, height); + this.aspectRatio = width / height; }; Phaser.Stage.prototype = { - _onChange: null, + boot: function () { - canvas: null, - bounds: null, - offset: null, + Phaser.Canvas.getOffset(this.canvas, this.offset); + + this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height); + + var _this = this; + + this._onChange = function (event) { + return _this.visibilityChange(event); + } + + document.addEventListener('visibilitychange', this._onChange, false); + document.addEventListener('webkitvisibilitychange', this._onChange, false); + document.addEventListener('pagehide', this._onChange, false); + document.addEventListener('pageshow', this._onChange, false); + + window.onblur = this._onChange; + window.onfocus = this._onChange; + + }, /** * This method is called when the document visibility is changed. @@ -10396,22 +8790,64 @@ Phaser.Stage.prototype = { }, }; -Phaser.Group = function (game, parent, name) { + +Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { + + get: function () { + return this._backgroundColor; + }, + + set: function (color) { + + this._backgroundColor = color; + + if (typeof color === 'string') + { + color = Phaser.Color.hexToRGB(color); + } + + this._stage.setBackgroundColor(color); + + } + +}); + +Phaser.Group = function (game, parent, name, useStage) { parent = parent || null; + if (typeof useStage == 'undefined') + { + useStage = false; + } + this.game = game; this.name = name || 'group'; - this._container = new PIXI.DisplayObjectContainer(); - - if (parent) + if (useStage) { - parent.addChild(this._container); + this._container = this.game.stage._stage; } else { - this.game.world.add(this._container); + this._container = new PIXI.DisplayObjectContainer(); + this._container.name = this.name; + + if (parent) + { + if (parent instanceof Phaser.Group) + { + parent._container.addChild(this._container); + } + else + { + parent.addChild(this._container); + } + } + else + { + this.game.stage._stage.addChild(this._container); + } } this.exists = true; @@ -10430,6 +8866,12 @@ Phaser.Group.prototype = { if (child.group !== this) { child.group = this; + + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } + this._container.addChild(child); } @@ -10442,6 +8884,12 @@ Phaser.Group.prototype = { if (child.group !== this) { child.group = this; + + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } + this._container.addChildAt(child, index); } @@ -10458,8 +8906,16 @@ Phaser.Group.prototype = { create: function (x, y, key, frame) { var child = new Phaser.Sprite(this.game, x, y, key, frame); + child.group = this; + + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } + this._container.addChild(child); + return child; }, @@ -10479,9 +8935,9 @@ Phaser.Group.prototype = { var child2Next = child2._iNext; var endNode = this._container.last._iNext; - var currentNode = this._container.first; + var currentNode = this.game.stage._stage; - do + do { if (currentNode !== child1 && currentNode !== child2) { @@ -10519,6 +8975,16 @@ Phaser.Group.prototype = { if (child1Prev) { child1Prev._iNext = child2; } if (child2Next) { child2Next._iPrev = child1; } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } + + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } + return true; } else if (child2._iNext == child1) @@ -10532,6 +8998,16 @@ Phaser.Group.prototype = { if (child2Prev) { child2Prev._iNext = child1; } if (child1Next) { child2Next._iPrev = child2; } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } + + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } + return true; } else @@ -10547,6 +9023,16 @@ Phaser.Group.prototype = { if (child2Prev) { child2Prev._iNext = child1; } if (child2Next) { child2Next._iPrev = child1; } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } + + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } + return true; } @@ -10556,9 +9042,10 @@ Phaser.Group.prototype = { bringToTop: function (child) { - if (child !== this._container.last) + if (child.group === this) { - this.swap(child, this._container.last); + this.remove(child); + this.add(child); } return child; @@ -10584,11 +9071,13 @@ Phaser.Group.prototype = { { if (newChild.parent != undefined) { + newChild.events.onRemovedFromGroup.dispatch(newChild, this); newChild.parent.removeChild(newChild); } this._container.removeChild(oldChild); this._container.addChildAt(newChild, index); + newChild.events.onAddedToGroup.dispatch(newChild, this); } }, @@ -10628,13 +9117,13 @@ Phaser.Group.prototype = { sortHandler: function (obj1, obj2) { /* - if(!obj1 || !obj2) { + if (!obj1 || !obj2) { //console.log('null objects in sort', obj1, obj2); return 0; } - if(obj1[this._sortIndex] < obj2[this._sortIndex]) { + if (obj1[this._sortIndex] < obj2[this._sortIndex]) { return this._sortOrder; - } else if(obj1[this._sortIndex] > obj2[this._sortIndex]) { + } else if (obj1[this._sortIndex] > obj2[this._sortIndex]) { return -this._sortOrder; } return 0; @@ -10843,7 +9332,10 @@ Phaser.Group.prototype = { */ getFirstExists: function (state) { - state = state || true; + if (typeof state !== 'boolean') + { + state = true; + } if (this._container.first._iNext) { @@ -10851,7 +9343,7 @@ Phaser.Group.prototype = { do { - if (currentNode.exists == state) + if (currentNode.exists === state) { return currentNode; } @@ -10998,7 +9490,9 @@ Phaser.Group.prototype = { remove: function (child) { + child.events.onRemovedFromGroup.dispatch(child, this); this._container.removeChild(child); + child.group = null; }, @@ -11006,6 +9500,7 @@ Phaser.Group.prototype = { do { + this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this); this._container.removeChild(this._container.children[0]); } while (this._container.children.length > 0); @@ -11022,6 +9517,7 @@ Phaser.Group.prototype = { for (var i = startIndex; i < endIndex; i++) { var child = this._container.children[i]; + child.events.onRemovedFromGroup.dispatch(child, this); this._container.removeChild(child); } @@ -11041,15 +9537,31 @@ Phaser.Group.prototype = { }, - dump: function () { + dump: function (full) { - console.log("\nNode\t\t|\t\tNext\t\t|\t\tPrev\t\t|\t\tFirst\t\t|\t\tLast"); - console.log("\t\t\t|\t\t\t\t\t|\t\t\t\t\t|\t\t\t\t\t|"); + if (typeof full == 'undefined') + { + full = false; + } - var displayObject = this._container; + var spacing = 20; + var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); - var testObject = displayObject.last._iNext; - displayObject = displayObject.first; + console.log(output); + + var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); + console.log(output); + + if (full) + { + var testObject = this.game.stage._stage.last._iNext; + var displayObject = this.game.stage._stage; + } + else + { + var testObject = this._container.last._iNext; + var displayObject = this._container; + } do { @@ -11099,7 +9611,8 @@ Phaser.Group.prototype = { nameLast = '-'; } - console.log(name + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast); + var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); + console.log(output); displayObject = displayObject._iNext; @@ -11118,10 +9631,8 @@ Object.defineProperty(Phaser.Group.prototype, "x", { set: function (value) { this._container.position.x = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Group.prototype, "y", { @@ -11132,10 +9643,8 @@ Object.defineProperty(Phaser.Group.prototype, "y", { set: function (value) { this._container.position.y = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Group.prototype, "angle", { @@ -11146,10 +9655,8 @@ Object.defineProperty(Phaser.Group.prototype, "angle", { set: function(value) { this._container.rotation = Phaser.Math.degToRad(value); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Group.prototype, "rotation", { @@ -11160,10 +9667,8 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", { set: function (value) { this._container.rotation = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Group.prototype, "visible", { @@ -11174,80 +9679,89 @@ Object.defineProperty(Phaser.Group.prototype, "visible", { set: function (value) { this._container.visible = value; - }, + } - enumerable: true, - configurable: true }); +/** + * World + * + * "This world is but a canvas to our imagination." - Henry David Thoreau + * + * A game has only one world. The world is an abstract place in which all game objects live. It is not bound + * by stage limits and can be any size. You look into the world via cameras. All game objects live within + * the world at world-based coordinates. By default a world is created the same size as your Stage. + * + * @package Phaser.World + * @author Richard Davey + * @copyright 2013 Photon Storm Ltd. + * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License + */ Phaser.World = function (game) { + /** + * Local reference to Game. + */ this.game = game; - this._stage = new PIXI.Stage(0x000000); - this._stage.name = '_stage_root'; - + /** + * Bound of this world that objects can not escape from. + * @type {Rectangle} + */ this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height); + + /** + * Camera instance. + * @type {Camera} + */ + this.camera = null; + + /** + * Reset each frame, keeps a count of the total number of objects updated. + * @type {Number} + */ + this.currentRenderOrderID = 0; + + /** + * Object container stores every object created with `create*` methods. + * @type {Group} + */ + this.group = null; }; Phaser.World.prototype = { - _stage: null, - _stage: null, - _length: 0, - - bounds: null, - camera: null, - - currentRenderOrderID: 0, - boot: function () { this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height); + this.game.camera = this.camera; - }, - - add: function (gameobject) { - - this._stage.addChild(gameobject); - return gameobject; - - }, - - addAt: function (gameobject, index) { - - this._stage.addChildAt(gameobject, index); - return gameobject; - - }, - - getAt: function (index) { - - return this._stage.getChildAt(index); - - }, - - remove: function (gameobject) { - - this._stage.removeChild(gameobject); - return gameobject; + this.group = new Phaser.Group(this.game, null, '__world', true); }, + /** + * This is called automatically every frame, and is where main logic happens. + */ update: function () { this.camera.update(); this.currentRenderOrderID = 0; - if (this._stage.first._iNext) + if (this.game.stage._stage.first._iNext) { - var currentNode = this._stage.first._iNext; + var currentNode = this.game.stage._stage.first._iNext; do { + if (currentNode['preUpdate']) + { + currentNode.preUpdate(); + } + if (currentNode['update']) { currentNode.update(); @@ -11255,7 +9769,7 @@ Phaser.World.prototype = { currentNode = currentNode._iNext; } - while (currentNode != this._stage.last._iNext) + while (currentNode != this.game.stage._stage.last._iNext) } }, @@ -11268,112 +9782,18 @@ Phaser.World.prototype = { */ setSize: function (width, height) { - this.bounds.width = width; - this.bounds.height = height; + if (width >= this.game.width) + { + this.bounds.width = width; + } - }, + if (height >= this.game.height) + { + this.bounds.height = height; + } - bringToTop: function (child) { - - if (child !== this._stage.last) - { - this.swapChildren(child, this._stage.last); - } - - return child; - - }, - - swapChildren: function (child1, child2) { - - if (child1 === child2 || !child1.parent || !child2.parent) - { - console.warn('You cannot swap a child with itself or swap un-parented children'); - return false; - } - - // Cache the values - var child1Prev = child1._iPrev; - var child1Next = child1._iNext; - var child2Prev = child2._iPrev; - var child2Next = child2._iNext; - - var endNode = this._stage.last._iNext; - var currentNode = this._stage.first; - - do - { - if (currentNode !== child1 && currentNode !== child2) - { - if (currentNode.first === child1) - { - currentNode.first = child2; - } - else if (currentNode.first === child2) - { - currentNode.first = child1; - } - - if (currentNode.last === child1) - { - currentNode.last = child2; - } - else if (currentNode.last === child2) - { - currentNode.last = child1; - } - } - - currentNode = currentNode._iNext; - } - while (currentNode != endNode) - - if (child1._iNext == child2) - { - // This is a downward (A to B) neighbour swap - child1._iNext = child2Next; - child1._iPrev = child2; - child2._iNext = child1; - child2._iPrev = child1Prev; - - if (child1Prev) { child1Prev._iNext = child2; } - if (child2Next) { child2Next._iPrev = child1; } - - return true; - } - else if (child2._iNext == child1) - { - // This is an upward (B to A) neighbour swap - child1._iNext = child2; - child1._iPrev = child2Prev; - child2._iNext = child1Next; - child2._iPrev = child1; - - if (child2Prev) { child2Prev._iNext = child1; } - if (child1Next) { child2Next._iPrev = child2; } - - return true; - } - else - { - // Children are far apart - child1._iNext = child2Next; - child1._iPrev = child2Prev; - child2._iNext = child1Next; - child2._iPrev = child1Prev; - - if (child1Prev) { child1Prev._iNext = child2; } - if (child1Next) { child1Next._iPrev = child2; } - if (child2Prev) { child2Prev._iNext = child1; } - if (child2Next) { child2Next._iPrev = child1; } - - return true; - } - - return false; - } - + }; // Getters / Setters @@ -11386,10 +9806,8 @@ Object.defineProperty(Phaser.World.prototype, "width", { set: function (value) { this.bounds.width = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.World.prototype, "height", { @@ -11400,50 +9818,40 @@ Object.defineProperty(Phaser.World.prototype, "height", { set: function (value) { this.bounds.height = value; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.World.prototype, "centerX", { get: function () { return this.bounds.halfWidth; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.World.prototype, "centerY", { get: function () { return this.bounds.halfHeight; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.World.prototype, "randomX", { get: function () { return Math.round(Math.random() * this.bounds.width); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.World.prototype, "randomY", { get: function () { return Math.round(Math.random() * this.bounds.height); - }, + } - enumerable: true, - configurable: true }); /** @@ -11482,17 +9890,205 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant transparent = transparent || false; antialias = antialias || true; + /** + * Phaser Game ID (for when Pixi supports multiple instances) + * @type {number} + */ this.id = Phaser.GAMES.push(this) - 1; + + /** + * The Games DOM parent. + * @type {HTMLElement} + */ this.parent = parent; // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too? + + /** + * The Game width (in pixels). + * @type {number} + */ this.width = width; + + /** + * The Game height (in pixels). + * @type {number} + */ this.height = height; + + /** + * Use a transparent canvas background or not. + * @type {boolean} + */ this.transparent = transparent; + + /** + * Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality) + * @type {boolean} + */ this.antialias = antialias; + + /** + * The Pixi Renderer + * @type {number} + */ + this.renderer = null; + + /** + * The StateManager. + * @type {Phaser.StateManager} + */ + this.state = new Phaser.StateManager(this, state); + + /** + * Is game paused? + * @type {bool} + */ + this._paused = false; + + /** + * The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL + * @type {number} + */ this.renderType = renderer; - this.state = new Phaser.StateManager(this, state); + /** + * Whether load complete loading or not. + * @type {bool} + */ + this._loadComplete = false; + + /** + * Whether the game engine is booted, aka available. + * @type {bool} + */ + this.isBooted = false; + + /** + * Is game running or paused? + * @type {bool} + */ + this.isRunning = false; + + /** + * Automatically handles the core game loop via requestAnimationFrame or setTimeout + * @type {Phaser.RequestAnimationFrame} + */ + this.raf = null; + + /** + * Reference to the GameObject Factory. + * @type {Phaser.GameObjectFactory} + */ + this.add = null; + + /** + * Reference to the assets cache. + * @type {Phaser.Cache} + */ + this.cache = null; + + /** + * Reference to the input manager + * @type {Phaser.Input} + */ + this.input = null; + + /** + * Reference to the assets loader. + * @type {Phaser.Loader} + */ + this.load = null; + + /** + * Reference to the math helper. + * @type {Phaser.GameMath} + */ + this.math = null; + + /** + * Reference to the network class. + * @type {Phaser.Net} + */ + this.net = null; + + /** + * Reference to the sound manager. + * @type {Phaser.SoundManager} + */ + this.sound = null; + + /** + * Reference to the stage. + * @type {Phaser.Stage} + */ + this.stage = null; + + /** + * Reference to game clock. + * @type {Phaser.TimeManager} + */ + this.time = null; + + /** + * Reference to the tween manager. + * @type {Phaser.TweenManager} + */ + this.tweens = null; + + /** + * Reference to the world. + * @type {Phaser.World} + */ + this.world = null; + + /** + * Reference to the physics manager. + * @type {Phaser.Physics.PhysicsManager} + */ + this.physics = null; + + /** + * Instance of repeatable random data generator helper. + * @type {Phaser.RandomDataGenerator} + */ + this.rnd = null; + + /** + * Contains device information and capabilities. + * @type {Phaser.Device} + */ + this.device = null; + + /** + * A handy reference to world.camera + * @type {Phaser.Camera} + */ + this.camera = null; + + /** + * A handy reference to renderer.view + * @type {HTMLCanvasElement} + */ + this.canvas = null; + + /** + * A handy reference to renderer.context (only set for CANVAS games) + * @type {Context} + */ + this.context = null; + + /** + * A set of useful debug utilities + * @type {Phaser.Utils.Debug} + */ + this.debug = null; + + /** + * The Particle Manager + * @type {Phaser.Particles} + */ + this.particles = null; var _this = this; @@ -11516,193 +10112,6 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant Phaser.Game.prototype = { - // temps so we can clean-up the event listeneres - _tempState: null, - _onBoot: null, - - /** - * Phaser Game ID. - * @type {number} - */ - id: 0, - - /** - * The Game width (in pixels). - * @type {number} - */ - width: 0, - - /** - * The Game height (in pixels). - * @type {number} - */ - height: 0, - - transparent: false, - antialias: true, - - /** - * The Games DOM parent. - * @type {HTMLElement} - */ - parent: '', - - /** - * The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL - * @type {number} - */ - renderType: 0, - - /** - * The Pixi Renderer - * @type {number} - */ - renderer: null, - - /** - * Whether load complete loading or not. - * @type {bool} - */ - _loadComplete: false, - - /** - * Is game paused? - * @type {bool} - */ - paused: false, - - /** - * Whether the game engine is booted, aka available. - * @type {bool} - */ - isBooted: false, - - /** - * Is game running or paused? - * @type {bool} - */ - isRunning: false, - - /** - * Automatically handles the core game loop via requestAnimationFrame or setTimeout - * @type {Phaser.RequestAnimationFrame} - */ - raf: null, - - /** - * The StateManager. - * @type {Phaser.StateManager} - */ - state: null, - - /** - * Reference to the GameObject Factory. - * @type {Phaser.GameObjectFactory} - */ - add: null, - - /** - * Reference to the assets cache. - * @type {Phaser.Cache} - */ - cache: null, - - /** - * Reference to the input manager - * @type {Phaser.Input} - */ - input: null, - - /** - * Reference to the assets loader. - * @type {Phaser.Loader} - */ - load: null, - - /** - * Reference to the math helper. - * @type {Phaser.GameMath} - */ - math: null, - - /** - * Reference to the network class. - * @type {Phaser.Net} - */ - net: null, - - /** - * Reference to the sound manager. - * @type {Phaser.SoundManager} - */ - sound: null, - - /** - * Reference to the stage. - * @type {Phaser.Stage} - */ - stage: null, - - /** - * Reference to game clock. - * @type {Phaser.TimeManager} - */ - time: null, - - /** - * Reference to the tween manager. - * @type {Phaser.TweenManager} - */ - tweens: null, - - /** - * Reference to the world. - * @type {Phaser.World} - */ - world: null, - - /** - * Reference to the physics manager. - * @type {Phaser.Physics.PhysicsManager} - */ - physics: null, - - /** - * Instance of repeatable random data generator helper. - * @type {Phaser.RandomDataGenerator} - */ - rnd: null, - - /** - * Contains device information and capabilities. - * @type {Phaser.Device} - */ - device: null, - - /** - * A handy reference to world.camera - * @type {Phaser.Camera} - */ - camera: null, - - /** - * A handy reference to renderer.view - * @type {HTMLCanvasElement} - */ - canvas: null, - - /** - * A handy reference to renderer.context (only set for CANVAS games) - * @type {Context} - */ - context: null, - - /** - * A set of useful debug utilities - * @type {Phaser.Utils.Debug} - */ - debug: null, - /** * Initialize engine sub modules and start the game. * @param parent {string} ID of parent Dom element. @@ -11734,10 +10143,11 @@ Phaser.Game.prototype = { this.math = Phaser.Math; this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]); + this.stage = new Phaser.Stage(this, this.width, this.height); + this.setUpRenderer(); this.world = new Phaser.World(this); - this.stage = new Phaser.Stage(this); this.add = new Phaser.GameObjectFactory(this); this.cache = new Phaser.Cache(this); this.load = new Phaser.Loader(this); @@ -11746,15 +10156,18 @@ Phaser.Game.prototype = { this.input = new Phaser.Input(this); this.sound = new Phaser.SoundManager(this); this.physics = new Phaser.Physics.Arcade(this); + this.particles = new Phaser.Particles(this); this.plugins = new Phaser.PluginManager(this, this); this.net = new Phaser.Net(this); this.debug = new Phaser.Utils.Debug(this); this.load.onLoadComplete.add(this.loadComplete, this); + this.stage.boot(); this.world.boot(); this.state.boot(); this.input.boot(); + this.sound.boot(); if (this.renderType == Phaser.CANVAS) { @@ -11777,12 +10190,12 @@ Phaser.Game.prototype = { setUpRenderer: function () { - if (this.renderType == Phaser.CANVAS || (this.renderType == Phaser.AUTO && this.device.webGL == false)) + if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false)) { if (this.device.canvas) { this.renderType = Phaser.CANVAS; - this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, this.transparent); + this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent); Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias); this.canvas = this.renderer.view; this.context = this.renderer.context; @@ -11794,8 +10207,9 @@ Phaser.Game.prototype = { } else { - // They must have requested WebGL and their browser supports it - this.renderer = new PIXI.WebGLRenderer(this.width, this.height, null, this.transparent, this.antialias); + // They requested WebGL, and their browser supports it + this.renderType = Phaser.WEBGL; + this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias); this.canvas = this.renderer.view; this.context = null; } @@ -11823,7 +10237,7 @@ Phaser.Game.prototype = { this.time.update(time); - if (!this.paused) + if (!this._paused) { this.plugins.preUpdate(); this.physics.preUpdate(); @@ -11832,10 +10246,12 @@ Phaser.Game.prototype = { this.tweens.update(); this.sound.update(); this.world.update(); + this.particles.update(); this.state.update(); this.plugins.update(); - this.renderer.render(this.world._stage); + this.renderer.render(this.stage._stage); + this.plugins.render(); this.state.render(); this.plugins.postRender(); @@ -11864,6 +10280,36 @@ Phaser.Game.prototype = { }; +Object.defineProperty(Phaser.Game.prototype, "paused", { + + get: function () { + return this._paused; + }, + + set: function (value) { + + if (value === true) + { + if (this._paused == false) + { + this._paused = true; + this.onPause.dispatch(this); + } + } + else + { + if (this._paused) + { + this._paused = false; + this.onResume.dispatch(this); + } + } + + } + +}); + + /** * Phaser.Input * @@ -11874,8 +10320,8 @@ Phaser.Input = function (game) { this.game = game; - this.inputObjects = []; - this.totalTrackedObjects = 0; + this.hitCanvas = null; + this.hitContext = null; }; @@ -12152,10 +10598,18 @@ Phaser.Input.prototype = { this.activePointer = this.mousePointer; this.currentPointers = 0; - // this.hitCanvas = document.createElement('canvas'); - // this.hitCanvas.width = 1; - // this.hitCanvas.height = 1; - // this.hitContext = this.hitCanvas.getContext('2d'); + this.hitCanvas = document.createElement('canvas'); + this.hitCanvas.width = 1; + this.hitCanvas.height = 1; + this.hitContext = this.hitCanvas.getContext('2d'); + + // Debugging + // this.hitCanvas.style['width'] = '200px'; + // this.hitCanvas.style['height'] = '200px'; + // this.hitCanvas.style['position'] = 'absolute'; + // this.hitCanvas.style['left'] = '810px'; + // this.hitCanvas.style['backgroundColor'] = '#ef0000'; + // Phaser.Canvas.addToDOM(this.hitCanvas); this.mouse.start(); this.keyboard.start(); @@ -12250,7 +10704,7 @@ Phaser.Input.prototype = { } this.currentPointers = 0; - // this.game.stage.canvas.style.cursor = "default"; + this.game.stage.canvas.style.cursor = "default"; if (hard == true) { @@ -12263,16 +10717,7 @@ Phaser.Input.prototype = { this.onTap = new Phaser.Signal(); this.onHold = new Phaser.Signal(); - for (var i = 0; i < this.totalTrackedObjects; i++) - { - if (this.inputObjects[i] && this.inputObjects[i].input) - { - this.inputObjects[i].input.reset(); - } - } - - this.inputObjects.length = 0; - this.totalTrackedObjects = 0; + this.interactiveItems.callAll('reset'); } this._pollCounter = 0; @@ -12334,7 +10779,7 @@ Phaser.Input.prototype = { { return this.pointer1.move(event); } - else if(this.pointer2.active && this.pointer2.identifier == event.identifier) + else if (this.pointer2.active && this.pointer2.identifier == event.identifier) { return this.pointer2.move(event); } @@ -12365,7 +10810,7 @@ Phaser.Input.prototype = { { return this.pointer1.stop(event); } - else if(this.pointer2.active && this.pointer2.identifier == event.identifier) + else if (this.pointer2.active && this.pointer2.identifier == event.identifier) { return this.pointer2.stop(event); } @@ -12398,7 +10843,7 @@ Phaser.Input.prototype = { { return this.pointer1; } - else if(this.pointer2.active == state) + else if (this.pointer2.active == state) { return this.pointer2; } @@ -12429,7 +10874,7 @@ Phaser.Input.prototype = { { return this.pointer1; } - else if(this.pointer2.identifier == identifier) + else if (this.pointer2.identifier == identifier) { return this.pointer2; } @@ -12486,10 +10931,8 @@ Object.defineProperty(Phaser.Input.prototype, "x", { set: function (value) { this._x = Math.floor(value); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "y", { @@ -12506,20 +10949,16 @@ Object.defineProperty(Phaser.Input.prototype, "y", { set: function (value) { this._y = Math.floor(value); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "pollLocked", { get: function () { return (this.pollRate > 0 && this._pollCounter < this.pollRate); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { @@ -12531,10 +10970,8 @@ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { **/ get: function () { return 10 - this.currentPointers; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { @@ -12558,30 +10995,24 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { return this.currentPointers; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "worldX", { get: function () { return this.game.camera.view.x + this.x; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Input.prototype, "worldY", { get: function () { return this.game.camera.view.y + this.y; - }, + } - enumerable: true, - configurable: true }); Phaser.Keyboard = function (game) { @@ -12916,6 +11347,12 @@ Phaser.Mouse.prototype = { */ disabled: false, + /** + * If the mouse has been Pointer Locked successfully this will be set to true. + * @type {bool} + */ + locked: false, + /** * Starts the event listeners running * @method start @@ -12942,9 +11379,10 @@ Phaser.Mouse.prototype = { return _this.onMouseUp(event); }; - this.game.stage.canvas.addEventListener('mousedown', this._onMouseDown, true); - this.game.stage.canvas.addEventListener('mousemove', this._onMouseMove, true); - this.game.stage.canvas.addEventListener('mouseup', this._onMouseUp, true); + this.game.renderer.view.addEventListener('mousedown', this._onMouseDown, true); + this.game.renderer.view.addEventListener('mousemove', this._onMouseMove, true); + this.game.renderer.view.addEventListener('mouseup', this._onMouseUp, true); + }, /** @@ -13008,6 +11446,58 @@ Phaser.Mouse.prototype = { this.game.input.mousePointer.stop(event); + }, + + requestPointerLock: function () { + + if (this.game.device.pointerLock) + { + var element = this.game.stage.canvas; + + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + + element.requestPointerLock(); + + var _this = this; + + this._pointerLockChange = function (event) { + return _this.pointerLockChange(event); + }; + + document.addEventListener('pointerlockchange', this._pointerLockChange, false); + document.addEventListener('mozpointerlockchange', this._pointerLockChange, false); + document.addEventListener('webkitpointerlockchange', this._pointerLockChange, false); + } + + }, + + pointerLockChange: function (event) { + + var element = this.game.stage.canvas; + + if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) + { + // Pointer was successfully locked + this.locked = true; + } + else + { + // Pointer was unlocked + this.locked = false; + } + + }, + + releasePointerLock: function () { + + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; + + document.exitPointerLock(); + + document.removeEventListener('pointerlockchange', this._pointerLockChange); + document.removeEventListener('mozpointerlockchange', this._pointerLockChange); + document.removeEventListener('webkitpointerlockchange', this._pointerLockChange); + }, /** @@ -13077,12 +11567,12 @@ Phaser.MSPointer.prototype = { return _this.onPointerUp(event); }; - this.game.stage.canvas.addEventListener('MSPointerDown', this._onMSPointerDown, false); - this.game.stage.canvas.addEventListener('MSPointerMove', this._onMSPointerMove, false); - this.game.stage.canvas.addEventListener('MSPointerUp', this._onMSPointerUp, false); + this.game.renderer.view.addEventListener('MSPointerDown', this._onMSPointerDown, false); + this.game.renderer.view.addEventListener('MSPointerMove', this._onMSPointerMove, false); + this.game.renderer.view.addEventListener('MSPointerUp', this._onMSPointerUp, false); - this.game.stage.canvas.style['-ms-content-zooming'] = 'none'; - this.game.stage.canvas.style['-ms-touch-action'] = 'none'; + this.game.renderer.view.style['-ms-content-zooming'] = 'none'; + this.game.renderer.view.style['-ms-touch-action'] = 'none'; } @@ -13162,6 +11652,181 @@ Phaser.MSPointer.prototype = { */ Phaser.Pointer = function (game, id) { + /** + * Local private variable to store the status of dispatching a hold event + * @property _holdSent + * @type {bool} + * @private + */ + this._holdSent = false; + + /** + * Local private variable storing the short-term history of pointer movements + * @property _history + * @type {Array} + * @private + */ + this._history = []; + + /** + * Local private variable storing the time at which the next history drop should occur + * @property _lastDrop + * @type {Number} + * @private + */ + this._nextDrop = 0; + + // Monitor events outside of a state reset loop + this._stateReset = false; + + /** + * A Vector object containing the initial position when the Pointer was engaged with the screen. + * @property positionDown + * @type {Vec2} + **/ + this.positionDown = null; + + /** + * A Vector object containing the current position of the Pointer on the screen. + * @property position + * @type {Vec2} + **/ + this.position = null; + + /** + * A Circle object centered on the x/y screen coordinates of the Pointer. + * Default size of 44px (Apple's recommended "finger tip" size) + * @property circle + * @type {Circle} + **/ + this.circle = null; + + /** + * + * @property withinGame + * @type {bool} + */ + this.withinGame = false; + + /** + * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset + * @property clientX + * @type {Number} + */ + this.clientX = -1; + + /** + * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset + * @property clientY + * @type {Number} + */ + this.clientY = -1; + + /** + * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset + * @property pageX + * @type {Number} + */ + this.pageX = -1; + + /** + * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset + * @property pageY + * @type {Number} + */ + this.pageY = -1; + + /** + * The horizontal coordinate of point relative to the screen in pixels + * @property screenX + * @type {Number} + */ + this.screenX = -1; + + /** + * The vertical coordinate of point relative to the screen in pixels + * @property screenY + * @type {Number} + */ + this.screenY = -1; + + /** + * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. + * @property x + * @type {Number} + */ + this.x = -1; + + /** + * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. + * @property y + * @type {Number} + */ + this.y = -1; + + /** + * If the Pointer is a mouse this is true, otherwise false + * @property isMouse + * @type {bool} + **/ + this.isMouse = false; + + /** + * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true + * @property isDown + * @type {bool} + **/ + this.isDown = false; + + /** + * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true + * @property isUp + * @type {bool} + **/ + this.isUp = true; + + /** + * A timestamp representing when the Pointer first touched the touchscreen. + * @property timeDown + * @type {Number} + **/ + this.timeDown = 0; + + /** + * A timestamp representing when the Pointer left the touchscreen. + * @property timeUp + * @type {Number} + **/ + this.timeUp = 0; + + /** + * A timestamp representing when the Pointer was last tapped or clicked + * @property previousTapTime + * @type {Number} + **/ + this.previousTapTime = 0; + + /** + * The total number of times this Pointer has been touched to the touchscreen + * @property totalTouches + * @type {Number} + **/ + this.totalTouches = 0; + + /** + * The number of miliseconds since the last click + * @property msSinceLastClick + * @type {Number} + **/ + this.msSinceLastClick = Number.MAX_VALUE; + + /** + * The Game Object this Pointer is currently over / touching / dragging. + * @property targetObject + * @type {Any} + **/ + this.targetObject = null; + this.game = game; this.id = id; @@ -13181,181 +11846,6 @@ Phaser.Pointer = function (game, id) { Phaser.Pointer.prototype = { - /** - * Local private variable to store the status of dispatching a hold event - * @property _holdSent - * @type {bool} - * @private - */ - _holdSent: false, - - /** - * Local private variable storing the short-term history of pointer movements - * @property _history - * @type {Array} - * @private - */ - _history: [], - - /** - * Local private variable storing the time at which the next history drop should occur - * @property _lastDrop - * @type {Number} - * @private - */ - _nextDrop: 0, - - // Monitor events outside of a state reset loop - _stateReset: false, - - /** - * A Vector object containing the initial position when the Pointer was engaged with the screen. - * @property positionDown - * @type {Vec2} - **/ - positionDown: null, - - /** - * A Vector object containing the current position of the Pointer on the screen. - * @property position - * @type {Vec2} - **/ - position: null, - - /** - * A Circle object centered on the x/y screen coordinates of the Pointer. - * Default size of 44px (Apple's recommended "finger tip" size) - * @property circle - * @type {Circle} - **/ - circle: null, - - /** - * - * @property withinGame - * @type {bool} - */ - withinGame: false, - - /** - * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientX - * @type {Number} - */ - clientX: -1, - - /** - * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientY - * @type {Number} - */ - clientY: -1, - - /** - * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageX - * @type {Number} - */ - pageX: -1, - - /** - * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageY - * @type {Number} - */ - pageY: -1, - - /** - * The horizontal coordinate of point relative to the screen in pixels - * @property screenX - * @type {Number} - */ - screenX: -1, - - /** - * The vertical coordinate of point relative to the screen in pixels - * @property screenY - * @type {Number} - */ - screenY: -1, - - /** - * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property x - * @type {Number} - */ - x: -1, - - /** - * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property y - * @type {Number} - */ - y: -1, - - /** - * If the Pointer is a mouse this is true, otherwise false - * @property isMouse - * @type {bool} - **/ - isMouse: false, - - /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true - * @property isDown - * @type {bool} - **/ - isDown: false, - - /** - * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true - * @property isUp - * @type {bool} - **/ - isUp: true, - - /** - * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ - timeDown: 0, - - /** - * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ - timeUp: 0, - - /** - * A timestamp representing when the Pointer was last tapped or clicked - * @property previousTapTime - * @type {Number} - **/ - previousTapTime: 0, - - /** - * The total number of times this Pointer has been touched to the touchscreen - * @property totalTouches - * @type {Number} - **/ - totalTouches: 0, - - /** - * The number of miliseconds since the last click - * @property msSinceLastClick - * @type {Number} - **/ - msSinceLastClick: Number.MAX_VALUE, - - /** - * The Game Object this Pointer is currently over / touching / dragging. - * @property targetObject - * @type {Any} - **/ - targetObject: null, - /** * Called when the Pointer is pressed onto the touchscreen * @method start @@ -13372,11 +11862,11 @@ Phaser.Pointer.prototype = { } // Fix to stop rogue browser plugins from blocking the visibility state event - // if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false) - // { - // this.game.stage.resumeGame(); - // return this; - // } + if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false) + { + this.game.paused = false; + return this; + } this._history.length = 0; this.active = true; @@ -13397,10 +11887,8 @@ Phaser.Pointer.prototype = { if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) { - //this.game.input.x = this.x * this.game.input.scale.x; - //this.game.input.y = this.y * this.game.input.scale.y; - this.game.input.x = this.x; - this.game.input.y = this.y; + this.game.input.x = this.x * this.game.input.scale.x; + this.game.input.y = this.y * this.game.input.scale.y; this.game.input.position.setTo(this.x, this.y); this.game.input.onDown.dispatch(this); this.game.input.resetSpeed(this.x, this.y); @@ -13770,10 +12258,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", { return this.game.time.now - this.timeDown; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Pointer.prototype, "worldX", { @@ -13786,10 +12272,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { return this.game.world.camera.x + this.x; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Pointer.prototype, "worldY", { @@ -13802,10 +12286,8 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { return this.game.world.camera.y + this.y; - }, + } - enumerable: true, - configurable: true }); /** @@ -13829,6 +12311,8 @@ Phaser.Touch = function (game) { this.touchLeaveCallback = null; this.touchCancelCallback = null; + this.preventDefault = true; + }; Phaser.Touch.prototype = { @@ -13883,30 +12367,28 @@ Phaser.Touch.prototype = { return _this.onTouchCancel(event); }; - this._documentTouchMove = function (event) { - return _this.consumeTouchMove(event); - }; - - this.game.stage.canvas.addEventListener('touchstart', this._onTouchStart, false); - this.game.stage.canvas.addEventListener('touchmove', this._onTouchMove, false); - this.game.stage.canvas.addEventListener('touchend', this._onTouchEnd, false); - this.game.stage.canvas.addEventListener('touchenter', this._onTouchEnter, false); - this.game.stage.canvas.addEventListener('touchleave', this._onTouchLeave, false); - this.game.stage.canvas.addEventListener('touchcancel', this._onTouchCancel, false); - - document.addEventListener('touchmove', this._documentTouchMove, false); + this.game.renderer.view.addEventListener('touchstart', this._onTouchStart, false); + this.game.renderer.view.addEventListener('touchmove', this._onTouchMove, false); + this.game.renderer.view.addEventListener('touchend', this._onTouchEnd, false); + this.game.renderer.view.addEventListener('touchenter', this._onTouchEnter, false); + this.game.renderer.view.addEventListener('touchleave', this._onTouchLeave, false); + this.game.renderer.view.addEventListener('touchcancel', this._onTouchCancel, false); } }, - /** - * Prevent iOS bounce-back (doesn't work?) + /** + * Consumes all touchmove events on the document (only enable this if you know you need it!) * @method consumeTouchMove * @param {Any} event **/ - consumeTouchMove: function (event) { + consumeDocumentTouches: function () { - event.preventDefault(); + this._documentTouchMove = function (event) { + event.preventDefault(); + }; + + document.addEventListener('touchmove', this._documentTouchMove, false); }, @@ -13927,7 +12409,10 @@ Phaser.Touch.prototype = { return; } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element @@ -13957,7 +12442,10 @@ Phaser.Touch.prototype = { return; } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } // Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome) // http://www.w3.org/TR/touch-events/#dfn-touchcancel @@ -13986,7 +12474,10 @@ Phaser.Touch.prototype = { return; } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } for (var i = 0; i < event.changedTouches.length; i++) { @@ -14008,7 +12499,10 @@ Phaser.Touch.prototype = { this.touchLeaveCallback.call(this.callbackContext, event); } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } for (var i = 0; i < event.changedTouches.length; i++) { @@ -14029,7 +12523,10 @@ Phaser.Touch.prototype = { this.touchMoveCallback.call(this.callbackContext, event); } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } for (var i = 0; i < event.changedTouches.length; i++) { @@ -14050,7 +12547,10 @@ Phaser.Touch.prototype = { this.touchEndCallback.call(this.callbackContext, event); } - event.preventDefault(); + if (this.preventDefault) + { + event.preventDefault(); + } // For touch end its a list of the touch points that have been removed from the surface // https://developer.mozilla.org/en-US/docs/DOM/TouchList @@ -14076,8 +12576,6 @@ Phaser.Touch.prototype = { this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter); this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave); this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel); - - document.removeEventListener('touchmove', this._documentTouchMove); } } @@ -14091,6 +12589,9 @@ Phaser.InputHandler = function (sprite) { this.enabled = false; // Linked list references + this.parent = null; + this.next = null; + this.prev = null; this.last = this; this.first = this; @@ -14098,17 +12599,31 @@ Phaser.InputHandler = function (sprite) { * The PriorityID controls which Sprite receives an Input event first if they should overlap. */ this.priorityID = 0; + this.useHandCursor = false; this.isDragged = false; - this.dragPixelPerfect = false; this.allowHorizontalDrag = true; this.allowVerticalDrag = true; this.bringToTop = false; + + this.snapOffset = null; this.snapOnDrag = false; this.snapOnRelease = false; this.snapX = 0; this.snapY = 0; + /** + * Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! + * @default false + */ + this.pixelPerfect = false; + + /** + * The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. + * @default 255 + */ + this.pixelPerfectAlpha = 255; + /** * Is this sprite allowed to be dragged by the mouse? true = yes, false = no * @default false @@ -14140,20 +12655,9 @@ Phaser.InputHandler = function (sprite) { Phaser.InputHandler.prototype = { - game: null, - sprite: null, - - // Linked list references - parent: null, - next: null, - prev: null, - first: null, - last: null, - - start: function (priority, checkBody, useHandCursor) { + start: function (priority, useHandCursor) { priority = priority || 0; - checkBody = checkBody || false; useHandCursor = useHandCursor || false; // Turning on @@ -14161,7 +12665,6 @@ Phaser.InputHandler.prototype = { { // Register, etc this.game.input.interactiveItems.add(this); - this.checkBody = checkBody; this.useHandCursor = useHandCursor; this.priorityID = priority; this._pointerData = []; @@ -14409,19 +12912,24 @@ Phaser.InputHandler.prototype = { { this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y); - // Check against bounds - var width = this.sprite.texture.frame.width, - height = this.sprite.texture.frame.height, - x1 = -width * this.sprite.anchor.x, - y1; + // Check against bounds first (move these to private vars) + var x1 = -(this.sprite.texture.frame.width) * this.sprite.anchor.x; + var y1; - if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + width) + if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + this.sprite.texture.frame.width) { - y1 = -height * this.sprite.anchor.y; + y1 = -(this.sprite.texture.frame.height) * this.sprite.anchor.y; - if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + height) + if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + this.sprite.texture.frame.height) { - return true; + if (this.pixelPerfect) + { + return this.checkPixel(this._tempPoint.x, this._tempPoint.y); + } + else + { + return true; + } } } } @@ -14430,6 +12938,30 @@ Phaser.InputHandler.prototype = { return false; } + }, + + checkPixel: function (x, y) { + + x += (this.sprite.texture.frame.width * this.sprite.anchor.x); + y += (this.sprite.texture.frame.height * this.sprite.anchor.y); + + // Grab a pixel from our image into the hitCanvas and then test it + + if (this.sprite.texture.baseTexture.source) + { + this.game.input.hitContext.clearRect(0, 0, 1, 1); + this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1); + + if (rgb.data[3] >= this.pixelPerfectAlpha) + { + return true; + } + } + + return false; + }, /** @@ -14712,8 +13244,9 @@ Phaser.InputHandler.prototype = { this.bringToTop = bringToTop; this.dragOffset = new Phaser.Point(); this.dragFromCenter = lockCenter; - this.dragPixelPerfect = pixelPerfect; - this.dragPixelPerfectAlpha = alphaThreshold; + + this.pixelPerfect = pixelPerfect; + this.pixelPerfectAlpha = alphaThreshold; if (boundsRect) { @@ -14903,12 +13436,26 @@ Phaser.InputHandler.prototype = { Phaser.Canvas = { + create: function (width, height) { + + width = width || 256; + height = height || 256; + + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + canvas.style.display = 'block'; + + return canvas; + + }, + /** * Get the DOM offset values of any given element */ getOffset: function (element, point) { - if (typeof point === "undefined") { point = new Phaser.Point; } + point = point || new Phaser.Point; var box = element.getBoundingClientRect(); var clientTop = element.clientTop || document.body.clientTop || 0; @@ -14944,7 +13491,7 @@ Phaser.Canvas = { */ setBackgroundColor: function (canvas, color) { - if (typeof color === "undefined") { color = 'rgb(0,0,0)'; } + color = color || 'rgb(0,0,0)'; canvas.style.backgroundColor = color; @@ -14962,7 +13509,7 @@ Phaser.Canvas = { */ setTouchAction: function (canvas, value) { - if (typeof value === "undefined") { value = 'none'; } + value = value || 'none'; canvas.style.msTouchAction = value; canvas.style['ms-touch-action'] = value; @@ -14984,12 +13531,19 @@ Phaser.Canvas = { */ addToDOM: function (canvas, parent, overflowHidden) { - if (typeof parent === "undefined") { parent = ''; } - if (typeof overflowHidden === "undefined") { overflowHidden = true; } + parent = parent || ''; + overflowHidden = overflowHidden || true; - if ((parent !== '' || parent !== null) && document.getElementById(parent)) + if (parent !== '') { - document.getElementById(parent).appendChild(canvas); + if (document.getElementById(parent)) + { + document.getElementById(parent).appendChild(canvas); + } + else + { + document.body.appendChild(canvas); + } if (overflowHidden) { @@ -15108,6 +13662,10 @@ Phaser.Events = function (sprite) { this.onDragStart = null; this.onDragStop = null; + this.onAnimationStart = null; + this.onAnimationComplete = null; + this.onAnimationLoop = null; + }; Phaser.GameObjectFactory = function (game) { @@ -15121,18 +13679,24 @@ Phaser.GameObjectFactory.prototype = { game: null, world: null, + existing: function (object) { + + return this.world.group.add(object); + + }, + /** * Create a new Sprite with specific position and sprite sheet key. * * @param x {number} X position of the new sprite. * @param y {number} Y position of the new sprite. - * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite + * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. * @returns {Sprite} The newly created sprite object. */ sprite: function (x, y, key, frame) { - return this.world.add(new Phaser.Sprite(this.game, x, y, key, frame)); + return this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); }, @@ -15141,13 +13705,13 @@ Phaser.GameObjectFactory.prototype = { * * @param x {number} X position of the new sprite. * @param y {number} Y position of the new sprite. - * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite + * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. * @returns {Sprite} The newly created sprite object. */ child: function (parent, x, y, key, frame) { - var child = this.world.add(new Phaser.Sprite(this.game, x, y, key, frame)); + var child = this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); parent.addChild(child); return child; @@ -15157,12 +13721,11 @@ Phaser.GameObjectFactory.prototype = { * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * * @param obj {object} Object the tween will be run on. - * @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written. * @return {Phaser.Tween} The newly created tween object. */ - tween: function (obj, localReference) { + tween: function (obj) { - return this.game.tweens.create(obj, localReference); + return this.game.tweens.create(obj); }, @@ -15180,23 +13743,62 @@ Phaser.GameObjectFactory.prototype = { tileSprite: function (x, y, width, height, key, frame) { - return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); + return this.world.group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); }, text: function (x, y, text, style) { - return this.world.add(new Phaser.Text(this.game, x, y, text, style)); + return this.world.group.add(new Phaser.Text(this.game, x, y, text, style)); }, + button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { + + return this.world.group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + + }, + + graphics: function (x, y) { + + return this.world.group.add(new Phaser.Graphics(this.game, x, y)); + + }, + + emitter: function (x, y, maxParticles) { + + return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles)); + + }, + + bitmapText: function (x, y, text, style) { + + return this.world.group.add(new Phaser.BitmapText(this.game, x, y, text, style)); + + }, + + tilemap: function (x, y, key, resizeWorld, tileWidth, tileHeight) { + + return this.world.group.add(new Phaser.Tilemap(this.game, key, x, y, resizeWorld, tileWidth, tileHeight)); + + }, + + renderTexture: function (key, width, height) { + + var texture = new Phaser.RenderTexture(this.game, key, width, height); + + this.game.cache.addRenderTexture(key, texture); + + return texture; + + }, }; Phaser.Sprite = function (game, x, y, key, frame) { x = x || 0; y = y || 0; - key = key || null; // if null we ought to set to the phaser logo or something :) + key = key || null; frame = frame || null; this.game = game; @@ -15213,16 +13815,14 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.renderOrderID = -1; - if (key) - { - PIXI.Sprite.call(this, PIXI.TextureCache[key]); - } - else - { - // No texture yet - PIXI.Sprite.call(this); - } + // If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. + // The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + this.lifespan = 0; + /** + * The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components + * @type Events + */ this.events = new Phaser.Events(this); /** @@ -15231,28 +13831,50 @@ Phaser.Sprite = function (game, x, y, key, frame) { */ this.animations = new Phaser.AnimationManager(this); - if (this.game.cache.isSpriteSheet(key)) - { - this.animations.loadFrameData(this.game.cache.getFrameData(key)); + /** + * The Input Handler Component + * @type InputHandler + */ + this.input = new Phaser.InputHandler(this); - if (frame !== null) - { - if (typeof frame === 'string') - { - this.frameName = frame; - } - else - { - this.frame = frame; - } - } + this.key = key; + + if (key instanceof Phaser.RenderTexture) + { + PIXI.Sprite.call(this, key); + + this.currentFrame = this.game.cache.getTextureFrame(key.name); } else { - this.currentFrame = this.game.cache.getFrame(key); - } + if (key == null || this.game.cache.checkImageKey(key) == false) + { + key = '__default'; + } - this.input = new Phaser.InputHandler(this); + PIXI.Sprite.call(this, PIXI.TextureCache[key]); + + if (this.game.cache.isSpriteSheet(key)) + { + this.animations.loadFrameData(this.game.cache.getFrameData(key)); + + if (frame !== null) + { + if (typeof frame === 'string') + { + this.frameName = frame; + } + else + { + this.frame = frame; + } + } + } + else + { + this.currentFrame = this.game.cache.getFrame(key); + } + } /** * The anchor sets the origin point of the texture. @@ -15265,6 +13887,9 @@ Phaser.Sprite = function (game, x, y, key, frame) { */ this.anchor = new Phaser.Point(); + this._cropUUID = null; + this._cropRect = null; + this.x = x; this.y = y; @@ -15336,6 +13961,11 @@ Phaser.Sprite = function (game, x, y, key, frame) { // Set-up the physics body this.body = new Phaser.Physics.Arcade.Body(this); + // World bounds check + this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds); + this.inWorldThreshold = 0; + this._outOfBoundsFired = false; + }; // Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) @@ -15343,9 +13973,9 @@ Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype); Phaser.Sprite.prototype.constructor = Phaser.Sprite; /** - * Automatically called by World.update + * Automatically called by World.update. You can create your own update in Objects that extend Phaser.Sprite. */ -Phaser.Sprite.prototype.update = function() { +Phaser.Sprite.prototype.preUpdate = function() { if (!this.exists) { @@ -15353,6 +13983,17 @@ Phaser.Sprite.prototype.update = function() { return; } + if (this.lifespan > 0) + { + this.lifespan -= this.game.time.elapsed; + + if (this.lifespan <= 0) + { + this.kill(); + return; + } + } + this._cache.dirty = false; if (this.animations.update()) @@ -15364,7 +14005,6 @@ Phaser.Sprite.prototype.update = function() { this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); // If this sprite or the camera have moved then let's update everything - // It may have rotated though ... if (this.position.x != this._cache.x || this.position.y != this._cache.y) { this.position.x = this._cache.x; @@ -15464,12 +14104,38 @@ Phaser.Sprite.prototype.update = function() { } -Phaser.Sprite.prototype.postUpdate = function() { +Phaser.Sprite.prototype.revive = function() { - this.body.postUpdate(); + this.alive = true; + this.exists = true; + this.visible = true; + this.events.onRevived.dispatch(this); } +Phaser.Sprite.prototype.kill = function() { + + this.alive = false; + this.exists = false; + this.visible = false; + this.events.onKilled.dispatch(this); + +} + +Phaser.Sprite.prototype.reset = function(x, y) { + + this.x = x; + this.y = y; + this.position.x = x; + this.position.y = y; + this.alive = true; + this.exists = true; + this.visible = true; + this._outOfBoundsFired = false; + this.body.reset(); + +} + Phaser.Sprite.prototype.updateBounds = function() { // Update the edge points @@ -15493,6 +14159,29 @@ Phaser.Sprite.prototype.updateBounds = function() { this._cache.boundsX = this._cache.x; this._cache.boundsY = this._cache.y; + if (this.inWorld == false) + { + // Sprite WAS out of the screen, is it still? + this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); + + if (this.inWorld) + { + // It's back again, reset the OOB check + this._outOfBoundsFired = false; + } + } + else + { + // Sprite WAS in the screen, has it now left? + this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); + + if (this.inWorld == false) + { + this.events.onOutOfBounds.dispatch(this); + this._outOfBoundsFired = true; + } + } + } Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) { @@ -15603,6 +14292,48 @@ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { }); +Object.defineProperty(Phaser.Sprite.prototype, "crop", { + + /** + * Get the input enabled state of this Sprite. + */ + get: function () { + + return this._cropRect; + + }, + + /** + * Set the ability for this sprite to receive input events. + */ + set: function (value) { + + if (value instanceof Phaser.Rectangle) + { + if (this._cropUUID == null) + { + this._cropUUID = this.game.rnd.uuid(); + + PIXI.TextureCache[this._cropUUID] = new PIXI.Texture(PIXI.BaseTextureCache[this.key], { + x: value.x, + y: value.y, + width: value.width, + height: value.height + }); + } + else + { + PIXI.TextureCache[this._cropUUID].frame = value; + } + + this._cropRect = value; + this.setTexture(PIXI.TextureCache[this._cropUUID]); + } + + } + +}); + Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { /** @@ -15705,6 +14436,478 @@ Phaser.Text.prototype.constructor = Phaser.Text; // Add our own custom methods +/** +* Create a new Button object. +* +* @param game {Phaser.Game} Current game instance. +* @param [x] {number} X position of the button. +* @param [y] {number} Y position of the button. +* @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this button. +* @param [callback] {function} The function to call when this button is pressed +* @param [callbackContext] {object} The context in which the callback will be called (usually 'this') +* @param [overFrame] {string|number} This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. +* @param [outFrame] {string|number} This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. +* @param [downFrame] {string|number} This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. +*/ +Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { + + x = x || 0; + y = y || 0; + key = key || null; + callback = callback || null; + callbackContext = callbackContext || this; + + Phaser.Sprite.call(this, game, x, y, key, outFrame); + + this._onOverFrameName = null; + this._onOutFrameName = null; + this._onDownFrameName = null; + this._onUpFrameName = null; + this._onOverFrameID = null; + this._onOutFrameID = null; + this._onDownFrameID = null; + this._onUpFrameID = null; + + // These are the signals the game will subscribe to + this.onInputOver = new Phaser.Signal; + this.onInputOut = new Phaser.Signal; + this.onInputDown = new Phaser.Signal; + this.onInputUp = new Phaser.Signal; + + this.setFrames(overFrame, outFrame, downFrame); + + if (callback !== null) + { + this.onInputUp.add(callback, callbackContext); + } + + this.input.start(0, false, true); + + // Redirect the input events to here so we can handle animation updates, etc + this.events.onInputOver.add(this.onInputOverHandler, this); + this.events.onInputOut.add(this.onInputOutHandler, this); + this.events.onInputDown.add(this.onInputDownHandler, this); + this.events.onInputUp.add(this.onInputUpHandler, this); + +}; + +Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype); +Phaser.Button.prototype.constructor = Phaser.Button; + +// Add our own custom methods + +Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { + + if (overFrame !== null) + { + if (typeof overFrame === 'string') + { + this._onOverFrameName = overFrame; + } + else + { + this._onOverFrameID = overFrame; + } + } + + if (outFrame !== null) + { + if (typeof outFrame === 'string') + { + this._onOutFrameName = outFrame; + this._onUpFrameName = outFrame; + } + else + { + this._onOutFrameID = outFrame; + this._onUpFrameID = outFrame; + } + } + + if (downFrame !== null) + { + if (typeof downFrame === 'string') + { + this._onDownFrameName = downFrame; + } + else + { + this._onDownFrameID = downFrame; + } + } + +}; + +Phaser.Button.prototype.onInputOverHandler = function (pointer) { + + if (this._onOverFrameName != null) + { + this.frameName = this._onOverFrameName; + } + else if (this._onOverFrameID != null) + { + this.frame = this._onOverFrameID; + } + + if (this.onInputOver) + { + this.onInputOver.dispatch(this, pointer); + } +}; + +Phaser.Button.prototype.onInputOutHandler = function (pointer) { + + if (this._onOutFrameName != null) + { + this.frameName = this._onOutFrameName; + } + else if (this._onOutFrameID != null) + { + this.frame = this._onOutFrameID; + } + + if (this.onInputOut) + { + this.onInputOut.dispatch(this, pointer); + } +}; + +Phaser.Button.prototype.onInputDownHandler = function (pointer) { + + if (this._onDownFrameName != null) + { + this.frameName = this._onDownFrameName; + } + else if (this._onDownFrameID != null) + { + this.frame = this._onDownFrameID; + } + + if (this.onInputDown) + { + this.onInputDown.dispatch(this, pointer); + } +}; + +Phaser.Button.prototype.onInputUpHandler = function (pointer) { + + if (this._onUpFrameName != null) + { + this.frameName = this._onUpFrameName; + } + else if (this._onUpFrameID != null) + { + this.frame = this._onUpFrameID; + } + + if (this.onInputUp) + { + this.onInputUp.dispatch(this, pointer); + } +}; + +Phaser.Graphics = function (game, x, y) { + + // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + this.exists = true; + + // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + this.alive = true; + + this.group = null; + + this.name = ''; + + this.game = game; + + PIXI.DisplayObjectContainer.call(this); + + this.position.x = x; + this.position.y = y; + + // Replaces the PIXI.Point with a slightly more flexible one + this.scale = new Phaser.Point(1, 1); + + // Influence of camera movement upon the position + this.scrollFactor = new Phaser.Point(1, 1); + + // A mini cache for storing all of the calculated values + this._cache = { + + dirty: false, + + // Transform cache + a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + + // The previous calculated position inc. camera x/y and scrollFactor + x: -1, y: -1, + + // The actual scale values based on the worldTransform + scaleX: 1, scaleY: 1 + + }; + + this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); + this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + + this.renderable = true; + + /** + * The alpha of the fill of this graphics object + * + * @property fillAlpha + * @type Number + */ + this.fillAlpha = 1; + + /** + * The width of any lines drawn + * + * @property lineWidth + * @type Number + */ + this.lineWidth = 0; + + /** + * The color of any lines drawn + * + * @property lineColor + * @type String + */ + this.lineColor = "black"; + + /** + * Graphics data + * + * @property graphicsData + * @type Array + * @private + */ + this.graphicsData = []; + + /** + * Current path + * + * @property currentPath + * @type Object + * @private + */ + this.currentPath = {points:[]}; + +}; + +Phaser.Graphics.prototype = Phaser.Utils.extend(true, PIXI.Graphics.prototype, PIXI.DisplayObjectContainer.prototype, Phaser.Sprite.prototype); +Phaser.Graphics.prototype.constructor = Phaser.Graphics; + +// Add our own custom methods + +/** + * Automatically called by World.update + */ +Phaser.Graphics.prototype.update = function() { + + if (!this.exists) + { + return; + } + + this._cache.dirty = false; + + this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); + this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + + if (this.position.x != this._cache.x || this.position.y != this._cache.y) + { + this.position.x = this._cache.x; + this.position.y = this._cache.y; + this._cache.dirty = true; + } + +} + +Object.defineProperty(Phaser.Graphics.prototype, 'angle', { + + get: function() { + return Phaser.Math.radToDeg(this.rotation); + }, + + set: function(value) { + this.rotation = Phaser.Math.degToRad(value); + } + +}); + +Object.defineProperty(Phaser.Graphics.prototype, 'x', { + + get: function() { + return this.position.x; + }, + + set: function(value) { + this.position.x = value; + } + +}); + +Object.defineProperty(Phaser.Graphics.prototype, 'y', { + + get: function() { + return this.position.y; + }, + + set: function(value) { + this.position.y = value; + } + +}); + +Phaser.RenderTexture = function (game, key, width, height) { + + this.game = game; + + this.name = key; + + PIXI.EventTarget.call( this ); + + this.width = width || 100; + this.height = height || 100; + + this.indetityMatrix = PIXI.mat3.create(); + + this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + + if (PIXI.gl) + { + this.initWebGL(); + } + else + { + this.initCanvas(); + } + +}; + +Phaser.RenderTexture.prototype = Phaser.Utils.extend(true, PIXI.RenderTexture.prototype); +Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture; + +Phaser.BitmapText = function (game, x, y, text, style) { + + x = x || 0; + y = y || 0; + text = text || ''; + style = style || ''; + + // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + this.exists = true; + + // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + this.alive = true; + + this.group = null; + + this.name = ''; + + this.game = game; + + PIXI.BitmapText.call(this, text, style); + + this.position.x = x; + this.position.y = y; + + // Replaces the PIXI.Point with a slightly more flexible one + this.scale = new Phaser.Point(1, 1); + + // Influence of camera movement upon the position + this.scrollFactor = new Phaser.Point(1, 1); + + // A mini cache for storing all of the calculated values + this._cache = { + + dirty: false, + + // Transform cache + a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + + // The previous calculated position inc. camera x/y and scrollFactor + x: -1, y: -1, + + // The actual scale values based on the worldTransform + scaleX: 1, scaleY: 1 + + }; + + this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); + this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + + this.renderable = true; + +}; + +Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype); +Phaser.BitmapText.prototype.constructor = Phaser.BitmapText; + +// Add our own custom methods + +/** + * Automatically called by World.update + */ +Phaser.BitmapText.prototype.update = function() { + + if (!this.exists) + { + return; + } + + this._cache.dirty = false; + + this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); + this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + + if (this.position.x != this._cache.x || this.position.y != this._cache.y) + { + this.position.x = this._cache.x; + this.position.y = this._cache.y; + this._cache.dirty = true; + } + +} + +Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { + + get: function() { + return Phaser.Math.radToDeg(this.rotation); + }, + + set: function(value) { + this.rotation = Phaser.Math.degToRad(value); + } + +}); + +Object.defineProperty(Phaser.BitmapText.prototype, 'x', { + + get: function() { + return this.position.x; + }, + + set: function(value) { + this.position.x = value; + } + +}); + +Object.defineProperty(Phaser.BitmapText.prototype, 'y', { + + get: function() { + return this.position.y; + }, + + set: function(value) { + this.position.y = value; + } + +}); + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -15714,12 +14917,26 @@ Phaser.Text.prototype.constructor = Phaser.Text; Phaser.Canvas = { + create: function (width, height) { + + width = width || 256; + height = height || 256; + + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + canvas.style.display = 'block'; + + return canvas; + + }, + /** * Get the DOM offset values of any given element */ getOffset: function (element, point) { - if (typeof point === "undefined") { point = new Phaser.Point; } + point = point || new Phaser.Point; var box = element.getBoundingClientRect(); var clientTop = element.clientTop || document.body.clientTop || 0; @@ -15755,7 +14972,7 @@ Phaser.Canvas = { */ setBackgroundColor: function (canvas, color) { - if (typeof color === "undefined") { color = 'rgb(0,0,0)'; } + color = color || 'rgb(0,0,0)'; canvas.style.backgroundColor = color; @@ -15773,7 +14990,7 @@ Phaser.Canvas = { */ setTouchAction: function (canvas, value) { - if (typeof value === "undefined") { value = 'none'; } + value = value || 'none'; canvas.style.msTouchAction = value; canvas.style['ms-touch-action'] = value; @@ -15795,12 +15012,19 @@ Phaser.Canvas = { */ addToDOM: function (canvas, parent, overflowHidden) { - if (typeof parent === "undefined") { parent = ''; } - if (typeof overflowHidden === "undefined") { overflowHidden = true; } + parent = parent || ''; + overflowHidden = overflowHidden || true; - if ((parent !== '' || parent !== null) && document.getElementById(parent)) + if (parent !== '') { - document.getElementById(parent).appendChild(canvas); + if (document.getElementById(parent)) + { + document.getElementById(parent).appendChild(canvas); + } + else + { + document.body.appendChild(canvas); + } if (overflowHidden) { @@ -15899,6 +15123,479 @@ Phaser.Canvas = { }; +Phaser.StageScaleMode = function (game, width, height) { + + /** + * Stage height when start the game. + * @type {number} + */ + this._startHeight = 0; + + /** + * If the game should be forced to use Landscape mode, this is set to true by Game.Stage + * @type {bool} + */ + this.forceLandscape = false; + + /** + * If the game should be forced to use Portrait mode, this is set to true by Game.Stage + * @type {bool} + */ + this.forcePortrait = false; + + /** + * If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. + * @type {bool} + */ + this.incorrectOrientation = false; + + /** + * If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @type {bool} + */ + this.pageAlignHorizontally = false; + + /** + * If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @type {bool} + */ + this.pageAlignVeritcally = false; + + /** + * Minimum width the canvas should be scaled to (in pixels) + * @type {number} + */ + this.minWidth = null; + + /** + * Maximum width the canvas should be scaled to (in pixels). + * If null it will scale to whatever width the browser can handle. + * @type {number} + */ + this.maxWidth = null; + + /** + * Minimum height the canvas should be scaled to (in pixels) + * @type {number} + */ + this.minHeight = null; + + /** + * Maximum height the canvas should be scaled to (in pixels). + * If null it will scale to whatever height the browser can handle. + * @type {number} + */ + this.maxHeight = null; + + /** + * Width of the stage after calculation. + * @type {number} + */ + this.width = 0; + + /** + * Height of the stage after calculation. + * @type {number} + */ + this.height = 0; + + /** + * The maximum number of times it will try to resize the canvas to fill the browser (default is 5) + * @type {number} + */ + this.maxIterations = 5; + this.game = game; + + this.enterLandscape = new Phaser.Signal(); + this.enterPortrait = new Phaser.Signal(); + + if (window['orientation']) + { + this.orientation = window['orientation']; + } + else + { + if (window.outerWidth > window.outerHeight) + { + this.orientation = 90; + } + else + { + this.orientation = 0; + } + } + + this.scaleFactor = new Phaser.Point(1, 1); + this.aspectRatio = 0; + + var _this = this; + + window.addEventListener('orientationchange', function (event) { + return _this.checkOrientation(event); + }, false); + + window.addEventListener('resize', function (event) { + return _this.checkResize(event); + }, false); + +}; + +Phaser.StageScaleMode.EXACT_FIT = 0; +Phaser.StageScaleMode.NO_SCALE = 1; +Phaser.StageScaleMode.SHOW_ALL = 2; + +Phaser.StageScaleMode.prototype = { + + startFullScreen: function () { + + if (this.isFullScreen) + { + return; + } + + var element = this.game.canvas; + + if (element['requestFullScreen']) + { + element['requestFullScreen'](); + } + else if (element['mozRequestFullScreen']) + { + element['mozRequestFullScreen'](); + } + else if (element['webkitRequestFullScreen']) + { + element['webkitRequestFullScreen'](Element.ALLOW_KEYBOARD_INPUT); + } + + this.game.stage.canvas.style['width'] = '100%'; + this.game.stage.canvas.style['height'] = '100%'; + + }, + + stopFullScreen: function () { + + if (document['cancelFullScreen']) + { + document['cancelFullScreen'](); + } + else if (document['mozCancelFullScreen']) + { + document['mozCancelFullScreen'](); + } + else if (document['webkitCancelFullScreen']) + { + document['webkitCancelFullScreen'](); + } + + }, + + checkOrientationState: function () { + + // They are in the wrong orientation + if (this.incorrectOrientation) + { + if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth)) + { + // Back to normal + this.game.paused = false; + this.incorrectOrientation = false; + this.refresh(); + } + } + else + { + if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth)) + { + // Show orientation screen + this.game.paused = true; + this.incorrectOrientation = true; + this.refresh(); + } + } + }, + + /** + * Handle window.orientationchange events + */ + checkOrientation: function (event) { + + this.orientation = window['orientation']; + + if (this.isLandscape) + { + this.enterLandscape.dispatch(this.orientation, true, false); + } + else + { + this.enterPortrait.dispatch(this.orientation, false, true); + } + + if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE) + { + this.refresh(); + } + + }, + + /** + * Handle window.resize events + */ + checkResize: function (event) { + + if (window.outerWidth > window.outerHeight) + { + this.orientation = 90; + } + else + { + this.orientation = 0; + } + + if (this.isLandscape) + { + this.enterLandscape.dispatch(this.orientation, true, false); + } + else + { + this.enterPortrait.dispatch(this.orientation, false, true); + } + + if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE) + { + this.refresh(); + } + }, + + /** + * Re-calculate scale mode and update screen size. + */ + refresh: function () { + + var _this = this; + + // We can't do anything about the status bars in iPads, web apps or desktops + if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) + { + // document.documentElement['style'].minHeight = '2000px'; + // this._startHeight = window.innerHeight; + + if (this.game.device.android && this.game.device.chrome == false) + { + window.scrollTo(0, 1); + } + else + { + window.scrollTo(0, 0); + } + } + + if (this._check == null && this.maxIterations > 0) + { + this._iterations = this.maxIterations; + this._check = window.setInterval(function () { + return _this.setScreenSize(); + }, 10); + this.setScreenSize(); + } + + }, + + /** + * Set screen size automatically based on the scaleMode. + */ + setScreenSize: function (force) { + + if (typeof force == 'undefined') + { + force = false; + } + + if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) + { + if (this.game.device.android && this.game.device.chrome == false) + { + window.scrollTo(0, 1); + } + else + { + window.scrollTo(0, 0); + } + } + + this._iterations--; + + if (force || window.innerHeight > this._startHeight || this._iterations < 0) + { + // Set minimum height of content to new window height + document.documentElement['style'].minHeight = window.innerHeight + 'px'; + + if (this.incorrectOrientation == true) + { + this.setMaximum(); + } + else if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT) + { + this.setExactFit(); + } + else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL) + { + this.setShowAll(); + } + + this.setSize(); + clearInterval(this._check); + this._check = null; + } + + }, + + setSize: function () { + + if (this.incorrectOrientation == false) + { + if (this.maxWidth && this.width > this.maxWidth) + { + this.width = this.maxWidth; + } + + if (this.maxHeight && this.height > this.maxHeight) + { + this.height = this.maxHeight; + } + + if (this.minWidth && this.width < this.minWidth) + { + this.width = this.minWidth; + } + + if (this.minHeight && this.height < this.minHeight) + { + this.height = this.minHeight; + } + } + + this.game.canvas.style.width = this.width + 'px'; + this.game.canvas.style.height = this.height + 'px'; + + this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height); + + if (this.pageAlignHorizontally) + { + if (this.width < window.innerWidth && this.incorrectOrientation == false) + { + this.game.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; + } + else + { + this.game.canvas.style.marginLeft = '0px'; + } + } + + if (this.pageAlignVeritcally) + { + if (this.height < window.innerHeight && this.incorrectOrientation == false) + { + this.game.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; + } + else + { + this.game.canvas.style.marginTop = '0px'; + } + } + + Phaser.Canvas.getOffset(this.game.canvas, this.game.stage.offset); + + this.aspectRatio = this.width / this.height; + + this.scaleFactor.x = this.game.width / this.width; + this.scaleFactor.y = this.game.height / this.height; + + }, + + setMaximum: function () { + + this.width = window.innerWidth; + this.height = window.innerHeight; + + }, + + setShowAll: function () { + + var multiplier = Math.min((window.innerHeight / this.game.height), (window.innerWidth / this.game.width)); + + this.width = Math.round(this.game.width * multiplier); + this.height = Math.round(this.game.height * multiplier); + + }, + + setExactFit: function () { + + var availableWidth = window.innerWidth - 0; + var availableHeight = window.innerHeight - 5; + + console.log('available', availableWidth, availableHeight); + + if (this.maxWidth && availableWidth > this.maxWidth) + { + this.width = this.maxWidth; + } + else + { + this.width = availableWidth; + } + + if (this.maxHeight && availableHeight > this.maxHeight) + { + this.height = this.maxHeight; + } + else + { + this.height = availableHeight; + } + + console.log('setExactFit', this.width, this.height, this.game.stage.offset); + + } + +}; + +Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", { + + get: function () { + + if (document['fullscreenElement'] === null || document['mozFullScreenElement'] === null || document['webkitFullscreenElement'] === null) + { + return false; + } + + return true; + + } + +}); + +Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", { + + get: function () { + return this.orientation == 0 || this.orientation == 180; + } + +}); + +Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", { + + get: function () { + return this.orientation === 90 || this.orientation === -90; + } + +}); + + /** * Phaser - Device * @@ -16015,6 +15712,12 @@ Phaser.Device = function () { */ this.css3D = false; + /** + * Is Pointer Lock available? + * @type {boolean} + */ + this.pointerLock = false; + // Browser /** @@ -16220,6 +15923,8 @@ Phaser.Device.prototype = { if (window.navigator.msPointerEnabled) { this.mspointer = true; } + + this.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; }, @@ -17261,9 +16966,9 @@ Phaser.Math = { */ angleLimit: function (angle, min, max) { var result = angle; - if(angle > max) { + if (angle > max) { result = max; - } else if(angle < min) { + } else if (angle < min) { result = min; } return result; @@ -17279,10 +16984,10 @@ Phaser.Math = { var m = v.length - 1; var f = m * k; var i = Math.floor(f); - if(k < 0) { + if (k < 0) { return this.linear(v[0], v[1], f); } - if(k > 1) { + if (k > 1) { return this.linear(v[m], v[m - 1], m - f); } return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i); @@ -17297,7 +17002,7 @@ Phaser.Math = { bezierInterpolation: function (v, k) { var b = 0; var n = v.length - 1; - for(var i = 0; i <= n; i++) { + for (var i = 0; i <= n; i++) { b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i); } return b; @@ -17316,15 +17021,15 @@ Phaser.Math = { var i = Math.floor(f); if (v[0] === v[m]) { - if(k < 0) { + if (k < 0) { i = Math.floor(f = m * (1 + k)); } return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); } else { - if(k < 0) { + if (k < 0) { return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]); } - if(k > 1) { + if (k > 1) { return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); } return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); @@ -17870,28 +17575,34 @@ Phaser.QuadTree.prototype = { **/ Phaser.Circle = function (x, y, diameter) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } - if (typeof diameter === "undefined") { diameter = 0; } - - this._diameter = 0; - this._radius = 0; + x = x || 0; + y = y || 0; + diameter = diameter || 0; /** * The x coordinate of the center of the circle * @property x * @type Number **/ - this.x = 0; + this.x = x; /** * The y coordinate of the center of the circle * @property y * @type Number **/ - this.y = 0; + this.y = y; - this.setTo(x, y, diameter); + this._diameter = diameter; + + if (diameter > 0) + { + this._radius = diameter * 0.5; + } + else + { + this._radius = 0; + } }; @@ -18058,13 +17769,12 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", { * @param {Number} The diameter of the circle. **/ set: function (value) { - if(value > 0) { + if (value > 0) { this._diameter = value; this._radius = value * 0.5; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "radius", { @@ -18084,13 +17794,12 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", { * @param {Number} The radius of the circle. **/ set: function (value) { - if(value > 0) { + if (value > 0) { this._radius = value; this._diameter = value * 2; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "left", { @@ -18110,15 +17819,14 @@ Object.defineProperty(Phaser.Circle.prototype, "left", { * @param {Number} The value to adjust the position of the leftmost point of the circle by. **/ set: function (value) { - if(value > this.x) { + if (value > this.x) { this._radius = 0; this._diameter = 0; } else { this.radius = this.x - value; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "right", { @@ -18138,15 +17846,14 @@ Object.defineProperty(Phaser.Circle.prototype, "right", { * @param {Number} The amount to adjust the diameter of the circle by. **/ set: function (value) { - if(value < this.x) { + if (value < this.x) { this._radius = 0; this._diameter = 0; } else { this.radius = value - this.x; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "top", { @@ -18166,15 +17873,14 @@ Object.defineProperty(Phaser.Circle.prototype, "top", { * @param {Number} The amount to adjust the height of the circle by. **/ set: function (value) { - if(value > this.y) { + if (value > this.y) { this._radius = 0; this._diameter = 0; } else { this.radius = this.y - value; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "bottom", { @@ -18201,9 +17907,8 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", { } else { this.radius = value - this.y; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "area", { @@ -18214,14 +17919,13 @@ Object.defineProperty(Phaser.Circle.prototype, "area", { * @return {Number} This area of this circle. **/ get: function () { - if(this._radius > 0) { + if (this._radius > 0) { return Math.PI * this._radius * this._radius; } else { return 0; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Circle.prototype, "empty", { @@ -18242,9 +17946,8 @@ Object.defineProperty(Phaser.Circle.prototype, "empty", { **/ set: function (value) { this.setTo(0, 0, 0); - }, - enumerable: true, - configurable: true + } + }); // Statics @@ -18378,8 +18081,8 @@ Phaser.Circle.intersectsRectangle = function (c, r) { **/ Phaser.Point = function (x, y) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } + x = x || 0; + y = y || 0; this.x = x; this.y = y; @@ -18777,34 +18480,6 @@ Phaser.Rectangle = function (x, y, width, height) { Phaser.Rectangle.prototype = { - /** - * @property x - * @type Number - * @default 0 - */ - x: 0, - - /** - * @property y - * @type Number - * @default 0 - */ - y: 0, - - /** - * @property width - * @type Number - * @default 0 - */ - width: 0, - - /** - * @property height - * @type Number - * @default 0 - */ - height: 0, - /** * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. * @method offset @@ -19023,9 +18698,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", { **/ get: function () { return Math.round(this.width / 2); - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", { @@ -19037,9 +18711,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", { **/ get: function () { return Math.round(this.height / 2); - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { @@ -19059,14 +18732,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { * @param {Number} value **/ set: function (value) { - if(value <= this.y) { + if (value <= this.y) { this.height = 0; } else { this.height = (this.y - value); } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { @@ -19087,9 +18759,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { set: function (value) { this.right = value.x; this.bottom = value.y; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "left", { @@ -19116,9 +18787,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", { this.width = this.right - value; } this.x = value; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "right", { @@ -19140,14 +18810,13 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", { * @param {Number} value **/ set: function (value) { - if(value <= this.x) { + if (value <= this.x) { this.width = 0; } else { this.width = this.x + value; } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "volume", { @@ -19159,9 +18828,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "volume", { **/ get: function () { return this.width * this.height; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", { @@ -19173,9 +18841,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", { **/ get: function () { return (this.width * 2) + (this.height * 2); - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "centerX", { @@ -19196,9 +18863,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", { **/ set: function (value) { this.x = value - this.halfWidth; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "centerY", { @@ -19219,9 +18885,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", { **/ set: function (value) { this.y = value - this.halfHeight; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "top", { @@ -19243,15 +18908,14 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", { * @param {Number} value **/ set: function (value) { - if(value >= this.bottom) { + if (value >= this.bottom) { this.height = 0; this.y = value; } else { this.height = (this.bottom - value); } - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { @@ -19272,9 +18936,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { set: function (value) { this.x = value.x; this.y = value.y; - }, - enumerable: true, - configurable: true + } + }); Object.defineProperty(Phaser.Rectangle.prototype, "empty", { @@ -19295,9 +18958,8 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", { **/ set: function (value) { this.setTo(0, 0, 0, 0); - }, - enumerable: true, - configurable: true + } + }); // Statics @@ -19630,6 +19292,9 @@ Phaser.TweenManager = function (game) { this.game = game; this._tweens = []; + this.game.onPause.add(this.pauseAll, this); + this.game.onResume.add(this.resumeAll, this); + }; Phaser.TweenManager.prototype = { @@ -19671,22 +19336,11 @@ Phaser.TweenManager.prototype = { * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * * @param obj {object} Object the tween will be run on. - * @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written. * @return {Phaser.Tween} The newly created tween object. */ - create: function (object, localReference) { + create: function (object) { - if (typeof localReference === "undefined") { localReference = false; } - - if (localReference) - { - object['tween'] = new Phaser.Tween(object, this.game); - return object['tween']; - } - else - { - return new Phaser.Tween(object, this.game); - } + return new Phaser.Tween(object, this.game); }, @@ -20405,21 +20059,12 @@ Phaser.Easing = { */ Phaser.Time = function (game) { - this.game = game; - - // this.game.onPause.add(this.gamePaused, this); - // this.game.onResume.add(this.gameResumed, this); - -}; - -Phaser.Time.prototype = { - /** * A reference to the currently running Game. * @property game * @type {Phaser.Game} */ - game: null, + this.game = game; /** * The time at which the Game instance started. @@ -20427,7 +20072,7 @@ Phaser.Time.prototype = { * @private * @type {Number} */ - _started: 0, + this._started = 0; /** * The time (in ms) that the last second counter ticked over. @@ -20435,7 +20080,7 @@ Phaser.Time.prototype = { * @private * @type {Number} */ - _timeLastSecond: 0, + this._timeLastSecond = 0; /** * The time the game started being paused. @@ -20443,7 +20088,7 @@ Phaser.Time.prototype = { * @private * @type {Number} */ - _pauseStarted: 0, + this._pauseStarted = 0; /** * The elapsed time calculated for the physics motion updates. @@ -20451,7 +20096,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - physicsElapsed: 0, + this.physicsElapsed = 0; /** * Game time counter. @@ -20459,7 +20104,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - time: 0, + this.time = 0; /** * Records how long the game has been paused for. Is reset each time the game pauses. @@ -20467,7 +20112,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - pausedTime: 0, + this.pausedTime = 0; /** * The time right now. @@ -20475,7 +20120,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - now: 0, + this.now = 0; /** * Elapsed time since the last frame. @@ -20483,7 +20128,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - elapsed: 0, + this.elapsed = 0; /** * Frames per second. @@ -20491,7 +20136,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - fps: 0, + this.fps = 0; /** * The lowest rate the fps has dropped to. @@ -20499,7 +20144,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - fpsMin: 1000, + this.fpsMin = 1000; /** * The highest rate the fps has reached (usually no higher than 60fps). @@ -20507,7 +20152,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - fpsMax: 0, + this.fpsMax = 0; /** * The minimum amount of time the game has taken between two frames. @@ -20515,7 +20160,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - msMin: 1000, + this.msMin = 1000; /** * The maximum amount of time the game has taken between two frames. @@ -20523,7 +20168,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - msMax: 0, + this.msMax = 0; /** * The number of frames record in the last second. @@ -20531,7 +20176,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - frames: 0, + this.frames = 0; /** * Records how long the game was paused for in miliseconds. @@ -20539,7 +20184,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - pauseDuration: 0, + this.pauseDuration = 0; /** * The value that setTimeout needs to work out when to next update @@ -20547,7 +20192,7 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - timeToCall: 0, + this.timeToCall = 0; /** * Internal value used by timeToCall as part of the setTimeout loop @@ -20555,7 +20200,15 @@ Phaser.Time.prototype = { * @public * @type {Number} */ - lastTime: 0, + this.lastTime = 0; + + // Listen for game pause/resume events + this.game.onPause.add(this.gamePaused, this); + this.game.onResume.add(this.gameResumed, this); + +}; + +Phaser.Time.prototype = { /** * The number of seconds that have elapsed since the game was started. @@ -20598,7 +20251,8 @@ Phaser.Time.prototype = { this.physicsElapsed = 1.0 * (this.elapsed / 1000); // Paused? - if (this.game.paused) { + if (this.game.paused) + { this.pausedTime = this.now - this._pauseStarted; } @@ -20623,7 +20277,6 @@ Phaser.Time.prototype = { // Level out the elapsed timer to avoid spikes this.elapsed = 0; this.physicsElapsed = 0; - this.time = Date.now(); this.pauseDuration = this.pausedTime; }, @@ -20668,7 +20321,7 @@ Phaser.Time.prototype = { * @copyright 2013 Photon Storm Ltd. * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License */ -Phaser.AnimationManager = function (parent) { +Phaser.AnimationManager = function (sprite) { /** * Data contains animation frames. @@ -20681,17 +20334,18 @@ Phaser.AnimationManager = function (parent) { */ this.currentFrame = null; - this._parent = parent; + this.sprite = sprite; - this.game = parent.game; + this.game = sprite.game; this._anims = {}; + this.updateIfVisible = true; + }; Phaser.AnimationManager.prototype = { - updateIfVisible: true, /** * Load animation frame data. @@ -20727,12 +20381,12 @@ Phaser.AnimationManager.prototype = { } // Create the signals the AnimationManager will emit - // if (this._parent.events.onAnimationStart == null) - // { - // this._parent.events.onAnimationStart = new Phaser.Signal(); - // this._parent.events.onAnimationComplete = new Phaser.Signal(); - // this._parent.events.onAnimationLoop = new Phaser.Signal(); - // } + if (this.sprite.events.onAnimationStart == null) + { + this.sprite.events.onAnimationStart = new Phaser.Signal(); + this.sprite.events.onAnimationComplete = new Phaser.Signal(); + this.sprite.events.onAnimationLoop = new Phaser.Signal(); + } if (frames == null) { @@ -20752,10 +20406,10 @@ Phaser.AnimationManager.prototype = { frames = this._frameData.getFrameIndexesByName(frames); } - this._anims[name] = new Phaser.Animation(this.game, this._parent, this._frameData, name, frames, frameRate, loop); + this._anims[name] = new Phaser.Animation(this.game, this.sprite, this._frameData, name, frames, frameRate, loop); this.currentAnim = this._anims[name]; this.currentFrame = this.currentAnim.currentFrame; - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); return this._anims[name]; @@ -20840,7 +20494,7 @@ Phaser.AnimationManager.prototype = { */ update: function () { - if (this.updateIfVisible && this._parent.visible == false) + if (this.updateIfVisible && this.sprite.visible == false) { return false; } @@ -20848,7 +20502,7 @@ Phaser.AnimationManager.prototype = { if (this.currentAnim && this.currentAnim.update() == true) { this.currentFrame = this.currentAnim.currentFrame; - this._parent.currentFrame = this.currentFrame; + this.sprite.currentFrame = this.currentFrame; return true; } @@ -20875,10 +20529,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", { get: function () { return this._frameData; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { @@ -20893,10 +20545,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { { return -1; } - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { @@ -20920,14 +20570,12 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { { this.currentFrame = this._frameData.getFrame(value); this._frameIndex = value; - this._parent.currentFrame = this.currentFrame; - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.currentFrame = this.currentFrame; + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { @@ -20947,17 +20595,15 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { { this.currentFrame = this._frameData.getFrameByName(value); this._frameIndex = this.currentFrame.index; - this._parent.currentFrame = this.currentFrame; - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.currentFrame = this.currentFrame; + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } else { console.warn("Cannot set frameName: " + value); } - }, + } - enumerable: true, - configurable: true }); /** @@ -21027,7 +20673,7 @@ Phaser.Animation.prototype = { this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); - // this._parent.events.onAnimationStart.dispatch(this._parent, this); + this._parent.events.onAnimationStart.dispatch(this._parent, this); return this; @@ -21076,7 +20722,7 @@ Phaser.Animation.prototype = { this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); - // this._parent.events.onAnimationLoop.dispatch(this._parent, this); + this._parent.events.onAnimationLoop.dispatch(this._parent, this); } else { @@ -21120,7 +20766,7 @@ Phaser.Animation.prototype = { this.isPlaying = false; this.isFinished = true; - // this._parent.events.onAnimationComplete.dispatch(this._parent, this); + this._parent.events.onAnimationComplete.dispatch(this._parent, this); } @@ -21130,10 +20776,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { get: function () { return this._frames.length; - }, - - enumerable: true, - configurable: true + } }); @@ -21162,10 +20805,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } - }, - - enumerable: true, - configurable: true + } }); @@ -21181,133 +20821,119 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { */ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.sourceSizeW = width; - this.sourceSizeH = height; - this.centerX = Math.floor(width / 2); - this.centerY = Math.floor(height / 2); - this.name = name; - this.uuid = uuid; - this.distance = Phaser.Math.distance(0, 0, width, height); - -}; - -Phaser.Animation.Frame.prototype = { - - /** - * A link to the PIXI.TextureCache entry - */ - uuid: '', - /** * X position within the image to cut from. * @type {number} */ - x: 0, + this.x = x; /** * Y position within the image to cut from. * @type {number} */ - y: 0, + this.y = y; /** * Width of the frame. * @type {number} */ - width: 0, + this.width = width; /** * Height of the frame. * @type {number} */ - height: 0, + this.height = height; /** * center X position within the image to cut from. * @type {number} */ - centerX: 0, + this.centerX = Math.floor(width / 2); /** * center Y position within the image to cut from. * @type {number} */ - centerY: 0, - - /** - * The distance from the top left to the bottom-right of this Frame. - * @type {number} - */ - distance: 0, + this.centerY = Math.floor(height / 2); /** * Useful for Sprite Sheets. * @type {number} */ - index: 0, + this.index = 0; /** * Useful for Texture Atlas files. (is set to the filename value) */ - name: '', + this.name = name; + + /** + * A link to the PIXI.TextureCache entry + */ + this.uuid = uuid; + + /** + * The distance from the top left to the bottom-right of this Frame. + * @type {number} + */ + this.distance = Phaser.Math.distance(0, 0, width, height); /** * Rotated? (not yet implemented) */ - rotated: false, + this.rotated = false; /** * Either cw or ccw, rotation is always 90 degrees. */ - rotationDirection: 'cw', + this.rotationDirection = 'cw'; /** * Was it trimmed when packed? * @type {bool} */ - trimmed: false, - - // The coordinates of the trimmed sprite inside the original sprite + this.trimmed = false; /** * Width of the original sprite. * @type {number} */ - sourceSizeW: 0, + this.sourceSizeW = width; /** * Height of the original sprite. * @type {number} */ - sourceSizeH: 0, + this.sourceSizeH = height; /** * X position of the trimmed sprite inside original sprite. * @type {number} */ - spriteSourceSizeX: 0, + this.spriteSourceSizeX = 0; /** * Y position of the trimmed sprite inside original sprite. * @type {number} */ - spriteSourceSizeY: 0, + this.spriteSourceSizeY = 0; /** * Width of the trimmed sprite. * @type {number} */ - spriteSourceSizeW: 0, + this.spriteSourceSizeW = 0; /** * Height of the trimmed sprite. * @type {number} */ - spriteSourceSizeH: 0, + this.spriteSourceSizeH = 0; + +}; + +Phaser.Animation.Frame.prototype = { /** * Set trim of the frame. @@ -21352,23 +20978,24 @@ Phaser.Animation.Frame.prototype = { * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License */ Phaser.Animation.FrameData = function () { + + /** + * Local frame container. + * @type {Phaser.Frame[]} + * @private + */ + this._frames = []; + + /** + * Local frameName<->index container. + * @private + */ + this._frameNames = []; + }; Phaser.Animation.FrameData.prototype = { - /** - * Local frame container. - * @type {Phaser.Frame[]} - * @private - */ - _frames: [], - - /** - * Local frameName<->index container. - * @private - */ - _frameNames: [], - /** * Add a new frame. * @param frame {Frame} The frame you want to add. @@ -21380,7 +21007,8 @@ Phaser.Animation.FrameData.prototype = { this._frames.push(frame); - if (frame.name !== '') { + if (frame.name !== '') + { this._frameNames[frame.name] = frame.index; } @@ -21395,7 +21023,8 @@ Phaser.Animation.FrameData.prototype = { */ getFrame: function (index) { - if (this._frames[index]) { + if (this._frames[index]) + { return this._frames[index]; } @@ -21410,7 +21039,8 @@ Phaser.Animation.FrameData.prototype = { */ getFrameByName: function (name) { - if (this._frameNames[name] !== '') { + if (this._frameNames[name] !== '') + { return this._frames[this._frameNames[name]]; } @@ -21425,11 +21055,13 @@ Phaser.Animation.FrameData.prototype = { */ checkFrameName: function (name) { - if (this._frameNames[name] == null) { + if (this._frameNames[name] == null) + { return false; } return true; + }, /** @@ -21443,7 +21075,8 @@ Phaser.Animation.FrameData.prototype = { if (typeof output === "undefined") { output = []; } - for (var i = start; i <= end; i++) { + for (var i = start; i <= end; i++) + { output.push(this._frames[i]); } @@ -21460,7 +21093,8 @@ Phaser.Animation.FrameData.prototype = { if (typeof output === "undefined") { output = []; } - for (var i = 0; i < this._frames.length; i++) { + for (var i = 0; i < this._frames.length; i++) + { output.push(i); } @@ -21477,12 +21111,12 @@ Phaser.Animation.FrameData.prototype = { var output = []; - for (var i = 0; i < input.length; i++) { - - if (this.getFrameByName(input[i])) { + for (var i = 0; i < input.length; i++) + { + if (this.getFrameByName(input[i])) + { output.push(this.getFrameByName(input[i]).index); } - } return output; @@ -21506,7 +21140,8 @@ Phaser.Animation.FrameData.prototype = { var output = []; - for (var i = 0; i < range.length; i++) { + for (var i = 0; i < range.length; i++) + { output.push(this._frames[i]); } @@ -21516,11 +21151,11 @@ Phaser.Animation.FrameData.prototype = { }; Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", { + get: function () { return this._frames.length; - }, - enumerable: true, - configurable: true + } + }); @@ -21549,7 +21184,8 @@ Phaser.Animation.Parser = { // How big is our image? var img = game.cache.getImage(key); - if (img == null) { + if (img == null) + { return null; } @@ -21559,13 +21195,15 @@ Phaser.Animation.Parser = { var column = Math.round(height / frameHeight); var total = row * column; - if (frameMax !== -1) { + if (frameMax !== -1) + { total = frameMax; } // Zero or smaller than frame sizes? - if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { - throw new Error("AnimationLoader.parseSpriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); + if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) + { + console.warn("Phaser.Animation.Parser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); return null; } @@ -21608,9 +21246,11 @@ Phaser.Animation.Parser = { JSONData: function (game, json, cacheKey) { // Malformed? - if (!json['frames']) { + if (!json['frames']) + { + console.warn("Phaser.Animation.Parser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); console.log(json); - throw new Error("Phaser.AnimationLoader.parseJSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); + return; } // Let's create some frames then @@ -21669,14 +21309,16 @@ Phaser.Animation.Parser = { JSONDataHash: function (game, json, cacheKey) { // Malformed? - if (!json['frames']) { + if (!json['frames']) + { + console.warn("Phaser.Animation.Parser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); console.log(json); - throw new Error("Phaser.AnimationLoader.parseJSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); + return; } // Let's create some frames then var data = new Phaser.Animation.FrameData(); - + // By this stage frames is a fully parsed array var frames = json['frames']; var newFrame; @@ -21730,8 +21372,10 @@ Phaser.Animation.Parser = { XMLData: function (game, xml, cacheKey) { // Malformed? - if (!xml.getElementsByTagName('TextureAtlas')) { - throw new Error("Phaser.AnimationLoader.parseXMLData: Invalid Texture Atlas XML given, missing tag"); + if (!xml.getElementsByTagName('TextureAtlas')) + { + console.warn("Phaser.Animation.Parser.XMLData: Invalid Texture Atlas XML given, missing tag"); + return; } // Let's create some frames then @@ -21803,40 +21447,56 @@ Phaser.Animation.Parser = { * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License */ Phaser.Cache = function (game) { - this.game = game; -}; - -Phaser.Cache.prototype = { /** * Local reference to Game. */ - game: null, + this.game = game; /** * Canvas key-value container. * @type {object} * @private */ - _canvases: {}, + this._canvases = {}; /** * Image key-value container. * @type {object} */ - _images: {}, + this._images = {}; + + /** + * RenderTexture key-value container. + * @type {object} + */ + this._textures = {}; /** * Sound key-value container. * @type {object} */ - _sounds: {}, + this._sounds = {}; /** * Text key-value container. * @type {object} */ - _text: {}, + this._text = {}; + + /** + * Tilemap key-value container. + * @type {object} + */ + this._tilemaps = {}; + + this.addDefaultImage(); + + this.onSoundUnlock = new Phaser.Signal; + +}; + +Phaser.Cache.prototype = { /** * Add a new canvas. @@ -21850,6 +21510,19 @@ Phaser.Cache.prototype = { }, + /** + * Add a new canvas. + * @param key {string} Asset key for this canvas. + * @param canvas {RenderTexture} A RenderTexture. + */ + addRenderTexture: function (key, texture) { + + var frame = new Phaser.Animation.Frame(0, 0, texture.width, texture.height, '', ''); + + this._textures[key] = { texture: texture, frame: frame }; + + }, + /** * Add a new sprite sheet. * @param key {string} Asset key for the sprite sheet. @@ -21870,6 +21543,22 @@ Phaser.Cache.prototype = { }, + /** + * Add a new tilemap. + * @param key {string} Asset key for the texture atlas. + * @param url {string} URL of this texture atlas file. + * @param data {object} Extra texture atlas data. + * @param atlasData {object} Texture atlas frames data. + */ + addTilemap: function (key, url, data, mapData, format) { + + this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format }; + + PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); + PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); + + }, + /** * Add a new texture atlas. * @param key {string} Asset key for the texture atlas. @@ -21899,6 +21588,44 @@ Phaser.Cache.prototype = { }, + /** + * Add a new Bitmap Font. + * @param key {string} Asset key for the font texture. + * @param url {string} URL of this font xml file. + * @param data {object} Extra font data. + * @param xmlData {object} Texture atlas frames data. + */ + addBitmapFont: function (key, url, data, xmlData) { + + this._images[key] = { url: url, data: data, spriteSheet: true }; + + PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); + PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); + + Phaser.Loader.Parser.bitmapFont(this.game, xmlData, key); + // this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, xmlData, key); + + }, + + /** + * Adds a default image to be used when a key is wrong / missing. + * Is mapped to the key __default + */ + addDefaultImage: function () { + + this._images['__default'] = { url: null, data: null, spriteSheet: false }; + this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 32, 32, '', ''); + + var base = new PIXI.BaseTexture(); + base.width = 32; + base.height = 32; + base.hasLoaded = true; // avoids a hanging event listener + + PIXI.BaseTextureCache['__default'] = base; + PIXI.TextureCache['__default'] = new PIXI.Texture(base); + + }, + /** * Add a new image. * @param key {string} Asset key for the image. @@ -21929,11 +21656,12 @@ Phaser.Cache.prototype = { var locked = this.game.sound.touchLocked; var decoded = false; - if (audioTag) { + if (audioTag) + { decoded = true; } - this._sounds[key] = { url: url, data: data, locked: locked, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag }; + this._sounds[key] = { url: url, data: data, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag }; }, @@ -21941,8 +21669,8 @@ Phaser.Cache.prototype = { var _this = this; - if (this._sounds[key]) { - + if (this._sounds[key]) + { this._sounds[key].data.src = this._sounds[key].url; this._sounds[key].data.addEventListener('canplaythrough', function () { @@ -21955,7 +21683,8 @@ Phaser.Cache.prototype = { reloadSoundComplete: function (key) { - if (this._sounds[key]) { + if (this._sounds[key]) + { this._sounds[key].locked = false; this.onSoundUnlock.dispatch(key); } @@ -21964,7 +21693,8 @@ Phaser.Cache.prototype = { updateSound: function (key, property, value) { - if (this._sounds[key]) { + if (this._sounds[key]) + { this._sounds[key][property] = value; } @@ -22005,13 +21735,30 @@ Phaser.Cache.prototype = { */ getCanvas: function (key) { - if (this._canvases[key]) { + if (this._canvases[key]) + { return this._canvases[key].canvas; } return null; }, + /** + * Checks if an image key exists. + * @param key Asset key of the image you want. + * @return {boolean} True if the key exists, otherwise false. + */ + checkImageKey: function (key) { + + if (this._images[key]) + { + return true; + } + + return false; + + }, + /** * Get image data by key. * @param key Asset key of the image you want. @@ -22019,13 +21766,29 @@ Phaser.Cache.prototype = { */ getImage: function (key) { - if (this._images[key]) { + if (this._images[key]) + { return this._images[key].data; } return null; }, + /** + * Get tilemap data by key. + * @param key Asset key of the tilemap you want. + * @return {object} The tilemap data. The tileset image is in the data property, the map data in mapData. + */ + getTilemap: function (key) { + + if (this._tilemaps[key]) + { + return this._tilemaps[key]; + } + + return null; + }, + /** * Get frame data by key. * @param key Asset key of the frame data you want. @@ -22033,13 +21796,44 @@ Phaser.Cache.prototype = { */ getFrameData: function (key) { - if (this._images[key] && this._images[key].frameData) { + if (this._images[key] && this._images[key].frameData) + { return this._images[key].frameData; } return null; }, + /** + * Get a single frame out of a frameData set by key. + * @param key Asset key of the frame data you want. + * @return {object} The frame data you want. + */ + getFrameByIndex: function (key, frame) { + + if (this._images[key] && this._images[key].frameData) + { + return this._images[key].frameData.getFrame(frame); + } + + return null; + }, + + /** + * Get a single frame out of a frameData set by key. + * @param key Asset key of the frame data you want. + * @return {object} The frame data you want. + */ + getFrameByName: function (key, frame) { + + if (this._images[key] && this._images[key].frameData) + { + return this._images[key].frameData.getFrameByName(frame); + } + + return null; + }, + /** * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. * @param key Asset key of the frame data you want. @@ -22055,6 +21849,37 @@ Phaser.Cache.prototype = { return null; }, + /** + * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. + * @param key Asset key of the frame data you want. + * @return {object} The frame data you want. + */ + getTextureFrame: function (key) { + + if (this._textures[key]) + { + return this._textures[key].frame; + } + + return null; + }, + + /** + * Get a RenderTexture by key. + * @param key Asset key of the RenderTexture you want. + * @return {object} The RenderTexture you want. + */ + getTexture: function (key) { + + if (this._textures[key]) + { + return this._textures[key]; + } + + return null; + + }, + /** * Get sound by key. * @param key Asset key of the sound you want. @@ -22062,7 +21887,8 @@ Phaser.Cache.prototype = { */ getSound: function (key) { - if (this._sounds[key]) { + if (this._sounds[key]) + { return this._sounds[key]; } @@ -22077,7 +21903,8 @@ Phaser.Cache.prototype = { */ getSoundData: function (key) { - if (this._sounds[key]) { + if (this._sounds[key]) + { return this._sounds[key].data; } @@ -22092,7 +21919,8 @@ Phaser.Cache.prototype = { */ isSoundDecoded: function (key) { - if (this._sounds[key]) { + if (this._sounds[key]) + { return this._sounds[key].decoded; } @@ -22104,7 +21932,9 @@ Phaser.Cache.prototype = { * @return {object} The sound data you want. */ isSoundReady: function (key) { - return (this._sounds[key] && this._sounds[key].decoded == true && this._sounds[key].locked == false); + + return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked == false); + }, /** @@ -22114,7 +21944,8 @@ Phaser.Cache.prototype = { */ isSpriteSheet: function (key) { - if (this._images[key]) { + if (this._images[key]) + { return this._images[key].spriteSheet; } @@ -22129,7 +21960,8 @@ Phaser.Cache.prototype = { */ getText: function (key) { - if (this._text[key]) { + if (this._text[key]) + { return this._text[key].data; } @@ -22141,8 +21973,12 @@ Phaser.Cache.prototype = { var output = []; - for (var item in array) { - output.push(item); + for (var item in array) + { + if (item !== '__default') + { + output.push(item); + } } return output; @@ -22194,19 +22030,23 @@ Phaser.Cache.prototype = { */ destroy: function () { - for (var item in this._canvases) { + for (var item in this._canvases) + { delete this._canvases[item['key']]; } - for (var item in this._images) { + for (var item in this._images) + { delete this._images[item['key']]; } - for (var item in this._sounds) { + for (var item in this._sounds) + { delete this._sounds[item['key']]; } - for (var item in this._text) { + for (var item in this._text) + { delete this._text[item['key']]; } } @@ -22221,10 +22061,74 @@ Phaser.Cache.prototype = { */ Phaser.Loader = function (game) { + /** + * Local reference to Game. + */ this.game = game; + /** + * Array stores assets keys. So you can get that asset by its unique key. + */ + this._keys = []; + + /** + * Contains all the assets file infos. + */ + this._fileList = {}; + + /** + * Indicates assets loading progress. (from 0 to 100) + * @type {number} + */ + this._progressChunk = 0; + + /** + * An XMLHttpRequest object used for loading text and audio data + * @type {XMLHttpRequest} + */ this._xhr = new XMLHttpRequest(); + /** + * Length of assets queue. + * @type {number} + */ + this.queueSize = 0; + + /** + * True if the Loader is in the process of loading the queue. + * @type {bool} + */ + this.isLoading = false; + + /** + * True if all assets in the queue have finished loading. + * @type {bool} + */ + this.hasLoaded = false; + + /** + * The Load progress percentage value (from 0 to 100) + * @type {number} + */ + this.progress = 0; + + /** + * The crossOrigin value applied to loaded images + * @type {string} + */ + this.crossOrigin = ''; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * Useful if you need to allow an asset url to be configured outside of the game code. + * MUST have / on the end of it! + * @type {string} + */ + this.baseURL = ''; + + /** + * Event Signals + */ this.onFileComplete = new Phaser.Signal; this.onFileError = new Phaser.Signal; this.onLoadStart = new Phaser.Signal; @@ -22241,79 +22145,6 @@ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2; Phaser.Loader.prototype = { - /** - * Local reference to Game. - */ - game: null, - - /** - * Array stores assets keys. So you can get that asset by its unique key. - */ - _keys: [], - - /** - * Contains all the assets file infos. - */ - _fileList: {}, - - /** - * Indicates assets loading progress. (from 0 to 100) - * @type {number} - */ - _progressChunk: 0, - - /** - * An XMLHttpRequest object used for loading text and audio data - * @type {XMLHttpRequest} - */ - _xhr: null, - - /** - * Length of assets queue. - * @type {number} - */ - queueSize: 0, - - /** - * True if the Loader is in the process of loading the queue. - * @type {bool} - */ - isLoading: false, - - /** - * True if all assets in the queue have finished loading. - * @type {bool} - */ - hasLoaded: false, - - /** - * The Load progress percentage value (from 0 to 100) - * @type {number} - */ - progress: 0, - - /** - * The crossOrigin value applied to loaded images - * @type {string} - */ - crossOrigin: '', - - /** - * If you want to append a URL before the path of any asset you can set this here. - * Useful if you need to allow an asset url to be configured outside of the game code. - * MUST have / on the end of it! - * @type {string} - */ - baseURL: '', - - /** - * Event Signals - */ - onFileComplete: null, - onFileError: null, - onLoadStart: null, - onLoadComplete: null, - /** * Check whether asset exists with a specific key. * @param key {string} Key of the asset you want to check. @@ -22321,9 +22152,12 @@ Phaser.Loader.prototype = { */ checkKeyExists: function (key) { - if (this._fileList[key]) { + if (this._fileList[key]) + { return true; - } else { + } + else + { return false; } @@ -22333,8 +22167,10 @@ Phaser.Loader.prototype = { * Reset loader, this will remove all loaded assets. */ reset: function () { + this.queueSize = 0; this.isLoading = false; + }, /** @@ -22351,12 +22187,12 @@ Phaser.Loader.prototype = { loaded: false }; - if (typeof properties !== "undefined") { - - for (var prop in properties) { + if (typeof properties !== "undefined") + { + for (var prop in properties) + { entry[prop] = properties[prop]; } - } this._fileList[key] = entry; @@ -22377,7 +22213,8 @@ Phaser.Loader.prototype = { if (typeof overwrite === "undefined") { overwrite = false; } - if (overwrite || this.checkKeyExists(key) == false) { + if (overwrite || this.checkKeyExists(key) == false) + { this.addToFileList('image', key, url); } @@ -22435,22 +22272,126 @@ Phaser.Loader.prototype = { }, + /** + * Add a new tilemap loading request. + * @param key {string} Unique asset key of the tilemap data. + * @param tilesetURL {string} The url of the tile set image file. + * @param [mapDataURL] {string} The url of the map data file (csv/json) + * @param [mapData] {object} An optional JSON data object (can be given in place of a URL). + * @param [format] {string} The format of the map data. + */ + tilemap: function (key, tilesetURL, mapDataURL, mapData, format) { + + if (typeof mapDataURL === "undefined") { mapDataURL = null; } + if (typeof mapData === "undefined") { mapData = null; } + if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; } + + if (this.checkKeyExists(key) === false) + { + // A URL to a json/csv file has been given + if (mapDataURL) + { + this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: mapDataURL, format: format }); + } + else + { + switch (format) + { + // A csv string or object has been given + case Phaser.Tilemap.CSV: + break; + + // An xml string or object has been given + case Phaser.Tilemap.JSON: + + if (typeof mapData === 'string') + { + mapData = JSON.parse(mapData); + } + break; + } + + this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: null, mapData: mapData, format: format }); + + } + } + + }, + + /** + * Add a new bitmap font loading request. + * @param key {string} Unique asset key of the bitmap font. + * @param textureURL {string} The url of the font image file. + * @param [xmlURL] {string} The url of the font data file (xml/fnt) + * @param [xmlData] {object} An optional XML data object. + */ + bitmapFont: function (key, textureURL, xmlURL, xmlData) { + + if (typeof xmlURL === "undefined") { xmlURL = null; } + if (typeof xmlData === "undefined") { xmlData = null; } + + if (this.checkKeyExists(key) === false) + { + // A URL to a json/xml file has been given + if (xmlURL) + { + this.addToFileList('bitmapfont', key, textureURL, { xmlURL: xmlURL }); + } + else + { + // An xml string or object has been given + if (typeof xmlData === 'string') + { + var xml; + + try { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(xmlData, "text/xml"); + } + else + { + xml = new ActiveXObject("Microsoft.XMLDOM"); + xml.async = 'false'; + xml.loadXML(xmlData); + } + } + catch (e) + { + xml = undefined; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) + { + throw new Error("Phaser.Loader. Invalid Bitmap Font XML given"); + } + else + { + this.addToFileList('bitmapfont', key, textureURL, { xmlURL: null, xmlData: xml }); + } + } + } + } + + }, + atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { - if (typeof atlasURL === "undefined") { atlasURL = null; } - if (typeof atlasData === "undefined") { atlasData = null; } + this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); + }, atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { - if (typeof atlasURL === "undefined") { atlasURL = null; } - if (typeof atlasData === "undefined") { atlasData = null; } + this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); + }, atlasXML: function (key, textureURL, atlasURL, atlasData) { - if (typeof atlasURL === "undefined") { atlasURL = null; } - if (typeof atlasData === "undefined") { atlasData = null; } + this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + }, /** @@ -22467,20 +22408,22 @@ Phaser.Loader.prototype = { if (typeof atlasData === "undefined") { atlasData = null; } if (typeof format === "undefined") { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; } - if (this.checkKeyExists(key) === false) { - + if (this.checkKeyExists(key) === false) + { // A URL to a json/xml file has been given - if (atlasURL) { + if (atlasURL) + { this.addToFileList('textureatlas', key, textureURL, { atlasURL: atlasURL, format: format }); } else { - switch (format) { - + switch (format) + { // A json string or object has been given case Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY: - if (typeof atlasData === 'string') { + if (typeof atlasData === 'string') + { atlasData = JSON.parse(atlasData); } break; @@ -22488,24 +22431,34 @@ Phaser.Loader.prototype = { // An xml string or object has been given case Phaser.Loader.TEXTURE_ATLAS_XML_STARLING: - if (typeof atlasData === 'string') { + if (typeof atlasData === 'string') + { var xml; + try { - if (window['DOMParser']) { + if (window['DOMParser']) + { var domparser = new DOMParser(); xml = domparser.parseFromString(atlasData, "text/xml"); - } else { + } + else + { xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = 'false'; xml.loadXML(atlasData); } - } catch (e) { + } + catch (e) + { xml = undefined; } - if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) { + if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) + { throw new Error("Phaser.Loader. Invalid Texture Atlas XML given"); - } else { + } + else + { atlasData = xml; } } @@ -22516,7 +22469,6 @@ Phaser.Loader.prototype = { } - } }, @@ -22585,6 +22537,8 @@ Phaser.Loader.prototype = { case 'image': case 'spritesheet': case 'textureatlas': + case 'bitmapfont': + case 'tilemap': file.data = new Image(); file.data.name = file.key; file.data.onload = function () { @@ -22619,7 +22573,7 @@ Phaser.Loader.prototype = { { if (this.game.sound.touchLocked) { - // If audio is locked we can't do this yet, so need to queue this load request somehow. Bum. + // If audio is locked we can't do this yet, so need to queue this load request. Bum. file.data = new Audio(); file.data.name = file.key; file.data.preload = 'auto'; @@ -22640,6 +22594,10 @@ Phaser.Loader.prototype = { } } } + else + { + this.fileError(file.key); + } break; @@ -22716,14 +22674,50 @@ Phaser.Loader.prototype = { switch (file.type) { case 'image': + this.game.cache.addImage(file.key, file.url, file.data); break; case 'spritesheet': + this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; + case 'tilemap': + + if (file.mapDataURL == null) + { + this.game.cache.addTilemap(file.key, file.url, file.data, file.mapData, file.format); + } + else + { + // Load the JSON or CSV before carrying on with the next file + loadNext = false; + this._xhr.open("GET", this.baseURL + file.mapDataURL, true); + this._xhr.responseType = "text"; + + if (file.format == Phaser.Tilemap.JSON) + { + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + } + else if (file.format == Phaser.Tilemap.CSV) + { + this._xhr.onload = function () { + return _this.csvLoadComplete(file.key); + }; + } + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + } + break; + case 'textureatlas': + if (file.atlasURL == null) { this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); @@ -22755,6 +22749,30 @@ Phaser.Loader.prototype = { } break; + case 'bitmapfont': + + if (file.xmlURL == null) + { + this.game.cache.addBitmapFont(file.key, file.url, file.data, file.xmlData); + } + else + { + // Load the XML before carrying on with the next file + loadNext = false; + this._xhr.open("GET", this.baseURL + file.xmlURL, true); + this._xhr.responseType = "text"; + + this._xhr.onload = function () { + return _this.xmlLoadComplete(file.key); + }; + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + } + break; + case 'audio': if (this.game.sound.usingWebAudio) @@ -22807,7 +22825,29 @@ Phaser.Loader.prototype = { var data = JSON.parse(this._xhr.response); var file = this._fileList[key]; - this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + if (file.type == 'tilemap') + { + this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); + } + else + { + this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + } + + this.nextFile(key, true); + + }, + + /** + * Successfully loaded a CSV file. + * @param key {string} Key of the loaded CSV file. + */ + csvLoadComplete: function (key) { + + var data = this._xhr.response; + var file = this._fileList[key]; + + this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); this.nextFile(key, true); @@ -22823,7 +22863,7 @@ Phaser.Loader.prototype = { file.error = true; - throw new Error("Phaser.Loader dataLoadError: " + key); + console.warn("Phaser.Loader dataLoadError: " + key); this.nextFile(key, true); @@ -22831,7 +22871,7 @@ Phaser.Loader.prototype = { xmlLoadComplete: function (key) { - var atlasData = this._xhr.response; + var data = this._xhr.response; var xml; try @@ -22839,13 +22879,13 @@ Phaser.Loader.prototype = { if (window['DOMParser']) { var domparser = new DOMParser(); - xml = domparser.parseFromString(atlasData, "text/xml"); + xml = domparser.parseFromString(data, "text/xml"); } else { xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = 'false'; - xml.loadXML(atlasData); + xml.loadXML(data); } } catch (e) @@ -22859,7 +22899,15 @@ Phaser.Loader.prototype = { } var file = this._fileList[key]; - this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + + if (file.type == 'bitmapfont') + { + this.game.cache.addBitmapFont(file.key, file.url, file.data, xml); + } + else if (file.type == 'textureatlas') + { + this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + } this.nextFile(key, true); @@ -22897,6 +22945,77 @@ Phaser.Loader.prototype = { } +}; +Phaser.Loader.Parser = { + + /** + * Parse frame data from an XML file. + * @param xml {object} XML data you want to parse. + * @return {FrameData} Generated FrameData object. + */ + bitmapFont: function (game, xml, cacheKey) { + + // Malformed? + if (!xml.getElementsByTagName('font')) + { + console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag"); + return; + } + + var texture = PIXI.TextureCache[cacheKey]; + + var data = {}; + var info = xml.getElementsByTagName("info")[0]; + var common = xml.getElementsByTagName("common")[0]; + data.font = info.attributes.getNamedItem("face").nodeValue; + data.size = parseInt(info.attributes.getNamedItem("size").nodeValue, 10); + data.lineHeight = parseInt(common.attributes.getNamedItem("lineHeight").nodeValue, 10); + data.chars = {}; + + //parse letters + var letters = xml.getElementsByTagName("char"); + + for (var i = 0; i < letters.length; i++) + { + var charCode = parseInt(letters[i].attributes.getNamedItem("id").nodeValue, 10); + + var textureRect = { + x: parseInt(letters[i].attributes.getNamedItem("x").nodeValue, 10), + y: parseInt(letters[i].attributes.getNamedItem("y").nodeValue, 10), + width: parseInt(letters[i].attributes.getNamedItem("width").nodeValue, 10), + height: parseInt(letters[i].attributes.getNamedItem("height").nodeValue, 10) + }; + + // Note: This means you can only have 1 BitmapFont loaded at once! + // Need to replace this with our own handler soon. + PIXI.TextureCache[charCode] = new PIXI.Texture(texture, textureRect); + + data.chars[charCode] = { + xOffset: parseInt(letters[i].attributes.getNamedItem("xoffset").nodeValue, 10), + yOffset: parseInt(letters[i].attributes.getNamedItem("yoffset").nodeValue, 10), + xAdvance: parseInt(letters[i].attributes.getNamedItem("xadvance").nodeValue, 10), + kerning: {}, + texture:new PIXI.Texture(texture, textureRect) + + }; + } + + //parse kernings + var kernings = xml.getElementsByTagName("kerning"); + + for (i = 0; i < kernings.length; i++) + { + var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10); + var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10); + var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10); + + data.chars[second].kerning[first] = amount; + } + + PIXI.BitmapText.fonts[data.font] = data; + + } + }; Phaser.Sound = function (game, key, volume, loop) { @@ -22904,9 +23023,35 @@ Phaser.Sound = function (game, key, volume, loop) { loop = loop || false; this.game = game; + this.name = ''; this.key = key; - this._volume = volume; this.loop = loop; + this._volume = volume; + this.markers = {}; + + /** + * Reference to AudioContext instance. + */ + this.context = null; + + /** + * Decoded data buffer / Audio tag. + */ + this._buffer = null; + + this._muted = false; + + this.autoplay = false; + this.totalDuration = 0; + this.startTime = 0; + this.currentTime = 0; + this.duration = 0; + this.stopTime = 0; + this.paused = false; + this.isPlaying = false; + this.currentMarker = ''; + this.pendingPlayback = false; + this.override = false; this.usingWebAudio = this.game.sound.usingWebAudio; this.usingAudioTag = this.game.sound.usingAudioTag; @@ -22930,10 +23075,15 @@ Phaser.Sound = function (game, key, volume, loop) { } else { - if (this.game.cache.getSound(key) && this.game.cache.getSound(key).locked == false) + if (this.game.cache.getSound(key) && this.game.cache.isSoundReady(key)) { this._sound = this.game.cache.getSoundData(key); - this.totalDuration = this._sound.duration; + this.totalDuration = 0; + + if (this._sound.duration) + { + this.totalDuration = this._sound.duration; + } } else { @@ -22954,55 +23104,13 @@ Phaser.Sound = function (game, key, volume, loop) { Phaser.Sound.prototype = { - game: null, - - /** - * Reference to AudioContext instance. - */ - context: null, - - /** - * Decoded data buffer / Audio tag. - */ - _buffer: null, - - _muted: false, - - key: '', - name: '', - markers: {}, - - usingWebAudio: false, - usingAudioTag: false, - autoplay: false, - totalDuration: 0, - startTime: 0, - currentTime: 0, - duration: 0, - stopTime: 0, - paused: false, - loop: false, - isPlaying: false, - currentMarker: '', - pendingPlayback: false, - override: false, - - onDecoded: null, - onPlay: null, - onPause: null, - onResume: null, - onLoop: null, - onStop: null, - onMute: null, - onMarkerComplete: null, - soundHasUnlocked: function (key) { if (key == this.key) { this._sound = this.game.cache.getSoundData(this.key); this.totalDuration = this._sound.duration; - console.log('sound has unlocked', this._sound); + console.log('sound has unlocked' + this._sound); } }, @@ -23101,7 +23209,7 @@ Phaser.Sound.prototype = { loop = loop || false; forceRestart = forceRestart || false; - console.log('play', marker, 'current is', this.currentMarker); + // console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); if (this.isPlaying == true && forceRestart == false && this.override == false) { @@ -23111,7 +23219,7 @@ Phaser.Sound.prototype = { if (this.isPlaying && this.override) { - //console.log('asked to play', marker, 'but already playing', this.currentMarker); + // console.log('asked to play ' + marker + ' but already playing ' + this.currentMarker); if (this.usingWebAudio) { @@ -23140,7 +23248,7 @@ Phaser.Sound.prototype = { this.loop = this.markers[marker].loop; this.duration = this.markers[marker].duration * 1000; - //console.log('marker info loaded', this.loop, this.duration); + // console.log('marker info loaded', this.loop, this.duration); this._tempMarker = marker; this._tempPosition = this.position; this._tempVolume = this.volume; @@ -23201,8 +23309,6 @@ Phaser.Sound.prototype = { this.currentTime = 0; this.stopTime = this.startTime + this.duration; this.onPlay.dispatch(this); - - //console.log('playing, start', this.startTime, 'stop'); } else { @@ -23216,24 +23322,28 @@ Phaser.Sound.prototype = { } else { - //console.log('Sound play Audio'); + // console.log('Sound play Audio'); if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked) { - //console.log('tried playing locked sound, pending set, reload started'); + // console.log('tried playing locked sound, pending set, reload started'); this.game.cache.reloadSound(this.key); this.pendingPlayback = true; } else { - //console.log('sound not locked, state?', this._sound.readyState); + // console.log('sound not locked, state?', this._sound.readyState); if (this._sound && this._sound.readyState == 4) { + this._sound.play(); + // This doesn't become available until you call play(), wonderful ... + this.totalDuration = this._sound.duration; + if (this.duration == 0) { this.duration = this.totalDuration * 1000; } - //console.log('playing', this._sound); + // console.log('playing', this._sound); this._sound.currentTime = this.position; this._sound.muted = this._muted; @@ -23246,7 +23356,6 @@ Phaser.Sound.prototype = { this._sound.volume = this._volume; } - this._sound.play(); this.isPlaying = true; this.startTime = this.game.time.now; this.currentTime = 0; @@ -23330,7 +23439,7 @@ Phaser.Sound.prototype = { this._sound.stop(0); } } - else if(this.usingAudioTag) + else if (this.usingAudioTag) { this._sound.pause(); this._sound.currentTime = 0; @@ -23351,20 +23460,16 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoding", { get: function () { return this.game.cache.getSound(this.key).isDecoding; - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Sound.prototype, "isDecoded", { get: function () { return this.game.cache.isSoundDecoded(this.key); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Sound.prototype, "mute", { @@ -23411,10 +23516,8 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", { this.onMute.dispatch(this); - }, + } - enumerable: true, - configurable: true }); Object.defineProperty(Phaser.Sound.prototype, "volume", { @@ -23425,20 +23528,22 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", { set: function (value) { - this._volume = value; - if (this.usingWebAudio) { + this._volume = value; this.gainNode.gain.value = value; } - else if(this.usingAudioTag && this._sound) + else if (this.usingAudioTag && this._sound) { - this._sound.volume = value; + // Causes an Index size error in Firefox if you don't clamp the value + if (value >= 0 && value <= 1) + { + this._volume = value; + this._sound.volume = value; + } } - }, + } - enumerable: true, - configurable: true }); /** @@ -23451,100 +23556,102 @@ Phaser.SoundManager = function (game) { this.onSoundDecode = new Phaser.Signal; - if (this.game.device.iOS && this.game.device.webAudio == false) - { - this.channels = 1; - } + this._muted = false; + this._unlockSource = null; + this._volume = 1; + this._muted = false; + this._sounds = []; - if (game.device.iOS || (window['PhaserGlobal'] && window['PhaserGlobal'].fakeiOSTouchLock)) - { - this.game.input.touch.callbackContext = this; - this.game.input.touch.touchStartCallback = this.unlock; - this.game.input.mouse.callbackContext = this; - this.game.input.mouse.mouseDownCallback = this.unlock; - this.touchLocked = true; - } - else - { - // What about iOS5? - this.touchLocked = false; - } + this.context = null; + this.usingWebAudio = true; + this.usingAudioTag = false; + this.noAudio = false; - if (window['PhaserGlobal']) - { - // Check to see if all audio playback is disabled (i.e. handled by a 3rd party class) - if (window['PhaserGlobal'].disableAudio == true) - { - this.usingWebAudio = false; - this.noAudio = true; - return; - } + this.touchLocked = false; - // Check if the Web Audio API is disabled (for testing Audio Tag playback during development) - if (window['PhaserGlobal'].disableWebAudio == true) - { - this.usingWebAudio = false; - this.usingAudioTag = true; - this.noAudio = false; - return; - } - } - - if (!!window['AudioContext']) - { - this.context = new window['AudioContext'](); - } - else if(!!window['webkitAudioContext']) - { - this.context = new window['webkitAudioContext'](); - } - else if(!!window['Audio']) - { - this.usingWebAudio = false; - this.usingAudioTag = true; - } - else - { - this.usingWebAudio = false; - this.noAudio = true; - } - - if (this.context !== null) - { - if (typeof this.context.createGain === 'undefined') - { - this.masterGain = this.context.createGainNode(); - } - else - { - this.masterGain = this.context.createGain(); - } - - this.masterGain.gain.value = 1; - this.masterGain.connect(this.context.destination); - } + this.channels = 32; }; Phaser.SoundManager.prototype = { - game: null, + boot: function () { - _muted: false, - _unlockSource: null, - _volume: 1, - _muted: false, - _sounds: [], + if (this.game.device.iOS && this.game.device.webAudio == false) + { + this.channels = 1; + } - context: null, - usingWebAudio: true, - usingAudioTag: false, - noAudio: false, + if (this.game.device.iOS || (window['PhaserGlobal'] && window['PhaserGlobal'].fakeiOSTouchLock)) + { + this.game.input.touch.callbackContext = this; + this.game.input.touch.touchStartCallback = this.unlock; + this.game.input.mouse.callbackContext = this; + this.game.input.mouse.mouseDownCallback = this.unlock; + this.touchLocked = true; + } + else + { + // What about iOS5? + this.touchLocked = false; + } - touchLocked: false, - onSoundDecode: null, + if (window['PhaserGlobal']) + { + // Check to see if all audio playback is disabled (i.e. handled by a 3rd party class) + if (window['PhaserGlobal'].disableAudio == true) + { + this.usingWebAudio = false; + this.noAudio = true; + return; + } - channels: 32, + // Check if the Web Audio API is disabled (for testing Audio Tag playback during development) + if (window['PhaserGlobal'].disableWebAudio == true) + { + this.usingWebAudio = false; + this.usingAudioTag = true; + this.noAudio = false; + return; + } + } + + if (!!window['AudioContext']) + { + this.context = new window['AudioContext'](); + } + else if (!!window['webkitAudioContext']) + { + this.context = new window['webkitAudioContext'](); + } + else if (!!window['Audio']) + { + this.usingWebAudio = false; + this.usingAudioTag = true; + } + else + { + this.usingWebAudio = false; + this.noAudio = true; + } + + if (this.context !== null) + { + if (typeof this.context.createGain === 'undefined') + { + this.masterGain = this.context.createGainNode(); + } + else + { + this.masterGain = this.context.createGain(); + } + + this.masterGain.gain.value = 1; + this.masterGain.connect(this.context.destination); + } + + + }, unlock: function () { @@ -23553,18 +23660,8 @@ Phaser.SoundManager.prototype = { return; } - console.log('SoundManager touch unlocked'); - - if (this.game.device.webAudio && (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == false)) - { - // Create empty buffer and play it - var buffer = this.context.createBuffer(1, 1, 22050); - this._unlockSource = this.context.createBufferSource(); - this._unlockSource.buffer = buffer; - this._unlockSource.connect(this.context.destination); - this._unlockSource.noteOn(0); - } - else + // Global override (mostly for Audio Tag testing) + if (this.game.device.webAudio == false || (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == true)) { // Create an Audio tag? this.touchLocked = false; @@ -23574,6 +23671,15 @@ Phaser.SoundManager.prototype = { this.game.input.mouse.callbackContext = null; this.game.input.mouse.mouseDownCallback = null; } + else + { + // Create empty buffer and play it + var buffer = this.context.createBuffer(1, 1, 22050); + this._unlockSource = this.context.createBufferSource(); + this._unlockSource.buffer = buffer; + this._unlockSource.connect(this.context.destination); + this._unlockSource.noteOn(0); + } }, @@ -23788,9 +23894,8 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { } } - }, - enumerable: true, - configurable: true + } + }); /** @@ -23800,10 +23905,6 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { * @module Phaser */ -Phaser.Utils = { - // Until we have a proper entry-point -} - /** * A collection of methods for displaying debug information about game objects. * @@ -23814,17 +23915,17 @@ Phaser.Utils.Debug = function (game) { this.game = game; this.context = game.context; + this.font = '14px Courier'; + this.lineHeight = 16; + this.renderShadow = true; + this.currentX = 0; + this.currentY = 0; + this.currentAlpha = 1; + }; Phaser.Utils.Debug.prototype = { - font: '14px Courier', - lineHeight: 16, - renderShadow: true, - currentX: 0, - currentY: 0, - currentAlpha: 1, - context: null, /** * Internal method that resets the debug output values. @@ -23995,7 +24096,8 @@ Phaser.Utils.Debug.prototype = { color = color || 'rgb(255,255,255)'; this.start(x, y, color); - this.line('Sound: ' + sound.key + ' Locked: ' + sound.game.sound.touchLocked + ' Pending Playback: ' + sound.pendingPlayback); + this.line('Sound: ' + sound.key + ' Locked: ' + sound.game.sound.touchLocked); + this.line('Is Ready?: ' + this.game.cache.isSoundReady(sound.key) + ' Pending Playback: ' + sound.pendingPlayback); this.line('Decoded: ' + sound.isDecoded + ' Decoding: ' + sound.isDecoding); this.line('Total Duration: ' + sound.totalDuration + ' Playing: ' + sound.isPlaying); this.line('Time: ' + sound.currentTime); @@ -24345,6 +24447,298 @@ Phaser.Utils.Debug.prototype = { }; +/** +* A collection of methods useful for manipulating and comparing colors. +* +* @class Color +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @module Phaser +*/ + +Phaser.Color = { + + /** + * Given an alpha and 3 color values this will return an integer representation of it + * + * @method getColor32 + * @param {Number} alpha The Alpha value (between 0 and 255) + * @param {Number} red The Red channel value (between 0 and 255) + * @param {Number} green The Green channel value (between 0 and 255) + * @param {Number} blue The Blue channel value (between 0 and 255) + * @return {Number} A native color value integer (format: 0xAARRGGBB) + */ + getColor32: function (alpha, red, green, blue) { + return alpha << 24 | red << 16 | green << 8 | blue; + }, + + /** + * Given 3 color values this will return an integer representation of it. + * + * @method getColor + * @param {Number} red The Red channel value (between 0 and 255) + * @param {Number} green The Green channel value (between 0 and 255) + * @param {Number} blue The Blue channel value (between 0 and 255) + * @return {Number} A native color value integer (format: 0xRRGGBB) + */ + getColor: function (red, green, blue) { + return red << 16 | green << 8 | blue; + }, + + /** + * Converts the given hex string into an object containing the RGB values. + * + * @method hexToRGB + * @param {String} The string hex color to convert. + * @return {Object} An object with 3 properties: r,g and b. + */ + hexToRGB: function (h) { + + var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h; + var red = parseInt(hex16.substring(0, 2), 16); + var green = parseInt(hex16.substring(2, 4), 16); + var blue = parseInt(hex16.substring(4, 6), 16); + + return red << 16 | green << 8 | blue; + + }, + + /** + * Returns a string containing handy information about the given color including string hex value, + * RGB format information and HSL information. Each section starts on a newline, 3 lines in total. + * + * @method getColorInfo + * @param {Number} color A color value in the format 0xAARRGGBB + * @return {String} string containing the 3 lines of information + */ + getColorInfo: function (color) { + var argb = Phaser.Color.getRGB(color); + var hsl = Phaser.Color.RGBtoHSV(color); + // Hex format + var result = Phaser.Color.RGBtoHexstring(color) + "\n"; + // RGB format + result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n"; + // HSL info + result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness); + return result; + }, + + /** + * Return a string representation of the color in the format 0xAARRGGBB + * + * @method RGBtoHexstring + * @param {Number} color The color to get the string representation for + * @return {String A string of length 10 characters in the format 0xAARRGGBB + */ + RGBtoHexstring: function (color) { + var argb = Phaser.Color.getRGB(color); + return "0x" + Phaser.Color.colorToHexstring(argb.alpha) + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue); + }, + + /** + * Return a string representation of the color in the format #RRGGBB + * + * @method RGBtoWebstring + * @param {Number} color The color to get the string representation for + * @return {String} A string of length 10 characters in the format 0xAARRGGBB + */ + RGBtoWebstring: function (color) { + var argb = Phaser.Color.getRGB(color); + return "#" + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue); + }, + + /** + * Return a string containing a hex representation of the given color + * + * @method colorToHexstring + * @param {Number} color The color channel to get the hex value for, must be a value between 0 and 255) + * @return {String} A string of length 2 characters, i.e. 255 = FF, 0 = 00 + */ + colorToHexstring: function (color) { + var digits = "0123456789ABCDEF"; + var lsd = color % 16; + var msd = (color - lsd) / 16; + var hexified = digits.charAt(msd) + digits.charAt(lsd); + return hexified; + }, + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * @method interpolateColor + * @param {Number} color1 + * @param {Number} color2 + * @param {Number} steps + * @param {Number} currentStep + * @param {Number} alpha + * @return {Number} The interpolated color value. + */ + interpolateColor: function (color1, color2, steps, currentStep, alpha) { + if (typeof alpha === "undefined") { alpha = 255; } + var src1 = Phaser.Color.getRGB(color1); + var src2 = Phaser.Color.getRGB(color2); + var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red; + var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green; + var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue; + return Phaser.Color.getColor32(alpha, r, g, b); + }, + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * @method interpolateColorWithRGB + * @param {Number} color + * @param {Number} r + * @param {Number} g + * @param {Number} b + * @param {Number} steps + * @param {Number} currentStep + * @return {Number} The interpolated color value. + */ + interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) { + var src = Phaser.Color.getRGB(color); + var or = (((r - src.red) * currentStep) / steps) + src.red; + var og = (((g - src.green) * currentStep) / steps) + src.green; + var ob = (((b - src.blue) * currentStep) / steps) + src.blue; + return Phaser.Color.getColor(or, og, ob); + }, + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * @method interpolateRGB + * @param {Number} r1 + * @param {Number} g1 + * @param {Number} b1 + * @param {Number} r2 + * @param {Number} g2 + * @param {Number} b2 + * @param {Number} steps + * @param {Number} currentStep + * @return {Number} The interpolated color value. + */ + interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) { + var r = (((r2 - r1) * currentStep) / steps) + r1; + var g = (((g2 - g1) * currentStep) / steps) + g1; + var b = (((b2 - b1) * currentStep) / steps) + b1; + return Phaser.Color.getColor(r, g, b); + }, + + /** + * Returns a random color value between black and white + *

Set the min value to start each channel from the given offset.

+ *

Set the max value to restrict the maximum color used per channel

+ * + * @method getRandomColor + * @param {Number} min The lowest value to use for the color + * @param {Number} max The highest value to use for the color + * @param {Number} alpha The alpha value of the returning color (default 255 = fully opaque) + * @return {Number} 32-bit color value with alpha + */ + getRandomColor: function (min, max, alpha) { + if (typeof min === "undefined") { min = 0; } + if (typeof max === "undefined") { max = 255; } + if (typeof alpha === "undefined") { alpha = 255; } + // Sanity checks + if (max > 255) { + return Phaser.Color.getColor(255, 255, 255); + } + if (min > max) { + return Phaser.Color.getColor(255, 255, 255); + } + var red = min + Math.round(Math.random() * (max - min)); + var green = min + Math.round(Math.random() * (max - min)); + var blue = min + Math.round(Math.random() * (max - min)); + return Phaser.Color.getColor32(alpha, red, green, blue); + }, + + /** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue + * + *

Alpha will only be set if it exist in the given color (0xAARRGGBB)

+ * + * @method getRGB + * @param {Number} color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB) + * @return {Object} An Object with properties: alpha, red, green, blue + */ + getRGB: function (color) { + return { + alpha: color >>> 24, + red: color >> 16 & 0xFF, + green: color >> 8 & 0xFF, + blue: color & 0xFF + }; + }, + + /** + * Returns a CSS friendly string value from the given color. + * @method getWebRGB + * @param {Number} color + * @return {String} A string in the format: 'rgba(r,g,b,a)' + */ + getWebRGB: function (color) { + var alpha = (color >>> 24) / 255; + var red = color >> 16 & 0xFF; + var green = color >> 8 & 0xFF; + var blue = color & 0xFF; + return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')'; + }, + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255 + * + * @method getAlpha + * @param {Number} color In the format 0xAARRGGBB + * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)) + */ + getAlpha: function (color) { + return color >>> 24; + }, + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1 + * + * @method getAlphaFloat + * @param {Number} color In the format 0xAARRGGBB + * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)) + */ + getAlphaFloat: function (color) { + return (color >>> 24) / 255; + }, + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255 + * + * @method getRed + * @param {Number} color In the format 0xAARRGGBB + * @return {Number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red) + */ + getRed: function (color) { + return color >> 16 & 0xFF; + }, + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255 + * + * @method getGreen + * @param {Number} color In the format 0xAARRGGBB + * @return {Number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green) + */ + getGreen: function (color) { + return color >> 8 & 0xFF; + }, + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255 + * + * @method getBlue + * @param {Number} color In the format 0xAARRGGBB + * @return {Number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue) + */ + getBlue: function (color) { + return color & 0xFF; + } + +}; + Phaser.Physics = {}; Phaser.Physics.Arcade = function (game) { @@ -24771,6 +25165,22 @@ Phaser.Physics.Arcade.prototype = { } }, + /** + * The core Collision separation function used by Collision.overlap. + * @param object1 The first GameObject to separate + * @param object2 The second GameObject to separate + * @returns {boolean} Returns true if the objects were separated, otherwise false. + */ + // separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) { + + // return this.separateX(object1, object2) || this.separateY(object1, object2) + + // }, + + + + + /** * Given the angle and speed calculate the velocity and return it as a Point * @@ -25262,8 +25672,11 @@ Phaser.Physics.Arcade.Body.prototype = { postUpdate: function () { - this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width); - this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height); + // this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width); + // this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height); + + this.sprite.x = (this.x - this.offset.x + (this.sprite.anchor.x * this.width)) - (this.game.world.camera.x * this.sprite.scrollFactor.x); + this.sprite.y = (this.y - this.offset.y + (this.sprite.anchor.y * this.height)) - (this.game.world.camera.y * this.sprite.scrollFactor.y); if (this.allowRotation) { @@ -25313,6 +25726,23 @@ Phaser.Physics.Arcade.Body.prototype = { }, + reset: function () { + + this.velocity = new Phaser.Point; + this.acceleration = new Phaser.Point; + this.drag = new Phaser.Point; + this.gravity = new Phaser.Point; + this.bounce = new Phaser.Point; + this.maxVelocity = new Phaser.Point(10000, 10000); + + this.angularVelocity = 0; + this.angularAcceleration = 0; + this.angularDrag = 0; + this.maxAngular = 1000; + this.mass = 1; + + }, + deltaAbsX: function () { return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); }, @@ -25348,14 +25778,18 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { * @param {Number} value **/ set: function (value) { - if(value <= this.y) { + + if (value <= this.y) + { this.height = 0; - } else { + } + else + { this.height = (this.y - value); } - }, - enumerable: true, - configurable: true + + } + }); Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { @@ -25377,13 +25811,1836 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { * @param {Number} value **/ set: function (value) { - if(value <= this.x) { + + if (value <= this.x) + { this.width = 0; - } else { + } + else + { this.width = this.x + value; } - }, - enumerable: true, - configurable: true + + } + }); +Phaser.Particles = function (game) { + + this.emitters = {}; + + this.ID = 0; + +}; + +Phaser.Particles.prototype = { + + emitters: null, + + add: function (emitter) { + + this.emitters[emitter.name] = emitter; + + return emitter; + + }, + + remove: function (emitter) { + + delete this.emitters[emitter.name]; + + }, + + update: function () { + + for (var key in this.emitters) + { + if (this.emitters[key].exists) + { + this.emitters[key].update(); + } + } + + }, + +}; +Phaser.Particles.Arcade = {} +/** +* Phaser - ArcadeEmitter +* +* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for +* continuous effects like rain and fire. All it really does is launch Particle objects out +* at set intervals, and fixes their positions and velocities accorindgly. +*/ + +Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { + + maxParticles = maxParticles || 50; + + Phaser.Group.call(this, game); + + this.name = 'emitter' + this.game.particles.ID++; + + /** + * The X position of the top left corner of the emitter in world space. + */ + this.x = x; + + /** + * The Y position of the top left corner of emitter in world space. + */ + this.y = y; + + /** + * The width of the emitter. Particles can be randomly generated from anywhere within this box. + */ + this.width = 1; + + /** + * The height of the emitter. Particles can be randomly generated from anywhere within this box. + */ + this.height = 1; + + /** + * The minimum possible velocity of a particle. + * The default value is (-100,-100). + */ + this.minParticleSpeed = new Phaser.Point(-100, -100); + + /** + * The maximum possible velocity of a particle. + * The default value is (100,100). + */ + this.maxParticleSpeed = new Phaser.Point(100, 100); + + /** + * The minimum possible scale of a particle. + * The default value is 1. + */ + this.minParticleScale = 1; + + /** + * The maximum possible scale of a particle. + * The default value is 1. + */ + this.maxParticleScale = 1; + + /** + * The minimum possible angular velocity of a particle. The default value is -360. + */ + this.minRotation = -360; + + /** + * The maximum possible angular velocity of a particle. The default value is 360. + */ + this.maxRotation = 360; + + /** + * Sets the gravity.y of each particle to this value on launch. + */ + this.gravity = 2; + + /** + * Set your own particle class type here. + * Default is Particle. + */ + this.particleClass = null; + + /** + * The X and Y drag component of particles launched from the emitter. + */ + this.particleDrag = new Phaser.Point(); + + /** + * How often a particle is emitted in ms (if emitter is started with Explode == false). + */ + this.frequency = 100; + + /** + * The total number of particles in this emitter. + */ + this.maxParticles = maxParticles; + + /** + * How long each particle lives once it is emitted in ms. Default is 2 seconds. + * Set lifespan to 'zero' for particles to live forever. + */ + this.lifespan = 2000; + + /** + * How much each particle should bounce. 1 = full bounce, 0 = no bounce. + */ + this.bounce = 0; + + /** + * Internal helper for deciding how many particles to launch. + */ + this._quantity = 0; + + /** + * Internal helper for deciding when to launch particles or kill them. + */ + this._timer = 0; + + /** + * Internal counter for figuring out how many particles to launch. + */ + this._counter = 0; + + /** + * Internal helper for the style of particle emission (all at once, or one at a time). + */ + this._explode = true; + + /** + * Determines whether the emitter is currently emitting particles. + * It is totally safe to directly toggle this. + */ + this.on = false; + + /** + * Determines whether the emitter is being updated by the core game loop. + */ + this.exists = true; + + /** + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + */ + this.emitX = 0; + this.emitY = 0; + +}; + +Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype); +Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.Emitter; + +/** + * Called automatically by the game loop, decides when to launch particles and when to "die". + */ +Phaser.Particles.Arcade.Emitter.prototype.update = function () { + + if (this.on) + { + if (this._explode) + { + this._counter = 0; + + do + { + this.emitParticle(); + this._counter++; + } + while (this._counter < this._quantity); + + this.on = false; + } + else + { + if (this.game.time.now >= this._timer) + { + this.emitParticle(); + + this._counter++; + + if (this._quantity > 0) + { + if (this._counter >= this._quantity) + { + this.on = false; + } + } + + this._timer = this.game.time.now + this.frequency; + } + } + } + +} + +/** + * This function generates a new array of particle sprites to attach to the emitter. + * + * @param graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet. + * @param quantity {number} The number of particles to generate when using the "create from image" option. + * @param multiple {boolean} Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!). + * @param collide {number} Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box. + * + * @return This Emitter instance (nice for chaining stuff together, if you're into that). + */ +Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide) { + + if (typeof frames == 'undefined') + { + frames = 0; + } + + quantity = quantity || this.maxParticles; + collide = collide || 0; + + var particle; + var i = 0; + var rndKey = keys; + var rndFrame = 0; + + while (i < quantity) + { + if (this.particleClass == null) + { + if (typeof keys == 'object') + { + rndKey = this.game.rnd.pick(keys); + } + + if (typeof frames == 'object') + { + rndFrame = this.game.rnd.pick(frames); + } + + particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame); + } + else + { + // particle = new this.particleClass(this.game); + } + + if (collide > 0) + { + particle.body.allowCollision.any = true; + } + else + { + particle.body.allowCollision.none = true; + } + + particle.exists = false; + particle.visible = false; + + // Center the origin for rotation assistance + particle.anchor.setTo(0.5, 0.5); + + this.add(particle); + + i++; + } + + return this; +} + +/** + * Call this function to turn off all the particles and the emitter. + */ +Phaser.Particles.Arcade.Emitter.prototype.kill = function () { + + this.on = false; + this.alive = false; + this.exists = false; + +} + +/** + * Handy for bringing game objects "back to life". Just sets alive and exists back to true. + * In practice, this is most often called by Object.reset(). + */ +Phaser.Particles.Arcade.Emitter.prototype.revive = function () { + + this.alive = true; + this.exists = true; + +} + +/** + * Call this function to start emitting particles. + * + * @param explode {boolean} Whether the particles should all burst out at once. + * @param lifespan {number} How long each particle lives once emitted. 0 = forever. + * @param frequency {number} Ignored if Explode is set to true. Frequency is how often to emit a particle in ms. + * @param quantity {number} How many particles to launch. 0 = "all of the particles". + */ +Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) { + + if (typeof explode !== 'boolean') + { + explode = true; + } + + lifespan = lifespan || 0; + + // How many ms between emissions? + frequency = frequency || 250; + + // Total number of particles to emit + quantity = quantity || 0; + + this.revive(); + + this.visible = true; + this.on = true; + + this._explode = explode; + this.lifespan = lifespan; + this.frequency = frequency; + this._quantity += quantity; + + this._counter = 0; + this._timer = this.game.time.now + frequency; + +} + +/** + * This function can be used both internally and externally to emit the next particle. + */ +Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { + + var particle = this.getFirstExists(false); + + if (particle == null) + { + return; + } + + if (this.width > 1 || this.height > 1) + { + particle.reset(this.x - this.game.rnd.integerInRange(this.left, this.right), this.y - this.game.rnd.integerInRange(this.top, this.bottom)); + } + else + { + particle.reset(this.emitX, this.emitY); + } + + particle.lifespan = this.lifespan; + + particle.body.bounce.setTo(this.bounce, this.bounce); + + if (this.minParticleSpeed.x != this.maxParticleSpeed.x) + { + particle.body.velocity.x = this.game.rnd.integerInRange(this.minParticleSpeed.x, this.maxParticleSpeed.x); + } + else + { + particle.body.velocity.x = this.minParticleSpeed.x; + } + + if (this.minParticleSpeed.y != this.maxParticleSpeed.y) + { + particle.body.velocity.y = this.game.rnd.integerInRange(this.minParticleSpeed.y, this.maxParticleSpeed.y); + } + else + { + particle.body.velocity.y = this.minParticleSpeed.y; + } + + particle.body.gravity.y = this.gravity; + + if (this.minRotation != this.maxRotation) + { + particle.body.angularVelocity = this.game.rnd.integerInRange(this.minRotation, this.maxRotation); + } + else + { + particle.body.angularVelocity = this.minRotation; + } + + if (this.minParticleScale !== 1 || this.maxParticleScale !== 1) + { + var scale = this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale); + particle.scale.setTo(scale, scale); + } + + particle.body.drag.x = this.particleDrag.x; + particle.body.drag.y = this.particleDrag.y; + +} + +/** + * A more compact way of setting the width and height of the emitter. + * + * @param width {number} The desired width of the emitter (particles are spawned randomly within these dimensions). + * @param height {number} The desired height of the emitter. + */ +Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { + + this.width = width; + this.height = height; + +} + +/** + * A more compact way of setting the X velocity range of the emitter. + * + * @param Min {number} The minimum value for this range. + * @param Max {number} The maximum value for this range. + */ +Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { + + min = min || 0; + max = max || 0; + + this.minParticleSpeed.x = min; + this.maxParticleSpeed.x = max; + +} + +/** + * A more compact way of setting the Y velocity range of the emitter. + * + * @param Min {number} The minimum value for this range. + * @param Max {number} The maximum value for this range. + */ +Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { + + min = min || 0; + max = max || 0; + + this.minParticleSpeed.y = min; + this.maxParticleSpeed.y = max; + +} + +/** + * A more compact way of setting the angular velocity constraints of the emitter. + * + * @param Min {number} The minimum value for this range. + * @param Max {number} The maximum value for this range. + */ +Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { + + min = min || 0; + max = max || 0; + + this.minRotation = min; + this.maxRotation = max; + +} + +/** + * Change the emitter's midpoint to match the midpoint of a Object. + * + * @param Object {object} The Object that you want to sync up with. + */ +Phaser.Particles.Arcade.Emitter.prototype.at = function (object) { + + this.emitX = object.center.x; + this.emitY = object.center.y; + +} + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", { + + /** + * Get the emitter alpha. + */ + get: function () { + return this._container.alpha; + }, + + /** + * Set the emiter alpha value. + */ + set: function (value) { + this._container.alpha = value; + } + +}); + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", { + + /** + * Get the emitter visible state. + */ + get: function () { + return this._container.visible; + }, + + /** + * Set the emitter visible state. + */ + set: function (value) { + this._container.visible = value; + } + +}); + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", { + + get: function () { + return Math.floor(this.x - (this.width / 2)); + } + +}); + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", { + + get: function () { + return Math.floor(this.x + (this.width / 2)); + } + +}); + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", { + + get: function () { + return Math.floor(this.y - (this.height / 2)); + } + +}); + +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { + + get: function () { + return Math.floor(this.y + (this.height / 2)); + } + +}); + +/** +* Phaser - Tilemap +* +* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size. +* Internally it creates a TilemapLayer for each layer in the tilemap. +*/ + +/** +* Tilemap constructor +* Create a new Tilemap. +* +* @param game {Phaser.Game} Current game instance. +* @param key {string} Asset key for this map. +* @param mapData {string} Data of this map. (a big 2d array, normally in csv) +* @param format {number} Format of this map data, available: Tilemap.CSV or Tilemap.JSON. +* @param resizeWorld {bool} Resize the world bound automatically based on this tilemap? +* @param tileWidth {number} Width of tiles in this map (used for CSV maps). +* @param tileHeight {number} Height of tiles in this map (used for CSV maps). +*/ +Phaser.Tilemap = function (game, key, x, y, resizeWorld, tileWidth, tileHeight) { + + if (typeof resizeWorld === "undefined") { resizeWorld = true; } + if (typeof tileWidth === "undefined") { tileWidth = 0; } + if (typeof tileHeight === "undefined") { tileHeight = 0; } + + this.game = game; + this.group = null; + this.name = ''; + this.key = key; + + /** + * Render iteration counter + */ + this.renderOrderID = 0; + + /** + * Tilemap collision callback. + * @type {function} + */ + this.collisionCallback = null; + + this.exists = true; + this.visible = true; + + this.tiles = []; + this.layers = []; + + var map = this.game.cache.getTilemap(key); + + PIXI.DisplayObjectContainer.call(this); + this.position.x = x; + this.position.y = y; + + this.renderer = new Phaser.TilemapRenderer(this.game); + + this.mapFormat = map.format; + + switch (this.mapFormat) + { + case Phaser.Tilemap.CSV: + this.parseCSV(map.mapData, key, tileWidth, tileHeight); + break; + + case Phaser.Tilemap.JSON: + this.parseTiledJSON(map.mapData, key); + break; + } + + if (this.currentLayer && resizeWorld) + { + this.game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true); + } + +}; + +// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) +Phaser.Tilemap.prototype = Object.create(PIXI.DisplayObjectContainer.prototype); +Phaser.Tilemap.prototype.constructor = Phaser.Tilemap; + +Phaser.Tilemap.CSV = 0; +Phaser.Tilemap.JSON = 1; + +/** +* Parset csv map data and generate tiles. +* @param data {string} CSV map data. +* @param key {string} Asset key for tileset image. +* @param tileWidth {number} Width of its tile. +* @param tileHeight {number} Height of its tile. +*/ +Phaser.Tilemap.prototype.parseCSV = function (data, key, tileWidth, tileHeight) { + + var layer = new Phaser.TilemapLayer(this, 0, key, Phaser.Tilemap.CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + + // Trim any rogue whitespace from the data + data = data.trim(); + + var rows = data.split("\n"); + + for (var i = 0; i < rows.length; i++) + { + var column = rows[i].split(","); + + if (column.length > 0) + { + layer.addColumn(column); + } + } + + layer.updateBounds(); + layer.createCanvas(); + + var tileQuantity = layer.parseTileOffsets(); + + this.currentLayer = layer; + this.collisionLayer = layer; + this.layers.push(layer); + + this.generateTiles(tileQuantity); + +}; + +/** +* Parse JSON map data and generate tiles. +* @param data {string} JSON map data. +* @param key {string} Asset key for tileset image. +*/ +Phaser.Tilemap.prototype.parseTiledJSON = function (json, key) { + + for (var i = 0; i < json.layers.length; i++) + { + var layer = new Phaser.TilemapLayer(this, i, key, Phaser.Tilemap.JSON, json.layers[i].name, json.tilewidth, json.tileheight); + + // Check it's a data layer + if (!json.layers[i].data) + { + continue; + } + + layer.alpha = json.layers[i].opacity; + layer.visible = json.layers[i].visible; + layer.tileMargin = json.tilesets[0].margin; + layer.tileSpacing = json.tilesets[0].spacing; + + var c = 0; + var row; + + for (var t = 0; t < json.layers[i].data.length; t++) + { + if (c == 0) + { + row = []; + } + + row.push(json.layers[i].data[t]); + c++; + + if (c == json.layers[i].width) + { + layer.addColumn(row); + c = 0; + } + } + + layer.updateBounds(); + layer.createCanvas(); + + var tileQuantity = layer.parseTileOffsets(); + + this.currentLayer = layer; + this.collisionLayer = layer; + this.layers.push(layer); + } + + this.generateTiles(tileQuantity); + +}; + +/** +* Create tiles of given quantity. +* @param qty {number} Quentity of tiles to be generated. +*/ +Phaser.Tilemap.prototype.generateTiles = function (qty) { + + for (var i = 0; i < qty; i++) + { + this.tiles.push(new Phaser.Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight)); + } + +}; + +/** +* Set callback to be called when this tilemap collides. +* @param context {object} Callback will be called with this context. +* @param callback {function} Callback function. +*/ +Phaser.Tilemap.prototype.setCollisionCallback = function (context, callback) { + + this.collisionCallbackContext = context; + this.collisionCallback = callback; + +}; + +/** +* Set collision configs of tiles in a range index. +* @param start {number} First index of tiles. +* @param end {number} Last index of tiles. +* @param collision {number} Bit field of flags. (see Tile.allowCollision) +* @param resetCollisions {bool} Reset collision flags before set. +* @param separateX {bool} Enable seprate at x-axis. +* @param separateY {bool} Enable seprate at y-axis. +*/ +Phaser.Tilemap.prototype.setCollisionRange = function (start, end, collision, resetCollisions, separateX, separateY) { + + if (typeof collision === "undefined") { collision = Phaser.Types.ANY; } + if (typeof resetCollisions === "undefined") { resetCollisions = false; } + if (typeof separateX === "undefined") { separateX = true; } + if (typeof separateY === "undefined") { separateY = true; } + + for (var i = start; i < end; i++) + { + this.tiles[i].setCollision(collision, resetCollisions, separateX, separateY); + } + +}; + +/** +* Set collision configs of tiles with given index. +* @param values {number[]} Index array which contains all tile indexes. The tiles with those indexes will be setup with rest parameters. +* @param collision {number} Bit field of flags. (see Tile.allowCollision) +* @param resetCollisions {bool} Reset collision flags before set. +* @param separateX {bool} Enable seprate at x-axis. +* @param separateY {bool} Enable seprate at y-axis. +*/ +Phaser.Tilemap.prototype.setCollisionByIndex = function (values, collision, resetCollisions, separateX, separateY) { + + if (typeof collision === "undefined") { collision = Phaser.Types.ANY; } + if (typeof resetCollisions === "undefined") { resetCollisions = false; } + if (typeof separateX === "undefined") { separateX = true; } + if (typeof separateY === "undefined") { separateY = true; } + + for (var i = 0; i < values.length; i++) + { + this.tiles[values[i]].setCollision(collision, resetCollisions, separateX, separateY); + } + +}; + +// Tile Management + +/** +* Get the tile by its index. +* @param value {number} Index of the tile you want to get. +* @return {Tile} The tile with given index. +*/ +Phaser.Tilemap.prototype.getTileByIndex = function (value) { + + if (this.tiles[value]) + { + return this.tiles[value]; + } + + return null; + +}; + +/** +* Get the tile located at specific position and layer. +* @param x {number} X position of this tile located. +* @param y {number} Y position of this tile located. +* @param [layer] {number} layer of this tile located. +* @return {Tile} The tile with specific properties. +*/ +Phaser.Tilemap.prototype.getTile = function (x, y, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } + + return this.tiles[this.layers[layer].getTileIndex(x, y)]; + +}; + +/** +* Get the tile located at specific position (in world coordinate) and layer. (thus you give a position of a point which is within the tile) +* @param x {number} X position of the point in target tile. +* @param x {number} Y position of the point in target tile. +* @param [layer] {number} layer of this tile located. +* @return {Tile} The tile with specific properties. +*/ +Phaser.Tilemap.prototype.getTileFromWorldXY = function (x, y, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } + + return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; + +}; + +/** +* Gets the tile underneath the Input.x/y position +* @param layer The layer to check, defaults to 0 +* @returns {Tile} +*/ +Phaser.Tilemap.prototype.getTileFromInputXY = function (layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } + + return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)]; + +}; + +/** +* Get tiles overlaps the given object. +* @param object {GameObject} Tiles you want to get that overlaps this. +* @return {array} Array with tiles information. (Each contains x, y and the tile.) +*/ +Phaser.Tilemap.prototype.getTileOverlaps = function (object) { + + return this.currentLayer.getTileOverlaps(object); + +}; + +// COLLIDE + +/** +* Check whether this tilemap collides with the given game object or group of objects. +* @param objectOrGroup {function} Target object of group you want to check. +* @param callback {function} This is called if objectOrGroup collides the tilemap. +* @param context {object} Callback will be called with this context. +* @return {bool} Return true if this collides with given object, otherwise return false. +*/ +Phaser.Tilemap.prototype.collide = function (objectOrGroup, callback, context) { + + if (typeof objectOrGroup === "undefined") { objectOrGroup = null; } + if (typeof callback === "undefined") { callback = null; } + if (typeof context === "undefined") { context = null; } + + if (callback !== null && context !== null) + { + this.collisionCallback = callback; + this.collisionCallbackContext = context; + } + + if (objectOrGroup == null) + { + objectOrGroup = this.game.world.group; + } + + // Group? + if (objectOrGroup.isGroup == false) + { + this.collideGameObject(objectOrGroup); + } + else + { + objectOrGroup.forEachAlive(this, this.collideGameObject, true); + } + +}; + +/** +* Check whether this tilemap collides with the given game object. +* @param object {GameObject} Target object you want to check. +* @return {bool} Return true if this collides with given object, otherwise return false. +*/ +Phaser.Tilemap.prototype.collideGameObject = function (object) { + + if (object.body.type == Phaser.Types.BODY_DYNAMIC && object.exists == true && object.body.allowCollisions != Phaser.Types.NONE) + { + this._tempCollisionData = this.collisionLayer.getTileOverlaps(object); + + if (this.collisionCallback !== null && this._tempCollisionData.length > 0) + { + this.collisionCallback.call(this.collisionCallbackContext, object, this._tempCollisionData); + } + + return true; + } + else + { + return false; + } + +}; + +/** +* Set a tile to a specific layer. +* @param x {number} X position of this tile. +* @param y {number} Y position of this tile. +* @param index {number} The index of this tile type in the core map data. +* @param [layer] {number} which layer you want to set the tile to. +*/ +Phaser.Tilemap.prototype.putTile = function (x, y, index, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer.ID; } + + this.layers[layer].putTile(x, y, index); + +}; + +/** +* Calls the renderer +*/ +Phaser.Tilemap.prototype.update = function () { + + this.renderer.render(this); + +}; + +Phaser.Tilemap.prototype.destroy = function () { + + this.tiles.length = 0; + this.layers.length = 0; + +}; + +Object.defineProperty(Phaser.Tilemap.prototype, "widthInPixels", { + + get: function () { + return this.currentLayer.widthInPixels; + } + +}); + +Object.defineProperty(Phaser.Tilemap.prototype, "heightInPixels", { + + get: function () { + return this.currentLayer.heightInPixels; + } + +}); + +/** +* Phaser - TilemapLayer +* +* A Tilemap Layer. Tiled format maps can have multiple overlapping layers. +*/ + +/** +* TilemapLayer constructor +* Create a new TilemapLayer. +* +* @param parent {Tilemap} The tilemap that contains this layer. +* @param id {number} The ID of this layer within the Tilemap array. +* @param key {string} Asset key for this map. +* @param mapFormat {number} Format of this map data, available: Tilemap.CSV or Tilemap.JSON. +* @param name {string} Name of this layer, so you can get this layer by its name. +* @param tileWidth {number} Width of tiles in this map. +* @param tileHeight {number} Height of tiles in this map. +*/ +Phaser.TilemapLayer = function (parent, id, key, mapFormat, name, tileWidth, tileHeight) { + + /** + * Controls whether update() and draw() are automatically called. + * @type {bool} + */ + this.exists = true; + + /** + * Controls whether draw() are automatically called. + * @type {bool} + */ + this.visible = true; + + /** + * How many tiles in each row. + * Read-only variable, do NOT recommend changing after the map is loaded! + * @type {number} + */ + this.widthInTiles = 0; + + /** + * How many tiles in each column. + * Read-only variable, do NOT recommend changing after the map is loaded! + * @type {number} + */ + this.heightInTiles = 0; + + /** + * Read-only variable, do NOT recommend changing after the map is loaded! + * @type {number} + */ + this.widthInPixels = 0; + + /** + * Read-only variable, do NOT recommend changing after the map is loaded! + * @type {number} + */ + this.heightInPixels = 0; + + /** + * Distance between REAL tiles to the tileset texture bound. + * @type {number} + */ + this.tileMargin = 0; + + /** + * Distance between every 2 neighbor tile in the tileset texture. + * @type {number} + */ + this.tileSpacing = 0; + + this.parent = parent; + this.game = parent.game; + this.ID = id; + this.name = name; + this.key = key; + + this.mapFormat = mapFormat; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + + this.boundsInTiles = new Phaser.Rectangle(); + + var map = this.game.cache.getTilemap(key); + + this.tileset = map.data; + + this._alpha = 1; + + this.canvas = null; + this.context = null; + this.baseTexture = null; + this.texture = null; + this.sprite = null; + + this.mapData = []; + this._tempTileBlock = []; + +}; + +Phaser.TilemapLayer.prototype = { + + /** + * Set a specific tile with its x and y in tiles. + * @param x {number} X position of this tile in world coordinates. + * @param y {number} Y position of this tile in world coordinates. + * @param index {number} The index of this tile type in the core map data. + */ + putTileWorldXY: function (x, y, index) { + + x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth; + y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight; + + if (y >= 0 && y < this.mapData.length) + { + if (x >= 0 && x < this.mapData[y].length) + { + this.mapData[y][x] = index; + } + } + + }, + + /** + * Set a specific tile with its x and y in tiles. + * @param x {number} X position of this tile. + * @param y {number} Y position of this tile. + * @param index {number} The index of this tile type in the core map data. + */ + putTile: function (x, y, index) { + + if (y >= 0 && y < this.mapData.length) + { + if (x >= 0 && x < this.mapData[y].length) + { + this.mapData[y][x] = index; + } + } + + }, + + /** + * Swap tiles with 2 kinds of indexes. + * @param tileA {number} First tile index. + * @param tileB {number} Second tile index. + * @param [x] {number} specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param [y] {number} specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param [width] {number} specify a Rectangle of tiles to operate. The width in tiles. + * @param [height] {number} specify a Rectangle of tiles to operate. The height in tiles. + */ + swapTile: function (tileA, tileB, x, y, width, height) { + + x = x || 0; + y = y || 0; + width = width || this.widthInTiles; + height = height || this.heightInTiles; + + this.getTempBlock(x, y, width, height); + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + // First sweep marking tileA as needing a new index + if (this._tempTileBlock[r].tile.index == tileA) + { + this._tempTileBlock[r].newIndex = true; + } + + // In the same pass we can swap tileB to tileA + if (this._tempTileBlock[r].tile.index == tileB) + { + this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileA; + } + } + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + // And now swap our newIndex tiles for tileB + if (this._tempTileBlock[r].newIndex == true) + { + this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB; + } + } + + }, + + /** + * Fill a tile block with a specific tile index. + * @param index {number} Index of tiles you want to fill with. + * @param [x] {number} x position (in tiles) of block's left-top corner. + * @param [y] {number} y position (in tiles) of block's left-top corner. + * @param [width] {number} width of block. + * @param [height] {number} height of block. + */ + fillTile: function (index, x, y, width, height) { + + x = x || 0; + y = y || 0; + width = width || this.widthInTiles; + height = height || this.heightInTiles; + + this.getTempBlock(x, y, width, height); + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = index; + } + + }, + + /** + * Set random tiles to a specific tile block. + * @param tiles {number[]} Tiles with indexes in this array will be randomly set to the given block. + * @param [x] {number} x position (in tiles) of block's left-top corner. + * @param [y] {number} y position (in tiles) of block's left-top corner. + * @param [width] {number} width of block. + * @param [height] {number} height of block. + */ + randomiseTiles: function (tiles, x, y, width, height) { + + x = x || 0; + y = y || 0; + width = width || this.widthInTiles; + height = height || this.heightInTiles; + + this.getTempBlock(x, y, width, height); + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this.game.math.getRandom(tiles); + } + + }, + + /** + * Replace one kind of tiles to another kind. + * @param tileA {number} Index of tiles you want to replace. + * @param tileB {number} Index of tiles you want to set. + * @param [x] {number} x position (in tiles) of block's left-top corner. + * @param [y] {number} y position (in tiles) of block's left-top corner. + * @param [width] {number} width of block. + * @param [height] {number} height of block. + */ + replaceTile: function (tileA, tileB, x, y, width, height) { + + x = x || 0; + y = y || 0; + width = width || this.widthInTiles; + height = height || this.heightInTiles; + + this.getTempBlock(x, y, width, height); + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + if (this._tempTileBlock[r].tile.index == tileA) + { + this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB; + } + } + + }, + + /** + * Get a tile block with specific position and size.(both are in tiles) + * @param x {number} X position of block's left-top corner. + * @param y {number} Y position of block's left-top corner. + * @param width {number} Width of block. + * @param height {number} Height of block. + */ + getTileBlock: function (x, y, width, height) { + + var output = []; + + this.getTempBlock(x, y, width, height); + + for (var r = 0; r < this._tempTileBlock.length; r++) + { + output.push({ + x: this._tempTileBlock[r].x, + y: this._tempTileBlock[r].y, + tile: this._tempTileBlock[r].tile + }); + } + + return output; + + }, + + /** + * Get a tile with specific position (in world coordinate). (thus you give a position of a point which is within the tile) + * @param x {number} X position of the point in target tile. + * @param x {number} Y position of the point in target tile. + */ + getTileFromWorldXY: function (x, y) { + + x = Phaser.Math.snapToFloor(x, this.tileWidth) / this.tileWidth; + y = Phaser.Math.snapToFloor(y, this.tileHeight) / this.tileHeight; + + return this.getTileIndex(x, y); + + }, + + /** + * Get tiles overlaps the given object. + * @param object {GameObject} Tiles you want to get that overlaps this. + * @return {array} Array with tiles informations. (Each contains x, y and the tile.) + */ + getTileOverlaps: function (object) { + + // If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds) + if (object.body.bounds.x < 0 || object.body.bounds.x > this.widthInPixels || object.body.bounds.y < 0 || object.body.bounds.bottom > this.heightInPixels) + { + return; + } + + // What tiles do we need to check against? + this._tempTileX = this.game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth; + this._tempTileY = this.game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight; + this._tempTileW = (this.game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth; + this._tempTileH = (this.game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight; + + // Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock) + this._tempBlockResults = []; + + this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true); + + /* + for (var r = 0; r < this._tempTileBlock.length; r++) + { + if (this.game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true) + { + this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile }); + } + } + */ + + return this._tempBlockResults; + + }, + + /** + * Get a tile block with its position and size. (This method does not return, it'll set result to _tempTileBlock) + * @param x {number} X position of block's left-top corner. + * @param y {number} Y position of block's left-top corner. + * @param width {number} Width of block. + * @param height {number} Height of block. + * @param collisionOnly {bool} Whethor or not ONLY return tiles which will collide (its allowCollisions value is not Collision.NONE). + */ + getTempBlock: function (x, y, width, height, collisionOnly) { + + if (typeof collisionOnly === "undefined") { collisionOnly = false; } + + if (x < 0) + { + x = 0; + } + + if (y < 0) + { + y = 0; + } + + if (width > this.widthInTiles) + { + width = this.widthInTiles; + } + + if (height > this.heightInTiles) + { + height = this.heightInTiles; + } + + this._tempTileBlock = []; + + for (var ty = y; ty < y + height; ty++) + { + for (var tx = x; tx < x + width; tx++) + { + if (collisionOnly) + { + // We only want to consider the tile for checking if you can actually collide with it + if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].allowCollisions != Phaser.Types.NONE) + { + this._tempTileBlock.push({ + x: tx, + y: ty, + tile: this.parent.tiles[this.mapData[ty][tx]] + }); + } + } + else + { + if (this.mapData[ty] && this.mapData[ty][tx]) + { + this._tempTileBlock.push({ + x: tx, + y: ty, + tile: this.parent.tiles[this.mapData[ty][tx]] + }); + } + } + } + } + }, + + /** + * Get the tile index of specific position (in tiles). + * @param x {number} X position of the tile. + * @param y {number} Y position of the tile. + * @return {number} Index of the tile at that position. Return null if there isn't a tile there. + */ + getTileIndex: function (x, y) { + + if (y >= 0 && y < this.mapData.length) + { + if (x >= 0 && x < this.mapData[y].length) + { + return this.mapData[y][x]; + } + } + + return null; + + }, + + /** + * Add a column of tiles into the layer. + * @param column {string[]/number[]} An array of tile indexes to be added. + */ + addColumn: function (column) { + + var data = []; + + for (var c = 0; c < column.length; c++) + { + data[c] = parseInt(column[c]); + } + + if (this.widthInTiles == 0) + { + this.widthInTiles = data.length; + this.widthInPixels = this.widthInTiles * this.tileWidth; + } + + this.mapData.push(data); + + this.heightInTiles++; + this.heightInPixels += this.tileHeight; + + }, + + createCanvas: function () { + + var width = this.game.width; + var height = this.game.height; + + if (this.widthInPixels < width) + { + width = this.widthInPixels; + } + + if (this.heightInPixels < height) + { + height = this.heightInPixels; + } + + this.canvas = Phaser.Canvas.create(width, height); + this.context = this.canvas.getContext('2d'); + + this.baseTexture = new PIXI.BaseTexture(this.canvas); + this.texture = new PIXI.Texture(this.baseTexture); + this.sprite = new PIXI.Sprite(this.texture); + + this.parent.addChild(this.sprite); + + }, + + /** + * Update boundsInTiles with widthInTiles and heightInTiles. + */ + updateBounds: function () { + + this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles); + + }, + + /** + * Parse tile offsets from map data. + * Basically this creates a large array of objects that contain the x/y coordinates to grab each tile from + * for the entire map. Yes we could calculate this at run-time by using the tile index and some math, but we're + * trading a quite small bit of memory here to not have to process that in our main render loop. + * @return {number} length of tileOffsets array. + */ + parseTileOffsets: function () { + + this.tileOffsets = []; + + var i = 0; + + if (this.mapFormat == Phaser.Tilemap.JSON) + { + // For some reason Tiled counts from 1 not 0 + this.tileOffsets[0] = null; + i = 1; + } + + for (var ty = this.tileMargin; ty < this.tileset.height; ty += (this.tileHeight + this.tileSpacing)) + { + for (var tx = this.tileMargin; tx < this.tileset.width; tx += (this.tileWidth + this.tileSpacing)) + { + this.tileOffsets[i] = { + x: tx, + y: ty + }; + i++; + } + } + + return this.tileOffsets.length; + + } + +}; + +Object.defineProperty(Phaser.TilemapLayer.prototype, 'alpha', { + + get: function() { + return this._alpha; + }, + + set: function(value) { + + if (this.sprite) + { + this.sprite.alpha = value; + } + + this._alpha = value; + } + +}); + +/** +* Phaser - Tile +* +* A Tile is a single representation of a tile within a Tilemap +*/ + +/** +* Tile constructor +* Create a new Tile. +* +* @param tilemap {Tilemap} the tilemap this tile belongs to. +* @param index {number} The index of this tile type in the core map data. +* @param width {number} Width of the tile. +* @param height number} Height of the tile. +*/ +Phaser.Tile = function (game, tilemap, index, width, height) { + + /** + * The virtual mass of the tile. + * @type {number} + */ + this.mass = 1.0; + + /** + * Indicating this Tile doesn't collide at all. + * @type {bool} + */ + this.collideNone = true; + + /** + * Indicating collide with any object on the left. + * @type {bool} + */ + this.collideLeft = false; + + /** + * Indicating collide with any object on the right. + * @type {bool} + */ + this.collideRight = false; + + /** + * Indicating collide with any object on the top. + * @type {bool} + */ + this.collideUp = false; + + /** + * Indicating collide with any object on the bottom. + * @type {bool} + */ + this.collideDown = false; + + /** + * Enable separation at x-axis. + * @type {bool} + */ + this.separateX = true; + + /** + * Enable separation at y-axis. + * @type {bool} + */ + this.separateY = true; + + this.game = game; + this.tilemap = tilemap; + this.index = index; + this.width = width; + this.height = height; + +}; + +Phaser.Tile.prototype = { + + /** + * Clean up memory. + */ + destroy: function () { + this.tilemap = null; + }, + + /** + * Set collision configs. + * @param collision {number} Bit field of flags. (see Tile.allowCollision) + * @param resetCollisions {bool} Reset collision flags before set. + * @param separateX {bool} Enable seprate at x-axis. + * @param separateY {bool} Enable seprate at y-axis. + */ + setCollision: function (left, right, up, down, reset, separateX, separateY) { + + if (reset) + { + this.resetCollision(); + } + + this.separateX = separateX; + this.separateY = separateY; + + this.collideNone = true; + this.collideLeft = left; + this.collideRight = right; + this.collideUp = up; + this.collideDown = down; + + if (left || right || up || down) + { + this.collideNone = false; + } + + }, + + /** + * Reset collision status flags. + */ + resetCollision: function () { + + this.collideNone = true; + this.collideLeft = false; + this.collideRight = false; + this.collideUp = false; + this.collideDown = false; + + }, + + /** + * Returns a string representation of this object. + * @method toString + * @return {string} a string representation of the object. + **/ + toString: function () { + + // return "[{Tile (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]"; + return ''; + + } + +}; +Phaser.TilemapRenderer = function (game) { + + this.game = game; + + // Local rendering related temp vars to help avoid gc spikes through constant var creation + this._ga = 1; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this._tx = 0; + this._ty = 0; + this._tl = 0; + this._maxX = 0; + this._maxY = 0; + this._startX = 0; + this._startY = 0; + +}; + +Phaser.TilemapRenderer.prototype = { + + /** + * Render a tilemap to a canvas. + * @param tilemap {Tilemap} The tilemap data to render. + */ + render: function (tilemap) { + + // Loop through the layers + this._tl = tilemap.layers.length; + + for (var i = 0; i < this._tl; i++) + { + if (tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1) + { + continue; + } + + var layer = tilemap.layers[i]; + + // Work out how many tiles we can fit into our canvas and round it up for the edges + this._maxX = this.game.math.ceil(layer.canvas.width / layer.tileWidth) + 1; + this._maxY = this.game.math.ceil(layer.canvas.height / layer.tileHeight) + 1; + + // And now work out where in the tilemap the camera actually is + this._startX = this.game.math.floor(this.game.camera.x / layer.tileWidth); + this._startY = this.game.math.floor(this.game.camera.y / layer.tileHeight); + + // Tilemap bounds check + if (this._startX < 0) + { + this._startX = 0; + } + + if (this._startY < 0) + { + this._startY = 0; + } + + if (this._maxX > layer.widthInTiles) + { + this._maxX = layer.widthInTiles; + } + + if (this._maxY > layer.heightInTiles) + { + this._maxY = layer.heightInTiles; + } + + if (this._startX + this._maxX > layer.widthInTiles) + { + this._startX = layer.widthInTiles - this._maxX; + } + + if (this._startY + this._maxY > layer.heightInTiles) + { + this._startY = layer.heightInTiles - this._maxY; + } + + // Finally get the offset to avoid the blocky movement + this._dx = -(this.game.camera.x - (this._startX * layer.tileWidth)); + this._dy = -(this.game.camera.y - (this._startY * layer.tileHeight)); + + this._tx = this._dx; + this._ty = this._dy; + + // Alpha + if (layer.alpha !== 1) + { + this._ga = layer.context.globalAlpha; + layer.context.globalAlpha = layer.alpha; + } + + layer.context.clearRect(0, 0, layer.canvas.width, layer.canvas.height); + + for (var row = this._startY; row < this._startY + this._maxY; row++) + { + this._columnData = layer.mapData[row]; + + for (var tile = this._startX; tile < this._startX + this._maxX; tile++) + { + if (layer.tileOffsets[this._columnData[tile]]) + { + layer.context.drawImage( + layer.tileset, + layer.tileOffsets[this._columnData[tile]].x, + layer.tileOffsets[this._columnData[tile]].y, + layer.tileWidth, + layer.tileHeight, + this._tx, + this._ty, + layer.tileWidth, + layer.tileHeight + ); + } + + this._tx += layer.tileWidth; + + } + + this._tx = this._dx; + this._ty += layer.tileHeight; + + } + + if (this._ga > -1) + { + layer.context.globalAlpha = this._ga; + } + + // Only needed if running in WebGL, otherwise this array will never get cleared down I don't think! + if (this.game.renderType == Phaser.WEBGL) + { + PIXI.texturesToUpdate.push(layer.baseTexture); + } + + } + + return true; + + } + +}; diff --git a/examples/js.php b/examples/js.php index f2ac05b6..f49d52a6 100644 --- a/examples/js.php +++ b/examples/js.php @@ -1,6 +1,6 @@ ?> @@ -13,12 +13,12 @@ - + - + diff --git a/examples/mapcollide.php b/examples/mapcollide.php new file mode 100644 index 00000000..1d788bdc --- /dev/null +++ b/examples/mapcollide.php @@ -0,0 +1,92 @@ + + + + phaser.js - a new beginning + + + + + + + + \ No newline at end of file diff --git a/examples/mariocombo.php b/examples/mariocombo.php new file mode 100644 index 00000000..551db25b --- /dev/null +++ b/examples/mariocombo.php @@ -0,0 +1,48 @@ + + + + phaser.js - Super Mario Combo + + + + + + + + + \ No newline at end of file diff --git a/examples/mariocombo/assets/mario1.json b/examples/mariocombo/assets/mario1.json new file mode 100644 index 00000000..ffff33bb --- /dev/null +++ b/examples/mariocombo/assets/mario1.json @@ -0,0 +1,39 @@ +{ "height":13, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 1, 1, 1, 1, 6, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 1, 1, 1, 1, 6, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 1, 1, 1, 1, 6, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 1, 1, 1, 1, 6, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 10, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 7, 7, 8, 1, 11, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 7, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14, 1, 6, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 17, 18, 16, 16, 16, 16, 16, 1, 1, 1, 16, 16, 16, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 1, 1, 1, 1, 16, 15, 15, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 22, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 24, 25, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 26, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 1, 1, 1, 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 29, 1, 1, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 1, 1, 31, 31, 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 1, 1, 1, 16, 15, 16, 15, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, 1, 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 15, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 1, 1, 1, 16, 28, 1, 1, 1, 1, 15, 1, 1, 15, 1, 1, 15, 1, 1, 1, 1, 1, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 1, 1, 1, 1, 1, 1, 19, 1, 1, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 1, 1, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 15, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 1, 1, 34, 35, 36, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 32, 33, 1, 1, 1, 1, 1, 1, 38, 39, 1, 1, 37, 1, 1, 1, 1, 1, 1, 40, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 1, 1, 19, 19, 1, 1, 1, 1, 37, 1, 1, 1, 19, 19, 19, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 19, 19, 19, 19, 1, 1, 1, 1, 37, 1, 1, 1, 20, 1, 1, 1, 31, 42, 42, 42, 31, 1, 1, 1, 1, 1, 43, 44, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, 38, 39, 1, 1, 1, 1, 1, 1, 38, 39, 1, 43, 44, 45, 1, 1, 1, 1, 1, 46, 47, 1, 1, 1, 1, 1, 1, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 43, 44, 45, 1, 1, 1, 1, 1, 48, 49, 1, 1, 1, 1, 1, 1, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, 19, 19, 1, 1, 19, 19, 19, 1, 1, 43, 44, 45, 1, 19, 19, 19, 19, 1, 1, 19, 19, 19, 1, 1, 1, 37, 1, 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 32, 33, 1, 19, 19, 19, 19, 19, 19, 19, 19, 1, 1, 1, 43, 44, 45, 1, 1, 20, 1, 1, 1, 35, 35, 50, 35, 35, 1, 1, 37, 1, 43, 44, 51, 52, 45, 1, 1, 1, 1, 1, 1, 53, 54, 54, 54, 55, 43, 44, 45, 1, 56, 57, 1, 53, 54, 55, 1, 1, 38, 39, 1, 1, 1, 1, 1, 1, 1, 1, 38, 39, 58, 59, 54, 54, 55, 1, 38, 39, 43, 44, 60, 61, 62, 57, 63, 64, 1, 38, 39, 53, 54, 54, 54, 55, 43, 44, 45, 1, 1, 1, 1, 53, 54, 55, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 53, 54, 54, 55, 1, 65, 66, 67, 68, 60, 61, 45, 1, 1, 1, 1, 69, 70, 53, 54, 54, 54, 55, 43, 44, 45, 1, 1, 1, 1, 53, 54, 55, 1, 71, 72, 66, 65, 66, 58, 73, 1, 1, 1, 1, 19, 19, 19, 19, 54, 54, 19, 19, 19, 19, 43, 44, 60, 61, 19, 19, 19, 19, 19, 1, 1, 19, 19, 19, 19, 55, 43, 44, 45, 74, 75, 1, 1, 53, 54, 55, 1, 1, 1, 76, 77, 78, 1, 1, 1, 38, 39, 19, 19, 19, 19, 19, 19, 19, 19, 19, 1, 1, 43, 44, 60, 61, 45, 1, 19, 1, 1, 1, 35, 35, 79, 35, 35, 55, 43, 44, 45, 80, 80, 81, 82, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 83, 84, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 85, 86, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 83, 84, 87, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 1, 1, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 1, 1, 1, 80, 80, 80, 80, 80, 80, 88, 89, 90, 80, 80, 80, 80, 80, 80, 80, 91, 92, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 93, 94, 88, 80, 88, 85, 86, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 1, 1, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 95, 96, 97, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80], + "height":13, + "name":"ShoeBox Tile Grab", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":211, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "image":"..\/..\/..\/..\/..\/..\/Art\/Artwork for game inspirations\/Super Mario Level Maps\/NES\/mario-1-1_bank.png", + "imageheight":144, + "imagewidth":176, + "margin":0, + "name":"mario-1-1_bank.png", + "properties": + { + + }, + "spacing":0, + "tileheight":16, + "tilewidth":16 + }], + "tilewidth":16, + "version":1, + "width":211 +} \ No newline at end of file diff --git a/examples/mariocombo/assets/mario1.png b/examples/mariocombo/assets/mario1.png new file mode 100644 index 0000000000000000000000000000000000000000..9cc96c1754be7a6c91c88dccafe3cbc90becb301 GIT binary patch literal 3181 zcmV-z43hJSP)y=xWCkXgcZ1{jpQJ~!ysK}<^W{yV zc-Q_#k>$sB`sug(zaC3U>8*IZPRjk<@Aqf<;m`Z)@l2t<-%ES_^7psTqS~(BJKI~Q zXh7TplnO7py*PE}MGN4+e*ETHl1H!W-LoJe&Pxey>$O?1tsqXf^iebcKHzl)a1Y$F zLv{wab)O}$Ik>IoM+JG^BY2O;<#T9&b9lD{_<(qKZ=A>WEs%SF&$N+7`?LV=Jw^gt z!n+N?txh{zNYVPT&U~RY!RutrqwZ9Pn=fK|o{NoMc0VU}oWXGN@4{hyJk-T>Giz}!q&l6c?NAg-lPpo9-d4?Kc9V&Js^bDif0 zz>lIWTDP1^riKu^XCY>QFCktHurvZloH=q9zz=8?0q#Ls8@!zjV2anyAzleEMRYX; zxOSsE0gMpy> zN`R{aor{r0>s24MU|!ZMR{OP z08?V<9RRMu`v!0iREZptv(6tmu`+v|z1hRjWQ+%ZCDZt)@W8E5!2`hDlpf_;TL8D7 z-vQuUP}LGwox%h6V%=Uifq=NTgj|xBrhege2e`GEwg+%;uLa7Qy5%023-IwedZP-& z#LDY>4+seW*L2OLNXY`=9AeHFw+Ha-pn7Iz(2WPC#K0(kTf35@;H`Dwj0f()>lxsg zc$ktE@&fRb2iDN@F4@uu0Pu(Ob3q8f&5)cC;HfM`Ym4~iHu4VPMSI}#v3GzuP6sia z>mm=Vq37Kh;NIV70$8esbK!xt@JiBXp5&AgfT{130<=n(J+&%%RunBA#Y#RODT|!_DWv=iwqiFg_4o8A zW&5M2`n$(Dj8tgH;{aF}pjPbWrT!Ao5x^*cl?dLHK^y>I+XJrvm!)Oo} z0EY+G02mfF)L)Aj_{ttwss~nwcLZ=`A@=gX-NPM)9+=aA>hO+A0KA_Eo`shh10w-8 zfj0n-7+3>fGk7Bg-a8LG6aP|TU_|?y!W&tLn2D42-%@zb3NXi8$4s0I;3e>$3E+K7l65ER3PB} zfO!$XwPp6&{g%p~p76jn>*2WZequ;Rk`%3&2F);769hMg+ z!kYtI0{n4+qcebyzC-q5Y7GK*o5{Kwz(a^{egJNA02zCAMzTB2WL+VIsDYaUeH6-P zT4kVWEa(DEg!rl+cts9%_BaR&fNT9uIb}!}U;@P9fo%tIk8A_i>q-G`ZS2QADl7k7 zJiwC>hX=L`AxeNHFl!Cgr~q>ZcZo8)b0!ar+A7Nm;4;oFbHCg;cqP1LW0mM6b zVB~hORsiP%wqw7y*WSfnkMjYZ2EbOQZ&JdE#F=N`-2;~!7w!ab4(`V>2uf)*RJ=>| z$aA49Q!KKp2R=IYZRbtlL5G$AkEW5)0Ixm^SqI<>#JhOlT>-9XA$rdRz(k0{1KVaH zD6b(x2#@eSuWgr2tJTtAi}kpkQi5CdA5zS1DI9kTFvq(xAs)4ZW&f<|bPRPnM8cDk@HvkhL9^JoX|E%uggsu$PNEUTLp}heXI}RWo-MeM~ zcsGY>P@n-Jd`^tW59u9hxiXD_^>f3&?Y<$75Y8KZ+hpa*vY>gwrPcL6w$ ziAVQu**~lMSOs9@hHlcjMoOyf0KUlq*4}W>vX99C_l{&j9|3@<>vRAYZL+d|kZTIL z*UJXDtW@I+3shaBU1N3xI8URk>L2u?SkCn(apgk2EJu)Du4$95YdeK5_Nx1GNJfqb zwH6uPquk&B_N-am8DPYU7|k|I(%hXjz^$#7JZo03?18n_ijawnB_6l}ujcNH-sOp_ z&Y4@)W-sjMCVy0+<>?P(83!n{@$}>NPDkST56Py%?C2rO?#aY7A^V#K4wqMh2Lo z*VG314c>cw04E*DX=-eD0+`}~E!*rhW2d3lH1og(yqX>usjNTy- zXeh%6jVy$w#&&fKtThv7*=8RexHZrk%H0Iw6zM*{y|4i}q2XO)>v1Mdv&}w2h@LQK zR6`#K z?A-xOfj9sTdzS#S_8C(KxKuWUeb^_dR?`aLGT6@t7GZx~`y|zBT6*BxXgBPyZJ(rC z&4_`+erXIW)oKR7VeblHs#+)j4tuv*2n&E`7XP(wGVH@XNwt~?51daOQg0yauWg^C zT1`|4(V7GA{ltWQ*e9u06CDFn(kx*g_DQPM)Evak#7|*=ZTlqEY9a=2BdH}tju-aV zvQM*mR*9w*s;8}q*;}@Q_fhJXv;p`2sk&iG`%~_xcl~MgzsN&|y(kYG0Ec}58~}%X z033SMuxIFTcL6x`sA1p8AnoIULysEvH9c;`z+oRTZ~z?k0dRC+*zX2#=uyL7XusYA zhaNTT*?L?rAw=j=!=9zb^%et%9yRPqdR)(gxX`19{Y3n{_Fw2x!(ODvUHtDqa+@>! TaiH#c00000NkvXXu0mjfU@!Dv literal 0 HcmV?d00001 diff --git a/examples/mariocombo/assets/phaser.png b/examples/mariocombo/assets/phaser.png new file mode 100644 index 0000000000000000000000000000000000000000..91393348a32650059c3051ac6017f8b0874fadc7 GIT binary patch literal 809 zcmV+^1J?YBP)X1^@s6-C}FS0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!%Sl8*RCwC#T2XGoFbr+0-DGC~aT&M) zeD4VRh8w_T5S(FW>3B?@JkNHVv|+7=r3lo)N_tWY0Ybn&0xzc#rw*6CmZUZ=UQ{6QAtR`|G z{QHn>nTvE&cTn53OE&T+L5^6JR%B1mGDbe53hG}GgmsWN>=klfsYy;MQ|O&#f4AGI z&#{Ne*m#TLk*iPm@s`qY3F0%dbaoCQ$I6~)7NL;PNP-@UjuL-TEro@wkR!Ohq&k#V zBbUo%^u0&xv)OFS_f+le_j{FGdLNlc(RjR!z<9ZMCifsL36GXk_Hdy2EYyJZGKv4T zdX(hinIy2 zYSJ#+jSSTX*pxO(#nR`tJv@0|x@j;8(gL@d=aAP=j*}uFMW9Ad2}#j-O7M^|X#Q6x z$kHDJ{74o_f}$j);_+I}gq1O9ScM4UicpX(N53TX<@iw|$6lhwT;d{GMEF)eNr?Uy z(keGpJp2Ha+mzLitmvjLG6u{4ZY+R@>T1=PR`C!~+PgWN(ea5UW8nV(x(`YL?A@D> zL2NX8Qdu-7iDc3DeNdEj?`pu)9dhHTjX&4_AxJzx2tTC&Vf=KY8$wP^-7#&5C_3g9&{_Te)()T^K|NZ^y^=!NL*hS~? z<;$0Q9s$>32)+i9(beDMV#5#|?ERmAZ=wi3=>^~faf$>igm-=)0C;tL`Hz4K>KqcV zZ@1ec(q}3_eth;gPLBX>b}xcEHHf1?oPlhHw*tf~fb)PLCwKwC%P~>soCgPS4({*o z+jE{@FF?G2`}y-9oBik4srGLI?h8R24Y1}`MFO0IoQ|6USOPDEI6tNY?+os56Ao_* z0^$YSPoI88;Z3ngeK4SY`LqpcI|pWI|BfMMFCumObwa%96_H!$T?6m}=g5QU^E@QR;;u ztT6SUa%c#!W)KGfF2Rco=2Y+^gE=+8^ZPx}!~I!+cY^qygG=>9r9s>bXbIqa`|3M6 zfIpxq06bum7+B5=_lW{HNoW+jX&^@doFp^~-ZYS-0G5JDz0b3MYlw?!0+IisI&cCN z29^I(Gif=zLV!&=asio-dwv) z?<1yyUFV%oIcsO);OrX*FCnF^X5Tn?2`Nnkum^1E{-h+=6T}s!k{2*n@aErpdv0UQ zIBtNofdOog(%9)^fs`hO(=$+$0*py=yF*M3-n3?(!mQc=0mk56Qit0*7Y+p21ToZr zEm9f;SgS_#qC%7;xmG%Hgq>3ISxl8)KfD6C2OaV-0O#^f!A?mjEDnHa-|apC zui;JKZ-rRuC!UxbxF;RbBg53(pR^7#0CV!75n$RZ{^0s%zvO z&JRqDrj-Dr@N)LWaEVX|uXfF%)la;<_tGK#HbAMJ(wIV!`7Y4qbXAeR&C$_&X3R06T9G*LL3V4 znf<8N{iOgadtfuX*m)Qr4uMw!v8MgeALivp?G9jG4>bU6fcU-6^f;a@=%a3Z` zU*iWBq!6sm%fTx>Kk>j3LhOK-gE$=EGy733`zIJRR?7MP2*4tp*8{K+;&0IA5Kn%1 zDTqUI;LDHdQXz%}u_h$&N|vg-E`BNZ1rU4T#UKs?_|k!00DJ6|=p26ya0?LQ1GoH` zvmV$AFND~C{DsD=tTXO2Qv@zTSoB#{QCj#g#N!+E1G1|g+^s7pr)mrD4S{$Hf_HLS z32T76zWqmT7XysRc#JCIlkB8AV`+5Q=pw34J`7@T*Q!u-Te}Kl+Xmx+_i(oD^#Jzj z&6F)qJIZYUvF+r&5MvtcZ5N2|#*Wg7m}yQe#07XOLcHxEu{<2cSU5N7_Syh@XZkF1 zO~Z5|bdFvOu@K%sh}oGi@!ewFzW(R$Kd&Jz?O#wO+$w~3n!1L@SP9}-c%=|4;SEqH zw&&>?Yyx;wsD1=YZyW-!=lbp8m+cnb62w+`eGsE5gLm>k4R78{V>5G60DG@r4L@y= zA9WviDTuxB+8{2PXS@)bRhJQkISgR)^^3G42KrI=g%^W(41iZ(cw_@`6ucptcL88i z$L76$djQ;nsoDjx2i{Q(F>7CJ0xxxr8N^Z2>Q4U>O789gAg{Vg_wN zL8cm&0k&PUAU|!mAGH;{7{pTmygbBR!AlPI3IJPjVE6TFVL=r8QCq<~8Po|0yg0;% zg*Rdl=e~Zee6(UeYAbj(>VyVfOp@vZU~T#kEu-1SEHy8_WOVPn_`F-IMuZ6Yh(_)? z4)3|#8-@69UObViXM?=Gy**-;f=syNwz)%1 z_%%tN`TqX?2xSO?n5b6xBy<4G)whMw#P=cuNq=Q(B}U? zBfwiFq9wdItXi$mRTe-~m3`9-7XX&j_swN2Gr+lLgKP5vZ||c3j7w>);pHJ7Y5=UQ z4{QNgS|T+EH~~uKyoi_|5=Q_Ss~klGd>nW~0j6Hp0<5X;OZC7UxB%b*O(Uj4kDTrM zS~_rBcx@{-l+}ea0BZ+vn;%pmKZiYVetU!gp*|zPyo`1{c*Ou)jrtmZvAaR3zVG~6 z4(SE3RR=yMyrBTA@?QY3wZ1O|SQ?=1TmYAHVam^d0Sh4ou&Pryg;>R5b zb9z4juiAr}Btdhy_5)_ojG^^WXe7MMM3Ace5^VV+VAJ#7_5fJo$AwnM<-L6Zj6y61 zcz?A={YYC)@f$6`6vQmR@EOL+ft(v)i658q?sf<;*%Pw>w~;Et0HzcOEx=q)Tm;yl zM7VNbi60kx5Bijwz5pIXe&O~y``!Dbs)(6P3St$&Mk&n=u(L2q&j1&D;tnQ>y7f~_ zdg29O>`9v*fH@iMWB{`ecQC`*ou3+hKHGj#I&ee}Y%H981b|71JD8sD&QFbf4%vRK zb>I^Lj6!_*spX%KwqFe$*qTC|0N@S8m!DdvY;4*uN(ZJOrr-_DfeRpu9|JJT7C}bz zdZ-uT#C~ec=dao?KnHf2c|rm1yuu;|@#UwsSN8m1z^wzjY>_7hcn!}<{nSzAX zk0E=tuFJBv%ea=yTpE-zWLp9B==jtM5w$0Jbc{u;F2MBV^T}f=gf`Otc`lv)g#iYM zrvv!8C@}_LtB$_`S8r==5Ab}l=~qmF4B^BAgEajMBXCXE;Q)>%z!$(+ zT>~zyP_H5h(D6mJm1(={1@Kt_POEBb^}tpg9|acsE`0k1@EHK6>l*lTV6Tpk0V^#( zdjWg`fcd%xaVmt>&n@v^GrsH#;4=YSQ%1A;xo1tiRDgx5uY3V~B7l3;fu$=SiiKG& zfL|NnUUgs#z;IRY1@Osq;B|Gym_eM!&z(E`w63!Y;1lY=H37EBXcxd2z$zWM7Qj{= zSOPG&q^CK+DJYOBKLZ9VgcQKan?WuexQPyIEn3nYzzrQ~mk!)e2R^(CaRGekz=sCd zc>*B~kf$EnT-=y@_oCy*n9`jcKz?4gVN{2402$W+*6M>6h_O*@?*LcSak~Rp3$a51 zX#=rl-To^8Tv^9G48YhnY*9n^5Np=$zZ$?5WUwv){&V>85g4Rt8@Cdt6~H9K)^+<* z8RiH8SJH921h}OA&j520YfFGph^_1PUj^WbI&L=rm)ez!q0Xx9{RVcP`mRS&Au8#( zes}|9OspM;{mKi}YaH*o{Z|9HLmBN^LFiV{QU_8?l|TvG@GyT>d*YMmz_MpmSnK=3 z^nrRr7@tNIzo&=XwmY5p1Um3?+=F0YrU8)M08VXvM1ZU5#4oA?qmW{fl*7lnJHX(F z==*yf!?AVZ7tn!=g+?k*0PF>D9K_?QD9W*Q;up|?#YITC*)0deu>kX6*#ORa+Q#sP z>%=dh1FI_OR4~KT0T{o<+k4;%JRAE})QK0+fn7!z7$$%x+_t!}FG8q?4AunIZBzFw z2H+cz`d&pRegPdg3}9Ct98udihdnw6E`PS^?>_^ugqrLXFh>9Y04;PySaefwW^{L9 za%BKwc`jmXZ*OE|c`jped2n=ZE@^FHXJsx>PDe5{MQ&qnWMy)w27m4V0000 + + + + phaser.js - Super Mario Combo + + + + + +
+ + + +

Potential game idea here? :)

+

Click game to full-screen (if supported)

+

Created with Phaser 1.0 by @photonstorm

+ + + \ No newline at end of file diff --git a/examples/mariotogether.php b/examples/mariotogether.php new file mode 100644 index 00000000..908a2361 --- /dev/null +++ b/examples/mariotogether.php @@ -0,0 +1,45 @@ + + + + phaser.js - Super Mario Combo + + + + + + + + \ No newline at end of file diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index c1454738..7ce7cf5b 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -110,7 +110,7 @@ Phaser.GameObjectFactory.prototype = { tilemap: function (x, y, key, resizeWorld, tileWidth, tileHeight) { - return this.world.group.add(new Phaser.Tilemap(this.game, key, resizeWorld, tileWidth, tileHeight)); + return this.world.group.add(new Phaser.Tilemap(this.game, key, x, y, resizeWorld, tileWidth, tileHeight)); }, diff --git a/src/math/Math.js b/src/math/Math.js index 439200c3..2995b4f8 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -440,7 +440,8 @@ Phaser.Math = { for (var i = 1, max = 0, len = arguments.length; i < len; i++) { - if (arguments[max] < arguments[i]) { + if (arguments[max] < arguments[i]) + { max = i; } } @@ -459,7 +460,8 @@ Phaser.Math = { for (var i =1 , min = 0, len = arguments.length; i < len; i++) { - if (arguments[i] < arguments[min]){ + if (arguments[i] < arguments[min]) + { min = i; } } diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 2fd46433..c517fc8b 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -424,6 +424,204 @@ Phaser.Physics.Arcade.prototype = { } }, + /** + * The core Collision separation function used by Collision.overlap. + * @param object1 The first GameObject to separate + * @param object2 The second GameObject to separate + * @returns {boolean} Returns true if the objects were separated, otherwise false. + */ + separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) { + + // Yes, the Y first + var separatedY = this.separateTileY(object.body, x, y, width, height, mass, collideUp, collideDown, separateY); + var separatedX = this.separateTileX(object.body, x, y, width, height, mass, collideLeft, collideRight, separateX); + + if (separatedX || separatedY) + { + object.body.postUpdate(); + return true; + } + + return false; + + }, + + /** + * Separates the two objects on their x axis + * @param object The GameObject to separate + * @param tile The Tile to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. + */ + separateTileX: function (object, x, y, width, height, mass, collideLeft, collideRight, separate) { + + // Can't separate two immovable objects (tiles are always immovable) + if (object.immovable) + { + return false; + } + + // First, get the object delta + this._overlap = 0; + + // console.log('separatedX', x, y, object.deltaX()); + + if (object.deltaX() != 0) + { + this._obj1Bounds.setTo(object.x, object.y, object.width, object.height); + + if ((this._obj1Bounds.right > x) && (this._obj1Bounds.x < x + width) && (this._obj1Bounds.bottom > y) && (this._obj1Bounds.y < y + height)) + { + // The hulls overlap, let's process it + this._maxOverlap = object.deltaAbsX() + this.OVERLAP_BIAS; + + // TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile + // in which case we didn't ought to separate because it'll look like tunneling + + if (object.deltaX() < 0) + { + // Going left ... + this._overlap = object.x - width - x; + + if (object.allowCollision.left && collideLeft && this._overlap < this._maxOverlap) + { + object.touching.left = true; + // console.log('left', this._overlap); + } + else + { + this._overlap = 0; + } + } + else + { + // Going right ... + this._overlap = object.right - x; + + if (object.allowCollision.right && collideRight && this._overlap < this._maxOverlap) + { + object.touching.right = true; + // console.log('right', this._overlap); + } + else + { + this._overlap = 0; + } + } + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (this._overlap != 0) + { + if (separate) + { + object.x = object.x - this._overlap; + + if (object.bounce.x == 0) + { + object.velocity.x = 0; + } + else + { + object.velocity.x = -object.velocity.x * object.bounce.x; + } + } + return true; + } + else + { + return false; + } + + }, + + /** + * Separates the two objects on their x axis + * @param object The GameObject to separate + * @param tile The Tile to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. + */ + separateTileY: function (object, x, y, width, height, mass, collideUp, collideDown, separate) { + + // Can't separate two immovable objects (tiles are always immovable) + if (object.immovable) + { + return false; + } + + // First, get the object delta + this._overlap = 0; + + if (object.deltaY() != 0) + { + this._obj1Bounds.setTo(object.x, object.y, object.width, object.height); + + if ((this._obj1Bounds.right > x) && (this._obj1Bounds.x < x + width) && (this._obj1Bounds.bottom > y) && (this._obj1Bounds.y < y + height)) + { + // The hulls overlap, let's process it + + // Not currently used, may need it so keep for now + this._maxOverlap = object.deltaAbsY() + this.OVERLAP_BIAS; + + // TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile + // in which case we didn't ought to separate because it'll look like tunneling + + if (object.deltaY() > 0) + { + // Going down ... + this._overlap = object.bottom - y; + + if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap) + { + object.touching.down = true; + } + else + { + this._overlap = 0; + } + } + else + { + // Going up ... + this._overlap = object.y - height - y; + + if (object.allowCollision.up && collideUp && this._overlap < this._maxOverlap) + { + object.touching.up = true; + } + else + { + this._overlap = 0; + } + } + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (this._overlap != 0) + { + if (separate) + { + object.y = object.y - this._overlap; + + if (object.bounce.y == 0) + { + object.velocity.y = 0; + } + else + { + object.velocity.y = -object.velocity.y * object.bounce.y; + } + } + return true; + } + else + { + return false; + } + + }, + /** * Given the angle and speed calculate the velocity and return it as a Point * diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 5385e6b3..9e5b8aff 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -122,6 +122,19 @@ Phaser.Physics.Arcade.Body.prototype = { }, + postUpdate: function () { + + this.sprite.x = this.x; + this.sprite.y = this.y; + + if (this.allowRotation) + { + this.sprite.angle = this.rotation; + } + + }, + + /* postUpdate: function () { // this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width); @@ -136,6 +149,7 @@ Phaser.Physics.Arcade.Body.prototype = { } }, + */ checkWorldBounds: function () { diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index cfae0a84..070c32dc 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -17,7 +17,7 @@ * @param tileWidth {number} Width of tiles in this map (used for CSV maps). * @param tileHeight {number} Height of tiles in this map (used for CSV maps). */ -Phaser.Tilemap = function (game, key, resizeWorld, tileWidth, tileHeight) { +Phaser.Tilemap = function (game, key, x, y, resizeWorld, tileWidth, tileHeight) { if (typeof resizeWorld === "undefined") { resizeWorld = true; } if (typeof tileWidth === "undefined") { tileWidth = 0; } @@ -47,8 +47,9 @@ Phaser.Tilemap = function (game, key, resizeWorld, tileWidth, tileHeight) { var map = this.game.cache.getTilemap(key); - // this._container = new PIXI.DisplayObjectContainer(); PIXI.DisplayObjectContainer.call(this); + this.position.x = x; + this.position.y = y; this.renderer = new Phaser.TilemapRenderer(this.game); @@ -208,16 +209,16 @@ Phaser.Tilemap.prototype.setCollisionCallback = function (context, callback) { * @param separateX {bool} Enable seprate at x-axis. * @param separateY {bool} Enable seprate at y-axis. */ -Phaser.Tilemap.prototype.setCollisionRange = function (start, end, collision, resetCollisions, separateX, separateY) { +Phaser.Tilemap.prototype.setCollisionRange = function (start, end, left, right, up, down, resetCollisions, separateX, separateY) { - if (typeof collision === "undefined") { collision = Phaser.Types.ANY; } if (typeof resetCollisions === "undefined") { resetCollisions = false; } if (typeof separateX === "undefined") { separateX = true; } if (typeof separateY === "undefined") { separateY = true; } for (var i = start; i < end; i++) { - this.tiles[i].setCollision(collision, resetCollisions, separateX, separateY); + //setCollision: function (left, right, up, down, reset, separateX, separateY) { + this.tiles[i].setCollision(left, right, up, down, resetCollisions, separateX, separateY); } }; @@ -343,13 +344,13 @@ Phaser.Tilemap.prototype.collide = function (objectOrGroup, callback, context) { } // Group? - if (objectOrGroup.isGroup == false) + if (objectOrGroup instanceof Phaser.Group) { - this.collideGameObject(objectOrGroup); + // objectOrGroup.forEachAlive(this, this.collideGameObject, true); } else { - objectOrGroup.forEachAlive(this, this.collideGameObject, true); + this.collideGameObject(objectOrGroup); } }; @@ -361,7 +362,7 @@ Phaser.Tilemap.prototype.collide = function (objectOrGroup, callback, context) { */ Phaser.Tilemap.prototype.collideGameObject = function (object) { - if (object.body.type == Phaser.Types.BODY_DYNAMIC && object.exists == true && object.body.allowCollisions != Phaser.Types.NONE) + if (object.exists && object.body.allowCollision.none == false) { this._tempCollisionData = this.collisionLayer.getTileOverlaps(object); diff --git a/src/tilemap/TilemapLayer.js b/src/tilemap/TilemapLayer.js index 0b01f499..33a027da 100644 --- a/src/tilemap/TilemapLayer.js +++ b/src/tilemap/TilemapLayer.js @@ -306,31 +306,30 @@ Phaser.TilemapLayer.prototype = { getTileOverlaps: function (object) { // If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds) - if (object.body.bounds.x < 0 || object.body.bounds.x > this.widthInPixels || object.body.bounds.y < 0 || object.body.bounds.bottom > this.heightInPixels) + if (object.body.x < 0 || object.body.x > this.widthInPixels || object.body.y < 0 || object.body.bottom > this.heightInPixels) { return; } // What tiles do we need to check against? - this._tempTileX = this.game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth; - this._tempTileY = this.game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight; - this._tempTileW = (this.game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth; - this._tempTileH = (this.game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight; + this._tempTileX = this.game.math.snapToFloor(object.body.x, this.tileWidth) / this.tileWidth; + this._tempTileY = this.game.math.snapToFloor(object.body.y, this.tileHeight) / this.tileHeight; + this._tempTileW = (this.game.math.snapToCeil(object.body.width, this.tileWidth) + this.tileWidth) / this.tileWidth; + this._tempTileH = (this.game.math.snapToCeil(object.body.height, this.tileHeight) + this.tileHeight) / this.tileHeight; // Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock) this._tempBlockResults = []; this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true); - /* for (var r = 0; r < this._tempTileBlock.length; r++) { - if (this.game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true) - { - this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile }); + // separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) + if (this.game.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY)) + { + this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile }); + } } - } - */ return this._tempBlockResults; @@ -377,7 +376,7 @@ Phaser.TilemapLayer.prototype = { if (collisionOnly) { // We only want to consider the tile for checking if you can actually collide with it - if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].allowCollisions != Phaser.Types.NONE) + if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].collideNone == false) { this._tempTileBlock.push({ x: tx, diff --git a/src/time/Time.js b/src/time/Time.js index 9009bd52..4be752a0 100644 --- a/src/time/Time.js +++ b/src/time/Time.js @@ -162,6 +162,8 @@ Phaser.Time = function (game) { this.game.onPause.add(this.gamePaused, this); this.game.onResume.add(this.gameResumed, this); + this._justResumed = false; + }; Phaser.Time.prototype = { @@ -212,6 +214,18 @@ Phaser.Time.prototype = { this.pausedTime = this.now - this._pauseStarted; } + if (this._justResumed) + { + console.log('Time just resumed'); + console.log('now', this.now); + console.log('timeToCall', this.timeToCall); + console.log('elapsed', this.elapsed); + console.log('lastTime', this.lastTime); + console.log('physicsElapsed', this.physicsElapsed); + + this._justResumed = false; + } + }, /** @@ -221,6 +235,12 @@ Phaser.Time.prototype = { */ gamePaused: function () { this._pauseStarted = this.now; + console.log('Time paused'); + console.log('now', this.now); + console.log('timeToCall', this.timeToCall); + console.log('elapsed', this.elapsed); + console.log('lastTime', this.lastTime); + console.log('physicsElapsed', this.physicsElapsed); }, /** @@ -235,6 +255,8 @@ Phaser.Time.prototype = { this.physicsElapsed = 0; this.pauseDuration = this.pausedTime; + this._justResumed = true; + }, /** diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 91797193..5b5bc9e4 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -312,6 +312,22 @@ Phaser.Utils.Debug.prototype = { }, + renderSpriteCollision: function (sprite, x, y, color) { + + color = color || 'rgb(255,255,255)'; + + this.start(x, y, color); + this.line('Sprite Collision: (' + sprite.width + ' x ' + sprite.height + ')'); + this.line('left: ' + sprite.body.touching.left); + this.line('right: ' + sprite.body.touching.right); + this.line('up: ' + sprite.body.touching.up); + this.line('down: ' + sprite.body.touching.down); + this.line('velocity.x: ' + sprite.body.velocity.x); + this.line('velocity.y: ' + sprite.body.velocity.y); + this.stop(); + + }, + /** * Render debug information about the Input object. * @param x {number} X position of the debug info to be rendered.