设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2425|回复: 14
打印 上一主题 下一主题

[已经过期] 求修改这个出错的窗口类脚本,让它不会出错

[复制链接]

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
跳转到指定楼层
1
发表于 2013-9-28 15:42:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
思路就是这样的:
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_SquareBattleActorMessge
  3. #------------------------------------------------------------------------------
  4. #  显示角色信息的类,归到窗口类为了方便。
  5. #==============================================================================
  6.  
  7. class Window_SquareBattleActorMessge < Window_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化窗口
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(0, 480 - 32, 160, 32)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.opacity = 0
  15.     refresh
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     # 角色の绘制
  23.     if $game_party.actors.size != 0
  24.       @x1 = 16
  25.       @x2 = 176
  26.       @x3 = 332
  27.       @x4 = 496
  28.       @ay = 0
  29.       # 一号角色
  30.       if $game_party.actors.include?($game_actors[1])
  31.         draw_actor_head(1, @x1, @ay)
  32.         @a1hp = 1.000000 / $game_actors[1].maxhp * $game_actors[1].hp
  33.         @a1hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  34.         @a1hpzao.x = @x1 + 64
  35.         @a1hpzao.y = @ay + 16
  36.         @a1hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  37.         @a1hptiao.x = @a1xuetiao.x + 1
  38.         @a1hptiao.y = @a1xuetiao.y + 1
  39.         @a1hptiao.zoom_x = @a1hp
  40.         @a1sp = 1.000000 / $game_actors[1].maxsp * $game_actors[1].sp
  41.         @a1spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  42.         @a1spzao.x = @x1 + 64
  43.         @a1spzao.y = @ay + 32
  44.         @a1sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  45.         @a1sptiao.x = @a1xuetiao.x + 1
  46.         @a1sptiao.y = @a1xuetiao.y + 1
  47.         @a1sptiao.zoom_x = @a1sp
  48.         @a1mor = 1.000000 / 100 * $game_actors[1].mor
  49.         @a1morzao = Bitmap.new("Graphics/Pictures/mor槽")
  50.         @a1morzao.x = @x1 + 64
  51.         @a1morzao.y = @ay + 48
  52.         @a1mortiao = Bitmap.new("Graphics/Pictures/mor槽(填充)")
  53.         @a1mortiao.x = @a1xuetiao.x + 1
  54.         @a1mortiao.y = @a1xuetiao.y + 1
  55.         @a1mortiao.zoom_x = @a1mor
  56.       end
  57.       # 二号角色
  58.       if $game_party.actors.include?($game_actors[2])
  59.         if $game_party.actors.include?($game_actors[1])
  60.           draw_actor_head(2, @x2, @ay)
  61.         else
  62.           draw_actor_head(2, @x1, @ay)
  63.         end
  64.         @a2hp = 1.000000 / $game_actors[2].maxhp * $game_actors[2].hp
  65.         @a2hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  66.         if $game_party.actors.include?($game_actors[1])
  67.           @a2hpzao.x = @x2 + 64
  68.         else
  69.           @a2hptiao.x = @x1 + 64
  70.         end
  71.         @a2hpzao.y = @ay + 16
  72.         @a2hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  73.         @a2hptiao.x = @a1xuetiao.x + 1
  74.         @a2hptiao.y = @a1xuetiao.y + 1
  75.         @a2hptiao.zoom_x = @a1hp
  76.         @a2sp = 1.000000 / $game_actors[2].maxsp * $game_actors[2].sp
  77.         @a2spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  78.         if $game_party.actors.include?($game_actors[1])
  79.           @a2spzao.x = @x2 + 64
  80.         else
  81.           @a2spzao.x = @x1 + 64
  82.         end
  83.         @a2spzao.y = @ay + 32
  84.         @a2sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  85.         @a2sptiao.x = @a1xuetiao.x + 1
  86.         @a2sptiao.y = @a1xuetiao.y + 1
  87.         @a2sptiao.zoom_x = @a1sp
  88.         @a2mor = 1.000000 / 100 * $game_actors[2].mor
  89.         @a2morzao = Bitmap.new("Graphics/Pictures/mor槽")
  90.         if $game_party.actors.include?($game_actors[1])
  91.           @a2morzao.x = @x2 + 64
  92.         else
  93.           @a2morzao.x = @x1 + 64
  94.         end
  95.         @a2morzao.y = @ay + 48
  96.         @a2mortiao = Bitmap.new("Graphics/Pictures/mor槽(填充)")
  97.         @a2mortiao.x = @a1xuetiao.x + 1
  98.         @a2mortiao.y = @a1xuetiao.y + 1
  99.         @a2mortiao.zoom_x = @a1mor
  100.       end
  101.       # 三号角色
  102.       if $game_party.actors.include?($game_actors[3])
  103.         if $game_party.actors.include?($game_actors[1])
  104.           if $game_party.actors.include?($game_actors[2])
  105.             draw_actor_head(3, @x3, @ay)
  106.           else
  107.             draw_actor_head(3, @x2, @ay)
  108.           end
  109.         elsif $game_party.actors.include?($game_actors[2])
  110.           draw_actor_head(3, @x2, @ay)
  111.         else
  112.           draw_actor_head(3, @x1, @ay)
  113.         end
  114.         @a3hp = 1.000000 / $game_actors[3].maxhp * $game_actors[3].hp
  115.         @a3hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  116.         @a3hpzao.y = @ay + 16
  117.         @a3hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  118.         @a3hptiao.x = @a1xuetiao.x + 1
  119.         @a3hptiao.y = @a1xuetiao.y + 1
  120.         @a3hptiao.zoom_x = @a1hp
  121.         @a3sp = 1.000000 / $game_actors[3].maxsp * $game_actors[3].sp
  122.         @a3spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  123.         @a3spzao.y = @ay + 32
  124.         @a3sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  125.         @a3sptiao.x = @a1xuetiao.x + 1
  126.         @a3sptiao.y = @a1xuetiao.y + 1
  127.         @a3sptiao.zoom_x = @a1sp
  128.         @a3mor = 1.000000 / 100 * $game_actors[3].mor
  129.         @a3morzao = Bitmap.new("Graphics/Pictures/mor槽")
  130.         @a3morzao.y = @ay + 48
  131.         @a3mortiao = Bitmap.new("Graphics/Pictures/mor槽(填充)")
  132.         @a3mortiao.x = @a1xuetiao.x + 1
  133.         @a3mortiao.y = @a1xuetiao.y + 1
  134.         @a3mortiao.zoom_x = @a1mor
  135.         if $game_party.actors.include?($game_actors[1])
  136.           if $game_party.actors.include?($game_actors[2])
  137.             @a3hpzao.x = @x3 + 64
  138.             @a3spzao.x = @x3 + 64
  139.             @a3morzao.x = @x3 + 64
  140.           else
  141.             @a3hpzao.x = @x2 + 64
  142.             @a3spzao.x = @x2 + 64
  143.             @a3morzao.x = @x2 + 64
  144.           end
  145.         elsif $game_party.actors.include?($game_actors[2])
  146.           @a3hpzao.x = @x2 + 64
  147.           @a3spzao.x = @x2 + 64
  148.           @a3morzao.x = @x2 + 64
  149.         else
  150.           @a3hpzao.x = @x1 + 64
  151.           @a3spzao.x = @x1 + 64
  152.           @a3morzao.x = @x1 + 64
  153.         end
  154.       end
  155.       # 四号角色
  156.       if $game_party.actors.include?($game_actors[4])
  157.         if $game_party.actors.include?($game_actors[1])
  158.           if $game_party.actors.include?($game_actors[2])
  159.             if $game_party.actors.include?($game_actors[3])
  160.               draw_actor_head(4, @x4, @ay)
  161.             else
  162.               draw_actor_head(4, @x3, @ay)
  163.             end
  164.           elsif $game_party.actors.include?($game_actors[3])
  165.             draw_actor_head(4, @x3, @ay)
  166.           else
  167.             draw_actor_head(4, @x2, @ay)
  168.           end
  169.         elsif $game_party.actors.include?($game_actors[2])
  170.           if $game_party.actors.include?($game_actors[3])
  171.             draw_actor_head(4, @x3, @ay)
  172.           else
  173.             draw_actor_head(4, @x2, @ay)
  174.           end
  175.         elsif $game_party.actors.include?($game_actors[3])
  176.           draw_actor_head(4, @x2, @ay)
  177.         else
  178.           draw_actor_head(4, @x1, @ay)
  179.         end
  180.         @a4hp = 1.000000 / $game_actors[4].maxhp * $game_actors[4].hp
  181.         @a4hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  182.         @a4hpzao.y = @ay + 16
  183.         @a4hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  184.         @a4hptiao.x = @a1xuetiao.x + 1
  185.         @a4hptiao.y = @a1xuetiao.y + 1
  186.         @a4hptiao.zoom_x = @a1hp
  187.         @a4sp = 1.000000 / $game_actors[4].maxsp * $game_actors[4].sp
  188.         @a4spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  189.         @a4spzao.y = @ay + 32
  190.         @a4sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  191.         @a4sptiao.x = @a1xuetiao.x + 1
  192.         @a4sptiao.y = @a1xuetiao.y + 1
  193.         @a4sptiao.zoom_x = @a1sp
  194.         @a4mor = 1.000000 / 100 * $game_actors[4].mor
  195.         @a4morzao = Bitmap.new("Graphics/Pictures/mor槽")
  196.         @a4morzao.y = @ay + 48
  197.         @a4mortiao = Bitmap.new("Graphics/Pictures/mor槽(填充)")
  198.         @a4mortiao.x = @a1xuetiao.x + 1
  199.         @a4mortiao.y = @a1xuetiao.y + 1
  200.         @a4mortiao.zoom_x = @a1mor
  201.         if $game_party.actors.include?($game_actors[1])
  202.           if $game_party.actors.include?($game_actors[2])
  203.             if $game_party.actors.include?($game_actors[3])
  204.               @a4hpzao.x = @x4 + 64
  205.               @a4spzao.x = @x4 + 64
  206.               @a4morzao.x = @x4 + 64
  207.             else
  208.               @a4hpzao.x = @x3 + 64
  209.               @a4spzao.x = @x3 + 64
  210.               @a4morzao.x = @x3 + 64
  211.             end
  212.           elsif $game_party.actors.include?($game_actors[3])
  213.             @a4hpzao.x = @x3 + 64
  214.             @a4spzao.x = @x3 + 64
  215.             @a4morzao.x = @x3 + 64
  216.           else
  217.             @a4hpzao.x = @x2 + 64
  218.             @a4spzao.x = @x2 + 64
  219.             @a4morzao.x = @x2 + 64
  220.           end
  221.         elsif $game_party.actors.include?($game_actors[2])
  222.           if $game_party.actors.include?($game_actors[3])
  223.             @a4hpzao.x = @x3 + 64
  224.             @a4spzao.x = @x3 + 64
  225.             @a4morzao.x = @x3 + 64
  226.           else
  227.             @a4hpzao.x = @x2 + 64
  228.             @a4spzao.x = @x2 + 64
  229.             @a4morzao.x = @x2 + 64
  230.           end
  231.         elsif $game_party.actors.include?($game_actors[3])
  232.           @a4hpzao.x = @x2 + 64
  233.           @a4spzao.x = @x2 + 64
  234.           @a4morzao.x = @x2 + 64
  235.         else
  236.           @a4hpzao.x = @x1 + 64
  237.           @a4spzao.x = @x1 + 64
  238.           @a4morzao.x = @x1 + 64
  239.         end
  240.       end
  241.     end
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 刷新画面
  245.   #--------------------------------------------------------------------------
  246.   def update
  247.     super
  248.     if @a1hptiao != 1.000000 / $game_actors[1].maxhp * $game_actors[1].hp or @a2hptiao != 1.000000 / $game_actors[2].maxhp * $game_actors[2].hp or @a3hptiao != 1.000000 / $game_actors[3].maxhp * $game_actors[3].hp or @a4hptiao != 1.000000 / $game_actors[4].maxhp * $game_actors[4].hp or @a1sptiao != 1.000000 / $game_actors[1].maxsp * $game_actors[1].sp or @a2sptiao != 1.000000 / $game_actors[2].maxsp * $game_actors[2].sp or @a3sptiao != 1.000000 / $game_actors[3].maxsp * $game_actors[3].sp or @a4sptiao != 1.000000 / $game_actors[4].maxsp * $game_actors[4].sp or @a1mortiao != 1.000000 / 100 * $game_actors[1].mor or @a2mortiao != 1.000000 / 100 * $game_actors[2].mor or @a3mortiao != 1.000000 / 100 * $game_actors[3].mor or @a4mortiao != 1.000000 / 100 * $game_actors[4].mor
  249.       refresh
  250.     end
  251.   end
  252. end
总是出错,还不显示.
MOR我已经定义了,ZTBS用的。
draw_actor_head方法:
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 头像的描绘
  3.   #     actor : 角色
  4.   #     x     : 描画目标 X 坐标
  5.   #     y     : 描画目标 Y 坐标
  6.   #--------------------------------------------------------------------------
  7.   def draw_actor_head(actor, x, y)
  8.     bitmap = RPG::Cache.picture(actor.character_name + "_h", actor.character_hue)
  9.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  10.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  11.   end

素材库:
素材库.zip (67.83 KB, 下载次数: 32)
呃,发糖贴好冷清呀!

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
2
发表于 2013-9-30 17:24:06 | 只看该作者
本帖最后由 恋′挂机 于 2013-9-30 17:34 编辑
  1.   #--------------------------------------------------------------------------
  2.   # ● 刷新
  3.   #--------------------------------------------------------------------------
  4.   def refresh
  5.     self.contents.clear
  6.     @item_max = $game_party.actors.size
  7.     for i in 0...$game_party.actors.size
  8.       x = 64
  9.       y = i * 116
  10.       actor = $game_party.actors[i]
  11.       draw_actor_graphic(actor, x - 40, y + 80)
  12.       draw_actor_name(actor, x, y)
  13.       draw_actor_class(actor, x + 144, y)
  14.       draw_actor_level(actor, x, y + 32)
  15.       draw_actor_state(actor, x + 90, y + 32)
  16.       draw_actor_exp(actor, x, y + 64)
  17.       draw_actor_hp(actor, x + 236, y + 32)
  18.       draw_actor_sp(actor, x + 236, y + 64)
  19.     end
  20.   end
