Project1
标题: 整合脚本 (掉血从右到左 [打印本页]
作者: fm303018 时间: 2013-5-11 12:54
标题: 整合脚本 (掉血从右到左
本帖最后由 亿万星辰 于 2013-5-11 13:47 编辑
game186_宿命脚本- #==============================================================================
- # ■ Window_BattleStatus
- #------------------------------------------------------------------------------
- # バトル画面でパーティメンバーのステータスを表示するウィンドウです。
- #==============================================================================
- class Window_BattleStatus < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, 240, 640, 240)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- @background_window = Window_Base.new(0, 320, 640, 160)
- @background_window.opacity = 0
- @menu = Sprite.new
- @menu.bitmap = RPG::Cache.picture("战斗状态")
- @menu.y = 320
- @menu.z += 1
- @level_up_flags = [false, false, false, false]
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 解放
- #--------------------------------------------------------------------------
- def dispose
- @background_window.dispose
- @menu.bitmap.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● レベルアップフラグの設定
- # actor_index : アクターインデックス
- #--------------------------------------------------------------------------
- def level_up(actor_index)
- @level_up_flags[actor_index] = true
- end
- #--------------------------------------------------------------------------
- # ● レベルアップ表示
- #--------------------------------------------------------------------------
- def refresh_level_up
- for i in 0...$game_party.actors.size
- if @level_up_flags[i]
- bitmap = RPG::Cache.picture("System/Battle-LevelUp")
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.contents.blt(i * 160, 0, bitmap, src_rect)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @item_max = $game_party.actors.size
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- actor_x = i * 160
- y = height - 200
- #---------------------------头象------------------------------
- testname = actor.battler_name+"_f.png"
- bitmap=Bitmap.new("Graphics/Battlers/#{testname}")
- src_rect = Rect.new(0,0, bitmap.width, bitmap.height) #——可自己调整大小
- self.contents.blt(actor_x+16, 65, bitmap, src_rect)
- #-----------------------------------------------------------
- draw_actor_hp(actor, actor_x, y + 96, 14)
- draw_actor_sp(actor, actor_x, y + 124, 14)
- draw_actor_hpbar(actor, actor_x + 16, y + 120)
- draw_actor_spbar(actor, actor_x + 16, y + 148)
- draw_actor_state(actor, actor_x+92, y + 80)
- draw_actor_name(actor, actor_x+95, y + 32)
- end
- end
- #--------------------------------------------------------------------------
- # ★ HPバー の描画
- # actor : アクター
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_actor_hpbar(actor, x, y)
- bitmap = RPG::Cache.picture("空槽")
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.contents.blt(x, y, bitmap, src_rect)
- bitmap = RPG::Cache.picture("血槽")
- cx = actor.hp * 100 / actor.maxhp
- src_rect = Rect.new(0, 0, cx, bitmap.height)
- self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
- end
- #--------------------------------------------------------------------------
- # ★ SPバー の描画
- # actor : アクター
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_actor_spbar(actor, x, y)
- bitmap = RPG::Cache.picture("空槽")
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.contents.blt(x, y, bitmap, src_rect)
- bitmap = RPG::Cache.picture("气槽")
- cx = actor.sp * 100 / actor.maxsp
- src_rect = Rect.new(0, 0, cx, bitmap.height)
- self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
- end
- #--------------------------------------------------------------------------
- # ● HP の描画
- # actor : アクター
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_actor_hp(actor, x, y, size = 16)
- bitmap = RPG::Cache.picture("HP字样")
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.contents.blt(x, y + 4, bitmap, src_rect)
- # HP を描画
- x += 32
- self.contents.font.size = size
- self.contents.font.italic = true
- color = actor.hp == 0 ? knockout_color :
- actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
- draw_text_custom(x, y, 42, 32, actor.hp.to_s, color, 2)
- self.contents.font.italic = false
- draw_text_normal(x + 42, y, 16, 32, "/", 1)
- self.contents.font.italic = true
- # MaxHP を描画
- draw_text_normal(x + 54, y, 42, 32, actor.maxhp.to_s, 2)
- self.contents.font.italic = false
- end
- #--------------------------------------------------------------------------
- # ● SP の描画
- # actor : アクター
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_actor_sp(actor, x, y, size = 16)
- bitmap = RPG::Cache.picture("MP字样")
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.contents.blt(x, y + 4, bitmap, src_rect)
- # SP を描画
- x += 32
- self.contents.font.size = size
- self.contents.font.italic = true
- color = actor.sp == 0 ? knockout_color :
- actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
- draw_text_custom(x, y, 42, 32, actor.sp.to_s, color, 2)
- self.contents.font.italic = false
- draw_text_normal(x + 42, y, 16, 32, "/", 1)
- self.contents.font.italic = true
- # MaxSP を描画
- draw_text_normal(x + 54, y, 42, 32, actor.maxsp.to_s, 2)
- self.contents.font.italic = false
- end
- #--------------------------------------------------------------------------
- # ★ 文字列(影つき:通常色・無効色あり)の描画
- #--------------------------------------------------------------------------
- def draw_text_custom(x, y, width, height, str, color, align = 0)
- self.contents.font.color = Color.new(36, 24, 16, 224)
- self.contents.draw_text(x + 1, y + 1, width, height, str, align)
- self.contents.font.color = color
- self.contents.draw_text(x, y, width, height, str, align)
- end
- #--------------------------------------------------------------------------
- # ★ 文字列(影つき:通常色)の描画
- #--------------------------------------------------------------------------
- def draw_text_normal(x, y, width, height, str, align = 0)
- self.contents.font.color = Color.new(36, 24, 16, 224)
- self.contents.draw_text(x + 1, y + 1, width, height, str, align)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, height, str, align)
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- # メインフェーズのときは不透明度をやや下げる
- if $game_temp.battle_main_phase
- self.contents_opacity -= 4 if self.contents_opacity > 192
- self.z = 50
- else
- self.contents_opacity += 4 if self.contents_opacity < 255
- self.z = 200
- end
- end
- end
复制代码 帮忙整合掉血掉蓝从右到左 谢谢
-
未命名.jpg
(28.69 KB, 下载次数: 4)
作者: cinderelmini 时间: 2013-5-11 18:15
本帖最后由 cinderelmini 于 2013-5-11 18:36 编辑
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
end
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
end
用到的是这两段~
可以替换~也可以把原来的函数名字稍微改一下~然后再ctrl+V在下面~
总之~就是下面这样写~
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
#cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 血槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
#cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 气槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
#cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 血槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
#cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 气槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
大体上是这样了~
ax就填上槽图片跟空槽图片的宽度差~
理论上是(空槽图片的宽-槽图片的宽)/2
不过这只是一般对称的槽图片公式~
详细的LZ自己填上就是~
作者: fm303018 时间: 2013-5-12 00:09
本帖最后由 fm303018 于 2013-5-12 00:40 编辑
cinderelmini
cx 和 ax 效果一样
src_rect = Rect.new(0, 0, cx, bitmap.height) #CX报错
ax = 血槽图片跟空槽图片的差距离 #不会用
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("BarBack")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("HPBar01")
cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx , bitmap.height)
self.contents.blt(x -103 + cx, y +0 , bitmap, src_rect)
end
注意我这里动过了x -103 + cx血槽从右到左正确 但是~被击中~血槽错位
作者: cinderelmini 时间: 2013-5-12 18:43
fm303018 发表于 2013-5-12 00:09
cinderelmini
cx 和 ax 效果一样
src_rect = Rect.new(0, 0, cx, bitmap.height) #CX报错
好吧……之前哀家各种脑残了……
于是修改一下……
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 血槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 气槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
def draw_actor_hpbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("血槽")
cx = actor.hp * 100 / actor.maxhp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 血槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ SPバー の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_spbar(actor, x, y)
bitmap = RPG::Cache.picture("空槽")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
bitmap = RPG::Cache.picture("气槽")
cx = actor.sp * 100 / actor.maxsp
src_rect = Rect.new(0, 0, cx, bitmap.height)
#self.contents.blt(x + 103 - cx + ax, y + 2, bitmap, src_rect)
ax = 气槽图片跟空槽图片的差距离
self.contents.blt(x + ax, y + 2, bitmap, src_rect)
end
也就是说cx别#掉就是了~
那会儿忘了cx还是计算槽的长度的OTZ……
然后就是那个ax的值~
你可以随便填个10以下的数字上去~不过目测应该是2~
道理是……
你看空槽外边不是有一层边框吗~
然后血槽或者气槽就没有边框了~
所以血槽和气槽的x和y坐标就必须必空槽的坐标多那么一点~
这样才能对准到空槽的边框内~
以上~
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |