加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 miantouchi 于 2019-4-17 21:04 编辑
# 描绘 HP self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# 描绘 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
这段代码从来没见过可以这样组合,分开我知道
= 赋值
==相等
<= 小于或相等
? 和 : 条件运算符
这段代码是分成以下3步的意思吗?
self.contents.font.color = actor.hp
actor.hp == 0 ? knockout_color :actor.hp
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color |