Open khuonghoanghuy opened 1 year ago
share the map and the code you used
my code to import:
map = new FlxOgmo3Loader(Paths.levelProject__ogmo, jsonPaths); walls = map.loadTilemap(Paths.tilemap_1__png, 'walls'); walls.follow(); walls.setTileProperties(1, NONE); walls.setTileProperties(2, ANY); add(walls);
my map:
or the .zip file:
can you share the tilemap 1 png and the ogmo file?
here:
this works for me, I see some issues but not the one you're experiencing.
This error typically happens when there's an error finding the tiles graphic, I see you're using Paths, so it seems unlikely but lets double check.
try commenting out the following lines
walls.setTileProperties(1, NONE);
walls.setTileProperties(2, ANY);
and add the following line:
var bmd = flixel.system.FlxAssets.getBitmapData(Paths.tilemap_1__png);
if (bmd == null)
throw "missing asset: " + Paths.tilemap_1__png;
else
trace('asset found, width:${bmd.width} height:${bmd.height}'); // should be 48x64
make sure you compile in debug mode
This give me a log:
source/lev/PlayState.hx:116: load: assets/data/lev/freeplay/lev1.json source/lev/PlayState.hx:166: asset found, width:48 height:64 Called from hxcpp::__hxcpp_main Called from ApplicationMain::main ApplicationMain.hx line 26 Called from ApplicationMain::create ApplicationMain.hx line 135 Called from lime.app.Application::exec lime/app/Application.hx line 150 Called from lime._internal.backend.native.NativeApplication::exec lime/_internal/backend/native/NativeApplication.hx line 146 Called from lime._internal.backend.native.NativeApplication::handleRenderEvent lime/_internal/backend/native/NativeApplication.hx line 371 Called from lime.app._Event_lime_graphics_RenderContext_Void::dispatch lime/_internal/macros/EventMacro.hx line 91 Called from openfl.display.Stage::onLimeRender openfl/display/Stage.hx line 2046 Called from openfl.display.Stage::broadcastEvent openfl/display/Stage.hx line 1181 Called from openfl.display.DisplayObject::dispatch openfl/display/DisplayObject.hx line 1399 Called from openfl.events.EventDispatcher::dispatchEvent openfl/events/EventDispatcher.hx line 402 Called from flixel.FlxGame::onEnterFrame flixel/FlxGame.hx line 550 Called from flixel.FlxGame::step flixel/FlxGame.hx line 682 Called from flixel.FlxGame::update flixel/FlxGame.hx line 729 Called from flixel.FlxGame::switchState flixel/FlxGame.hx line 642 Called from lev.PlayState::create lev/PlayState.hx line 182 Called from flixel.tile.FlxBaseTilemap::setTileProperties flixel/tile/FlxBaseTilemap.hx line 827
and crash again
Its really hard to diagnose bugs by proxy. Can you put your project on a public github repo and link it here?
your jsonPaths
is "" that's why it's erroring, for me. when I replace
map = new FlxOgmo3Loader(Paths.levelProject__ogmo, jsonPaths);
with
map = new FlxOgmo3Loader(Paths.levelProject__ogmo, "assets/data/lev/freeplay/lev1.json");
It doesn't fail on the that line but it then errors on setTileProperties, but not for "walls", but for "fruitShop". this makes sense because shop.png only has one frame, or a frame index of 0.
also flixel takes all tiles -1 and makes them tile 0, your tile 0 in tilemap_1.png is a grass tile, I recommend adding an empty frame as the "empty" 0 frame. also why are you calling the following on every tilemap?
stone.setTileProperties(1, NONE);
stone.setTileProperties(2, ANY);
this doesn't really fit your tiles
I tried to load a json tilemap using json file, after build game, the game got crash and give me:
i tried to rebuild game, fixing stuff but still give me the same dialogue box
im using Ogmo Editior 3 to make tilemap!