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.

How to use .oy and .ox.

Tdata

Sponsor

I would like to know how to use oy and ox. As no one has helped me with my last question i feel i must ask this one.
 
ox and oy are short for original-x and original-y, for example used while cutting images into pieces. There are good examples in Sprite_Character, I think...
If you want to do something specific and can't figure it out looking at the example, tell us what it is, so it's easier for us to help you ^_^
 
NAME.ox = NAME.ox + #
NAME.oy = NAME.oy + #

Where NAME is the name of the plane/window, and # is the speed in pixels to move in (+/-).

You should put this within the "Refresh" section of the script or somewhere similar.
 

Tdata

Sponsor

so for example, i'd do something along the lines of?
Code:
      if @status_window.index >= 3
        @status_window.oy = @status_window.oy + (160 * (@status_window.index - 1))
      end
 
When you create the window's initial bitmap, you are essentially creating the 'bounds' for drawing any of that window's content. Your initial bitmap for that window probably looks something like this:

Code:
self.contents = Bitmap.new(width - 32, height - 32)

You need to change it to something like this:

Code:
self.contents = Bitmap.new(width - 32, @item_max * 32)

Where @item_max is the number of lines within that window.
 
ox and oy, like Yiyinde said, is the sprite's origin coordinates. These coordinates are used for many things. The sprite will be rotated around these coordinates, it will be resized around these coordinates too.
 
That feature is automatically built into the Window_Selectable class. The @item_max variable is used to keep track of how many lines/options there are in the window. When the index exceeds the limit, it returns to 0 (or vice versa).
 
Set the index if your window to correspond to one of the visible lines. Let's say you're looking at lines 5-8 and your index is 6. You scroll up to lines 1-4, so your cursor is no longer visible. Set the index of the window to be between 0 and 3.
 

Tdata

Sponsor

Here is what i have, I still can't get it to work correctly.
Code:
def update_status
       # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Make command window active
        @player_menu.active = true
        @status_window.active = false
        @status_window.visible = false
        return
      end
      # If C button was pressed
      if Input.trigger?(Input::A) or Input.trigger?(Input::C)
        # Branch by command window cursor position
        case @player_menu.index
        when 0  # status
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          # Switch to status screen
          $scene = Scene_Status.new(@status_window.index)
        when 1  # equipment
            # Play decision SE
            $game_system.se_play($data_system.decision_se)
            # Switch to equipment screen
            $scene = Scene_Equip.new(@status_window.index)
        when 2  # skill
              # If this actor's action limit is 2 or more
              if $game_party.actors[@status_window.index].restriction >= 2
                # Play buzzer SE
                $game_system.se_play($data_system.buzzer_se)
                return
              end
              # Play decision SE
              $game_system.se_play($data_system.decision_se)
              # Switch to skill screen
              $scene = Scene_Skill.new(@status_window.index)
        end      
      end
      if @status_window.index <= 2
        @status_window.oy = 0
      end
      if @status_window.index > 2 and @status_window.index <=5
        @status_window.oy = (120 * 3)
      end
      if @status_window.index > 5 and @status_window.index <=8
        @status_window.oy = (120 * 6)
      end
      if @status_window.index > 8 and @status_window.index <=11
        @status_window.oy = (120 * 9)
      end
    end
The scrolling part i can fix myself, but the cursor isn't showing up right. I tryed to set the index back to 0 after the scrolling, but thn it just stays at the second level of people...
 

Tdata

Sponsor

Please mark this as resolved.

my solution:
Code:
class Window_MenuStatus
  def initialize
    super(0, 0, 480, (12*120))
    @item_max = $game_party.actors.size
    self.contents = Bitmap.new(width - 32, (12 * 120))
    refresh
    self.active = false
    self.index = -1
  end
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      if (@index * 116) < 348
       self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
     else 
       self.cursor_rect.set(0, (@index - 3) * 116, self.width - 32, 96)
       if (@index * 116) > 580
         self.cursor_rect.set(0, (@index - 6) * 116, self.width - 32, 96)
         if (@index * 116) > 928
           self.cursor_rect.set(0, (@index - 9) * 116, self.width - 32, 96)
         end
       end
     end
   end
 end
end

#----------------

    def update_status
       # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Make command window active
        @player_menu.active = true
        @status_window.active = false
        @status_window.visible = false
        return
      end
      # If C button was pressed
      if Input.trigger?(Input::A) or Input.trigger?(Input::C)
        # Branch by command window cursor position
        case @player_menu.index
        when 0  # status
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          # Switch to status screen
          $scene = Scene_Status.new(@status_window.index)
        when 1  # equipment
            # Play decision SE
            $game_system.se_play($data_system.decision_se)
            # Switch to equipment screen
            $scene = Scene_Equip.new(@status_window.index)
        when 2  # skill
              # If this actor's action limit is 2 or more
              if $game_party.actors[@status_window.index].restriction >= 2
                # Play buzzer SE
                $game_system.se_play($data_system.buzzer_se)
                return
              end
              # Play decision SE
              $game_system.se_play($data_system.decision_se)
              # Switch to skill screen
              $scene = Scene_Skill.new(@status_window.index)
        end      
      end
      if @status_window.index > 2
        @status_window.oy = (116 * 3)
        if @status_window.index > 5
          @status_window.oy = (116 * 6)
          if @status_window.index > 8
            @status_window.oy = (116 * 9)
          end
        end
      else 
        @status_window.oy = 0
      end
    end
If anyone has a better/cleaner solution please post it.

I now have to clean up my code... :)
 

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