Giter Club home page Giter Club logo

Comments (6)

 avatar commented on May 22, 2024 1

Thanks, I've added the plugin link on wikipedia phaser 3 page

from phaser3-rex-notes.

rexrainbow avatar rexrainbow commented on May 22, 2024

Yes, you can use that virtual joystick plugin without using import. Here is an example about how to install phaser plugin.
In preload stage, call

var url = 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexvirtualjoystickplugin.min.js';
this.load.plugin('rexvirtualjoystickplugin', url, true);

to download and install virtual joystick plugin from an external file, then create a new virtual joystick instance via

var joyStick = this.plugins.get('rexvirtualjoystickplugin').add(this, config);

from phaser3-rex-notes.

 avatar commented on May 22, 2024

Yes, you can use that virtual joystick plugin without using import. Here is an example about how to install phaser plugin.
In preload stage, call

var url = 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexvirtualjoystickplugin.min.js';
this.load.plugin('rexvirtualjoystickplugin', url, true);

to download and install virtual joystick plugin from an external file, then create a new virtual joystick instance via

var joyStick = this.plugins.get('rexvirtualjoystickplugin').add(this, config);

Thanks it works now

from phaser3-rex-notes.

gskriptor avatar gskriptor commented on May 22, 2024

Hi,
I am using this same plugin and method, but I am getting an error in my console:
Uncaught TypeError: n.onDown is not a function

class MyScene extends Phaser.Scene{
  preload() {
    this.load.plugin('rexvirtualjoystickplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexvirtualjoystickplugin.min.js', true);
  }
  create() {
    this.joyStick = this.plugins.get('rexvirtualjoystickplugin').add(this, {
      x: this.game.config.width * 0.5,
      y: 680,
      radius: 60,
      base: this.add.circle(0, 0, 100, 0x888888),
      thumb: this.add.circle(0, 0, 50, 0xcccccc),
      // dir: '8dir',   // 'up&down'|0|'left&right'|1|'4dir'|2|'8dir'|3
      // forceMin: 16,
      // enable: true
    }).on('update', this.dumpJoyStickState, this);

    this.text = this.add.text(0, 0);
    this.dumpJoyStickState();
  }
  dumpJoyStickState() {
        var cursorKeys = this.joyStick.createCursorKeys();
        var s = 'Key down: ';
        for (var name in cursorKeys) {
            if (cursorKeys[name].isDown) {
                s += name + ' ';
            }
        }
        s += '\n';
        s += ('Force: ' + Math.floor(this.joyStick.force * 100) / 100 + '\n');
        s += ('Angle: ' + Math.floor(this.joyStick.angle * 100) / 100 + '\n');
        this.text.setText(s);
    }
}

Is there something I am missing?

from phaser3-rex-notes.

rexrainbow avatar rexrainbow commented on May 22, 2024

Please use latest phaser3.

from phaser3-rex-notes.

gskriptor avatar gskriptor commented on May 22, 2024

Please use latest phaser3.

Thank you this worked for me.

from phaser3-rex-notes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.