我正在嘗試在 Ursina Engine 中為我的游戲制作暫停選單,但我無法找到有關函式 pause() 的作業原理或操作方法的資訊。
有人能幫我嗎?
uj5u.com熱心網友回復:
ursina 中已經實作了暫停。只需設定application.paused為 True 或 False。application.pause()并且application.resume()做同樣的事情。
from ursina import *
app = Ursina()
# Make a simple game so we have something to test with
from ursina.prefabs.first_person_controller import FirstPersonController
player = FirstPersonController(gravity=0, model='cube', color=color.azure)
camera.z = -10
ground = Entity(model='plane', texture='grass', scale=10)
# Create an Entity for handling pausing an unpausing.
# Make sure to set ignore_paused to True so the pause handler itself can still recieve input while the game is paused.
pause_handler = Entity(ignore_paused=True)
pause_text = Text('PAUSED', origin=(0,0), scale=2, enabled=False) # Make a Text saying "PAUSED" just to make it clear when it's paused.
def pause_handler_input(key):
if key == 'escape':
application.paused = not application.paused # Pause/unpause the game.
pause_text.enabled = application.paused # Also toggle "PAUSED" graphic.
pause_handler.input = pause_handler_input # Assign the input function to the pause handler.
app.run()
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/479024.html
標籤:Python python-3.x python-2.7 暂停 小熊座
