Python Forum
[PyGame] Button class still not working?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Button class still not working?
#2
You shouldnt have two main game loops like that. Here is an example using buttons between states. Notice there is only one while loop in the entire code regardless of the number of states. Classes are a fundamental part of python. I would learn that before trying to program games to be honest.

You are not using the button's event check correctly. It needs to be within the main loop's event check.

from this:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
    studentButton.getEvent()
    teacherButton.getEvent()
to this:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        studentButton.getEvent()
        teacherButton.getEvent()
Recommended Tutorials:
Reply


Messages In This Thread
Button class still not working? - by mzmingle - Jan-16-2019, 10:56 AM
RE: Button class still not working? - by metulburr - Jan-16-2019, 01:09 PM
RE: Button class still not working? - by Windspar - Jan-16-2019, 04:10 PM
RE: Button class still not working? - by metulburr - Jan-16-2019, 04:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Can't get button class to work mzmingle 3 3,404 Nov-26-2018, 10:06 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020