复制代码
这个默认的显示角色信息的脚本,就是个很好的范例,
大可照着这个写,
也会随时刷新,
你脚本248行,绝对的莫名其妙

只想在index变化时刷新(节省内存)是要这样写的:
  1. def update
  2. super
  3. if self.index != @old_index
  4. refresh
  5. @old_index = self.index
  6. end
  7. end
复制代码
老不显示,有下面几种可能:
(在你脚本主体无误的情况下)
1.没有在地图场景上调用
2.坐标值过大或过小,也就是描绘的内容在屏幕外
3.窗口处于透明状态(opacity contents_opacity)
4.窗口处于不显示状态(visible)
5.窗口自身坐标过大或过小
(脚本主体有误)
6.不说了

据我分析,
你脚本主体就出了问题,
(我没看,只是大眼一扫得出的结论)
你是先判断角色一,看在没在队伍中,如果在的话去描绘,不在的话去判断第二个角色,第二个角色所描绘的内容又有了一个新的坐标
也就是说,假如,队伍中只有角色2,并且脚本也是正确的,那么角色2的信息不会描绘在窗口顶端(因为空出了一个角色1的坐标)

评分

参与人数 1星屑 +105 收起 理由
myownroc + 105 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
3
 楼主| 发表于 2013-9-30 17:39:51 | 只看该作者
