colinvella / phaser-tilemap-plus-demo

Demo application for Phaser plugin phaser-tilemap-plus
MIT License
5 stars 2 forks source link

Body.plus does not have contactNormal (also missing other fields) #3

Closed bayruns closed 6 years ago

bayruns commented 6 years ago

I forked and downloaded the repo, ran npm install, then npm start. I can see the title screen and that works, but once the game starts it crashes in the PlayState update() when it tries to access body.plus.contactNormal.length(). However, I changed the code to avoid using the normals and was able to get the demo to actually display the game map. Obviously the game didn't function without movement and whatnot, but all of the tiles were animated, etc.

I'm running NPM 3.10.10 with your most up to date version. Previously had version 0.9.1 or so and the issue was also present there. From package.json:

"dependencies": {
    "lodash": "^4.17.4",
    "phaser-ce": "^2.9.1",
    "phaser-tilemap-plus": "^0.10.2",
    "poly-decomp": "^0.2.1"
  },

Here's the contents of body.plus when it errors out on Cannot access property length of undefined on the attempted call to body.plus.contactNormal.length():

Contents of body.plus


  "shape": {
    "vertices": [
      {
        "x": 10,
        "y": -10
      },
      ...
      {
        "x": 10,
        "y": 10
      }
    ],
    "aabb": {
      "left": -10,
      "right": 10,
      "top": -19.84807753012208,
      "bottom": 19.84807753012208
    },
    "edges": [
      {
        "x": -0.6030737921409148,
        "y": -3.420201433256686
      },
      ...
      {
        "x": 0,
        "y": -20
      }
    ],
    "normals": [
      {
        "x": 0.9848077530122081,
        "y": -0.17364817766693003
      },
     ...
      {
        "x": 1,
        "y": 0
      }
    ],
    "count": 20,
    "centre": {
      "x": 8.881784197001253e-17,
      "y": 5.329070518200751e-16
    }
  }
}```
bayruns commented 6 years ago

I don't know what changed but I did a git reset --hard head (although I think I tried this the other night) and things are working now. Strange. It may have been a problem I had last night with something where multiple npm starts were running at once. I'm going to mark this as closed haha

colinvella commented 6 years ago

Glad to hear you sorted it out :)