1.ไปที่Window_Gold สคริปต์ข้างล่างนวางทับ def refresh อันเดิม (เหลือendตัวสุดท้ายไว้อย่าลืมนะครับ)
#สำหรับhp def draw_gradient_hpbar(x, y, length , percenthp) gradient_red_start = 0 gradient_red_end = 0 gradient_green_start = 0 gradient_green_end = 0 gradient_blue_start = 0 gradient_blue_end = 0 self.contents.fill_rect(x-1, y, length+2,5, Color.new(0, 0, 0, 255)) draw_bar_percent = percenthp for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 4) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end #สำหรับsp def draw_gradient_spbar(x, y, length , percentsp) gradient_red_start = 0 gradient_red_end = 0 gradient_green_start = 0 gradient_green_end = 0 gradient_blue_start = 0 gradient_blue_end = 0 self.contents.fill_rect(x-1, y, length+2,5, Color.new(0, 0, 0, 255)) draw_bar_percent = percentsp for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 4) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end |
|