Project1

标题: 在地图上显示EXP这个脚本! [打印本页]

作者: stair    时间: 2008-6-27 23:37
标题: 在地图上显示EXP这个脚本!
class Window_Exp < Window_Base
def initialize
  super(0, 0, 160, 64)
  self.contents = Bitmap.new(width - 32, height - 32)
  refresh
end
def refresh
  self.contents.clear
    for i in 0...$game_party.actors.size
    x = 64
    y = i * 116
    actor = $game_party.actors[1]
     exp(actor,0,0)
  end
end
def exp(actor,x,y)
  self.contents.fill_rect(x,y,96,16,Color.new(255,255,255,255))
  self.contents.fill_rect(x+1,y+1,94,14,Color.new(0,0,0,255))
  w = 94*$game_actors[1].now_exp/$game_actors[1].next_exp
  self.contents.fill_rect(x+1,y+1,w,14,Color.new(50,255,50,255))
end
end
class Scene_Map
def initialize
  @o_exp = $game_actors[1].exp
end
alias old_main main
def main
  @exp = Window_Exp.new
  @exp.x = 0
  @exp.y = 0
  @exp.opacity = 0 # 255可见 0不可见
  old_main
  @exp.dispose
end
alias old_update update
def update
  if @o_exp != $game_actors[1].exp
    @o_exp = $game_actors[1].exp
    @exp.refresh
  else
    @exp.update
  end
  old_update
end
end
class Game_Actor
def now_exp
  return @exp - @exp_list[@level]
end
def next_exp
  return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end


就这个!就一个个筐什么都没了
有谁能帮我在前面填加一个显示EXP字样?
作者: dbshy    时间: 2008-6-27 23:49
self.contents.draw_text(x, y, w, h, "exp")
作者: stair    时间: 2008-6-27 23:50
LS的填加在哪行里能说下吗?
作者: dbshy    时间: 2008-6-27 23:51
def exp(actor,x,y)

作者: stair    时间: 2008-6-27 23:52
恩!填加后出错
作者: dbshy    时间: 2008-6-27 23:54
以下引用stair于2008-6-27 15:52:31的发言:

恩!填加后出错



self.contents.draw_text(x, y, w, h, "exp")

x,y,w,h都需自己改的

作者: stair    时间: 2008-6-27 23:56
undefined local variable or method w' for #<Window_Exp:0x360bt70>  这个是错误显示!
作者: stair    时间: 2008-6-27 23:56
哦!!3Q
作者: stair    时间: 2008-6-27 23:59
错误是没了!可是没有显示字
作者: 八云紫    时间: 2008-6-28 00:00
这段出错:

alias old_main main
def main
@exp = Window_Exp.new
@exp.x = 0
@exp.y = 0
@exp.opacity = 0 # 255可见 0不可见
old_main
@exp.dispose
end

@exp.dispose 不是放在 main 里的
作者: stair    时间: 2008-6-28 00:02
那删掉吗??是吗
作者: 八云紫    时间: 2008-6-28 00:04


dispose 一般是放在 terminate 里的
作者: stair    时间: 2008-6-28 00:06
按照你的意思删了,可是还是没有显示呢!
作者: dbshy    时间: 2008-6-28 00:07
以下引用八云紫于2008-6-27 16:00:28的发言:

这段出错:

alias old_main main
def main
@exp = Window_Exp.new
@exp.x = 0
@exp.y = 0
@exp.opacity = 0 # 255可见 0不可见
old_main
@exp.dispose
end

@exp.dispose 不是放在 main 里的


@exp.dispose 是放在 main 里的

闪人


作者: stair    时间: 2008-6-28 00:10
!!!!!!!!!!!!!!!!!到底怎么的哦!!你们测试了吗!有显示出来吗
作者: 八云紫    时间: 2008-6-28 00:10
以下引用dbshy于2008-6-27 16:07:28的发言:


@exp.dispose 是放在 main 里的

闪人


@exp.dispose , dispose 是释放窗口,在 main 中创建了窗口,然后有释放它,最后就是什么

都没有呀。
作者: dbshy    时间: 2008-6-28 00:13
以下引用八云紫于2008-6-27 16:10:13的发言:


以下引用dbshy于2008-6-27 16:07:28的发言:


@exp.dispose 是放在 main 里的

闪人



@exp.dispose , dispose 是释放窗口,在 main 中创建了窗口,然后有释放它,最后就是什么

都没有呀。


alias old_main main
def main
@exp = Window_Exp.new
@exp.x = 0
@exp.y = 0
@exp.opacity = 0 # 255可见 0不可见
old_main
@exp.dispose
end

这样没错哦
作者: 八云紫    时间: 2008-6-28 00:17


看成 VX 的了,闪人~~~
作者: stair    时间: 2008-6-28 00:22
额!还是没显示!是不是我把x y w h调错了!!




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