java游戏开发入门(二) - 菜单
生活随笔
收集整理的這篇文章主要介紹了
java游戏开发入门(二) - 菜单
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
java游戲開發入門(二) - 菜單
- 前言
- 編碼
- 主菜單
- 游戲內菜單(按下ESC后出現,并會暫停游戲)
- 效果展示
- 主菜單
- 游戲內菜單
- 完整代碼
- 完整項目
前言
??上一章我們創建了一個600x600的窗體,這章我們在此基礎上創建游戲菜單,游戲引擎自帶了一套菜單UI供我們使用,如果想要更好看的菜單,之后我們會有自定義菜單。
編碼
主菜單
settings.setMainMenuEnabled(true);游戲內菜單(按下ESC后出現,并會暫停游戲)
settings.setGameMenuEnabled(true);效果展示
主菜單
游戲內菜單
完整代碼
import com.almasb.fxgl.app.GameApplication; import com.almasb.fxgl.app.GameSettings;/*** @author lhDream*/ public class HelloWorldApp extends GameApplication {@Overrideprotected void initSettings(GameSettings settings) {settings.setTitle("Hello world");settings.setWidth(600);settings.setHeight(600);settings.setMainMenuEnabled(true);settings.setGameMenuEnabled(true);}/*** main 程序的開始* @param args 參數*/public static void main(String[] args) {launch(args);} }完整項目
https://github.com/lhDream/lhDreamGameDemo/tree/master/HelloWorld
總結
以上是生活随笔為你收集整理的java游戏开发入门(二) - 菜单的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows Terminal 安装
- 下一篇: 赛门铁克推出增强版存储优化套装软件