After the most recent update (3.22.4) there is an issue with the Tiles constructor.
If one of the Groups used in the Tiles constructor has a custom image used as the tile, the following error appears:
For example, the following code:
const g = new Group();
g.tile = "=";
g.img = loadImage("image.png"); //or whatever other valid image path
new Tiles(
["===="],
0, 0,
10, 10
);
will cause the aforementioned error.
I've traced the problem to line 641:
if (this._img || ani instanceof p5.Image) {
this.image = new $.EmojiImage(ani, w);
// ... rest of code
This code will be executed if ani is a p5.Image. However, the EmojiImage constructor treats the first argument (in this case, ani) as a String, and there is no case for if ani is a p5.Image. Thus, in _genTextImageKey, str (the first argument) should be a String but it is actually a p5.Image, and the error occurs.
I've found that if line 641 is changed to this.image = ani;, the issue is resolved.
EDIT: provided the Group has no animations, ani will always be an image by line 641. This is because of lines 613-627:
if (!group._isAllSpritesGroup) {
if (!ani) {
for (let _ani in group.animations) {
ani = _ani;
break;
}
if (!ani) {
ani = group._img;
if (typeof ani == 'function') {
ani = ani(group.length);
}
if (ani) this._img = true;
}
}
}
By this point, ani will be undefined. After the for loop over group.animations, ani will still be undefined (since the Group has no animations). Because !ani will then evaluate true, ani will be assigned to group._img. Since the Group has a custom image, this means that ani will always be a p5.Image by line 641.
After the most recent update (3.22.4) there is an issue with the Tiles constructor. If one of the Groups used in the Tiles constructor has a custom image used as the tile, the following error appears:
For example, the following code:
will cause the aforementioned error.
I've traced the problem to line 641:
This code will be executed if
ani
is ap5.Image
. However, theEmojiImage
constructor treats the first argument (in this case,ani
) as aString
, and there is no case for ifani
is ap5.Image
. Thus, in_genTextImageKey
,str
(the first argument) should be aString
but it is actually ap5.Image
, and the error occurs.I've found that if line 641 is changed to
this.image = ani;
, the issue is resolved.EDIT: provided the Group has no animations,
ani
will always be an image by line 641. This is because of lines 613-627:By this point,
ani
will beundefined
. After the for loop overgroup.animations
,ani
will still beundefined
(since the Group has no animations). Because!ani
will then evaluate true,ani
will be assigned togroup._img
. Since the Group has a custom image, this means thatani
will always be ap5.Image
by line 641.