Ok I followed a tutorial on this site, and was able to make a nice hub for my game. After I added it to my game my game began to lag. Can some one help me fix this lag problem.
Code:
class Window_Cat < Window_Base
def initialize
super(410, 0, 227, 132)
self.opacity = 127
self.contents = Bitmap.new(640 - 32, 64 - 32)
refresh
end
def refresh
self.contents.clear
reset_variables
return if !@actor
draw_actor_hp(@actor, 0, -7)
draw_actor_sp(@actor, 0, 11)
self.contents.draw_text(0, 30, 200, 32, "Exp to next: " + $game_party.actors[0].next_rest_exp_s)
self.contents.draw_text(0, 53, 200, 32, "Level " + $game_party.actors[0].level.to_s)
self.contents.draw_text(0, 70, 640, 32, "Hero: " + @actor.name.to_s)
self.contents.draw_text(100, 70, 640, 32, "Gold: " + $game_party.gold.to_s)
end
def reset_variables
@actor = $game_party.actors[0]
@old_hp = @actor ? @actor.hp : 0
@old_maxhp = @actor ? @actor.maxhp : 0
@old_sp = @actor ? @actor.sp : 0
@old_maxsp = @actor ? @actor.maxsp : 0
end
def update
super
refresh if (@actor = $game_party.actors[0] or
@old_hp = @actor ? @actor.hp : 0 or
@old_maxhp = @actor ? @actor.maxhp : 0 or
@old_sp = @actor ? @actor.sp : 0 or
@old_maxsp = @actor ? @actor.maxsp : 0)
end
end
class Scene_Map
alias cat_main main
alias cat_update update
def main
@cat = Window_Cat.new
cat_main
@cat.dispose
end
def update
@cat.update
@cat.visible = $game_switches[8]
cat_update
end
end