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.

Argument Error

Hello,
Ive looked for hours, well not hours but very long, and couldnt find it. I also asked on IRC but Dissonance kept being annnoying, irritating and spamming, so that wasn't working.
What is an argument error? Here is what I get:

Script 'Scene_Menu' line 5: ArgumentError occured.
wrong number of arguments(1 of 0)

This is line 5:
Code:
super

This is the code around line 5:
Code:
  def initialize(menu_index = 0)
    @menu_index = menu_index
    super
    self.bitmap = Bitmap.new
    self.bitmap.font.name = "Visitor -BRK-"
    self.bitmap.font.size = 7
    update
  end

How the heck can I fix this?
Ty in advance,
~Smiff(Sniff)
 
Ty, you finally had the gutts to help me. Now another error, keep this open as I try to fix it.

EDIT: Keep this open pls, as I have more errors to fix, but thats for tomorrow.
 
Brewmeister":3eqxzawm said:
Shouldn't Bitmap.new have either 1 or 2 arguments?

Bitmap.new(filename) OR
Bitmap.new(width, height)

No, I looked in Sprite_Timer and there it had more then 1, see.
Code:
  def initialize
    super
    self.bitmap = Bitmap.new(88, 48)
    self.bitmap.font.name = "Arial"
    self.bitmap.font.size = 32
    self.x = 640 - self.bitmap.width
    self.y = 0
    self.z = 500
    update
  end

Anyways, I have now another error,
Script 'Scene_Menu' line 6: NoMethodError occured.
undefined method 'bitmap=' for #<Scene_Menu:0x1609b98 @menu_index=0>

Here the code again:
Code:
  def initialize(menu_index = 0)
    @menu_index = menu_index
    super()
    self.bitmap = Bitmap.new(10, 10)
    self.bitmap.font.name = "Visitor -BRK-"
    self.bitmap.font.size = 7
    update
  end

Im pretty sure its something dumb, but I cant figure it out.

EDIT: If your helping me, why not answer this question also, self.bitmap = Bitmap.new(88, 48)
Where does the (88, 48) stand for?
 

Zeriab

Sponsor

Scene_Menu has by default no attr_accessor :bitmap.
Sprite_Timer inherits the two methods for reading and writing to the bitmap attribute from the Sprite class. Hence the reason why you don't see it in the Sprite_Timer class.

I would suggest a design change.
Right now you are treating a scene as if you had a sprite. A scene is not a sprite.
I would suggest you create a Window_Menu class or Sprite_Menu class which inherits from the Window and Sprite class respectively.
The Scene_Menu creates instances of those classes and displays them.

I know it is a big change from what you have now. If you don't want to go through all that yet just use @bitmap instead of self.bitmap.

Btw. you misunderstood Brew.
You can both use Bitmap.new(filename) and Bitmap.new(width, height) for creating a bitmap.
The one you see with two arguments is the second way of creating a bitmap. Bitmap.new(88,48) creates a bitmap which is 88 pixels wide and 48 pixels high. All pixels are fully transparent. (Color.new(0,0,0,0) I think)

*hugs*
- Zeriab
 

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