Link zum aktuellen Blendfile: https://filehorst.de/d/dldndfvi
Scripts:
—-button.py—-
import bge
import startscreen
def ready():
cont = bge.logic.getCurrentController()
own = cont.owner
mouse_over = cont.sensors[‘MouseOver’]
highlight_visible()
def highlight_visible():
cont = bge.logic.getCurrentController()
own = cont.owner
mouse_over = cont.sensors[‘MouseOver’]
mouse_click = cont.sensors[‘MouseClick’]
scene = bge.logic.getCurrentScene()
highlight = scene.objects[‘Highlight’]
high_home = scene.objects[‘HighHome’].worldPosition
button_name = own.name
highlight.worldPosition = own.worldPosition
if mouse_over.hitObject != own:
highlight.worldPosition = high_home
if mouse_over.hitObject == own and mouse_click.positive:
highlight.worldPosition = high_home
startscreen.handle_button(button_name)
—-startscreen.py—-
import bge
scene = bge.logic.getCurrentScene()
start_button = scene.objects[‘StartButton’]
def handle_button(button_name):
if button_name == ‘StartButton’:
scene.objects[‘LadenLabel’]
scene.replace(‘Level’)
if button_name == ‘EndButton’:
bge.logic.endGame()
Source