Project1

标题: 这个描边脚本怎么设计成在某个字后面加上1@就不同颜色 [打印本页]

作者: eu国猪    时间: 2012-5-20 19:24
标题: 这个描边脚本怎么设计成在某个字后面加上1@就不同颜色
本帖最后由 hcm 于 2012-6-1 13:35 编辑

这个描边脚本怎么设计成在武器名字后面加上1@就不同颜色,加上@2又不同颜色
  1. #==================描边================================================

  2. class Bitmap
  3. unless $OK
  4.   alias NKX_draw_text draw_text unless method_defined? :NKX_draw_text
  5. def draw_text(p1, p2, p3 = 0, p4 = 3, p5 = nil, p6 = 0, p7 = 3, p8 = nil)
  6.      case p1
  7.      when Numeric
  8.        x = p1
  9.        y = p2
  10.        width = p3
  11.        height = p4
  12.        text = p5
  13.        align = p6
  14.        shadow_direction = p7
  15.        shadow_color = p8
  16.        if shadow_color.nil?
  17.          shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.67)
  18.        end
  19.      when Rect
  20.        x = p1.x
  21.        y = p1.y
  22.        width = p1.width
  23.        height = p1.height
  24.        text = p2
  25.        align = p3
  26.        shadow_direction = p4
  27.        shadow_color = p5
  28.        if shadow_color.nil?
  29.          shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.67)
  30.        end
  31.      end
  32.      color_temp = self.font.color.clone
  33.   self.font.color = Color.new(0, 0, 255, 255)
  34.     NKX_draw_text(x + 1,y + 1,width, height, text, align)
  35.     NKX_draw_text(x + 1,y - 1,width, height, text, align)
  36.     NKX_draw_text(x - 1,y - 1,width, height, text, align)
  37.     NKX_draw_text(x - 1,y + 1,width, height, text, align)
  38.   self.font.color = color_temp
  39.      $OK = true
  40.      NKX_draw_text(x, y, width, height, text, align)
  41.    end
  42. end
  43. end
复制代码
dsu_plus_rewardpost_czw
作者: tommay    时间: 2012-5-20 19:41
本帖最后由 tommay 于 2012-5-20 19:42 编辑

楼主是要不同的武器可以在菜单中显示不同的颜色吧?
作者: hys111111    时间: 2012-5-20 19:53
本帖最后由 hys111111 于 2012-5-20 20:01 编辑

首先,在脚本编辑器Main前面添加这个东西
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   def draw_item(index)
  8.     item = @data[index]
  9.     case item
  10.     when RPG::Item
  11.       number = $game_party.item_number(item.id)
  12.     when RPG::Weapon
  13.       number = $game_party.weapon_number(item.id)
  14.     when RPG::Armor
  15.       number = $game_party.armor_number(item.id)
  16.     end
  17.    
  18.     if item.is_a?(RPG::Item) and
  19.       $game_party.item_can_use?(item.id)
  20.       self.contents.font.color = normal_color
  21.     else
  22.       self.contents.font.color = disabled_color
  23.     end
  24.    
  25.     x = 4 + index % 2 * (288 + 32)
  26.     y = index / 2 * 32
  27.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  28.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  29.     bitmap = RPG::Cache.icon(item.icon_name)
  30.     opacity = self.contents.font.color == normal_color ? 255 : 128
  31.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

  32.     case item.name.split('@')[1].to_i
  33.     when 1  #"红色"
  34.       self.contents.font.color = Color.new(255,0,0)
  35.     when 2  #"橙色"
  36.       self.contents.font.color = Color.new(255,100,0)
  37.     when 3  #"黄色"
  38.       self.contents.font.color = Color.new(255,255,0)
  39.     when 4  #"绿色"
  40.       self.contents.font.color = Color.new(0,255,0)
  41.     when 5  #"青色"
  42.       self.contents.font.color = Color.new(0,255,255)
  43.     when 6  #"蓝色"
  44.       self.contents.font.color = Color.new(0,0,255)
  45.     when 7  #"紫色"
  46.       self.contents.font.color = Color.new(255,0,255)
  47.     end

  48.     self.contents.draw_text(x + 28, y, 212, 32, item.name.split('@')[0] , 0)
  49.    
  50.     if item.is_a?(RPG::Item) and
  51.       $game_party.item_can_use?(item.id)
  52.       self.contents.font.color = normal_color
  53.     else
  54.       self.contents.font.color = disabled_color
  55.     end
  56.    
  57.    
  58.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  59.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  60.   end
  61. end
复制代码
格式:物品名称后面加上:@颜色编号

效果如此:

另外,这张图中有些问题,现在已经修复
作者: eu国猪    时间: 2012-5-21 13:18
哦谢谢




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