Just started learning Python/Pygame watching videos and reading to learn . I would like to see a example code to cycle 3 images on a rect button from a mouse press and return to first image. Really I want the pictures to be three options and return different results. So be able to cycle image be able to select option and option when triggered execute choice.
相关问题
- MultiThreading with pygame, program crashing
- Pygame for Python 3.2 on mac - import error
- Pygame Distribution - Runtime Error
- Pygame not finding image folder when in subdirecto
- Pygame - Play sounds simultaneously
相关文章
- How to save captured image to disk, using Pygame
- Python pygame writing text in sprite [closed]
- Generating a Voronoi Diagram around 2D Polygons
- Pygame point image towards mouse
- Creating an accurate metronome with python and Qt
- recv() function too slow
- Pygame: allow clicks to go through the window
- how to detect if the sprite has been clicked in py
If I understood the question correctly, you need a single button that changes the look every time you click on it, and changes its relative function accordingly.
You should be able to solve your problem by creating a class that takes two list and a counter
1) list of images
2) list of functions
3) the counter tells you which image/function is selected.
The functions needs to be built in the class, but you can provide the image that you want in the class argument (actually, you could pass them as arguments, but I don't think is worth it).
Here is the code, I commented some lines with their intended meaning (in line comments)
Example
Example using class - to create many buttons