I’m trying to modify some phaser 2 code to work with phaser 3 and am having an issue setting some data.
I have a sprite ‘tile’ that I set data for:
tile.setData({ row: x / _this.tileWidth, column: y / _this.tileHeight, words: {}, letter: letter, startWord: false});
This works fine but later in the code the Phaser 2 version adds a word and some properties to the words array in data(‘entry’ is an object):
tile.data.words[entry.word] = { orientation: entry.orientation, length: entry.word.length };
In Phaser 3 sprite.data is a DataManager, not a plain object. You mustn’t set anything on tile.data, which is the manager. Use only tile.getData(), tile.setData(), or tile.data.values.
There are two ways to add properties to the words data value: