Merge pull request #2345 from pandamicro/next

Remove sgNode usages and SpriteDistortion
This commit is contained in:
pandamicro
2018-02-20 00:19:26 +08:00
committed by GitHub
10 changed files with 6 additions and 140 deletions
+2 -6
View File
@@ -1909,12 +1909,10 @@ var Node = cc.Class({
*
* @method getDisplayedOpacity
* @returns {number} displayed opacity
* @deprecated please use opacity property, cascade opacity is removed
* @example
* var displayOpacity = node.getDisplayedOpacity();
*/
getDisplayedOpacity () {
return this._sgNode.getDisplayedOpacity();
},
/**
* !#en
@@ -1927,12 +1925,10 @@ var Node = cc.Class({
*
* @method getDisplayedColor
* @returns {Color}
* @deprecated please use color property, cascade color is not supported
* @example
* var displayColor = node.getDisplayedColor();
*/
getDisplayedColor () {
return this._sgNode.getDisplayedColor();
},
_updateLocalMatrix () {
if (this._localMatDirty) {
@@ -1,117 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 Chukong Technologies Inc.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Chukong Aipu reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/**
* !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
* !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用.
* @class SpriteDistortion
* @extends Component
* @example
* // Create a new node and add sprite components.
* var node = new cc.Node("New Sprite");
* var sprite = node.addComponent(cc.Sprite);
* var spriteDistortion = node.addComponent(cc.SpriteDistortion);
* node.parent = this.node;
*/
var SpriteDistortion = cc.Class({
name: 'cc.SpriteDistortion', extends: require('./CCComponent'),
editor: CC_EDITOR && {
menu: 'i18n:MAIN_MENU.component.renderers/SpriteDistortion',
executeInEditMode: true,
requireComponent: cc.Sprite,
},
ctor: function() {
this._spriteSGNode = null;
},
properties: {
/**
* !#en Change the UV offset for distortion rendering.
* !#zh 在渲染时改变UV的整体偏移.
* @property offset
* @type {Vec2}
* @example
* distortion.offset = new cc.Vec2(0.5, 0.3);;
*/
_distortionOffset: cc.v2(0.0,0.0),
offset: {
get: function() {
return this._distortionOffset;
},
set:function(value) {
this._distortionOffset.x = value.x;
this._distortionOffset.y = value.y;
if(this._spriteSGNode) {
this._spriteSGNode.setDistortionOffset(this._distortionOffset);
}
}
},
/**
* !#en Change the UV scale for distortion rendering.
* !#zh 在渲染时改变UV的寻址系数
* @property tiling
* @type {Vec2}
* @example
* distortion.tiling = new cc.Vec2(0.5, 0.3);;
*/
_distortionTiling: cc.v2(1.0,1.0),
tiling: {
get: function() {
return this._distortionTiling;
},
set:function(value) {
this._distortionTiling.x = value.x;
this._distortionTiling.y = value.y;
if(this._spriteSGNode) {
this._spriteSGNode.setDistortionTiling(this._distortionTiling);
}
}
},
},
onEnable: function () {
var sprite = this.node.getComponent('cc.Sprite');
var sgNode = this._spriteSGNode = sprite && sprite._sgNode;
if(this._spriteSGNode) {
sgNode.setState(cc.Scale9Sprite.state.DISTORTION);
sgNode.setDistortionOffset(this._distortionOffset);
sgNode.setDistortionTiling(this._distortionTiling);
}
},
onDisable: function () {
if(this._spriteSGNode) {
this._spriteSGNode.setState(cc.Scale9Sprite.state.NORMAL);
}
this._spriteSGNode = null;
},
});
cc.SpriteDistortion = module.exports = SpriteDistortion;
-1
View File
@@ -46,7 +46,6 @@ var components = [
require('./editbox/CCEditBox'),
// require('./CCVideoPlayer'),
// require('./CCWebView'),
require('./CCSpriteDistortion'),
require('./CCLabelOutline'),
require('./CCRichText'),
require('./CCToggleContainer'),
+2
View File
@@ -442,6 +442,8 @@ if (CC_DEV) {
'setGLServerState',
'_initRendererCmd',
'_createRenderCmd',
'getDisplayedOpacity',
'getDisplayedColor',
'updateDisplayedOpacity',
'updateDisplayedColor',
'userData',
-1
View File
@@ -430,7 +430,6 @@ let TiledMap = cc.Class({
},
_applyFile () {
let sgNode = this._sgNode;
let file = this._tmxFile;
let self = this;
if (file) {
-6
View File
@@ -30,12 +30,6 @@
"./cocos2d/core/components/CCMask.js"
]
},
{
"name": "CCSpriteDistortion",
"entries": [
"./cocos2d/core/components/CCSpriteDistortion.js"
]
},
{
"name": "LabelOutline",
"entries": [
@@ -2,7 +2,7 @@ largeModule('Component Scheduler', {
setup: SetupEngine.setup,
teardown: function () {
cc.director._scene = new cc.Scene();
cc.director._runningScene = cc.director._scene._sgNode;
cc.director._runningScene = cc.director._scene;
SetupEngine.teardown();
}
});
-6
View File
@@ -157,9 +157,6 @@
strictEqual(reloadedParent.active, false, 'root active should be kept');
strictEqual(reloadedParent.children.length, 1, 'children should be synced');
// test parent sgNode
strictEqual(reloadedParent._sgNode.parent === scene._sgNode, true, 'parent of parent _sgNode should be synced');
// test child
var syncedChild = reloadedParent.children[0];
strictEqual(syncedChild.active, child.active, 'child active should be synced');
@@ -167,9 +164,6 @@
strictEqual(syncedChild.y, child.y, 'child position should be synced');
strictEqual(syncedChild.scaleY, child.scaleY, 'child scale should be synced');
strictEqual(syncedChild.parent, reloadedParent, 'prefab reference should redirect to scene node');
// test child sgNode
strictEqual(syncedChild._sgNode.parent === reloadedParent._sgNode, true, 'parent of child _sgNode should be synced');
});
})();
-1
View File
@@ -209,7 +209,6 @@
strictEqual(testNode.childrenCount, 2, 'Should create removed node');
var created = testNode.children[1];
ok(created._sgNode, 'Checking created node');
var comp = created.getComponent(MyComponent);
comp.resetExpect(CallbackTester.OnLoad, 'call onLoad while attaching to node');
+1 -1
View File
@@ -9,7 +9,7 @@ test('basic test', function () {
node.color = Color.RED;
var render = node.addComponent(cc.Sprite);
deepEqual(render._sgNode.color, Color.RED, 'color set success');
deepEqual(node.color, Color.RED, 'color set success');
var newSprite = new cc.SpriteFrame();
var texture = cc.textureUtil.loadImage(url);