analog clock in ATL [SOLVED]

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
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

analog clock in ATL [SOLVED]

#1 Post by saguaro » Fri Jun 08, 2012 11:35 pm

I was hoping I could achieve this with ATL so I wouldn't have to make an animation. I have a clock face and a separate minute and hour hand, and I am layering the images and using transforms on the hands. This was the last thing I tried:

Code: Select all

transform timeforward:
    alignaround (0.5, 0.5)
    linear 1.0 clockwise circles 2
I can't figure out how to (or if I can) anchor the minute and hour hands to the center and have them rotate. Any help is much appreciated.
Last edited by saguaro on Sat Jun 09, 2012 1:05 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: analog clock in ATL

#2 Post by PyTom » Sat Jun 09, 2012 1:10 am

I suspect the easiest way would be to just have the face, hour hand, and minute hand all be the same (square) size, and then rotate them all.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: analog clock in ATL

#3 Post by saguaro » Sat Jun 09, 2012 1:04 pm

Thanks, PyTom. I tried using rotate before, but I was Doing It Wrong (TM). I figured out how to use it properly. This is the solution:

Code: Select all

    image clock:
        "images/clock/clockface.png"
        yalign 0.5 xalign 0.5
        
    image minutes = "images/clock/minutehand.png"
    image hours = "images/clock/hourhand.png"
        
    transform timeforwardhours:
        xalign 0.5 yalign 0.5
       
        block:
            rotate 0
            linear 60.0 rotate 360
            repeat
        
    transform timeforwardminutes:
        xalign 0.5 yalign 0.5
        
        block:
            rotate 0
            linear 5.0 rotate 360
            repeat
There might be a more efficient way to write that, but this way I can use transforms that go clockwise or counter-clockwise. (To go backwards, just set the second rotate to -360.)

Post Reply

Who is online

Users browsing this forum: No registered users