赞 | 0 |
VIP | 0 |
好人卡 | 18 |
积分 | 1 |
经验 | 14606 |
最后登录 | 2012-11-16 |
在线时间 | 273 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 273 小时
- 注册时间
- 2011-5-20
- 帖子
- 295
|
这个怎么样:
放在System里,色彩可以自己PS- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- #_/ ◆ 汎用ゲージ描画 - KGC_GenericGauge ◆ VX ◆
- #_/ ◇ Last update : 2009/09/26 ◇
- #_/----------------------------------------------------------------------------
- #_/ 汎用的なゲージ描画機能を提供します。
- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- #==============================================================================
- # ★ カスタマイズ項目 - Customize BEGIN ★
- #==============================================================================
- module KGC
- module GenericGauge
- # ◆ ゲージ画像
- # "Graphics/System" から読み込む。
- HP_IMAGE = "GaugeHP" # HP
- MP_IMAGE = "GaugeMP" # MP
- EXP_IMAGE = "GaugeEXP" # EXP
- # ◆ ゲージ位置補正 [x, y]
- HP_OFFSET = [-23, -2] # HP
- MP_OFFSET = [-23, -2] # MP
- EXP_OFFSET = [-23, -2] # EXP
- # ◆ ゲージ長補正
- HP_LENGTH = -4 # HP
- MP_LENGTH = -4 # MP
- EXP_LENGTH = -4 # EXP
- # ◆ ゲージの傾き角度
- # -89 ~ 89 で指定。
- HP_SLOPE = 30 # HP
- MP_SLOPE = 30 # MP
- EXP_SLOPE = 30 # EXP
- end
- end
- #==============================================================================
- # ☆ カスタマイズ項目 終了 - Customize END ☆
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["GenericGauge"] = true
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Bitmap
- #==============================================================================
- unless $imported["BitmapExtension"]
- class Bitmap
- #--------------------------------------------------------------------------
- # ○ 平行四辺形転送
- #--------------------------------------------------------------------------
- def skew_blt(x, y, src_bitmap, src_rect, slope, opacity = 255)
- slope = [[slope, -90].max, 90].min
- sh = src_rect.height
- off = sh / Math.tan(Math::PI * (90 - slope.abs) / 180.0)
- if slope >= 0
- dx = x + off.round
- diff = -off / sh
- else
- dx = x
- diff = off / sh
- end
- rect = Rect.new(src_rect.x, src_rect.y, src_rect.width, 1)
- sh.times { |i|
- blt(dx + (diff * i).round, y + i, src_bitmap, rect, opacity)
- rect.y += 1
- }
- end
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ○ 次のレベルの経験値取得
- #--------------------------------------------------------------------------
- def next_exp
- return @exp_list[@level+1]
- end
- #--------------------------------------------------------------------------
- # ○ 次のレベルの差分経験値取得
- #--------------------------------------------------------------------------
- def next_diff_exp
- return (@exp_list[@level+1] - @exp_list[@level])
- end
- #--------------------------------------------------------------------------
- # ○ 次のレベルまでの経験値取得
- #--------------------------------------------------------------------------
- def next_rest_exp
- return (@exp_list[@level+1] - @exp)
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Window_Base
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ○ 定数
- #--------------------------------------------------------------------------
- # ゲージ転送元座標 [x, y]
- GAUGE_SRC_POS = {
- :normal => [ 0, 24],
- :decrease => [ 0, 48],
- :increase => [72, 48],
- }
- #--------------------------------------------------------------------------
- # ○ クラス変数
- #--------------------------------------------------------------------------
- @@__gauge_buf = Bitmap.new(320, 24)
- #--------------------------------------------------------------------------
- # ○ ゲージ描画
- # file : ゲージ画像ファイル名
- # x, y : 描画先 X, Y 座標
- # width : 幅
- # value : 現在値
- # limit : 上限値
- # offset : 座標調整 [x, y]
- # len_offset : 長さ調整
- # slope : 傾き
- # gauge_type : ゲージタイプ
- #--------------------------------------------------------------------------
- def draw_gauge(file, x, y, width, value, limit, offset, len_offset, slope,
- gauge_type = :normal)
- img = Cache.system(file)
- x += offset[0]
- y += offset[1]
- width += len_offset
- draw_gauge_base(img, x, y, width, slope)
- gw = width * value / limit
- draw_gauge_bar(img, x, y, width, gw, slope, GAUGE_SRC_POS[gauge_type])
- end
- #--------------------------------------------------------------------------
- # ○ ゲージベース描画
- # img : ゲージ画像
- # x, y : 描画先 X, Y 座標
- # width : 幅
- # slope : 傾き
- #--------------------------------------------------------------------------
- def draw_gauge_base(img, x, y, width, slope)
- rect = Rect.new(0, 0, 24, 24)
- if slope != 0
- self.contents.skew_blt(x, y, img, rect, slope)
- rect.x = 96
- self.contents.skew_blt(x + width + 24, y, img, rect, slope)
- rect.x = 24
- rect.width = 72
- dest_rect = Rect.new(0, 0, width, 24)
- @@__gauge_buf.clear
- @@__gauge_buf.stretch_blt(dest_rect, img, rect)
- self.contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
- else
- self.contents.blt(x, y, img, rect)
- rect.x = 96
- self.contents.blt(x + width + 24, y, img, rect)
- rect.x = 24
- rect.width = 72
- dest_rect = Rect.new(x + 24, y, width, 24)
- self.contents.stretch_blt(dest_rect, img, rect)
- end
- end
- #--------------------------------------------------------------------------
- # ○ ゲージ内部描画
- # img : ゲージ画像
- # x, y : 描画先 X, Y 座標
- # width : 全体幅
- # gw : 内部幅
- # slope : 傾き
- # src_pos : 転送元座標 [x, y]
- # start : 開始位置
- #--------------------------------------------------------------------------
- def draw_gauge_bar(img, x, y, width, gw, slope, src_pos, start = 0)
- rect = Rect.new(src_pos[0], src_pos[1], 72, 24)
- dest_rect = Rect.new(0, 0, width, 24)
- @@__gauge_buf.clear
- @@__gauge_buf.stretch_blt(dest_rect, img, rect)
- dest_rect.x = start
- dest_rect.width = gw
- x += start
- if slope != 0
- self.contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
- else
- self.contents.blt(x + 24, y, @@__gauge_buf, dest_rect)
- end
- end
- #--------------------------------------------------------------------------
- # ● HP ゲージの描画
- # actor : アクター
- # x, y : 描画先 X, Y 座標
- # width : 幅
- #--------------------------------------------------------------------------
- def draw_actor_hp_gauge(actor, x, y, width = 120)
- draw_gauge(KGC::GenericGauge::HP_IMAGE,
- x, y, width, actor.hp, actor.maxhp,
- KGC::GenericGauge::HP_OFFSET,
- KGC::GenericGauge::HP_LENGTH,
- KGC::GenericGauge::HP_SLOPE
- )
- end
- #--------------------------------------------------------------------------
- # ● MP ゲージの描画
- # actor : アクター
- # x, y : 描画先 X, Y 座標
- # width : 幅
- #--------------------------------------------------------------------------
- def draw_actor_mp_gauge(actor, x, y, width = 120)
- draw_gauge(KGC::GenericGauge::MP_IMAGE,
- x, y, width, actor.mp, [actor.maxmp, 1].max,
- KGC::GenericGauge::MP_OFFSET,
- KGC::GenericGauge::MP_LENGTH,
- KGC::GenericGauge::MP_SLOPE
- )
- end
- #--------------------------------------------------------------------------
- # ○ Exp の描画
- # actor : アクター
- # x, y : 描画先 X, Y 座標
- # width : 幅
- #--------------------------------------------------------------------------
- def draw_actor_exp(actor, x, y, width = 180)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, WLH, actor.exp_s, 2)
- end
- #--------------------------------------------------------------------------
- # ○ NextExp の描画
- # actor : アクター
- # x, y : 描画先 X, Y 座標
- # width : 幅
- #--------------------------------------------------------------------------
- def draw_actor_next_exp(actor, x, y, width = 180)
- draw_actor_exp_gauge(actor, x, y, width)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, WLH, actor.next_rest_exp_s, 2)
- end
- #--------------------------------------------------------------------------
- # ○ Exp ゲージの描画
- # actor : アクター
- # x, y : 描画先 X, Y 座標
- # width : 幅
- #--------------------------------------------------------------------------
- def draw_actor_exp_gauge(actor, x, y, width = 180)
- diff = [actor.next_diff_exp, 1].max
- rest = [actor.next_rest_exp, 1].max
- draw_gauge(KGC::GenericGauge::EXP_IMAGE,
- x, y, width, diff - rest, diff,
- KGC::GenericGauge::EXP_OFFSET,
- KGC::GenericGauge::EXP_LENGTH,
- KGC::GenericGauge::EXP_SLOPE
- )
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Window_Status
- #==============================================================================
- class Window_Status < Window_Base
- #--------------------------------------------------------------------------
- # ● 経験値情報の描画
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_exp_info(x, y)
- s_next = sprintf(Vocab::ExpNext, Vocab::level)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal)
- self.contents.draw_text(x, y + WLH * 2, 180, WLH, s_next)
- draw_actor_exp(@actor, x, y + WLH * 1)
- draw_actor_next_exp(@actor, x, y + WLH * 3)
- end
- end
复制代码 |
|