Imagebutton appears before animation

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
kl7
Newbie
Posts: 13
Joined: Wed Jul 13, 2016 11:39 am
Contact:

Imagebutton appears before animation

#1 Post by kl7 »

Hi, everyone! Need help with imagebuttons.

I have two imagebuttons in one screen and I want my second button to appear with delay 1sec, with scaling from 0 to 0.5 and with alpha from 0 to 1.

The problem is that - the second imagebutton (which is with delay) appears before animation starts, and it's clickable.

I know that i can create two screens for each button and add pause between them, but the question - is it possible with one screen?

Sorry for my english)

My code:

Code: Select all

transform anim_01:
    parallel:
        zoom 0.0
        linear 0.25 zoom 0.6
    parallel:
        zoom 0.6
        linear 0.1 zoom 0.5

transform anim_02:
    pause 1
    parallel:
        zoom 0.0
        linear 0.25 zoom 0.6
    parallel:
        zoom 0.6
        linear 0.1 zoom 0.5


screen my_buttons:
    
    imagebutton xanchor 1.0 yanchor 1.0 xpos 300 ypos 200 at anim_01:
        focus_mask True
        idle "images/button01_idle.png"
        hover "images/button01_hover.png"
        action Jump("label01")
   
    imagebutton xanchor 1.0 yanchor 1.0 xpos 300 ypos 200 at anim_02:
        focus_mask True
        idle "images/button02_idle.png"
        hover "images/button02_hover.png"
        action Jump("label02")

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Imagebutton appears before animation

#2 Post by Ocelot »

Set zoom and alpha to 0 before pause:

Code: Select all

transform anim_02:
    zoom 0.0
    alpha 0.0
    pause 1
    parallel:
        linear 0.25 zoom 0.5
    parallel:
        linear 0.1 alpha 1.0
< < insert Rick Cook quote here > >

kl7
Newbie
Posts: 13
Joined: Wed Jul 13, 2016 11:39 am
Contact:

Re: Imagebutton appears before animation

#3 Post by kl7 »

Ocelot,

it helps to hide this imagebutton, but it is still clickable before animation starts.

UPD
i send the code where positions of the buttons are same, which is mistake. In my original code positions of buttons are different, so the problem is not solved.

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: Imagebutton appears before animation

#4 Post by jw2pfd »

It's possible to prevent the user from clicking it for a set amount of time. I would try it this way although there may be an easier way. In your main code, you can add a variable just before you call the screen.

Code: Select all

    $ loaded = False

    # whatever code you have for your call screen
Then you can add a timer on your screen as well as change the buttons actions like this:

Code: Select all

screen my_buttons:
   
    imagebutton xanchor 1.0 yanchor 1.0 xpos 300 ypos 200 at anim_01:
        focus_mask True
        idle "images/button01_idle.png"
        hover "images/button01_hover.png"
        action If(loaded, "label01")    #<--- change the action here
   
    imagebutton xanchor 1.0 yanchor 1.0 xpos 300 ypos 200 at anim_02:
        focus_mask True
        idle "images/button02_idle.png"
        hover "images/button02_hover.png"
        action If(loaded, "label02")     #<--- change the action here

    timer 1.6 action SetVariable("loaded", True)  #you can change the 1.6 to whatever time value you need to fit the duration of the animation

kl7
Newbie
Posts: 13
Joined: Wed Jul 13, 2016 11:39 am
Contact:

Re: Imagebutton appears before animation

#5 Post by kl7 »

jw2pfd,

It works perfect. Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users