EDIT: FOR SOME REASON NOW ITS WORKING, PROBLEM SOLVED (AND I DON'T EDIT THE SCRIPT O.O)
Hi guys, so, I created this script to call it in a event and display an image, however if I call the script more than once disabling the image again the event/npc stops talking to me and even trying to talk to him again nothing happens nor does the script call anymore
Hi guys, so, I created this script to call it in a event and display an image, however if I call the script more than once disabling the image again the event/npc stops talking to me and even trying to talk to him again nothing happens nor does the script call anymore
Code:
class Sprite_Dialogo < Sprite
def initialize(viewport, image_name)
super(viewport)
@nome_avatar = image_name
@bitmap = RPG::Cache.picture(@nome_avatar)
self.bitmap = @bitmap
update_position
self.z = 9999
self.visible = false #controle pelo chamar script
end
def update_position(x = 0, y = 0)
self.x = x
self.y = y
end
def update
super
end
def dispose
@bitmap.dispose if @bitmap
super
end
end
class Spriteset_Map
alias :verdadeiro_initialize :initialize
alias :verdadeiro_dispose :dispose
alias :verdadeiro_update :update
def initialize
#ao invés de usar @avatar_sprite, estou usando $avatar_sprite
#para poder torna-la global e poder acessar no chamar script do evento
# armazenar a instância de Sprite_Dialogo em uma variável global para que possa acessá-la em qualquer lugar.
verdadeiro_initialize
# Certifica de que o viewport está corretamente inicializado
if @viewport1
$sprite_dialogo = Sprite_Dialogo.new(@viewport2, "p1")
$sprite_dialogo.update_position(100, 144)
else
p "Viewport não inicializado corretamente."
end
end
def update
verdadeiro_update
$avatar_sprite.update if @avatar_sprite
end
def dispose
verdadeiro_dispose
$avatar_sprite.dispose if @avatar_sprite
end
end