javalibgdxoverlap2d

Field not found: pixelToWorld (com.uwsoft.editor.renderer.data.ProjectInfoVO)


I got this error when compile desktop application:

Exception in thread “LWJGL Application” com.badlogic.gdx.utils.SerializationException: Field not found: pixelToWorld (com.uwsoft.editor.renderer.data.ProjectInfoVO)
at com.badlogic.gdx.utils.Json.readFields(Json.java:776)
at com.badlogic.gdx.utils.Json.readValue(Json.java:902)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:714)
at com.uwsoft.editor.renderer.resources.ResourceManager.loadProjectVO(ResourceManager.java:334)
at com.uwsoft.editor.renderer.resources.ResourceManager.initAllResources(ResourceManager.java:86)
at com.uwsoft.editor.renderer.Overlap2DStage.initSceneLoader(Overlap2DStage.java:92)
at com.mygdx.Test.GameStage.<init>(GameStage.java:9)
at com.mygdx.Test.TestGame.create(TestGame.java:15)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)

I have check my project.dt and I found field ‘pixelToWorld’. Why is this happen? Here to view my project.dt: http://pastebin.com/FqnVkw8p


UPDATE:

I follow this tutorial: making-physics-based-side-scroller-project-setup-part-1

I only have 2 class in my core project. GameStage.java and TestGame.java

GameStage.java

package com.mygdx.Test;

import com.uwsoft.editor.renderer.Overlap2DStage;

public class GameStage extends Overlap2DStage{
    public GameStage() {

        // This will create SceneLoader instance and configure all things like default resource manager, physics e.t.c
        initSceneLoader();

        // This will load MainScene data from json and make Actors from it
        sceneLoader.loadScene("MainScene");

        // Get the root actor and add it to stage
        addActor(sceneLoader.getRoot());
    }
}

TestGame.java

package com.mygdx.Test;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class TestGame extends ApplicationAdapter {

    private GameStage stage;

    @Override
    public void create () {
        stage = new GameStage();
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(0.8f, 0.8f, 0.8f, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        stage.act();
        stage.draw();
    }
}

Solution

  • I've been looking into sources you can find here and what I've found is that the sceneLoader.loadScene() method returns the object with Scene that is being kept in HashMap with .dt (I guess it is something like .json) file name.

    The thing is that method loadScene() is looking for a pixelToWorld field but there is no pixelToWorld in MainScene.dt

    I guess you should call sceneLoader.loadScene("project"); or you have done something wrong with MainScene.dt and this is why there is no pixelToWorld