Project1
标题: 图片显示优化 [打印本页]
作者: 黑米馒头 时间: 2022-10-4 18:22
标题: 图片显示优化
本帖最后由 黑米馒头 于 2022-10-4 18:42 编辑
工程里用到很多重复命名的图片,如何简化。。脚本盲看的头晕
if @battler.startactive == "移动"
if Graphics.frame_count % 2 == 0
unless BattlerName[@battler.name].nil?
@number = (@number + 1) % BattlerName[@battler.name][@battler.startactive].size
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
end
end
module Scene_BattleName
BattlerName = {
"泡泡-友" => {
"待机" => ["泡泡/友/待/1","泡泡/友/待/2","泡泡/友/待/3","泡泡/友/待/4","泡泡/友/待/5","泡泡/友/待/6","泡泡/友/待/7","泡泡/友/待/8","泡泡/友/待/9","泡泡/友/待/10","泡泡/友/待/11"],
"移动" => ["泡泡/友/移/1","泡泡/友/移/2","泡泡/友/移/3","泡泡/友/移/4","泡泡/友/移/5","泡泡/友/移/6","泡泡/友/移/7"]
},
}
end
class Scene_Battle
include Scene_BattleName
end
class Sprite_Battler
include Scene_BattleName
end
if @battler.startactive == "移动"
if Graphics.frame_count % 2 == 0
unless BattlerName[@battler.name].nil?
@number = (@number + 1) % BattlerName[@battler.name][@battler.startactive].size
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
end
end
module Scene_BattleName
BattlerName = {
"泡泡-友" => {
"待机" => ["泡泡/友/待/1","泡泡/友/待/2","泡泡/友/待/3","泡泡/友/待/4","泡泡/友/待/5","泡泡/友/待/6","泡泡/友/待/7","泡泡/友/待/8","泡泡/友/待/9","泡泡/友/待/10","泡泡/友/待/11"],
"移动" => ["泡泡/友/移/1","泡泡/友/移/2","泡泡/友/移/3","泡泡/友/移/4","泡泡/友/移/5","泡泡/友/移/6","泡泡/友/移/7"]
},
}
end
class Scene_Battle
include Scene_BattleName
end
class Sprite_Battler
include Scene_BattleName
end
#==============================================================================
# ■ Window_Head
#------------------------------------------------------------------------------
# 处理宠物图像画面的类。
#==============================================================================
class Window_Head < Window_Base
def initialize(actor)
super(100, 42, 400, 390)
self.opacity = 0
self.z = 999
self.contents = Bitmap.new(width - 32, height - 32)
@bitmap_index = 0
@rect = Rect.new(0, 0, 1, 1)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
actor = $baby_index
return if actor.nil? or Baby_Face[actor.name].nil?
if @id != actor.id or @face != actor.face
# 宠物图片类型设定
actor.face = "待机" or "移动" or "挨打" or "防御" if actor.face.nil?
@id = actor.id
@face = actor.face
@bitmap_index = 0
str = Baby_Face[actor.name][actor.face]
@index = [*str.split("-")[0].to_i..str.split("-")[1].to_i]
end
filename = sprintf("%d", @index[@bitmap_index])
# 宠物图片显示格式
bitmap = Bitmap.new("Graphics/Battlers/#{actor.name}/友/#{actor.face}/"+filename)
self.contents.blt(0, 0, bitmap, @rect.set(-30, -30, bitmap.width+100, bitmap.height))
self.x = 100
self.y = 42
@bitmap_index += 1
if @bitmap_index >= @index.size
@bitmap_index = 0
# 宠物图片类型切换的时间
if rand(40) < 10
ar = Baby_Face[actor.name].keys
actor.face = ar[rand(ar.size)]
end
end
end
end
#==============================================================================
# ■ Scene_BattleName
#------------------------------------------------------------------------------
# 设置宠物图像画面的类。
#==============================================================================
module Scene_BattleName
Baby_Face = {
"泡泡" => {
"待机" => "1-11",
"移动" => "1-7",
"挨打" => "1-2"
},
}
end
#==============================================================================
# ■ Window_Head
#------------------------------------------------------------------------------
# 处理宠物图像画面的类。
#==============================================================================
class Window_Head < Window_Base
include Scene_BattleName
end
#==============================================================================
# ■ Window_Head
#------------------------------------------------------------------------------
# 处理宠物图像画面的类。
#==============================================================================
class Window_Head < Window_Base
def initialize(actor)
super(100, 42, 400, 390)
self.opacity = 0
self.z = 999
self.contents = Bitmap.new(width - 32, height - 32)
@bitmap_index = 0
@rect = Rect.new(0, 0, 1, 1)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
actor = $baby_index
return if actor.nil? or Baby_Face[actor.name].nil?
if @id != actor.id or @face != actor.face
# 宠物图片类型设定
actor.face = "待机" or "移动" or "挨打" or "防御" if actor.face.nil?
@id = actor.id
@face = actor.face
@bitmap_index = 0
str = Baby_Face[actor.name][actor.face]
@index = [*str.split("-")[0].to_i..str.split("-")[1].to_i]
end
filename = sprintf("%d", @index[@bitmap_index])
# 宠物图片显示格式
bitmap = Bitmap.new("Graphics/Battlers/#{actor.name}/友/#{actor.face}/"+filename)
self.contents.blt(0, 0, bitmap, @rect.set(-30, -30, bitmap.width+100, bitmap.height))
self.x = 100
self.y = 42
@bitmap_index += 1
if @bitmap_index >= @index.size
@bitmap_index = 0
# 宠物图片类型切换的时间
if rand(40) < 10
ar = Baby_Face[actor.name].keys
actor.face = ar[rand(ar.size)]
end
end
end
end
#==============================================================================
# ■ Scene_BattleName
#------------------------------------------------------------------------------
# 设置宠物图像画面的类。
#==============================================================================
module Scene_BattleName
Baby_Face = {
"泡泡" => {
"待机" => "1-11",
"移动" => "1-7",
"挨打" => "1-2"
},
}
end
#==============================================================================
# ■ Window_Head
#------------------------------------------------------------------------------
# 处理宠物图像画面的类。
#==============================================================================
class Window_Head < Window_Base
include Scene_BattleName
end
作者: 我为鱼肉 时间: 2022-10-4 19:30
本帖最后由 我为鱼肉 于 2022-10-4 19:33 编辑
拆分为基本名+动作+帧数
比如说数据库中角色名字
泡泡@泡泡@待机帧数@移动帧数@攻击帧数@技能帧数@死亡帧数等等
第一个泡泡是召唤兽名字可以随便取,第二个泡泡是基本名或者说告诉程序用哪一套素材
角色初始化时把这些信息全部属性化
作者: guoxiaomi 时间: 2022-10-8 22:11
数据写在脚本里是这样子的,就这么点内容,个人感觉没必要改。
作者: enghao_lim 时间: 2022-10-11 01:06
就上楼上所说,有点没必要。如果要帮你,还得研究研究脚本,这太耗时了。当然,不研究脚本的方法也有,就是让BattlerName自动生成就好,举例:
- module Scene_BattleName
- def genName
- defi = {
- "泡泡-友" => {
- "待机" => ["泡泡/友/待/", 1..11],
- "移动" => ["泡泡/友/移/", 1..7]
- }
- }
-
- list = {}
- 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) } } }
-
- return list
- end
- module_function:genName
- BattlerName = genName
- end
复制代码
懂了就懂,不懂就慢慢研究吧。
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |