PhaserEditor2D / PhaserEditor

A friendly IDE to develop HTML5 games based on the Phaser framework.
https://phasereditor2d.com
Eclipse Public License 1.0
327 stars 45 forks source link

error, please, help me! #147

Closed ghost closed 4 years ago

ghost commented 4 years ago

Version

Description

Possible solution

VM27:52 Uncaught TypeError: Cannot set property 'x' of undefined at Function.eval (eval at addToCache (phaser.js:171065), :52:77) at World.collideSpriteVsSprite (phaser.js:100039) at World.collideHandler (phaser.js:99968) at World.collideObjects (phaser.js:99878) at Collider.update (phaser.js:103006) at World.update (phaser.js:99108) at EventEmitter.emit (phaser.js:1774) at Systems.step (phaser.js:35504) at SceneManager.update (phaser.js:77851) at Game.step (phaser.js:139643) eval @ VM27:52 collideSpriteVsSprite @ phaser.js:100039 collideHandler @ phaser.js:99968 collideObjects @ phaser.js:99878 update @ phaser.js:103006 update @ phaser.js:99108 emit @ phaser.js:1774 step @ phaser.js:35504 update @ phaser.js:77851 step @ phaser.js:139643 step @ phaser.js:67227 step @ phaser.js:67474 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476 requestAnimationFrame (async) step @ phaser.js:67476

my code:

// You can write more code here

/ START OF COMPILED CODE /

class Scene1 extends Phaser.Scene {

constructor() {

    super("Scene1");

}

_create() {

    var Bird = this.add.sprite(378.5, 184.0, "textures", "Bird");

    var Pig = this.add.sprite(414.5, 213.0, "textures", "Pig");

    this.fBird = Bird;
    this.fPig = Pig;

}

/* START-USER-CODE */

create() {
    this._create();
    this.cursors = this.input.keyboard.createCursorKeys();
    this.physics.add.existing(this.fBird);
    this.physics.add.existing(this.fPig);
}

hit(){ this.fPig.x = Phaser.Math.Between(0, 500); } update() {

    if(this.cursors.down.isDown){
        this.fBird.y += 1;
    }
    if(this.cursors.up.isDown){
        this.fBird.y -= 1;
    }
    if(this.cursors.left.isDown){
        this.fBird.x -= 1;
    }
    if(this.cursors.right.isDown){
        this.fBird.x += 1;
    }
            this.physics.add.overlap(this.fBird, this.fPig, function(){this.fBird.x = 100});

}

/* END-USER-CODE */

}

/ END OF COMPILED CODE /

// You can write more code here

// You can write more code here

/ START OF COMPILED CODE /

/ END OF COMPILED CODE /

// You can write more code here

PhaserEditor2D commented 4 years ago

Hi, did you started the physics system in the creation of the game?

Something like this:


var game = new Phaser.Game({
    "title": "Sunny Land Woods",
    "width": 288,
    "height": 192,
    "type": Phaser.WEBGL,
    "backgroundColor": "#000",
    "parent": "game-container",
    "scale": {
        "mode": Phaser.Scale.FIT,
        "autoCenter": Phaser.Scale.CENTER_BOTH
    },
    physics: {
        default: "arcade",
        arcade: {
            debug: false
        }
    },
    pixelArt: true
});

Note the physics configuration.

ghost commented 4 years ago

yes

ghost commented 4 years ago

Uncaught TypeError: Cannot set property 'x' of undefined

PhaserEditor2D commented 4 years ago

Well, if you send me the project (developers@phasereditor2d.com) I can test here locally and try to reproduce the issue, to find a solution.