Project1

标题: 能把光标改在图片的前面吗光标盖住图片 [打印本页]

作者: 金芒芒    时间: 2016-2-17 17:44
标题: 能把光标改在图片的前面吗光标盖住图片
本帖最后由 金芒芒 于 2016-2-19 14:52 编辑

RUBY 代码复制
  1. class Window_Command_New < Window_Selectable
  2.  
  3.     def initialize(actors=4,enemynums=0)
  4.  
  5.  
  6.     super(160, 20, 968, 620)
  7.     self.contents = Bitmap.new(width - 32, height - 32)
  8.     self.opacity = HS::OPACITY
  9.     @commands = ["装备","物品","魔法","状态","战斗","队列","任务","系统"]
  10.     @item_max = 8
  11.     @column_max = 8
  12.  
  13. #   bitmap = RPG::Cache.icon("菜单")
  14. #   self.contents.blt( - 22,-34, bitmap, Rect.new(-5, -34, 965, 569))
  15.  
  16.     bitmap = RPG::Cache.icon("属性养成")
  17.     self.contents.blt(32, 48, bitmap, Rect.new(0, 0, 65, 24))
  18.     bitmap = RPG::Cache.icon("上阵出战")
  19.     self.contents.blt(99, 48, bitmap, Rect.new(0, 0, 65, 24))
  20.     bitmap = RPG::Cache.icon("出仕下野")
  21.     self.contents.blt(164, 48, bitmap, Rect.new(0, 0, 65, 24))
  22.     bitmap = RPG::Cache.icon("合成进阶")
  23.     self.contents.blt(232, 48, bitmap, Rect.new(0, 0, 65, 24))
  24.     bitmap = RPG::Cache.icon("载入史册")
  25.     self.contents.blt(297, 48, bitmap, Rect.new(0, 0, 65, 24))
  26.     bitmap = RPG::Cache.icon("放马南山")
  27.     self.contents.blt(364, 48, bitmap, Rect.new(0, 0, 65, 24))
  28.  
  29.  
  30.    @actors = actors
  31.    @enemynums = enemynums
  32.    draw_item(0, @actors==0 ? disabled_color : normal_color)
  33.    draw_item(1, normal_color)
  34.    draw_item(2, @actors==0 ? disabled_color : normal_color)
  35.   draw_item(3, @actors==0 ? disabled_color : normal_color)
  36.    draw_item(4, @actors==0 ? disabled_color : normal_color)
  37.   draw_item(5, @actors==0 ? disabled_color : normal_color)
  38.    draw_item(6, normal_color)
  39.    draw_item(7, normal_color)
  40.     self.index = 0
  41.   end
  42.    def draw_item(index, color)
  43.    self.contents.font.color = color
  44.    x = 4 + index % 8 * 70
  45.    y = 2
  46. # y = index / 2 * 32
  47.    rect = Rect.new(x+32, y+47, 0, 0)
  48.    self.contents.fill_rect(rect, Color.new(200, 255,20, 200))#(0, 0, 0, 0))
  49.    self.contents.draw_text(rect, @commands[index], 1)
  50. end
  51. #########################
  52.   def refresh
  53.     self.contents.clear
  54.  
  55.    #  Color.new(红色192, 绿192, 蓝192, 透明255)
  56.     for i in 0...@item_max
  57.       if i ==  self.index #@index  #
  58.         actors = Color.new(220, 200, 20, 255)#  Color.new(红色192, 绿192, 蓝192, 透明255)
  59.         font_name = "黑体"
  60.       else
  61.      actors = normal_color #Color.new(180, 150, 60, 255)#
  62.         font_name = "黑体"
  63.      end
  64.       draw_item(i, color, font_name)#加入各种i=我,颜色,字体,
  65.     end
  66.   end
  67. ######################################################################
  68.   def update_cursor_rect
  69.     # 光标位置不满 0 的情况下
  70.     if @index < 0
  71.       self.cursor_rect.empty
  72.       return
  73.     end
  74.     # 获取当前的行
  75.     row = @index / @column_max
  76.     # 当前行被显示开头行前面的情况下
  77.     if row < self.top_row
  78.       # 从当前行向开头行滚动
  79.       self.top_row = row
  80.     end
  81.     # 当前行被显示末尾行之后的情况下
  82.     if row > self.top_row + (self.page_row_max - 1)
  83.       # 从当前行向末尾滚动
  84.       self.top_row = row - (self.page_row_max - 1)
  85.     end
  86.     # 计算光标的宽
  87.     cursor_width = 68               #600 / (@column_max + 1) - 32
  88.     # 计算光标坐标
  89.        x = 4 + index % 8 * 70
  90.        y = 2
  91.     # 更新国标矩形
  92.     self.cursor_rect.set(x+32, y+47, 70, 28)
  93.   end
  94. end

