Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Distance between the text and window border!! :P

Hii every one!! :smile:
I'm starting a game and I'm rewriting some of the code in RGSS!! one thing I came across was when I write text on a window.. the text is to far away from the border! :S is there a way to reduce the distance?? saying I want the text to be for example, 8 pixels away from the border of the window!
Can someone help me here? :crazy:
 
The draw_text method allows you to set the coordinates for the text:
Code:
window.contents.draw_text(x, y, width, height, text, alignment)
X and Y are the coordinates, remember that the upper left corner is (0, 0). So if you want to draw the text 8 pixels away from the borders, just do:
Code:
window.contents.draw_text(8, 8, 200, 32, "Hello World")
 
I'm pretty sure he means the cutoff point, where text won't display. IF that's the case, you'll need a hidden window class rewrite. (It was by Sephirothspawn, or one of the other older scripters). Also, 0,0 as an x and y actually draws it away from the borders, because the cutoff point is also 0,0. Thre cutoff point (0,0) is actually 16 pixels into the window from every direction.
 
@vgvgf - Ok! I thought I understood, but aparently I didn't well this is what I have got:

Code:
class Test < Window_Base

  
  def initialize
    super(0, 0, 480, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @newwindow = Window.new
    refresh
  end

  
  def refresh
    self.contents.clear
    @newwindow = window.contents..draw_text(8, 8, 200, 32, "Hello World")

  end

end

I'm using it wrong.. I'm almost sure but I looked for information every where and I don't know where is the error
 
Code:
class Test < Window_Base

  
  def initialize
    super(0, 0, 480, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    refresh
  end

  
  def refresh
    self.contents.clear
    self.contents.draw_text(8, 8, 200, 32, "Hello World")

  end

end

You had several problems. First, in a window, you don't use Window.new
Second, you had two periods before draw_text(...)
Third, all you need is a self.whatever command.

Oh, and I'd recommend against global variables. I could go into a lengthy explanation of why they are bad coding, but let's just say it isn't a very good idea.
 
@Glitchfinder - You're write I'm talking about the "cutoff point", or "marign" I found the script rewritting the Window hidden class! Everything is OKAY now! btw thank you for correcting my code.. it wasn't actually like this, I just put on a sketch to examplify the problem! But everything is OK now!

@vgvgf - Thank you for the velocity in the response and for the attention xD

Goods to all of you!! :grin: :grin:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top