恋′挂机 发表于 2013-9-30 17:24
这个默认的显示角色信息的脚本,就是个很好的范例,
大可照着这个写,
也会随时刷新,

追问:
这个我根本不会改,求把修改后的脚本奉献上来。
这个专门显示血条的,默认的就不是了。
呃,发糖贴好冷清呀!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
4
发表于 2013-9-30 18:02:02 | 只看该作者
我不是很会描绘矩形,直接拿黑暗圣剑传说的脚本,但添上了注释
看这个之前有个基础需要了解
矩形:Rect.new(x, y, width, height)
描绘矩形:fill_rect(rect, color) fill_rect(x, y, width, height, color)
请先想办法弄懂上面的知识,其实大概看下F1帮助,再看下方注释。
  1.   # 定义新方法名,就相当于Window_Base的draw_actor_hp
  2.   # 带有四个参数,角色,你给谁描绘血条呢?给这个角色
  3.   # 参数描绘,相对的X,Y坐标,以及血条的宽度
  4.   # 方法名完全可以改为draw_actor_hp,在window中用
  5.   def carol3_draw_hp_bar(actor, x, y, width = 128)
  6.     # 自身文字颜色为系统文字色
  7.     self.contents.font.color = system_color
  8.     # 填充矩形fill_rect(x, y, width, height, color)
  9.     # 可以看到,填充的颜色是(0, 0, 0, 255)这就
  10.     # 是血条的底色了(也就是红条覆盖的黑条)
  11.     self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
  12.     # 计算红条宽度,很简单。宽度 = 角色当前HP / 最大HP × 宽度
  13.     w = width * actor.hp / actor.maxhp
  14.     # 填充矩形,要不颜色太单调,也不好看,下面四行不是重点
  15.     self.contents.fill_rect(x, y+18, w,1, Color.new(255, 96, 96, 255))
  16.     self.contents.fill_rect(x, y+19, w,1, Color.new(255, 0, 0, 255))
  17.     self.contents.fill_rect(x, y+20, w,1, Color.new(128, 0, 0, 255))
  18.     self.contents.fill_rect(x, y+21, w,1, Color.new(0, 0, 0, 255))
  19.     # 描绘“HP”这两字母,实际上是数据库中HP的用语
  20.     self.contents.draw_text(x,y,128,32,$data_system.words.hp,1)
  21.     # 自身文字色改为普通文字色(白色)
  22.     self.contents.font.color = normal_color
  23.   end
  24.   # 下方的基本一样,就不多废话了,只说不一样的地方。
  25.   def carol3_draw_sp_bar(actor, x, y, width = 128)
  26.     self.contents.font.color = system_color
  27.     self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
  28.     # 如果角色的最大SP为0,比如说,有些怪物是不会使用魔法的。
  29.     if actor.maxsp == 0
  30.       # 那么让蓝条的宽度为0
  31.       w = 0
  32.     # 其他情况,也就是最大SP不为0
  33.     else
  34.       # 计算宽度,和上方一模一样
  35.       w = width * actor.sp / actor.maxsp
  36.     end#end
  37.     #下方就不多说了。
  38.     self.contents.fill_rect(x, y+18, w,1, Color.new(128, 255, 255, 255))
  39.     self.contents.fill_rect(x, y+19, w,1, Color.new(0, 255, 255, 255))
  40.     self.contents.fill_rect(x, y+20, w,1, Color.new(0, 192, 192, 255))
  41.     self.contents.fill_rect(x, y+21, w,1, Color.new(0, 128, 128, 255))
  42.     self.contents.draw_text(x,y,128,32,$data_system.words.sp,1)
  43.     self.contents.font.color = normal_color
  44.   end
