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.

Need some help

Basically, what I am trying to do is this:

-If f8 is pressed, two windows are shown. If it is pressed again they disappear.
-If f9 is pressed, same but different windows.

Here's what I have:

Code:
def update_winds
    if Input.trigger?(Input::F8)
      if @inputf8 == true
        @inputf8 = false
      else
        @inputf8 = true
      end
    end
    if Input.trigger?(Input::F9)
      if @inputf9 == true
        @inputf9 = false
      else
        @inputf9 = true
      end
    end
  end

/\ In a seperate thing called def winds.

Code:
if @inputf8 == true
      @window1.update
      @window2.update
    end
    if @inputf9 == true
      @herowin.update
      @petwin.update
    end

/\ In def update_graphics

Code:
update_winds

/\ In def update

Code:
    if @inputf8 == true
      @window1 = Window_Quests.new
      @window2 = Window_QuestRewards.new
    end
    if @inputf9 == true
      @herowin = Window_HeroStats.new
      @petwin = Window_PetStats.new
    end

/\ In def main_draw

This is all in Scene_Map...

I know I have done this wrong, as it is not working. (Undefined method "update", for these lines:
@herowin.update
@petwin.update
@window1.update
@window2.update

How should I have done this?
 
first you have to initialize the followings in the main method of your scene :
Code:
@window1 = Window_Quests.new
@window2 = Window_QuestRewards.new

and to make windows appear and disappear you have to use
Code:
WINDOW.visible = false # or true

so I'd go like this in the update method:

Code:
if Input.trigger?(Input::F9)
  bool |= @window1.visible
  @window1.visible = @window2.visible = bool
  return
end
 
it should have worked.
could you post the scene script you're using please?

and this won't make the windows invisible by default. to do that you have to put the following lines right after you initialized your windows :
Code:
@window1.visible = false
@window2.visible = false
 

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