XthemeCore   10-13-2012, 10:13 PM
#1
ต้องขอโทษทุกท่านด้วยครับที่มาขาดๆหายๆ
วันนี้มีคำถามอยากขอความช่วยเหลือหน่อยครับ
คือจากภาพด้านล่างนี้

[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]

ช่วยหน่อยนะครับ
This post was last modified: 10-13-2012, 10:14 PM by XthemeCore.
Muge9thD   10-13-2012, 10:24 PM
#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
This post was last modified: 10-13-2012, 10:28 PM by Muge9thD.

[Image: 3e1d83fcd8.png]
[Image: 76561198067540196.png][Image: AddFriend.png]
XthemeCore   10-13-2012, 10:35 PM
#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]

ขอบคุณครับ
This post was last modified: 10-13-2012, 10:35 PM by XthemeCore.
  
Users browsing this thread: 1 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.