Skip to content
This repository
Browse code

fixed #700 add zlib support for cc.TMXXMLParser

  • Loading branch information...
commit 533245c778d610ba183e2422fc0a1d420591ec27 1 parent 8c4f1a8
dingpinglv authored December 21, 2012
1  HelloHTML5World/build.xml
@@ -18,6 +18,7 @@
18 18
                 <file name="platform/CCMacro.js"/>
19 19
                 <file name="platform/CCFileUtils.js"/>
20 20
                 <file name="platform/CCTypes.js"/>
  21
+                <file name="platform/zlib.min.js"/>
21 22
                 <file name="cocoa/CCGeometry.js"/>
22 23
                 <file name="platform/CCConfig.js"/>
23 24
                 <file name="cocoa/CCNS.js"/>
5  chipmunk/chipmunk.js
@@ -27,13 +27,12 @@
27 27
     };
28 28
 
29 29
 //var VERSION = CP_VERSION_MAJOR + "." + CP_VERSION_MINOR + "." + CP_VERSION_RELEASE;
30  
-
31 30
     var cp;
32 31
     if(typeof exports === 'undefined'){
33 32
         cp = {};
34 33
 
35 34
         if(typeof window === 'object'){
36  
-            window.cp = cp;
  35
+            window["cp"] = cp;
37 36
         }
38 37
     } else {
39 38
         cp = exports;
@@ -3370,7 +3369,7 @@
3370 3369
 
3371 3370
     SegmentShape.prototype.collisionTable = [
3372 3371
         null,
3373  
-        function(seg, seg) { return NONE; }, // seg2seg
  3372
+        function(seg, seg2) { return NONE; }, // seg2seg
3374 3373
         seg2poly
3375 3374
     ];
3376 3375
 
1  cocos2d/build.xml
@@ -21,6 +21,7 @@
21 21
                 <file name="platform/CCMacro.js"/>
22 22
                 <file name="platform/CCFileUtils.js"/>
23 23
                 <file name="platform/CCTypes.js"/>
  24
+                <file name="platform/zlib.min.js"/>
24 25
                 <file name="cocoa/CCGeometry.js"/>
25 26
                 <file name="platform/CCConfig.js"/>
26 27
                 <file name="cocoa/CCNS.js"/>
12  cocos2d/cocos2d_externs.js
@@ -13,3 +13,15 @@
13 13
  * @type {string}
14 14
  */
15 15
 CSSProperties.prototype._super;
  16
+
  17
+/**
  18
+ * cocos2d-html5-only.
  19
+ * @type {string}
  20
+ */
  21
+CSSProperties.prototype.Inflate;
  22
+
  23
+/**
  24
+ * cocos2d-html5-only.
  25
+ * @type {string}
  26
+ */
  27
+CSSProperties.prototype.decompress;
14  cocos2d/platform/base64.js
@@ -69,6 +69,7 @@ cc.Codec.Base64.decode = function Jacob__Codec__Base64__decode(input) {
69 69
  * var decodeArr = cc.Codec.Base64.decodeAsArray("U29tZSBTdHJpbmc=");
70 70
  */
71 71
 cc.Codec.Base64.decodeAsArray = function Jacob__Codec__Base64___decodeAsArray(input, bytes) {
  72
+    bytes = bytes || 4;
72 73
     var dec = this.decode(input),
73 74
         ar = [], i, j, len;
74 75
     for (i = 0, len = dec.length / bytes; i < len; i++) {
@@ -115,3 +116,16 @@ cc.Codec.Base64.encode = function Jacob__Codec__Base64__encode(input) {
115 116
 
116 117
     return output;
117 118
 };
  119
+
  120
+cc.uint8ArrayToUint32Array = function(uint8Arr){
  121
+    if(uint8Arr.length % 4 != 0)
  122
+        return null;
  123
+
  124
+    var arrLen = uint8Arr.length /4;
  125
+    var retArr = window.Uint8Array? new Uint32Array(arrLen) : [];
  126
+    for(var i = 0; i < arrLen; i++){
  127
+        var offset = i * 4;
  128
+        retArr[i] = uint8Arr[offset]  + uint8Arr[offset + 1] * (1 << 8) + uint8Arr[offset + 2] * (1 << 16) + uint8Arr[offset + 3] * (1<<24);
  129
+    }
  130
+    return retArr;
  131
+};
1  cocos2d/platform/jsloader.js
@@ -36,6 +36,7 @@
36 36
         'platform/CCMacro.js',
37 37
         'platform/CCFileUtils.js',
38 38
         'platform/CCTypes.js',
  39
+        'platform/zlib.min.js',
39 40
         'cocoa/CCGeometry.js',
40 41
         'platform/CCConfig.js',
41 42
         'cocoa/CCSet.js',
46  cocos2d/platform/zlib.min.js
... ...
@@ -0,0 +1,46 @@
  1
+/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
  2
+(function() {'use strict';function i(a){throw a;}var r=void 0,v=!0,aa=this;function y(a,c){var b=a.split("."),e=aa;!(b[0]in e)&&e.execScript&&e.execScript("var "+b[0]);for(var f;b.length&&(f=b.shift());)!b.length&&c!==r?e[f]=c:e=e[f]?e[f]:e[f]={}};var H="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array;function ba(a){if("string"===typeof a){var c=a.split(""),b,e;b=0;for(e=c.length;b<e;b++)c[b]=(c[b].charCodeAt(0)&255)>>>0;a=c}for(var f=1,d=0,g=a.length,h,m=0;0<g;){h=1024<g?1024:g;g-=h;do f+=a[m++],d+=f;while(--h);f%=65521;d%=65521}return(d<<16|f)>>>0};function J(a,c){this.index="number"===typeof c?c:0;this.i=0;this.buffer=a instanceof(H?Uint8Array:Array)?a:new (H?Uint8Array:Array)(32768);2*this.buffer.length<=this.index&&i(Error("invalid index"));this.buffer.length<=this.index&&this.f()}J.prototype.f=function(){var a=this.buffer,c,b=a.length,e=new (H?Uint8Array:Array)(b<<1);if(H)e.set(a);else for(c=0;c<b;++c)e[c]=a[c];return this.buffer=e};
  3
+J.prototype.d=function(a,c,b){var e=this.buffer,f=this.index,d=this.i,g=e[f],h;b&&1<c&&(a=8<c?(N[a&255]<<24|N[a>>>8&255]<<16|N[a>>>16&255]<<8|N[a>>>24&255])>>32-c:N[a]>>8-c);if(8>c+d)g=g<<c|a,d+=c;else for(h=0;h<c;++h)g=g<<1|a>>c-h-1&1,8===++d&&(d=0,e[f++]=N[g],g=0,f===e.length&&(e=this.f()));e[f]=g;this.buffer=e;this.i=d;this.index=f};J.prototype.finish=function(){var a=this.buffer,c=this.index,b;0<this.i&&(a[c]<<=8-this.i,a[c]=N[a[c]],c++);H?b=a.subarray(0,c):(a.length=c,b=a);return b};
  4
+var ca=new (H?Uint8Array:Array)(256),ha;for(ha=0;256>ha;++ha){for(var R=ha,ia=R,ja=7,R=R>>>1;R;R>>>=1)ia<<=1,ia|=R&1,--ja;ca[ha]=(ia<<ja&255)>>>0}var N=ca;var ka=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,
  5
+2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,
  6
+2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,
  7
+2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,
  8
+3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,
  9
+936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];H&&new Uint32Array(ka);function la(a){this.buffer=new (H?Uint16Array:Array)(2*a);this.length=0}la.prototype.getParent=function(a){return 2*((a-2)/4|0)};la.prototype.push=function(a,c){var b,e,f=this.buffer,d;b=this.length;f[this.length++]=c;for(f[this.length++]=a;0<b;)if(e=this.getParent(b),f[b]>f[e])d=f[b],f[b]=f[e],f[e]=d,d=f[b+1],f[b+1]=f[e+1],f[e+1]=d,b=e;else break;return this.length};
  10
+la.prototype.pop=function(){var a,c,b=this.buffer,e,f,d;c=b[0];a=b[1];this.length-=2;b[0]=b[this.length];b[1]=b[this.length+1];for(d=0;;){f=2*d+2;if(f>=this.length)break;f+2<this.length&&b[f+2]>b[f]&&(f+=2);if(b[f]>b[d])e=b[d],b[d]=b[f],b[f]=e,e=b[d+1],b[d+1]=b[f+1],b[f+1]=e;else break;d=f}return{index:a,value:c,length:this.length}};function S(a){var c=a.length,b=0,e=Number.POSITIVE_INFINITY,f,d,g,h,m,j,s,n,l;for(n=0;n<c;++n)a[n]>b&&(b=a[n]),a[n]<e&&(e=a[n]);f=1<<b;d=new (H?Uint32Array:Array)(f);g=1;h=0;for(m=2;g<=b;){for(n=0;n<c;++n)if(a[n]===g){j=0;s=h;for(l=0;l<g;++l)j=j<<1|s&1,s>>=1;for(l=j;l<f;l+=m)d[l]=g<<16|n;++h}++g;h<<=1;m<<=1}return[d,b,e]};function ma(a,c){this.h=pa;this.w=0;this.input=a;this.b=0;c&&(c.lazy&&(this.w=c.lazy),"number"===typeof c.compressionType&&(this.h=c.compressionType),c.outputBuffer&&(this.a=H&&c.outputBuffer instanceof Array?new Uint8Array(c.outputBuffer):c.outputBuffer),"number"===typeof c.outputIndex&&(this.b=c.outputIndex));this.a||(this.a=new (H?Uint8Array:Array)(32768))}var pa=2,qa={NONE:0,r:1,j:pa,N:3},ra=[],T;
  11
+for(T=0;288>T;T++)switch(v){case 143>=T:ra.push([T+48,8]);break;case 255>=T:ra.push([T-144+400,9]);break;case 279>=T:ra.push([T-256+0,7]);break;case 287>=T:ra.push([T-280+192,8]);break;default:i("invalid literal: "+T)}
  12
+ma.prototype.n=function(){var a,c,b,e,f=this.input;switch(this.h){case 0:b=0;for(e=f.length;b<e;){c=H?f.subarray(b,b+65535):f.slice(b,b+65535);b+=c.length;var d=c,g=b===e,h=r,m=r,j=r,s=r,n=r,l=this.a,q=this.b;if(H){for(l=new Uint8Array(this.a.buffer);l.length<=q+d.length+5;)l=new Uint8Array(l.length<<1);l.set(this.a)}h=g?1:0;l[q++]=h|0;m=d.length;j=~m+65536&65535;l[q++]=m&255;l[q++]=m>>>8&255;l[q++]=j&255;l[q++]=j>>>8&255;if(H)l.set(d,q),q+=d.length,l=l.subarray(0,q);else{s=0;for(n=d.length;s<n;++s)l[q++]=
  13
+d[s];l.length=q}this.b=q;this.a=l}break;case 1:var E=new J(new Uint8Array(this.a.buffer),this.b);E.d(1,1,v);E.d(1,2,v);var t=sa(this,f),z,K,A;z=0;for(K=t.length;z<K;z++)if(A=t[z],J.prototype.d.apply(E,ra[A]),256<A)E.d(t[++z],t[++z],v),E.d(t[++z],5),E.d(t[++z],t[++z],v);else if(256===A)break;this.a=E.finish();this.b=this.a.length;break;case pa:var x=new J(new Uint8Array(this.a),this.b),B,k,p,D,C,da=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],W,Ma,ea,Na,na,va=Array(19),Oa,$,oa,F,Pa;B=pa;x.d(1,
  14
+1,v);x.d(B,2,v);k=sa(this,f);W=ta(this.L,15);Ma=ua(W);ea=ta(this.K,7);Na=ua(ea);for(p=286;257<p&&0===W[p-1];p--);for(D=30;1<D&&0===ea[D-1];D--);var Qa=p,Ra=D,M=new (H?Uint32Array:Array)(Qa+Ra),u,O,w,fa,L=new (H?Uint32Array:Array)(316),I,G,P=new (H?Uint8Array:Array)(19);for(u=O=0;u<Qa;u++)M[O++]=W[u];for(u=0;u<Ra;u++)M[O++]=ea[u];if(!H){u=0;for(fa=P.length;u<fa;++u)P[u]=0}u=I=0;for(fa=M.length;u<fa;u+=O){for(O=1;u+O<fa&&M[u+O]===M[u];++O);w=O;if(0===M[u])if(3>w)for(;0<w--;)L[I++]=0,P[0]++;else for(;0<
  15
+w;)G=138>w?w:138,G>w-3&&G<w&&(G=w-3),10>=G?(L[I++]=17,L[I++]=G-3,P[17]++):(L[I++]=18,L[I++]=G-11,P[18]++),w-=G;else if(L[I++]=M[u],P[M[u]]++,w--,3>w)for(;0<w--;)L[I++]=M[u],P[M[u]]++;else for(;0<w;)G=6>w?w:6,G>w-3&&G<w&&(G=w-3),L[I++]=16,L[I++]=G-3,P[16]++,w-=G}a=H?L.subarray(0,I):L.slice(0,I);na=ta(P,7);for(F=0;19>F;F++)va[F]=na[da[F]];for(C=19;4<C&&0===va[C-1];C--);Oa=ua(na);x.d(p-257,5,v);x.d(D-1,5,v);x.d(C-4,4,v);for(F=0;F<C;F++)x.d(va[F],3,v);F=0;for(Pa=a.length;F<Pa;F++)if($=a[F],x.d(Oa[$],
  16
+na[$],v),16<=$){F++;switch($){case 16:oa=2;break;case 17:oa=3;break;case 18:oa=7;break;default:i("invalid code: "+$)}x.d(a[F],oa,v)}var Sa=[Ma,W],Ta=[Na,ea],Q,Ua,ga,ya,Va,Wa,Xa,Ya;Va=Sa[0];Wa=Sa[1];Xa=Ta[0];Ya=Ta[1];Q=0;for(Ua=k.length;Q<Ua;++Q)if(ga=k[Q],x.d(Va[ga],Wa[ga],v),256<ga)x.d(k[++Q],k[++Q],v),ya=k[++Q],x.d(Xa[ya],Ya[ya],v),x.d(k[++Q],k[++Q],v);else if(256===ga)break;this.a=x.finish();this.b=this.a.length;break;default:i("invalid compression type")}return this.a};
  17
+function wa(a,c){this.length=a;this.G=c}
  18
+function xa(){var a=za;switch(v){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-
  19
+31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:i("invalid length: "+a)}}var Aa=[],za,Ba;
  20
+for(za=3;258>=za;za++)Ba=xa(),Aa[za]=Ba[2]<<24|Ba[1]<<16|Ba[0];var Ca=H?new Uint32Array(Aa):Aa;
  21
+function sa(a,c){function b(a,c){var b=a.G,d=[],e=0,f;f=Ca[a.length];d[e++]=f&65535;d[e++]=f>>16&255;d[e++]=f>>24;var g;switch(v){case 1===b:g=[0,b-1,0];break;case 2===b:g=[1,b-2,0];break;case 3===b:g=[2,b-3,0];break;case 4===b:g=[3,b-4,0];break;case 6>=b:g=[4,b-5,1];break;case 8>=b:g=[5,b-7,1];break;case 12>=b:g=[6,b-9,2];break;case 16>=b:g=[7,b-13,2];break;case 24>=b:g=[8,b-17,3];break;case 32>=b:g=[9,b-25,3];break;case 48>=b:g=[10,b-33,4];break;case 64>=b:g=[11,b-49,4];break;case 96>=b:g=[12,b-
  22
+65,5];break;case 128>=b:g=[13,b-97,5];break;case 192>=b:g=[14,b-129,6];break;case 256>=b:g=[15,b-193,6];break;case 384>=b:g=[16,b-257,7];break;case 512>=b:g=[17,b-385,7];break;case 768>=b:g=[18,b-513,8];break;case 1024>=b:g=[19,b-769,8];break;case 1536>=b:g=[20,b-1025,9];break;case 2048>=b:g=[21,b-1537,9];break;case 3072>=b:g=[22,b-2049,10];break;case 4096>=b:g=[23,b-3073,10];break;case 6144>=b:g=[24,b-4097,11];break;case 8192>=b:g=[25,b-6145,11];break;case 12288>=b:g=[26,b-8193,12];break;case 16384>=
  23
+b:g=[27,b-12289,12];break;case 24576>=b:g=[28,b-16385,13];break;case 32768>=b:g=[29,b-24577,13];break;default:i("invalid distance")}f=g;d[e++]=f[0];d[e++]=f[1];d[e++]=f[2];var h,j;h=0;for(j=d.length;h<j;++h)l[q++]=d[h];t[d[0]]++;z[d[3]]++;E=a.length+c-1;n=null}var e,f,d,g,h,m={},j,s,n,l=H?new Uint16Array(2*c.length):[],q=0,E=0,t=new (H?Uint32Array:Array)(286),z=new (H?Uint32Array:Array)(30),K=a.w,A;if(!H){for(d=0;285>=d;)t[d++]=0;for(d=0;29>=d;)z[d++]=0}t[256]=1;e=0;for(f=c.length;e<f;++e){d=h=0;
  24
+for(g=3;d<g&&e+d!==f;++d)h=h<<8|c[e+d];m[h]===r&&(m[h]=[]);j=m[h];if(!(0<E--)){for(;0<j.length&&32768<e-j[0];)j.shift();if(e+3>=f){n&&b(n,-1);d=0;for(g=f-e;d<g;++d)A=c[e+d],l[q++]=A,++t[A];break}if(0<j.length){var x=r,B=r,k=0,p=r,D=r,C=r,da=r,W=c.length,D=0,da=j.length;a:for(;D<da;D++){x=j[da-D-1];p=3;if(3<k){for(C=k;3<C;C--)if(c[x+C-1]!==c[e+C-1])continue a;p=k}for(;258>p&&e+p<W&&c[x+p]===c[e+p];)++p;p>k&&(B=x,k=p);if(258===p)break}s=new wa(k,e-B);n?n.length<s.length?(A=c[e-1],l[q++]=A,++t[A],b(s,
  25
+0)):b(n,-1):s.length<K?n=s:b(s,0)}else n?b(n,-1):(A=c[e],l[q++]=A,++t[A])}j.push(e)}l[q++]=256;t[256]++;a.L=t;a.K=z;return H?l.subarray(0,q):l}
  26
+function ta(a,c){function b(a){var c=z[a][K[a]];c===n?(b(a+1),b(a+1)):--E[c];++K[a]}var e=a.length,f=new la(572),d=new (H?Uint8Array:Array)(e),g,h,m,j,s;if(!H)for(j=0;j<e;j++)d[j]=0;for(j=0;j<e;++j)0<a[j]&&f.push(j,a[j]);g=Array(f.length/2);h=new (H?Uint32Array:Array)(f.length/2);if(1===g.length)return d[f.pop().index]=1,d;j=0;for(s=f.length/2;j<s;++j)g[j]=f.pop(),h[j]=g[j].value;var n=h.length,l=new (H?Uint16Array:Array)(c),q=new (H?Uint8Array:Array)(c),E=new (H?Uint8Array:Array)(n),t=Array(c),z=
  27
+Array(c),K=Array(c),A=(1<<c)-n,x=1<<c-1,B,k,p,D,C;l[c-1]=n;for(k=0;k<c;++k)A<x?q[k]=0:(q[k]=1,A-=x),A<<=1,l[c-2-k]=(l[c-1-k]/2|0)+n;l[0]=q[0];t[0]=Array(l[0]);z[0]=Array(l[0]);for(k=1;k<c;++k)l[k]>2*l[k-1]+q[k]&&(l[k]=2*l[k-1]+q[k]),t[k]=Array(l[k]),z[k]=Array(l[k]);for(B=0;B<n;++B)E[B]=c;for(p=0;p<l[c-1];++p)t[c-1][p]=h[p],z[c-1][p]=p;for(B=0;B<c;++B)K[B]=0;1===q[c-1]&&(--E[0],++K[c-1]);for(k=c-2;0<=k;--k){D=B=0;C=K[k+1];for(p=0;p<l[k];p++)D=t[k+1][C]+t[k+1][C+1],D>h[B]?(t[k][p]=D,z[k][p]=n,C+=2):
  28
+(t[k][p]=h[B],z[k][p]=B,++B);K[k]=0;1===q[k]&&b(k)}m=E;j=0;for(s=g.length;j<s;++j)d[g[j].index]=m[j];return d}function ua(a){var c=new (H?Uint16Array:Array)(a.length),b=[],e=[],f=0,d,g,h,m;d=0;for(g=a.length;d<g;d++)b[a[d]]=(b[a[d]]|0)+1;d=1;for(g=16;d<=g;d++)e[d]=f,f+=b[d]|0,f>1<<d&&i("overcommitted"),f<<=1;65536>f&&i("undercommitted");d=0;for(g=a.length;d<g;d++){f=e[a[d]];e[a[d]]+=1;h=c[d]=0;for(m=a[d];h<m;h++)c[d]=c[d]<<1|f&1,f>>>=1}return c};function Da(a,c){this.input=a;this.a=new (H?Uint8Array:Array)(32768);this.h=U.j;var b={},e;if((c||!(c={}))&&"number"===typeof c.compressionType)this.h=c.compressionType;for(e in c)b[e]=c[e];b.outputBuffer=this.a;this.z=new ma(this.input,b)}var U=qa;
  29
+Da.prototype.n=function(){var a,c,b,e,f,d,g,h=0;g=this.a;a=Ea;switch(a){case Ea:c=Math.LOG2E*Math.log(32768)-8;break;default:i(Error("invalid compression method"))}b=c<<4|a;g[h++]=b;switch(a){case Ea:switch(this.h){case U.NONE:f=0;break;case U.r:f=1;break;case U.j:f=2;break;default:i(Error("unsupported compression type"))}break;default:i(Error("invalid compression method"))}e=f<<6|0;g[h++]=e|31-(256*b+e)%31;d=ba(this.input);this.z.b=h;g=this.z.n();h=g.length;H&&(g=new Uint8Array(g.buffer),g.length<=
  30
+h+4&&(this.a=new Uint8Array(g.length+4),this.a.set(g),g=this.a),g=g.subarray(0,h+4));g[h++]=d>>24&255;g[h++]=d>>16&255;g[h++]=d>>8&255;g[h++]=d&255;return g};y("Zlib.Deflate",Da);y("Zlib.Deflate.compress",function(a,c){return(new Da(a,c)).n()});y("Zlib.Deflate.CompressionType",U);y("Zlib.Deflate.CompressionType.NONE",U.NONE);y("Zlib.Deflate.CompressionType.FIXED",U.r);y("Zlib.Deflate.CompressionType.DYNAMIC",U.j);function V(a,c){this.k=[];this.l=32768;this.e=this.g=this.c=this.q=0;this.input=H?new Uint8Array(a):a;this.s=!1;this.m=Fa;this.B=!1;if(c||!(c={}))c.index&&(this.c=c.index),c.bufferSize&&(this.l=c.bufferSize),c.bufferType&&(this.m=c.bufferType),c.resize&&(this.B=c.resize);switch(this.m){case Ga:this.b=32768;this.a=new (H?Uint8Array:Array)(32768+this.l+258);break;case Fa:this.b=0;this.a=new (H?Uint8Array:Array)(this.l);this.f=this.J;this.t=this.H;this.o=this.I;break;default:i(Error("invalid inflate mode"))}}
  31
+var Ga=0,Fa=1,Ha={D:Ga,C:Fa};
  32
+V.prototype.p=function(){for(;!this.s;){var a=X(this,3);a&1&&(this.s=v);a>>>=1;switch(a){case 0:var c=this.input,b=this.c,e=this.a,f=this.b,d=r,g=r,h=r,m=e.length,j=r;this.e=this.g=0;d=c[b++];d===r&&i(Error("invalid uncompressed block header: LEN (first byte)"));g=d;d=c[b++];d===r&&i(Error("invalid uncompressed block header: LEN (second byte)"));g|=d<<8;d=c[b++];d===r&&i(Error("invalid uncompressed block header: NLEN (first byte)"));h=d;d=c[b++];d===r&&i(Error("invalid uncompressed block header: NLEN (second byte)"));h|=
  33
+d<<8;g===~h&&i(Error("invalid uncompressed block header: length verify"));b+g>c.length&&i(Error("input buffer is broken"));switch(this.m){case Ga:for(;f+g>e.length;){j=m-f;g-=j;if(H)e.set(c.subarray(b,b+j),f),f+=j,b+=j;else for(;j--;)e[f++]=c[b++];this.b=f;e=this.f();f=this.b}break;case Fa:for(;f+g>e.length;)e=this.f({v:2});break;default:i(Error("invalid inflate mode"))}if(H)e.set(c.subarray(b,b+g),f),f+=g,b+=g;else for(;g--;)e[f++]=c[b++];this.c=b;this.b=f;this.a=e;break;case 1:this.o(Ia,Ja);break;
  34
+case 2:Ka(this);break;default:i(Error("unknown BTYPE: "+a))}}return this.t()};
  35
+var La=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Za=H?new Uint16Array(La):La,$a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],ab=H?new Uint16Array($a):$a,bb=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],cb=H?new Uint8Array(bb):bb,db=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],eb=H?new Uint16Array(db):db,fb=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,
  36
+10,11,11,12,12,13,13],gb=H?new Uint8Array(fb):fb,hb=new (H?Uint8Array:Array)(288),Y,ib;Y=0;for(ib=hb.length;Y<ib;++Y)hb[Y]=143>=Y?8:255>=Y?9:279>=Y?7:8;var Ia=S(hb),jb=new (H?Uint8Array:Array)(30),kb,lb;kb=0;for(lb=jb.length;kb<lb;++kb)jb[kb]=5;var Ja=S(jb);function X(a,c){for(var b=a.g,e=a.e,f=a.input,d=a.c,g;e<c;)g=f[d++],g===r&&i(Error("input buffer is broken")),b|=g<<e,e+=8;g=b&(1<<c)-1;a.g=b>>>c;a.e=e-c;a.c=d;return g}
  37
+function mb(a,c){for(var b=a.g,e=a.e,f=a.input,d=a.c,g=c[0],h=c[1],m,j,s;e<h;)m=f[d++],m===r&&i(Error("input buffer is broken")),b|=m<<e,e+=8;j=g[b&(1<<h)-1];s=j>>>16;a.g=b>>s;a.e=e-s;a.c=d;return j&65535}
  38
+function Ka(a){function c(a,b,c){var d,e,f,g;for(g=0;g<a;)switch(d=mb(this,b),d){case 16:for(f=3+X(this,2);f--;)c[g++]=e;break;case 17:for(f=3+X(this,3);f--;)c[g++]=0;e=0;break;case 18:for(f=11+X(this,7);f--;)c[g++]=0;e=0;break;default:e=c[g++]=d}return c}var b=X(a,5)+257,e=X(a,5)+1,f=X(a,4)+4,d=new (H?Uint8Array:Array)(Za.length),g,h,m,j;for(j=0;j<f;++j)d[Za[j]]=X(a,3);g=S(d);h=new (H?Uint8Array:Array)(b);m=new (H?Uint8Array:Array)(e);a.o(S(c.call(a,b,g,h)),S(c.call(a,e,g,m)))}
  39
+V.prototype.o=function(a,c){var b=this.a,e=this.b;this.u=a;for(var f=b.length-258,d,g,h,m;256!==(d=mb(this,a));)if(256>d)e>=f&&(this.b=e,b=this.f(),e=this.b),b[e++]=d;else{g=d-257;m=ab[g];0<cb[g]&&(m+=X(this,cb[g]));d=mb(this,c);h=eb[d];0<gb[d]&&(h+=X(this,gb[d]));e>=f&&(this.b=e,b=this.f(),e=this.b);for(;m--;)b[e]=b[e++-h]}for(;8<=this.e;)this.e-=8,this.c--;this.b=e};
  40
