How do I give imagebuttons an animation after being clicked?

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
LyraCentauri
Newbie
Posts: 10
Joined: Fri Mar 26, 2021 5:50 pm
Contact:

How do I give imagebuttons an animation after being clicked?

#1 Post by LyraCentauri »

Hello! I am still in the process of making my first dating sim game, and I'm almost done! But I want to spruce up some parts of the minigame.

This is a QTE minigame where the player clicks the targets (which are imagebuttons) and everytime they click, the button adds a point and randomizes a new location. Is there any way to make it so that after each click, the imagebutton plays a small/short animation (for example the target exploding) before it disappears and goes to a new location?

Code: Select all

screen target_scr(tgt_align, t):

    # animated timer
    bar value AnimatedValue(0, t, t, t) bar_invert True xsize 300 align (0.95, 0.05)

    imagebutton:
        auto "target_%s.png"
        action [Hide("target_scr"), Return(1)] # hide the screen by its name
        align tgt_align
        sensitive not game_over # clickable if game is not over

    if not game_over:
        timer t action [Jump("too_slow")]

label minigame(targets_number, game_time):

    label try_again: # place to jump to for a game replay
        pass

    $ targets_left = targets_number # set the game length

    show qte scoreboard
    show screen minigame_scr

    while targets_left > 0: # show targets while we have them
        show screen target_scr(tgt_align=( renpy.random.randint(2, 8)*0.1, renpy.random.randint(2, 8)*0.1 ), t=game_time)
        $ ui.interact() # waits for player interaction
        $ score += 1
        $ targets_left -= 1

Post Reply

Who is online

Users browsing this forum: No registered users