Variable as image size

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
Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Variable as image size

#1 Post by Doeny »

Hi, is there a way to define an image with variable value as its size to make it update continously?

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Variable as image size

#2 Post by Kia »

Depends on where you want to use it I guess, if it's a screen, you can easily add zoom transform to it and pass the zoom level as a variable

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Variable as image size

#3 Post by Doeny »

Kia wrote: Thu Nov 10, 2022 3:18 am Depends on where you want to use it I guess, if it's a screen, you can easily add zoom transform to it and pass the zoom level as a variable
I wanna use it as a button's image

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Variable as image size

#4 Post by _ticlock_ »

Doeny wrote: Thu Nov 10, 2022 3:46 am I wanna use it as a button's image
Doeny wrote: Thu Nov 10, 2022 12:24 am Hi, is there a way to define an image with variable value as its size to make it update continously?
How do you change the variable?
Here some examples:
1) In a RenPy statements:

Code: Select all

default v = 1.0

screen test_button(disp):
    button:
        add disp:
            zoom v
        action NullAction()
        xalign 0.5 yalign 0.5
        
label start:
    show screen test_button(Solid("#f00", xysize=(100,100)))
    "Line - 1"
    $ v = 1.5
    "Line  - 2"
2) Inside the screen using action or bar:

Code: Select all

default v = 1.0
default bval = VariableValue("v", 2.0, offset = 1)

screen test_button(disp):
    button:
        add disp:
            zoom v
        action Return()
        xalign 0.5 yalign 0.5
        
    bar:
        value bval
        yalign 0.0
    textbutton "1.2" action SetVariable('v', 1.2) xalign 0.0 yalign 0.5
    textbutton "1.8" action SetVariable('v', 1.8) xalign 1.0 yalign 0.5

label start:
    call screen test_button(Solid("#f00", xysize=(100,100)))

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot], trailsiderice