How to make an "animation" appear on the main menu after clicking a button?

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
LilyValley98
Newbie
Posts: 10
Joined: Sat Jul 24, 2021 3:15 pm
Contact:

How to make an "animation" appear on the main menu after clicking a button?

#1 Post by LilyValley98 »

Can you make an "animation" appear in the main menu by clicking a button in the main menu? It's an animation that appears somewhere on the main menu with two images cycling back and forth. I know how to make this in the script but I don't know how to do this in the main menu itself.
Attachments
explanation.gif
Last edited by LilyValley98 on Sun Aug 08, 2021 11:49 am, edited 1 time in total.
New to Ren'Py with No Thoughts, Head Empty.

User avatar
Träumer
Newbie
Posts: 4
Joined: Fri Jun 11, 2021 2:00 pm
Projects: Hearts and Hexes
Discord: Träumer#5470
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#2 Post by Träumer »

you can make a screen and call it like that: In screens.rpy under screen navigation(where the other menubuttons are); textbutton "Animation" action ShowMenu ("AnimationScreen")

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#3 Post by Alex »

LilyValley98 wrote: Fri Jul 30, 2021 2:14 pm Can you make an "animation" appear in the main menu by clicking a button in the main menu?...
Try it like - https://www.renpy.org/doc/html/screens. ... -statement

User avatar
LilyValley98
Newbie
Posts: 10
Joined: Sat Jul 24, 2021 3:15 pm
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#4 Post by LilyValley98 »

Träumer wrote: Fri Jul 30, 2021 3:44 pm you can make a screen and call it like that: In screens.rpy under screen navigation(where the other menubuttons are); textbutton "Animation" action ShowMenu ("AnimationScreen")
Thank you for explaining! Unfortunately, it didn't work.
New to Ren'Py with No Thoughts, Head Empty.

User avatar
Träumer
Newbie
Posts: 4
Joined: Fri Jun 11, 2021 2:00 pm
Projects: Hearts and Hexes
Discord: Träumer#5470
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#5 Post by Träumer »

Why dosen´t it work?

User avatar
LilyValley98
Newbie
Posts: 10
Joined: Sat Jul 24, 2021 3:15 pm
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#6 Post by LilyValley98 »

Träumer wrote: Sat Jul 31, 2021 9:06 am Why dosen´t it work?
This is the button that I want to be clicked and then show that animation:

Code: Select all

imagebutton auto "UI/signature_%s.png" xpos 5 ypos 690 action showMenu("AnimationScreen", transition= slowdissolve)
This is the screen that I want to show:

Code: Select all

screen AnimationScreen():
    xpos 50
    ypos 700
    image "cat hand up.png"
    pause 0.5
    image "cat hand down.png"
    pause 0.5
    repeat
It keeps making an error on every single line until I get rid of the whole thing.
for example:

Code: Select all

File "game/script.rpy", line 25: u'xpos' is not a keyword argument or valid child for the screen statement.
Even if I get rid of xpos the line underneath it will be the next error and I get rid of it, the next line will then be the next error until I get rid of the whole thing.
I've tried other stuff such as using transform but I just don't get how to use it.

I still tried though:

Code: Select all

transform AnimationScreen:
    screen AnimationScreen:
        xpos 50
        ypos 700
        image "cat hand up.png"
        pause 0.5
        image "cat hand down.png"
        pause 0.5
        repeat
and an error came up:

Code: Select all

File "game/cat screen.rpy", line 2: ATL statement contains two expressions in a row; is one of them a misspelled property? If not, separate them with pass.
    screen AnimationScreen:
                          ^
I can't use the image statement since I can't change the placement of the image.
New to Ren'Py with No Thoughts, Head Empty.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#7 Post by hell_oh_world »

that's not a valid screen. what you're doing is supposed to be ATL which is different from the syntax of a screen.
What I can suggest is to use showif statements and trigger a variable.

Code: Select all

transform show_anim:
  on show:
    alpha 0.0
    easein 0.25 alpha 1.0

  on hide:
    easeout 0.25 alpha 0.0

