Imagebutton after click action and animation
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.
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.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Imagebutton after click action and animation
Good day,
I would like to ask for your help in regards to my problem in imagebuttons.
First, I would like the imagebutton to be invisible (at least) or to go out of sight (whether taking it out of position) after I click the button but the other buttons will still be in the screen. I just want to the button to disappear after I clicked it.
Then second, that button when clicked will be adding a certain number to a variable (actually all other imagebuttons will be adding a number to that variable).
Thank you very much for the support and help.
I would like to ask for your help in regards to my problem in imagebuttons.
First, I would like the imagebutton to be invisible (at least) or to go out of sight (whether taking it out of position) after I click the button but the other buttons will still be in the screen. I just want to the button to disappear after I clicked it.
Then second, that button when clicked will be adding a certain number to a variable (actually all other imagebuttons will be adding a number to that variable).
Thank you very much for the support and help.
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Imagebutton after click action and animation
Here you go.
Code: Select all
label start:
$ button1_variable = True
$ counter = 0
show screen image_button_test
"Top disappears, bottom increments counter."
return
screen image_button_test:
frame:
vbox:
if button1_variable:
imagebutton:
idle "black_button"
hover "black_button"
action ToggleVariable("button1_variable")
else:
null height 50 # added a null so the screen size doesn't change, you can remove this else statement altogether
imagebutton:
idle "white_button"
hover "white_button"
action SetVariable("counter", counter+1)
text str(counter)
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
Thank you very much!
It works!
But how can I do both in one button?
Another problem is, if the player clicks on the other part of the screen, the dialogues continues. How can I make disabled aside on those buttons?
It works!
But how can I do both in one button?
Another problem is, if the player clicks on the other part of the screen, the dialogues continues. How can I make disabled aside on those buttons?
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Imagebutton after click action and animation
You can assign multiple actions like this
You will want to set the screen's modal to True to prevent other interactions.
http://www.renpy.org/doc/html/screens.h ... -statement
Code: Select all
action [ToggleVariable("button1_variable"), SetVariable("counter", counter+1)]
http://www.renpy.org/doc/html/screens.h ... -statement
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
That helped a lot!
Another question, how about the variable counter reaches a certain value then I need it to jump to the next scene, how can I do that?
Thank you very much again. I know I'm asking too much.
Another question, how about the variable counter reaches a certain value then I need it to jump to the next scene, how can I do that?
Thank you very much again. I know I'm asking too much.
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Imagebutton after click action and animation
Not at all.
It sounds like you need to 1. check the value of the variable. 2. jump to a label and hide the screen when a certain value is reached.
There is a way to give a button a conditional action using If.
http://www.renpy.org/doc/html/screen_ac ... er-actions
When they click the button the 3rd time, it will increment the counter, hide the screen, and jump to label test_label.
It sounds like you need to 1. check the value of the variable. 2. jump to a label and hide the screen when a certain value is reached.
There is a way to give a button a conditional action using If.
http://www.renpy.org/doc/html/screen_ac ... er-actions
Code: Select all
action If(counter==2, [SetVariable("counter", counter+1), Hide("image_button_test"), Jump("test_label")], SetVariable("counter", counter+1))
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
It answers my problem! But currently I encountered another problem, when I click a button, the button is displacing. I need them to be in place even I already clicked a button(s). Is the problem coming from xpos and ypos? I also tried xalign and yalign but they are also displacing the button.
Thank you very much again for helping!
Here is the code:
Thank you very much again for helping!
Here is the code:
Code: Select all
label test2:
$ button1_variable = True
$ button2_variable = True
$ button3_variable = True
$ memo_timer = 10
$ counter = 0
call screen image_button_test
label test3:
screen image_button_test:
timer 1.0 action If (memo_timer > 1, SetVariable("memo_timer", memo_timer - 1), Jump("end") ) repeat True
text str(memo_timer) xalign 0.95 yalign 0.05
frame:
vbox:
style "nvl_window"
if button3_variable:
imagebutton:
xpos 100
ypos 200
idle "gui/testButton_idle.png"
hover "gui/testButton_hover.png"
action If(counter==2, [Hide("image_button_test"), Jump("end")], [SetVariable("counter", counter+1), ToggleVariable("button3_variable")])
if button1_variable:
imagebutton:
xpos 200
ypos 200
idle "gui/testButton_idle.png"
hover "gui/testButton_hover.png"
action If(counter==2, [Hide("image_button_test"), Jump("end")], [SetVariable("counter", counter+1), ToggleVariable("button1_variable")])
if button2_variable:
imagebutton:
xpos 300
ypos 200
idle "gui/testButton_idle.png"
hover "gui/testButton_hover.png"
action If(counter==2, [Hide("image_button_test"), Jump("end")], [SetVariable("counter", counter+1), ToggleVariable("button2_variable")])
text str(counter)
label end:
t "end"
return
Re: Imagebutton after click action and animation
If you want the buttons to stay in position even when some vanish, you could try setting a vbox with a separate xpos/vpos for each button and put the if statements inside the vboxes
something like this:
that way if a button gets removed the layout should not change
something like this:
Code: Select all
frame:
vbox xpos 0:
if button:
button
vbox xpos 50:
if button:
button
vbox xpos 100:
if button:
button
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Imagebutton after click action and animation
If you look back at that first example, you'll see that for the if statement I had an else with a null. That's so if the button isn't there, a null displayable of the same size is created to fill the place.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
I think i've found a solution also.
Thank you very much guys!
I'll try to update you guys here at the forum if my project is completed.
Thank you very much guys!
I'll try to update you guys here at the forum if my project is completed.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
Hello guys! Sorry if I didn't update you guys. I would like you to know I will now continue this project. My target is within 3 months. I hope you can again help me. Thank you very much.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Imagebutton after click action and animation
May I ask if how can I add animation/transformation using this imagebutton codes? I'm having a problem in that. For example, I would like the buttons to zoom while it still not being clicked.
Thank you very much!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot]