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

Project1

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

[已经过期] 图片显示优化

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3241
在线时间
1866 小时
注册时间
2010-6-19
帖子
1207
跳转到指定楼层
1
发表于 2022-10-4 18:22:41 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 黑米馒头 于 2022-10-4 18:42 编辑

工程里用到很多重复命名的图片,如何简化。。脚本盲看的头晕






RUBY 代码复制
  1. if @battler.startactive == "移动"
  2.   if Graphics.frame_count % 2 == 0
  3.     unless BattlerName[@battler.name].nil?
  4.       @number = (@number + 1) % BattlerName[@battler.name][@battler.startactive].size
  5.       self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
  6.     end
  7.   end
  8.  
  9. module Scene_BattleName
  10.   BattlerName = {
  11.   "泡泡-友" => {
  12.   "待机" => ["泡泡/友/待/1","泡泡/友/待/2","泡泡/友/待/3","泡泡/友/待/4","泡泡/友/待/5","泡泡/友/待/6","泡泡/友/待/7","泡泡/友/待/8","泡泡/友/待/9","泡泡/友/待/10","泡泡/友/待/11"],
  13.   "移动" => ["泡泡/友/移/1","泡泡/友/移/2","泡泡/友/移/3","泡泡/友/移/4","泡泡/友/移/5","泡泡/友/移/6","泡泡/友/移/7"]
  14.   },   
  15.   }  
  16. end
  17. class Scene_Battle
  18.   include Scene_BattleName
  19. end
  20. class Sprite_Battler
  21.   include Scene_BattleName
  22. end



RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Head
  3. #------------------------------------------------------------------------------
  4. #  处理宠物图像画面的类。
  5. #==============================================================================
  6.  
  7. class Window_Head < Window_Base
  8.   def initialize(actor)
  9.     super(100, 42, 400, 390)
  10.     self.opacity = 0
  11.     self.z = 999
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     @bitmap_index = 0
  14.     @rect = Rect.new(0, 0, 1, 1)
  15.     refresh
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     actor = $baby_index
  23.     return if actor.nil? or Baby_Face[actor.name].nil?
  24.     if @id != actor.id or @face != actor.face
  25.       # 宠物图片类型设定
  26.       actor.face = "待机" or "移动" or "挨打" or "防御" if actor.face.nil?
  27.       @id = actor.id
  28.       @face = actor.face
  29.       @bitmap_index = 0
  30.       str = Baby_Face[actor.name][actor.face]
  31.       @index = [*str.split("-")[0].to_i..str.split("-")[1].to_i]
  32.     end
  33.     filename = sprintf("%d", @index[@bitmap_index])
  34.     # 宠物图片显示格式
  35.     bitmap = Bitmap.new("Graphics/Battlers/#{actor.name}/友/#{actor.face}/"+filename)
  36.     self.contents.blt(0, 0, bitmap, @rect.set(-30, -30, bitmap.width+100, bitmap.height))
  37.     self.x = 100
  38.     self.y = 42
  39.  
  40.     @bitmap_index += 1
  41.     if @bitmap_index >= @index.size
  42.       @bitmap_index = 0
  43.       # 宠物图片类型切换的时间
  44.       if rand(40) < 10
  45.         ar = Baby_Face[actor.name].keys
  46.         actor.face = ar[rand(ar.size)]
  47.       end
  48.     end
  49.   end
  50. end
  51.  
  52. #==============================================================================
  53. # ■ Scene_BattleName
  54. #------------------------------------------------------------------------------
  55. #  设置宠物图像画面的类。
  56. #==============================================================================
  57.  
  58. module Scene_BattleName
  59.  
  60.   Baby_Face = {
  61.  
  62.   "泡泡" => {
  63.   "待机" => "1-11",
  64.   "移动" => "1-7",
  65.   "挨打" => "1-2"
  66.   },   
  67.   }  
  68. end
  69.  
  70. #==============================================================================
  71. # ■ Window_Head
  72. #------------------------------------------------------------------------------
  73. #  处理宠物图像画面的类。
  74. #==============================================================================
  75.  
  76. class Window_Head < Window_Base
  77.   include Scene_BattleName
  78. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-21 00:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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