IceCreamYou/HTML5-Canvas-Game-Boilerplate

TypeError: collideWith.getAll is not a function

nossidge opened this issue · 1 comments

Within the Actor.collideSolid() function there is a section of code:

...
else if ((typeof Collection !== 'undefined' && collideWith instanceof Collection) ||
    (typeof TileMap !== 'undefined' && collideWith instanceof TileMap)) {
  var items = collideWith.getAll();
...

This results in an error when collideWith is a Collection, because getAll() is not defined in Collection (only in TileMap)

A similar problem occurs in Actor.standingOn()

My solution was not to add an additional clause to these if statements, but to standardise by adding to the Collection.prototype:

getAll: function() {
  return this;
},

Thanks for the report. I have pushed a fix along the lines of what you suggested and it will be included in the next release.