Code: Select all
if ballclicked >= 0 and y >=100 and y < 100+ball_h:
ball_kill(ballclicked)
bcolor = renpy.random.randint(0,ballcolors-1)
balls_color.append(bcolor)
balls_sprites.append(balls.create(ballpic[bcolor]))
balls_sprites[number_balls-2].zorder = 1
balls_sprites[number_balls-1].zorder = 0
balls_sprites[number_balls-1].y = 100
balls_sprites[number_balls-1].x = ball_xoffset+(number_balls-1)*ball_w
ballclicked is a theoretical ball that was clicked, calculated using mouse coordinates. The game then checks whether there is actually a ball to be clicked at that position.
If there is one, delete it (first line of the block) and then create another ball at the end of the line.
When there is a vacancy, all balls to the right of it are moved left so to make room for a new ball on the right. This happens in the update function.
Now I want the new ball to appear BEHIND the old rightmost ball so I manipulate the zorder of the rightmost ball and the one left to it, but it does nothing. The new ball seemingly randomly appears in front or behind the old ball and I don't get why.