Java 纹理随机出现在角色LibGDX上方

Java 纹理随机出现在角色LibGDX上方,java,libgdx,box2d,Java,Libgdx,Box2d,我在游戏中增加了射击的能力,尽管效果很好,但出于某种原因,每次射击之间,精灵上方都会出现子弹纹理。结果是这样的: 我正在查看我的代码,但我找不到任何可以在那里绘制纹理的东西。纹理的位置设置为在子弹体上绘制,并且没有子弹体出现在上面。你知道为什么会有这种纹理吗?感谢您的帮助 这是我的子弹课: public bullet(playScreen screen, float x, float y, boolean fireRight){ this.fireRight = fireRight;

我在游戏中增加了射击的能力,尽管效果很好,但出于某种原因,每次射击之间,精灵上方都会出现子弹纹理。结果是这样的:

我正在查看我的代码,但我找不到任何可以在那里绘制纹理的东西。纹理的位置设置为在子弹体上绘制,并且没有子弹体出现在上面。你知道为什么会有这种纹理吗?感谢您的帮助

这是我的子弹课:

public bullet(playScreen screen, float x, float y, boolean fireRight){
    this.fireRight = fireRight;
    this.screen = screen;
    this.world = screen.getWorld();

    tearPopAtlas = new TextureAtlas("tear_pop.pack");

    frames = new Array<TextureRegion>();
    for(int i = 0; i < 5; i++){
        frames.add(new TextureRegion(tearPopAtlas.findRegion("tear_pop"), i * 32, 0, 64, 64));
    }
    for(int i = 0; i < 5; i++){
        frames.add(new TextureRegion(tearPopAtlas.findRegion("tear_pop"), i * 32, 32, 64, 64));
    }
    for(int i = 0; i < 5; i++){
        frames.add(new TextureRegion(tearPopAtlas.findRegion("tear_pop"), i * 32, 64, 64, 64));
    }
    bulletDestroyedAnimation = new Animation<TextureRegion>(0.1f, frames);

    setRegion(bulletDestroyedAnimation.getKeyFrame(0));
    setBounds(x, y, 32 / icsGame.PPM, 32 / icsGame.PPM);
    defineBullet();
}

public void defineBullet(){
    FixtureDef fdef;
    CircleShape shape;
    BodyDef bdef = new BodyDef();
    bdef.position.set(fireRight ? getX() + 0.05f / icsGame.PPM : getX() - 0.05f, getY());
    bdef.type = BodyDef.BodyType.DynamicBody;
    if(!world.isLocked())
        b2Body = world.createBody(bdef);

    fdef = new FixtureDef();
    shape = new CircleShape();
    shape.setRadius(3 / icsGame.PPM);
    fdef.filter.categoryBits = icsGame.BULLET_BIT;
    fdef.filter.maskBits = icsGame.DEAFAULT_BIT | icsGame.ENEMY_BIT | icsGame.DOOR_BIT;

    fdef.shape = shape;
    fdef.friction = 0;
    b2Body.createFixture(fdef).setUserData(this);
    b2Body.setLinearVelocity(new Vector2(fireRight ? 2f : -2f, 0));
}

public void update(float dt){
    stateTime += dt;
    setPosition(b2Body.getPosition().x - getWidth() / 2, b2Body.getPosition().y - getHeight() / 2);
    if((stateTime > 1 || setToDestroy) && !destroyed){
        world.destroyBody(b2Body);
        destroyed = true;
    }

    if((fireRight && b2Body.getLinearVelocity().x < 0) || (!fireRight && b2Body.getLinearVelocity().x > 0)){
        setToDestroy();
    }

}

public void setToDestroy(){
    setToDestroy = true;
}

public boolean isDestroyed(){
    return destroyed;
}
}

这些都是与我的子弹有关的代码片段,我不明白为什么子弹纹理会在它所在的位置绘制

你的bullet draw方法在哪里?draw方法的循环每帧迭代多少次?什么->超级绘图(批量);
for(bullet bullet : bullets){
        bullet.update(dt);
        if(bullet.isDestroyed())
            bullets.removeValue(bullet, true);
    }

 if(currentStateShooting == State.EASTWEST && shootTimer >= SHOOT_WAIT_TIME) {
        shootTimer = 0;
        fire();
    }

 public void fire(){
    bullets.add(new bullet(screen, isaac.ISAACX, isaac.ISAACY, shootingRight ? true : false));
}

public void draw(Batch batch){
    super.draw(batch);
    for(bullet bullet : bullets){
        bullet.draw(batch);
    }
}