查看: 2709|回复: 1

[已经解决] 让一个窗口中文字能单独显示各自的颜色

[复制链接]
梦石
0
星屑
50
在线时间
231 小时
注册时间
2007-12-17
回帖
384
发表于 2014-12-15 10:43:55 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 stella 于 2014-12-15 10:47 编辑

这段脚本是一个窗口中描绘文字部分,我希望当变量1大等于10,变量1文字就是无效色,当变量2大等于10,变量2文字就是无效色。。。
而现在这样写法的效果是:当任何一个变量大等于10,所有描绘出的变量文字全都是无效色了,怎么让文字单独显示各自的颜色?


    self.contents.font.color = disabled_color if $game_variables[1] >= 10
    self.contents.draw_text(x+302 , y, 96, 32, ($game_variables[1]).to_s )
    self.contents.font.color = disabled_color if $game_variables[2] >= 10
    self.contents.draw_text(x+221 , y, 96, 32, ($game_variables[2]).to_s )
    self.contents.font.color = disabled_color if $game_variables[3] >= 10
    self.contents.draw_text(x+302 , y+105, 96, 32, ($game_variables[3]).to_s )

点评

一个一个的描绘文字。  发表于 2014-12-15 11:48

评分

参与人数 1星屑 +35 收起 理由
︶ㄣ牛排ぶ + 35 手动认可奖励

查看全部评分

梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
回帖
1643

开拓者

发表于 2014-12-15 11:55:52 | 显示全部楼层
不动你原来的结构的话你可以这样
  1.     self.contents.font.color = disabled_color if $game_variables[1] >= 10
  2.     self.contents.draw_text(x+302 , y, 96, 32, ($game_variables[1]).to_s )
  3.     self.contents.font.color = normal_color
  4.     self.contents.font.color = disabled_color if $game_variables[2] >= 10
  5.     self.contents.draw_text(x+221 , y, 96, 32, ($game_variables[2]).to_s )
  6.     self.contents.font.color = normal_color
  7.     self.contents.font.color = disabled_color if $game_variables[3] >= 10
  8.     self.contents.draw_text(x+302 , y+105, 96, 32, ($game_variables[3]).to_s )
  9.     self.contents.font.color = normal_color
复制代码
但是也可以稍微改一改变成这样【稍微介绍一下封装
  1. def draw_var(x, y, id)
  2.   self.contents.font.color = $game_variables[id] >= 10 ? disabled_color : normal_color
  3.   self.contents.draw_text(x, y, 96, 32, ($game_variables[id]).to_s )
  4. end
  5. draw_var(x+302 , y, 1); draw_var(x+221 , y, 96, 2); draw_var(x+302 , y+105, 3)
复制代码

评分

参与人数 2星屑 +220 收起 理由
︶ㄣ牛排ぶ + 200 认可答案
stella + 20 认可答案

查看全部评分


  -fk: -azogi:
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部