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.

IN-Depth Scenes&Windows for you(Includes CMS)

hmm.. since I'm feeling good, I'll give you a quick lesson in why you got that error, rather then just fixing it.

The error type is "nil", this happens because the "object" you are referencing to does not exist. The "object" in this case is the window. You are referencing it by calling ".update" on "@window".

When you create variables, you also have to define them. In this case, you did not define @window ;). Here is what you did wrong:

class Scene_ShowWindow

def main
  MyCustomWindow.new
  Graphics.transition

You called the class, but you didn't assign it to the variable "@window"

Change that bolded line to:

@window = MyCustomWindow.new

and it should work.
 

Ioto

Member

Thank you. it works now. well, showing that window so far does.
I also understand it a bit better now! thanks.
 
I was told that I should not include a method like
  def update
    @window.update
  end
if I was working on a window class script. Is it ok? Or there is no problem with that?
 
hmm.. Do you mean in a scene? or Window_Base related class.

You only need to update your windows in a scene, such as Scene_Title or Scene_Menu ;).
 
Thanks for the start on CMS scripting, Mo. However, I'm left a little confused by the Window_Command section.

What you have is great if all you are wanting to do is modify the base CMS window. However, how would you create an entirely new one, and have it called in a scene WITH the original? (IE, I modify the base menu command window to include a new command. When selected, this new command will shift the focus over to another command window, this one using icons instead of text.) How would the class for the new window be defined, and how would it be called?

Also, would the method you showed for putting bitmaps in the window work for placing the icons in the command window as well?
 
BlueScope":uf70sjpk said:
This reminds me very much on my own window tutorial... I wonder if I got a fan :P
Well, since it's more in-depth than mine (I try to let space for the people to make progress for themselves, you simply explain everything *lol*), most lazy people may like it more... but at least I can be confident and say that my examples are far less cheap than yours ^_^

if I'm correct the idea of a tutorial is to give out the information people are MISSING so they can USE the tool properly and not be stuck there for hours going "Why won't this work??"

Why would you necropost to point this out?  It's not even related to the tutorial.  Please, be more careful next time.
~Guardian
 

dcbd

Member

I'm having a slight problem...

http://img240.imageshack.us/img240/7879/error001ga0.png[/img]

#==============================================================================
# * MyCustomWindow
#==============================================================================

class MyCustomWindow < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def main
    super(100, 100, 200, 200)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    def refresh
    end
  end
  def refresh
  self.contents.clear
  self.contents.font.color = normal_color
  self.contents.font.size = 20
  self.contents.draw_text(100, 100, cx, 40, "Practice")
  end
end
class Scene_ShowWindow
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @window = MyCustomWindow.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
    end
    end
    Graphics.freeze
    @window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @window.update
  end
end

I get this error when i select Items.
Not sure what's wrong, please help.
 

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