Rose Game Solutions

Plugins Phaser 3 matter.js matter-attractors

Recommended Posts

I'm not understanding how to incorporate plugins... especially for matter-attractors.

 

my config file looks like this, I'm bringing in another plugin that worked well, and had good instructions.

 

type: Phaser.AUTO,
    parent: "my game",
    canvas: document.getElementById("game"),
    width: 1500, // window.innerWidth
    height: 1500, // window.innerHeight
    pixelArt: true,
    roundPixels: true,
    physics: {
        default: "matter",
        matter: {
            gravity: { scale: 0 },
            debug: true,
        },
    },
    plugins: {
        scene: [
            {
                plugin: PhaserMatterCollisionPlugin, // The plugin class
                key: "matterCollision", // Where to store in Scene.Systems, e.g. scene.sys.matterCollision
                mapping: "matterCollision", // Where to store in the Scene, e.g. scene.matterCollision
            },
{
                plugin: MatterAttractors, 
                key: "matterAttractors", 
                mapping: "matterAttractors", 
            },
        ],
    },
};

You can see I'm trying to use it there at the bottom... I'm not having any luck.

I'm expecting to see them in the console when they get in by using this:

this.plugins.scenePlugins

 

I'm hoping someone call show me what needs to change. here is matter-atractor's github link

Share this post


Link to post
Share on other sites

Thanks @rich.

I'm still having trouble getting the matter-attractors plugin working...

i'm using es6 classes with webpack and my entry point file looks like this:

import "phaser";
import config from "./config";
import GameScene from "./Game";
import BootScene from "./Boot";

class Game extends Phaser.Game {
    constructor() {
        super(config);
        this.scene.add("Boot", BootScene);
        this.scene.add("Game", GameScene);

        this.scene.start("Boot");
    }
}

window.game = new Game();
window.addEventListener("resize", event => {
    window.game.resize(window.innerWidth, window.innerHeight);
});

Any thoughts on what I might check?

my updated config file:

export default {
    type: Phaser.AUTO,
    parent: "TESTING",
    canvas: document.getElementById("game"),
    width: 600,
    height: 400,
    pixelArt: true,
    roundPixels: true,
    physics: {
        default: "matter",
        matter: {
            gravity: { scale: 0 },
            debug: true,
        },
        plugins: {
            attractors: true,
        },
    },
};

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.