查看: 2622|回复: 4

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

[复制链接]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2022-10-4 18:22:41 | 显示全部楼层 |阅读模式

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

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

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

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


图片显示.png



  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. module Scene_BattleName
  9.   BattlerName = {
  10.   "泡泡-友" => {
  11.   "待机" => ["泡泡/友/待/1","泡泡/友/待/2","泡泡/友/待/3","泡泡/友/待/4","泡泡/友/待/5","泡泡/友/待/6","泡泡/友/待/7","泡泡/友/待/8","泡泡/友/待/9","泡泡/友/待/10","泡泡/友/待/11"],
  12.   "移动" => ["泡泡/友/移/1","泡泡/友/移/2","泡泡/友/移/3","泡泡/友/移/4","泡泡/友/移/5","泡泡/友/移/6","泡泡/友/移/7"]
  13.   },   
  14.   }  
  15. end
  16. class Scene_Battle
  17.   include Scene_BattleName
  18. end
  19. class Sprite_Battler
  20.   include Scene_BattleName
  21. end
复制代码


  1. #==============================================================================
  2. # ■ Window_Head
  3. #------------------------------------------------------------------------------
  4. #  处理宠物图像画面的类。
  5. #==============================================================================

  6. class Window_Head < Window_Base
  7.   def initialize(actor)
  8.     super(100, 42, 400, 390)
  9.     self.opacity = 0
  10.     self.z = 999
  11.     self.contents = Bitmap.new(width - 32, height - 32)
  12.     @bitmap_index = 0
  13.     @rect = Rect.new(0, 0, 1, 1)
  14.     refresh
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 刷新
  18.   #--------------------------------------------------------------------------
  19.   def refresh
  20.     self.contents.clear
  21.     actor = $baby_index
  22.     return if actor.nil? or Baby_Face[actor.name].nil?
  23.     if @id != actor.id or @face != actor.face
  24.       # 宠物图片类型设定
  25.       actor.face = "待机" or "移动" or "挨打" or "防御" if actor.face.nil?
  26.       @id = actor.id
  27.       @face = actor.face
  28.       @bitmap_index = 0
  29.       str = Baby_Face[actor.name][actor.face]
  30.       @index = [*str.split("-")[0].to_i..str.split("-")[1].to_i]
  31.     end
  32.     filename = sprintf("%d", @index[@bitmap_index])
  33.     # 宠物图片显示格式
  34.     bitmap = Bitmap.new("Graphics/Battlers/#{actor.name}/友/#{actor.face}/"+filename)
  35.     self.contents.blt(0, 0, bitmap, @rect.set(-30, -30, bitmap.width+100, bitmap.height))
  36.     self.x = 100
  37.     self.y = 42
  38.    
  39.     @bitmap_index += 1
  40.     if @bitmap_index >= @index.size
  41.       @bitmap_index = 0
  42.       # 宠物图片类型切换的时间
  43.       if rand(40) < 10
  44.         ar = Baby_Face[actor.name].keys
  45.         actor.face = ar[rand(ar.size)]
  46.       end
  47.     end
  48.   end
  49. end

  50. #==============================================================================
  51. # ■ Scene_BattleName
  52. #------------------------------------------------------------------------------
  53. #  设置宠物图像画面的类。
  54. #==============================================================================

  55. module Scene_BattleName
  56.   
  57.   Baby_Face = {

  58.   "泡泡" => {
  59.   "待机" => "1-11",
  60.   "移动" => "1-7",
  61.   "挨打" => "1-2"
  62.   },   
  63.   }  
  64. end

  65. #==============================================================================
  66. # ■ Window_Head
  67. #------------------------------------------------------------------------------
  68. #  处理宠物图像画面的类。
  69. #==============================================================================

  70. class Window_Head < Window_Base
  71.   include Scene_BattleName
  72. end
复制代码
梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
回帖
81
发表于 2022-10-4 19:30:31 | 显示全部楼层
本帖最后由 我为鱼肉 于 2022-10-4 19:33 编辑

拆分为基本名+动作+帧数
比如说数据库中角色名字
泡泡@泡泡@待机帧数@移动帧数@攻击帧数@技能帧数@死亡帧数等等
第一个泡泡是召唤兽名字可以随便取,第二个泡泡是基本名或者说告诉程序用哪一套素材
角色初始化时把这些信息全部属性化


5.png
6.png

点评

????脚本盲表示看不懂….  发表于 2022-10-4 20:56
回复

使用道具 举报

梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2022-10-8 22:11:40 | 显示全部楼层
数据写在脚本里是这样子的,就这么点内容,个人感觉没必要改。
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
回帖
2014
发表于 2022-10-11 01:06:10 | 显示全部楼层
就上楼上所说,有点没必要。如果要帮你,还得研究研究脚本,这太耗时了。当然,不研究脚本的方法也有,就是让BattlerName自动生成就好,举例:
  1. module Scene_BattleName
  2.   def genName
  3.       defi = {
  4.         "泡泡-友" => {
  5.           "待机" => ["泡泡/友/待/", 1..11],
  6.           "移动" => ["泡泡/友/移/", 1..7]
  7.         }
  8.       }
  9.      
  10.       list = {}
  11.       defi.each{|a,b| list[a] = {}; b.each{|c,d| list[a][c] = []; d[1].each{|i| list[a][c].push(d[0] + i.to_s) } } }
  12.      
  13.       return list
  14.     end
  15.   module_function:genName
  16.   BattlerName =  genName
  17. end
复制代码

懂了就懂,不懂就慢慢研究吧。
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部