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

Project1

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

[已经解决] 怎样使图片显示生命的脚本改成从上至下减少?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
118 小时
注册时间
2011-7-13
帖子
182
跳转到指定楼层
1
发表于 2011-7-22 10:29:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用了这个脚本:(怎样使它从上至下减少(垂直),而不是从右至左减少(水平))
  1. #======================================
  2. # ■ 图片显示生命
  3. #======================================
  4. #  By: pudding
  5. #======================================
  6. class Hp_Window  < Window_Base
  7.   def initialize  
  8.     super(-15, -16, 740, 580)
  9.     self.contents = Bitmap.new(width - 32, height - 32)
  10.     self.opacity = 0
  11.     self.z = 998
  12.     self.visible = true
  13.     refresh
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 刷新画面
  17.   #--------------------------------------------------------------------------
  18.   def update
  19.     value_x = -188
  20.     actor = $game_party.actors[0]  #主角
  21.     draw_hp_background(0 + value_x,0)    # HP底图
  22.     draw_mp_background(312 + value_x,8)  # MP底图
  23.     draw_hp(actor, 209 + value_x, 8) #生命条
  24.     draw_mp(actor, 312 + value_x, 8) #能量条
  25.     draw_map_exp(actor, 246 + value_x, 29)   #经验条
  26.     end
  27.   #--------------------------------------------------------------------------
  28.   # ● 刷新画面
  29.   #--------------------------------------------------------------------------
  30.   def refresh
  31.     self.contents.clear
  32.     value_x = -188
  33.     actor = $game_party.actors[0]  #主角
  34.   end
  35.    #----------------------------------------------------------------------------
  36.   # ● 底图
  37.   #----------------------------------------------------------------------------
  38.   def draw_hp_background(x,y)
  39.     hp_background = RPG::Cache.picture("HPdi")
  40.     hp_back = Rect.new(0, 0, hp_background.width, hp_background.height)
  41.     self.contents.blt(x, y, hp_background, hp_back)
  42.   end
  43.   def draw_mp_background(x,y)
  44.     hp_background = RPG::Cache.picture("MP")
  45.     hp_back = Rect.new(0, 0, hp_background.width, hp_background.height)
  46.     self.contents.blt(x, y, hp_background, hp_back)
  47.   end
  48.   #----------------------------------------------------------------------------
  49.   # ● 生命条
  50.   #----------------------------------------------------------------------------
  51. def draw_hp(actor,x,y)
  52.     hp = RPG::Cache.picture("HP条")
  53.     hp_w = hp.width * actor.hp / [actor.maxhp,1].max
  54.     rect2 = Rect.new(0,0,hp_w,hp.height)
  55.     self.contents.blt(x,y,hp,rect2)
  56.   end #def HP
  57.   #----------------------------------------------------------------------------
  58.   # ● 能量条
  59.   #----------------------------------------------------------------------------
  60.    def draw_mp(actor,x,y)
  61.     mp = RPG::Cache.picture("MP条")
  62.     mp_w = mp.width * (actor.maxsp-actor.sp)  / [actor.maxsp,1].max
  63.     rect3 = Rect.new(0,0,mp_w,mp.height)
  64.     self.contents.blt(x,y,mp,rect3)
  65.   end #def MP
  66.   #----------------------------------------------------------------------------
  67.   # ● 描绘地图界面经验条
  68.   #----------------------------------------------------------------------------
  69.   def draw_map_exp(actor, x, y)
  70.     bitmap = RPG::Cache.picture("EXP条")
  71.     actor = $game_party.actors[0]
  72.     if actor.nextexp != 0
  73.       jisuan = actor.nowexp.to_f / actor.nextexp
  74.     else
  75.       jisuan = 1
  76.     end
  77.     if actor.level < 99 # 最大等级
  78.       nw = bitmap.width * jisuan
  79.     else
  80.       nw = bitmap.width
  81.     end  
  82.     src_rect = Rect.new(0, 0, nw, bitmap.height)
  83.     self.contents.blt( x, y, bitmap, src_rect)
  84.   end
  85. end
  86. #==============================================================================
  87. # ■ Game_Actor
  88. #==============================================================================
  89. class Game_Actor
  90.   #--------------------------------------------------------------------------
  91.   # ● 获取目前经验
  92.   #--------------------------------------------------------------------------
  93.   def nowexp
  94.      return @exp - @exp_list[@level]
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 下一等级还需的经验
  98.   #--------------------------------------------------------------------------
  99.   def nextexp
  100.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  101.   end
  102. end

  103. class Scene_Map
  104.   #--------------------------------------------------------------------------
  105.   # ● 主处理
  106.   #--------------------------------------------------------------------------
  107.   alias fox_text_window_main main
  108.   def main
  109.     @HP_window = Hp_Window.new
  110.     @item_1_new = $game_party.item_number(1).to_s
  111.     @item_2_new = $game_party.item_number(2).to_s
  112.     @item_3_new = $game_party.item_number(3).to_s
  113.     @item_4_new = $game_party.item_number(4).to_s
  114.     fox_text_window_main
  115.     # 释放
  116.     @HP_window.dispose
  117.     if $scene.is_a?(Scene_Title)
  118.       # 淡入淡出画面
  119.       Graphics.transition
  120.       Graphics.freeze
  121.     end
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 更新
  125.   #--------------------------------------------------------------------------
  126.   alias fox_text_window_update update
  127.   def update
  128.     # 刷新地图状态窗口
  129.     if @item_1_new != $game_party.item_number(1).to_s
  130.       @HP_window.refresh
  131.       @item_1_new = $game_party.item_number(1).to_s
  132.     end
  133.     if @item_2_new != $game_party.item_number(2).to_s
  134.       @HP_window.refresh
  135.       @item_2_new = $game_party.item_number(2).to_s
  136.     end
  137.     if @item_3_new != $game_party.item_number(3).to_s
  138.       @HP_window.refresh
  139.       @item_3_new = $game_party.item_number(3).to_s
  140.     end
  141.     if @item_4_new != $game_party.item_number(4).to_s
  142.       @HP_window.refresh
  143.       @item_4_new = $game_party.item_number(4).to_s
  144.     end
  145.     fox_text_window_update
  146.     if @HP_window.visible
  147.       @HP_window.update
  148.     end
  149.   end
  150. end
