Hey all,
I'm pretty new to this iPhone coding gig so apologies if this is a bit of a newbie question!
So here is the problem:
I have 2 players - Player 1 and Player 2. At any one point I want one of them marked as 'Active'. Then I have two buttons - the first button 'point' gives one point to whichever player is 'active'. The other button 'endturn' swaps the active player and gives the new active player a point. To explain that better:
- Player 1 is active - he wins and so I press 'point' and Player 1 gets the point
- On the next round Player 2 wins so I press the 'endturn' button instead. That gives Player 2 a point and makes Player 2 active. Now if the 'point' button is pressed Player 2 should get the points.
So far I have defined the two buttons and two score labels, and I can get the buttons to score each player separately, but I can't seem to figure out how to declare a player as 'active' and therefore make the points button give points to them. Any thoughts? I'm guessing I need to define a variable called 'active' and use some kind of if statement to check if 'active' is set to player 1 or 2, and then get the points button to write to the appropriate score, and then define a separate function which swops the active variable to the other player - the problem is I'm not exactly sure how to do that!
Any help would be greatly appreciated!
I'm pretty new to this iPhone coding gig so apologies if this is a bit of a newbie question!
So here is the problem:
I have 2 players - Player 1 and Player 2. At any one point I want one of them marked as 'Active'. Then I have two buttons - the first button 'point' gives one point to whichever player is 'active'. The other button 'endturn' swaps the active player and gives the new active player a point. To explain that better:
- Player 1 is active - he wins and so I press 'point' and Player 1 gets the point
- On the next round Player 2 wins so I press the 'endturn' button instead. That gives Player 2 a point and makes Player 2 active. Now if the 'point' button is pressed Player 2 should get the points.
So far I have defined the two buttons and two score labels, and I can get the buttons to score each player separately, but I can't seem to figure out how to declare a player as 'active' and therefore make the points button give points to them. Any thoughts? I'm guessing I need to define a variable called 'active' and use some kind of if statement to check if 'active' is set to player 1 or 2, and then get the points button to write to the appropriate score, and then define a separate function which swops the active variable to the other player - the problem is I'm not exactly sure how to do that!
Any help would be greatly appreciated!