Rotation issues

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
Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Rotation issues

#1 Post by Onishion »

Ok, I can't get rotation to work right for the life of me. I am trying to rotate an image that is contained inside an image set. The image file is 200x500 pixels. What I want to happen, is for it to spin in place around an axis that is located at the vertical center of the image, and slightly above the bottom of the image, so roughly at the 100x450 point of the image or so. Instead, no matter what I try to do, it ends up spinning around a point several hundred pixels to the side of the image itself, causing it to move a bit like one of those pirate ship carnival rides. Is it a problem of having it inside a contained image? Does that cause the anchor points to not function properly? Here's the base code I'm dealing with:

Code: Select all

transform Arm_Rotation():
    subpixel True
#    rotate_pad False
    ease 1 rotate -360
    ease 1 rotate 0
    pause 0.1
    repeat
    
image Arm:
    contains:
        ConditionSwitch(
            "Arm_Color == 'silver'", "images/Arm_S.png",
            "Arm_Color == 'black'", "images/Arm_B.png",             
            "Arm_Color == 'gold'", "images/Arm_G.png", 
            ), 
#    anchor (0.5,0.5)
#    pos (200,200)

Image Clockface:
     contains:
        ConditionSwitch(  
            "Speed == 0", At("Arm", Arm_Rotation()),
            "Speed <= 1", At("Arm",Arm_Rotation()),
            "Speed != 0", "images/nothing.png",
            ),    
        zoom .55
I've tried it with and without padding, I've tried the anchor at (0.0,0.0) (1.0,1.0), no anchor, setting it to fixed points, all those changes seem to do is move the center point relative to the screen, not relative to the shape of the image file. What am I doing wrong here?

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: Rotation issues

#2 Post by trooper6 »

If you are doing an analogue clock, you might want to check out the clock tutorial linked in my sig.
If you are doing an analogue clock, what I would recommend is having all of your images be exaclty the same size and when they are all layere on top of each other, the hands are right in the center of the image. Then you can just rotate the images with the hands and not have to worry about any shenanigans.
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

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Rotation issues

#3 Post by Onishion »

It's a little more complicated than that, but I basically need it to rotate around the point indicated. I;ll check out the tutorial though.

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Rotation issues

#4 Post by Onishion »

Ok, I tried to mess with your tutorial example and learned some things. If I took one of the clock hand images and did a simple image define statement, and then just used:

Code: Select all

show Arm:
    xalign 0.5 yalign 0.5
    rotate 0 #This puts the minute hand at the starting position of 12
    block: #Everything in this block repeats over and over
        linear 2 rotate 360
        repeat
Then it would rotate in place around its central axis, which is at least a step in the right direction. If, on the other hand, I tried to use my previous image tag, with the contains and the condition switch and the zoom in it, then it would do the same thing as usual, the "carnival pirate ride" effect, spinning around an axis well away from itself. How do I reposition the axis of rotation to the correct location?

edit:
So some more testing, it's definitely something to do with the "contains" element. If I just use:

Code: Select all

image Arm:
    "images/Arm_S.png"

#as the image then it will display and rotate around its center, but if I use:

image Arm:
    contains:
        "images/Arm_S.png"

# then it does the "pirate ship effect" again. 

I still can't get it to deliberately rotate around anything other than its center though (aside from the accidental method which seems out of control).

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: Rotation issues

#5 Post by trooper6 »

Is there any reason why you have to use contains?
You could put the elements on a screen, or you could create a Creator Defined Displayable like I did.
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

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Rotation issues

#6 Post by Onishion »

Is there any reason why you have to use contains?
You could put the elements on a screen, or you could create a Creator Defined Displayable like I did.
Well, I could maybe use Live Composite. By necessity I need to be able to use it on a complex, condition-effected display grouping of some kind. I'd just like to know why it's acting so oddly. What I'm trying to do should be very very very simple to do, it's just "set where the center point is, and spin it." You can do it with a piece of cardboard and a pencil, so why is it so difficult here?

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: Rotation issues

#7 Post by trooper6 »

Wouldn't a Creator Defined Displayable meet your needs?
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

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Rotation issues

#8 Post by Onishion »

Wouldn't a Creator Defined Displayable meet your needs?
I don't know exactly what the means. It might, or it might not. I just want to understand why this isn't working. Why is the center of rotation all over the place and seemingly uncontrollable?

edit:

Ok, I tried a Live Composite for the arm, and that let me make it spin around it's center point, now I need to try and figure out how to shift that center point (although worth case scenario I can just make the image about twice as tall as it needs to be an mostly invisible). I still wish I understood the underlying problem that was preventing this from just working right out of the gate.

Post Reply

Who is online

Users browsing this forum: Google [Bot]