Test für Buttonsounds und Images
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,4 +8,5 @@
|
||||
/build
|
||||
/user.db
|
||||
/.vs
|
||||
/.idea
|
||||
/SnakeTest.spec
|
||||
|
||||
27
SnakeTest.py
27
SnakeTest.py
@@ -319,6 +319,8 @@ class User_login:
|
||||
self.__btn = btn
|
||||
print(self.__btn)
|
||||
|
||||
|
||||
|
||||
class MyApp(ShowBase):
|
||||
|
||||
us = User.User
|
||||
@@ -331,6 +333,13 @@ class MyApp(ShowBase):
|
||||
def __init__(self):
|
||||
ShowBase.__init__(self) #Insantziert das Hauptfenster, diese stellen immer eine Instanz der ShowBase-Klasse dar
|
||||
|
||||
buttonImages = (
|
||||
self.loader.loadTexture("data/panda_example/UI/UIButton.png"),
|
||||
self.loader.loadTexture("data/panda_example/UI/UIButtonPressed.png"),
|
||||
self.loader.loadTexture("data/panda_example/UI/UIButtonHighlighted.png"),
|
||||
self.loader.loadTexture("data/panda_example/UI/UIButtonDisabled.png")
|
||||
)
|
||||
|
||||
def button_enter_pressed():
|
||||
print("Die Taste Enter wurde gedrückt!")
|
||||
#print(label_input.get())
|
||||
@@ -343,14 +352,16 @@ class MyApp(ShowBase):
|
||||
#Erstellt ein DialogFenster
|
||||
self.gameOverScreen = DirectDialog(frameSize = (-0.7, 0.7, -0.7, 0.7),
|
||||
fadeScreen = 0.4,
|
||||
relief = DGG.FLAT)
|
||||
relief = DGG.FLAT, frameTexture= "data/panda_example/UI/stoneFrame.png")
|
||||
|
||||
#Erstellt einen Button zum Parent-Dialogfenster
|
||||
self.btn = DirectButton(text = "Quit",
|
||||
command = self.quit,
|
||||
pos = (0.3, 0, -0.2),
|
||||
parent = self.gameOverScreen,
|
||||
scale = 0.09)
|
||||
scale = 0.09, frameTexture=buttonImages, relief=DGG.FLAT, frameSize = (-4, 4, -1, 1),
|
||||
clickSound = self.loader.loadSfx("data/panda_example/UIClick.ogg"))
|
||||
self.btn.setTransparency(True)
|
||||
|
||||
label_menu = DirectDialog(text="Hauptmenü", parent=self.gameOverScreen, scale = 1, pos=(0,0,0.5))
|
||||
if(us.checkuserdb() == False):
|
||||
@@ -368,7 +379,7 @@ class MyApp(ShowBase):
|
||||
u.setButtonObject(label_users)
|
||||
pos_button_y -= 0.2
|
||||
|
||||
#self.taskMgr.doMethodLater(0.2,self.exampleTask, "exampleTask") #Hängt einen zustäzlichen Task in den Taskmanager ein
|
||||
#self.taskMgr.doMethodLater(0.8,self.exampleTask, "exampleTask") #Hängt einen zustäzlichen Task in den Taskmanager ein
|
||||
|
||||
self.gameOverScreen.show()
|
||||
|
||||
@@ -421,16 +432,18 @@ class MyApp(ShowBase):
|
||||
#self.us.__del__(self.us)
|
||||
app.finalizeExit()
|
||||
|
||||
|
||||
#Dieser Task wird bei Berechnungs jeden Frames ausgeführt
|
||||
"""
|
||||
|
||||
x=0
|
||||
def exampleTask(self, task):
|
||||
self.btn['text'] = "Woscht" + str(self.x)
|
||||
if(self.x==200):
|
||||
print("Ich laufe im Hintergrund!\n")
|
||||
if(self.x==100):
|
||||
return task.done
|
||||
self.x +=1
|
||||
return task.again
|
||||
"""
|
||||
|
||||
app = MyApp()
|
||||
app.run()
|
||||
|
||||
#TODO Änderungen
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 734 KiB After Width: | Height: | Size: 867 KiB |
BIN
data/panda_example/UIClick.ogg
Normal file
BIN
data/panda_example/UIClick.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user