mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 11:31:59 +08:00
deprecated Node & Layer api (#5377)
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
*/
|
||||
|
||||
import { BaseNode } from './base-node';
|
||||
import { replaceProperty } from '../utils/deprecated';
|
||||
import { replaceProperty, removeProperty } from '../utils/deprecated';
|
||||
import { Layers } from './layers';
|
||||
import { Node } from './node';
|
||||
|
||||
// js.get(BaseNode.prototype, 'childrenCount', function () {
|
||||
// cc.warn("`childrenCount` is deprecated, please use `node.children.length` instead.");
|
||||
@@ -19,4 +21,19 @@ replaceProperty(BaseNode.prototype, 'BaseNode', [
|
||||
return this.children.length;
|
||||
}
|
||||
}
|
||||
]);
|
||||
]);
|
||||
|
||||
removeProperty(Layers, 'Layers', [
|
||||
{
|
||||
'name': 'addLayer',
|
||||
}
|
||||
]);
|
||||
|
||||
removeProperty(Node.prototype, 'Node.prototype', [
|
||||
{
|
||||
'name': 'addLayer',
|
||||
},
|
||||
{
|
||||
'name': 'removeLayer',
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -60,23 +60,6 @@ export class Layers {
|
||||
*/
|
||||
public static RaycastMask = Layers.makeExclusiveMask([Layers.Gizmos, Layers.SceneGizmo, Layers.Editor, Layers.IgnoreRaycast]);
|
||||
|
||||
/**
|
||||
* @en
|
||||
* Add a new layer
|
||||
* @zh
|
||||
* 添加一个新层
|
||||
* @param name 层名字
|
||||
* @return 新层的检测值
|
||||
*/
|
||||
public static addLayer (name: string): number | undefined {
|
||||
if (Layers._nextAvailable > 31) {
|
||||
console.warn('maximum layers reached.');
|
||||
return;
|
||||
}
|
||||
Layers[name] = (1 << Layers._nextAvailable++);
|
||||
return Layers[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @en
|
||||
* Make a layer mask accepting nothing but the listed layers
|
||||
@@ -117,8 +100,6 @@ export class Layers {
|
||||
public static check (layer: number, mask: number): boolean {
|
||||
return (layer & mask) === layer;
|
||||
}
|
||||
|
||||
private static _nextAvailable = 8;
|
||||
}
|
||||
|
||||
cc.Layers = Layers;
|
||||
|
||||
@@ -258,22 +258,6 @@ export class Node extends BaseNode implements INode {
|
||||
return this._layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 向节点添加一个层分组,参考 [[Layers]]
|
||||
*/
|
||||
public addLayer (layer: number) {
|
||||
this._layer |= layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 从节点中移除一个层分组,参考 [[Layers]]
|
||||
*/
|
||||
public removeLayer (layer: number) {
|
||||
this._layer &= ~layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 这个节点的空间变换信息在当前帧内是否有变过?
|
||||
|
||||
Reference in New Issue
Block a user