+V.prototype.I=function(a,c){var b=this.a,e=this.b;this.u=a;for(var f=b.length,d,g,h,m;256!==(d=mb(this,a));)if(256>d)e>=f&&(b=this.f(),f=b.length),b[e++]=d;else{g=d-257;m=ab[g];0<cb[g]&&(m+=X(this,cb[g]));d=mb(this,c);h=eb[d];0<gb[d]&&(h+=X(this,gb[d]));e+m>f&&(b=this.f(),f=b.length);for(;m--;)b[e]=b[e++-h]}for(;8<=this.e;)this.e-=8,this.c--;this.b=e};
  41
+V.prototype.f=function(){var a=new (H?Uint8Array:Array)(this.b-32768),c=this.b-32768,b,e,f=this.a;if(H)a.set(f.subarray(32768,a.length));else{b=0;for(e=a.length;b<e;++b)a[b]=f[b+32768]}this.k.push(a);this.q+=a.length;if(H)f.set(f.subarray(c,c+32768));else for(b=0;32768>b;++b)f[b]=f[c+b];this.b=32768;return f};
  42
+V.prototype.J=function(a){var c,b=this.input.length/this.c+1|0,e,f,d,g=this.input,h=this.a;a&&("number"===typeof a.v&&(b=a.v),"number"===typeof a.F&&(b+=a.F));2>b?(e=(g.length-this.c)/this.u[2],d=258*(e/2)|0,f=d<h.length?h.length+d:h.length<<1):f=h.length*b;H?(c=new Uint8Array(f),c.set(h)):c=h;return this.a=c};
  43
+V.prototype.t=function(){var a=0,c=this.a,b=this.k,e,f=new (H?Uint8Array:Array)(this.q+(this.b-32768)),d,g,h,m;if(0===b.length)return H?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);d=0;for(g=b.length;d<g;++d){e=b[d];h=0;for(m=e.length;h<m;++h)f[a++]=e[h]}d=32768;for(g=this.b;d<g;++d)f[a++]=c[d];this.k=[];return this.buffer=f};
  44
+V.prototype.H=function(){var a,c=this.b;H?this.B?(a=new Uint8Array(c),a.set(this.a.subarray(0,c))):a=this.a.subarray(0,c):(this.a.length>c&&(this.a.length=c),a=this.a);return this.buffer=a};function nb(a,c){var b,e;this.input=a;this.c=0;if(c||!(c={}))c.index&&(this.c=c.index),c.verify&&(this.M=c.verify);b=a[this.c++];e=a[this.c++];switch(b&15){case Ea:this.method=Ea;break;default:i(Error("unsupported compression method"))}0!==((b<<8)+e)%31&&i(Error("invalid fcheck flag:"+((b<<8)+e)%31));e&32&&i(Error("fdict flag is not supported"));this.A=new V(a,{index:this.c,bufferSize:c.bufferSize,bufferType:c.bufferType,resize:c.resize})}
  45
