在属性管理器里确定了摄像机绘制位置 比如 rect x=0.5 y=0,5 w=0.2 h=0.2
在代码里面就不能更改了吗 这是只读属性?
properties: {
camTest: cc.Camera,
},
onLoad() {
console.log(this.camTest.rect.x)
this.camTest.rect.x += 0.3;
},
为什么代码里更改了rect.x无效果呢?哪位大佬能解个惑
在属性管理器里确定了摄像机绘制位置 比如 rect x=0.5 y=0,5 w=0.2 h=0.2
在代码里面就不能更改了吗 这是只读属性?
properties: {
camTest: cc.Camera,
},
onLoad() {
console.log(this.camTest.rect.x)
this.camTest.rect.x += 0.3;
},
为什么代码里更改了rect.x无效果呢?哪位大佬能解个惑
打个比方,要实现把小地图的显示从左上角拖拽到右上角?
什么版本啊,我2.2.2亲测可以耶
试试以下2个方法?
this.camTest.rect.x += 0.3;
camTest"_updateRect"
this.camTest.rect.x += 0.3;
this.camTest.rect = rect
properties: {
camTest: cc.Camera,
},
onLoad() {
// this.camTest.rect.x -= 0.1;
},
moveBtn() { //绑了个Button
this.camTest.rect.x -= 0.1;
},
奇怪的很啊 如果在 onLoad里面执行没有问题,但是脚本组件如果和摄像机组件放在一个节点下必须先于摄像机执行才生效
然后如果在button的里面来改变rect.x就无效?是要手动update rect?
还是说这个rect的值只能在onLoad里面修改?
camTest"_updateRect"
是什么方法?api里面找不到用法啊
如果只是在onLoad里面执行是没有问题的,但是在onLoad之后就无效了?没道理啊
而且如果把脚本和摄像机放在一个节点上,还得把摄像机放在脚本的后面,要不然onLoad里面也无效
我找到问题了,确实是要rect整个更新。。。这好坑的赶脚
多谢大佬提示
properties: {
camTest: cc.Camera,
},
onLoad() {
// this.camTest.rect.x -= 0.4;
},
moveBtn() { //绑了个Button
let rect = this.camTest.rect;
rect.x -= 0.1;
console.log(rect)
this.camTest.rect = rect;
},
主要还是文档搞的不是特别好 