I'm trying to do few things on screen that will depend on mouse position (eg. set position of elements or show text with cursor position).. I've got many different approaches, but currently I'm using one with adding mouse position checker as displayable on screen:
Code: Select all
class getMousePosition(renpy.Displayable):
x = 0
y = 0
def __init__(self):
renpy.Displayable.__init__(self)
def event(self, ev, x, y, st):
import pygame
if ev.type == pygame.MOUSEMOTION: # Updates the position of the mouse every time the player moves it
print self.x
self.x = x
self.y = y
renpy.restart_interaction()
def render(self, width, height, st, at):
return renpy.Render(1, 1)
mousePosition = getMousePosition()
Code: Select all
$ ui.add(mousePosition)
Code: Select all
$ renpy.music.play("xxx.mp3", channel="music", loop=True, fadeout=2.0, fadein=4.0, relative_volume=0.4)
Has anyone idea how to actually make it work or maybe different approach will make it happen?