{"id":14964020,"url":"https://github.com/littlee/wechat-small-game-phaser","last_synced_at":"2026-03-05T20:19:19.561Z","repository":{"id":87819365,"uuid":"116938569","full_name":"littlee/wechat-small-game-phaser","owner":"littlee","description":"make phaser works with wechat small game","archived":false,"fork":false,"pushed_at":"2020-08-14T02:19:02.000Z","size":966,"stargazers_count":50,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T05:05:38.994Z","etag":null,"topics":["phaser","wechat","wechat-game","wechat-mini-program"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littlee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-10T09:40:40.000Z","updated_at":"2025-03-22T11:01:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"173574d1-54a6-4288-8dd4-411ba0d8dba2","html_url":"https://github.com/littlee/wechat-small-game-phaser","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.05555555555555558,"last_synced_commit":"f9f0ef0ae3c8c9e246a832dee3c1288cae23f9c0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/littlee/wechat-small-game-phaser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlee%2Fwechat-small-game-phaser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlee%2Fwechat-small-game-phaser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlee%2Fwechat-small-game-phaser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlee%2Fwechat-small-game-phaser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littlee","download_url":"https://codeload.github.com/littlee/wechat-small-game-phaser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlee%2Fwechat-small-game-phaser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266419435,"owners_count":23925767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["phaser","wechat","wechat-game","wechat-mini-program"],"created_at":"2024-09-24T13:32:28.913Z","updated_at":"2026-03-05T20:19:14.515Z","avatar_url":"https://github.com/littlee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wechat Small Game with Phaser.js\n\n## Currently Using Phaser-CE Build\n\nv2.16.0\n\n## Main Idea\n\n\"Thanks to\" the WeChat Small Game runtime environment, directly importing 'phaser' will get lots of errors.\n\n## Solution\n\nStub some global variables which Phaser required, that's what 'js/libs/stub.js' does.\n\n```js\nimport './js/libs/stub';\n```\n\nUse Phaser's split custom build instead of the standard version, which can expose PIXI, p2 and Phaser to global.\n\n```js\nwindow.PIXI = require('./js/libs/pixi');\nwindow.p2 = require('./js/libs/p2');\nwindow.Phaser = require('./js/libs/phaser-split');\n```\n\nCreate the game instance with an object instead of multiple parameters, specify the `canvas` option.\n\n```js\nvar game = new Phaser.Game({\n  width: gameWidth,\n  height: gameHeight,\n  renderer: Phaser.CANVAS,\n  canvas: canvas,\n  state: {}\n});\n```\n\n## Caveats\n\n### Input Pointer\n\nIf the game size is not the same as the canvas', you should set scale mode to make Phaser calculate input pointer correctly.\n\n```js\nthis.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;\nthis.scale.pageAlignHorizontally = true; // optional\nthis.scale.pageAlignVertically = true; // optional\n```\n\n### Audio Playing\n\nThe Phaser built-in audio API won't work, however, we can use the Audio API from the adapter.\n\n```js\nlet au = new Audio('path/to/audio.mp3');\nau.play();\nau.pause();\n```\n\n### Loading JSON files\n\nLoading JSON file with a relative path won't work, you have to put the JSON file on the server and load it with a URL.\n\n```js\nthis.load.json('version', './a.json'); // ERROR T_T\nthis.load.json('version', 'http://phaser.io/version.json'); // WORKS YoY\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlee%2Fwechat-small-game-phaser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittlee%2Fwechat-small-game-phaser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlee%2Fwechat-small-game-phaser/lists"}