- Joined
- Jun 21, 2015
- Messages
- 1,441
- Reaction score
- 680
- First Language
- Polish
- Primarily Uses
- Other
Hello everybody!
Currently I'm designing HUD, that will display characters' HP and MP on map screen and I'd like to ask a question.
What I was about to do, is to create sprites directly in Scene_Map ~ their variables and such all in that scene.
However, I think that's not the smartest solution, as it will get kinda messy later, right?
For example making a sprite for each character, where each sprite will have their own values based on characters' statuses ~ and each bars will have multiple layers like base and fill~ and all of this - directly in Scene_Map.
It itself isn't an issue, but it may bring some problems later, so I'd have to use pretty long names, to make sure, that I'll not bump into them when working on different things.
So I was thinking, if making a class to handle that would be better.
But now there's a question - can I make a sprite class with multiple graphics? When I'll set the bitmap to bar's base, how can I add the fill part?
creating variable with the graphics and using contents.blt method or whatever works there?
How should I go about this to not kill the performance?
Another solution would be making a window class, where I could perform such an action, but I'd like to avoid using windows as they simply have totally unnecessary features, that I don't need there, so that would be just a free performance loss. And redrawing stuff is painful. I'd simply like to operate with multiple graphics, like moving&resizing 'fill' layer on the base one etc.
EXAMPLE:
For example if I'd be doing that in window class then:
I'm making one window class - generally a window where I'll draw stuff.
Now I'm making a variable for base and throwing graphics to it for example:
base = Cache.abc("base")
rect = Rect.new(0,0,base.width,base.height)
contents.blt(100,100,base,rect,255)
and doing the same with the 'fill' image~ where it's size is determined by let's say HP.
Now I could redraw that part in the window to resize the fill when the HP will change.
Since it's not the best solution I think ~ I'd like to use sprite class instead.
For example create a sprite class.
As a self.bitmap put the base.
Then create a variable with 'fill' part and set its position and size dependable on let's say HP.
Then simply resize the sprite/bitmap without having to redraw it like it would happen in window class.
A quick example of what I'm trying to do:
In scene, I'm creating a base of the bar:
@bar = Sprite.new
@bar.bitmap = Cache.hud("bar")
@bar.x = 50
now fill part on it
@fill = Sprite.new
@fill.bitmap = Cache.hud("fill")
@fill.x = 52
width = hp/mhp * 100
@fill.src_rect.set(0, 0, width, 16)
and then change width and update src_rect.
It all would work, but the thing is, there's much more stuff than this and updating that in the Scene_Map update method will be pretty messy, so that's why I was thinking of moving that all to a new class and in the Scene_Map just create sprites and update them with a single line, where it all would be handled further individually by each sprite from their update method specified in class.
I was thinking of making a class, that would handle the whole bar, then just create it multiple times in the map scene for each character.
The solution is probably pretty obvious, but it's been awhile since I was scripting stuff, plus I haven't slept for 39 hours now (at the time it was posted), so please mind potential lack of logic in this post.
I kinda got stuck with this. =P
I hope I covered everything. =P
Now excuse me, I'm going to sleep. x3
Thank you! x3
Currently I'm designing HUD, that will display characters' HP and MP on map screen and I'd like to ask a question.
What I was about to do, is to create sprites directly in Scene_Map ~ their variables and such all in that scene.
However, I think that's not the smartest solution, as it will get kinda messy later, right?
For example making a sprite for each character, where each sprite will have their own values based on characters' statuses ~ and each bars will have multiple layers like base and fill~ and all of this - directly in Scene_Map.
It itself isn't an issue, but it may bring some problems later, so I'd have to use pretty long names, to make sure, that I'll not bump into them when working on different things.
So I was thinking, if making a class to handle that would be better.
But now there's a question - can I make a sprite class with multiple graphics? When I'll set the bitmap to bar's base, how can I add the fill part?
creating variable with the graphics and using contents.blt method or whatever works there?
How should I go about this to not kill the performance?
Another solution would be making a window class, where I could perform such an action, but I'd like to avoid using windows as they simply have totally unnecessary features, that I don't need there, so that would be just a free performance loss. And redrawing stuff is painful. I'd simply like to operate with multiple graphics, like moving&resizing 'fill' layer on the base one etc.
EXAMPLE:
For example if I'd be doing that in window class then:
I'm making one window class - generally a window where I'll draw stuff.
Now I'm making a variable for base and throwing graphics to it for example:
base = Cache.abc("base")
rect = Rect.new(0,0,base.width,base.height)
contents.blt(100,100,base,rect,255)
and doing the same with the 'fill' image~ where it's size is determined by let's say HP.
Now I could redraw that part in the window to resize the fill when the HP will change.
Since it's not the best solution I think ~ I'd like to use sprite class instead.
For example create a sprite class.
As a self.bitmap put the base.
Then create a variable with 'fill' part and set its position and size dependable on let's say HP.
Then simply resize the sprite/bitmap without having to redraw it like it would happen in window class.
A quick example of what I'm trying to do:
In scene, I'm creating a base of the bar:
@bar = Sprite.new
@bar.bitmap = Cache.hud("bar")
@bar.x = 50
now fill part on it
@fill = Sprite.new
@fill.bitmap = Cache.hud("fill")
@fill.x = 52
width = hp/mhp * 100
@fill.src_rect.set(0, 0, width, 16)
and then change width and update src_rect.
It all would work, but the thing is, there's much more stuff than this and updating that in the Scene_Map update method will be pretty messy, so that's why I was thinking of moving that all to a new class and in the Scene_Map just create sprites and update them with a single line, where it all would be handled further individually by each sprite from their update method specified in class.
I was thinking of making a class, that would handle the whole bar, then just create it multiple times in the map scene for each character.
The solution is probably pretty obvious, but it's been awhile since I was scripting stuff, plus I haven't slept for 39 hours now (at the time it was posted), so please mind potential lack of logic in this post.
I kinda got stuck with this. =P
I hope I covered everything. =P
Now excuse me, I'm going to sleep. x3
Thank you! x3
Last edited by a moderator:

