Shake Sprite without changing it's 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
User avatar
neometalero
Regular
Posts: 157
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Shake Sprite without changing it's position

#1 Post by neometalero » Sun May 09, 2021 3:21 pm

I'm trying to shake the sprite of a monster, but every time I do it the position changes, and ruins the scene.
Image

This is the code I'm using

Code: Select all

show camExtPlantVivo at center, Shake(None, 1.0, dist=5)
How can I shake only the sprite without changing it's position?
Image
Working on My Dream Sport Dating Simulator right now
https://store.steampowered.com/app/1521 ... Simulator/

User avatar
Alex
Lemma-Class Veteran
Posts: 2691
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Shake Sprite without changing it's position

#2 Post by Alex » Sun May 09, 2021 5:13 pm

neometalero wrote:
Sun May 09, 2021 3:21 pm
...How can I shake only the sprite without changing it's position?
Try it like

Code: Select all

image red:
    Solid("#c00")
    size(100, 100)

transform my_shake(dist=10, t=0.4, r=3):
    yoffset 0
    linear t / 4.0
    yoffset -dist
    linear t / 2.0
    yoffset dist
    linear t / 4.0
    yoffset 0
    repeat r
    
# The game starts here.
label start:
    "..."
    show red at truecenter
    "... ..."
    show red at my_shake(15, 0.2, 2)
    "?!"
https://www.renpy.org/doc/html/atl.html

User avatar
neometalero
Regular
Posts: 157
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Shake Sprite without changing it's position

#3 Post by neometalero » Mon May 10, 2021 7:35 am

This worked a lot better but the image still moved a little bit from it's position. Any idea about what can be wrong?
Alex wrote:
Sun May 09, 2021 5:13 pm
neometalero wrote:
Sun May 09, 2021 3:21 pm
...How can I shake only the sprite without changing it's position?
Try it like

Code: Select all

image red:
    Solid("#c00")
    size(100, 100)

transform my_shake(dist=10, t=0.4, r=3):
    yoffset 0
    linear t / 4.0
    yoffset -dist
    linear t / 2.0
    yoffset dist
    linear t / 4.0
    yoffset 0
    repeat r
    
# The game starts here.
label start:
    "..."
    show red at truecenter
    "... ..."
    show red at my_shake(15, 0.2, 2)
    "?!"
https://www.renpy.org/doc/html/atl.html
Image
Working on My Dream Sport Dating Simulator right now
https://store.steampowered.com/app/1521 ... Simulator/

User avatar
neometalero
Regular
Posts: 157
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Shake Sprite without changing it's position

#4 Post by neometalero » Mon May 10, 2021 7:47 am

Ok I fixed it, I just used

Code: Select all

show camExtPlantVivo at shakeChar(15, 0.2, 2)
and it worked great, tks a lot for the help!
Image
Working on My Dream Sport Dating Simulator right now
https://store.steampowered.com/app/1521 ... Simulator/

Post Reply

Who is online

Users browsing this forum: Ayael, Ocelot