• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Showing an image in a window

  • 752
    Posts
    14
    Years
    • UK
    • Seen Dec 29, 2024
    This is not for essentials, just for standard XP

    I have a window created with the text I want, and I'm trying to show an image located in the pictures folder, but am unsure how to do this.
    Also, how would I go about making text multi-lined? Mainly the description text

    Code:
    class Window_Realms < Window_Base
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        @index = []
        super(0, 0, 440, 480)
        self.contents = Bitmap.new(width - 32, height - 32)
        refresh
      end
      
      def setIndex(i)
        @index = i
        refresh
      end
      
      def refresh
          self.contents.dispose
          self.contents = Bitmap.new(width - 32, height - 32)
          
          if @index.size == 7
            name = ($game_variables[@index[5]] > 0) ? @index[0] : "???"
            desc = ($game_variables[@index[5]] > 0) ? @index[1] : "???"
            complete = ($game_variables[@index[5]] == 0) ? "???" : ($game_variables[@index[5]] == 2) ? "Complete" : "Incomplete"
            
            self.contents.draw_text(10, 10, 450, 32, "Name: #{name} - #{complete}")
            self.contents.draw_text(10, 40, 450, 32, "Description:")
            self.contents.draw_text(10, 70, 450, 32, desc)
            
            # Show image at 10, 100
          end
      end
    end
     
    Last edited:
    Code:
    #Name
    self.content.bitmap = Bitmap.new("Graphics/Pictures/PICNAMEHERE")
    
    #Multi-line option 1
    self.contents.draw_text(10, 10, 450, 32, "Name: #{name} - #{complete}\\nDescription")  #\\n creates new line
    
    #Multi-line option 2
    self.contents.draw_text(10, 10, 450, 32, "Name: #{name} - #{complete}    #this is equivalent to \\n
    description")
    
    
    #Consider using 'sprites' and 'viewports', as they already have quite a few methods on them.
    VARIABLE = Sprite.new  #Variable is now a 'Sprite' class, and can use sprite methods
    VARIABLE.bitmap = Bitmap.new("Graphics/Pictures/PICNAMEHERE")
     
    Last edited:
    Back
    Top