Skip to content

Commit 533245c

Browse files
committed
fixed #700 add zlib support for cc.TMXXMLParser
1 parent 8c4f1a8 commit 533245c

File tree

12 files changed

+232
-158
lines changed

12 files changed

+232
-158
lines changed

HelloHTML5World/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<file name="platform/CCMacro.js"/>
1919
<file name="platform/CCFileUtils.js"/>
2020
<file name="platform/CCTypes.js"/>
21+
<file name="platform/zlib.min.js"/>
2122
<file name="cocoa/CCGeometry.js"/>
2223
<file name="platform/CCConfig.js"/>
2324
<file name="cocoa/CCNS.js"/>

chipmunk/chipmunk.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@
2727
};
2828

2929
//var VERSION = CP_VERSION_MAJOR + "." + CP_VERSION_MINOR + "." + CP_VERSION_RELEASE;
30-
3130
var cp;
3231
if(typeof exports === 'undefined'){
3332
cp = {};
3433

3534
if(typeof window === 'object'){
36-
window.cp = cp;
35+
window["cp"] = cp;
3736
}
3837
} else {
3938
cp = exports;
@@ -3370,7 +3369,7 @@
33703369

33713370
SegmentShape.prototype.collisionTable = [
33723371
null,
3373-
function(seg, seg) { return NONE; }, // seg2seg
3372+
function(seg, seg2) { return NONE; }, // seg2seg
33743373
seg2poly
33753374
];
33763375

cocos2d/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<file name="platform/CCMacro.js"/>
2222
<file name="platform/CCFileUtils.js"/>
2323
<file name="platform/CCTypes.js"/>
24+
<file name="platform/zlib.min.js"/>
2425
<file name="cocoa/CCGeometry.js"/>
2526
<file name="platform/CCConfig.js"/>
2627
<file name="cocoa/CCNS.js"/>

cocos2d/cocos2d_externs.js

+12
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@
1313
* @type {string}
1414
*/
1515
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;

cocos2d/platform/base64.js

+14
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ cc.Codec.Base64.decode = function Jacob__Codec__Base64__decode(input) {
6969
* var decodeArr = cc.Codec.Base64.decodeAsArray("U29tZSBTdHJpbmc=");
7070
*/
7171
cc.Codec.Base64.decodeAsArray = function Jacob__Codec__Base64___decodeAsArray(input, bytes) {
72+
bytes = bytes || 4;
7273
var dec = this.decode(input),
7374
ar = [], i, j, len;
7475
for (i = 0, len = dec.length / bytes; i < len; i++) {
@@ -115,3 +116,16 @@ cc.Codec.Base64.encode = function Jacob__Codec__Base64__encode(input) {
115116

116117
return output;
117118
};
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+
};

cocos2d/platform/jsloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'platform/CCMacro.js',
3737
'platform/CCFileUtils.js',
3838
'platform/CCTypes.js',
39+
'platform/zlib.min.js',
3940
'cocoa/CCGeometry.js',
4041
'platform/CCConfig.js',
4142
'cocoa/CCSet.js',

cocos2d/platform/zlib.min.js

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cocos2d/tileMap_parallax_nodes/CCTMXLayer.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
415415
getPositionAt:function (pos) {
416416
var ret = cc.PointZero();
417417
switch (this._layerOrientation) {
418-
case cc.TMXOrientationOrtho:
418+
case cc.TMX_ORIENTATION_ORTHO:
419419
ret = this._positionForOrthoAt(pos);
420420
break;
421-
case cc.TMXOrientationIso:
421+
case cc.TMX_ORIENTATION_ISO:
422422
ret = this._positionForIsoAt(pos);
423423
break;
424-
case cc.TMXOrientationHex:
424+
case cc.TMX_ORIENTATION_HEX:
425425
ret = this._positionForHexAt(pos);
426426
break;
427427
}
@@ -550,14 +550,14 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
550550
_calculateLayerOffset:function (pos) {
551551
var ret = cc.PointZero();
552552
switch (this._layerOrientation) {
553-
case cc.TMXOrientationOrtho:
553+
case cc.TMX_ORIENTATION_ORTHO:
554554
ret = cc.p(pos.x * this._mapTileSize.width, -pos.y * this._mapTileSize.height);
555555
break;
556-
case cc.TMXOrientationIso:
556+
case cc.TMX_ORIENTATION_ISO:
557557
ret = cc.p((this._mapTileSize.width / 2) * (pos.x - pos.y),
558558
(this._mapTileSize.height / 2 ) * (-pos.x - pos.y));
559559
break;
560-
case cc.TMXOrientationHex:
560+
case cc.TMX_ORIENTATION_HEX:
561561
ret = cc.p(0, 0);
562562
cc.log("cocos2d:offset for hexagonal map not implemented yet");
563563
break;
@@ -728,14 +728,14 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
728728
var maxVal = 0;
729729
if (this._useAutomaticVertexZ) {
730730
switch (this._layerOrientation) {
731-
case cc.TMXOrientationIso:
731+
case cc.TMX_ORIENTATION_ISO:
732732
maxVal = this._layerSize.width + this._layerSize.height;
733733
ret = -(maxVal - (pos.x + pos.y));
734734
break;
735-
case cc.TMXOrientationOrtho:
735+
case cc.TMX_ORIENTATION_ORTHO:
736736
ret = -(this._layerSize.height - pos.y);
737737
break;
738-
case cc.TMXOrientationHex:
738+
case cc.TMX_ORIENTATION_HEX:
739739
cc.Assert(0, "TMX Hexa zOrder not supported");
740740
break;
741741
default:

cocos2d/tileMap_parallax_nodes/CCTMXTiledMap.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929
* @constant
3030
* @type Number
3131
*/
32-
cc.TMXOrientationOrtho = 0;
32+
cc.TMX_ORIENTATION_ORTHO = 0;
3333

3434
/**
3535
* Hexagonal orientation
3636
* @constant
3737
* @type Number
3838
*/
3939

40-
cc.TMXOrientationHex = 1;
40+
cc.TMX_ORIENTATION_HEX = 1;
4141

4242
/**
4343
* Isometric orientation
4444
* @constant
4545
* @type Number
4646
*/
47-
cc.TMXOrientationIso = 2;
47+
cc.TMX_ORIENTATION_ISO = 2;
4848

4949
/**
5050
* <p>cc.TMXTiledMap knows how to parse and render a TMX map.</p>

0 commit comments

Comments
 (0)