So i've spend the night on this, but can't seem to solve the problem. I have an imagemap screen with multiple hotspots (an "explorable" location), which i show on a layer with a parallax effect applied to it. The code is this:
Code: Select all
init python:
class MouseParallax(renpy.Displayable):
def __init__(self,layer_info):
super(renpy.Displayable,self).__init__()
self.xoffset,self.yoffset=0.0,0.0
self.sort_layer=sorted(layer_info,reverse=True)
cflayer=[]
masteryet=False
for m,n in self.sort_layer:
if(not masteryet)and(m<0):
cflayer.append("master")
masteryet=True
cflayer.append(n)
if not masteryet:
cflayer.append("master")
cflayer.extend(["transient","screens","overlay"])
config.layers=cflayer
config.overlay_functions.append(self.overlay)
return
def render(self,width,height,st,at):
return renpy.Render(width,height)
def parallax(self,m):
func = renpy.curry(trans)(disp=self, m=m)
return Transform(function=func)
def trans(d,st,at):
d.xoffset,d.yoffset=(int)(m*self.xoffset),(int)(m*self.yoffset)
return 0
def overlay(self):
ui.add(self)
for m,n in self.sort_layer:
renpy.layer_at_list([self.parallax(m)],n)
return
def event(self,ev,x,y,st):
import pygame
if ev.type==pygame.MOUSEMOTION:
self.xoffset,self.yoffset=((float)(x)/(config.screen_width))-0.5,((float)(y)/(config.screen_height))-0.5
return
MouseParallax([(-50,"l4"),(-100,"l3"),(-150,"l2"),(-200,"l1")])
def trans(d, st, at, disp=None, m=None):
d.xoffset, d.yoffset = int(round(m*disp.xoffset)), int(round(m*disp.yoffset))
return 0
Is there a better way to do this? since this code is a written class, did anyone tried writing something similar for button focus? ButtonParallax?.. Really at a loss here.
The goal is to move the screen accordingly with the hotpot in focus.
Thank you in advance!