
[SOLVED!] Moving an image by pressing a button?
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.
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
- Contact:
[SOLVED!] Moving an image by pressing a button?
Okay, this might be a bit of an ask here, but is it in any way possible for me to make a function that will move the image on the left to the X on the right with "linear" animation when clicking on the X on the right?


Last edited by Michael Regal on Fri Apr 01, 2022 11:03 am, edited 1 time in total.
-
rayminator
- Miko-Class Veteran
- Posts: 754
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
- Contact:
Re: Moving an image by pressing a button?
it is possible to do this I think you need something from pygame coding to do this it out of my knowledge but I believe there something in the codebook section for this
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
- Contact:
Re: Moving an image by pressing a button?
A kind soul on the Renpy discord gave me the solution! Thanks guys!
Code: Select all
transform move_to_right:
on show:
linear 1.0 xoffset 200 #aka the new position
screen yourscreen:
default move_me = False
showif move_me:
add 'abstract' at move_to_right
else:
add 'abstract'
textbutton "A button":
action SetScreenVariable('move_me', True)- Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Moving an image by pressing a button?
An example:
https://i.imgur.com/dwUKvPl.gif
EDIT: Oh... I glad you found a solution.
Code: Select all
image cross = Crop((0, 0, 30, 30), Solid("#F00"))
image marker = Crop((0, 0, 20, 50), Solid("#0F0"))
default marker_pos = (0.1, 0.5)
screen move_example():
imagebutton:
idle "cross"
action SetVariable("marker_pos", (0.1, 0.5))
pos (0.1, 0.5)
anchor (0.5, 0.5)
imagebutton:
idle "cross"
action SetVariable("marker_pos", (0.4, 0.5))
pos (0.4, 0.5)
anchor (0.5, 0.5)
add "marker":
anchor (0.5, 1.0)
at marker_move(marker_pos)
transform marker_move(position, duration=0.8):
linear duration pos position
label start:
show screen move_example
' . . . '
return
EDIT: Oh... I glad you found a solution.
< < insert Rick Cook quote here > >
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
- Contact:
Re: Moving an image by pressing a button?
Your code is MUCH more efficient thoughOcelot wrote: ↑Fri Apr 01, 2022 11:11 amAn example:https://i.imgur.com/dwUKvPl.gifCode: Select all
image cross = Crop((0, 0, 30, 30), Solid("#F00")) image marker = Crop((0, 0, 20, 50), Solid("#0F0")) default marker_pos = (0.1, 0.5) screen move_example(): imagebutton: idle "cross" action SetVariable("marker_pos", (0.1, 0.5)) pos (0.1, 0.5) anchor (0.5, 0.5) imagebutton: idle "cross" action SetVariable("marker_pos", (0.4, 0.5)) pos (0.4, 0.5) anchor (0.5, 0.5) add "marker": anchor (0.5, 1.0) at marker_move(marker_pos) transform marker_move(position, duration=0.8): linear duration pos position label start: show screen move_example ' . . . ' return
EDIT: Oh... I glad you found a solution.