复制代码

评分

参与人数 1星屑 +60 收起 理由
myownroc + 60 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
5
 楼主| 发表于 2013-9-30 18:04:47 | 只看该作者
恋′挂机 发表于 2013-9-30 18:02
我不是很会描绘矩形,直接拿黑暗圣剑传说的脚本,但添上了注释
看这个之前有个基础需要了解
矩形:Rect.new ...

追问:
不要“HP”、“SP”字样,还有MOR的描绘(MOR系统中应该为“CP”)。
用我的素材来描绘可以吗?
思路不变,出错地方改变。
呃,发糖贴好冷清呀!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
6
发表于 2013-9-30 18:12:48 | 只看该作者
用你的其实也可以,很麻烦
(先要除错,又要一个一个
判断非常是麻烦)
删去相应文字描绘语句,就能不描绘用语

我是不会帮你改的了(如果按你的思路的话,也就是一个角色一个角色判断)
CP?
CP制战斗?
我对这个不是很了解,如果是战斗中。。我劝你还是用别人现成脚本吧,


图片描绘类似的血条,也是不难的,就是利用矩形的不同宽度实现对图片宽度的调整
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

7
发表于 2013-9-30 19:05:28 | 只看该作者
首先先吐槽一下楼主的代码,基本上可以丢掉重写了,思路根本不对,尤其是分别刻画角色的各种属性,一个个穷举,不但代码复杂,而且很容易出错。建议楼主多研究一下RGSS的代码结构,否则由于理解不深刻,代码根本不能运行。
比如说13行创建bitmap对象,楼主用height-32代表高度,但是height的含义是窗口的高度,你在前面定义窗口高度也是32,那么bitmap的高度是32-32=0,RGSS不能创造大小为0的位图,因此导致失败。
再比如说31行draw_actor_head(1,x,y),你定义draw_actor_head的第一个参数是Game_Actor类型,代入的参数却是Fixnum类的1,这样的错误希望楼主注意。
还有就是混淆bitmap类和sprite类的概念,bitmap类没有定义x坐标这样一个属性,所以bitmap.x(bitmap是Bitmap类的一个实例)这样的指令是非法的,而sprite类却有x坐标这一个属性。所以对x坐标进行访问的是Sprite类而不是Bitmap类。
说了这么多,可能有点不太中听,不过希望楼主能认真理解这些代码的含义,这样才能写出自己想要的脚本。


