So, as the title states, I would like to find out how I am able to amend an existing sprite to a new colour/image, when I touch another Sprite on the iPad screen.
Specifically - this is part of the Connect-4 script I am trying to create. The way I have chosen to do the 'how to choose ones move' is comprised of an area with left and right arrows, and in between these arrows is the button that says 'make move'. So, as one presses the left or right arrows, another sprite moves one column at a time to the respective column in the space above the board where the player wishes to make the move. Once the player is happy with the column to move, they press the separate 'make move' sprite.
This then calls the code that fills the next empty space on the board for that column, and also calls a 'check if winning line' function.
However. what I also wish to do is once the 'make move' sprite has been pressed, the colour of the sprite in the space above the board changes to match the colour of the next player to go. I believe I have the logic sorted for this, but I can't for the life of me figure out how to change the sprites colour.
In the def setup(self) function I have defined the sprite as this;
# this will show current player above row selected
self.player = SpriteNode(self.turn_colour)
self.player.position = (player_x, player_y)
self.player.scale = 1.8
self.add_child(self.player)
and then in the def touch_began(self, touch) function, I have this;
if self.turn == 0:
self.turn_colour = ('emj:Red_Circle')
else:
self.turn_colour = ('emj:Blue_Circle')
self.player = SpriteNode(self.turn_colour)
# left button pressed, so insert code to move disc to left here
# right button pressed so insert code to move disc to right here
But unfortunately, this does not seem to amend the self.player sprite at all. Could someone advise please;
1 - if this is possible, and if so
2 - what is the correct syntax I should use, and
3 - which Pythonista game function I should place the code to do that
Any help greatly appreciated. More than happy to elaborate if needed. Many thanks.