StealClick:function(){
//判断
// var workspace = cc.find(“Canvas/workspace”);
// if(workspace.workstatus !=2){
// return;
// }
// var getcoin = cc.wk.Dictable.shovel[cc.wk.Tool.shovel.ttype].outp;
var usercoin = cc.find("Canvas/useri/coin");
var userCoin = usercoin.getComponent(cc.Label);
// //随机数
var dogprotecta = true;
// var otherdog = cc.wk.Dictable.dog[cc.wk.Tool.dog.ttype];
//if(otherdog != null && Math.random() < otherdog.guaPro){
//写死,待服务器接入
//var dogprotectc = cc.find("Canvas/dogprotect");
//dogprotectc.active = true;
this.dogprotect.active = true;
if(dogprotecta) {
//console.log(dogprotectc);
//console.log( dogprotectc.active);
cc.log(this.dogprotect);
this.dogprotect.active = true;
//dogprotectc.active = true;
//console.log(dogprotectc);
} else {
cc.wk.User.coin = String(parseInt(cc.wk.User.coin) + 10);
cc.log("steal is false");
userCoin.string = cc.wk.User.coin;
}
//偷取按钮关闭,防止无限偷
var steal = cc.find("Canvas/steal");
steal.active = false;
},
代码如上 按钮上绑的脚本,无论是用cc.find获取还是直接通过属性检查器绑定 都不能在if里面改变node的active属性。
如图
点击后不生效,active也没有被改变。
但是放在if语句的外面。 像下面这样
jiuhui
就会生效 ,
求问这是什么情况?



