- May 10, 2023
- 76
- 84
Hello!
I'm working on a freeroam and I'm kinda stuck for hours now with absolutely no idea how I would be able to solve it. I would like to achieve a flashlight freeroam where some objects are hidden by the black area of the flashlight. Unfortunately all the imagebuttons are completely ignoring my dark overlay... (It's fine for the arrows as their idle state are just blank images but other hovers like the door is just not pretty as its "glowing" in the dark
)
I have the following code from Lemmasoft forums:
This is how I have my imagebuttons are setup + how i call the screens into the freeroam section:
Thanks in advance if anyone decides to help me out.
I'm working on a freeroam and I'm kinda stuck for hours now with absolutely no idea how I would be able to solve it. I would like to achieve a flashlight freeroam where some objects are hidden by the black area of the flashlight. Unfortunately all the imagebuttons are completely ignoring my dark overlay... (It's fine for the arrows as their idle state are just blank images but other hovers like the door is just not pretty as its "glowing" in the dark
I have the following code from Lemmasoft forums:
Code:
screen flashlight_screen:
modal False tag flashlight_screen
add Flashlight()
init python:
class Flashlight(renpy.Displayable):
def __init__(self):
super(Flashlight, self).__init__()
# This image should be twice the width and twice the height
# of the screen.
self.child = Image("others/flashlight_cursor.png")
# (-1, -1) is the way the event system represents
# "outside the game window".
self.pos = (-1, -1)
def render(self, width, height, st, at):
render = renpy.Render(config.screen_width, config.screen_height)
if self.pos == (-1, -1):
# If we don't know where the cursor is, render pure black.
render.canvas().rect("#000", (0, 0, config.screen_width, config.screen_height))
return render
# Render the flashlight image.
child_render = renpy.render(self.child, width, height, st, at)
# Draw the image centered on the cursor.
flashlight_width, flashlight_height = child_render.get_size()
x, y = self.pos
x -= flashlight_width / 2
y -= flashlight_height / 2
render.blit(child_render, (x, y))
return render
def event(self, ev, x, y, st):
# Re-render if the position changed.
if self.pos != (x, y):
renpy.redraw(self, 0)
# Update stored position
self.pos = (x, y)
def visit(self):
return [ self.child ]
Code:
screen so_wc:
imagebutton:
xalign 0.0
yalign 1.0
idle "others/arrow_idlev.png"
hover "others/arrowd_hover.png"
action Jump("o_wcback")
imagebutton:
xalign 0.0
yalign 0.0
auto "Fshome/Fshome10_%s.png"
focus_mask True
action Play("sound", "audio/sfx/door_open.mp3"), Jump("o_wcoutside")
label o_wc:
scene foffice54 with Dissolve(.1)
show screen flashlight_screen
call screen so_wc