下面是我自己弄的一个脚本,功能跟你的差不多,就是在地图上显示人物的各种信息。
那个CP是RTBS的东西,我没那个系统,但是楼主依然能看看是不是这个效果。

另外,楼主想用图片来描绘HP和SP,但是楼主提供的图片和RGSS能创建的实心矩形没有丝毫差别,所以我没有用楼主的“各种槽”图片,因为在系统能够创建一模一样的。

下面是代码
  1. #==============================================================================
  2. # ■ Window_SquareBattleActorMessge
  3. #------------------------------------------------------------------------------
  4. #  显示角色信息的类,归到窗口类为了方便。
  5. #==============================================================================
  6. class Window_MapStatus < Window_Base  
  7. #--------------------------------------------------------------------------  
  8. # ● 初始化窗口  
  9. #--------------------------------------------------------------------------
  10. def initialize   
  11.   super(0, 480 - 64, 640, 64)   
  12.   self.contents = Bitmap.new(width - 32, height - 32)   
  13.   refresh  
  14. end  
  15. #--------------------------------------------------------------------------  
  16. # ● 刷新  
  17. #--------------------------------------------------------------------------  
  18. def refresh
  19.   self.contents.clear
  20.   for i in 0...$game_party.actors.size
  21.     x = i * 152
  22.     y = 0
  23.     actor = $game_party.actors[i]
  24.     draw_actor_head(actor,x, y)
  25.     draw_actor_hp_bar(actor,x + 40, y)
  26.     draw_actor_sp_bar(actor,x + 40, y + 11)
  27.     draw_actor_cp_bar(actor,x + 40, y + 22)
  28.   end
  29. end
  30. end

  31. class Window_Base < Window
  32.   def draw_actor_hp_bar(actor, x, y, w = 96)
  33.     self.contents.fill_rect(x, y, w, 10, Color.new(255,255,255,255))
  34.     self.contents.fill_rect(x+1, y+1, w-2, 8, Color.new(0,0,0,255))
  35.     w1 = (w-2) * actor.hp / actor.maxhp
  36.     self.contents.fill_rect(x+1, y+1, w1, 8, Color.new(255,0,0,255))
  37.   end
  38.   def draw_actor_sp_bar(actor, x, y, w = 96)
  39.     self.contents.fill_rect(x, y, w, 10, Color.new(255,255,255,255))
  40.     self.contents.fill_rect(x+1, y+1, w-2, 8, Color.new(0,0,0,255))
  41.     w1 = (w-2) * actor.sp / actor.maxsp
  42.     self.contents.fill_rect(x+1, y+1, w1, 8, Color.new(0,0,255,255))
  43.   end
  44.   def draw_actor_cp_bar(actor, x, y, w = 96)
  45.     self.contents.fill_rect(x, y, w, 10, Color.new(255,255,255,255))
  46.     self.contents.fill_rect(x+1, y+1, w-2, 8, Color.new(0,0,0,255))
  47.     w1 = (w-2) * actor.mor / 100
  48.     self.contents.fill_rect(x+1, y+1, w1, 8, Color.new(0,255,0,255))
  49.   end
  50.   #--------------------------------------------------------------------------  
  51.   # ● 头像的描绘  
  52.   #     actor : 角色  
  53.   #     x     : 描画目标 X 坐标  
  54.   #     y     : 描画目标 Y 坐标  
  55.   #--------------------------------------------------------------------------  
  56.   def draw_actor_head(actor, x, y)   
  57.     bitmap = RPG::Cache.picture(actor.character_name + "_h")   
  58.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)   
  59.     self.contents.blt(x + 4, y , bitmap, src_rect)  
  60.   end
  61. end

  62. class Scene_Map
  63.   alias old_main main
  64.   def main
  65.     @status_window = Window_MapStatus.new
  66.     old_main
  67.     @status_window.dispose
  68.   end
  69.   alias old_update update
  70.   def update
  71.     @status_window.update
  72.     @status_window.refresh
  73.     old_update
  74.   end
  75. end
