Rose Game Solutions

Members
  • Content Count

    10
  • Joined

  • Last visited

Posts posted by Rose Game Solutions


  1. I included 

    phaser-matter-collision-plugin

    npm package info for matter-collision: https://www.npmjs.com/package/phaser-matter-collision-plugin

    Then, in my scene, I passed an array containing all the walls of the world bounds... like so:

    // 'this' refers to Phaser.Scene 
    const { bottom, left, top, right } = this.matter.world.walls;
            this.matterCollision.addOnCollideStart({
                objectA: [bottom, left, right, top], //world bounds
                objectB: this.gate, // some object to detect collision with
                callback: eventData => {
                    // run logic here
                    console.log(eventData)
                },
            });

     


  2. 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,
            },
        },
    };

     


  3. I'm using multiple scenes and trying to get a Heads Up Display (HUD) that is always active. I'm also using a sprite with anims. however, when I load the sprite into the scene, I get an error coming from animation.

     

    here's my HUD class:

    export default class HUDScene extends Phaser.Scene {
        constructor() {
            super({ key: "HUD", active: true });
        }

     and in my create method I'm just doing a simple constructor call

            this.HUD = new HUD(this.matter.world, 0, 0);
    

    Is there another way to accomplish this? or, what am I missing/doing wrong?

    the animations work in my 'gameScene' but not in the -always active- HUD scene...

    Thanks!


  4. 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


  5. in my scene's create method I'm using this line of code to set bounds.

     

    this.matter.world.setBounds(0, 0, 1800, 1800, 15);

    here, the thickness, is set to 15 as I understand it. But I fly through the walls sometimes and need a more solid barrier.

     

    any ideas on how to shore up the world bounds? Alternatively if you know of a way of setting tiles along the world bounds, I'd be fine with that kind of solution...