Dark Sky 20 Posted September 3, 2016 (edited) Hey guys, is there any way to flip a bitmap horizontally in RGSS3? I know we can use a Sprite to flip it. Edited September 3, 2016 by Dark Sky Share this post Link to post Share on other sites
Rikifive 3,411 Posted September 3, 2016 I have moved this thread to 'Ruby School For Thought' as it's not a script request, but a question related to scripting. (= Yes, you can - just use this: @sprite.mirror = true ~ in the initialization method (of the sprite, that is) or somewhere else to flip the sprite's bitmap horizontally. Example: def create_sprite @sprite = Sprite.new @sprite.bitmap = Cache.system("GRAPHICS YAY!") @sprite.x = 255 @sprite.y = 115 @sprite.mirror = true end 1 Share this post Link to post Share on other sites
Dark Sky 20 Posted September 3, 2016 I have moved this thread to 'Ruby School For Thought' as it's not a script request, but a question related to scripting. (= Yes, you can - just use this: @sprite.mirror = true ~ in the initialization method (of the sprite, that is) or somewhere else to flip the sprite's bitmap horizontally. Example: def create_sprite @sprite = Sprite.new @sprite.bitmap = Cache.system("GRAPHICS YAY!") @sprite.x = 255 @sprite.y = 115 @sprite.mirror = true end Aw thank you for fast replying. But i need a way that we don't have to use Sprite xD Share this post Link to post Share on other sites
Rikifive 3,411 Posted September 3, 2016 Ooh, sorry I've misread ~ now I see, that you clearly stated, that you know about that with sprites, my bad. But now I'm wondering, what exactly are you trying to do? Draw bitmaps in windows? Share this post Link to post Share on other sites
Dark Sky 20 Posted September 3, 2016 Ooh, sorry I've misread ~ now I see, that you clearly stated, that you know about that with sprites, my bad. But now I'm wondering, what exactly are you trying to do? Draw bitmaps in windows? I want a function that we can use to flip a bitmap. So I can use "blt" to transfer it to another bitmap. Sorry, i'm still very bad at English. =) Share this post Link to post Share on other sites
Rikifive 3,411 Posted September 3, 2016 And mirroring there doesn't work? =P Could you show your piece of code where you want to mirror that bitmap? x3 Share this post Link to post Share on other sites
Dark Sky 20 Posted September 3, 2016 And mirroring there doesn't work? =P Could you show your piece of code where you want to mirror that bitmap? x3 It works but i don't want to use too much Sprite cause i have to update all of it for every frame. It causes lag. Yeah. @layer1 = Sprite.new @layer1.bitmap = Bitmap.new(640,480) @temp_bitmap = Cache.system("Graphic") #Need to flip this bitmap @temp_bitmap.flip! #This is the function I want @layer1.bitmap.blt(32*5,32*6,@temp_bitmap,@temp_bitmap.rect) Share this post Link to post Share on other sites
Rikifive 3,411 Posted September 3, 2016 Oh I see the problem now... To be honest that's a nice question.. Now when you brought that up, I'm curious myself. I was trying to look up for information on the web, but no luck. My first guess was to recreate the mirror method from Sprite class in Bitmap class, but I have no idea. Eh... Then sorry, I'm helpless... =/ Share this post Link to post Share on other sites
Kayzee 4,032 Posted September 4, 2016 (edited) You can do this by manipulating the rect to use negative width like this I think: @layer1 = Sprite.new @layer1.bitmap = Bitmap.new(640,480) @temp_bitmap = Cache.system("Graphic") #Need to flip this bitmap x = @temp_bitmap.rect.x+@temp_bitmap.rect.width w = 0-@temp_bitmap.rect fliprect = Rect.new(x, @temp_bitmap.rect.y, w, @temp_bitmap.rect.height) @layer1.bitmap.blt(32*5,32*6,@temp_bitmap,fliprect)I might need to experiment a bit more. Edit: If you want to, I played around with adding mirror (x flip) and flip (y flip) functions to the Rect class. Try this out: class Rect def mirror rect = self.dup rect.x = rect.x+rect.width rect.width = 0-rect.width return rect end def flip rect = self.dup rect.y = rect.y+rect.height rect.height = 0-rect.height return rect end endThen you can just do this: @layer1 = Sprite.new @layer1.bitmap = Bitmap.new(640,480) @temp_bitmap = Cache.system("Graphic") #Need to flip this bitmap @layer1.bitmap.blt(32*5,32*6,@temp_bitmap,@temp_bitmap.rect.mirror) Edited September 4, 2016 by KilloZapit 1 Share this post Link to post Share on other sites
Dark Sky 20 Posted September 4, 2016 Wow, it works really nice. Thank you. I thought we can't use negative width. Share this post Link to post Share on other sites
Kayzee 4,032 Posted September 4, 2016 (edited) Hehe, I wasn't sure until I tried it myself, but I had a feeling it might work, I think I used it before... anyway good luck! *Sprinkles fairy dust on you* Edited September 4, 2016 by KilloZapit Share this post Link to post Share on other sites
Rikifive 3,411 Posted September 4, 2016 Nice~! This thread is closed, due to being solved. If for some reason anybody would like to re-open this thread, just send me a PM or report the thread. (= Share this post Link to post Share on other sites