Android LibGDX 'Cannot resolve symbol setRadius'
Android LibGDX 'Cannot resolve symbol setRadius'
我正在使用 Box2d,libGDX 并导入了...physics。box2d.CircleShape;我做错了什么以至于 setRadius 不可接受。谢谢你的时间。
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.Shape;
import com.badlogic.gdx.physics.box2d.World;
import com.sun.xml.internal.ws.client.sei.ResponseBuilder;
import sun.security.pkcs11.wrapper.Constants;
我正在尝试按照 Github 教程进行操作。我检查了 API 指南并遵循了功能规则。它不建议再导入。
尝试刷新gradle的所有依赖项。我认为您使用 Android Studio 。 Here是怎么用它刷新的
如果您使用 Eclipse -> 右键单击项目 ->Gradle -> 全部刷新。
The Box2d natives, loaded in the code, to create world class, you have to have them loaded, before using, or also can use box2d.init(),我的英文很不好,你可以在这里阅读:
P.S: 我不太记得是什么错误了,我现在也看不到,但我认为这会有所帮助
新:
resulting this error:
java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.CircleShape.newCircleShape()J
at com.badlogic.gdx.physics.box2d.CircleShape.newCircleShape(Native Method)
at com.badlogic.gdx.physics.box2d.CircleShape.(CircleShape.java:30)
现在就找网络,如果你有类似这样的错误,我认为它应该加载,box2d before the World crearcion or box2d.init () are with;在使用 classes.
之前
错误已确认,在这个线程中,我不记得它是什么,但他之前有加载过的预设 ->
https://github.com/libgdx/libgdx/issues/2393
故事的寓意:将指令放在函数中。不要把它们放在 class 中,就像它是一个变量一样。抱歉,我花了一个多小时才弄清楚自己有多蠢。我知道的任何语言都不允许,即使有构造函数,我很抱歉我会 reRTFM。感谢您忍受这一点,我确实从您的所有建议中学到了一些东西。如果需要我会 edit/remove 这个问题。
@Override
public void create () {
batch = new SpriteBatch();
// Initiate Sprite
img = new Texture("heavybreathing.jpg");
sprite = new Sprite(img);
Red = new Sprite(new Texture("Red.png"));
screenHeight = Gdx.graphics.getHeight();
screenWidth = Gdx.graphics.getWidth();
font = new BitmapFont();
font.setColor(Color.GREEN);
font.getData().scale(5);
Gdx.input.setInputProcessor(this);
CircleShape circle1 = new CircleShape();
circle1.setRadius(6f);
}
我正在使用 Box2d,libGDX 并导入了...physics。box2d.CircleShape;我做错了什么以至于 setRadius 不可接受。谢谢你的时间。
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.Shape;
import com.badlogic.gdx.physics.box2d.World;
import com.sun.xml.internal.ws.client.sei.ResponseBuilder;
import sun.security.pkcs11.wrapper.Constants;
我正在尝试按照 Github 教程进行操作。我检查了 API 指南并遵循了功能规则。它不建议再导入。
尝试刷新gradle的所有依赖项。我认为您使用 Android Studio 。 Here是怎么用它刷新的
如果您使用 Eclipse -> 右键单击项目 ->Gradle -> 全部刷新。
The Box2d natives, loaded in the code, to create world class, you have to have them loaded, before using, or also can use box2d.init(),我的英文很不好,你可以在这里阅读:
P.S: 我不太记得是什么错误了,我现在也看不到,但我认为这会有所帮助
新:
resulting this error:
java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.CircleShape.newCircleShape()J
at com.badlogic.gdx.physics.box2d.CircleShape.newCircleShape(Native Method)
at com.badlogic.gdx.physics.box2d.CircleShape.(CircleShape.java:30)
现在就找网络,如果你有类似这样的错误,我认为它应该加载,box2d before the World crearcion or box2d.init () are with;在使用 classes.
之前错误已确认,在这个线程中,我不记得它是什么,但他之前有加载过的预设 -> https://github.com/libgdx/libgdx/issues/2393
故事的寓意:将指令放在函数中。不要把它们放在 class 中,就像它是一个变量一样。抱歉,我花了一个多小时才弄清楚自己有多蠢。我知道的任何语言都不允许,即使有构造函数,我很抱歉我会 reRTFM。感谢您忍受这一点,我确实从您的所有建议中学到了一些东西。如果需要我会 edit/remove 这个问题。
@Override
public void create () {
batch = new SpriteBatch();
// Initiate Sprite
img = new Texture("heavybreathing.jpg");
sprite = new Sprite(img);
Red = new Sprite(new Texture("Red.png"));
screenHeight = Gdx.graphics.getHeight();
screenWidth = Gdx.graphics.getWidth();
font = new BitmapFont();
font.setColor(Color.GREEN);
font.getData().scale(5);
Gdx.input.setInputProcessor(this);
CircleShape circle1 = new CircleShape();
circle1.setRadius(6f);
}