Jump to content
Zen Blood

Drawing Text Overlapping and Refreshing Windows

Recommended Posts

Hello! I've been hacking away at what I originally thought would be a fairly simple scene to create. I'm making a special little update for my game where players can view concept art. They open up a scene that has a command bar that allows them to scroll through the art using "previous" and "next", with the command "commentary" in the middle that opens up a window to show a brief description of the image. 

textissue.png.8265bdb759b8a7bb5332bb29a6302f7f.png

Almost everything is working pretty swimmingly (after much struggle 😛) except for two issues: 1: when I move to a new picture and re-open the commentary window, the new text will overlap with the old text instead of replacing it, 2: the third line of text doesn't appear for whatever reason. (Solved, it was a typo that prevented the third line from drawing 😣)

Spoiler

textissue2.png.e2cb97b2c95c0911189a967545fd6ae9.png

This is the whole script used to create the window for the artwork commentary:

Spoiler

 


#==============================================================================
# ** Window
#==============================================================================

class Window_ArtworkDescription < Window_Base
  
  def initialize(x, y, w_w, w_h)# X, Y, WIDTH, HEIGHT
    super(x, y, w_w, w_h)
  end
  
  def change_text(text, text2 = "", text3 = "", text4 = "")
    draw_text(text, 5, 20, 0, 0)
    draw_text(text2, 5, 60, 0, 0)
    draw_text(text3, 5, 100, 0, 0)
    draw_text(text4, 5, 140, 0, 0)
  end
  
  def draw_text(text, x, y, text_width, text_height, alignment = 0)
    contents.draw_text(x, y, text_width, text_height, text, alignment)
  end
  
end

 

 

 

This is the script that is used to change the artwork image and the artwork description accordingly (used in the scene):

Spoiler

 


  #--------------------------------------------------------------------------  
  # * REFRESH THE ARTWORK AND ARTWORK COMMENTARY
  #--------------------------------------------------------------------------  
  
  def update_artwork
    case $game_variables[600] #This variable is used to determine which image to pull up (and its description) based on the player using Previous and Next
    when 0
      @selectedartwork_sprite.bitmap = Cache.system("conceptart_01")
      @windowtext  = "One of the first iterations of"
      @windowtext2 = "The Missing Piece. Her 'dark"
      @windowtext3 = "version' was redesigned to be"
      @windowtext4 = "the 'The Other Nipsy.'"
    when 1
      @selectedartwork_sprite.bitmap = Cache.system("conceptart_02")
      @windowtext  = "This is the other description."
      @windowtext2 = "This is the other description."
      @windowtext3 = "This is the other description."
      @windowtext4 = "This is the other description."
    end #There's more, but I'll keep this part short since it just repeats.
    
  #--------------------------------------------------------------------------  
  # * These next 3 commands are called in other parts of the script. 
  #   create_description_window is called during the start of the scene
  #   open_description_window is ONLY called when the player selects "Commentary"
  #   close_description_window is called when the player selects ANY of the 
  #   commands (Previous, Commentary, Next) and @commentaryup is set to true
  #--------------------------------------------------------------------------  
    
  def create_description_window
    @description_window = Window_ArtworkDescription.new(120, 139, 400, 178)
    @description_window.hide
    @commentaryup = false
  end
  
  def open_description_window
    @description_window.show
    @description_window.open
    @description_window.change_text(@windowtext, @windowtext2, @windowtex3, @windowtext4)
    @commentaryup = true
  end
  
  def close_description_window
    @description_window.close
    @commentaryup = false
  end

 

 

 

I was hoping to completely dispose of and recreate the window using @description_window.dispose, but after much ado, I could only get it to throw up this error:

textissue3.png.ac3e426f17a39baa73e754059d4ac673.png

To me, this looks like the .dispose command has a definition and could work, but the script doesn't think there's a window to dispose of? After I couldn't get that to work, I resolved to attempt to replace the drawn text and keep the window in existence as long as the scene is up.

As for the missing third line, I'm really unsure of what's happening because all four lines are drawn exactly the same but at different coordinate of the Y Axis. 🤔 I'll continue poking around for any misspellings that may be interfering with the third line appearing, because that's the only thing I can think is the problem at the moment. Yes, it was that! I've been trying to figure this out for a day, but the minute I post for help, my brain decides to un-derp itself.

I'm using Victor's S Font, by the way. Thank you for any and all help!

Edited by Zen Blood
Edited to show I resolved one issue.

Share this post


Link to post
Share on other sites

You could try something like

def description_clear
  @description_window.clear
end

# in Window_ArtworkDescription 

def clear
  self.contents.clear
end

that should remove the draw text

  • Thanks 1

Share this post


Link to post
Share on other sites
8 hours ago, roninator2 said:

You could try something like

Spoiler




def description_clear
  @description_window.clear
end

# in Window_ArtworkDescription 

def clear
  self.contents.clear
end


 

that should remove the draw text

You are exactly right! Thank you so much.

Before I posted here, I tried using .clear and got an error. Since I could use .dispose/.hide/ect;, I thought .clear simply didn't exist. I did sweep through Window_Base and didn't find it either, but I did see the word "contents" being used. Does the method clear come from class Window instead of Window_Base?

Share this post


Link to post
Share on other sites

.clear comes form the Bitmap class. All windows have a bitmap called contents, so you can clear a window with .contents.clear you see.

  • Thanks 1

Share this post


Link to post
Share on other sites

Ah! Thank you @Kayzee, I understand that better now. I'm going to look into learning more about that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted