cc.Class({
extends: cc.Component,
properties: {
result_tip_success : ‘Congratulations! This time the score is’,
result_tip_err : ‘Continue to cheer! This time the score is’,
},
my function(){
var last_sorce= this.node.getChildByName(‘fenshuValue’).getComponent(cc.Label).string;
var last_result_tip = this.result_menu.getChildByName(‘tip’).getComponent(cc.Label).string;
if(last_sorce >=150){
this.result_menu.getChildByName('tip').getComponent(cc.Label).string = this.result_tip_success;
cc.log(">>>>>>");
}else{ // 小于150
this.result_menu.getChildByName('tip').getComponent(cc.Label).string = this.result_tip_err;
// let last_result_tip = 'Continue to cheer! This time the score is';
cc.log("<<<<<<<");
}
},
如题,1.为啥在creator-js脚本里 last_sorce 字符串不需要转换成int类型就可以直接进行>=150判断?
类比“200”>=150这样可以进行???
2.为啥 var last_result_tip = this.result_menu.getChildByName(‘tip’).getComponent(cc.Label).string;
后 last_result_tip = this.result_tip_err;
却不显示,没效果??
直接用
this.result_menu.getChildByName(‘tip’).getComponent(cc.Label).string = this.result_tip_err;
就有效果了
难道js 的类型赋值时,不能用var 或者 let 声明变量类型后,取变量类型再赋值不能???
只能直接取值后赋值?? this.result_menu.getChildByName(‘tip’).getComponent(cc.Label).string = this.result_tip_err;