Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Simple Window Opacity Help

This should be fairly simple so i'll be quick.
I'm working on a HUD for my game that uses windows with full opacity. However, whenever the player walks behind the HUD, I want the HUD to become transparent.
I already know how to make the opacity change (window.opacity = 150). What I'm asking is how do I check whether the player is walking into the HUD or not so that I can trigger the opacity change.

Here's a picture of what I mean...
http://i61.photobucket.com/albums/h72/R ... /helpo.jpg[/img]


Here's the script... (which does nothing right now besides draw a window)
Code:
class Game_Map
attr_reader :map_minimap
  
alias map_minimap_setup setup

end

class Scene_Map

alias map_minimap_main main
alias map_minimap_update update
  
def main
#@spriteset_map = Spriteset_Map.new
@message_window = Window_Message.new
# Add name of map to window
@minimap_window = Window_Minimap.new
@minimap_window.opacity = 255
@minimap_window.x = 490
@minimap_window.y = 330
map_minimap_main
@minimap_window.dispose
end

def update
  @minimap_window.update
  map_minimap_update
end

end

class Window_Minimap < Window_Base

def initialize
super(0, 0, 150, 150)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end


def refresh
self.contents.clear
end

def update
super
refresh
end

end

Any help would be quite appreciated.
Thanks in advance.
 
Well, screen_x and screen_y retrieve a Game_Character object's position.

So, just check $game_player.screen_x and $game_player.screen_y and when ever he is in the vicinity, just lower the opacity. You would probably want to perform the check when the player moves - there might be a more clever way to do it but that is my first impression of the problem
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top