Skip to content

Commit 4d0c0e8

Browse files
committed
Issue cocos2d#2416: added CCNodeRenderCmd.js to engine
1 parent ab54d4c commit 4d0c0e8

File tree

6 files changed

+57
-7
lines changed

6 files changed

+57
-7
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/****************************************************************************
2+
Copyright (c) 2013-2014 Chukong Technologies Inc.
3+
4+
http://www.cocos2d-x.org
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
23+
****************************************************************************/
24+
25+
//The cc.Node's render command for Canvas
26+
cc.NodeCanvasRenderCmd = function(){
27+
this._needDraw = false;
28+
this._anchorPointInPoints = new cc.Point(0,0);
29+
this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
30+
this._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
31+
32+
};
33+
34+
cc.NodeCanvasRenderCmd.prototype = {
35+
constructor: cc.NodeCanvasRenderCmd
36+
37+
};
38+
39+
//register to renderer
40+
41+
//The cc.Node's render command for WebGL
42+
cc.NodeWebGLRenderCmd = function(){
43+
this._needDraw = false;
44+
};
45+
46+
cc.NodeWebGLRenderCmd.prototype = {
47+
constructor: cc.NodeCanvasRenderCmd
48+
49+
};

cocos2d/core/layers/CCLayer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{
308308
this._updateColor();
309309
},
310310

311-
_blendFuncStr: "source",
311+
_blendFuncStr: "source-over",
312312

313313
/**
314314
* Constructor of cc.LayerColor

cocos2d/core/renderer/RendererCanvas.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
171171
locHeight = node._rect.height,
172172
image, curColor, contentSize;
173173

174-
var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255);
174+
var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255);
175175

176176
if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) {
177177
context.save();
@@ -304,7 +304,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
304304
return;
305305

306306
var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); //TODO
307-
var needRestore = (node._blendFuncStr !== "source") || needTransform;
307+
var needRestore = (node._blendFuncStr !== "source-over") || needTransform;
308308

309309
if (needRestore) {
310310
context.save();
@@ -343,7 +343,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
343343
return;
344344

345345
var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1);
346-
var needRestore = (node._blendFuncStr !== "source") || needTransform;
346+
var needRestore = (node._blendFuncStr !== "source-over") || needTransform;
347347
if(needRestore){
348348
context.save();
349349
context.globalCompositeOperation = node._blendFuncStr;
@@ -490,7 +490,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
490490
context.save();
491491
context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY);
492492

493-
if (locSprite._blendFuncStr != "source")
493+
if (locSprite._blendFuncStr != "source-over")
494494
context.globalCompositeOperation = locSprite._blendFuncStr;
495495
context.globalAlpha = alpha;
496496

cocos2d/core/sprites/CCSprite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
800800
_quadWebBuffer: null,
801801
_quadDirty: false,
802802
_colorized: false,
803-
_blendFuncStr: "source",
803+
_blendFuncStr: "source-over",
804804
_originalTexture: null,
805805
_drawSize_Canvas: null,
806806

cocos2d/physics/CCPhysicsSprite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@
369369
* @return {Number}
370370
*/
371371
getRotation:function () {
372-
return this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadiansX) : -cc.radiansToDegrees(this._body.a);
372+
return this._ignoreBodyRotation ? this._rotationX : -cc.radiansToDegrees(this._body.a);
373373
},
374374

375375
/**

moduleConfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"cocos2d/core/base-nodes/BaseNodesWebGL.js",
7777
"cocos2d/core/base-nodes/BaseNodesPropertyDefine.js",
7878
"cocos2d/core/base-nodes/CCNode.js",
79+
"cocos2d/core/base-nodes/CCNodeRenderCmd.js",
7980
"cocos2d/core/base-nodes/CCAtlasNode.js",
8081

8182
"cocos2d/core/textures/TexturesWebGL.js",

0 commit comments

Comments
 (0)