Skip to content

Commit 381ace0

Browse files
committed
Merge pull request #1 from cocos2d/develop
Updating my fork
2 parents e1e2931 + 1579939 commit 381ace0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3047
-2855
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
/tools/jsdoc_toolkit-2.4.0
88
/package
99
/tools/jsdoc_toolkit/jsdoc_toolkit-2.4.0
10+
/.project

AUTHORS.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ Asano @LaercioAsano cc.Node bug fix
169169

170170
Bruno Assarisse @bassarisse cc.LabelBMFont bug fix
171171

172-
Mykyta Usikov @musikov cc.ClippingNode bug fix
172+
Mykyta Usikov @musikov cc.ClippingNode bugs fix
173173
cc.fontLoader bug fix
174174
Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode
175175
JumpTo bug with wrong _delta position bug fix
176176
cc.ProgressTimer bugs fix
177177
cc.Scale9Sprite bugs fix
178178
cc.RenderTexture bug fix
179+
cc.ParticleSystem bug fix
179180

180181
Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix
181182

@@ -234,6 +235,15 @@ Joe Lafiosca @lafiosca Added Javascript file loader
234235

235236
galapagosit @galapagosit ccs.actionManager bug fix
236237

238+
Dany Ellement @DEllement cc.FontDefinition & ccui.RichText improvements
239+
cc.LayerGradient improvements
240+
241+
IShm @IShm cc.Screen bug fix
242+
cc.ParticleSystem bug fix
243+
244+
Thomas Jablonski @thomas-jablonski cc.audioEngine bug fix
245+
246+
WingGao @WingGao cc.TMXLayer bug fix
237247

238248
Retired Core Developers:
239249
Shengxiang Chen (Nero Chan)

