Project1

标题: Window_ShopCommand 的文字颜色如何修改呢? [打印本页]

作者: overpan    时间: 2009-10-28 19:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: Eienshinken    时间: 2009-10-28 20:02
本帖最后由 Eienshinken 于 2009-10-28 20:36 编辑

def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 3
    @column_max = 3
    self.contents.font.color = Color.new(255,0,0)
    s1 = "买"
    s2 = "卖"
    s3 = "取消"

    @commands = [s1, s2, s3]
    refresh
    self.index = 0
  end


这是在Window_ShopCommand里
错了..之前的变回普通颜色删掉就好了..更改一下..
貌似要每个都设置各自颜色有点难度
作者: overpan    时间: 2009-10-28 20:49
提示: 作者被禁止或删除 内容自动屏蔽
作者: Eienshinken    时间: 2009-10-28 20:57
稍微改了下 .分别定义选择项目的颜色成功了.
如果你是所有选择项目都一样颜色的话 用上面的就行了.如果眼分别定义每个选择项目的颜色.用下面的脚本
  1. #==============================================================================
  2. # ■ Window_ShopCommand
  3. #------------------------------------------------------------------------------
  4. #  商店画面、选择要做的事的窗口
  5. #==============================================================================

  6. class Window_ShopCommand < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 64, 480, 64)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     @item_max = 3
  14.     @column_max = 3
  15.     @commands = ["买", "卖", "取消"]
  16.     refresh
  17.     self.index = 0
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 刷新
  21.   #--------------------------------------------------------------------------
  22.   def refresh
  23.     self.contents.clear
  24.     for i in 0...@item_max
  25.       draw_item(i)
  26.     end
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 描绘项目
  30.   #     index : 项目编号
  31.   #--------------------------------------------------------------------------
  32.   def draw_item(index)
  33.     x = 4 + index * 160
  34.     for i in 0..index
  35.       # 买的字体颜色
  36.     if i == 0
  37.       self.contents.font.color = Color.new(255,0,0)
  38.       # 卖的字体颜色
  39.     elsif i == 1
  40.       self.contents.font.color = Color.new(0,255,0)
  41.       # 取消的字体颜色
  42.     elsif i == 2
  43.       self.contents.font.color = Color.new(0,0,255)
  44.     end
  45.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  46.     end
  47.   end
  48. end
复制代码

作者: overpan    时间: 2009-10-28 21:21
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1