{"id":13639377,"url":"https://github.com/eva-engine/eva-plugin-joystick","last_synced_at":"2025-04-10T11:50:25.057Z","repository":{"id":75771820,"uuid":"394674761","full_name":"eva-engine/eva-plugin-joystick","owner":"eva-engine","description":"joystick for Eva.js","archived":false,"fork":false,"pushed_at":"2021-09-05T06:52:27.000Z","size":295,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-07T08:02:34.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eva-plugin-joystick","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eva-engine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-08-10T13:59:25.000Z","updated_at":"2024-08-07T08:02:34.856Z","dependencies_parsed_at":null,"dependency_job_id":"e883f4db-a2aa-45b2-95d8-067108309dd6","html_url":"https://github.com/eva-engine/eva-plugin-joystick","commit_stats":null,"previous_names":["fanmingfei/eva-plugin-joystick"],"tags_count":0,"template":false,"template_full_name":"eva-engine/plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eva-engine%2Feva-plugin-joystick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eva-engine%2Feva-plugin-joystick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eva-engine%2Feva-plugin-joystick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eva-engine%2Feva-plugin-joystick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eva-engine","download_url":"https://codeload.github.com/eva-engine/eva-plugin-joystick/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215192,"owners_count":21066619,"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","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":[],"created_at":"2024-08-02T01:01:00.030Z","updated_at":"2025-04-10T11:50:25.040Z","avatar_url":"https://github.com/eva-engine.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# Eva.js Joystick\n\n基于 Eva.js 的虚拟摇杆\n\n[Play demo](https://fanmingfei.github.io/eva-plugin-joystick/)\n\n![](https://user-images.githubusercontent.com/4632277/128896471-de547d92-2c4f-4299-92b5-a7d3264ca6c0.png)\n\n注意事项：\n- 不要设置被添加游戏对象的宽高\n- 手指跟随的情况下无法使用anchor `待解决`\n\n## Usage\n```bash\nnpm i eva-plugin-joystick\n```\n\n```js\nimport { Joystick } from 'eva-plugin-joystick'\n\nconst go = new GameObject('joystick')\n\nconst joystick = go.addComponent(new Joystick({\n  followPointer: {\n    open: true,\n    area: {\n      x: 0, y: 0,\n      width: 400,\n      height: 600\n    }\n  }\n}))\n\njoystick.on(JOYSTICK_EVENT.Begin, (data) =\u003e {\n  console.log('begin', data)\n})\njoystick.on(JOYSTICK_EVENT.Drag, (data) =\u003e {\n  console.log('drag', data)\n})\njoystick.on(JOYSTICK_EVENT.End, (data) =\u003e {\n  console.log('end', data)\n})\n\n\ngame.scene.addChild(go)\n\n```\n\n## 参数\n  \n- limitRadius `number` `optional`\n\n  摇杆的半径，限制操作杆的移动范围\n\n- boxImageResource `string` `optional`\n\n  背景图片\n\n- boxRadius `number` `optional`\n\n  背景图片的半径\n\n- btnImageResource `string` `optional`\n\n  操作杆的图片\n\n- btnRadius `number` `optional`\n\n  操作杆图片的半径\n\n- followPointer `object` `optional`\n  \n  手指跟随\n  - open `boolean`\n    \n    是否打开手指跟随\n  - area `object` `request`\n    \n    手指跟随生效的范围 必填\n    - x `number` \n    - y `number`\n    - width `number`\n    - height `nubmer`\n\n\n## 事件\n```js\njoystick.on(JOYSTICK_EVENT.Begin, (data) =\u003e {\n  console.log('begin', data)\n  data.x \n  data.y\n})\n```\n\n### 事件名\n\n参数为摇杆移动的二维向量，-1,1之间\n\n- JOYSTICK_EVENT.Begin\n\n  摇杆开始事件\n\n- JOYSTICK_EVENT.Drag\n\n  摇杆拖拽事件\n\n- JOYSTICK_EVENT.End\n\n  摇杆结束事件\n\n\n### 回调函数参数\n- x \n  \n  当前的joystick向量 x 值 -1 ～ 1 之间\n\n- y\n  \n  当前的joystick向量 y 值 -1 ～ 1 之间\n\n- updateParams\n\n  当前update事件的参数\n\n  - deltaTime: number;\n    \n    每帧间隔时间，可以用于物体匀速运动\n\n  - frameCount: number;\n\n    当前游戏总帧数\n\n  - currentTime: number;\n\n    当前游戏时间\n\n  - fps: number;\n\n    当前游戏帧率","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feva-engine%2Feva-plugin-joystick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feva-engine%2Feva-plugin-joystick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feva-engine%2Feva-plugin-joystick/lists"}