Problem with alpha in transformation

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
Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Problem with alpha in transformation

#1 Post by Nero »

So to be quick I want to have same transformations in both case however second one is written inside a function but it doesn't work the way I want it as you can see Ren'Py transformation works like it should but how do I make same thing inside a function? The picture should disappear AFTER the zoom and rotation but it disappears in same moment with rest of stuff how do I delay it? (And is there a way without using a pause as it might mess up my battle engine code). Can linear be used in function if so how?

Code: Select all

transform test_1():
    parallel:
        rotate 0
        linear 2.4 rotate 360
        #repeat

    parallel:
        zoom 0.50
        linear 2.4 zoom 1.2
        #repeat

    alpha 1
    pause 0.4
    linear 0.5 alpha 0

screen test_2():
    add "simpleimage.png" at test_1
    add "simpleimage.png" at Transform(function=SKILL_ANIMATION), truecenter

init python:

    # This spins the logo, while at the same time zooming it and decreasing the
    # alpha.
    def SKILL_ANIMATION(t, st, at):

        ## Repeat every 4 seconds.
        st = st % 4.0

        # The move takes 2.4 seconds.
        done = min(st / 2.4, 1.0)
        t.rotate = 360 * done
        t.zoom = 0.2  + done
        t.alpha = 1.0 - done


        return 0




label start:
    show screen test_2
    "I want to make those animations work exactly same however transform made in function doesnt work as I want it"
    "End"

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: Problem with alpha in transformation

#2 Post by PyTom »

From your description, it seems like you might want:

Code: Select all

if done < 1.0:
    t.alpha = 1.0
else:
    t.alpha = 0.0
You can do anything you want in a function, as ATL actually is just a very complex transform function. But when you're working in Python, you have to very precisely understand and express what you want, which is something ATL makes far easier.
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

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Problem with alpha in transformation

#3 Post by Nero »

Hey, thanks for response PyTom I agree using ALT is much more easier and I'm using it but for this current animation I cant use it since I get some kind of bug interaction when I combine transform with tooltip that shows new screen while game is locked in renpy.pause. Animation just gets stuck there might be many factors why this happen and code is way too large to spot the mistake. When using Python this error is gone now however it needs much more knowledge as you said.

Now about code this is the far as I could get and its still not what I wanted "alpha" still runs in background so in the end it looks really unnatural, and I don't know how you meant to use code above as "done" is not dynamic value that changes right? You meant to use a some kind of timer or? I'm stuck here.

Code: Select all

transform test_1():
    parallel:
        rotate 0
        linear 2.4 rotate 360
        #repeat

    parallel:
        zoom 0.50
        linear 2.4 zoom 1.2
        #repeat

    alpha 1
    pause 0.4
    linear 0.5 alpha 0

screen test_2():
    add "simpleimage.png" at test_1
    add "simpleimage.png" at Transform(function=SKILL_ANIMATION), truecenter

init python:

    # This spins the logo, while at the same time zooming it and decreasing the
    # alpha.
    def SKILL_ANIMATION(t, st, at):

        ## Repeat every 4 seconds.
        st = st % 4.0

        # The move takes 2.4 seconds.
        done = min(st / 2.4, 1.0)
        done2 = min(st / 4.0, 1.0)
        t.zoom = 0.2  + done
        t.rotate = 360 * done
        
        if st > 2.4:
            t.alpha = 1.0 - done2
        else:
            t.alpha = 1.0

        return 0




label start:
    show screen test_2
    "I want to make those animations work exactly same however transform made in function doesnt work as I want it"
    "End"

Post Reply

Who is online

Users browsing this forum: No registered users