更改lib源代码而不破坏它

时间:2015-02-12 18:52:04

标签: java android libgdx

因此,当我找到 BodyEditorLoader.java 的修补源代码时,我无法对.java文件进行任何更改。如何在不破坏库的情况下编辑它?谢谢!

1 个答案:

答案 0 :(得分:1)

我希望能够很好地解释,一个简单的方法是创建一个新类,复制BodyEditorLoader类的内容,类包名package aurelienribon.bodyeditor;除外,并用您的名称重命名public class BodyEditorLoader class,例如MyBodyEditorLoader。例如:

//package aurelienribon.bodyeditor;  --> change or delete for your packege name

package com.tynibattles04.game;    //--> in your case for example.

import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyBodyEditorLoader {
    //...other code
    public MyBodyEditorLoader(FileHandle file) {
    //...other code
    }

    public MyBodyEditorLoader(String str) {
    //...other code
    }
    //..other code

并使用(和导入,如果您需要它):

MyBodyEditorLoader loader = new MyBodyEditorLoader(
                          Gdx.files.internal("tankA.json"));