CCBoot.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,8 @@ cc._initSys = function (config, CONFIG_KEY) {
15601560
browserType = sys.BROWSER_TYPE_ANDROID;
15611561
else if (browserType == "trident") browserType = sys.BROWSER_TYPE_IE;
15621562
else if (browserType == "360 aphone") browserType = sys.BROWSER_TYPE_360;
1563+
}else if(ua.indexOf("iphone") && ua.indexOf("mobile")){
1564+
browserType = "safari";
15631565
}
15641566
/**
15651567
* Indicate the running browser type
@@ -1596,10 +1598,13 @@ cc._initSys = function (config, CONFIG_KEY) {
15961598
var renderType = cc._RENDER_TYPE_WEBGL;
15971599
var tempCanvas = cc.newElement("Canvas");
15981600
cc._supportRender = true;
1599-
var notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1;
1600-
if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) {
1601+
var notSupportGL = true;
1602+
if(iOS)
1603+
notSupportGL = !window.WebGLRenderingContext || osSupportWebGL.indexOf(sys.os) == -1;
1604+
else
1605+
notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1;
1606+
if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://"))
16011607
renderType = cc._RENDER_TYPE_CANVAS;
1602-
}
16031608

16041609
sys._canUseCanvasNewBlendModes = function(){
16051610
var canvas = document.createElement('canvas');

CHANGELOG.txt

+39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
ChangeLog:
22

3+
Cocos2d-JS v3.4 Beta0 @ March 19 2015
4+
5+
* Added Windows Phone 8.0 platform support.
6+
* Upgraded SpiderMonkey to v33, greatly improved JS object garbage collection and performance.
7+
* Bound 3D modules including camera, light, sprite 3d, animation 3d, billboard, etc.
8+
* Improved `cc.FontDefinition` & `ccui.RichText` in the web engine.
9+
* Added gradient stops feature to `cc.LayerGradient` [Web exclusive].
10+
* Upgraded `cc.Scheduler` in the web engine with Cocos2d-x v3.4 implementation.
11+
* Added a loading screen when scripts are loading.
12+
* Improved performance by replacing `Object.defineProperties` with `cc.defineGetterSetter`.
13+
* Supported loading sprite frames from json object.
14+
* Refactored math library to improve web engine performance.
15+
* Removed some variables from `cc` namespace to improve web engine performance.
16+
* Added the Firefox OS Web manifest to support Firefox OS apps.
17+
* Added `cocos` attr to the script element in templates.
18+
* Moved loading.js to res folder for Cocos Console release mode.
19+
20+
* Bug fixes:
21+
1. Added `getSpriteFrame` to `cc.Sprite` to fix API inconsistency.
22+
2. Added `getObejct` to `cc.TMXObjectGroup` to fix API inconsistency.
23+
3. Added `addImageAsync` to `cc.textureCache` to fix API inconsistency.
24+
4. Fixed a bug of `cc.text` that its default font name is incorrect.
25+
5. Fixed a bug of `ccui.PageView` that its `getPage` doesn't work.
26+
6. Fixed a bug of `ccui.ImageView` that its `loadTexture` doesn't work while it's invoked multiple times at the same frame.
27+
7. Fixed a bug of `ccui` that its load event callbacks have some mistakes.
28+
8. Fixed a bug of `cc.Layer` that its bake function doesn't work when the layer has a parent node.
29+
9. Fixed typos in `cc.ClippingNode.WebGLRenderCmd` and `cc.ParticleSystem.WebGLRenderCmd` creation.
30+
10. Fixed a bug of `cc.Sprite` in `setTextureRect`.
31+
11. Fixed a bug of `cc.Screen`.
32+
12. Fixed a bug of `cc.view` that it doesn't work on iOS 8.1.2.
33+
13. Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero.
34+
14. Fixed a bug in hack for particles performance on canvas.
35+
15. Fixed a bug of `cc.audioEngine` that it doesn't work after minified/compiled.
36+
16. Fixed a bug in `CCBoot.js` that WebGL is not activated in web view of iOS 8.
37+
17. Fixed a bug of `cc.CheckBox` that its position is incorrect when its texture isn't preloaded.
38+
18. Fixed a bug of `cc.TMXLayer` that it stops to work after `setTileGID` called.
39+
19. Fixed a bug of Cocos parser 2.x that it doesn't set widget's LayoutComponent.
40+
20. Fixed a bug of `cc.isObject` that it considered function as an object.
41+
342
Cocos2d-JS v3.3 @ Feb.9, 2015
443

544
* Upgraded spine runtime to support the latest version and updated its test case.

README.mdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Cocos2d-html5
33

44
[Cocos2d-html5][1] is a cross-platform 2D game engine written in Javascript, based on [Cocos2d-X][2] and licensed under MIT.
55
It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X.
6-
It currently supports canvas and will support WebGL in the future.
6+
It currently supports canvas and WebGL renderer.
77

88
Cross Platform
99
-------------

cocos2d/audio/CCAudio.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@
134134
else
135135
cc.__audioSupport = supportTable[sys.BROWSER_TYPE_SAFARI];
136136
}else{
137-
//Desktop support all
138-
if(cc.sys.browserType != cc.sys.BROWSER_TYPE_IE)
139-
cc.__audioSupport = supportTable["common"];
140-
else
141-
cc.__audioSupport = supportTable[sys.BROWSER_TYPE_IE];
137+
switch(sys.browserType){
138+
case sys.BROWSER_TYPE_IE:
139+
cc.__audioSupport = supportTable[sys.BROWSER_TYPE_IE];
140+
break;
141+
case sys.BROWSER_TYPE_FIREFOX:
142+
cc.__audioSupport = supportTable[sys.BROWSER_TYPE_FIREFOX];
143+
break;
144+
default:
145+
cc.__audioSupport = supportTable["common"];
146+
}
142147
}
143148

144149
if(DEBUG){

cocos2d/core/CCCamera.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cc.Camera = cc.Class.extend({
6262
* constructor of cc.Camera
6363
*/
6464
ctor:function () {
65-
this._lookupMatrix = new cc.kmMat4();
65+
this._lookupMatrix = new cc.math.Matrix4();
6666
this.restore();
6767
},
6868

@@ -103,7 +103,7 @@ cc.Camera = cc.Class.extend({
103103
this._upY = 1.0;
104104
this._upZ = 0.0;
105105

106-
cc.kmMat4Identity( this._lookupMatrix );
106+
this._lookupMatrix.identity();
107107

108108
this._dirty = false;
109109
},
@@ -113,32 +113,24 @@ cc.Camera = cc.Class.extend({
113113
*/
114114
locate:function () {
115115
if (this._dirty) {
116-
var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3();
117-
118-
cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ );
119-
cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ);
120-
121-
cc.kmVec3Fill( up, this._upX, this._upY, this._upZ);
122-
cc.kmMat4LookAt( this._lookupMatrix, eye, center, up);
123-
116+
var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ),
117+
center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ),
118+
up = new cc.math.Vec3(this._upX, this._upY, this._upZ);
119+
this._lookupMatrix.lookAt(eye, center, up);
124120
this._dirty = false;
125121
}
126122
cc.kmGLMultMatrix( this._lookupMatrix);
127123
},
128124

129125
_locateForRenderer: function(matrix){
130126
if (this._dirty) {
131-
var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3();
132-
133-
cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ );
134-
cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ);
135-
136-
cc.kmVec3Fill( up, this._upX, this._upY, this._upZ);
137-
cc.kmMat4LookAt( this._lookupMatrix, eye, center, up);
138-
127+
var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ),
128+
center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ),
129+
up = new cc.math.Vec3(this._upX, this._upY, this._upZ);
130+
this._lookupMatrix.lookAt(eye, center, up);
139131
this._dirty = false;
140132
}
141-
cc.kmMat4Multiply(matrix, matrix, this._lookupMatrix);
133+
matrix.multiply(this._lookupMatrix);
142134
},
143135