光标.jpg (226.81 KB, 下载次数: 2)

光标.jpg

44444.jpg (112.5 KB, 下载次数: 1)

44444.jpg

作者: 陈大帅帅帅哥    时间: 2016-2-18 09:05
试试在
  1. # 更新国标矩形
  2.     self.cursor_rect.set(x+32, y+47, 70, 28)
复制代码
后面加一个self.z = 2000(数字只要比图片dz值大就行了)
作者: 金芒芒    时间: 2016-2-18 09:17
矩形光标还是在图片后面,

作者: 金芒芒    时间: 2016-2-18 09:18
陈大帅帅帅哥 发表于 2016-2-18 09:05
试试在后面加一个self.z = 2000(数字只要比图片dz值大就行了)


矩形光标还是在图片后面,
作者: 陈大帅帅帅哥    时间: 2016-2-18 09:27
金芒芒 发表于 2016-2-18 09:18
矩形光标还是在图片后面,

换成9999999试试
作者: 金芒芒    时间: 2016-2-18 09:46
陈大帅帅帅哥 发表于 2016-2-18 09:05
试试在后面加一个self.z = 2000(数字只要比图片dz值大就行了)

还是在图片的后面

作者: 陈大帅帅帅哥    时间: 2016-2-18 09:47
要不你发范例上来,我尽力帮你@金芒芒
作者: 金芒芒    时间: 2016-2-18 09:52
本帖最后由 金芒芒 于 2016-2-18 09:55 编辑
陈大帅帅帅哥 发表于 2016-2-18 09:47
要不你发范例上来,我尽力帮你@金芒芒


https://yunpan.cn/cxStd2QzXFQeW (提取码:ece7)
要不调一下图片z=????

QQ截图20160218095432.jpg (170.78 KB, 下载次数: 4)

QQ截图20160218095432.jpg

作者: 陈大帅帅帅哥    时间: 2016-2-18 15:06
不好意思,学艺不精,弄了半天也没成,要不你去下载一个动态光标脚本试一试

另外,bitmap没有z属性
作者: 紫英晓狼1130    时间: 2016-2-18 17:00
没必要重写Window_Command,在Scene_Menu里建几个精灵就行了
范例里只做了一个为例,查找“★”就能知道在哪儿修改了
Project1.rar (193.39 KB, 下载次数: 60)
作者: 金芒芒    时间: 2016-2-18 18:25
本帖最后由 金芒芒 于 2016-2-18 18:29 编辑
紫英晓狼1130 发表于 2016-2-18 17:00
没必要重写Window_Command,在Scene_Menu里建几个精灵就行了
范例里只做了一个为例,查找“★”就能知道在 ...
  1. class Scene_Menu
  2. def initialize(menu_index = 0)
  3.     @menu_index = menu_index
  4.   def initialize(menu_index = 0)
  5.     @menu_index = menu_index
  6.   end
  7.   def main
  8. #  check_enemy_in_map($game_player.x,$game_player.y)
  9.     Window_Command_New.new($game_party.actors.size)
  10.     cmd.index = @menu_index

  11.     Graphics.transition
  12.     loop do
  13.       Graphics.update
  14.       Input.update
  15.       cmd.update
  16.       if Input.trigger?(Input::B)
  17.         $game_system.se_play($data_system.cancel_se)
  18.         $scene = Scene_Map.new
  19.       end
  20.       if Input.trigger?(Input::C)
  21.         case cmd.index
  22.         when 0
  23.           $game_system.se_play($data_system.buzzer_se)
  24.           $scene = Scene_Equip.new
  25.         when 1
  26.           $game_system.se_play($data_system.decision_se)
  27.           $scene = Scene_Item.new
  28.         when 2
  29.           $game_system.se_play($data_system.decision_se)
  30.           $scene = Scene_Skill.new
  31.         when 3
  32.           $game_system.se_play($data_system.decision_se)
  33.           $scene = Scene_Status.new
  34.         when 4
  35.           $game_system.se_play($data_system.decision_se)
  36.          
  37.         when 5
  38.           $game_system.se_play($data_system.decision_se)
  39.           $scene = Scene_Change_Turn.new
  40.         when 6
  41.           print "可以自己结合叶子的任务系统设计"
  42.         when 7
  43.           print "自己安排什么 储存、读取、什么的等"
  44.         end
  45.       end
  46.       if $scene != self
  47.         break
  48.       end
  49.     end
  50.     Graphics.freeze
  51.     cmd.dispose
  52.   end
  53. end
