New account registration is temporarily disabled.

FISHURE'S PROFILE

Search

Filter

Slip into Ruby part 3: Making a Scene continued.

Hey, I was confused about the case where the enemy image is larger than the window. You write

if fits
dummy_bmp.blt(dest_rect.x, dest_rect.y, bmp, bmp.rect)
else
src_rect = Rect.new((bmp.rect.width - dest_rect.width) / 2,
(bmp.rect.height - dest_rect.height) / 2, dest_rect.width, dest_rect.height)
dummy_bmp.blt(dest_rect.x, dest_rect.y, bmp, src_rect)
end

From this, I understand that you call the blt method on dummy_bmp, which fits a certain section of the source bmp, (3rd argument) into dummy_bmp (which in this case is an empty bitmap spanning the window). The 1st and 2nd argument determine where in the dummy_bmp the source will be printed into. I am confused about what the fourth arguemnt determines. Is it a Rect object that determines what cropped portion of the bmp is transferred onto dummy_bmp or something like that? Could you please explain it, thanks. Also, I don't understand the calculation for x and y of src_rect if the bmp doesn't fit, so I would appreciate if you explained it in a bit more depth. I was able to visualise the centering calculation earlier for dest_rect.x and dest_rect.y but not this one. And finally, does this code mean there will be a cropped version of larger enemies such as Demon Lord, or is it resized. If its resized does it maintain its aspect ratio?
Sorry for all the question, I don't have access to RPGM to mess around with this stuff.

Slip into Ruby part 2 - Making a Scene

author=Trihan
1. Oh goodness you're absolutely right, it should be @data or self.data.

2. As a property, they're pretty much interchangeable. I didn't have any particular reason for using one over the other. self. can also call methods though, which instance variables obviously can't.

SceneManager's call method creates an instance of the destination scene as part of its implementation, so that part is taken care of for you. This will include calls to the initialize and start methods, which you can see by looking at Scene_Base.

Yes, refresh is only called once when objects are created because it's only called from the constructors. If you wanted it to run every frame, you'd put it in update instead.

Thank you, that cleared things up.

Slip into Ruby part 2 - Making a Scene

Hey, I've just started learning Ruby, and, inspired by RPGM games, I've decided to have a go at learning RGSS while I'm at it using your guide. I'm just confused about some things.
In the constructor for Window_EnemyList, you write
data = []
self.index = 0
1. Should data be @data or self.data, since its not used in the constructor? If not, how come?
2. What actually is the difference between saying @index and self.index, and why do you opt for self.index here, and @data when referring to the data later?
Also, the Scene Manager calls a class rather than creating a new instance of the class, so there's no initialize happening or anything, how does that work? Does it run 'start' instead?
And one more thing, which is more related to me not knowing a thing about RGSS. 'refresh' only occurs once, when you open up the scene right?
Pages: 1