screen test():
  default showing = False

  textbutton "Press" action ToggleScreenVariable("showing")

  showif showing:
    add "some image" at show_anim

User avatar
LilyValley98
Newbie
Posts: 10
Joined: Sat Jul 24, 2021 3:15 pm
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#8 Post by LilyValley98 »

hell_oh_world wrote: Wed Aug 04, 2021 7:17 am that's not a valid screen. what you're doing is supposed to be ATL which is different from the syntax of a screen.
What I can suggest is to use showif statements and trigger a variable.

Code: Select all

transform show_anim:
  on show:
    alpha 0.0
    easein 0.25 alpha 1.0

  on hide:
    easeout 0.25 alpha 0.0

screen test():
  default showing = False

  textbutton "Press" action ToggleScreenVariable("showing")

  showif showing:
    add "some image" at show_anim
The game starts and I click the image button but it resorts in an error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_data.rpy", line 356, in __call__
    value = cs.scope[self.name]
KeyError: u'showing'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "renpy/ast.py", line 922, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "renpy/python.py", line 2218, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3006, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3815, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "renpy/display/layout.py", line 1027, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1027, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1027, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/screen.py", line 720, in event
    rv = self.child.event(ev, x, y, st)
  File "renpy/display/layout.py", line 1027, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1027, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/behavior.py", line 969, in event
    return handle_click(self.clicked)
  File "renpy/display/behavior.py", line 904, in handle_click
    rv = run(action)
  File "renpy/display/behavior.py", line 323, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_data.rpy", line 356, in __call__
    value = cs.scope[self.name]
KeyError: u'showing'

Windows-7-6.1.7601-SP1
Ren'Py 7.4.1.1270
Summer Love 1.0
Wed Aug  4 22:44:57 2021
I did this for the image button in the main menu(unde the screen.rpy in the main menu section):

Code: Select all

imagebutton auto "UI/signature_%s.png" xpos 5 ypos 690 action ToggleScreenVariable("showing") hovered [ Play("sound", "audio/click.wav") ]
And this is the current code:

Code: Select all

transform show_anim:
  on show:
    alpha 0.0
    easein 0.25 alpha 1.0

  on hide:
    easeout 0.25 alpha 0.0

screen cat():
  default showing = False

  showif showing:
    add "cat hand up.png" at show_anim
I want two images to flip back and forth, how do I do that?

This a better version of what I was trying to do:
Attachments
bear explanation2.gif
New to Ren'Py with No Thoughts, Head Empty.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#9 Post by hell_oh_world »

the `showing` variable should be on the same screen as the button. and of course, the `showing` variable is only accessible to the screen where it is declared.
to avoid issues regarding the global accessibility of the variable, make it a global variable instead, and perhaps a persistent one?

Code: Select all

default persistent.showing = False

screen test():
  textbutton "Press" action ToggleVariable("persistent.showing")

  showif showing:
    add "some image" at show_anim

User avatar
LilyValley98
Newbie
Posts: 10
Joined: Sat Jul 24, 2021 3:15 pm
Contact:

Re: How to make an "animation" appear on the main menu after clicking a button

#10 Post by LilyValley98 »

hell_oh_world wrote: Wed Aug 04, 2021 11:49 am the `showing` variable should be on the same screen as the button. and of course, the `showing` variable is only accessible to the screen where it is declared.
to avoid issues regarding the global accessibility of the variable, make it a global variable instead, and perhaps a persistent one?

Code: Select all

default persistent.showing = False

screen test():
  textbutton "Press" action ToggleVariable("persistent.showing")

  showif showing:
    add "some image" at show_anim
Same error but now changed to KeyError: u'persistent.showing'
I moved the whole code to the screens.rpy and I also tried putting the image button the way you wrote it but it just didn't appear in the main menu, the only way I can make the button appear is if I put it under 'if main_menu:' in screens.rpy
New to Ren'Py with No Thoughts, Head Empty.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]