I have a concern about Images to use instead of Sprite / Bitmap Gradient Fill. This is my gradient fill based hud script:
class Milena_Sprite < Window_Base # ---------------------------------------------------------- # Initialize # ---------------------------------------------------------- def initialize super(0,0,250,150) self.contents = Bitmap.new(200,100) self.opacity = 0 update end # ---------------------------------------------------------- # Update # ---------------------------------------------------------- def update milena_amount = 100 self.contents.clear self.contents.gradient_fill_rect(41,20,milena_amount,30,Color.new(200,100,255),Color.new(150,0,255)) endendAs you can see, if we call it as:
@hud_cont = Milena_Sprite.newBut instead of gradient fill, I want to use an image. How can you do this in the simplest form possible?
@hud_cont.bitmap = Bitmap.new(Graphics.width,Graphics.height)bit = Cache.pictures(filename) #assuming it's on the pictures folder#use the correct Cache.xxx call for wherever the image is@hud_cont.bitmap.blt(dest_x,dest_y,bit,Rect.new(0,0,bit.width,bit.height)#Assumption here is that we're gonna use the whole image and paste it in the same size#if you want to paste the whole image on another size@hud_cont.bitmap.stretch_blt(Rect.new(dest_x,dest_y,width,height),bit,Rect.new(0,0,bit.width,bit.height)#if you want only a part of the image, just modify the values on the Rect.new after bit,you could also just do@hud_cont.bitmap = Bitmap.new(full file path)I would use the first two if I'm gonna put more than 1 image in the sprite, if not, the 2nd will be a much simpler way to do it.If you want more info, just go to the help file and read on the Bitmap topic... It's all in there. I personally do hope people would start reading the Help file, coz it can save a lot of time.
Alternatively, you could use src_rect in Sprite.
Set the bitmap image to your sprite, modify its size by modifying the src_rect.
This is the problem I encountered with stretch, it stretches the image! It should not stretch it depending on my tp but it should half or decrease itself like any other hud there. My hud isn't that good anymore. I will have to try src_rect.
You should use percent TP if you want it to be full size at 100% TP and smaller at smaller TP...
so like
#let's say max tp is 100rate = object.tp / [email hidden](0,0,bit,Rect.new(0,0,bit.width*rate,bit.height)This way, it will be at full size if you have max TP and be shorter if you have less TP. You would be doing the same if you go with the src_rect path... you'd still use the rate to get the correct width.
You could also do the same with stretch_blt depending on what effect you think is better. But normally, yeah you would just use blt for this.
He PMed me about src_rect, and seems his problem is already solved
Another thing I wish, for people to post if they've already PM'd someone and got it solved and mark the thread as solved... XD
And that they post the answer, for the benefit of other people who might have this same problem. 🙂
PS: If there's going to be multiple bars at the same time, I do suggest using 1 sprite for all of them rather than 1 sprite per bar, as having multiple sprites have a lot more impact on performance...