How would I go about making a .png image (with transparency) display on top of my games screen without it being fog? (edit) And also be able to make it go over menus
Overlaying Image
RPG Maker XP Supportyou can either use an event command show picture (which has several big limitations) or you'll need an overlay script for this.
Do you know of any existing overlay scripts for rmxp?
Okay, so we're not talking a simple HUD that appears ONLY when the field map is visible, but when EVERYTHING is visible. I think you are trying for some old-school effect with a frilly or entertaining border effect throughout your game.
Um, for clarification, I take it that this overlay will likely NOT affect or be visible in the Title Screen. HOWEVER, I do have something.
Code:
#==============================================================================
# ** Scene_Overlay
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Overlay
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@overlay_bk = Sprite.new
@overlay_bk.z = 9999
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
defupdate
# DO NOTHING unless a scene change
return unless @old_scene != $scene
# Snag the graphics from the Windowskin folder
@overlay_bk.bitmap = RPG::Cache.windowskin("FRED")
# Set that the scene changed, store in temp value
@old_scene = $scene
# IF the current scene is 'Scene_Title'
if $scene.is_a?(Scene_Title)
# Hide the overlay
@overlay_bk.visible = false
else
# Otherwise, show the overlay
@overlay_bk.visible = true
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
@overlay_bk.dispose
end
end
It looks simple, does it not? But it will not work without tying it into your project.
You are connecting it to EVERY scene in your game, so we need to put it in a system that connects to every menu system, the battlesystem and the field map. The ONE script that does that is... MAIN. Yep, this is something I tend to avoid except. But this is where to add it... and how.
Code:
#==============================================================================
# ** Main
#------------------------------------------------------------------------------
# After defining each class, actual processing begins here.
#==============================================================================
begin
# Prepare for transition
Graphics.freeze
# Make scene object (title screen)
$scene = Scene_Title.new
$over = Scene_Overlay.new # <---- CHAANGE HERE
# Call main method as long as $scene is effective
while $scene != nil
$scene.main
$over.update # <---- CHAANGE HERE
end
$over.dispose # <---- CHAANGE HERE
# Fade out
Graphics.transition(20)
rescue Errno::ENOENT
# Supplement Errno::ENOENT exception
# If unable to open file, display message and end
filename = $!.message.sub("No such file or directory - ", "")
print("Unable to find file #{filename}.")
end
This expects that you have an overlay image of 640x480 in your Windowskin folder, one with a transparent background.
And this has been tested. The overlay does not change in appearance, neither for fog effects or Screen Tone changes. And because I put in a test for the Scene_Title, the overlay does not appear when the Title screen is visible.
😀 Yes, my overlay file is Fred.png
The scripts didn't work for me, I even created a new project and tested it and made an image in GIMP(a bunch of scribbles over a transparent background) instead of using the one i was trying to use for my original project, but I kept getting the error "Script 'overlay' line 40:SytaxError occurred." I named the image fred.png even and kept the script unmeddled with but still the same error(edit) you didnt put a space between def and update on line 18, instead putting, defupdate
😳 How did that space DISAPPEAR? I only copy/pasted after repeat testings!
Original thread: https://forums.rpgmakerweb.com/threads/overlaying-image.112198/