TRIHAN'S PROFILE
Search
Filter
Slip into Ruby part 3: Making a Scene continued.
No worries about the questions! I'm here to help. :)
You are correct; the fourth argument is the rectangular portion of the source image that will be block transferred.
Basically what I'm doing, if the full image doesn't fit, is taking half the difference between the full image width and available destination width as the x, and half the difference between the full image height and available destination height as the y, and then slicing out a portion of the image that fits in the space available for it.
So say I have a 150x150 window for the enemies, and my graphic is 204x280.
The x will be (204 - 150) / 2, or 27. The y will be (280 - 150) / 2, or 65. So the source rect will be (27, 65, 150, 150) which should end up taking roughly the centre 150x150 "square" of the image.
There is a stretch_blt method which makes the image scale to fit the destination.
You are correct; the fourth argument is the rectangular portion of the source image that will be block transferred.
Basically what I'm doing, if the full image doesn't fit, is taking half the difference between the full image width and available destination width as the x, and half the difference between the full image height and available destination height as the y, and then slicing out a portion of the image that fits in the space available for it.
So say I have a 150x150 window for the enemies, and my graphic is 204x280.
The x will be (204 - 150) / 2, or 27. The y will be (280 - 150) / 2, or 65. So the source rect will be (27, 65, 150, 150) which should end up taking roughly the centre 150x150 "square" of the image.
There is a stretch_blt method which makes the image scale to fit the destination.
Slip into Ruby part 2 - Making a Scene
author=fishure
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 writedata = []
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?
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.
Slip into Ruby part 2 - Making a Scene
Slip into Ruby part 2 - Making a Scene
[Poll] I HATE THE ADMINS
[MAFIA] Is this Werewolf?
It was a really fun game, I can't believe how close it got at the end.
And I'm really sorry for winning a game that by all rights my incompetent and sloppy plays should have lost me several times over. XD
And I'm really sorry for winning a game that by all rights my incompetent and sloppy plays should have lost me several times over. XD
[MAFIA] Is this Werewolf?
[MAFIA] Is this Werewolf?
Rachel, I actually felt really bad about convincing you I was innocent to the point where I was tempted to admit I was a wolf so that town would win.