+nb.prototype.p=function(){var a=this.input,c,b;c=this.A.p();this.c=this.A.c;this.M&&(b=(a[this.c++]<<24|a[this.c++]<<16|a[this.c++]<<8|a[this.c++])>>>0,b!==ba(c)&&i(Error("invalid adler-32 checksum")));return c};y("Zlib.Inflate",nb);y("Zlib.Inflate.BufferType",Ha);Ha.ADAPTIVE=Ha.C;Ha.BLOCK=Ha.D;y("Zlib.Inflate.prototype.decompress",nb.prototype.p);var ob=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];H&&new Uint16Array(ob);var pb=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258];H&&new Uint16Array(pb);var qb=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0];H&&new Uint8Array(qb);var rb=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];H&&new Uint16Array(rb);
  46
+var sb=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];H&&new Uint8Array(sb);var tb=new (H?Uint8Array:Array)(288),Z,ub;Z=0;for(ub=tb.length;Z<ub;++Z)tb[Z]=143>=Z?8:255>=Z?9:279>=Z?7:8;S(tb);var vb=new (H?Uint8Array:Array)(30),wb,xb;wb=0;for(xb=vb.length;wb<xb;++wb)vb[wb]=5;S(vb);var Ea=8;}).call(this);
18  cocos2d/tileMap_parallax_nodes/CCTMXLayer.js
@@ -415,13 +415,13 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
415 415
     getPositionAt:function (pos) {
416 416
         var ret = cc.PointZero();
417 417
         switch (this._layerOrientation) {
418  
-            case cc.TMXOrientationOrtho:
  418
+            case cc.TMX_ORIENTATION_ORTHO:
419 419
                 ret = this._positionForOrthoAt(pos);
420 420
                 break;
421  
-            case cc.TMXOrientationIso:
  421
+            case cc.TMX_ORIENTATION_ISO:
422 422
                 ret = this._positionForIsoAt(pos);
423 423
                 break;
424  
-            case cc.TMXOrientationHex:
  424
+            case cc.TMX_ORIENTATION_HEX:
425 425
                 ret = this._positionForHexAt(pos);
426 426
                 break;
427 427
         }
@@ -550,14 +550,14 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
550 550
     _calculateLayerOffset:function (pos) {
551 551
         var ret = cc.PointZero();
552 552
         switch (this._layerOrientation) {
553  
-            case cc.TMXOrientationOrtho:
  553
+            case cc.TMX_ORIENTATION_ORTHO:
554 554
                 ret = cc.p(pos.x * this._mapTileSize.width, -pos.y * this._mapTileSize.height);
555 555
                 break;
556  
-            case cc.TMXOrientationIso:
  556
+            case cc.TMX_ORIENTATION_ISO:
557 557
                 ret = cc.p((this._mapTileSize.width / 2) * (pos.x - pos.y),
558 558
                     (this._mapTileSize.height / 2 ) * (-pos.x - pos.y));
559 559
                 break;
560  
-            case cc.TMXOrientationHex:
  560
+            case cc.TMX_ORIENTATION_HEX:
561 561
                 ret = cc.p(0, 0);
562 562
                 cc.log("cocos2d:offset for hexagonal map not implemented yet");
563 563
                 break;
@@ -728,14 +728,14 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
728 728
         var maxVal = 0;
729 729
         if (this._useAutomaticVertexZ) {
730 730
             switch (this._layerOrientation) {
731  
-                case cc.TMXOrientationIso:
  731
+                case cc.TMX_ORIENTATION_ISO:
732 732
                     maxVal = this._layerSize.width + this._layerSize.height;
733 733
                     ret = -(maxVal - (pos.x + pos.y));
734 734
                     break;
735  
-                case cc.TMXOrientationOrtho:
  735
+                case cc.TMX_ORIENTATION_ORTHO:
736 736
                     ret = -(this._layerSize.height - pos.y);
737 737
                     break;
738  
-                case cc.TMXOrientationHex:
  738
+                case cc.TMX_ORIENTATION_HEX:
739 739
                     cc.Assert(0, "TMX Hexa zOrder not supported");
740 740
                     break;
741 741
                 default:
6  cocos2d/tileMap_parallax_nodes/CCTMXTiledMap.js
@@ -29,7 +29,7 @@
29 29
  * @constant
30 30
  * @type Number
31 31
  */
32  
-cc.TMXOrientationOrtho = 0;
  32
+cc.TMX_ORIENTATION_ORTHO = 0;
33 33
 
34 34
 /**
35 35
  * Hexagonal orientation
@@ -37,14 +37,14 @@ cc.TMXOrientationOrtho = 0;
37 37
  * @type Number
38 38
  */
39 39
 
40  
-cc.TMXOrientationHex = 1;
  40
+cc.TMX_ORIENTATION_HEX = 1;
41 41
 
42 42
 /**
43 43
  * Isometric orientation
44 44
  * @constant
45 45
  * @type Number
46 46
  */
47  
-cc.TMXOrientationIso = 2;
  47
+cc.TMX_ORIENTATION_ISO = 2;
48 48
 
49 49
 /**
50 50
  * <p>cc.TMXTiledMap knows how to parse and render a TMX map.</p>
257  cocos2d/tileMap_parallax_nodes/CCTMXXMLParser.js
@@ -28,58 +28,58 @@
28 28
  * @constant
29 29
  * @type Number
30 30
  */
31  
-cc.TMXLayerAttribNone = 1 << 0;
  31
+cc.TMX_LAYER_ATTRIB_NONE = 1 << 0;
32 32
 /**
33 33
  * @constant
34 34
  * @type Number
35 35
  */
36  
-cc.TMXLayerAttribBase64 = 1 << 1;
  36
+cc.TMX_LAYER_ATTRIB_BASE64 = 1 << 1;
37 37
 /**
38 38
  * @constant
39 39
  * @type Number
40 40
  */
41  
-cc.TMXLayerAttribGzip = 1 << 2;
  41
+cc.TMX_LAYER_ATTRIB_GZIP = 1 << 2;
42 42
 /**
43 43
  * @constant
44 44
  * @type Number
45 45
  */
46  
-cc.TMXLayerAttribZlib = 1 << 3;
  46
+cc.TMX_LAYER_ATTRIB_ZLIB = 1 << 3;
47 47
 
48 48
 /**
49 49
  * @constant
50 50
  * @type Number
51 51
  */
52  
-cc.TMXPropertyNone = 0;
  52
+cc.TMX_PROPERTY_NONE = 0;
53 53
 
54 54
 /**
55 55
  * @constant
56 56
  * @type Number
57 57
  */
58  
-cc.TMXPropertyMap = 1;
  58
+cc.TMX_PROPERTY_MAP = 1;
59 59
 
60 60
 /**
61 61
  * @constant
62 62
  * @type Number
63 63
  */
64  
-cc.TMXPropertyLayer = 2;
  64
+cc.TMX_PROPERTY_LAYER = 2;
65 65
 
66 66
 /**
67 67
  * @constant
68 68
  * @type Number
69 69
  */
70  
-cc.TMXPropertyObjectGroup = 3;
  70
+cc.TMX_PROPERTY_OBJECTGROUP = 3;
71 71
 
72 72
 /**
73 73
  * @constant
74 74
  * @type Number
75 75
  */
76  
-cc.TMXPropertyObject = 4;
  76
+cc.TMX_PROPERTY_OBJECT = 4;
77 77
 
78 78
 /**
79 79
  * @constant
80 80
  * @type Number
81 81
  */
82  
-cc.TMXPropertyTile = 5;
  82
+cc.TMX_PROPERTY_TILE = 5;
83 83
 
84 84
 /**
85 85
  * @constant
@@ -436,6 +436,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
436 436
      */
437 437
     parseXMLFile:function (tmxFile) {
438 438
         var mapXML = cc.SAXParser.getInstance().tmxParse(tmxFile);
  439
+        var i, j;
439 440
 
440 441
         // PARSE <map>
441 442
         var map = mapXML.documentElement;
@@ -444,78 +445,71 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
444 445
         var orientationStr = map.getAttribute('orientation');
445 446
 
446 447
         if (map.nodeName == "map") {
447  
-            if (version != "1.0" && version !== null) {
  448
+            if (version != "1.0" && version !== null)
448 449
                 cc.log("cocos2d: TMXFormat: Unsupported TMX version:" + version);
449  
-            }
450 450
 
451 451
             if (orientationStr == "orthogonal")
452  
-                this.setOrientation(cc.TMXOrientationOrtho);
  452
+                this.setOrientation(cc.TMX_ORIENTATION_ORTHO);
453 453
             else if (orientationStr == "isometric")
454  
-                this.setOrientation(cc.TMXOrientationIso);
  454
+                this.setOrientation(cc.TMX_ORIENTATION_ISO);
455 455
             else if (orientationStr == "hexagonal")
456  
-                this.setOrientation(cc.TMXOrientationHex);
  456
+                this.setOrientation(cc.TMX_ORIENTATION_HEX);
457 457
             else if (orientationStr !== null)
458 458
                 cc.log("cocos2d: TMXFomat: Unsupported orientation:" + this.getOrientation());
459 459
 
460  
-            var s = cc.size(0, 0);
461  
-            s.width = parseFloat(map.getAttribute('width'));
462  
-            s.height = parseFloat(map.getAttribute('height'));
463  
-            this.setMapSize(s);
  460
+            var mapSize = cc.size(0, 0);
  461
+            mapSize.width = parseFloat(map.getAttribute('width'));
  462
+            mapSize.height = parseFloat(map.getAttribute('height'));
  463
+            this.setMapSize(mapSize);
464 464
 
465  
-            s = cc.size(0, 0);
466  
-            s.width = parseFloat(map.getAttribute('tilewidth'));
467  
-            s.height = parseFloat(map.getAttribute('tileheight'));
468  
-            this.setTileSize(s)
  465
+            mapSize = cc.size(0, 0);
  466
+            mapSize.width = parseFloat(map.getAttribute('tilewidth'));
  467
+            mapSize.height = parseFloat(map.getAttribute('tileheight'));
  468
+            this.setTileSize(mapSize);
469 469
 
470 470
             // The parent element is the map
471  
-            var mp = map.querySelectorAll("map > properties >  property");
472  
-            if (mp) {
473  
-                for (var k = 0; k < mp.length; k++) {
474  
-                    var dict = {};
475  
-                    var name = mp[k].getAttribute('name');
476  
-                    var value = mp[k].getAttribute('value');
477  
-                    dict[name] = value;
478  
-                    this.setProperties(dict);
  471
+            var propertyArr = map.querySelectorAll("map > properties >  property");
  472
+            if (propertyArr) {
  473
+                for (i = 0; i < propertyArr.length; i++) {
  474
+                    var aProperty = {};
  475
+                    aProperty[propertyArr[i].getAttribute('name')] = propertyArr[i].getAttribute('value');
  476
+                    this.setProperties(aProperty);
479 477
                 }
480 478
             }
481 479
         }
482 480
 
483  
-        //todo fixed
484 481
         // PARSE <tileset>
485 482
         var tilesets = map.getElementsByTagName('tileset');
486 483
         if (map.nodeName !== "map") {
487  
-            tilesets = []
  484
+            tilesets = [];
488 485
             tilesets.push(map);
489 486
         }
490 487
 
491  
-        for (var i = 0, len = tilesets.length; i < len; i++) {
492  
-            var t = tilesets[i];
  488
+        for (i = 0; i < tilesets.length; i++) {
  489
+            var selTileset = tilesets[i];
493 490
             // If this is an external tileset then start parsing that
494  
-            var externalTilesetFilename = t.getAttribute('source');
  491
+            var externalTilesetFilename = selTileset.getAttribute('source');
495 492
             if (externalTilesetFilename) {
496 493
                 this.parseXMLFile(cc.FileUtils.getInstance().fullPathFromRelativeFile(externalTilesetFilename, tmxFile));
497  
-            }
498  
-            else {
  494
+            } else {
499 495
                 var tileset = new cc.TMXTilesetInfo();
500  
-                tileset.name = t.getAttribute('name') || "";
501  
-                tileset.firstGid = parseInt(t.getAttribute('firstgid')) || 1;
502  
-                tileset.spacing = parseInt(t.getAttribute('spacing')) || 0;
503  
-                tileset.margin = parseInt(t.getAttribute('margin')) || 0;
  496
+                tileset.name = selTileset.getAttribute('name') || "";
  497
+                tileset.firstGid = parseInt(selTileset.getAttribute('firstgid')) || 1;
  498
+                tileset.spacing = parseInt(selTileset.getAttribute('spacing')) || 0;
  499
+                tileset.margin = parseInt(selTileset.getAttribute('margin')) || 0;
504 500
 
505  
-                var s = cc.size(0, 0);
506  
-                s.width = parseFloat(t.getAttribute('tilewidth'));
507  
-                s.height = parseFloat(t.getAttribute('tileheight'));
508  
-                tileset._tileSize = s;
  501
+                var tilesetSize = cc.size(0, 0);
  502
+                tilesetSize.width = parseFloat(selTileset.getAttribute('tilewidth'));
  503
+                tilesetSize.height = parseFloat(selTileset.getAttribute('tileheight'));
  504
+                tileset._tileSize = tilesetSize;
509 505
 
510  
-                var image = t.getElementsByTagName('image')[0];
  506
+                var image = selTileset.getElementsByTagName('image')[0];
511 507
                 var imgSource = image.getAttribute('source');
512 508
                 if (imgSource) {
513  
-                    if (this._resources) {
  509
+                    if (this._resources)
514 510
                         imgSource = this._resources + "/" + imgSource;
515  
-                    }
516  
-                    else {
  511
+                    else
517 512
                         imgSource = cc.FileUtils.getInstance().fullPathFromRelativeFile(imgSource, tmxFile);
518  
-                    }
519 513
                 }
520 514
                 tileset.sourceImage = imgSource;
521 515
                 this.setTilesets(tileset);
@@ -525,18 +519,16 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
525 519
         // PARSE  <tile>
526 520
         var tiles = map.querySelectorAll('tile');
527 521
         if (tiles) {
528  
-            for (var i = 0, len = tiles.length; i < len; i++) {
  522
+            for (i = 0; i < tiles.length; i++) {
529 523
                 var info = this._tileSets[0];
530  
-                var t = tiles[i];
531  
-                this.setParentGID(parseInt(info.firstGid) + parseInt(t.getAttribute('id') || 0));
532  
-                var tp = t.querySelectorAll("properties > property")[0];
  524
+                var selTile = tiles[i];
  525
+                this.setParentGID(parseInt(info.firstGid) + parseInt(selTile.getAttribute('id') || 0));
  526
+                var tp = selTile.querySelectorAll("properties > property")[0];
533 527
 
534 528
                 if (tp) {
535  
-                    var dict = {};
536  
-                    var name = tp.getAttribute('name');
537  
-                    var value = tp.getAttribute('value');
538  
-                    dict[name] = value;
539  
-                    this._tileProperties[this.getParentGID()] = dict;
  529
+                    var tileProp = {};
  530
+                    tileProp[tp.getAttribute('name')] = tp.getAttribute('value');
  531
+                    this._tileProperties[this.getParentGID()] = tileProp;
540 532
                 }
541 533
             }
542 534
         }
@@ -544,144 +536,123 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
544 536
         // PARSE  <layer>
545 537
         var layers = map.getElementsByTagName('layer');
546 538
         if (layers) {
547  
-            for (var i = 0, len = layers.length; i < len; i++) {
548  
-                var l = layers[i];
549  
-                var data = l.getElementsByTagName('data')[0];
  539
+            for (i = 0; i < layers.length; i++) {
  540
+                var selLayer = layers[i];
  541
+                var data = selLayer.getElementsByTagName('data')[0];
550 542
 
551 543
                 var layer = new cc.TMXLayerInfo();
552  
-                layer.name = l.getAttribute('name');
  544
+                layer.name = selLayer.getAttribute('name');
553 545
 
554  
-                var s = cc.size(0, 0);
555  
-                s.width = parseFloat(l.getAttribute('width'));
556  
-                s.height = parseFloat(l.getAttribute('height'));
557  
-                layer._layerSize = s;
  546
+                var layerSize = cc.size(0, 0);
  547
+                layerSize.width = parseFloat(selLayer.getAttribute('width'));
  548
+                layerSize.height = parseFloat(selLayer.getAttribute('height'));
  549
+                layer._layerSize = layerSize;
558 550
 
559  
-                var visible = l.getAttribute('visible')
  551
+                var visible = selLayer.getAttribute('visible');
560 552
                 layer.visible = !(visible == "0");
561 553
 
562  
-                var opacity = l.getAttribute('opacity') || 1;
  554
+                var opacity = selLayer.getAttribute('opacity') || 1;
563 555
 
564  
-                if (opacity) {
  556
+                if (opacity)
565 557
                     layer._opacity = parseInt(255 * parseFloat(opacity));
566  
-                }
567  
-                else {
  558
+                else
568 559
                     layer._opacity = 255;
569  
-                }
  560
+                layer.offset = cc.p(parseFloat(selLayer.getAttribute('x')) || 0, parseFloat(selLayer.getAttribute('y')) || 0);
570 561
 
571  
-                var x = parseFloat(l.getAttribute('x')) || 0;
572  
-                var y = parseFloat(l.getAttribute('y')) || 0;
573  
-                layer.offset = cc.p(x, y);
574  
-
575  
-                var nodeValue = ''
576  
-                for (var j = 0; j < data.childNodes.length; j++) {
  562
+                var nodeValue = '';
  563
+                for ( j = 0; j < data.childNodes.length; j++) {
577 564
                     nodeValue += data.childNodes[j].nodeValue
578 565
                 }
  566
+                nodeValue = nodeValue.trim();
579 567
 
580 568
                 // Unpack the tilemap data
581 569
                 var compression = data.getAttribute('compression');
582 570
                 var encoding = data.getAttribute('encoding');
583  
-                cc.Assert(compression == null || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method");
  571
+                cc.Assert(compression == null || compression === "gzip" || compression === "zlib", "TMX: unsupported compression method");
584 572
                 switch (compression) {
585 573
                     case 'gzip':
586 574
                         layer._tiles = cc.unzipBase64AsArray(nodeValue, 4);
587 575
                         break;
588 576
                     case 'zlib':
589  
-                        //Not Implemented
  577
+                        var inflator = new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(nodeValue,1));
  578
+                        layer._tiles = cc.uint8ArrayToUint32Array(inflator.decompress());
590 579
                         break;
591  
-                    // Uncompressed
592 580
                     case null:
593 581
                     case '':
594  
-                        if (encoding == "base64") {
  582
+                        // Uncompressed
  583
+                        if (encoding == "base64")
595 584
                             layer._tiles = cc.Codec.Base64.decodeAsArray(nodeValue, 4);
596  
-                        }
597  
-                        else {
  585
+                        else
598 586
                             layer._tiles = cc.StringToArray(nodeValue);
599  
-                        }
600 587
                         break;
601 588
                     default:
602  
-                        cc.Assert(this.getLayerAttribs() != cc.TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported");
  589
+                        cc.Assert(this.getLayerAttribs() != cc.TMX_LAYER_ATTRIB_NONE, "TMX tile map: Only base64 and/or gzip/zlib maps are supported");
603 590
                 }
604 591
 
605 592
                 // The parent element is the last layer
606  
-                var lp = l.querySelectorAll("properties > property");
607  
-                if (lp) {
608  
-                    for (var k = 0; k < lp.length; k++) {
609  
-                        var dict = {};
610  
-                        var name = lp[k].getAttribute('name');
611  
-                        var value = lp[k].getAttribute('value');
612  
-                        dict[name] = value;
613  
-
614  
-                        layer.setProperties(dict);
  593
+                var layerProps = selLayer.querySelectorAll("properties > property");
  594
+                if (layerProps) {
  595
+                    for (j = 0; j < layerProps.length; j++) {
  596
+                        var layerProp = {};
  597
+                        layerProp[layerProps[j].getAttribute('name')] = layerProps[j].getAttribute('value');
  598
+                        layer.setProperties(layerProp);
615 599
                     }
616 600
                 }
617  
-
618 601
                 this.setLayers(layer);
619 602
             }
620 603
         }
621 604
 
622 605
         // PARSE <objectgroup>
623  
-        var objectgroups = map.getElementsByTagName('objectgroup');
624  
-        if (objectgroups) {
625  
-
626  
-            for (var i = 0; i < objectgroups.length; i++) {
627  
-                var g = objectgroups[i];
  606
+        var objectGroups = map.getElementsByTagName('objectgroup');
  607
+        if (objectGroups) {
  608
+            for (i = 0; i < objectGroups.length; i++) {
  609
+                var selGroup = objectGroups[i];
628 610
                 var objectGroup = new cc.TMXObjectGroup();
629  
-                objectGroup.setGroupName(g.getAttribute('name'));
630  
-                var positionOffset = cc.p(0, 0);
631  
-                positionOffset.x = parseFloat(g.getAttribute('x')) * this.getTileSize().width || 0;
632  
-                positionOffset.y = parseFloat(g.getAttribute('y')) * this.getTileSize().height || 0;
633  
-                objectGroup.setPositionOffset(positionOffset);
634  
-
635  
-                var gp = g.querySelectorAll("objectgroup > properties > property");
636  
-                if (gp) {
637  
-                    for (var k = 0; k < gp.length; k++) {
638  
-                        var dict = {};
639  
-                        var name = gp[k].getAttribute('name');
640  
-                        var value = gp[k].getAttribute('value');
641  
-                        dict[name] = value;
642  
-
  611
+                objectGroup.setGroupName(selGroup.getAttribute('name'));
  612
+                objectGroup.setPositionOffset(cc.p(parseFloat(selGroup.getAttribute('x')) * this.getTileSize().width || 0,
  613
+                    parseFloat(selGroup.getAttribute('y')) * this.getTileSize().height || 0));
  614
+
  615
+                var groupProps = selGroup.querySelectorAll("objectgroup > properties > property");
  616
+                if (groupProps) {
  617
+                    for (j = 0; j < groupProps.length; j++) {
  618
+                        var groupProp = {};
  619
+                        groupProp[groupProps[j].getAttribute('name')] = groupProps[j].getAttribute('value');
643 620
                         // Add the property to the layer
644  
-                        objectGroup.setProperties(dict);
  621
+                        objectGroup.setProperties(groupProp);
645 622
                     }
646 623
                 }
647 624
 
648  
-                var objects = g.querySelectorAll('object')
  625
+                var objects = selGroup.querySelectorAll('object');
649 626
                 if (objects) {
650  
-                    for (var j = 0; j < objects.length; j++) {
651  
-                        var o = objects[j]
  627
+                    for (j = 0; j < objects.length; j++) {
  628
+                        var selObj = objects[j];
652 629
                         // The value for "type" was blank or not a valid class name
653 630
                         // Create an instance of TMXObjectInfo to store the object and its properties
654  
-                        var dict = {};
  631
+                        var objectProp = {};
655 632
 
656 633
                         // Set the name of the object to the value for "name"
657  
-                        dict["name"] = o.getAttribute('name') || "";
  634
+                        objectProp["name"] = selObj.getAttribute('name') || "";
658 635
 
659 636
                         // Assign all the attributes as key/name pairs in the properties dictionary
660  
-                        dict["type"] = o.getAttribute('type') || "";
  637
+                        objectProp["type"] = selObj.getAttribute('type') || "";
661 638
 
662  
-                        dict["x"] = parseInt(o.getAttribute('x') || 0) + objectGroup.getPositionOffset().x;
  639
+                        objectProp["x"] = parseInt(selObj.getAttribute('x') || 0) + objectGroup.getPositionOffset().x;
  640
+                        var y = parseInt(selObj.getAttribute('y') || 0) + objectGroup.getPositionOffset().y;
663 641
 
664  
-                        var y = parseInt(o.getAttribute('y') || 0) + objectGroup.getPositionOffset().y;
665  
-
666  
-                        dict["width"] = parseInt(o.getAttribute('width')) || 0;
667  
-
668  
-                        dict["height"] = parseInt(o.getAttribute('height')) || 0;
  642
+                        objectProp["width"] = parseInt(selObj.getAttribute('width')) || 0;
  643
+                        objectProp["height"] = parseInt(selObj.getAttribute('height')) || 0;
669 644
 
670 645
                         // Correct y position. (Tiled uses Flipped, cocos2d uses Standard)
671  
-                        y = parseInt(this.getMapSize().height * this.getTileSize().height) - y - dict["height"];
672  
-                        dict["y"] = y;
673  
-
674  
-                        var op = o.querySelectorAll("properties > property");
675  
-                        if (op) {
676  
-                            for (var k = 0; k < op.length; k++) {
677  
-                                var name = op[k].getAttribute('name');
678  
-                                var value = op[k].getAttribute('value');
679  
-                                dict[name] = value;
680  
-                            }
  646
+                        objectProp["y"] = parseInt(this.getMapSize().height * this.getTileSize().height) - y - objectProp["height"];
  647
+
  648
+                        var docObjProps = selObj.querySelectorAll("properties > property");
  649
+                        if (docObjProps) {
  650
+                            for (var k = 0; k < docObjProps.length; k++)
  651
+                                objectProp[docObjProps[k].getAttribute('name')] = docObjProps[k].getAttribute('value');
681 652
                         }
682 653
 
683 654
                         // Add the object to the objectGroup
684  
-                        objectGroup.setObjects(dict);
  655
+                        objectGroup.setObjects(objectProp);
685 656
                     }
686 657
                 }
687 658
 
@@ -751,8 +722,8 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
751 722
         // tmp vars
752 723
         this._currentString = "";
753 724
         this._storingCharacters = false;
754  
-        this._layerAttribs = cc.TMXLayerAttribNone;
755  
-        this._parentElement = cc.TMXPropertyNone;
  725
+        this._layerAttribs = cc.TMX_LAYER_ATTRIB_NONE;
  726
+        this._parentElement = cc.TMX_PROPERTY_NONE;
756 727
     }
757 728
 });
758 729
 
28  licenses/LICENSE_zlib.js.txt
... ...
@@ -0,0 +1,28 @@
  1
+/**
  2
+ * @license
  3
+ * zlib.js
  4
+ * JavaScript Zlib Library
  5
+ * https://github.com/imaya/zlib.js
  6
+ *
  7
+ * The MIT License
  8
+ *
  9
+ * Copyright (c) 2012 imaya
  10
+ *
  11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
  12
+ * of this software and associated documentation files (the "Software"), to deal
  13
+ * in the Software without restriction, including without limitation the rights
  14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15
+ * copies of the Software, and to permit persons to whom the Software is
  16
+ * furnished to do so, subject to the following conditions:
  17
+ *
  18
+ * The above copyright notice and this permission notice shall be included in
  19
+ * all copies or substantial portions of the Software.
  20
+ *
  21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27
+ * THE SOFTWARE.
  28
+ */
1  template/build.xml
@@ -18,6 +18,7 @@
18 18
                 <file name="platform/CCMacro.js"/>
19 19
                 <file name="platform/CCFileUtils.js"/>
20 20
                 <file name="platform/CCTypes.js"/>
  21
+                <file name="platform/zlib.min.js"/>
21 22
                 <file name="cocoa/CCGeometry.js"/>
22 23
                 <file name="platform/CCConfig.js"/>
23 24
                 <file name="cocoa/CCNS.js"/>

0 notes on commit 533245c

Please sign in to comment.
Something went wrong with that request. Please try again.