复制代码
纯事件的怨念啊...

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
2
发表于 2011-7-22 10:47:19 | 只看该作者
  1. class Hp_Window
  2.   def draw_hp(actor,x,y)
  3.     hp = RPG::Cache.picture("HP条")
  4.     hp_h = hp.height * actor.hp / [actor.maxhp,1].max
  5.     rect2 = Rect.new(0,hp.height-hp_h,hp.width,hp_h)
  6.     self.contents.blt(x,y,hp,rect2)
  7.   end #def HP
  8.   #----------------------------------------------------------------------------
  9.   # ● 能量条
  10.   #----------------------------------------------------------------------------
  11.    def draw_mp(actor,x,y)
  12.     mp = RPG::Cache.picture("MP条")
  13.     mp_h = mp.height * (actor.maxsp-actor.sp)  / [actor.maxsp,1].max
  14.     rect3 = Rect.new(0,mp.height-mp_h,mp.width,mp_h)
  15.     self.contents.blt(x,y,mp,rect3)
  16.   end #def MP
  17. end
复制代码

点评

脚本一类的要测试啊....(如果是遇到脚本完全白痴的提问者...你的答案会被纠结死的...)  发表于 2011-7-22 11:31

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
118 小时
注册时间
2011-7-13
帖子
182
3
 楼主| 发表于 2011-7-22 11:28:05 | 只看该作者
本帖最后由 南宫爱 于 2011-7-22 11:32 编辑

恩恩...不过应该是这样的...(如果直接把你的那个脚本改上去的话...会有意想不到的结果...)
  1.   #----------------------------------------------------------------------------
  2.   # ● 生命条
  3.   #----------------------------------------------------------------------------
  4. def draw_hp(actor,x,y)
  5.     hp = RPG::Cache.picture("HP")
  6.     hp_h = hp.height * actor.hp / [actor.maxhp,1].max
  7.     rect2 = Rect.new(0,hp.height-hp_h,hp.width,hp_h)
  8.     self.contents.blt(x,y+(hp.height-hp_h),hp,rect2)
  9.   end #def HP

  10.   #----------------------------------------------------------------------------
  11.   # ● 能量条
  12.   #----------------------------------------------------------------------------
  13. def draw_mp(actor,x,y)
  14.     mp = RPG::Cache.picture("PP")
  15.     mp_h = mp.height * actor.sp / [actor.maxsp,1].max
  16.     rect3 = Rect.new(0,mp.height-mp_h,mp.width,mp_h)
  17.     self.contents.blt(x,y+(mp.height-mp_h),mp,rect3)
  18.   end #def MP
复制代码
(如果不加上 self.contents.blt(x,y+(mp.height-mp_h),mp,rect3)
和self.contents.blt(x,y+(hp.height-hp_h),hp,rect2))
就是从下至上了...(额...= =)

纯事件的怨念啊...
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-13 22:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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