幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2443|回复: 11

[RMXP] 谁帮我解决覆盖的问题?

[复制链接]

4

主题

12

帖子

104

积分

③业余

积分
104
发表于 2010-1-18 17:53:51 | 显示全部楼层 |阅读模式
  1. class Sprite_Character
  2.   alias old_initialize initialize
  3.   def initialize(a,b)
  4.     @hpspsprite = Sprite.new
  5.     @hpspsprite.bitmap = Bitmap.new(160, 100)
  6.     @hpspsprite.z = 0
  7.     @hp = 0
  8.     @sp = 0
  9.     old_initialize(a,b)
  10.   end
  11.   
  12.   def dispose
  13.     super
  14.     @hpspsprite.bitmap.dispose
  15.     @hpspsprite.dispose
  16.   end
  17.   
  18.   alias :old_update :update
  19.   def update
  20.     old_update
  21.     @hpspsprite.x = self.x-80
  22.     @hpspsprite.y = self.y-80
  23.    for event in $game_map.events.values
  24.    next if event.list[0].code != 108
  25.    next if event.list[0].parameters[0] != "敌人"
  26.      @sp = event.list[3].parameters[0].to_i
  27.      @hp = event.list[4].parameters[0].to_i
  28.      @maxhp = event.list[5].parameters[0].to_i
  29.      @maxsp = event.list[6].parameters[0].to_i
  30.      @hpspsprite.bitmap.clear
  31.         width = 40
  32.         x = 60
  33.         y = 55
  34.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(255,255,255,200))
  35.         wss = width * @hp / [@maxhp].max
  36.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(255, 96, 96, 255))
  37.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(255, 0, 0, 255))
  38.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(128, 0, 0, 255))
  39.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 0, 0, 255))
  40.         width = 40
  41.         x = 60
  42.         y = 60
  43.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  44.         wss = width * @sp / [@maxsp,1].max
  45.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(128, 255, 255, 255))
  46.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(0, 255, 255, 255))
  47.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(0, 192, 192, 255))
  48.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 128, 128, 255))
  49.         @sp = $game_party.actors[0].sp
  50.         @hp = $game_party.actors[0].hp
  51.         @hpspsprite.bitmap.clear
  52.         width = 40
  53.         x = 60
  54.         y = 55
  55.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  56.         wss = width * @hp / [$game_party.actors[0].maxhp,1].max
  57.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(255, 96, 96, 255))
  58.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(255, 0, 0, 255))
  59.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(128, 0, 0, 255))
  60.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 0, 0, 255))
  61.         width = 40
  62.         x = 60
  63.         y = 60
  64.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  65.         wss = width * @sp / [$game_party.actors[0].maxsp,1].max
  66.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(128, 255, 255, 255))
  67.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(0, 255, 255, 255))
  68.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(0, 192, 192, 255))
  69.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 128, 128, 255))  
  70.     end
  71.   end
  72. end
  73. def dispose
  74.     super
  75.     @hpspsprite.dispose
  76.   end
复制代码
这血条覆盖人物 谁帮我解决下?
回复

使用道具 举报

0

主题

50

帖子

408

积分

④见习

腿神姐真的很温柔&

积分
408
QQ
发表于 2010-1-18 18:04:21 | 显示全部楼层
@hpspsprite = Sprite.new(a)
把开头那段改为这个即可。
http://www.diyrpg.net/bbs/index.php 欢迎大家来先行者论坛><
回复 支持 反对

使用道具 举报

4

主题

12

帖子

104

积分

③业余

积分
104
 楼主| 发表于 2010-1-18 18:14:07 | 显示全部楼层
谢谢 这脚本是我参考你写的那个的
才发现这脚本存在一个问题
原来  next if event.list[0].parameters[0] != "敌人"   不是条件分歧?
该怎么写? 当注释内容为敌人  才执行
回复 支持 反对

使用道具 举报

0

主题

50

帖子

408

积分

④见习

腿神姐真的很温柔&

