Jump to content

Plugins Phaser 3 matter.js matter-attractors


Rose Game Solutions
 Share

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

Link to comment
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,
        },
    },
};

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...