144136
/**

cocos2d/core/CCDirector.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
cc.g_NumberOfDraws = 0;
2828

2929
cc.GLToClipTransform = function (transformOut) {
30-
var projection = new cc.kmMat4();
31-
cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection);
30+
//var projection = new cc.math.Matrix4();
31+
//cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection);
32+
cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, transformOut);
3233

33-
var modelview = new cc.kmMat4();
34+
var modelview = new cc.math.Matrix4();
3435
cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, modelview);
3536

36-
cc.kmMat4Multiply(transformOut, projection, modelview);
37+
transformOut.multiply(modelview);
3738
};
3839
//----------------------------------------------------------------------------------------------------------------------
3940

cocos2d/core/CCDirectorWebGL.js

+16-25
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,33 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
5757
case cc.Director.PROJECTION_2D:
5858
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
5959
cc.kmGLLoadIdentity();
60-
var orthoMatrix = new cc.kmMat4();
61-
cc.kmMat4OrthographicProjection(
62-
orthoMatrix,
60+
var orthoMatrix = cc.math.Matrix4.createOrthographicProjection(
6361
-ox,
64-
size.width - ox,
62+
size.width - ox,
6563
-oy,
66-
size.height - oy,
64+
size.height - oy,
6765
-1024, 1024);
6866
cc.kmGLMultMatrix(orthoMatrix);
6967
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
7068
cc.kmGLLoadIdentity();
7169
break;
7270
case cc.Director.PROJECTION_3D:
7371
var zeye = _t.getZEye();
74-
var matrixPerspective = new cc.kmMat4(), matrixLookup = new cc.kmMat4();
72+
var matrixPerspective = new cc.math.Matrix4(), matrixLookup = new cc.math.Matrix4();
7573
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
7674
cc.kmGLLoadIdentity();
7775

7876
// issue #1334
79-
cc.kmMat4PerspectiveProjection(matrixPerspective, 60, size.width / size.height, 0.1, zeye * 2);
77+
matrixPerspective = cc.math.Matrix4.createPerspectiveProjection(60, size.width / size.height, 0.1, zeye * 2);
8078

8179
cc.kmGLMultMatrix(matrixPerspective);
8280

8381
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
8482
cc.kmGLLoadIdentity();
85-
var eye = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, zeye);
86-
var center = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, 0.0);
87-
var up = cc.kmVec3Fill(null, 0.0, 1.0, 0.0);
88-
cc.kmMat4LookAt(matrixLookup, eye, center, up);
83+
var eye = new cc.math.Vec3(-ox + size.width / 2, -oy + size.height / 2, zeye);
84+
var center = new cc.math.Vec3( -ox + size.width / 2, -oy + size.height / 2, 0.0);
85+
var up = new cc.math.Vec3( 0.0, 1.0, 0.0);
86+
matrixLookup.lookAt(eye, center, up);
8987
cc.kmGLMultMatrix(matrixLookup);
9088
break;
9189
case cc.Director.PROJECTION_CUSTOM:
@@ -238,38 +236,31 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
238236
};
239237

240238
_p.convertToGL = function (uiPoint) {
241-
var transform = new cc.kmMat4();
239+
var transform = new cc.math.Matrix4();
242240
cc.GLToClipTransform(transform);
243241

244-
var transformInv = new cc.kmMat4();
245-
cc.kmMat4Inverse(transformInv, transform);
242+
var transformInv = transform.inverse();
246243

247244
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
248245
var zClip = transform.mat[14] / transform.mat[15];
249-
250246
var glSize = this._openGLView.getDesignResolutionSize();
251-
var clipCoord = new cc.kmVec3(2.0 * uiPoint.x / glSize.width - 1.0, 1.0 - 2.0 * uiPoint.y / glSize.height, zClip);
252-
253-
var glCoord = new cc.kmVec3();
254-
cc.kmVec3TransformCoord(glCoord, clipCoord, transformInv);
255-
247+
var glCoord = new cc.math.Vec3(2.0 * uiPoint.x / glSize.width - 1.0, 1.0 - 2.0 * uiPoint.y / glSize.height, zClip);
248+
glCoord.transformCoord(transformInv);
256249
return cc.p(glCoord.x, glCoord.y);
257250
};
258251

259252
_p.convertToUI = function (glPoint) {
260-
var transform = new cc.kmMat4();
253+
var transform = new cc.math.Matrix4();
261254
cc.GLToClipTransform(transform);
262255

263-
var clipCoord = new cc.kmVec3();
256+
var clipCoord = new cc.math.Vec3(glPoint.x, glPoint.y, 0.0);
264257
// Need to calculate the zero depth from the transform.
265-
var glCoord = new cc.kmVec3(glPoint.x, glPoint.y, 0.0);
266-
cc.kmVec3TransformCoord(clipCoord, glCoord, transform);
258+
clipCoord.transformCoord(transform);
267259

268260
var glSize = this._openGLView.getDesignResolutionSize();
269261
return cc.p(glSize.width * (clipCoord.x * 0.5 + 0.5), glSize.height * (-clipCoord.y * 0.5 + 0.5));
270262
};
271263

272-
273264
_p.getVisibleSize = function () {
274265
//if (this._openGLView) {
275266
return this._openGLView.getVisibleSize();

cocos2d/core/base-nodes/CCNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
11551155
*/
11561156
setScheduler: function (scheduler) {
11571157
if (this._scheduler != scheduler) {
1158-
this.unscheduleAll();
1158+
this.unscheduleAllCallbacks();
11591159
this._scheduler = scheduler;
11601160
}
11611161
},

cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
cc.Node.WebGLRenderCmd = function (renderable) {
2727
cc.Node.RenderCmd.call(this, renderable);
2828

29-
var mat4 = new cc.kmMat4();
30-
mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0;
31-
mat4.mat[10] = mat4.mat[15] = 1.0;
29+
var mat4 = new cc.math.Matrix4(), mat = mat4.mat;
30+
mat[2] = mat[3] = mat[6] = mat[7] = mat[8] = mat[9] = mat[11] = mat[14] = 0.0;
31+
mat[10] = mat[15] = 1.0;
3232
this._transform4x4 = mat4;
33-
this._stackMatrix = new cc.kmMat4();
33+
this._stackMatrix = new cc.math.Matrix4();
3434
this._shaderProgram = null;
3535

3636
this._camera = null;
@@ -223,15 +223,15 @@
223223
apy = 0 | apy;
224224
}
225225
//cc.kmGLTranslatef(apx, apy, 0);
226-
var translation = new cc.kmMat4();
227-
cc.kmMat4Translation(translation, apx, apy, 0);
228-
cc.kmMat4Multiply(stackMatrix, stackMatrix, translation);
226+
var translation = cc.math.Matrix4.createByTranslation(apx, apy, 0, t4x4); //t4x4 as a temp matrix
227+
stackMatrix.multiply(translation);
229228

230229
node._camera._locateForRenderer(stackMatrix);
231230

232-
//cc.kmGLTranslatef(-apx, -apy, 0);
233-
cc.kmMat4Translation(translation, -apx, -apy, 0);
234-
cc.kmMat4Multiply(stackMatrix, stackMatrix, translation);
231+
//cc.kmGLTranslatef(-apx, -apy, 0); optimize at here : kmGLTranslatef
232+
translation = cc.math.Matrix4.createByTranslation(-apx, -apy, 0, translation);
233+
stackMatrix.multiply(translation);
234+
t4x4.identity(); //reset t4x4;
235235
} else {
236236
node._camera._locateForRenderer(stackMatrix);
237237
}

cocos2d/core/layers/CCLayer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{
349349

350350
if(stops && stops instanceof Array){
351351
this._colorStops = stops;
352-
stops.splice(0, 0, {p:0, color: start});
353-
stops.push({p:1, color: end});
352+
stops.splice(0, 0, {p:0, color: start || cc.color.BLACK});
353+
stops.push({p:1, color: end || cc.color.BLACK});
354354
} else
355-
this._colorStops = [{p:0, color: start}, {p:1, color: end}];
355+
this._colorStops = [{p:0, color: start || cc.color.BLACK}, {p:1, color: end || cc.color.BLACK}];
356356

357357
cc.LayerGradient.prototype.init.call(this, start, end, v, stops);
358358
},

cocos2d/core/platform/CCConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @type {String}
3232
* @name cc.ENGINE_VERSION
3333
*/
34-
window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3";
34+
window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4 Beta0";
3535

3636
/**
3737
* <p>

cocos2d/core/platform/CCEGLView.js

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ switch(cc.__BrowserGetter.adaptationType){
7575
cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){
7676
return cc.view._targetDensityDPI;
7777
});
78+
case cc.sys.BROWSER_TYPE_SOUGOU:
7879
case cc.sys.BROWSER_TYPE_UC:
7980
cc.__BrowserGetter.availWidth = function(frame){
8081
return frame.clientWidth;

0 commit comments

Comments
 (0)