复制代码
放进去马上就消失了
作者: 金芒芒    时间: 2016-2-18 18:30
紫英晓狼1130 发表于 2016-2-18 17:00
没必要重写Window_Command,在Scene_Menu里建几个精灵就行了
范例里只做了一个为例,查找“★”就能知道在 ...
  1. class Scene_Menu
  2. def initialize(menu_index = 0)
  3.     @menu_index = menu_index
  4.   def initialize(menu_index = 0)
  5.     @menu_index = menu_index
  6.   end
  7.   def main
  8. #  check_enemy_in_map($game_player.x,$game_player.y)
  9.     Window_Command_New.new($game_party.actors.size)
  10.     cmd.index = @menu_index

  11.     Graphics.transition
  12.     loop do
  13.       Graphics.update
  14.       Input.update
  15.       cmd.update
  16.       if Input.trigger?(Input::B)
  17.         $game_system.se_play($data_system.cancel_se)
  18.         $scene = Scene_Map.new
  19.       end
  20.       if Input.trigger?(Input::C)
  21.         case cmd.index
  22.         when 0
  23.           $game_system.se_play($data_system.buzzer_se)
  24.           $scene = Scene_Equip.new
  25.         when 1
  26.           $game_system.se_play($data_system.decision_se)
  27.           $scene = Scene_Item.new
  28.         when 2
  29.           $game_system.se_play($data_system.decision_se)
  30.           $scene = Scene_Skill.new
  31.         when 3
  32.           $game_system.se_play($data_system.decision_se)
  33.           $scene = Scene_Status.new
  34.         when 4
  35.           $game_system.se_play($data_system.decision_se)
  36.          
  37.         when 5
  38.           $game_system.se_play($data_system.decision_se)
  39.           $scene = Scene_Change_Turn.new
  40.         when 6
  41.           print "可以自己结合叶子的任务系统设计"
  42.         when 7
  43.           print "自己安排什么 储存、读取、什么的等"
  44.         end
  45.       end
  46.       if $scene != self
  47.         break
  48.       end
  49.     end
  50.     Graphics.freeze
  51.     cmd.dispose
  52.   end
  53. end
复制代码

作者: 金芒芒    时间: 2016-2-18 18:44
陈大帅帅帅哥 发表于 2016-2-18 15:06
不好意思,学艺不精,弄了半天也没成,要不你去下载一个动态光标脚本试一试

另外,bitmap没有z属性 ...

谢了,大哥
作者: 陈大帅帅帅哥    时间: 2016-2-18 20:27
本帖最后由 陈大帅帅帅哥 于 2016-2-18 20:31 编辑