积分
408
QQ
发表于 2010-1-18 20:31:48 | 显示全部楼层
  1. class Sprite_Character
  2.   alias old_initialize initialize
  3.   def initialize(a,b)
  4.     @hpspsprite = Sprite.new(a)
  5.     @hpspsprite.bitmap = Bitmap.new(160, 100)
  6.     @hpspsprite.z = 0
  7.     @hp = 0
  8.     @sp = 0
  9.     old_initialize(a,b)
  10.   end
  11.   def dispose
  12.     super
  13.     @hpspsprite.bitmap.dispose
  14.     @hpspsprite.dispose
  15.   end
  16.   alias :old_update :update
  17.   def update
  18.     old_update
  19.     @hpspsprite.x = self.x-80
  20.     @hpspsprite.y = self.y-80
  21.      return if @character.id == 0
  22.      event = $game_map.events[@character.id]
  23.      return if event.list[0].code != 108
  24.      return if event.list[0].parameters[0] != "敌人"
  25.      @sp = event.list[3].parameters[0].to_i
  26.      @hp = event.list[4].parameters[0].to_i
  27.      @maxhp = event.list[5].parameters[0].to_i
  28.      @maxsp = event.list[6].parameters[0].to_i
  29.      @hpspsprite.bitmap.clear
  30.         width = 40
  31.         x = 60
  32.         y = 55
  33.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(255,255,255,200))
  34.         wss = width * @hp / [@maxhp].max
  35.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(255, 96, 96, 255))
  36.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(255, 0, 0, 255))
  37.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(128, 0, 0, 255))
  38.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 0, 0, 255))
  39.         width = 40
  40.         x = 60
  41.         y = 60
  42.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  43.         wss = width * @sp / [@maxsp,1].max
  44.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(128, 255, 255, 255))
  45.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(0, 255, 255, 255))
  46.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(0, 192, 192, 255))
  47.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 128, 128, 255))
  48.         @sp = $game_party.actors[0].sp
  49.         @hp = $game_party.actors[0].hp
  50.         @hpspsprite.bitmap.clear
  51.         width = 40
  52.         x = 60
  53.         y = 55
  54.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  55.         wss = width * @hp / [$game_party.actors[0].maxhp,1].max
  56.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(255, 96, 96, 255))
  57.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(255, 0, 0, 255))
  58.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(128, 0, 0, 255))
  59.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 0, 0, 255))
  60.         width = 40
  61.         x = 60
  62.         y = 60
  63.         @hpspsprite.bitmap.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  64.         wss = width * @sp / [$game_party.actors[0].maxsp,1].max
  65.         @hpspsprite.bitmap.fill_rect(x, y+28, wss,1, Color.new(128, 255, 255, 255))
  66.         @hpspsprite.bitmap.fill_rect(x, y+29, wss,1, Color.new(0, 255, 255, 255))
  67.         @hpspsprite.bitmap.fill_rect(x, y+30, wss,1, Color.new(0, 192, 192, 255))
  68.         @hpspsprite.bitmap.fill_rect(x, y+31, wss,1, Color.new(0, 128, 128, 255))  
  69.   end
  70. end
复制代码
做了下修改,你先看,有问题问我。
http://www.diyrpg.net/bbs/index.php 欢迎大家来先行者论坛><
回复 支持 反对

使用道具 举报

4

主题

12

帖子

104

积分

③业余

积分
104
 楼主| 发表于 2010-1-19 07:43:11 | 显示全部楼层
我要在其他脚本调用HP的增减  怎么弄?
是要把  @hp = event.list[2].parameters[0].to_i
然后     @hp -= 100#伤害
但测试有错误?  我就把     return if @character.id == 0
     event = $game_map.events[@character.id]
加上~测试还是错误    我不知道怎么弄

角色的生命条  没显示出来  也解决下
回复 支持 反对

使用道具 举报

0

主题

50

帖子

408

积分

④见习

腿神姐真的很温柔&

积分
408
QQ
发表于 2010-1-19 08:09:26 | 显示全部楼层
要用全局变量或是类属性。建议是后者,
  1. class Sprite_Character
  2.   attr_accessor :hp
  3. end
复制代码
然后在Spriteset_Map加入判断0.0



角色的HP、SP是在哪里的?
http://www.diyrpg.net/bbs/index.php 欢迎大家来先行者论坛><
回复 支持 反对

使用道具 举报

4

主题

12

帖子

104

积分

③业余

积分
104
 楼主| 发表于 2010-1-19 08:21:38 | 显示全部楼层
class Sprite_Character
  attr_accessor :hp
end
这个加在哪?
在Spriteset_Map 哪里加判断?
从48行开始就是角色的
回复 支持 反对

使用道具 举报

0

主题

50

帖子

408

积分

④见习

腿神姐真的很温柔&

积分
408
QQ
发表于 2010-1-19 08:25:03 | 显示全部楼层
那段代码任意空白页插入即可。
至于要在哪里加判断,还要看你是哪控制HP这些变量的。
http://www.diyrpg.net/bbs/index.php 欢迎大家来先行者论坛><
回复 支持 反对

使用道具 举报

4

主题

12

帖子

104

积分

③业余

积分
104
 楼主| 发表于 2010-1-19 08:39:55 | 显示全部楼层
我是这样处理伤害
for event in $game_map.events.values
event.damage = $game_party.actors[0].atk - event.list[1].parameters[0].to_i
               #伤害 =         角色攻击力         减去   敌人防御(注释第2行)
我不知道
class Sprite_Character
  attr_accessor :hp
end
有什么用?

是不是直接可以@hp -= event.damage                           
                             生命 减去  伤害
回复 支持 反对

使用道具 举报

0

主题

50

帖子

408

积分

④见习

腿神姐真的很温柔&

积分
408
QQ
发表于 2010-1-19 08:44:54 | 显示全部楼层
0.0还是发送文件到我的邮箱里吧。我看看再说。
http://www.diyrpg.net/bbs/index.php 欢迎大家来先行者论坛><
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-6-3 21:31 , Processed in 0.020694 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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