复制代码

评分

参与人数 2星屑 +65 收起 理由
myownroc + 60 塞糖
无脑之人 + 5 节操满满

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

8
发表于 2013-10-2 10:55:24 | 只看该作者
额额啊啊。。。。
LZ可不可以用普通代码框发,我电脑复制不了你的代码框.....
回复 支持 反对

使用道具 举报

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
9
 楼主| 发表于 2013-10-3 20:08:12 | 只看该作者
恋′挂机 发表于 2013-9-30 18:12
用你的其实也可以,很麻烦
(先要除错,又要一个一个
判断非常是麻烦)
  1. #==============================================================================
  2. # ■ Window_SquareBattleActorMessge
  3. #------------------------------------------------------------------------------
  4. #  显示角色信息的类,归到窗口类为了方便。
  5. #==============================================================================

  6. class Window_SquareBattleActorMessge < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化窗口
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 416, 160, 64)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     self.opacity = 0
  14.     refresh
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 刷新
  18.   #--------------------------------------------------------------------------
  19.   def refresh
  20.     self.contents.clear
  21.     # 角色の绘制
  22.     for i in 0...$game_party.actors.size
  23.       x = 160 * i
  24.       y = 16
  25.       actor = $game_party.actors[i]
  26.       draw_actor_head(actor, x, y)
  27.       carol3_draw_hp_bar(actor, x + 64, y)
  28.       carol3_draw_sp_bar(actor, x + 64, y + 16)
  29.       carol3_draw_cp_bar(actor, x + 64, y + 32)
  30.     end
  31.   end
  32. end
复制代码
还是不行,不能显示
呃,发糖贴好冷清呀!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
10
发表于 2013-10-3 20:13:11 | 只看该作者
Y坐标过大,如果调小还是不显示,就是
draw_actor_head
carol3_draw_hp_bar
carol3_draw_sp_bar
carol3_draw_cp_bar
的问题了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-30 03:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表