RUBY 代码复制
  1. class Window_Command_New < Window_Selectable
  2.  
  3.     def initialize(actors=4,enemynums=0)
  4.  
  5.     super(160, 20, 968, 620)
  6.     self.contents = Bitmap.new(width - 32, height - 32)
  7.     self.opacity = HS::OPACITY
  8.     self.z = 90
  9.     @commands = ["装备","物品","魔法","状态","战斗","队列","任务","系统"]
  10.     @item_max = 8
  11.     @column_max = 8
  12.  
  13. #   bitmap = RPG::Cache.icon("菜单")
  14.   #  self.contents.blt( - 22,-34, bitmap, Rect.new(-5, -34, 965, 569))
  15.  
  16.     #bitmap = RPG::Cache.icon("属性养成")
  17.     #self.contents.blt(32, 48, bitmap, Rect.new(0, 0, 65, 24))
  18.  
  19.     #bitmap = RPG::Cache.icon("上阵出战")
  20.     #self.contents.blt(99, 48, bitmap, Rect.new(0, 0, 65, 24))
  21.     #bitmap = RPG::Cache.icon("出仕下野")
  22.     #self.contents.blt(164, 48, bitmap, Rect.new(0, 0, 65, 24))
  23.     #bitmap = RPG::Cache.icon("合成进阶")
  24.     #self.contents.blt(232, 48, bitmap, Rect.new(0, 0, 65, 24))
  25.     #bitmap = RPG::Cache.icon("载入史册")
  26.     #self.contents.blt(297, 48, bitmap, Rect.new(0, 0, 65, 24))
  27.     #bitmap = RPG::Cache.icon("放马南山")
  28.     #self.contents.blt(364, 48, bitmap, Rect.new(0, 0, 65, 24))
  29.  
  30.  
  31.    @actors = actors
  32.    @enemynums = enemynums
  33.    draw_item(0, @actors==0 ? disabled_color : normal_color)
  34.    draw_item(1, normal_color)
  35.    draw_item(2, @actors==0 ? disabled_color : normal_color)
  36.   draw_item(3, @actors==0 ? disabled_color : normal_color)
  37.    draw_item(4, @actors==0 ? disabled_color : normal_color)
  38.   draw_item(5, @actors==0 ? disabled_color : normal_color)
  39.    draw_item(6, normal_color)
  40.    draw_item(7, normal_color)
  41.     self.index = 0
  42.   end
  43.    def draw_item(index, color)
  44.    self.contents.font.color = color
  45.    x = 4 + index % 8 * 70
  46.    y = 2
  47. # y = index / 2 * 32
  48.    rect = Rect.new(x+32, y+47, 0, 0)
  49.    self.contents.fill_rect(rect, Color.new(200, 255,20, 200))#(0, 0, 0, 0))
  50.    self.contents.draw_text(rect, @commands[index], 1)
  51. end
  52. #########################
  53.   def refresh
  54.     self.contents.clear
  55.  
  56.    #  Color.new(红色192, 绿192, 蓝192, 透明255)
  57.     for i in 0...@item_max
  58.       if i ==  self.index #@index  #
  59.         actors = Color.new(220, 200, 20, 255)#  Color.new(红色192, 绿192, 蓝192, 透明255)
  60.         font_name = "黑体"
  61.       else
  62.      actors = normal_color #Color.new(180, 150, 60, 255)#
  63.         font_name = "黑体"
  64.      end
  65.       draw_item(i, color, font_name)#加入各种i=我,颜色,字体,
  66.     end
  67.   end
  68. ######################################################################
  69.   def update_cursor_rect
  70.     # 光标位置不满 0 的情况下
  71.     if @index < 0
  72.       self.cursor_rect.empty
  73.       return
  74.     end
  75.     # 获取当前的行
  76.     row = @index / @column_max
  77.     # 当前行被显示开头行前面的情况下
  78.     if row > self.top_row #<
  79.       # 从当前行向开头行滚动
  80.       self.top_row = row
  81.     end
  82.     # 当前行被显示末尾行之后的情况下
  83.     if row > self.top_row + (self.page_row_max - 1)
  84.       # 从当前行向末尾滚动
  85.       self.top_row = row - (self.page_row_max - 1)
  86.     end
  87.     # 计算光标的宽
  88.     cursor_width = 68               #600 / (@column_max + 1) - 32
  89.     # 计算光标坐标
  90.        x = 4 + index % 8 * 70
  91.        y = 2
  92.  
  93.     # 更新国标矩形
  94.     self.cursor_rect.set(x+32, y+47, 68, 28)
  95.  
  96.   end
  97. end
  98.  
  99.  
  100.  
  101. class Scene_Menu
  102.   def initialize(menu_index = 0)
  103.     @menu_index = menu_index
  104.   end
  105.   def main
  106. #卐-----------------------------------------------------------------------------
  107.     @sxyc = Sprite.new
  108.     @szcz = Sprite.new
  109.     @csxy = Sprite.new
  110.     @hcjj = Sprite.new
  111.     @zrsc = Sprite.new
  112.     @fmns = Sprite.new
  113.     @sxyc.bitmap = RPG::Cache.icon("属性养成")
  114.     @szcz.bitmap = RPG::Cache.icon("上阵出战")
  115.     @csxy.bitmap = RPG::Cache.icon("出仕下野")
  116.     @hcjj.bitmap = RPG::Cache.icon("合成进阶")
  117.     @zrsc.bitmap = RPG::Cache.icon("载入史册")
  118.     @fmns.bitmap = RPG::Cache.icon("放马南山")
  119.     @sxyc.x = 62
  120.     @sxyc.y = 80
  121.     @sxyc.z = 91
  122.     @szcz.x = 129
  123.     @szcz.y = 80
  124.     @szcz.z = 91
  125.     @csxy.x = 194
  126.     @csxy.y = 80
  127.     @csxy.z = 91
  128.     @hcjj.x = 262
  129.     @hcjj.y = 80
  130.     @hcjj.z = 91
  131.     @zrsc.x = 327
  132.     @zrsc.y = 80
  133.     @zrsc.z = 91
  134.     @fmns.x = 394
  135.     @fmns.y = 80
  136.     @fmns.z = 91
  137. #卐-----------------------------------------------------------------------------
  138. #   check_enemy_in_map($game_player.x,$game_player.y)
  139.     cmd = Window_Command_New.new($game_party.actors.size)
  140.     cmd.index = @menu_index
  141.  
  142.     Graphics.transition
  143.     loop do
  144.       Graphics.update
  145.       Input.update
  146.       cmd.update
  147.       if Input.trigger?(Input::B)
  148.         $game_system.se_play($data_system.cancel_se)
  149.         $scene = Scene_Map.new
  150.       end
  151.       if Input.trigger?(Input::C)
  152.         case cmd.index
  153.         when 0
  154.           $game_system.se_play($data_system.buzzer_se)
  155.           $scene = Scene_Equip.new
  156.         when 1
  157.           $game_system.se_play($data_system.decision_se)
  158.           $scene = Scene_Item.new
  159.         when 2
  160.           $game_system.se_play($data_system.decision_se)
  161.           $scene = Scene_Skill.new
  162.         when 3
  163.           $game_system.se_play($data_system.decision_se)
  164.           $scene = Scene_Status.new
  165.         when 4
  166.           $game_system.se_play($data_system.decision_se)
  167.  
  168.         when 5
  169.           $game_system.se_play($data_system.decision_se)
  170.           $scene = Scene_Change_Turn.new
  171.         when 6
  172.           print "可以自己结合叶子的任务系统设计"
  173.         when 7
  174.           print "自己安排什么 储存、读取、什么的等"
  175.         end
  176.       end
  177.       if $scene != self
  178.         break
  179.       end
  180.     end
  181.     Graphics.freeze
  182.     cmd.dispose
  183. #卐-----------------------------------------------------------------------------
  184.     # ★释放精灵
  185.     @sxyc.dispose
  186.     @szcz.dispose
  187.     @csxy.dispose
  188.     @hcjj.dispose
  189.     @zrsc.dispose
  190.     @fmns.dispose
  191. #卐-----------------------------------------------------------------------------
  192.   end
  193. end


根据刚刚的大神的思路弄了一晚上(果然自己太渣了)
x值和y值你自己调一下,z值最好不要动
这段脚本替换Scene_Menu
作者: 金芒芒    时间: 2016-2-18 20:37
本帖最后由 金芒芒 于 2016-2-18 21:11 编辑
陈大帅帅帅哥 发表于 2016-2-18 20:27
class Window_Command_New < Window_Selectable
   
    def initialize(actors=4,enemynums=0)


刚刚的是大神,你我送你4个字:我以成仙:

QQ截图20160218210936.jpg (165.04 KB, 下载次数: 6)

QQ截图20160218210936.jpg

QQ截图20160218211036.jpg (227.68 KB, 下载次数: 2)

QQ截图20160218211036.jpg





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