Ren'Py Rotating sprite.

Milvidi

Member
Game Developer
Feb 26, 2018
200
540
I need some help with Renpy transition and transform. Basically, I want my sprite to move similar to when I use:

hide sprite with moveoutleft

But got the sprite to spin the whole time while moving out of the screen.

Is there anyway to achieve this?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
Best guess, you want to create a spinning sprite using and then move it using with moveoutleft.

Something like:

Python:
image spinning_sprite:
    "sprite.png"
    clockwise circles 3
    linear 5.0

# sometime later...

    show spinning_sprite with moveoutleft
I'm guessing at the code here, as I haven't tested or used either clockwise or circles before. But seems to say it's rotation is auto-calculated based on the length of the transition/warper (linear).

Though also seems to point to being able to create custom transforms that do pretty much the same without creating custom images/displayables as I have done.
 
  • Like
Reactions: Milvidi

Milvidi

Member
Game Developer
Feb 26, 2018
200
540
Best guess, you want to create a spinning sprite using and then move it using with moveoutleft.

Something like:

Python:
image spinning_sprite:
    "sprite.png"
    clockwise circles 3
    linear 5.0

# sometime later...

    show spinning_sprite with moveoutleft
I'm guessing at the code here, as I haven't tested or used either clockwise or circles before. But seems to say it's rotation is auto-calculated based on the length of the transition/warper (linear).

Though also seems to point to being able to create custom transforms that do pretty much the same without creating custom images/displayables as I have done.
Thank you, but this doesn't work. I'll just dig a little more. All the guides I've seen to rotate sprite up until now look pretty complicated.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
Thank you, but this doesn't work. I'll just dig a little more. All the guides I've seen to rotate sprite up until now look pretty complicated.
When you say it doesn't work, what does it actually do? I thought of the same general idea that 79flavors suggested - it seems like it should work. Although it might just be a question of syntax. Like maybe

Code:
image spinning_sprite:
    "sprite.png" anchor (0.5, 0.5)
    linear 5.0 rotate 1440.0
 

Milvidi

Member
Game Developer
Feb 26, 2018
200
540
When you say it doesn't work, what does it actually do? I thought of the same general idea that 79flavors suggested - it seems like it should work. Although it might just be a question of syntax. Like maybe

Code:
image spinning_sprite:
    "sprite.png" anchor (0.5, 0.5)
    linear 5.0 rotate 1440.0

Thank you, with some fiddling, this works. 79flavors's code actually do nothing. No error or anything, the sprite showed up like normal, without the spinning.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,608
2,256
Glad you got it sorted out.

If I'm honest, I didn't expect my code to work as was. I tried to cover that by explaining it was a guess. However, I hoped it would be enough of a hint and a the starting point for an actual solution. Shame it did nothing.

After a little messing last night, I did figure out that clockwise wasn't quite what I thought it was. I also forgot that this sort of ATL needs a starting point in addition to the place where it is to move to.

This code puts the image in the centre of the screen and then it spirals a few times before reaching the left hand edge of the screen. The spiral was a surprise to me. I put the ATL inline to the show rather than defining it beforehand.

Python:
    show rotating_circle:
        xalign 0.5 yalign 0.5
        alignaround (0.5, 0.5)
        linear 5.0 xalign 0.0 counterclockwise circles 3

Perhaps you could post your updated code, so others can see what working code looks like.

Based on Rich's code, this is what mine ended up looking like...

Python:
    show rotating_circle:
        xalign 0.5 yalign 0.5
        alignaround (0.5, 0.5)
        linear 1.0 xalign -0.15 rotate -720

I'm using xalign -0.15 to be a position off the left edge of the game screen (1920x1080).
With a bit more time, I'd perhaps be able to refine it more.

My rotating_circle.png - 150px x 150px:

rotating_circle.png
 
  • Like
Reactions: Rich and Milvidi

Milvidi

Member
Game Developer
Feb 26, 2018
200
540
Here's my working code. The original purpose of this is to make a scene where character B slams into character A, and A got flung out of the screen in a comical way.

Code:
##### Defining the images #####

image spriteA normal= "spriteA.png"

image spriteB = "spriteB.png"

image spriteA spin:
    "spriteA normal"
    xoffset 0
    yoffset 0
    anchor (0.5, 0.5)
    linear 3.0 rotate -1440 xoffset -1000 yoffset -1000
    
##### The actual code #####

label whatever:
    show spriteA normal
    
    "Dialogues..."
    
    show spriteB with moveinright
    
    show spriteA spin with vpunch
    
    "Dialogues..."
 
  • Like
Reactions: Rich