Oh wow where to begin. Alright first Window_Name:
class Window_Name < Window_Base
def initialize(actor)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
def refresh
self.contents.clear
draw_actor_name(@actor, 40, 0)
end
def update
# I guess I should do something.
end
end
Ok never ever use $defaultfontsize/$defaultfontname. These are no no. In the legal version there is no such thing as those global variables. In the legal version which you do in fact have, these cause an error. So no worries if you thought I was accusing you. Window's font and such are pulled from the "Font" class and this is done automatically so you don't even need to set the default font name or the size like you were doing in the initialize originally. In the update of the window you don't want to put things like Input catches. This should be left up to the scene where the window is being created. In this case, Scene_Name.
class Scene_Name
def initialize(actor_index = 0)
@actor_index = actor_index
end
def main
actor = $game_party.actors[@actor_index]
@name_window = Window_Name.new(actor)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@name_window.dispose
end
def update
@name_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
end
end
Originally you were creating a Window_Name object passing in the variable "actor" instead of "@actor". These are seen as two very different things in Ruby. One is a local variable, "actor", the other an instance variable, "@actor". So the solution was just make the instance variable a local variable by removing the at symbol(@) from the front of it. You don't need to know the actor across multiple methods within this class. Lastly if you don't make a new update in Scene_Name it will call the original Scene_Name's update and will cause you errors. So I wrote a method to override the update of Scene_Name which only checks for the B button press. If it is pressed go back to Scene_Map.
Now to the event you created just above the start player's position. You can't plop a $ in front of a class name. Meaning you can't do something like this:
That will not work. You need a global variable to store the instance of the class you are instantiating.
See the difference? But in your case you are creating a window. Never create a window through a script call on the map. This would mean that the window would have to handle many of the functions that a Scene type object would normally handle. I assume that's why you originally had Input calls inside Window_Name. Also disposal and updating the window suddenly becomes a fiasco. This is a poor practice I would not encourage. Always have a Scene that contains objects that can be affected by input. Your script call should be something like:
Good luck with it Ryuzaki! :thumb: