The virtual joystick plugin can be instantiated directly.
Detailed description of interface(joystick.d.ts).
It relies on TCGSDK. We recommend you use it in the callback function onConnectSuccess in TCGSDK.init.
-
import joystick plugin
import Joystick from 'plugin/joystick/joystick';
or use script tag
<script type="text/javascript" src="plugin/joystick/joystick.js"></script>
-
Instantiating the joystick
const j = new Joystick({ zone: document.querySelector('#your-element') });
or use global variables
const j = new CloudGamingPlugin.joystick({ zone: document.querySelector('#your-element') });
-
Listening for events(if sendData is true (default value true), the plugin will automatically send the corresponding command)
j.on('move', (data) => { const { degree } = data.angle; console.log('degree', degree); });
If you have any questions or needs, please feel free to contact ranpeng.