Add Virtual Joystick component

A place to request and discuss new engine features / functionality

Add Virtual Joystick component

Postby StuartTresadern » Sat Dec 28, 2013 4:10 pm

Currently I am using https://github.com/jeromeetienne/virtualjoystick.js to add joystick support.

I just include the library in the ClientConfig add a container div to index.html <div id="container"></div>.

In my client.js I setup the joystick

Code: Select all
self.joystick = new VirtualJoystick({
                        container: document.getElementById('container'),
                        mouseSupport: true,
                        stationaryBase: true,
                        baseX: 200,
                        baseY: 200,
                        limitStickTravel: true,
                        stickRadius: 50
                    });


and then I can access it inside my PlayerComponent for example:

Code: Select all
if(ige.client.joystick.up()){
            direction += 'N';
        }
        if(ige.client.joystick.down()){
            direction += 'S';
        }
        if(ige.client.joystick.left()){
            direction += 'W';
        }
        if(ige.client.joystick.right()){
            direction += 'E';
        }


this implementation is not ideal and if I have time I will create a component for it but for now it does the job very well.
User avatar
StuartTresadern
 
Posts: 59
Joined: Sun Dec 01, 2013 5:23 pm
Location: Germany

Return to New Feature Discussion

Who is online

Users browsing this forum: No registered users and 1 guest
cron