How to make a clickable moving button

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
Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

How to make a clickable moving button

#1 Post by Exiscoming » Tue Nov 03, 2020 7:21 pm

I'm making a side scrolling game where the player can randomly encounter an event along the way.
That means the encounter spawns somewhere along the path and comes into frame as you move from left to right.
Now what I want to do is make the encounter a button that you can click on.

The problem
I normally use imagebuttons, however they are part of a screen, and screens can't be animated.
Because the encounter (and the player) move around, I need to figure out a way the player can click on the encounter.

The Question
How do I make clickable buttons that move around?

Visual:
https://i.imgur.com/fpjT2r3.mp4

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to make a clickable moving button

#2 Post by Imperf3kt » Tue Nov 03, 2020 8:45 pm

Imagebutton suit this well.

Take a look at this post which has an example project that details exactly how to do what you're asking.

viewtopic.php?f=51&t=22565&start=75#p455107
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: How to make a clickable moving button

#3 Post by Exiscoming » Wed Nov 04, 2020 8:06 am

That's an excellent tutorial. Thanks!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]