0

I came across this problem in pygame. Let say I've 3 different page(frame), 1 is called menu, 1 called highscore the other is called game. In my menu frame, I've a button called start, which will brings me to game frame. This is the coordinate:

 button("Start",340,510,115,40,lightYellow, blue, action = "Start")

In my highscore frame, I've a button called back, which will brings me back to the menu frame. This is the coordinate:

button("Back",340,510,115,40,white,blue, action = "Menu")

When I'm running this code, I realise that the coordinate will override each other. Which mean that when I'm in highscore frame, and click on the "back" button, by right, it should bring me to the menu frame instead. However, this isn't the case; it brought me to game frame.

Just wondering, is it that in pygame, buttons cannot shared the same coordinate although they are in different frame? Is there a way to resolve this issue instead of changing to different coordinate.

I understand that in Pygame, there isn't "button", the button I meant was the rectangle that I render.

stack
  • 414
  • 1
  • 7
  • 21
  • This is very easly solved, when you are in the menu frame only check collision with menu buttons, and when in game frame, only with the game frame buttons and so on. – Fredrik Mar 12 '16 at 07:39
  • meaning? do you have sample code to share? – stack Mar 12 '16 at 08:14
  • What is it you don't understand? If you are in the menu only check if that button is clicked – Fredrik Mar 12 '16 at 08:17
  • We will not be able to help you without more sourcecode, I am however sure that this is not a pygame related issue, but rather one related to your code. – xXliolauXx Mar 13 '16 at 14:10

0 Answers0