I’m back with another noob support question, despite me being a moderator and this being a very small community atm. As far as efficiency/optimization is concerned, what’s the best approach to making a really big open world, and then how do I actually implement it?? My stack:
- OS: Windows 10
- IDE: VSCode
- Game engine: Haxe Flixel
- Pixel art: PixiEditor
- Map making: LDtk
I know how to just make one huge level, that’s easy enough, but I’ve heard that might be inefficient memory-wise? I tried setting up multiple levels in LDtk, and importing each level into its own FlxTilemap. But then I couldn’t figure out how to get more than one tilemap to actually display? Only the first one I add shows up. Maybe the second one is loaded but just hidden underneath it, but if so, how do I tell a FlxTilemap where it should show up? They seem to default to (0,0) and I didn’t any method to change that. Or maybe you can just only have one tilemap in any given scene at a time? Would it be better to use the render method of the LDtk api instead of a FlxTilemap? I heard FlxTilemap is more efficient because it batch renders everything, whereas the LDtk api renders each tile as its own sprite.
One last question. When I switched from Ogmo to LDtk, suddenly I couldn’t compile to Neko anymore. I get an Uncaught exception - std@module_read
erorr. I can test the game in HTML5, but it’s slower, and also for some reason the browser keeps caching old versions of the game so I have to clear everything to see any changes.
Places I’ve looked for answers so far:
- A guide from Ohsat Games
- The LDtk documentation
- The Flixel documentation
- This question on Stack Overflow
- This issue on GitHub
- The example projects in the repo for the LDtk Haxe api
- …and some discussions on the Deepnight Discord server
Maybe the answer is actually in these sources, but I’m too much of an amatuer to see it? Either way, I’d really appreciate some advice!
boop
UPDATE: Ok, I’m just unbelievably oblivious…
Sooo, Flixel tilemap objects do have “.x” and “.y” location parameters. You can literally just
myMap.x = 5
or whatever! I didn’t see it in the documentation for FlxTilemap because it inherits it from FlxBaseTilemap, which inherits it from FlxObject, which… is really obvious in retrospect. And LDtk levels that you pull into Haxe also have those exact same fields, so you can just point one to the other.Also, you can add all the tilemap objects to a FlxGroup and just call “add” and “collide” and stuff on that. It will pass everything along to each map. I’m pretty sure the appropriate way to go about this would be to use a loop to do something like this:
- Iterate through each LDtk level.
- Pull the IntGrid layer from that level.
- Create a FlxTilemap using that data.
- Set its position.
- add it to the FlxGroup.
I can’t figure out how to actually do that though, mostly because everything seems to need to be referenced by name? Like I can’t just go
intGrid = level[i]
wherei
is my iterator. Instead I have to go likeintGrid = level_name.intGrid_layer_name.json.intGridCsv
as far as I know?