| 赞 | 189 |
| VIP | |
| 好人卡 | |
| 积分 | 96 |
| 经验 | |
| 最后登录 | 2026-5-4 |
| 在线时间 | 5074 小时 |
- 梦石
- 0
- 星屑
- 9557
- 在线时间
- 5074 小时
- 注册时间
- 2013-6-21
- 回帖
- 3459
  
|
发表于 2016-5-22 08:48:37
|
显示全部楼层
这个方法定义在Window_Base内部,因此只能在Window_Base以及它的子类中使用,在别的类中无法使用。
要想在别的类里面也能使用这个方法,最简单的办法就是重新定义一遍。
- class A
- def text_color(n)
- case n
- when 0
- return Color.new(255, 255, 255, 255)
- when 1
- return Color.new(128, 128, 255, 255)
- when 2
- return Color.new(255, 128, 128, 255)
- when 3
- return Color.new(128, 255, 128, 255)
- when 4
- return Color.new(128, 255, 255, 255)
- when 5
- return Color.new(255, 128, 255, 255)
- when 6
- return Color.new(255, 255, 128, 255)
- when 7
- return Color.new(192, 192, 192, 255)
- else
- normal_color
- end
- end
- end
复制代码
另外,不推荐生成一个Window_Base对象之后再通过这个对象调用。这是因为Window_Base类的对象会显示在屏幕当中,并且这样调用也不合逻辑。 |
|