我想更改播放器的偏移量,它根本不会移动,而我也没有将原点设置为移动,因此我可以将精灵旋转一个偏移量,并可以使纹理在其顶部旋转因此它可以像在另一端那样工作。您会在我设定的来源中看到尝试此操作但未成功的地方
package com.mygdx.game.Sprites.weapons;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.World;
import com.mygdx.game.PlayScreen;
import com.mygdx.game.main;
import com.mygdx.game.Sprites.player.LArm;
import com.mygdx.game.Sprites.player.Player;
@SuppressWarnings("unused")
public class FireRifle extends Sprite {
private static boolean xflip = false;
private static boolean yflip = false;
private static World world;
//public static Body b2body;
public FireRifle(PlayScreen screen){
FireRifle.world = screen.getWorld();
setRegion(new Texture(Gdx.files.internal("fire rifle.png")));
setBounds(PlayScreen.larm.getX(),PlayScreen.larm.getY(), 8 / main.PPM, 19 / main.PPM);
}
public void update(float dt) {
if(!Player.runningRight) {
if(xflip == true) {
flip(true, false);
xflip = false;
}
if(yflip == false) {
flip(false, true);
yflip = true;
}
this.setPosition(PlayScreen.larm.getX(), PlayScreen.larm.getY());
}
if(Player.runningRight) {
if(xflip == false) {
flip(true, false);
xflip = true;
}
this.setPosition(PlayScreen.larm.getX(), PlayScreen.larm.getY()+5/main.PPM);
this.setOrigin(2, 2);
//this.setPosition(
//(float) (PlayScreen.larm.getX()-(Math.sin(LArm.b2body.getAngle())/60)),
//(float) ((PlayScreen.larm.getY()+this.getWidth()/1.6)+(Math.cos(LArm.b2body.getAngle())/60)));
// have to use (Math.cos(LArm.b2body.getAngle())/7.25) with this now to get it to move on rotation thingy yea
}
this.setOrigin(PlayScreen.larm.getOriginX(), PlayScreen.larm.getOriginY());
//this.setPosition(PlayScreen.larm.getX(), PlayScreen.larm.getY());
this.setRotation(PlayScreen.larm.getRotation()+0);
System.out.println("x fliped: " + this.isFlipX());
System.out.println("y fliped: " + this.isFlipY());
}
}