@playcraft/skills 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/skills.loader.d.ts +31 -0
- package/dist/src/skills.loader.d.ts.map +1 -0
- package/dist/src/skills.loader.js +200 -0
- package/dist/src/skills.loader.js.map +1 -0
- package/dist/src/skills.types.d.ts +44 -0
- package/dist/src/skills.types.d.ts.map +1 -0
- package/dist/src/skills.types.js +9 -0
- package/dist/src/skills.types.js.map +1 -0
- package/package.json +35 -0
- package/skills/2048_core.aigameplay/SKILL.md +123 -0
- package/skills/2048_core.aigameplay/manifest.json +159 -0
- package/skills/2048_core.aigameplay/ref/pgs-schema.json +194 -0
- package/skills/2048_core.aigameplay/ref/reducer.template.ts +189 -0
- package/skills/SKILL.md +46 -0
- package/skills/ad_compliance_rules.aiconfig/SKILL.md +85 -0
- package/skills/ad_compliance_rules.aiconfig/manifest.json +60 -0
- package/skills/agent_remix_orchestrator.aicomponent/SKILL.md +257 -0
- package/skills/agent_remix_orchestrator.aicomponent/manifest.json +12 -0
- package/skills/app_metadata.aiconfig/SKILL.md +53 -0
- package/skills/app_metadata.aiconfig/manifest.json +32 -0
- package/skills/appear_sfx.aiaudio/SKILL.md +59 -0
- package/skills/appear_sfx.aiaudio/manifest.json +45 -0
- package/skills/appear_sfx.aiaudio/ref/appear.mp3 +0 -0
- package/skills/arrow_move_error_sfx.aiaudio/SKILL.md +59 -0
- package/skills/arrow_move_error_sfx.aiaudio/manifest.json +45 -0
- package/skills/arrow_move_error_sfx.aiaudio/ref/arrow_move_error.mp3 +0 -0
- package/skills/arrow_path_data_format.aicomponent/SKILL.md +152 -0
- package/skills/arrow_path_data_format.aicomponent/manifest.json +57 -0
- package/skills/arrow_path_data_format.aicomponent/ref/LevelParser.ts +188 -0
- package/skills/arrow_path_data_format.aicomponent/ref/LevelTypes.ts +131 -0
- package/skills/arrow_pick_match_rules.aigameplay/SKILL.md +117 -0
- package/skills/arrow_pick_match_rules.aigameplay/manifest.json +105 -0
- package/skills/arrow_pick_match_rules.aigameplay/ref/pgs-schema.json +180 -0
- package/skills/asset_pipeline_scripts.aicomponent/SKILL.md +117 -0
- package/skills/asset_pipeline_scripts.aicomponent/manifest.json +17 -0
- package/skills/asset_pipeline_scripts.aicomponent/ref/gen-sprite.sh +105 -0
- package/skills/ball_sort.aigameplay/SKILL.md +109 -0
- package/skills/ball_sort.aigameplay/manifest.json +155 -0
- package/skills/ball_sort.aigameplay/ref/pgs-schema.json +192 -0
- package/skills/ball_sort.aigameplay/ref/reducer.template.ts +156 -0
- package/skills/basketball_shot.aigameplay/SKILL.md +94 -0
- package/skills/basketball_shot.aigameplay/manifest.json +150 -0
- package/skills/basketball_shot.aigameplay/ref/pgs-schema.json +229 -0
- package/skills/basketball_shot.aigameplay/ref/reducer.template.ts +189 -0
- package/skills/bg_music.aiaudio/SKILL.md +61 -0
- package/skills/bg_music.aiaudio/manifest.json +48 -0
- package/skills/bg_music.aiaudio/ref/bg.mp3 +0 -0
- package/skills/big_watermelon.aigameplay/SKILL.md +94 -0
- package/skills/big_watermelon.aigameplay/manifest.json +155 -0
- package/skills/big_watermelon.aigameplay/ref/pgs-schema.json +191 -0
- package/skills/big_watermelon.aigameplay/ref/reducer.template.ts +202 -0
- package/skills/block_puzzle.aigameplay/SKILL.md +121 -0
- package/skills/block_puzzle.aigameplay/manifest.json +154 -0
- package/skills/block_puzzle.aigameplay/ref/pgs-schema.json +170 -0
- package/skills/block_puzzle.aigameplay/ref/reducer.template.ts +182 -0
- package/skills/board_entity_sprite.aiimage/SKILL.md +255 -0
- package/skills/board_entity_sprite.aiimage/manifest.json +153 -0
- package/skills/board_entity_sprite.aiimage/ref/ProceduralCar.ts +357 -0
- package/skills/board_entity_sprite.aiimage/ref/car.png +0 -0
- package/skills/board_entity_sprite.aiimage/ref/car.webp +0 -0
- package/skills/bottom_ui_bar.aicomponent/SKILL.md +50 -0
- package/skills/bottom_ui_bar.aicomponent/manifest.json +31 -0
- package/skills/bottom_ui_bar.aicomponent/ref/GameBottomUI.ts +27 -0
- package/skills/bubble_shooter.aigameplay/SKILL.md +129 -0
- package/skills/bubble_shooter.aigameplay/manifest.json +181 -0
- package/skills/bubble_shooter.aigameplay/ref/pgs-schema.json +226 -0
- package/skills/bubble_shooter.aigameplay/ref/reducer.template.ts +228 -0
- package/skills/button_click_sfx.aiaudio/SKILL.md +59 -0
- package/skills/button_click_sfx.aiaudio/manifest.json +45 -0
- package/skills/button_click_sfx.aiaudio/ref/button_click.mp3 +0 -0
- package/skills/calm_piano.aiaudio/SKILL.md +68 -0
- package/skills/calm_piano.aiaudio/manifest.json +50 -0
- package/skills/camera_controller_3d.aicomponent/SKILL.md +100 -0
- package/skills/camera_controller_3d.aicomponent/manifest.json +52 -0
- package/skills/camera_controller_3d.aicomponent/ref/CameraController.ts +199 -0
- package/skills/camera_controller_3d.aicomponent/ref/OrbitControlsAdapter.ts +152 -0
- package/skills/candy_tile.aiimage/SKILL.md +62 -0
- package/skills/candy_tile.aiimage/manifest.json +49 -0
- package/skills/car_parking.aigameplay/SKILL.md +105 -0
- package/skills/car_parking.aigameplay/manifest.json +164 -0
- package/skills/car_parking.aigameplay/ref/pgs-schema.json +163 -0
- package/skills/car_parking.aigameplay/ref/reducer.template.ts +166 -0
- package/skills/castle.aiimage/SKILL.md +64 -0
- package/skills/castle.aiimage/manifest.json +48 -0
- package/skills/cheerful_ukulele.aiaudio/SKILL.md +72 -0
- package/skills/cheerful_ukulele.aiaudio/manifest.json +50 -0
- package/skills/click_sfx.aiaudio/SKILL.md +59 -0
- package/skills/click_sfx.aiaudio/manifest.json +45 -0
- package/skills/click_sfx.aiaudio/ref/click.mp3 +0 -0
- package/skills/combo_display.aicomponent/SKILL.md +45 -0
- package/skills/combo_display.aicomponent/manifest.json +31 -0
- package/skills/combo_display.aicomponent/ref/ComboManager.ts +362 -0
- package/skills/combo_display.aicomponent/ref/ComboSmallUI.ts +232 -0
- package/skills/combo_praise_text.aicomponent/SKILL.md +56 -0
- package/skills/combo_praise_text.aicomponent/manifest.json +34 -0
- package/skills/combo_praise_text.aicomponent/ref/ComboManager.ts +362 -0
- package/skills/countdown_timer.aicomponent/SKILL.md +44 -0
- package/skills/countdown_timer.aicomponent/manifest.json +35 -0
- package/skills/countdown_timer.aicomponent/ref/CountdownDisplay.ts +213 -0
- package/skills/cta_platform_config.aiconfig/SKILL.md +72 -0
- package/skills/cta_platform_config.aiconfig/manifest.json +56 -0
- package/skills/debug_overlay.aicomponent/SKILL.md +75 -0
- package/skills/debug_overlay.aicomponent/manifest.json +17 -0
- package/skills/debug_overlay.aicomponent/ref/DebugOverlay.ts +144 -0
- package/skills/desert.aiimage/SKILL.md +63 -0
- package/skills/desert.aiimage/manifest.json +49 -0
- package/skills/difficulty_curve_designer.aiconfig/SKILL.md +68 -0
- package/skills/difficulty_curve_designer.aiconfig/manifest.json +36 -0
- package/skills/digit_renderer.aicomponent/SKILL.md +43 -0
- package/skills/digit_renderer.aicomponent/manifest.json +25 -0
- package/skills/digit_renderer.aicomponent/ref/DigitRenderer.ts +237 -0
- package/skills/download_button.aicomponent/SKILL.md +44 -0
- package/skills/download_button.aicomponent/manifest.json +25 -0
- package/skills/download_button.aicomponent/ref/DownloadButton.ts +137 -0
- package/skills/draw_line_puzzle.aigameplay/SKILL.md +84 -0
- package/skills/draw_line_puzzle.aigameplay/manifest.json +152 -0
- package/skills/draw_line_puzzle.aigameplay/ref/pgs-schema.json +189 -0
- package/skills/draw_line_puzzle.aigameplay/ref/reducer.template.ts +194 -0
- package/skills/easy_to_hard.aiconfig/SKILL.md +52 -0
- package/skills/easy_to_hard.aiconfig/manifest.json +33 -0
- package/skills/eight_ball_pool.aigameplay/SKILL.md +104 -0
- package/skills/eight_ball_pool.aigameplay/manifest.json +152 -0
- package/skills/eight_ball_pool.aigameplay/ref/pgs-schema.json +205 -0
- package/skills/eight_ball_pool.aigameplay/ref/reducer.template.ts +198 -0
- package/skills/energetic_electronic.aiaudio/SKILL.md +69 -0
- package/skills/energetic_electronic.aiaudio/manifest.json +51 -0
- package/skills/fail_sfx.aiaudio/SKILL.md +59 -0
- package/skills/fail_sfx.aiaudio/manifest.json +44 -0
- package/skills/fail_sfx.aiaudio/ref/fail.mp3 +0 -0
- package/skills/figer_icon.aiimage/SKILL.md +58 -0
- package/skills/figer_icon.aiimage/manifest.json +48 -0
- package/skills/figer_icon.aiimage/ref/figer.png +0 -0
- package/skills/figer_icon.aiimage/ref/figer.webp +0 -0
- package/skills/forest.aiimage/SKILL.md +74 -0
- package/skills/forest.aiimage/manifest.json +48 -0
- package/skills/fruit_tile.aiimage/SKILL.md +68 -0
- package/skills/fruit_tile.aiimage/manifest.json +48 -0
- package/skills/game_over_panel.aicomponent/SKILL.md +47 -0
- package/skills/game_over_panel.aicomponent/manifest.json +61 -0
- package/skills/game_over_panel.aicomponent/ref/GameOverPanel.ts +74 -0
- package/skills/game_scene.aicomponent/SKILL.md +57 -0
- package/skills/game_scene.aicomponent/manifest.json +36 -0
- package/skills/game_scene.aicomponent/ref/Game.ts +748 -0
- package/skills/gameplay_balance_check.aivalidator/SKILL.md +69 -0
- package/skills/gameplay_balance_check.aivalidator/manifest.json +21 -0
- package/skills/gameplay_unit_test.aivalidator/SKILL.md +89 -0
- package/skills/gameplay_unit_test.aivalidator/manifest.json +17 -0
- package/skills/gameplay_unit_test.aivalidator/ref/gameplay.test.ts +202 -0
- package/skills/gameplay_unit_test.aivalidator/ref/vitest.config.ts +13 -0
- package/skills/grid_board_layout.aicomponent/SKILL.md +85 -0
- package/skills/grid_board_layout.aicomponent/manifest.json +69 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayout.ts +416 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayout3D.ts +125 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayoutMath.ts +85 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardRenderer3D.ts +298 -0
- package/skills/heart_lives.aicomponent/SKILL.md +42 -0
- package/skills/heart_lives.aicomponent/manifest.json +25 -0
- package/skills/heart_lives.aicomponent/ref/HeartDisplay.ts +96 -0
- package/skills/idle-breathe.aicomponent/SKILL.md +27 -0
- package/skills/idle-breathe.aicomponent/manifest.json +20 -0
- package/skills/idle-breathe.aicomponent/ref/phaser.js +25 -0
- package/skills/idle-breathe.aicomponent/ref/playcanvas.js +29 -0
- package/skills/jewel_tile.aiimage/SKILL.md +63 -0
- package/skills/jewel_tile.aiimage/manifest.json +49 -0
- package/skills/knife_hit.aigameplay/SKILL.md +103 -0
- package/skills/knife_hit.aigameplay/manifest.json +151 -0
- package/skills/knife_hit.aigameplay/ref/pgs-schema.json +202 -0
- package/skills/knife_hit.aigameplay/ref/reducer.template.ts +196 -0
- package/skills/left_right_parkour.aigameplay/SKILL.md +120 -0
- package/skills/left_right_parkour.aigameplay/manifest.json +165 -0
- package/skills/left_right_parkour.aigameplay/ref/pgs-schema.json +200 -0
- package/skills/left_right_parkour.aigameplay/ref/reducer.template.ts +194 -0
- package/skills/level_data_pack.aiconfig/SKILL.md +64 -0
- package/skills/level_data_pack.aiconfig/manifest.json +37 -0
- package/skills/level_data_validator.aivalidator/SKILL.md +85 -0
- package/skills/level_data_validator.aivalidator/manifest.json +17 -0
- package/skills/level_data_validator.aivalidator/ref/LevelValidator.ts +113 -0
- package/skills/level_lifecycle.aicomponent/SKILL.md +81 -0
- package/skills/level_lifecycle.aicomponent/manifest.json +87 -0
- package/skills/level_lifecycle.aicomponent/ref/LevelLifecycle.ts +235 -0
- package/skills/level_solvability_validator.aivalidator/SKILL.md +74 -0
- package/skills/level_solvability_validator.aivalidator/manifest.json +23 -0
- package/skills/level_solvability_validator.aivalidator/ref/LevelValidator.ts +186 -0
- package/skills/level_state.aicomponent/SKILL.md +55 -0
- package/skills/level_state.aicomponent/manifest.json +34 -0
- package/skills/level_state.aicomponent/ref/LevelDataManager.ts +26 -0
- package/skills/level_state.aicomponent/ref/LevelManager.ts +26 -0
- package/skills/loading_screen.aicomponent/SKILL.md +57 -0
- package/skills/loading_screen.aicomponent/manifest.json +43 -0
- package/skills/loading_screen.aicomponent/ref/LoadingUI.ts +339 -0
- package/skills/lose_result_panel.aiimage/SKILL.md +58 -0
- package/skills/lose_result_panel.aiimage/manifest.json +47 -0
- package/skills/lose_result_panel.aiimage/ref/lose.png +0 -0
- package/skills/lose_result_panel.aiimage/ref/lose.webp +0 -0
- package/skills/lose_sfx.aiaudio/SKILL.md +59 -0
- package/skills/lose_sfx.aiaudio/manifest.json +45 -0
- package/skills/lose_sfx.aiaudio/ref/lose.mp3 +0 -0
- package/skills/match-pop.aicomponent/SKILL.md +29 -0
- package/skills/match-pop.aicomponent/manifest.json +19 -0
- package/skills/match-pop.aicomponent/ref/phaser.js +30 -0
- package/skills/match-pop.aicomponent/ref/playcanvas.js +22 -0
- package/skills/match3_core.aigameplay/SKILL.md +125 -0
- package/skills/match3_core.aigameplay/manifest.json +107 -0
- package/skills/match3_core.aigameplay/ref/pgs-schema.json +154 -0
- package/skills/match3_core.aigameplay/ref/reducer.template.ts +191 -0
- package/skills/match_engine.aicomponent/SKILL.md +84 -0
- package/skills/match_engine.aicomponent/manifest.json +23 -0
- package/skills/match_engine.aicomponent/ref/MatchEngine.ts +75 -0
- package/skills/memory_match.aigameplay/SKILL.md +111 -0
- package/skills/memory_match.aigameplay/manifest.json +164 -0
- package/skills/memory_match.aigameplay/ref/pgs-schema.json +190 -0
- package/skills/memory_match.aigameplay/ref/reducer.template.ts +162 -0
- package/skills/merge_core.aigameplay/SKILL.md +112 -0
- package/skills/merge_core.aigameplay/manifest.json +154 -0
- package/skills/merge_core.aigameplay/ref/pgs-schema.json +202 -0
- package/skills/merge_core.aigameplay/ref/reducer.template.ts +179 -0
- package/skills/mistake_sfx.aiaudio/SKILL.md +59 -0
- package/skills/mistake_sfx.aiaudio/manifest.json +45 -0
- package/skills/mistake_sfx.aiaudio/ref/mistake.mp3 +0 -0
- package/skills/nomove_hint_overlay.aiimage/SKILL.md +58 -0
- package/skills/nomove_hint_overlay.aiimage/manifest.json +48 -0
- package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.png +0 -0
- package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.webp +0 -0
- package/skills/normal_dot.aiimage/SKILL.md +58 -0
- package/skills/normal_dot.aiimage/manifest.json +46 -0
- package/skills/normal_dot.aiimage/ref/normal_dot.png +0 -0
- package/skills/normal_dot.aiimage/ref/normal_dot.webp +0 -0
- package/skills/ocean.aiimage/SKILL.md +71 -0
- package/skills/ocean.aiimage/manifest.json +49 -0
- package/skills/particle-confetti.aicomponent/SKILL.md +32 -0
- package/skills/particle-confetti.aicomponent/manifest.json +21 -0
- package/skills/particle-confetti.aicomponent/ref/html5-spritesheet.js +17 -0
- package/skills/particle-confetti.aicomponent/ref/phaser.js +38 -0
- package/skills/particle-explosion.aicomponent/SKILL.md +37 -0
- package/skills/particle-explosion.aicomponent/manifest.json +24 -0
- package/skills/particle-explosion.aicomponent/ref/html5-spritesheet.js +40 -0
- package/skills/particle-explosion.aicomponent/ref/phaser.js +46 -0
- package/skills/particle-explosion.aicomponent/ref/playcanvas.js +33 -0
- package/skills/particle-trail.aicomponent/SKILL.md +25 -0
- package/skills/particle-trail.aicomponent/manifest.json +22 -0
- package/skills/particle-trail.aicomponent/ref/phaser.js +31 -0
- package/skills/path_animation.aicomponent/SKILL.md +82 -0
- package/skills/path_animation.aicomponent/manifest.json +77 -0
- package/skills/path_animation.aicomponent/ref/AnimationManager.ts +694 -0
- package/skills/path_animation.aicomponent/ref/AnimationManager3D.ts +317 -0
- package/skills/path_elimination_rules.aigameplay/SKILL.md +88 -0
- package/skills/path_elimination_rules.aigameplay/manifest.json +119 -0
- package/skills/path_elimination_rules.aigameplay/ref/pgs-schema.json +227 -0
- package/skills/path_input_handler.aicomponent/SKILL.md +87 -0
- package/skills/path_input_handler.aicomponent/manifest.json +97 -0
- package/skills/path_input_handler.aicomponent/ref/InputHandler.ts +714 -0
- package/skills/path_input_handler.aicomponent/ref/InputHandler3D.ts +204 -0
- package/skills/path_renderer.aicomponent/SKILL.md +101 -0
- package/skills/path_renderer.aicomponent/manifest.json +69 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderer.ts +509 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderer3D.ts +176 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderers.ts +640 -0
- package/skills/phaser.aicomponent/SKILL.md +315 -0
- package/skills/phaser.aicomponent/manifest.json +156 -0
- package/skills/phaser.aicomponent/ref/BootScene.ts +29 -0
- package/skills/phaser.aicomponent/ref/GameConfig.ts +29 -0
- package/skills/phaser.aicomponent/ref/GameScene.ts +88 -0
- package/skills/phaser.aicomponent/ref/PreloaderScene.ts +78 -0
- package/skills/phaser.aicomponent/ref/SceneKeys.ts +7 -0
- package/skills/phaser.aicomponent/ref/SoundUtils.ts +21 -0
- package/skills/phaser.aicomponent/ref/UiLayout.ts +74 -0
- package/skills/phaser.aicomponent/ref/globals.d.ts +52 -0
- package/skills/phaser.aicomponent/ref/index.css +40 -0
- package/skills/phaser.aicomponent/ref/index.html +14 -0
- package/skills/phaser.aicomponent/ref/index.ts +48 -0
- package/skills/phaser.aicomponent/ref/main.ts +16 -0
- package/skills/phaser.aicomponent/ref/package.json +22 -0
- package/skills/phaser.aicomponent/ref/tsconfig.json +25 -0
- package/skills/phaser.aicomponent/ref/webpack.config.js +57 -0
- package/skills/phaser_scene_lifecycle.aicomponent/SKILL.md +63 -0
- package/skills/phaser_scene_lifecycle.aicomponent/manifest.json +33 -0
- package/skills/pick_and_match_rules.aigameplay/SKILL.md +113 -0
- package/skills/pick_and_match_rules.aigameplay/manifest.json +121 -0
- package/skills/pick_and_match_rules.aigameplay/ref/pgs-schema.json +354 -0
- package/skills/pin_pull.aigameplay/SKILL.md +110 -0
- package/skills/pin_pull.aigameplay/manifest.json +164 -0
- package/skills/pin_pull.aigameplay/ref/pgs-schema.json +201 -0
- package/skills/pin_pull.aigameplay/ref/reducer.template.ts +216 -0
- package/skills/playable_app_logo.aiimage/SKILL.md +58 -0
- package/skills/playable_app_logo.aiimage/manifest.json +47 -0
- package/skills/playable_app_logo.aiimage/ref/logo.png +0 -0
- package/skills/playable_app_logo.aiimage/ref/logo.webp +0 -0
- package/skills/playable_end_screen_layout.aicomponent/SKILL.md +75 -0
- package/skills/playable_end_screen_layout.aicomponent/manifest.json +24 -0
- package/skills/playable_guidance_layer.aicomponent/SKILL.md +89 -0
- package/skills/playable_guidance_layer.aicomponent/manifest.json +24 -0
- package/skills/playable_hud_layout.aicomponent/SKILL.md +96 -0
- package/skills/playable_hud_layout.aicomponent/manifest.json +24 -0
- package/skills/playable_scripts_build.aicomponent/SKILL.md +69 -0
- package/skills/playable_scripts_build.aicomponent/manifest.json +53 -0
- package/skills/playable_scripts_build.aicomponent/ref/builds.config.js +257 -0
- package/skills/playcraft-3d-flip-sprite/SKILL.md +336 -0
- package/skills/playcraft-3d-flip-sprite/renderer/flatten_glb.mjs +62 -0
- package/skills/playcraft-3d-flip-sprite/renderer/render.mjs +325 -0
- package/skills/playcraft-3d-flip-sprite/renderer/render_single.mjs +138 -0
- package/skills/playcraft-asset-management/SKILL.md +73 -0
- package/skills/playcraft-audio-generation/SKILL.md +126 -0
- package/skills/playcraft-build/SKILL.md +44 -0
- package/skills/playcraft-code-editor/SKILL.md +71 -0
- package/skills/playcraft-create-remix/SKILL.md +62 -0
- package/skills/playcraft-deploy/SKILL.md +59 -0
- package/skills/playcraft-image-generation/SKILL.md +148 -0
- package/skills/playcraft-image-processing/SKILL.md +216 -0
- package/skills/playcraft-platform-intro/SKILL.md +41 -0
- package/skills/playcraft-prefab/SKILL.md +98 -0
- package/skills/playcraft-project-management/SKILL.md +57 -0
- package/skills/playcraft-remix-workflow/SKILL.md +119 -0
- package/skills/playcraft-remix-workflow/references/xplatform.schema.json5 +31 -0
- package/skills/playcraft-save/SKILL.md +46 -0
- package/skills/playcraft-skill-recommender/SKILL.md +152 -0
- package/skills/playcraft-sprite-generation/SKILL.md +534 -0
- package/skills/playcraft-sprite-remix/SKILL.md +155 -0
- package/skills/playcraft-sprite-sheet/SKILL.md +97 -0
- package/skills/playtest_report.aivalidator/SKILL.md +103 -0
- package/skills/playtest_report.aivalidator/manifest.json +21 -0
- package/skills/preloader_scene.aicomponent/SKILL.md +58 -0
- package/skills/preloader_scene.aicomponent/manifest.json +43 -0
- package/skills/preloader_scene.aicomponent/ref/Preloader.ts +339 -0
- package/skills/progress_bar.aicomponent/SKILL.md +38 -0
- package/skills/progress_bar.aicomponent/manifest.json +25 -0
- package/skills/progress_bar.aicomponent/ref/ProgressDisplay.ts +140 -0
- package/skills/references/xplatform.schema.json5 +31 -0
- package/skills/responsive_2d_layout.aicomponent/SKILL.md +161 -0
- package/skills/responsive_2d_layout.aicomponent/manifest.json +43 -0
- package/skills/responsive_2d_layout.aicomponent/ref/UiLayout.ts +56 -0
- package/skills/run_context_state.aicomponent/SKILL.md +54 -0
- package/skills/run_context_state.aicomponent/manifest.json +40 -0
- package/skills/run_context_state.aicomponent/ref/RunContextRuntime.ts +30 -0
- package/skills/score-fly.aicomponent/SKILL.md +31 -0
- package/skills/score-fly.aicomponent/manifest.json +21 -0
- package/skills/score-fly.aicomponent/ref/phaser.js +26 -0
- package/skills/score-fly.aicomponent/ref/playcanvas.js +28 -0
- package/skills/score_goal.aiconfig/SKILL.md +46 -0
- package/skills/score_goal.aiconfig/manifest.json +33 -0
- package/skills/screen-flash.aicomponent/SKILL.md +30 -0
- package/skills/screen-flash.aicomponent/manifest.json +20 -0
- package/skills/screen-flash.aicomponent/ref/phaser.js +48 -0
- package/skills/screen-shake.aicomponent/SKILL.md +30 -0
- package/skills/screen-shake.aicomponent/manifest.json +19 -0
- package/skills/screen-shake.aicomponent/ref/phaser.js +23 -0
- package/skills/screen-shake.aicomponent/ref/playcanvas.js +44 -0
- package/skills/screw_puzzle.aigameplay/SKILL.md +116 -0
- package/skills/screw_puzzle.aigameplay/manifest.json +164 -0
- package/skills/screw_puzzle.aigameplay/ref/pgs-schema.json +235 -0
- package/skills/screw_puzzle.aigameplay/ref/reducer.template.ts +213 -0
- package/skills/settings_state.aicomponent/SKILL.md +61 -0
- package/skills/settings_state.aicomponent/manifest.json +33 -0
- package/skills/settings_state.aicomponent/ref/SettingsManager.ts +130 -0
- package/skills/slide_out_to_tray_animation.aicomponent/SKILL.md +64 -0
- package/skills/slide_out_to_tray_animation.aicomponent/manifest.json +58 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager.ts +164 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager3D.ts +198 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/BezierUtils.ts +59 -0
- package/skills/slot_machine.aigameplay/SKILL.md +119 -0
- package/skills/slot_machine.aigameplay/manifest.json +166 -0
- package/skills/slot_machine.aigameplay/ref/pgs-schema.json +212 -0
- package/skills/slot_machine.aigameplay/ref/reducer.template.ts +212 -0
- package/skills/sniper_shot.aigameplay/SKILL.md +84 -0
- package/skills/sniper_shot.aigameplay/manifest.json +153 -0
- package/skills/sniper_shot.aigameplay/ref/pgs-schema.json +211 -0
- package/skills/sniper_shot.aigameplay/ref/reducer.template.ts +211 -0
- package/skills/solitaire.aigameplay/SKILL.md +101 -0
- package/skills/solitaire.aigameplay/manifest.json +151 -0
- package/skills/solitaire.aigameplay/ref/pgs-schema.json +200 -0
- package/skills/solitaire.aigameplay/ref/reducer.template.ts +176 -0
- package/skills/sound-effects/SKILL.md +46 -0
- package/skills/sound_utils.aicomponent/SKILL.md +52 -0
- package/skills/sound_utils.aicomponent/manifest.json +30 -0
- package/skills/sound_utils.aicomponent/ref/SoundUtils.ts +29 -0
- package/skills/sprite-animation-2d.aicomponent/SKILL.md +45 -0
- package/skills/sprite-animation-2d.aicomponent/manifest.json +28 -0
- package/skills/sprite-animation-2d.aicomponent/ref/html5.js +83 -0
- package/skills/sprite-animation-2d.aicomponent/ref/phaser.js +38 -0
- package/skills/sprite-animation-2d.aicomponent/ref/playcanvas.js +67 -0
- package/skills/sprite_entity_renderer.aicomponent/SKILL.md +148 -0
- package/skills/sprite_entity_renderer.aicomponent/manifest.json +17 -0
- package/skills/sprite_entity_renderer.aicomponent/ref/SpriteEntityRenderer.ts +126 -0
- package/skills/success_sfx.aiaudio/SKILL.md +59 -0
- package/skills/success_sfx.aiaudio/manifest.json +45 -0
- package/skills/success_sfx.aiaudio/ref/success.mp3 +0 -0
- package/skills/tap_blast.aigameplay/SKILL.md +116 -0
- package/skills/tap_blast.aigameplay/manifest.json +153 -0
- package/skills/tap_blast.aigameplay/ref/pgs-schema.json +208 -0
- package/skills/tap_blast.aigameplay/ref/reducer.template.ts +202 -0
- package/skills/theme_state.aicomponent/SKILL.md +53 -0
- package/skills/theme_state.aicomponent/manifest.json +33 -0
- package/skills/theme_state.aicomponent/ref/ThemeManager.ts +174 -0
- package/skills/theme_switcher_build.aicomponent/SKILL.md +62 -0
- package/skills/theme_switcher_build.aicomponent/manifest.json +38 -0
- package/skills/theme_switcher_build.aicomponent/ref/theme-index.ts +8 -0
- package/skills/theme_variant.aiconfig/SKILL.md +78 -0
- package/skills/theme_variant.aiconfig/manifest.json +39 -0
- package/skills/theme_variant.aiconfig/ref/ExampleTheme/index.ts +16 -0
- package/skills/theme_variant.aiconfig/ref/ExampleTheme/levelEasy.json +141 -0
- package/skills/threejs.aicomponent/SKILL.md +422 -0
- package/skills/threejs.aicomponent/manifest.json +166 -0
- package/skills/threejs.aicomponent/ref/AssetLoader.ts +158 -0
- package/skills/threejs.aicomponent/ref/BaseScene.ts +88 -0
- package/skills/threejs.aicomponent/ref/GameConfig.ts +47 -0
- package/skills/threejs.aicomponent/ref/MainScene.ts +170 -0
- package/skills/threejs.aicomponent/ref/PreloaderScene.ts +93 -0
- package/skills/threejs.aicomponent/ref/SceneKeys.ts +6 -0
- package/skills/threejs.aicomponent/ref/SceneManager.ts +69 -0
- package/skills/threejs.aicomponent/ref/ViewportManager.ts +62 -0
- package/skills/threejs.aicomponent/ref/globals.d.ts +74 -0
- package/skills/threejs.aicomponent/ref/index.css +80 -0
- package/skills/threejs.aicomponent/ref/index.html +20 -0
- package/skills/threejs.aicomponent/ref/index.ts +117 -0
- package/skills/threejs.aicomponent/ref/main.ts +10 -0
- package/skills/threejs.aicomponent/ref/package.json +23 -0
- package/skills/threejs.aicomponent/ref/tsconfig.json +24 -0
- package/skills/threejs.aicomponent/ref/webpack.config.js +61 -0
- package/skills/time_clear_goal.aiconfig/SKILL.md +46 -0
- package/skills/time_clear_goal.aiconfig/manifest.json +32 -0
- package/skills/time_icon.aiimage/SKILL.md +58 -0
- package/skills/time_icon.aiimage/manifest.json +47 -0
- package/skills/time_icon.aiimage/ref/time.png +0 -0
- package/skills/time_icon.aiimage/ref/time.webp +0 -0
- package/skills/top_ui_bar.aicomponent/SKILL.md +45 -0
- package/skills/top_ui_bar.aicomponent/manifest.json +27 -0
- package/skills/top_ui_bar.aicomponent/ref/GameTopUI.ts +229 -0
- package/skills/tower_defence.aigameplay/SKILL.md +117 -0
- package/skills/tower_defence.aigameplay/manifest.json +175 -0
- package/skills/tower_defence.aigameplay/ref/pgs-schema.json +247 -0
- package/skills/tower_defence.aigameplay/ref/reducer.template.ts +239 -0
- package/skills/tray_container.aicomponent/SKILL.md +143 -0
- package/skills/tray_container.aicomponent/manifest.json +58 -0
- package/skills/tray_container.aicomponent/ref/TrayRenderer.ts +155 -0
- package/skills/tray_container.aicomponent/ref/TrayRenderer3D.ts +281 -0
- package/skills/tray_container.aicomponent/ref/TrayRendererHtmlOverlay.ts +228 -0
- package/skills/tutorial_overlay.aicomponent/SKILL.md +46 -0
- package/skills/tutorial_overlay.aicomponent/manifest.json +34 -0
- package/skills/tutorial_overlay.aicomponent/ref/TutorialManager.ts +367 -0
- package/skills/tween-animation-2d.aicomponent/SKILL.md +35 -0
- package/skills/tween-animation-2d.aicomponent/manifest.json +28 -0
- package/skills/tween-animation-2d.aicomponent/ref/phaser.js +49 -0
- package/skills/tween-animation-2d.aicomponent/ref/playcanvas.js +36 -0
- package/skills/typescript_module_patterns.aicomponent/SKILL.md +209 -0
- package/skills/typescript_module_patterns.aicomponent/manifest.json +28 -0
- package/skills/typescript_module_patterns.aicomponent/ref/globals.d.ts +31 -0
- package/skills/ui-transition.aicomponent/SKILL.md +33 -0
- package/skills/ui-transition.aicomponent/manifest.json +19 -0
- package/skills/ui-transition.aicomponent/ref/phaser.js +45 -0
- package/skills/ux_flow_spec.aiconfig/SKILL.md +82 -0
- package/skills/ux_flow_spec.aiconfig/manifest.json +39 -0
- package/skills/wave_difficulty.aiconfig/SKILL.md +46 -0
- package/skills/wave_difficulty.aiconfig/manifest.json +33 -0
- package/skills/webpack_build.aicomponent/SKILL.md +204 -0
- package/skills/webpack_build.aicomponent/manifest.json +29 -0
- package/skills/webpack_build.aicomponent/ref/package.json +16 -0
- package/skills/webpack_build.aicomponent/ref/webpack.config.js +53 -0
- package/skills/win_anim_sfx.aiaudio/SKILL.md +59 -0
- package/skills/win_anim_sfx.aiaudio/manifest.json +46 -0
- package/skills/win_anim_sfx.aiaudio/ref/win_anim.mp3 +0 -0
- package/skills/win_dot.aiimage/SKILL.md +58 -0
- package/skills/win_dot.aiimage/manifest.json +47 -0
- package/skills/win_dot.aiimage/ref/win_dot.png +0 -0
- package/skills/win_dot.aiimage/ref/win_dot.webp +0 -0
- package/skills/win_result_panel.aiimage/SKILL.md +58 -0
- package/skills/win_result_panel.aiimage/manifest.json +47 -0
- package/skills/win_result_panel.aiimage/ref/win.png +0 -0
- package/skills/win_result_panel.aiimage/ref/win.webp +0 -0
- package/skills/word_connect.aigameplay/SKILL.md +86 -0
- package/skills/word_connect.aigameplay/manifest.json +154 -0
- package/skills/word_connect.aigameplay/ref/pgs-schema.json +212 -0
- package/skills/word_connect.aigameplay/ref/reducer.template.ts +186 -0
- package/src/index.ts +10 -0
- package/src/skills.loader.ts +225 -0
- package/src/skills.types.ts +42 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: phaser.aicomponent
|
|
3
|
+
description: Phaser 3 游戏引擎运行时 + 完整可运行空项目。提供 13 个文件:三场景生命周期(Boot→Preloader→Game)、自适应布局系统(750×1334 设计基准)、移动端适配(安全区/触摸/HiDPI)、音效工具。安装依赖后 `pnpm dev` 即可看到 Hello Phaser 画面。
|
|
4
|
+
triggers: 需要初始化一个新的 Phaser 试玩广告项目、添加游戏引擎基础层,或配置 Phaser 渲染器和 Scene 时触发。
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Phaser 3 游戏引擎(Phaser Engine + Complete Project Skeleton)
|
|
8
|
+
|
|
9
|
+
## 说明
|
|
10
|
+
|
|
11
|
+
本 skill 是所有其他 Phaser skill 的基础。它贡献的 **13 个文件**构成了一个**完整可运行的 Phaser 空项目**,开箱即用:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm install
|
|
15
|
+
pnpm dev # 开发模式 → 浏览器显示 "Hello Phaser!" + 布局参考信息
|
|
16
|
+
pnpm build # 构建产物
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**已内置的基础能力:**
|
|
20
|
+
|
|
21
|
+
- **三场景生命周期**:Boot(全局初始化)→ Preloader(进度条 + 资源加载)→ Game(主场景)
|
|
22
|
+
- **自适应布局系统**:`computeUiLayout()` 基于 750×1334 设计稿,计算 `uiScale` / `vScale` / `centerX` / `centerY`
|
|
23
|
+
- **移动端适配**:viewport meta(禁缩放)、安全区 padding、禁止选中/回弹/长按菜单、2× HiDPI 画布
|
|
24
|
+
- **音效工具**:`safePlaySound()` 封装安全音效播放
|
|
25
|
+
- **TypeScript 完整支持**:资源模块声明(`*.webp` / `*.mp3` 等)+ `__DEV__` 全局变量
|
|
26
|
+
|
|
27
|
+
**UI 布局数学**以 `responsive_2d_layout.aicomponent` 的 **SKILL.md 第一节 Layout Canon** 为规范原文;本 skill 的 `UiLayout.ts` 为该规范的 Phaser 绑定实现。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Scaffold
|
|
32
|
+
|
|
33
|
+
| 目标路径 | 来源 | 说明 |
|
|
34
|
+
|---------|-----|-----|
|
|
35
|
+
| `src/index.ts` | `ref/main.ts` | **webpack 入口**:import CSS → DOMContentLoaded → StartGame + resize reload |
|
|
36
|
+
| `src/index.html` | `ref/index.html` | **HTML 容器**:viewport meta + 安全区 + `#game-container` |
|
|
37
|
+
| `src/index.css` | `ref/index.css` | **全屏样式**:移动端适配、安全区 padding、禁止选中/回弹 |
|
|
38
|
+
| `globals.d.ts` | `ref/globals.d.ts` | **类型声明**:资源模块(图片/音频)+ `__DEV__` 全局 |
|
|
39
|
+
| `tsconfig.json` | `ref/tsconfig.json` | **TypeScript 配置**:target es5, moduleResolution bundler, paths assets/* |
|
|
40
|
+
| `src/game/index.ts` | `ref/index.ts` | **`StartGame(parent)`**:2× 设计分辨率 + Scale.FIT + 三场景注册 |
|
|
41
|
+
| `src/game/GameConfig.ts` | `ref/GameConfig.ts` | **游戏配置**:设计稿基准、UI 缩放范围、安全区、调试开关 |
|
|
42
|
+
| `src/game/SceneKeys.ts` | `ref/SceneKeys.ts` | **场景名枚举**:Boot / Preloader / Game |
|
|
43
|
+
| `src/game/scenes/BootScene.ts` | `ref/BootScene.ts` | **Boot 场景**:禁右键菜单 → 路由到 Preloader |
|
|
44
|
+
| `src/game/scenes/PreloaderScene.ts` | `ref/PreloaderScene.ts` | **Preloader 场景**:进度条 + Loading 文字 → 切到 Game |
|
|
45
|
+
| `src/game/scenes/GameScene.ts` | `ref/GameScene.ts` | **Game 场景**:Hello Phaser + 布局参考(十字线/安全区框/坐标信息) |
|
|
46
|
+
| `src/game/utils/UiLayout.ts` | `ref/UiLayout.ts` | **自适应布局**:`computeUiLayout()` — uiScale/vScale/centerX/centerY |
|
|
47
|
+
| `src/game/utils/SoundUtils.ts` | `ref/SoundUtils.ts` | **音效工具**:`safePlaySound()` — 缺失键静默返回 |
|
|
48
|
+
|
|
49
|
+
`package.json` 新增:`"phaser": "^3.90.0"`
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 空项目文件结构
|
|
54
|
+
|
|
55
|
+
安装本 skill 后 Remix 项目的完整文件树:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
<remix-project>/
|
|
59
|
+
├── src/
|
|
60
|
+
│ ├── index.ts ← webpack 入口
|
|
61
|
+
│ ├── index.html ← HTML 容器(含 viewport meta)
|
|
62
|
+
│ ├── index.css ← 全屏 + 移动端适配样式
|
|
63
|
+
│ └── game/
|
|
64
|
+
│ ├── index.ts ← StartGame()
|
|
65
|
+
│ ├── GameConfig.ts ← 通用游戏配置
|
|
66
|
+
│ ├── SceneKeys.ts ← 场景名枚举
|
|
67
|
+
│ ├── scenes/
|
|
68
|
+
│ │ ├── BootScene.ts ← 全局初始化 → 路由
|
|
69
|
+
│ │ ├── PreloaderScene.ts ← 资源加载 + 进度条
|
|
70
|
+
│ │ └── GameScene.ts ← Hello Phaser(主场景骨架)
|
|
71
|
+
│ └── utils/
|
|
72
|
+
│ ├── UiLayout.ts ← 自适应布局系统
|
|
73
|
+
│ └── SoundUtils.ts ← 安全音效播放
|
|
74
|
+
├── assets/ ← 资产目录(游戏图片/音频放这里)
|
|
75
|
+
├── globals.d.ts ← 完整类型声明
|
|
76
|
+
├── tsconfig.json ← TypeScript 配置
|
|
77
|
+
├── package.json ← phaser 依赖
|
|
78
|
+
└── webpack.config.js ← 构建配置(由 webpack_build.aicomponent 提供)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 文件详解
|
|
84
|
+
|
|
85
|
+
### src/index.ts(webpack 入口)
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import "./index.css";
|
|
89
|
+
import { StartGame } from "./game";
|
|
90
|
+
|
|
91
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
92
|
+
StartGame("game-container");
|
|
93
|
+
|
|
94
|
+
window.addEventListener("resize", () => {
|
|
95
|
+
window.location.reload();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### src/game/index.ts(StartGame 函数)
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { BootScene } from "./scenes/BootScene";
|
|
104
|
+
import { PreloaderScene } from "./scenes/PreloaderScene";
|
|
105
|
+
import { GameScene } from "./scenes/GameScene";
|
|
106
|
+
|
|
107
|
+
export const StartGame = (parent: string): Phaser.Game => {
|
|
108
|
+
const DESIGN_SCALE = 2;
|
|
109
|
+
const designWidth = Math.round((window.innerWidth || 375) * DESIGN_SCALE);
|
|
110
|
+
const designHeight = Math.round((window.innerHeight || 667) * DESIGN_SCALE);
|
|
111
|
+
|
|
112
|
+
const config: Phaser.Types.Core.GameConfig = {
|
|
113
|
+
type: Phaser.WEBGL,
|
|
114
|
+
parent,
|
|
115
|
+
width: designWidth,
|
|
116
|
+
height: designHeight,
|
|
117
|
+
backgroundColor: 0xffffff,
|
|
118
|
+
scene: [BootScene, PreloaderScene, GameScene],
|
|
119
|
+
scale: {
|
|
120
|
+
mode: Phaser.Scale.FIT,
|
|
121
|
+
autoCenter: Phaser.Scale.CENTER_BOTH,
|
|
122
|
+
},
|
|
123
|
+
input: { activePointers: 2 },
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return new Phaser.Game(config);
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### src/game/GameConfig.ts(通用配置)
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
export const GameConfig = {
|
|
134
|
+
baseWidth: 750, // 设计稿宽度
|
|
135
|
+
baseHeight: 1334, // 设计稿高度
|
|
136
|
+
minScale: 0.7, // UI 最小缩放
|
|
137
|
+
maxScale: 1.4, // UI 最大缩放
|
|
138
|
+
safeAreaTop: 0, // 安全区顶部偏移 (dp)
|
|
139
|
+
safeAreaBottom: 0, // 安全区底部偏移 (dp)
|
|
140
|
+
debugScene: "game", // 启动场景路由
|
|
141
|
+
showFps: false, // FPS 显示开关
|
|
142
|
+
settings: {
|
|
143
|
+
musicOn: true,
|
|
144
|
+
soundOn: true,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### src/game/utils/UiLayout.ts(自适应布局)
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
export function computeUiLayout(sceneOrCamera, config = GameConfig): UiLayoutResult {
|
|
153
|
+
// uiScale = clamp(min(Wr/Wd, Hr/Hd), minScale, maxScale)
|
|
154
|
+
// vScale = Hr/Hd
|
|
155
|
+
// centerX = Wr/2, centerY = Hr/2
|
|
156
|
+
// isLandscape = width > height
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**使用示例**:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { computeUiLayout } from '../utils/UiLayout';
|
|
164
|
+
|
|
165
|
+
// 在任意 Scene.create() 中
|
|
166
|
+
const { width, height, uiScale, vScale, centerX, centerY, isLandscape } = computeUiLayout(this);
|
|
167
|
+
|
|
168
|
+
// UI 元素定位
|
|
169
|
+
const buttonY = height - 80 * vScale; // 距底 80dp
|
|
170
|
+
const iconSize = 48 * uiScale; // 48dp 图标
|
|
171
|
+
const title = this.add.text(centerX, 100 * vScale, 'Title', {
|
|
172
|
+
fontSize: `${32 * uiScale}px`,
|
|
173
|
+
}).setOrigin(0.5);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### src/game/scenes/BootScene.ts(全局初始化)
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
export class BootScene extends Scene {
|
|
180
|
+
create(): void {
|
|
181
|
+
this.input.mouse?.disableContextMenu();
|
|
182
|
+
this.scene.start(SceneKeys.Preloader); // 或根据 GameConfig.debugScene 路由
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### src/game/scenes/PreloaderScene.ts(通用加载)
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
export class PreloaderScene extends Scene {
|
|
191
|
+
preload(): void {
|
|
192
|
+
// 自动显示进度条
|
|
193
|
+
// 在此处添加 this.load.image / this.load.audio 调用
|
|
194
|
+
}
|
|
195
|
+
create(): void {
|
|
196
|
+
this.scene.start(SceneKeys.Game);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### src/game/scenes/GameScene.ts(空白主场景)
|
|
202
|
+
|
|
203
|
+
显示 "Hello Phaser!" + 十字参考线 + 安全区框 + 布局参数信息。
|
|
204
|
+
作为开发起点,替换 `create()` 内容即可开始编写游戏逻辑。
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 坐标系与布局规范
|
|
209
|
+
|
|
210
|
+
### 坐标系
|
|
211
|
+
|
|
212
|
+
- **原点**:画布左上角 (0, 0)
|
|
213
|
+
- **x 向右,y 向下**(标准 2D 画布/Phaser 约定)
|
|
214
|
+
- **设计空间**:750 × 1334 dp(竖屏基准)
|
|
215
|
+
|
|
216
|
+
### 缩放系数(Layout Canon)
|
|
217
|
+
|
|
218
|
+
| 系数 | 公式 | 用途 |
|
|
219
|
+
|------|------|------|
|
|
220
|
+
| `scaleX` | `Wr / Wd` | 水平缩放比 |
|
|
221
|
+
| `scaleY` | `Hr / Hd` | 垂直缩放比 |
|
|
222
|
+
| `uiScale` | `clamp(min(scaleX, scaleY), minScale, maxScale)` | **UI 元素尺寸**(字号、间距、图标边长) |
|
|
223
|
+
| `vScale` | `scaleY` | **垂向距离**(距底/距顶的 dp 换算) |
|
|
224
|
+
| `centerX/Y` | `Wr/2, Hr/2` | 居中锚点 |
|
|
225
|
+
|
|
226
|
+
### 使用规则
|
|
227
|
+
|
|
228
|
+
1. **同一画面只算一次** `computeUiLayout()`,全 UI 共用
|
|
229
|
+
2. 宽高/圆角/字号 → 乘 `uiScale`
|
|
230
|
+
3. 距底/距顶距离 → 乘 `vScale`
|
|
231
|
+
4. 居中偏移 → `centerX/Y` + `偏移 × uiScale`
|
|
232
|
+
5. 安全区先扣减 `safeAreaTop/Bottom`,再代入公式
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 移动端适配清单
|
|
237
|
+
|
|
238
|
+
| 特性 | 实现位置 | 说明 |
|
|
239
|
+
|------|---------|------|
|
|
240
|
+
| **HiDPI 清晰度** | `StartGame()` | viewport × 2 设计分辨率 + Scale.FIT 缩小 |
|
|
241
|
+
| **禁止页面缩放** | `index.html` | `viewport` meta:`user-scalable=no, maximum-scale=1` |
|
|
242
|
+
| **iOS 全屏** | `index.html` | `apple-mobile-web-app-capable` + `black-translucent` 状态栏 |
|
|
243
|
+
| **安全区(刘海屏)** | `index.css` | `env(safe-area-inset-*)` padding |
|
|
244
|
+
| **禁止文字选中** | `index.css` | `user-select: none` |
|
|
245
|
+
| **禁止长按菜单** | `index.css` | `-webkit-touch-callout: none` |
|
|
246
|
+
| **禁止 iOS 回弹** | `index.css` | `overscroll-behavior: none; touch-action: none` |
|
|
247
|
+
| **禁止点击高亮** | `index.css` | `-webkit-tap-highlight-color: transparent` |
|
|
248
|
+
| **禁止右键菜单** | `BootScene.ts` | `this.input.mouse?.disableContextMenu()` |
|
|
249
|
+
| **双指支持** | `StartGame()` | `activePointers: 2`(pinch zoom 预留) |
|
|
250
|
+
| **横竖屏感知** | `UiLayout.ts` | `isLandscape` 字段 |
|
|
251
|
+
| **resize 响应** | `index.ts` | reload 重新计算设计分辨率 |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Imports
|
|
256
|
+
|
|
257
|
+
本 skill 是所有 Phaser 组件的基础,无 skill 层依赖。
|
|
258
|
+
|
|
259
|
+
**配套 skill(推荐一起使用):**
|
|
260
|
+
- `webpack_build.aicomponent` — 提供 webpack.config.js + devDependencies(pnpm dev / pnpm build)
|
|
261
|
+
- `playable_scripts_build.aicomponent` — 腾讯 playable-scripts 构建管线(替代 webpack_build)
|
|
262
|
+
|
|
263
|
+
**不再需要单独安装**(已内置):
|
|
264
|
+
- ~~`typescript_module_patterns.aicomponent`~~ — 资源模块声明已合入 `globals.d.ts`
|
|
265
|
+
- ~~`responsive_2d_layout.aicomponent`~~ 的 scaffold 部分 — `UiLayout.ts` 已内置(SKILL.md 规范文档仍然有效)
|
|
266
|
+
- ~~`sound_utils.aicomponent`~~ 的基础版 — `SoundUtils.ts` 已内置(增强版如 BGM 管理仍可独立使用)
|
|
267
|
+
- ~~`phaser_scene_lifecycle.aicomponent`~~ 的场景骨架 — Boot/Preloader/Game 三场景已内置
|
|
268
|
+
|
|
269
|
+
## Skill Definition
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
tools:
|
|
273
|
+
- read_file
|
|
274
|
+
- write_file
|
|
275
|
+
inputs:
|
|
276
|
+
- source: ref/main.ts (webpack entry)
|
|
277
|
+
- source: ref/index.html (HTML container with viewport meta)
|
|
278
|
+
- source: ref/index.css (fullscreen + mobile styles)
|
|
279
|
+
- source: ref/globals.d.ts (asset module declarations + __DEV__)
|
|
280
|
+
- source: ref/tsconfig.json (TypeScript config)
|
|
281
|
+
- source: ref/index.ts (StartGame function)
|
|
282
|
+
- source: ref/GameConfig.ts (generic game config)
|
|
283
|
+
- source: ref/SceneKeys.ts (scene key enum)
|
|
284
|
+
- source: ref/BootScene.ts (boot scene)
|
|
285
|
+
- source: ref/PreloaderScene.ts (preloader scene)
|
|
286
|
+
- source: ref/GameScene.ts (game scene skeleton)
|
|
287
|
+
- source: ref/UiLayout.ts (responsive layout system)
|
|
288
|
+
- source: ref/SoundUtils.ts (safe sound playback)
|
|
289
|
+
outputs:
|
|
290
|
+
- projectSkeleton: 13 files forming a complete runnable Phaser project
|
|
291
|
+
- phaserDep: phaser ^3.90.0 npm dependency
|
|
292
|
+
- sceneLifecycle: Boot → Preloader → Game three-scene architecture
|
|
293
|
+
- responsiveLayout: computeUiLayout() with uiScale/vScale/center
|
|
294
|
+
- mobileAdaptation: viewport meta, safe areas, touch handling, HiDPI
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Recipe
|
|
298
|
+
|
|
299
|
+
| 决策 | 原因 |
|
|
300
|
+
|-----|-----|
|
|
301
|
+
| **2× 设计分辨率** | 在 HiDPI 屏上用更高物理像素渲染,再通过 Scale.FIT 缩小,避免模糊 |
|
|
302
|
+
| **resize 时 reload** | 最简单可靠的方式重新计算设计分辨率;试玩广告不需要复杂的响应式 |
|
|
303
|
+
| **activePointers: 2** | 允许双指缩放手势(InputHandler 实现 pinch zoom) |
|
|
304
|
+
| **三场景架构** | Boot 负责全局初始化(只跑一次),Preloader 负责资源加载,Game 为主场景 |
|
|
305
|
+
| **Layout Canon 内置** | computeUiLayout 是所有 UI 定位的基础,不应是可选依赖 |
|
|
306
|
+
| **GameConfig 纯通用** | 去掉所有 arrow-puzzle 专属常量(棋盘/箭头/路径),具体游戏 skill 自行声明 |
|
|
307
|
+
| **globals.d.ts 合并模块声明** | 减少 skill 依赖数量,一个 skill 出完整项目 |
|
|
308
|
+
|
|
309
|
+
## Adapter
|
|
310
|
+
|
|
311
|
+
- **Role**: `phaserEngine` — Phaser 3 游戏引擎基座,所有 Phaser 系 skill 的运行时依赖
|
|
312
|
+
- **Provides**: `StartGame()` 启动入口、`SceneKeys` 枚举、`GameConfig` 通用配置、`computeUiLayout()` 自适应布局、`safePlaySound()` 安全音效
|
|
313
|
+
- **Requires**: 无 skill 层硬依赖(`webpack_build.aicomponent` 为配套工具,非运行时依赖)
|
|
314
|
+
- **Consumed by**: 所有以 `phaser.aicomponent` 为 Imports 硬依赖的 skill,包括 `grid_board_layout`、`path_renderer`、`path_input_handler`、`tray_container`、`level_lifecycle`、`game_scene` 等
|
|
315
|
+
- **Integration point**: `src/game/index.ts` 导出 `StartGame()`,由 `src/index.ts` 在 `DOMContentLoaded` 中调用
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"atomId": "phaser.aicomponent",
|
|
4
|
+
"bundleType": "aicomponent",
|
|
5
|
+
"category": "engine",
|
|
6
|
+
"mode": "fixed",
|
|
7
|
+
"label": { "zh": "Phaser 3 游戏引擎", "en": "Phaser 3 game engine" },
|
|
8
|
+
"tags": ["phaser", "game-engine", "webgl", "2d", "canvas", "scene", "runtime", "skeleton", "responsive", "mobile"],
|
|
9
|
+
"bindingRoles": ["gameEngine"],
|
|
10
|
+
"scaffold": {
|
|
11
|
+
"files": {
|
|
12
|
+
"src/index.ts": {
|
|
13
|
+
"source": "ref/main.ts",
|
|
14
|
+
"mode": "full",
|
|
15
|
+
"weight": 10,
|
|
16
|
+
"_comment": "webpack 入口:import CSS + 调用 StartGame + 监听 resize"
|
|
17
|
+
},
|
|
18
|
+
"src/index.html": {
|
|
19
|
+
"source": "ref/index.html",
|
|
20
|
+
"mode": "full",
|
|
21
|
+
"weight": 10,
|
|
22
|
+
"_comment": "HTML 容器,包含 viewport meta + #game-container"
|
|
23
|
+
},
|
|
24
|
+
"src/index.css": {
|
|
25
|
+
"source": "ref/index.css",
|
|
26
|
+
"mode": "full",
|
|
27
|
+
"weight": 10,
|
|
28
|
+
"_comment": "全屏样式:移动端适配、安全区、禁止选中/回弹"
|
|
29
|
+
},
|
|
30
|
+
"globals.d.ts": {
|
|
31
|
+
"source": "ref/globals.d.ts",
|
|
32
|
+
"mode": "full",
|
|
33
|
+
"weight": 10,
|
|
34
|
+
"_comment": "资源模块声明(*.webp, *.mp3 等)+ __DEV__ 全局变量"
|
|
35
|
+
},
|
|
36
|
+
"tsconfig.json": {
|
|
37
|
+
"source": "ref/tsconfig.json",
|
|
38
|
+
"mode": "merge-json",
|
|
39
|
+
"weight": 10,
|
|
40
|
+
"_comment": "TypeScript 配置:target es5, moduleResolution bundler, paths assets/*"
|
|
41
|
+
},
|
|
42
|
+
"src/game/index.ts": {
|
|
43
|
+
"source": "ref/index.ts",
|
|
44
|
+
"mode": "full",
|
|
45
|
+
"weight": 10,
|
|
46
|
+
"_comment": "StartGame(parent) 游戏入口,2× 设计分辨率 + Scale.FIT"
|
|
47
|
+
},
|
|
48
|
+
"src/game/GameConfig.ts": {
|
|
49
|
+
"source": "ref/GameConfig.ts",
|
|
50
|
+
"mode": "full",
|
|
51
|
+
"weight": 10,
|
|
52
|
+
"_comment": "通用游戏配置:设计稿基准、UI 缩放范围、安全区、调试开关"
|
|
53
|
+
},
|
|
54
|
+
"src/game/SceneKeys.ts": {
|
|
55
|
+
"source": "ref/SceneKeys.ts",
|
|
56
|
+
"mode": "full",
|
|
57
|
+
"weight": 10,
|
|
58
|
+
"_comment": "场景名枚举,避免字符串硬编码"
|
|
59
|
+
},
|
|
60
|
+
"src/game/scenes/BootScene.ts": {
|
|
61
|
+
"source": "ref/BootScene.ts",
|
|
62
|
+
"mode": "full",
|
|
63
|
+
"weight": 10,
|
|
64
|
+
"_comment": "Boot 场景:全局初始化 + 场景路由"
|
|
65
|
+
},
|
|
66
|
+
"src/game/scenes/PreloaderScene.ts": {
|
|
67
|
+
"source": "ref/PreloaderScene.ts",
|
|
68
|
+
"mode": "full",
|
|
69
|
+
"weight": 10,
|
|
70
|
+
"_comment": "预加载场景:进度条 + Loading 文字"
|
|
71
|
+
},
|
|
72
|
+
"src/game/scenes/GameScene.ts": {
|
|
73
|
+
"source": "ref/GameScene.ts",
|
|
74
|
+
"mode": "full",
|
|
75
|
+
"weight": 10,
|
|
76
|
+
"_comment": "空白主场景:Hello Phaser + 布局参考信息"
|
|
77
|
+
},
|
|
78
|
+
"src/game/utils/UiLayout.ts": {
|
|
79
|
+
"source": "ref/UiLayout.ts",
|
|
80
|
+
"mode": "full",
|
|
81
|
+
"weight": 10,
|
|
82
|
+
"_comment": "自适应布局:computeUiLayout() — uiScale/vScale/centerX/centerY"
|
|
83
|
+
},
|
|
84
|
+
"src/game/utils/SoundUtils.ts": {
|
|
85
|
+
"source": "ref/SoundUtils.ts",
|
|
86
|
+
"mode": "full",
|
|
87
|
+
"weight": 10,
|
|
88
|
+
"_comment": "安全音效播放封装:缺失音效键时静默返回"
|
|
89
|
+
},
|
|
90
|
+
"package.json": {
|
|
91
|
+
"source": "ref/package.json",
|
|
92
|
+
"mode": "merge-json",
|
|
93
|
+
"weight": 10,
|
|
94
|
+
"_comment": "项目依赖:phaser + webpack + ts-loader + html-webpack-plugin 等"
|
|
95
|
+
},
|
|
96
|
+
"webpack.config.js": {
|
|
97
|
+
"source": "ref/webpack.config.js",
|
|
98
|
+
"mode": "full",
|
|
99
|
+
"weight": 10,
|
|
100
|
+
"_comment": "Webpack 5 配置:ts-loader + asset/resource + HtmlWebpackPlugin + __DEV__"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"packageJson": {
|
|
104
|
+
"dependencies": {
|
|
105
|
+
"phaser": { "version": "^3.90.0", "weight": 10 }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"exports": [
|
|
110
|
+
{ "name": "StartGame", "kind": "function", "location": "src/game/index.ts" },
|
|
111
|
+
{ "name": "GameConfig", "kind": "object", "location": "src/game/GameConfig.ts" },
|
|
112
|
+
{ "name": "SceneKeys", "kind": "object", "location": "src/game/SceneKeys.ts" },
|
|
113
|
+
{ "name": "BootScene", "kind": "class", "location": "src/game/scenes/BootScene.ts" },
|
|
114
|
+
{ "name": "PreloaderScene", "kind": "class", "location": "src/game/scenes/PreloaderScene.ts" },
|
|
115
|
+
{ "name": "GameScene", "kind": "class", "location": "src/game/scenes/GameScene.ts" },
|
|
116
|
+
{ "name": "computeUiLayout", "kind": "function", "location": "src/game/utils/UiLayout.ts" },
|
|
117
|
+
{ "name": "UiLayoutConfig", "kind": "interface", "location": "src/game/utils/UiLayout.ts" },
|
|
118
|
+
{ "name": "UiLayoutResult", "kind": "interface", "location": "src/game/utils/UiLayout.ts" },
|
|
119
|
+
{ "name": "safePlaySound", "kind": "function", "location": "src/game/utils/SoundUtils.ts" }
|
|
120
|
+
],
|
|
121
|
+
"neutralDescriptor": {
|
|
122
|
+
"geometry": "2D WebGL game engine runtime with complete project skeleton: 3-scene lifecycle (Boot→Preloader→Game), responsive layout system (750×1334 design base), mobile adaptation (safe areas, touch, HiDPI), sound utilities",
|
|
123
|
+
"layers": ["rendering", "scene-management", "input-system", "responsive-layout", "sound-utils", "project-scaffold"],
|
|
124
|
+
"replaceable": ["renderer type (WEBGL/CANVAS)", "scene list", "design resolution", "HTML title", "background color"]
|
|
125
|
+
},
|
|
126
|
+
"usageHints": [
|
|
127
|
+
"本 skill 提供完整 Phaser 空项目骨架(15 个文件),包含 package.json + webpack.config.js,scaffold 后 pnpm install && pnpm dev 即可运行",
|
|
128
|
+
"项目结构:package.json / webpack.config.js / tsconfig.json / globals.d.ts + src/ (13个源文件) + assets/images/ + assets/sounds/",
|
|
129
|
+
"三场景生命周期:Boot(全局初始化)→ Preloader(资源加载 + 进度条)→ Game(主游戏场景)",
|
|
130
|
+
"computeUiLayout(scene) 统一计算 uiScale/vScale/centerX/centerY,所有 UI 元素必须使用此函数的输出定位",
|
|
131
|
+
"设计稿基准 750×1334,运行时 2× viewport 作为设计分辨率(HiDPI 适配)+ Scale.FIT",
|
|
132
|
+
"移动端已处理:viewport meta(禁缩放)、安全区 padding、禁止选中/回弹/长按菜单、双指输入",
|
|
133
|
+
"globals.d.ts 已包含所有常见资源类型的模块声明(图片/音频/JSON),无需额外 skill",
|
|
134
|
+
"webpack.config.js 内置 __DEV__ 全局变量注入,开发模式自动为 true",
|
|
135
|
+
"safePlaySound(scene, key, config?) 封装安全音效播放,缺失音效键不抛异常",
|
|
136
|
+
"assets/ 目录约定:assets/images/(图片)+ assets/sounds/(音频),webpack alias 已配置为 'assets' 短路径"
|
|
137
|
+
],
|
|
138
|
+
"files": {
|
|
139
|
+
"skill": "SKILL.md",
|
|
140
|
+
"mainEntry": "ref/main.ts",
|
|
141
|
+
"html": "ref/index.html",
|
|
142
|
+
"css": "ref/index.css",
|
|
143
|
+
"globals": "ref/globals.d.ts",
|
|
144
|
+
"tsconfig": "ref/tsconfig.json",
|
|
145
|
+
"packageJson": "ref/package.json",
|
|
146
|
+
"webpackConfig": "ref/webpack.config.js",
|
|
147
|
+
"gameEntry": "ref/index.ts",
|
|
148
|
+
"gameConfig": "ref/GameConfig.ts",
|
|
149
|
+
"sceneKeys": "ref/SceneKeys.ts",
|
|
150
|
+
"bootScene": "ref/BootScene.ts",
|
|
151
|
+
"preloaderScene": "ref/PreloaderScene.ts",
|
|
152
|
+
"gameScene": "ref/GameScene.ts",
|
|
153
|
+
"uiLayout": "ref/UiLayout.ts",
|
|
154
|
+
"soundUtils": "ref/SoundUtils.ts"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Scene } from "phaser";
|
|
2
|
+
import { SceneKeys } from "../SceneKeys";
|
|
3
|
+
import { GameConfig } from "../GameConfig";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Boot 场景 — 引擎初始化后第一个运行的场景。
|
|
7
|
+
*
|
|
8
|
+
* 职责:
|
|
9
|
+
* 1. 设置全局输入配置(禁用右键菜单等)
|
|
10
|
+
* 2. 根据 GameConfig.debugScene 路由到目标场景
|
|
11
|
+
*/
|
|
12
|
+
export class BootScene extends Scene {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(SceneKeys.Boot);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
create(): void {
|
|
18
|
+
this.input.mouse?.disableContextMenu();
|
|
19
|
+
|
|
20
|
+
const target =
|
|
21
|
+
GameConfig.debugScene === "preloader"
|
|
22
|
+
? SceneKeys.Preloader
|
|
23
|
+
: GameConfig.debugScene === "game"
|
|
24
|
+
? SceneKeys.Game
|
|
25
|
+
: SceneKeys.Preloader;
|
|
26
|
+
|
|
27
|
+
this.scene.start(target);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 游戏全局配置(通用基础版)。
|
|
3
|
+
*
|
|
4
|
+
* 具体游戏的业务常量(棋盘间距、箭头尺寸等)应在各自 skill 中声明,
|
|
5
|
+
* 不要污染此文件。
|
|
6
|
+
*/
|
|
7
|
+
export const GameConfig = {
|
|
8
|
+
// ─── 设计稿基准 ───
|
|
9
|
+
baseWidth: 750,
|
|
10
|
+
baseHeight: 1334,
|
|
11
|
+
|
|
12
|
+
// ─── UI 缩放范围(供 computeUiLayout 使用) ───
|
|
13
|
+
minScale: 0.7,
|
|
14
|
+
maxScale: 1.4,
|
|
15
|
+
|
|
16
|
+
// ─── 安全区偏移(刘海屏等,单位 dp;启用后 UiLayout 自动扣减) ───
|
|
17
|
+
safeAreaTop: 0,
|
|
18
|
+
safeAreaBottom: 0,
|
|
19
|
+
|
|
20
|
+
// ─── 调试 ───
|
|
21
|
+
debugScene: "game" as "boot" | "preloader" | "game",
|
|
22
|
+
showFps: false,
|
|
23
|
+
|
|
24
|
+
// ─── 音频默认状态 ───
|
|
25
|
+
settings: {
|
|
26
|
+
musicOn: true,
|
|
27
|
+
soundOn: true,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Scene } from "phaser";
|
|
2
|
+
import { SceneKeys } from "../SceneKeys";
|
|
3
|
+
import { computeUiLayout } from "../utils/UiLayout";
|
|
4
|
+
import { GameConfig } from "../GameConfig";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 主游戏场景(空白骨架)。
|
|
8
|
+
*
|
|
9
|
+
* 执行脚手架后,此场景显示 "Hello Phaser!" 文字和布局参考网格,
|
|
10
|
+
* 作为开发起点。替换 create() 中的内容即可开始编写游戏逻辑。
|
|
11
|
+
*/
|
|
12
|
+
export class GameScene extends Scene {
|
|
13
|
+
private fpsText?: Phaser.GameObjects.Text;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super(SceneKeys.Game);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
create(): void {
|
|
20
|
+
const layout = computeUiLayout(this);
|
|
21
|
+
const { width, height, centerX, centerY, uiScale, vScale, isLandscape } =
|
|
22
|
+
layout;
|
|
23
|
+
|
|
24
|
+
// ─── 背景 ───
|
|
25
|
+
this.cameras.main.setBackgroundColor(0xf5f5f5);
|
|
26
|
+
|
|
27
|
+
// ─── 参考十字线(设计期辅助,正式项目可删除) ───
|
|
28
|
+
const crosshair = this.add.graphics();
|
|
29
|
+
crosshair.lineStyle(1, 0xcccccc, 0.5);
|
|
30
|
+
crosshair.lineBetween(centerX, 0, centerX, height);
|
|
31
|
+
crosshair.lineBetween(0, centerY, width, centerY);
|
|
32
|
+
|
|
33
|
+
// ─── 安全区可视化边框 ───
|
|
34
|
+
const safeMargin = 40 * uiScale;
|
|
35
|
+
const safeRect = this.add.graphics();
|
|
36
|
+
safeRect.lineStyle(1, 0x4488ff, 0.3);
|
|
37
|
+
safeRect.strokeRect(safeMargin, safeMargin, width - safeMargin * 2, height - safeMargin * 2);
|
|
38
|
+
|
|
39
|
+
// ─── 标题 ───
|
|
40
|
+
this.add
|
|
41
|
+
.text(centerX, centerY - 40 * uiScale, "Hello Phaser!", {
|
|
42
|
+
fontSize: `${48 * uiScale}px`,
|
|
43
|
+
color: "#333333",
|
|
44
|
+
fontFamily: "Arial, sans-serif",
|
|
45
|
+
fontStyle: "bold",
|
|
46
|
+
})
|
|
47
|
+
.setOrigin(0.5);
|
|
48
|
+
|
|
49
|
+
// ─── 布局信息(帮助开发者理解坐标系) ───
|
|
50
|
+
const info = [
|
|
51
|
+
`canvas: ${width} × ${height}`,
|
|
52
|
+
`design: ${GameConfig.baseWidth} × ${GameConfig.baseHeight}`,
|
|
53
|
+
`uiScale: ${uiScale.toFixed(3)} vScale: ${vScale.toFixed(3)}`,
|
|
54
|
+
`orientation: ${isLandscape ? "landscape" : "portrait"}`,
|
|
55
|
+
`dpr: ${window.devicePixelRatio}`,
|
|
56
|
+
].join("\n");
|
|
57
|
+
|
|
58
|
+
this.add
|
|
59
|
+
.text(centerX, centerY + 30 * uiScale, info, {
|
|
60
|
+
fontSize: `${14 * uiScale}px`,
|
|
61
|
+
color: "#888888",
|
|
62
|
+
fontFamily: "monospace",
|
|
63
|
+
align: "center",
|
|
64
|
+
lineSpacing: 6 * uiScale,
|
|
65
|
+
})
|
|
66
|
+
.setOrigin(0.5, 0);
|
|
67
|
+
|
|
68
|
+
// ─── FPS 显示 ───
|
|
69
|
+
if (GameConfig.showFps) {
|
|
70
|
+
this.fpsText = this.add
|
|
71
|
+
.text(10, 10, "FPS: 0", {
|
|
72
|
+
fontSize: `${12 * uiScale}px`,
|
|
73
|
+
color: "#00cc00",
|
|
74
|
+
fontFamily: "monospace",
|
|
75
|
+
backgroundColor: "#00000066",
|
|
76
|
+
padding: { x: 4, y: 2 },
|
|
77
|
+
})
|
|
78
|
+
.setScrollFactor(0)
|
|
79
|
+
.setDepth(9999);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
update(): void {
|
|
84
|
+
if (this.fpsText) {
|
|
85
|
+
this.fpsText.setText(`FPS: ${this.game.loop.actualFps.toFixed(0)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|