Open nemoDreamer opened 6 years ago
You seem to have a good grasp of the code already! :)
As you figured out yourself, the system builds a structure that keeps track of the animated tiles. If you are confident you can submit a PR, please do go ahead! I think we should also look at other layer modification code besides removeTile(..).
Yup, I mentioned "swap", "randomize" etc above.
Tilemap.swap
will need to check for removal and potentially add a new tileLocation
(and maybe even a whole new tileAnimation
... (haven't checked if you add all available ones in the tileset, regardless of whether it's used.))
Tilemap.random
will only need to correct tileLocation
coordinates.
But yeah, nothing trivial in those 2... Then apart from the obvious "add", there's "copy", "paste", "replace",...
Damn... I understand why tile animations weren't made part of the core lib yet.
Would be a whole lot easier if it were the Tile
object itself that was responsible for managing its own animations...
Yeah, it would have been easier if it was encapsulated in each tile somehow. Also, when I initially coded the animation system, I didn't give much thought to map modification once it was loaded. I'll tackle this in the next update.
I realize this is a nice-to-have, but would make using animations more plug-and-play:
When calling
this.tilemap.removeTile(x, y, layer)
(or "swap", "randomize", etc...), the correspondingthis.tilemap.plus.tileAnimations[*].tileLocations[*]
doesn't get "corrected".I've currently got a crude external approach:
But would be sweet to have
removeTile
patched to remove "anytileLocations
at given coordinates wheretileAnimations
'frames
containsindex
".And while typing this, I just realized that I could just as well override
TileMap.prototype.removeTile
and make this less clunky...Maybe I'll send along a PR 😜