Define a transition based on device variant?

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
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Define a transition based on device variant?

#1 Post by Jackkel Dragon »

I couldn't find an answer to this myself or in any of the places I looked, so I figured I'd ask here: Is there a way to have transforms defined differently based on which type of device a game is being played on? (Similar to how some screen language can be modified based on which device the game is on.)

Something I tried which may help show what I mean:

Code: Select all

init -20:

    transform left:
        if not renpy.variant("small"): # normal devices
            xalign 0.0
            yalign 1.0
        else: # mobile phones
            xalign -0.25
            yalign 1.0
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Define a transition based on device variant?

#2 Post by Remix »

As you cannot programmatically create an ATL transform and cannot use conditional block logic within an ATL transform the options are pretty limited.

If you are just tweaking values, you can wrap those in parenthesis and do logic in there:

Code: Select all

transform variable_values_transform():
    xpos (100 if not renpy.variant("small") else 300)
    ypos (400 if not renpy.variant("small") else 100)
I think that is about all you can get away with though...
Frameworks & Scriptlets:

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: Define a transition based on device variant?

#3 Post by Jackkel Dragon »

That seems to work for me, thanks! Luckily, I think I only need to change the position/alignment values based on the device type. I'm not really familiar with the syntax used, but at least it seems to work the way I needed it to.
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Define a transition based on device variant?

#4 Post by Imperf3kt »

The way I do it is make different transforms, and then use the variant check, where tha transform is applied.
Also has its limits, but is another possible way to do it.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Define a transition based on device variant?

#5 Post by PyTom »

renpy.variant should be defined in an init block, and an init block can run Ren'Py. So you should be able to do:

Code: Select all

init:
    if not renpy.variant("small"): # normal devices

        transform left:
            xalign 0.0
            yalign 1.0

    else: # mobile phones

        transform left:
            xalign -0.25
            yalign 1.0

Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: Define a transition based on device variant?

#6 Post by Jackkel Dragon »

That kind of syntax looks more familiar to me, so I might try that one. That's exactly the kind of thing I'm looking for, so thanks for the help!
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], voluorem