Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RGSS1 ช่วยหน่อยครับเรื่องแถบ exp (Script HUD ของ mog hunter)
#1
Question 
ต้องขอโทษทุกท่านด้วยครับที่มาขาดๆหายๆ
วันนี้มีคำถามอยากขอความช่วยเหลือหน่อยครับ
คือจากภาพด้านล่างนี้

[Image: asdasdd_zpsdd6afabd.png]

ผมกำลังทำแถบ exp สำหรับเกมครับโดย mo จาก HUD ของ mog hunter
ทีนี้ผมทำแถบ exp 2 แถบ โดยแถบซ้ายเป็น exp ของเรา ส่วนแถบขวาเป็น exp ของนคร
ผมอยากให้แถบขวาเพิ่มจากขวาไปซ้ายครับ จากที่เห็นในภาพจะเพิ่มจากซ้ายไปขวาทั้งสองแถบครับ
ไม่รู้ทำไงดีเลยแนบ script บางส่วนมาให้ครับ (ตัดมาเฉพาะส่วนของ exp ของนครนะครับ)

[shcode=rails]
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# * Now Exp
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end

#--------------------------------------------------------------------------
# * Next Exp
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end

class HUD < Sprite
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@civil = $game_party.actors[1]
return if @civil == nil
@civil_level = @civil.level
@civil_exp = @civil.exp


# CIVILIZATION LEVEL METER
@civil_level_image = RPG::Cache.windowskin("C_Exp_Meter")
@civil_level_bitmap = Bitmap.new(@civil_level_image.width,@civil_level_image.height)
@civil_level_sprite = Sprite.new
civil_rate = @civil.now_exp.to_f / @civil.next_exp
civil_rate = 1 if @civil.next_exp == 0
@civil_level_cw = @civil_level_image.width * civil_rate
@civil_level_cw = @civil_level_image.width if @civil.level == 99
@civil_level_src_rect_back = Rect.new(0, 0,@civil_level_cw, @civil_level_image.height)
@civil_level_bitmap.blt(0,0, @civil_level_image, @civil_level_src_rect_back)
@civil_level_sprite.bitmap = @civil_level_bitmap
@civil_level_sprite.z = 5001
@civil_level_sprite.x = CIVIL_LEVEL_METER[0] + HUD_X
@civil_level_sprite.y = CIVIL_LEVEL_METER[1] + HUD_Y
end

def update
civil_exp_update if @civil_exp != @civil.exp
end
end

#--------------------------------------------------------------------------
# * Civilization_exp_update
#--------------------------------------------------------------------------
def civil_exp_update
@civil_level_sprite.bitmap.clear
civil_rate = @civil.now_exp.to_f / @civil.next_exp
civil_rate = 1 if @civil.next_exp == 0
@civil_level_cw = @civil_level_image.width * civil_rate
@civil_level_cw = @civil_level_image.width if @civil.level == 99

@civil_level_src_rect_back = Rect.new(0, 0,@civil_level_cw, @civil_level_image.height)
@civil_level_bitmap.blt(0,0, @civil_level_image, @civil_level_src_rect_back)
@civil_exp = @civil.exp
end
[/shcode]

ช่วยหน่อยนะครับ
Reply
#2
ลองเอาไปเทสดูฮะ บอกผลด้วยเน้อว์ >w<//
[shcode=rails]#==============================================================================?
# Game_Actor
#====================================================================?==========
class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# * Now Exp
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end

#--------------------------------------------------------------------------
# * Next Exp
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end

class HUD < Sprite
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@civil = $game_party.actors[1]
return if @civil == nil
@civil_level = @civil.level
@civil_exp = @civil.exp


# CIVILIZATION LEVEL METER
@civil_level_image = RPG::Cache.windowskin("C_Exp_Meter")
@civil_level_bitmap = Bitmap.new(@civil_level_image.width,@civil_level_image.height)
@civil_level_sprite = Sprite.new
civil_rate = @civil.now_exp.to_f / @civil.next_exp
civil_rate = 1 if @civil.next_exp == 0
@civil_level_cw = @civil_level_image.width * civil_rate
@civil_level_cw = @civil_level_image.width if @civil.level == 99
@civil_level_src_rect_back = Rect.new(0, 0,@civil_level_cw, @civil_level_image.height)
@civil_level_bitmap.blt(@civil_level_image.width - @civil_level_cw ,0, @civil_level_image, @civil_level_src_rect_back)
@civil_level_sprite.bitmap = @civil_level_bitmap
@civil_level_sprite.z = 5001
@civil_level_sprite.x = CIVIL_LEVEL_METER[0] + HUD_X
@civil_level_sprite.y = CIVIL_LEVEL_METER[1] + HUD_Y
end

def update
civil_exp_update if @civil_exp != @civil.exp
end
end

#--------------------------------------------------------------------------
# * Civilization_exp_update
#--------------------------------------------------------------------------
def civil_exp_update
@civil_level_sprite.bitmap.clear
civil_rate = @civil.now_exp.to_f / @civil.next_exp
civil_rate = 1 if @civil.next_exp == 0
@civil_level_cw = @civil_level_image.width * civil_rate
@civil_level_cw = @civil_level_image.width if @civil.level == 99

@civil_level_src_rect_back = Rect.new(0, 0,@civil_level_cw, @civil_level_image.height)
@civil_level_bitmap.blt(@civil_level_image.width - @civil_level_cw,0, @civil_level_image, @civil_level_src_rect_back)
@civil_exp = @civil.exp
end [/shcode]
น่าจะไม่มีปัญหาPoker Face
[Image: 3e1d83fcd8.png]
[Image: 76561198067540196.png][Image: AddFriend.png]
[-] The following 1 user says Thank You to Muge9thD for this post:
  • XthemeCore
Reply
#3
ขอบคุณครับ คุณ Muge9thD

ตรง @civil_level_src_rect_back = Rect.new(0, 0,@civil_level_cw, @civil_level_image.height)

ผมแก้ x = 0 เป็น @civil_level_image.width - @civil_level_cw ด้วยครับ
มันจะเริ่มจากปลายพอดี

[Image: qweqwe_zpsdab090fc.png]

ขอบคุณครับ
[-] The following 1 user says Thank You to XthemeCore for this post:
  • Muge9thD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)