求教各位大佬,我的需求场景是在编辑添加碰撞体,如果没留意 node 的 scale 是小于0的话会有不可预期的结果,例如碰撞体偏移等。想要通过修改源码实现,这样不用每种碰撞体都写一个专门的编辑器运行时脚本。
下面是我尝试参考 __init 写的代码,但是获取到的 node 是 null
var PhysicsCollider = cc.Class({
name: 'cc.PhysicsCollider',
extends: cc.Collider,
ctor: function () {
this._fixtures = [];
this._shapes = [];
this._inited = false;
this._rect = cc.rect();
if (CC_EDITOR) {
try {
var body = this.body;
var node = body.node;
var scale = getWorldScale(node);
if (scale.x < 0 || scale.y < 0) {
cc.warn('this node scale value is < 0!');
}
} catch (e) {
cc.warn(e);
cc.warn('try to get scale value error!');
}
}
},