@window_gold = Window_Gold.new
@window_gold.x = 640 - @window_gold.width - 32 #右下角窗口
@window_gold.y = 480 - @window_gold.height - 32
@windows << @window_gold << @window_shopcommand << @window_mercenaries << @window_help
@window_help.visible = false
@spriteset = Spriteset_Map.new
end
def main_loop
while $scene == self
rm_update
update_window
input_update
end
end
def main_end
@windows.each{ |window|window.dispose }
@spriteset.dispose
end
def rm_update
Graphics.update
Input.update
end
def update_window
@windows.each{ |window|window.update }
update_help
end
def update_help
if @window_mercenaries.active
@window_help.visible=true
cw=@window_mercenaries.index%@window_mercenaries.column_max*64
ch=@window_mercenaries.index/@window_mercenaries.column_max*80
@window_help.x=cw+@window_mercenaries.x+64
@window_help.y=ch+@window_mercenaries.y+80
if @window_help.x+@window_help.width>640
@window_help.x=640-@window_help.width
end
if @window_help.y+@window_help.height>480
@window_help.y=480-@window_help.height
end
@window_help.draw_actor($game_actors[@window_mercenaries.id])
else
@window_help.visible=false
end
end
def input_update
if Input.trigger?(Input::B)
@window_shopcommand.active=true
@window_mercenaries.active=true
@window_mercenaries.index=-1
end
if Input.trigger?(Input::C)
if @window_shopcommand.active
case @window_shopcommand.index
when 0
@window_mercenaries.set_mercenaries(@temp)
@type=0
@window_shopcommand.active=false
@window_mercenaries.active=true
@window_mercenaries.index=0
return
when 1
actors=[]
for actor in $game_party.actors
actors<<actor.id
end
@window_mercenaries.set_mercenaries(actors)
@type=1
@window_shopcommand.active=false
@window_mercenaries.active=true
@window_mercenaries.index=0
return
when 2
$scene=Scene_Menu.new
end
end#@window_shopcommand.active
case @type
when 0
if $game_party.gold>=$game_actors[@window_mercenaries.id].price
if $game_party.actors.size<4
$game_party.lose_gold($game_actors[@window_mercenaries.id].price)
$game_party.add_actor(@window_mercenaries.id)
@window_mercenaries.mercenaries.delete(@window_mercenaries.id)
@window_mercenaries.refresh
if @window_mercenaries.index>@window_mercenaries.mercenaries.size-1
@window_mercenaries.index=@window_mercenaries.mercenaries.size-1
end
end
end
when 1
if @window_mercenaries.id !=1#$game_party.actors != 1
$game_party.gain_gold($game_actors[@window_mercenaries.id].price/2)
$game_party.remove_actor(@window_mercenaries.id)
@temp<<@window_mercenaries.id
@window_mercenaries.mercenaries.delete(@window_mercenaries.id)
@window_mercenaries.refresh
if @window_mercenaries.index>@window_mercenaries.mercenaries.size-1
@window_mercenaries.index=@window_mercenaries.mercenaries.size-1
end
end
end#case @type
@window_gold.refresh
end#Input::C
end#input_update
end#场景类
end
class Game_Actor
def price [email protected](/,/)[1].nil? ? 0 : @name.split(/,/)[1]
return price*self.level
end
def name [email protected](/,/)[0]
end
end
在地图上建一事件,用脚本:
a=[2,3]
$scene=\
Mercenaries::\
Scene_Mercenaries.new(a)
Game_Actor本来在模块Mercenaries的外部,我把Game_Actor移进Mercenaries内部,怎么显示price
调用错误了?作者: kvkv97 时间: 2023-11-21 21:20
不好意思,我把文本弄错了,重新贴出来一个。
我把格式写成Mercenaries::Game_Actor,结果显示找不到@name,不知道为什么?作者: qq634488405 时间: 2023-11-23 08:18