module DataManager
class << self
alias :th_multiplayer_create_game_objects :create_game_objects
alias :th_multiplayer_make_save_contents :make_save_contents
alias :th_multiplayer_extract_save_contents :extract_save_contents
end
def self.create_game_objects
th_multiplayer_create_game_objects
$game_player2 = Game_Multiplayer.new
end
def self.make_save_contents
contents = th_multiplayer_make_save_contents
contents[:player2] = $game_player2
contents
end
def self.extract_save_contents(contents)
th_multiplayer_extract_save_contents(contents)
$game_player2 = contents[:player2]
end
def self.setup_new_game
create_game_objects
$game_party.setup_starting_members
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$game_player2.moveto($data_system.start_x, $data_system.start_y)
$game_player2.refresh
Graphics.frame_count = 0
end
end
class Game_Multiplayer < Game_Player
DOWN = Input::Y # S in Keyboard
LEFT = Input::X # A in Keyboard
RIGHT = Input::Z # D in Keyboard
UP = Input::R # W in Keyboard
ENTER = Input::L # Q in Keyboard
RUN = Input::A # Shift in Keyboard
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
if Input.press?(DOWN)
move_straight(2)
elsif Input.press?(LEFT)
move_straight(4)
elsif Input.press?(RIGHT)
move_straight(6)
elsif Input.press?(UP)
move_straight(8)
end
end
def update_nonmoving(last_moving)
return if $game_map.interpreter.running?
if last_moving
$game_party.on_player_walk
return if check_touch_event
end
if movable? && Input.trigger?(ENTER)
return if get_on_off_vehicle
return if check_action_event
end
update_encounter if last_moving
end
end
class Spriteset_Map
alias :th_multiplayer_create_characters :create_characters
def create_characters
th_multiplayer_create_characters
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player2))
end
end
class Scene_Map < Scene_Base
alias :th_multiplayer_map_update :update
def update
th_multiplayer_map_update
$game_player2.update if $game_player2
end
end
อันนี้คือสคริปที่เล่นได้ 2 คนในหน้าต่างเดียวในเกมแต่ผมสงสัยว่ามันสามารถเปลี่ยนตัวละครเป็นตัวอื่นได้ไหมถ้าทำได้มันสามารถเปลี่ยนยังไงเพราะตอนนี้ที่ผมทำคือพอใส่สคริปแล้วมันมีตัวละครตัวเดียวกันออกมา 2 ตัวสอบถามผู้รู้ครับ (ศึกษาเพื่อแข่งศิลปหัตถกรรม)
rpg maker vx ace 2 ผู้เล่น
class << self
alias :th_multiplayer_create_game_objects :create_game_objects
alias :th_multiplayer_make_save_contents :make_save_contents
alias :th_multiplayer_extract_save_contents :extract_save_contents
end
def self.create_game_objects
th_multiplayer_create_game_objects
$game_player2 = Game_Multiplayer.new
end
def self.make_save_contents
contents = th_multiplayer_make_save_contents
contents[:player2] = $game_player2
contents
end
def self.extract_save_contents(contents)
th_multiplayer_extract_save_contents(contents)
$game_player2 = contents[:player2]
end
def self.setup_new_game
create_game_objects
$game_party.setup_starting_members
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$game_player2.moveto($data_system.start_x, $data_system.start_y)
$game_player2.refresh
Graphics.frame_count = 0
end
end
class Game_Multiplayer < Game_Player
DOWN = Input::Y # S in Keyboard
LEFT = Input::X # A in Keyboard
RIGHT = Input::Z # D in Keyboard
UP = Input::R # W in Keyboard
ENTER = Input::L # Q in Keyboard
RUN = Input::A # Shift in Keyboard
def move_by_input
return unless movable?
return if $game_map.interpreter.running?
if Input.press?(DOWN)
move_straight(2)
elsif Input.press?(LEFT)
move_straight(4)
elsif Input.press?(RIGHT)
move_straight(6)
elsif Input.press?(UP)
move_straight(8)
end
end
def update_nonmoving(last_moving)
return if $game_map.interpreter.running?
if last_moving
$game_party.on_player_walk
return if check_touch_event
end
if movable? && Input.trigger?(ENTER)
return if get_on_off_vehicle
return if check_action_event
end
update_encounter if last_moving
end
end
class Spriteset_Map
alias :th_multiplayer_create_characters :create_characters
def create_characters
th_multiplayer_create_characters
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player2))
end
end
class Scene_Map < Scene_Base
alias :th_multiplayer_map_update :update
def update
th_multiplayer_map_update
$game_player2.update if $game_player2
end
end
อันนี้คือสคริปที่เล่นได้ 2 คนในหน้าต่างเดียวในเกมแต่ผมสงสัยว่ามันสามารถเปลี่ยนตัวละครเป็นตัวอื่นได้ไหมถ้าทำได้มันสามารถเปลี่ยนยังไงเพราะตอนนี้ที่ผมทำคือพอใส่สคริปแล้วมันมีตัวละครตัวเดียวกันออกมา 2 ตัวสอบถามผู้รู้ครับ (ศึกษาเพื่อแข่งศิลปหัตถกรรม)