Moving character image across screen to new position

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
ddalziel
Newbie
Posts: 10
Joined: Tue Dec 31, 2013 1:25 pm
Contact:

Moving character image across screen to new position

#1 Post by ddalziel »

Hi all,

I'm new here and hope I can get some help.

I'm pretty much an absolute beginner. I've been following ren'py tutorials (like this one) and learning python on the side but my knowledge is extremely basic and confined to simple games so apologies in advance.

I'm trying to smoothly move a character image which is already on screen about xpos 0.1 or 0.15 over to the right. I've only ever used the predefined moveinleft etc for showing characters. Everything I've experimented with has errors so I think I may be approaching it the wrong way. I didn't understand looking at code in the tutorial file and I was hoping someone could help explain it to me.

this is what i was trying to use but it gets errors and I think I'm probably barking up the wrong tree:
show alice at xpos 0.85 with move

Any help is appreciated, looking forward to contributing myself :)

D

User avatar
akemicchi
Veteran
Posts: 465
Joined: Mon Dec 31, 2007 11:22 pm
Projects: Magicians of Delphine, Panaderia: Ensaimada, SweetTooth!, XOXO Droplets
Deviantart: littlebabyshoes
Contact:

Re: Moving character image across screen to new position

#2 Post by akemicchi »

Hi! Welcome to Lemmasoft forums!

Have you see the documentation on ATL? (http://www.renpy.org/doc/html/atl.html) It would help a lot in learning how to make displayables do what you want it to. If you're using ATL, you'll have to put it in a block like this:

Code: Select all

show alice:
    xalign 0.0
    linear 0.3 xpos 0.85
The first part, xalign 0.0, is the position of the image. You can use xpos too, but xalign makes it relative to the screen. Using xalign 0.0 means the image is on the left side of the screen (0.5 means centered, and 1.0 means on the right). What makes it move is in the third line. linear 0.3 means it will take 0.3 seconds to position the image at xpos 0.85.

You can also do something like this so that you don't have to repeat yourself.

Code: Select all

transform moveright:
    linear 0.5 xpos 0.85

label start:
    show alice:
        xalign 0.0
        moveright
If the image alice is already showing, you can skip the line xalign 0.0 completely so she will move to the position wherever Alice already is. You can also add xalign 0.0 to the transform statement, so you can just use 'show alice at moveright' whenever you want to show Alice at the left of the screen moving to the right.

If you want something more similar to your code, you could do:

Code: Select all

define farright = Position(xpos=0.85)

label start:
    show alice at left
    show alice at farright with move
It's simpler, but you can do a lot more things with ATL. :) It's worth learning.

ddalziel
Newbie
Posts: 10
Joined: Tue Dec 31, 2013 1:25 pm
Contact:

Re: Moving character image across screen to new position

#3 Post by ddalziel »

Thank you Akemicchi!

Thanks for explaining it so well and clearly. And thank you for putting me onto ATL, I'll start studying. :)

ddalziel
Newbie
Posts: 10
Joined: Tue Dec 31, 2013 1:25 pm
Contact:

Re: Moving character image across screen to new position

#4 Post by ddalziel »

(Just popped it in the code, played with the numbers to get the perfect position and it worked perfectly!)

Post Reply

Who is online

Users browsing this forum: No registered users