TileMap broken in v16

23 views
Skip to first unread message

James McGeorge

unread,
Apr 8, 2018, 12:35:02 PM4/8/18
to excaliburjs
Hey all,

Just updated from v14 to v16 yesterday and noticed that the TileMap/TileMapImpl class does not function properly at all.

Dug deeper into the source and it looks like the TileMapImpl constructor is not assigning it's own variables,

ie:

if (xOrConfig && typeof xOrConfig === 'object') {
var config = xOrConfig;
xOrConfig = config.x;
y = config.y;
cellWidth = config.cellWidth;
cellHeight = config.cellHeight;
rows = config.rows;
cols = config.cols;
}
this.data = new Array<Cell>(rows * cols);

So later down the line when you try to tilemap.getCell(x,y) the function refers to this.cols, which is undefined, giving you an undefined result instead of a Cell or null (this is the error I was getting upon loading).

Looking further down at the Cell implementation I saw what you were going for and it looks like the variable assignment was just missed after checking if the xOrConfig was an object.

ie:

if (xOrConfig && typeof xOrConfig === 'object') {
var config = xOrConfig;
xOrConfig = config.x;
y = config.y;
cellWidth = config.cellWidth;
cellHeight = config.cellHeight;
rows = config.rows;
cols = config.cols;
}
this.x = <number>xOrConfig;
this.y = y;
this.cellWidth = cellWidth;
this.cellHeight = cellHeight;
this.rows = rows;
this.cols = cols;
this.data = new Array<Cell>(rows * cols);

After adding that and compiling I can again push sprites to my cells :)

Kamran Ayub

unread,
Apr 8, 2018, 3:13:42 PM4/8/18
to James McGeorge, excaliburjs
Thanks James, did you want to open a PR and we can issue a hotfix?

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To post to this group, send email to excal...@googlegroups.com.
Visit this group at https://groups.google.com/group/excaliburjs.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/bbdf1115-e373-41ac-ba0e-fe8c3ebb63bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James McGeorge

unread,
Apr 8, 2018, 6:44:47 PM4/8/18
to excaliburjs
Sure I'd love to, I'm just a little new to using version repositories... only have my own stuff locally with Git.

I'll give it a shot, just let me know if I'm doing it totally wrong.

Erik Onarheim

unread,
Apr 10, 2018, 8:43:28 AM4/10/18
to excaliburjs
Hi James,

For the forum thread, your PR has been merged. It will definitely be included in the v0.17.0 release, if not sooner in a hotfix.

In the mean time an alpha npm package is available with your fix https://www.npmjs.com/package/excalibur version 0.16.0-alpha.2218


Thanks for helping out!
Erik

Kamran Ayub

unread,
Apr 10, 2018, 9:02:46 AM4/10/18
to Erik Onarheim, excaliburjs
Let us know if you run into any more issues, we are happy to help!

Reply all
Reply to author
Forward
0 new messages