Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RMVX มีสคริป คะแนน และ ค่าพลัง ของ ผู้เล่นไหมครับ
#1
มีสคริป คะแนน และ ค่าพลัง ของ ผู้เล่นไหมครับ

ผมมี ของ xp แต่ไปใส่ ใน vx แล้วมัน Error

และ อีกอันนึ่งมี vx ace มันก็ Error เหมือนกันครับ
ของ vx ace ที่ error
?27? NameError???
uninitialized constant Scene_Map::SceneManager

อันนี้คือ สคริป vx ace

class ScoreWindow < Window_Base
def initialize
super(0, 0, window_width, window_height)
makeScore
refresh
self.opacity=0
end
def window_width
return 200
end
def window_height
return 100
end
def refresh
contents.clear
makeScore
end

def makeScore
text=sprintf("Score: %d", $game_variables[1])
draw_text(0, 0, 200, line_height, text)
end
end
class Scene_Map < Scene_Base
def start
super
SceneManager.clear
$game_player.straighten
$game_map.refresh
$game_message.visible = false
create_spriteset
create_all_windows
@menu_calling = false
makeWindow
end
def makeWindow
@myWindow=ScoreWindow.new
end
def update
super
$game_map.update(true)
$game_player.update
$game_timer.update
@spriteset.update
update_scene if scene_change_ok?
if $update==1
@myWindow.refresh
end
if $showScore==0
@myWindow.hide
end
if $showScore==1
@myWindow.show
end
end
end

ส่วนจะแก้ ของ xp หรือ vx ace ง่ายกว่ากัน
หรือมีวิธีไหนที ให้มันแสดงคะแนน และค่าพลัง ในเกม รบกวนด้วยนะครับ
Reply
#2
คิดว่าถ้าโมจาก VX Ace ไป VX น่าจะง่ายกว่า อยากลองช่วยแต่ติดตรงที่ผมไม่มี License ของ VX นี่สิ *0*
ว่าแต่อยากรู้ทำไมถึงใช้ VX หรือครับ แหะๆ
[-] The following 2 users say Thank You to splendith for this post:
  • snowhero, XthemeCore
Reply
#3
ของxpไปใส่ในvxไม่ได้และของvxไปใส่ในvxaตรงๆเลยก็ไม่ได้ต้องแปลงเอา
สำหรับระบบประมาณนี้ใช้ตัวแปรแล้ววางอีเวนท์เอาน่าจะง่ายกว่านะ
[Image: 76561198134933497.png]
Show ContentFanPage:


[-] The following 1 user says Thank You to Nazuth for this post:
  • XthemeCore
Reply
#4
ผมดูจากโค้ดนับคะแนนที่ให้มาคิดว่าปัญหาเยอะ
1. มีการใช้ global variable เยอะ และมีค่าเริ่มต้น nil ซึ่งไม่ปลอดภัยมาก
2. score ไม่ update ทันทีเมื่อตัวแปรเปลี่ยน (ผมลองใน Ace เวลาเปลี่ยนตัวแปรคะแนน ต้องเข้าออกเมนู คะแนนถึงจะอัพเดต แต่จากการแกะโค้ด คิดว่าต้องเปลี่ยนค่า $update เป็น 1 คะแนนถึงอัพเดต ซึ่งอาจเกิดปัญหาที่กล่าวไปในข้อ 1. ในอนาคต)
3. โมให้ไปใช้ได้ในเวอร์ชันอื่นยากมากๆ เพราะใช้วิธีการ overwrite เยอะจัด ทำให้โค้ดซับซ้อนและอาจมีโอกาสมีปัญหาในอนาคต (ถ้าสนใจลองอ่านรายละเอียดเกี่ยวกับ overwrite / alias ที่นี่จ้า)

ผมเลยเขียนขึ้นใหม่ครับ แสดงทั้งคะแนนและ HP ของตัวละคร
น่าจะใช้งานได้ทั้ง VX / VX Ace

โดยมี Config 6 จุด
SHOW_SWITCH: ใส่หมายเลข id สวิตซ์ที่ใช้เปิด-ปิด การแสดงระบบคะแนน เวลาจะ เปิด-ปิด การแสดงจะได้ไม่ยาก เพียงสั่งเปิด-ปิด switch ที่ต้องการใน event
SCORE_VARIABLE: ใส่หมายเลข id ตัวแปรที่ใช้นับคะแนน
HP_PARTY_MEMBER: ใส่หมายเลขลำดับสมาชิกที่ต้องการให้แสดง HP บนจอ โดยสมาชิกคนแรก (หรือ leader) จะเริ่มนับที่ 0 ไปเรื่อยๆ
SCORE_TEXT: ข้อความแสดงคะแนน โดย %d หมายถึงคะแนน
BG_OPACITY: ความโปร่งใสพื้นหลัง (0 - 255)
WINDOW_WIDTH: กำหนดขนาดของจอแสดงผล

ถ้ามีปัญหาแจ้งได้ครับผม Big Grin

[shcode=rails]
module SCORE_PANEL
SHOW_SWITCH = 1
SCORE_VARIABLE = 1
HP_PARTY_MEMBER = 0 # Party member that show HP on the screen, first member (or leader) is 0

SCORE_TEXT = "Score: %d"
BG_OPACITY = 0 # 0 - 255

WINDOW_WIDTH = 200
end

class Window_Score < Window_Base

def initialize
super(0, 0, window_width, window_height)
self.opacity = SCORE_PANEL::BG_OPACITY
refresh
end

def update
super
refresh
end

def window_width
return SCORE_PANEL::WINDOW_WIDTH
end

def window_height
return line_height*2 + 32
end

def line_height
if defined?(super)
return super
else
return WLH
end
end

def refresh
self.visible = $game_switches[SCORE_PANEL::SHOW_SWITCH]
contents.clear
make_score
end

def make_score
text = sprintf(SCORE_PANEL::SCORE_TEXT, $game_variables[SCORE_PANEL::SCORE_VARIABLE])
self.contents.draw_text(0, 0, window_width - 32, line_height, text)
self.draw_actor_hp($game_party.members[SCORE_PANEL::HP_PARTY_MEMBER], 0, line_height, window_width - 32)
end

end

class Scene_Map < Scene_Base
alias cur_start start
def start
cur_start
make_window
end

def make_window
@score_window = Window_Score.new
end

alias cur_update update
def update
cur_update
@score_window.update
end
end

[/shcode]
[-] The following 3 users say Thank You to splendith for this post:
  • dreamknight, snowhero, XthemeCore
Reply
#5
ขอบคุณมากครับ ได้ความรู้เยอะเลยเว็บนี้ มีกรูรู เยอะเเยะ ยังไงมีเรื่องสงสัยจะเข้ามาถามอีกนะครับ
[-] The following 1 user says Thank You to snowhero for this post:
  • splendith
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)