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.

very basic Scene question

ok...i'm really newb to all this as you may know, and i need scene_map to show two windows, that i already created, but the problem is that i need the player to activate them by call script.

well...i hope it's not so confusing...
i was trying to use booleans for if @window1 = true and stuff...but i dont know how to use these stuff yet.
if you can help me, i would be very grateful :thumb: ;)
 
Use this:
Code:
class Scene_Map
  alias scene_map_main main
  def main
    @window1 = Window_1.new # Change Window_1 to your window class
    @window2 = Window_2.new # Change Window_2 to your window class
    scene_map_main
    @window1.dispose
    @window2.dispose
  end
end
 
Use:
Code:
class Scene_Map
  attr_accessor :window1
  attr_accessor :window2
  alias scene_map_main main
  def main
    @window1 = Window_1.new # Change Window_1 to your window class
    @window2 = Window_2.new # Change Window_2 to your window class
    @window1.visible = false
    @window2.visible = false
    scene_map_main
    @window1.dispose
    @window2.dispose
  end
end
And in the event call script, use:
Code:
$scene.window1.visible = true # For show the window
$scene.window1.visible = false # For hide the window
 
oh my god thank you so very much!!!
finally...thanks a lot...
and...well, this is not necessary, but would you mind explaining why are the attr_accessor there for?
im really interested to know =)
 
The attr_accessor functions declares a instance variable(The variables with the "@") to be able for reading from a external place. In other words, in the script I made for you, the attr_accessor allow that I can modify or read the "@window1" variable with "$scene.window1".
 

Mac

Member

In extra detail you have:-

* attr_accessor
* attr_reader
* attr_writer


Reader, reads the variable but has no ability to rewrite the variable so it can't be changed.

Writer, as guess it writes the variable so it can rewritten and such.

Accessor, this has the functions of both Reader and Writer...thats why you see most scripts using instance variables using Accessors, as they can be read and changed.
 

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