用 Story 寫劇情, 用 JavaScript 加功能。 角色、選項和對話介面都有範例,不用從空白畫面開始。
Try it out
安裝、建立專案、啟動預覽。
Terminal命令列範例
npm install -g @prismatix/cliprismatix create my-gameprismatix dev my-game需要 Node.js 與包含對應 runtime 的 CLI 套件。0.2.0 目前的文件依據是候選版;安裝前先看套件狀態。
不用先學 C++。
打開 Story/main.pxstory 就能改台詞。接著學會安排分支、切換立繪, 再把範本換成自己的角色與素材。
寫第一個故事從台詞,到自訂玩法。
Story 負責劇情,UI 決定畫面,Extension 處理額外的遊戲邏輯。需要哪一部分,再往下加。
*start
[show guide expression=smile position=center]
@guide
今晚想先做什麼?
[choice text="看看星星" goto=stars]
[choice text="聽個故事" goto=story]
[choice.wait]
*stars
第一顆星亮了起來。
[jump target=finish]
*story
桌上的書翻開了新的一頁。
*finish
[end]/** @jsxImportSource @prismatix/authoring-sdk */
import { Scene, VBox, Text, Button } from '@prismatix/authoring-sdk';
export default (
<Scene name="Title" width={1280} height={720}>
<VBox name="Root" fill>
<Text name="Heading">First Light</Text>
<Button name="Start" size={[240, 64]} action="game.start">
開始遊戲
</Button>
</VBox>
</Scene>
);import { createPrismatiXContext, defineCommand } from '@prismatix/runtime';
const ctx = createPrismatiXContext();
defineCommand<{ message: string }>('tutorial.note', async ({ message }) => {
ctx.raw.log('tutorial.note', message);
await ctx.time.wait(0.2);
});
// 在 .pxextension 宣告 tutorial.note,再從 Story 呼叫:
// [tutorial.note message="Hello from the extension"]介面,不必長得一樣。
從預設的對話框開始,逐步換掉標題、按鈕和存檔畫面。JSON 和 TSX 都能用來編寫 UI。
UI 與 Action需要更多,再加進來。
用 Runtime API 控制聲音、動畫與畫面效果,或替遊戲加入計分和進度記錄。Extension 在 Player 內的 QuickJS 執行。
查看 Runtime API寫故事、試玩、打包。
第一句,要寫什麼?
建立專案,打開故事檔。從那裡開始。