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.

Show Picture for window background?

Hey, I was just wondering, for my new HUD script...

    How would I show a picture for the background of a window.
    I tried
Code:
self.contents.bitmap =
and
Code:
self.bitmap =
    And I get the error:
    NoMethodError occured.
    undefined method "bitmap="

So how do I do this?
 
You can't alter the width of a bitmap. You can however choose which rect of the bitmap you transfer. Like so:

Code:
bitmap = Bitmap.new(width, height)
other_bitmap = Cache.picture("MyWindowBackground.png")
bitmap.blt(x, y, other_bitmap, Bitmap.new(bx, by, bw, bh))

Ok. So bitmap is your objects actual bitmap. Just choose your width and height here.
other_bitmap is the bitmap you will be transferring from.
x, y are the position on the bitmap you will be transferring.
bx, by, bw, bh is the rect from the other_bitmap you will be transferring from.

I can better explain it with this:
http://www.owainc.net/images/bitmap_blt_visual.PNG[/img]
 
Thank you, I figured I might be able to do something
like that, but I wanted to be sure. Also, the
"self.windowskin =" didn't work, any other ideas?

EDIT: it is giving me an error, wrong number of arguments(4 for 2) in the "blt" method.
 
The 'blt' method has either 4 or 5 arguments. Unless you have less than 4 arguments, it should not return an error.

Also note, that if you're planning on having a single picture wrap the entire window, it shouldn't work with windowskin, as windowskin takes out the small portion to the left in the skin as the window's bitmap. Or at least that's how I understood it anyway.
 
Ok yeah, FireRaven, that's what's happening. Do
you know how to use the entire picture as the
background?
Also, the erroring code on my 'blt' method is:
Code:
    bitmap = Bitmap.new(width,16)
    vis_bitmap = RPG::Cache.picture(filename)
    if var > width
      bw = width
    else
      bw = var
    end
    bitmap.blt(x, y, vis_bitmap, Bitmap.new(x, y, bw, 16))
**var, width, x, y, and filename are for arguments in the method.
 
etheon":3ubvkmkx said:
Code:
self.windowskin = Cache.picture("MyWindowBackground.png")

The windowskin option should work. You just need to paste your image into the window portion of the windowskin (left side). And the command should be:

self.windowskin = RPG::Cache.windowskin("MyWindowSkin.png")

Using the windowskin, the bitmap will stretch to fit the window.


Also, in your first try, you were close.

self.contents  is a bitmap object, so you should have tried...

self.contents = Bitmap.new("Graphics\\Pictures\\MyWindowBackground.png")  

Except, In this case you will have a 16 pixel border around your image, and it won't resize / stretch to fit the window.

Be Well
 
Near":2rblcby1 said:
Ok yeah, FireRaven, that's what's happening. Do
you know how to use the entire picture as the
background?
Also, the erroring code on my 'blt' method is:
Code:
    bitmap = Bitmap.new(width,16)
    vis_bitmap = RPG::Cache.picture(filename)
    if var > width
      bw = width
    else
      bw = var
    end
    bitmap.blt(x, y, vis_bitmap, Bitmap.new(x, y, bw, 16))
**var, width, x, y, and filename are for arguments in the method.
The last parameter is Bitmap.new. Bitmap supports only two arguments. You need to change Bitmap into Rect. So the command goes:
Code:
bitmap.blt(x, y, vis_bitmap, Rect.new(x, y, bw, 16))
 

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