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.

Window issues?

Hi!

Does a Window needs to be on a Scene?

This code:
class myWin < Window_Base

def initialize
super(0, 0, 100, 200)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 14
self.contents.draw_text(0, 0, 200, 32, "Empty window")
end
end

makes a window and displays it for a while. But if it is called whitout a Scene does it automatically become a part of the Scene_Map?

Why does it just display for a little while. How do i make it to display until a press a keybord button?
 
This is my opinion:

Make an event and trigger it via ACTION BUTTON if you want to talk to the event before the window appears or use parallel process with Switch precondition to activate it via any other event...

Then, for example, you named your window "class myWin"(uhmm, shouldn't the first letter of the class name ALWAYS be CAPITALIZED?), then you use the CALL SCRIPT event command and type in:

@window = myWin.new(x,y,height,width)

to call it.. Try it and tell if it fails big time... :D
 
altorn said:
This is my opinion:

Make an event and trigger it via ACTION BUTTON if you want to talk to the event before the window appears or use parallel process with Switch precondition to activate it via any other event...

Then, for example, you named your window "class myWin"(uhmm, shouldn't the first letter of the class name ALWAYS be CAPITALIZED?), then you use the CALL SCRIPT event command and type in:

@window = myWin.new(x,y,height,width)

to call it.. Try it and tell if it fails big time... :D

Yes, it fails big time. Becuase the window disappears after a couple of seconds.
 
No, it isn't dangerous if done right.
You could aliasing it to add it to Scene_Map, something like:
Code:
class Scene_Map

alias old_main main

def main
@your_window = Your_Window.new
old_main
@your_window.dispose
end

end
 
Raziel said:
No, it isn't dangerous if done right.
You could aliasing it to add it to Scene_Map, something like:
Code:
class Scene_Map

alias old_main main

def main
@your_window = Your_Window.new
old_main
@your_window.dispose
end

end

Thanx...but can you explain you code a little?

alias old_main main

what does that code do?
 
Alias renames a method to a new name, which can be used to inset new variables into to original method.
Ex:
Code:
def initialize
   print 'bar'
end
alias old_initialize initialize # Renames initialize into old_initialize
def initialize
   print 'foo'
   old_initialize
end
#old_initialize will say bar, and initialize will say foo bar
 
Can I ask some too?

In Window_ class, do I need a refresh method? I don't see that method called anywhere in Scene_ classes, but instead they always do something like this in their update method:

Code:
def update
  @help_window.update
  @my_window.update
  #something else here...
end

When do I need a refresh method within my Window_ class?

And, by the way, if I call @my_window.dispose and somewhere later I decided to have an if @my_window != nil block, why it always gives me a "disposed window" error at that if block? Isn't a disposed window nil? If not, how can I check if a window has already disposed or not?

Thank you.
 

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