Playing an animation when user clicks

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
Glazed Donuts
Regular
Posts: 121
Joined: Thu Aug 12, 2010 11:47 am
Contact:

Playing an animation when user clicks

#1 Post by Glazed Donuts »

I'm trying to find a way for a small animation to play when you click on the screen. For example, if you click in a certain spot, then it shows an explosion animation (non-looping) where the mouse cursor is to let the user know where they clicked. Is there a way to do this in Ren'Py?

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Playing an animation when user clicks

#2 Post by Jake »

Glazed Donuts wrote:I'm trying to find a way for a small animation to play when you click on the screen. For example, if you click in a certain spot, then it shows an explosion animation (non-looping) where the mouse cursor is to let the user know where they clicked. Is there a way to do this in Ren'Py?
The playing-an-explosion-animation part, yes. But IIRC it's not that simple to find the precise location that a user clicked on, in Ren'Py... do you just want a single, predetermined spot where this will happen, or do you want it to happen wherever the user clicks?

In general terms, I would set the animation up beforehand using an ATL-defined image, then when you want to show it at X, Y you can do something like:

Code: Select all

  $ renpy.show("explosion image name", at_list=[Transform(xpos=X, ypos=Y, xalign=0.5, yalign=0.5)], layer="transient")
  $ renpy.pause(1)
  $ renpy.hide("explosion image name", layer="transient")
(where '1' is the length in seconds of your animation, and the 'layer="transient"' bit makes the explosion play over the top of most things.)
Server error: user 'Jake' not found

Post Reply

Who is online

Users browsing this forum: Google [Bot]