Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A error when load a json tilemap #388

Open
khuonghoanghuy opened this issue May 21, 2023 · 11 comments
Open

A error when load a json tilemap #388

khuonghoanghuy opened this issue May 21, 2023 · 11 comments

Comments

@khuonghoanghuy
Copy link

I tried to load a json tilemap using json file, after build game, the game got crash and give me:
crash

i tried to rebuild game, fixing stuff but still give me the same dialogue box

im using Ogmo Editior 3 to make tilemap!

@Geokureli
Copy link
Member

share the map and the code you used

@khuonghoanghuy
Copy link
Author

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);

@khuonghoanghuy
Copy link
Author

my map:

as

@khuonghoanghuy
Copy link
Author

or the .zip file:

lev1.zip

@Geokureli
Copy link
Member

can you share the tilemap 1 png and the ogmo file?

@khuonghoanghuy
Copy link
Author

here:

tilemap_level.zip

@Geokureli
Copy link
Member

Geokureli commented May 23, 2023

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

@khuonghoanghuy
Copy link
Author

khuonghoanghuy commented May 24, 2023

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

@Geokureli
Copy link
Member

Its really hard to diagnose bugs by proxy. Can you put your project on a public github repo and link it here?

@khuonghoanghuy
Copy link
Author

@Geokureli
Copy link
Member

Geokureli commented May 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants