RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RMVXA] Create_Background

0 Members and 1 Guest are viewing this topic.

*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Zero to Hero2013 Biggest Drama WhoreParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
Hello, it's me again.   ._.

This time, I want to screw up mess with the drawing of the menu background.
 
Code: [Select]
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end

So, I'm most likely completely wrong... but this is what I think it's doing.
background_sprite = sprite.new
I see this a lot, the whole X.new. Not sure what it does. >_>

The part where it says~
@background_sprite.bitmap = SceneManager.background_bitmap
That's pulling the image SceneManager.background_bitmap from somewhere, and setting it as background_sprite... right? (I think I have that backwards.)

(Sorry scripters, mak'n u faceplam and junk.)

TS;DB
Is there a way for me to substitute "Scenemanager.background_bitmap" for another image?

WWTP?
I was hoping that even with my complete lack of scripting knowledge, I could understand enough to poke it until it did what I wanted it to.


&&&&&&&&&&&&&&&&

*
*crack*
Rep:
Level 64
2012 Most Unsung Member2012 Best NewbieFor frequently finding and reporting spam and spam bots
change
Code: [Select]
@background_sprite.bitmap = SceneManager.background_bitmap

to
Code: [Select]
@background_sprite.bitmap = Cache.picture("Filename")

replace the filename with a picture filename located in your games picture folder.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
So, I'm most likely completely wrong... but this is what I think it's doing.
background_sprite = sprite.new
I see this a lot, the whole X.new. Not sure what it does. >_>
X.new creates a new object of the class X, and runs the initialise method on that object. This line here sets the variable background_sprite to be a new object of the Sprite class.
The part where it says~
@background_sprite.bitmap = SceneManager.background_bitmap
That's pulling the image SceneManager.background_bitmap from somewhere, and setting it as background_sprite... right? (I think I have that backwards.)
That is setting the bitmap property of the instance variable @background_sprite to the background_bitmap method of the SceneManager module.

That's all I can tell you for now, unfortunately, as I don't have VXA on this computer, because it can't run VXA, because it's a MacBook. And I can't be bothered using Boot Camp and installing VXA right now.
it's like a metaphor or something i don't know

*
Rep:
Level 82
X.new creates a new object of the class X, and runs the initialize method on that object. This line here sets the variable background_sprite to be a new object of the Sprite class.

Remember your American-English, Ms.

Just to note, there doesn't need to be an 'initialize' method defined in a class. If there is such a method, however, that's probably the first thing to be called.

@Boe (+anyone else who cares)
Check this article out here: http://www.rubyist.net/~slagell/ruby/objinitialization.html

It tells you a little about object initialization following the use of X.new.

Quote
That is setting the bitmap property of the instance variable @background_sprite to the background_bitmap method of the SceneManager module.

That's all I can tell you for now, unfortunately, as I don't have VXA on this computer, because it can't run VXA, because it's a MacBook. And I can't be bothered using Boot Camp and installing VXA right now.

This is why I find it hard to move away from Windows. At least I know things work with Windows.

As a little extra, here's a thing to keep in mind. Using your code snippet as an example:

Code: [Select]
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end

Specifically with the line:

Code: [Select]
@background_sprite.bitmap = SceneManager.background_bitmap

SceneManager, as you will notice if you look at the list on the left in the editor, is a script. When it comes to the default editor (with no added custom scripts involved) the names of the scripts share the name with the classes/modules that are written in that script. The 'SceneManager' script contains the module, SceneManager, which as you can see from the code is being directly referred to in the code 'SceneManager.background_bitmap'. What you can do, is look at the script and try to find a method called 'background_bitmap'.

Code: [Select]
  def self.background_bitmap
    @background_bitmap
  end

This is that method. You will notice the 'self' part prefixing the method name, but I wouldn't concern yourself with that just yet - you can expand your knowledge into the self part of a class or module later. For now, just know that SceneManager.background_bitmap is calling that method there.

This method does one thing only. It returns the variable, @background_bitmap. It's not necessary to use the return keyword in certain situations. Basically, the last statement, or line, in a method will return the result of that statement on its own, without any direction from the programmer. It just does that for some reason. It took me a while to get used to it, because I come from other languages where the return is needed to return some object or value.

In this particular example, whatever @background_bitmap refers to will be handed back to the method that called SceneManager.background_bitmap. If you change that variable, you can change what background bitmap is handed back.

Code: [Select]
@background_sprite.bitmap = SceneManager.background_bitmap

In this line, then, the bitmap that is held in the @background_bitmap variable in SceneManager is being assigned to the bitmap of @background_sprite. So if @background_bitmap in SceneManager is "CloudyFields", following this line of code above, @background_sprite.bitmap is now also "CloudyFields".

Hopefully that helps a little. I know that my explanations tend to get a little winded and can be a bit confusing straight away.

WWTP?
I was hoping that even with my complete lack of scripting knowledge, I could understand enough to poke it until it did what I wanted it to.

This is how I learned how to use Ruby. Just have patience, do some research and ask questions. Keep poking and eventually you will get there.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Zero to Hero2013 Biggest Drama WhoreParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
You're all awesome. ^_^

After reading what you said Logan, am I right in thinking that just changing the background like this

Code: [Select]
@background_sprite.bitmap = Cache.picture("Filename")

would only change it in the main menu. When you opened "Items" (or something) the background would be the default again, because it's using

Code: [Select]
'SceneManager'
def self.background_bitmap
    @background_bitmap
  end

so if I want the backgrounds in all the menus to change, can I just replace scenemanger's "@background_bitmap" to "@background_sprite.bitmap = Cache.picture("Filename")"?

Well, I'm going to go try that.
Again, thank you all. :3

EDIT:
I went into the scenemanager and switched it out for D&P3's code snippert... and it gave me an error. I saw that it was crying about a "Nilclass" for the method "Bitmap", so I erased the part about bitmaps, and was left with
 
Code: [Select]
  def self.background_bitmap
    @background_sprite = Cache.picture("menubackpic")
  end
end

And now it works. ^_^
Spoiler for:

Next, I'm going to make it so I can change the background at different parts of the game. It about planet hopping, so I'm going to make the planet change. I think I know enough to do this.  ^_^'

I don't know if getting rid of the "Bitmap" will cause problems down the road, but I'll burn cross that bridge when I get to it.

EDITEDIT:

 So, now I see why I would want to use a different image for each sub menu. It doesn't really work with the same image. ;___;
Spoiler for:
« Last Edit: March 14, 2013, 08:10:37 PM by Boe »
&&&&&&&&&&&&&&&&

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
X.new creates a new object of the class X, and runs the initialize method on that object. This line here sets the variable background_sprite to be a new object of the Sprite class.

Remember your American-English, Ms.
My brain must be trying to make me forget that there was ever a time in my life when I was forced to write 'initialise' with a 'z'.
it's like a metaphor or something i don't know