Skip to content

Commit 3d0c024

Browse files
committed
Merge pull request #1759 from pandamicro/develop-3.0
Issue #4580: Fix CONSTANTS inconsistence between h5 and JSB
2 parents 321bf6b + 8a493d2 commit 3d0c024

File tree

13 files changed

+366
-352
lines changed

13 files changed

+366
-352
lines changed

cocos2d/core/CCDirector.js

Lines changed: 30 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -24,75 +24,8 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626

27-
//Possible OpenGL projections used by director
28-
/**
29-
* sets a 2D projection (orthogonal projection)
30-
* @constant
31-
* @type Number
32-
*/
33-
cc.DIRECTOR_PROJECTION_2D = 0;
34-
3527
cc.g_NumberOfDraws = 0;
3628

37-
/**
38-
* sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
39-
* @constant
40-
* @type Number
41-
*/
42-
cc.DIRECTOR_PROJECTION_3D = 1;
43-
44-
/**
45-
* it calls "updateProjection" on the projection delegate.
46-
* @constant
47-
* @type Number
48-
*/
49-
cc.DIRECTOR_PROJECTION_CUSTOM = 3;
50-
51-
/**
52-
* Default projection is 3D projection
53-
* @constant
54-
* @type Number
55-
*/
56-
cc.DIRECTOR_PROJECTION_DEFAULT = cc.DIRECTOR_PROJECTION_3D;
57-
58-
//----------------------------------------------------------------------------------------------------------------------
59-
//Possible device orientations
60-
/**
61-
* Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)
62-
* @constant
63-
* @type Number
64-
*/
65-
cc.DEVICE_ORIENTATION_PORTRAIT = 0;
66-
67-
/**
68-
* Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)
69-
* @constant
70-
* @type Number
71-
*/
72-
cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
73-
74-
/**
75-
* Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)
76-
* @constant
77-
* @type Number
78-
*/
79-
cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
80-
81-
/**
82-
* Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)
83-
* @constant
84-
* @type Number
85-
*/
86-
cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
87-
88-
/**
89-
* In browsers, we only support 2 orientations by change window size.
90-
* @constant
91-
* @type Number
92-
*/
93-
cc.DEVICE_MAX_ORIENTATIONS = 2;
94-
95-
9629
cc.GLToClipTransform = function (transformOut) {
9730
var projection = new cc.kmMat4();
9831
cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection);
@@ -197,7 +130,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{
197130
this._oldAnimationInterval = this._animationInterval = 1.0 / cc.defaultFPS;
198131
this._scenesStack = [];
199132
// Set default projection (3D)
200-
this._projection = cc.DIRECTOR_PROJECTION_DEFAULT;
133+
this._projection = cc.Director.PROJECTION_DEFAULT;
201134
// projection delegate if "Custom" projection is used
202135
this._projectionDelegate = null;
203136

@@ -872,6 +805,35 @@ cc.Director._getInstance = function () {
872805
*/
873806
cc.defaultFPS = 60;
874807

808+
//Possible OpenGL projections used by director
809+
/**
810+
* sets a 2D projection (orthogonal projection)
811+
* @constant
812+
* @type Number
813+
*/
814+
cc.Director.PROJECTION_2D = 0;
815+
816+
/**
817+
* sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
818+
* @constant
819+
* @type Number
820+
*/
821+
cc.Director.PROJECTION_3D = 1;
822+
823+
/**
824+
* it calls "updateProjection" on the projection delegate.
825+
* @constant
826+
* @type Number
827+
*/
828+
cc.Director.PROJECTION_CUSTOM = 3;
829+
830+
/**
831+
* Default projection is 3D projection
832+
* @constant
833+
* @type Number
834+
*/
835+
cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
836+
875837
if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
876838

877839
var _p = cc.Director.prototype;

cocos2d/core/CCDirectorWebGL.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
4949
_t.setViewport();
5050

5151
switch (projection) {
52-
case cc.DIRECTOR_PROJECTION_2D:
52+
case cc.Director.PROJECTION_2D:
5353
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
5454
cc.kmGLLoadIdentity();
5555
var orthoMatrix = new cc.kmMat4();
@@ -58,7 +58,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
5858
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
5959
cc.kmGLLoadIdentity();
6060
break;
61-
case cc.DIRECTOR_PROJECTION_3D:
61+
case cc.Director.PROJECTION_3D:
6262
var zeye = _t.getZEye();
6363
var matrixPerspective = new cc.kmMat4(), matrixLookup = new cc.kmMat4();
6464
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
@@ -77,7 +77,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
7777
cc.kmMat4LookAt(matrixLookup, eye, center, up);
7878
cc.kmGLMultMatrix(matrixLookup);
7979
break;
80-
case cc.DIRECTOR_PROJECTION_CUSTOM:
80+
case cc.Director.PROJECTION_CUSTOM:
8181
if (_t._projectionDelegate)
8282
_t._projectionDelegate.updateProjection();
8383
break;

cocos2d/core/base-nodes/BaseNodesWebGL.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ _tmp.WebGLCCNode = function () {
131131
if (_t._camera != null && !(_t.grid != null && _t.grid.isActive())) {
132132
var apx = _t._anchorPointInPoints.x, apy = _t._anchorPointInPoints.y;
133133
var translate = (apx !== 0.0 || apy !== 0.0);
134-
if (translate) {
135-
cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(apx), cc.RENDER_IN_SUBPIXEL(apy), 0);
134+
if (translate){
135+
if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
136+
apx = 0 | apx;
137+
apy = 0 | apy;
138+
}
139+
cc.kmGLTranslatef(apx, apy, 0);
136140
_t._camera.locate();
137-
cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(-apx), cc.RENDER_IN_SUBPIXEL(-apy), 0);
141+
cc.kmGLTranslatef(-apx, -apy, 0);
138142
} else {
139143
_t._camera.locate();
140144
}

cocos2d/core/platform/CCClass.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,12 @@ cc.defineGetterSetter = function (proto, prop, getter, setter, getterName, sette
252252
var hasGetter = (getter != null), hasSetter = (setter != undefined), props = Object.getOwnPropertyNames(proto);
253253
for (var i = 0; i < props.length; i++) {
254254
var name = props[i];
255-
if( proto.__lookupGetter__(name) || typeof proto[name] !== "function" ) continue;
255+
256+
if( (Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(proto, name)
257+
: proto.__lookupGetter__(name))
258+
|| typeof proto[name] !== "function" )
259+
continue;
260+
256261
var func = proto[name];
257262
if (hasGetter && func === getter) {
258263
getterName = name;

cocos2d/core/platform/CCConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @constant
3434
* @type String
3535
*/
36-
cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha";
36+
cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha 2";
3737

3838
/**
3939
* <p>

0 commit comments

Comments
 (0)