Project1

标题: 关于消息框中更改装备名的颜色 [打印本页]

作者: 幻耶    时间: 2009-7-8 10:21
标题: 关于消息框中更改装备名的颜色
本帖最后由 幻耶 于 2009-7-9 08:44 编辑

用了enghao_Lim的打造随机装备脚本,那脚本的末尾有获得新装备的提示框,能否在提示框中就显示不同颜色的字体?
比如:如果获得的新防具名称中包含有”神话“两个字的,提示框里的字就是金色的:Color.new(255,215,0)



获得新防具的提示框脚本部分
#==============================================================================
# ■获得新防具盾
#==============================================================================
def get_armor1(armor_name, n)
  @armor_name = armor_name
  for i in 1...$data_armors.size
    if $data_armors.name ==  @armor_name
      @armor_id = i
    end
  end
  $game_party.gain_armor(@armor_id, n)
  enghao_showbar_armor = $data_armors[@armor_id]
  enghao_showbar = Window_Base.new((640-300)/2,128,300,100)
  enghao_showbar.contents = Bitmap.new(enghao_showbar.width - 32, enghao_showbar.height - 32)
  if n >= 0
    enghao_showbar.contents.draw_text(0,0,240,32,"获得防具:")
    Audio.se_play("Audio/SE/"+"006-System06",80,100)
  else
    enghao_showbar.contents.draw_text(0,0,240,32,"失去防具:")
    Audio.se_play("Audio/SE/"+"005-System05",80,100)
  end
  enghao_showbar_bitmap = RPG::Cache.icon(enghao_showbar_armor.icon_name)
  enghao_showbar.contents.blt(0, 32, enghao_showbar_bitmap, Rect.new(0, 0, 24, 24), 255)
  enghao_showbar.contents.draw_text(0 + 28, 32, 212, 32, enghao_showbar_armor.name, 0)
  enghao_showbar.contents.draw_text(0, 32, 268, 32, "×"+n.abs.to_s, 2)
  enghao_showbar.opacity = 160
  for i in 0...30
    Graphics.update
  end
  for i in 0...10
    enghao_showbar.opacity -= 30
    enghao_showbar.contents_opacity -= 30
    Graphics.update
  end
  enghao_showbar.dispose
end
作者: 幻耶    时间: 2009-7-9 08:44
顶.........
作者: IamI    时间: 2009-7-9 08:57
改成如下的部分。我想设定应该能很容易看懂吧
不过没有全部脚本,没有测试过。
  1. #==============================================================================
  2. # ■获得新防具盾
  3. #==============================================================================
  4. def get_armor1(armor_name, n)
  5.   @armor_name = armor_name
  6.   for i in 1...$data_armors.size
  7.     if $data_armors.name ==  @armor_name
  8.       @armor_id = i
  9.     end
  10.   end
  11.   $game_party.gain_armor(@armor_id, n)
  12.   enghao_showbar_armor = $data_armors[@armor_id]
  13.   enghao_showbar = Window_Base.new((640-300)/2,128,300,100)
  14.   enghao_showbar.contents = Bitmap.new(enghao_showbar.width - 32, enghao_showbar.height - 32)
  15.   if n >= 0
  16.     enghao_showbar.contents.draw_text(0,0,240,32,"获得防具:")
  17.     Audio.se_play("Audio/SE/"+"006-System06",80,100)
  18.   else
  19.     enghao_showbar.contents.draw_text(0,0,240,32,"失去防具:")
  20.     Audio.se_play("Audio/SE/"+"005-System05",80,100)
  21.   end
  22.   enghao_showbar_bitmap = RPG::Cache.icon(enghao_showbar_armor.icon_name)
  23.   enghao_showbar.contents.blt(0, 32, enghao_showbar_bitmap, Rect.new(0, 0, 24, 24), 255)
  24.   #---------------------sign-------------------------
  25.   if enghao_showbar_armor.name[/神话/] != nil
  26.     enghao_showbar.contents.font.color = Color.new(255,215,0)
  27.   end
  28.   #--------------------------------------------------
  29.   enghao_showbar.contents.draw_text(0 + 28, 32, 212, 32, enghao_showbar_armor.name, 0)
  30.   #---------------------sign-------------------------
  31.   enghao_showbar.contents.font.color = normal_color
  32.   #--------------------------------------------------
  33.   enghao_showbar.contents.draw_text(0, 32, 268, 32, "×"+n.abs.to_s, 2)

  34.   enghao_showbar.opacity = 160
  35.   for i in 0...30
  36.     Graphics.update
  37.   end
  38.   for i in 0...10
  39.     enghao_showbar.opacity -= 30
  40.     enghao_showbar.contents_opacity -= 30
  41.     Graphics.update
  42.   end
  43.   enghao_showbar.dispose
  44. end
复制代码

作者: 幻耶    时间: 2009-7-9 09:10
显示出错,normal_color未定义,不过替换成Color.new(255,255,255)应该也可以吧?谢谢了
作者: IamI    时间: 2009-7-9 09:17
啥?不是窗口类?某只在Base里翻了半天默认颜色的默立中




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