From 5e99a3195f0d40ba69ec23290014283bddd4432d Mon Sep 17 00:00:00 2001 From: verekia <522007+verekia@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:49:48 +0700 Subject: [PATCH] feat(vue): add joystick support --- README.md | 4 +- examples/react/src/App.tsx | 2 +- .../react/src/components/MobileJoystick.tsx | 10 +-- examples/vue/src/App.vue | 23 +++++- .../vue/src/components/MobileJoystick.vue | 56 ++++++++++++++ packages/vue/src/JoystickArea.vue.ts | 76 +++++++++++++++++++ packages/vue/src/index.ts | 1 + 7 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 examples/vue/src/components/MobileJoystick.vue create mode 100644 packages/vue/src/JoystickArea.vue.ts diff --git a/README.md b/README.md index 39d5558..d61c391 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,7 @@ useAnimationFrame( ## Virtual joysticks -⚠️ React and vanilla-only for now ⚠️ +⚠️ Svelte not supported yet ⚠️ Mana Potion includes **🗿 non-reactive** and **headless** virtual joysticks for mobile controls. Each virtual joystick is associated with a single ``. You can create your own Joystick objects with `createJoystick()` or use one of the two default ones that are already available on the joysticks store. The default ones are called `movement` and `rotation` joysticks. @@ -374,6 +374,8 @@ const MobileUI = () => ( ) ``` +With vanilla JS, use `mountJoystickArea` instead. + In follow mode, the joystick will follow the user's finger, which is good for player movement. Here are the properties that will be updated on your joystick object: diff --git a/examples/react/src/App.tsx b/examples/react/src/App.tsx index 634eb05..630e7d2 100644 --- a/examples/react/src/App.tsx +++ b/examples/react/src/App.tsx @@ -260,7 +260,7 @@ const UI = ({
Switch to 👆 mobile mode in devtools
- +
Mode{' '}