设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1788|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
231 小时
注册时间
2007-12-17
帖子
541
跳转到指定楼层
1
发表于 2014-12-15 10:43:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 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 手动认可奖励

查看全部评分

Lv1.梦旅人

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

开拓者

2
发表于 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:
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-21 10:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表