一键导入
handling-user-input
Game will always use the same control scheme/buttons and mapping of the gamepad and keyboard. Use when creating or modifying a game.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Game will always use the same control scheme/buttons and mapping of the gamepad and keyboard. Use when creating or modifying a game.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Enforces data governance by verifying Knowledge Catalog Aspects before recommending BigQuery tables.
Ensures the game has a fun easter egg that turns the screen black and white, sepia or gameboy monotone colours. Use when creating or modifying a game.
Ensures platformer games have polished movement, responsive controls, and balanced jump mechanics. Use ONLY when the game type is "platformer".
Guides the creation of a new game and is the high-level orchestrator skill that MUST be invoked first. Use when tasked with creating a new game.
Arcade game must have a retro asthetic. Use when creating or modifying a game to ensure that the game looks retro and maintains a consistent look and feel with all games.
Helps the user make or modify a game. Use when the user wants to create a new game or modify an existing one.
| name | handling-user-input |
| description | Game will always use the same control scheme/buttons and mapping of the gamepad and keyboard. Use when creating or modifying a game. |
When creating or modifying a game:
update(), implement the virtual gamepad adapter wrapper to remap the inputs transparently so game logic and tutorial text can refer to semantic buttons (e.g. pad.A) correctly:create() {
// rest of function
this.initGamePad();
}
initGamePad() {
this.input.gamepad.start();
this.activeGamepad = null;
// 1. Check for gamepads ALREADY connected before the game booted
if (this.input.gamepad.total > 0) {
// Grab the first available valid gamepad from Phaser's manager
this.activeGamepad = this.input.gamepad.gamepads.find(pad => pad !== null);
if (this.activeGamepad) {
console.log(`Found pre-connected gamepad: ${this.activeGamepad.id}`);
}
}
// 2. Fallback listener for gamepads plugged in AFTER the game started
this.input.gamepad.on('connected', (pad) => {
// Only assign it if we don't already have an active gamepad
if (!this.activeGamepad) {
this.activeGamepad = pad;
console.log(`Gamepad plugged in mid-game: ${pad.id}`);
}
});
}
update() {
const rawPad = this.activeGamepad;
// Remap hardware wiring inversion where physical face buttons are swapped:
// Physical wiring: B=0, A=1, Y=2, X=3, Home=8, Restart=9
// Standard Web Gamepad API: A=0, B=1, X=2, Y=3
const pad = rawPad ? {
...rawPad,
A: rawPad.B,
B: rawPad.A,
X: rawPad.Y,
Y: rawPad.X,
isButtonDown: (index) => {
if (index === 0) return rawPad.isButtonDown(1);
if (index === 1) return rawPad.isButtonDown(0);
if (index === 2) return rawPad.isButtonDown(3);
if (index === 3) return rawPad.isButtonDown(2);
return rawPad.isButtonDown(index);
},
left: rawPad.left,
right: rawPad.right,
up: rawPad.up,
down: rawPad.down,
axes: rawPad.axes,
buttons: rawPad.buttons
} : null;
// rest of function
}
X and physical Button B sends key Z. When polling primary fire actions for Button A in keyboard environments, check this.keys.x instead of this.keys.z.The game's config.json, found in the game's root folder (e.g. <game-folder>/config.json) contains a controls section that defines the labels for buttons A, B, X, and Y. These arew the only 4 buttons allowed in the config.
When the game is created or modified, this config.json file should be updated to reflect the correct labels for each button. For example, if a code edit adds business logic so that the B enables the player to jump, set the label to "Jump". Labels must be short and limited to one word, or two words at most and MUST be an action (e.g. "Jump", "Run", "Fire", "Crawl", "Climb", etc.). There is limited space where the label will render in the UI so it must remain short.
If useful to explain the game's objective, the objective may be improved to include the new behavior.
Example:
{
"title": "Space Pilot",
"objective": "Navigate your spaceship while evading obstacles. Destroy them for points.",
"controls": {
"A": "Shoot",
"B": "Evade",
"X": "Roll Ship",
"Y": ""
}
}