bug(?) with two textbutton hovered renpy.play()

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Xellosz
Newbie
Posts: 1
Joined: Mon Dec 31, 2018 6:36 pm
Contact:

bug(?) with two textbutton hovered renpy.play()

#1 Post by Xellosz »

Hi based on Elaine's https://www.youtube.com/watch?v=SbNNG6RuoY4 I tried to make two changing image with textbuttons. If you hover your mouse over the textbutton the image change and the sound is played, but the problem is that both cat1.mp3 and cat2.mp3 will be played if I hover over any of the textbutton. How could it be changed so only one mp3 will be played?

I'd prefer not to make the player click on the images just hover over it. (if i work with click not hover I probably (99% sure) could do it with jump to a label where I play the sound then call the whole "label catmusic" again, so the same things will be displayed.)

This is the code I'm using now for the testing:

Code: Select all

image bg one:
    "images/cats/mother cat/mothercat.png"
    size(128,72)

image bg two:
    "images/cats/bogyó/bogyo.png"
    size(128,72)

default bg_toggle1 = False

screen bg_swap1:
    if bg_toggle1:
        add "bg one"
    else:
        add "bg two"

    textbutton "SWAP BGS":
        action NullAction()
        hovered [SetVariable("bg_toggle1",True), With(dissolve),  renpy.play("music/cat1.mp3")]
        unhovered [SetVariable("bg_toggle1",False), With(dissolve)]
        xalign 0.5
        yalign 0.5

image one:
    "images/cats/mother cat/mothercat.png"
    size(128,72)
    xalign 0.2
    yalign 0.2

image two:
    "images/cats/bogyó/bogyo.png"
    size(128,72)
    xalign 0.2
    yalign 0.2

default bg_toggle2 = False

screen bg_swap2:
    if bg_toggle2:
        add "two"
    else:
        add "one"

    textbutton "SWAP cat":
        action NullAction()
        hovered [SetVariable("bg_toggle2",True), With(dissolve),  renpy.play("music/cat4.mp3")]
        unhovered [SetVariable("bg_toggle2",False), With(dissolve)]
        xalign 0.3
        yalign 0.5

Post Reply

Who is online

Users browsing this forum: No registered users