2
我改變了小部件的顏色保持pong遊戲的分數,但是一旦我點擊開始玩遊戲,球的顏色和槳的顏色也會改變。球和槳從白色開始,我想讓它們保持白色。標籤顏色改變其他標籤
#:kivy 1.8.0
<PongBall>:
size: 30,30
canvas:
Ellipse:
pos: self.pos
size: self.size
<PongPaddle>:
size: 100, 15
canvas:
Rectangle:
pos: self.pos
size: self.size
<PongGame>:
ball: pong_ball
player1: player_bottom
test_text: test_text
canvas:
Color:
rgb: (1, 1, 1)
Rectangle:
pos: 0, self.height-30
size: self.width, 30
Label:
font_size: 30
center_x: 30
top: root.top
text: str(root.player1.score)
color: 1,0,0,1
Label:
id: test_text
font_size: 60
center_x: root.width/2
top: root.top-(root.top - (root.top/2))/2
text: 'Tap to Play!'
PongBall:
id: pong_ball
center: self.parent.center
PongPaddle:
id: player_bottom
x: root.center_x
center_y: root.y+self.height
太棒了,謝謝。這工作。有沒有其他方法可以解決這個問題?如果我想添加一些不同的東西並使其變藍,該怎麼辦? – FortuneFaded
@ user3587392,我在我的答案中增加了一些額外的細節。 –
謝謝Padraic,所以基本上我必須爲每件事物設定顏色? – FortuneFaded