Running a transform on click? - Solved

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
User avatar
Springroll Games
Newbie
Posts: 13
Joined: Fri Mar 17, 2017 3:49 pm
Contact:

Running a transform on click? - Solved

#1 Post by Springroll Games » Sun Dec 31, 2017 6:09 pm

I want to have a button rotate when it's clicked.

Is there any way to run a transform when a button is clicked, or is the best way to show and hide the buttons so they can have on show/hide transforms?

Thank you.
Last edited by Springroll Games on Sun Dec 31, 2017 7:56 pm, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Running a transform on click?

#2 Post by trooper6 » Sun Dec 31, 2017 7:22 pm

Code: Select all

default degs = 0

init python:
    def make_rotate():
        global degs
        degs += 40

transform rotary(degrees=0):
    subpixel True
    linear 1.0 rotate degrees

screen button_test():
    textbutton _("Push Me") action Function(make_rotate) at rotary(degs)

label start:
    show screen button_test()
    "This is a tester showing how to have a button that rotates when clicked."
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Springroll Games
Newbie
Posts: 13
Joined: Fri Mar 17, 2017 3:49 pm
Contact:

Re: Running a transform on click?

#3 Post by Springroll Games » Sun Dec 31, 2017 7:55 pm

Wow, thank you so much! This is perfect. I would never have thought of that, but it makes so much sense!

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Running a transform on click? - Solved

#4 Post by trooper6 » Sun Dec 31, 2017 8:15 pm

Hm...you know what? Here is a shorter version of the code that cuts out the function and just updates the degrees directly:

Code: Select all

default degs = 0

transform rotary(degrees=0):
    subpixel True
    linear 1.0 rotate degrees

screen button_test():
    textbutton _("Push Me") action SetVariable("degs", degs + 40) at rotary(degs)

label start:
    show screen button_test()
    "This is a tester showing how to have a button that rotates when clicked."
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Springroll Games
Newbie
Posts: 13
Joined: Fri Mar 17, 2017 3:49 pm
Contact:

Re: Running a transform on click? - Solved

#5 Post by Springroll Games » Mon Jan 01, 2018 9:16 am

Sweet. I never quite know how Renpy's actions really work ^^; Thanks again!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot