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.

Scrolling windows

Heya

Just wondering how do you make windows scroll.
LIke how can you make a window have multiple choice then are off screen untill you press down and the top ones go off screen as the bottom ones go up.

I just can't figure it out. I've gone dumb



Thanks in advance ^_^
 
It's all adjusting the oy variable. Window_Selectable is a bit un-organized, but essientially, when you set the top row (is taken care of in the update or sub-update methods), it basically takes whatever row it is, and adjust the oy with the row number * 32. So if you are scrolling down two rows, so the second row is on the top, then the windows self.oy is 64.

If you make the window and tell me exactly what you are wanting, I will help you get it going.
 
Right, ok this is what I've got so far:

Code:
#--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
def initialize(width)
  super(80, 336, 480,  32 * $game_temp.choice_text.size + 32 - 40) #336 #136 # 32 * $game_temp.choice_text.size + 32 - 40
  self.contents = Bitmap.new(width - 32, height - 32)
  self.contents.font.name = $fontface
  self.contents.font.size = $fontsize
  self.opacity = 0
  self.z = 200
  @item_max = $game_temp.choice_text.size
  self.index = 0
  @width = width
  refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
def refresh
  self.contents.clear
  for i in 0...$game_temp.choice_text.size
    x = 2
    y = i * 32
    self.contents.draw_text(x, y, @width, 32, $game_temp.choice_text[i])
  end
end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
def update_cursor_rect
  if @index >= 0
    if @width != nil
      self.cursor_rect.set(0, @index * 32, @width - 43, 32)
    end
  else
    self.cursor_rect.empty
  end
end
end

Oh I missed off the top class, but that doesn't matter. It's under Window_Selectable.

Right my problem is that the options appear, but you can't scroll down to them and that the window is the right size...
I wanted the window to cut off about where the Window_Message window ends.

Thanks
Syvkal

:EDIT:
Ignore the comments in the script. They were just incase I forgot some of the measurements.
 
because you override 'update_cursor_rect' the original method in Window_Selectable isn't called anymore.
Code:
alias :update_cursor_rect_original :update_cursor_rect
def update_cursor_rect
  if @index >= 0
    if @width != nil
      update_cursor_rect_original
    end
  else
    self.cursor_rect.empty
  end
end
I'm not sure if it works, but you can try it.
 
First, thanks Freakboy that kinda worked....
It lets me scroll down, but it doesn't show any of the options after the first 3.
And it doesn't show the select bar at the bottom set of them.

This is what I've got for it so far:
Code:
class Window_Choices < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
def initialize(width)
  super(80, 336, 480,  160 - 32)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.opacity = 0
  self.z = 9999
  @item_max = $game_temp.choice_text.size
  self.index = 0
  @width = width
  refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
def refresh
  self.contents.clear
  for i in 0...$game_temp.choice_text.size
    x = 8
    y = i * 32
    self.contents.draw_text(x, y, @width, 32, $game_temp.choice_text[i]) 
  end
end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
alias update_cursor_rect_original update_cursor_rect
def update_cursor_rect
  if @index >= 0
    if @width != nil
      update_cursor_rect_original
      self.cursor_rect.set(6, @index * 32, @width - 42, 32)
    end
  else
    self.cursor_rect.empty
  end
end
end
 

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