I have problem with moving image and DynamicDisplayable

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
0xrgb
Newbie
Posts: 3
Joined: Thu Sep 03, 2015 6:36 am
Deviantart: 0xrgb
Github: 0xrgb
Soundcloud: 0xrgb
Contact:

I have problem with moving image and DynamicDisplayable

#1 Post by 0xrgb »

Hello, I'm Korean Renpy user, and I have problem about DynamicDisplayable

I want to show image "x" when persistent.endline is true and image "x2" when it is false.

x and x2 is both ATL images.
endline*.png is cursor image.

Code: Select all

image x:
    "endline1.png"
    pause 0.1
    "endline4.png"
    pause 0.1
    "endline2.png"
    pause 0.1
    "endline3.png"
    pause 0.1
    repeat

image x2:
    "endline.png"
    linear 0.5 alpha 0
    linear 0.5 alpha 1
    repeat

init python:
    def endimage(st,at):
        if persistent.endline:
            return x, .1
        else:
            return x2, .1

init:
    $ Eco = Character("Eco",ctc = DynamicDisplayable(endimage), ctc_position = "nestled")
Eco "yay"
But this code didn't work as I expected. What should I do?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: I have problem with moving image and DynamicDisplayable

#2 Post by trooper6 »

I'm not exactly sure what is supposed to be happening here.
If you just want something that shows one image if a variable is true, but a different image if it is false, I'd use ConditionSwitch: http://www.renpy.org/doc/html/displayab ... tionSwitch

But...I do have to ask what is persistent.endline? Why is it persistent? When do you define it? When do you change it?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
orz
Regular
Posts: 126
Joined: Tue Apr 21, 2015 10:19 pm
Contact:

Re: I have problem with moving image and DynamicDisplayable

#3 Post by orz »

But this code didn't work as I expected. What should I do?
Correct me if I'm wrong, but the problem appears to be that by using "image x:", you're declaring that there's a displayable by the name of x. There isn't.

Instead of doing it the way you have done, just change "image x:" and "image x2:" into "transform x:" and "transform x2:". There, we've declared that we're making a transform by the name of x and x2, and later we'll apply it to a displayable.

Then, in your DynamicDisplayable function, you just do "return At(Null(), x), None" and "return At(Null(), x2), None" as your returns. There, we took the transforms you took earlier and applied them to a displayable (which transforms require).

Since you didn't need anything as the displayable because you defined all the images in the transform, I just used Null() as the displayable to act upon.

At() is a function that applies a transform to a displayable.

Oh, and I returned None as the second part because you shouldn't need to call the function multiple times, since it'll be true or false immediately.

Edit: For a bit of an example, try this--

Code: Select all

label start:
    show image Null():
        Solid("#FFF", xysize = (50,50))
        linear 0.5 alpha 0
        linear 0.5 alpha 1
        repeat

    "Eco" "yay"

User avatar
0xrgb
Newbie
Posts: 3
Joined: Thu Sep 03, 2015 6:36 am
Deviantart: 0xrgb
Github: 0xrgb
Soundcloud: 0xrgb
Contact:

Solved. Thank you.

#4 Post by 0xrgb »

Thank you very much.

I solved this problem two ways.
First solution is using function "choice", and the other is using "transform" instead of "image".

(1)

Code: Select all

image x:
    choice(persistent.endline == True):
        "endline1.png"
        pause 0.1
        "endline4.png"
        pause 0.1
        "endline2.png"
        pause 0.1
        "endline3.png"
        pause 0.1
        repeat
    choice(persistent.endline == False):
        "endline.png"
        linear .5 alpha 0
        linear .5 alpha 1
        repeat
(2)

Code: Select all

init python:
    def endimage(st,at):
        if persistent.endline:
            return At(Null(),x),None
        else:
            return At(Null(),x2),None

transform x:
    "endline1.png"
    pause 0.1
    "endline4.png"
    pause 0.1
    "endline2.png"
    pause 0.1
    "endline3.png"
    pause 0.1
    repeat

transform x2:
    "endline.png"
    linear .5 alpha 0
    linear .5 alpha 1
    repeat

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]