我试图改变我的游戏菜单的背景。但我似乎找不到一种方法来使用kivy插件。在
这是我的.kv文件。在
ScreenManagement :
transition : FadeTransition()
MainMenu :
ThemeMenu :
<MainMenu> :
name : 'main'
Label :
size_hint : 1 , 1
Rectangle:
pos: self.pos
size: self.size
source: 'Background.jpeg'
Button :
id : 'Play'
background_normal : 'Play button.png'
background_down : 'Play Button - Press.png'
size_hint : 0.3 , 0.85
pos_hint : {'x' : 0.04 , 'y' : 0.03}
on_release : app.clickfx()
Button :
background_normal : 'Theme button.png'
background_down : 'Themes button - Press.png'
size_hint : 0.6 , 0.42
pos_hint : {'x' : 0.35 , 'y' : 0.46}
on_release : app.root.current = 'theme'
on_release : app.clickfx()
Button :
background_normal : 'Setting button.png'
background_down : 'Settings button - Press.png'
size_hint : 0.295 , 0.42
pos_hint : {'x' : 0.35 , 'y' : 0.03}
on_release : app.clickfx()
Button :
background_normal : 'About button.png'
background_down : 'Abouts button - Press.png'
size_hint : 0.295 , 0.42
pos_hint : {'x' : 0.655 , 'y' : 0.03}
on_release : app.clickfx()
Image :
source : 'Header.png'
size_hint : 1.2 , 1
pos_hint : {'x' : -0.1, 'y' : 0.51}
Image :
source : 'Pong X.png'
size_hint : 0.1 , 0.1
pos_hint : {'x' : 0.005 , 'y' : 0.92 }
<ThemeMenu> :
name : 'theme'
感谢任何帮助:D
解决方案
要更改屏幕的背景,在kv文件中,使用}。有关详细信息,请参阅下面的片段。在
canvas.before:
、Rectangle:
和{设置背景图像
屏幕管理器
在
<MainMenu>:
中,将app.root.current
替换为root.manager.current
Screen's default property manager
输出
相关问题 更多 >
编程相关推荐