좋아, 이건 어리석게 쉬운 일 이겠지만 어떤 이유 때문에 그냥 잡기가 쉽지가 않아.애니메이션의 전환 프레임
내가 서있는 애니메이션을 가지고 있고, 내가 원하는 것을 움직이는 애니메이션이 두 애니메이션 해당 증속 단일 프레임 전환을 재생하는 것입니다, 내가 달성하는 것 기운이 여기
아마도 내 코드입니다 (논리 값으로 그것을 시도) 누군가가 도울 수 있습니다.또한 왼쪽/오른쪽을 향한 별도의 애니메이션을 수행합니다. 단일 애니메이션을 뒤집을 수있는 방법이 있습니까? 멍청한 놈 코더에서 미리
덕분에 - Heres는 일부 irrelivent 물건을 내 코드는지도에서 얻을
public class Player extends Sprite implements InputProcessor {
private Vector2 velocity = new Vector2();
private float speed = 60 * 2, gravity = 60 * 2.2f, animationTime = 0;
private boolean canJump;
private boolean attacking;
private boolean starting = true;
private Animation still, left, right, attack, start;
private TiledMapTileLayer collisionLayer;
public Player(Animation still, Animation left, Animation right, Animation attack, Animation start, TiledMapTileLayer collisionLayer) {
super(still.getKeyFrame(0));
this.still = still;
this.left = left;
this.right = right;
this.attack = attack;
this.start = start;
this.collisionLayer = collisionLayer;
setSize(getWidth(), getHeight() /* * 1.5f*/);
//setScale((float) 1.4);
}
@Override
public void draw(SpriteBatch spriteBatch) {
update(Gdx.graphics.getDeltaTime());
super.draw(spriteBatch);
// update animation
animationTime += delta;
setRegion(
velocity.x < 0 ? left.getKeyFrame(animationTime) :
velocity.x > 0 ? right.getKeyFrame(animationTime) :
attacking == true ? attack.getKeyFrame(animationTime) :
still.getKeyFrame(animationTime));
}
@Override
public boolean keyDown(int keycode) {
switch(keycode) {
case Keys.W:
if(canJump) {
velocity.y = speed/1.8f;
canJump = false;
}
break;
case Keys.A:
velocity.x = -speed;
animationTime = 0;
break;
case Keys.D:
velocity.x = speed;
animationTime = 0;
case Keys.I:
attacking = true;
animationTime = 0.15f;
}
return true;
}
@Override
public boolean keyUp(int keycode) {
switch(keycode) {
case Keys.A:
case Keys.D:
velocity.x = 0;
animationTime = 0;
case Keys.I:
animationTime = 0;
attacking = false;
}
return true;
}
그리고 내 화면에서
을 잘라@Override
public void show() {
map = new TmxMapLoader().load("maps/map.tmx");
camera = new OrthographicCamera();
batch = new SpriteBatch();
backimage = new Sprite(new Texture("images/backgrounds/background.png"));
playerAtlas = new TextureAtlas("img/player/player.pack");
Animation still, left, right, attack, start;
still = new Animation(2/2f, playerAtlas.findRegions("still"));
left = new Animation(1/6f, playerAtlas.findRegions("left"));
right = new Animation(2/26f, playerAtlas.findRegions("right"));
attack = new Animation(1/6f, playerAtlas.findRegions("attack"));
start = new Animation(1/2f, playerAtlas.findRegions("start"));
still.setPlayMode(Animation.LOOP);
left.setPlayMode(Animation.LOOP);
right.setPlayMode(Animation.LOOP);
start.setPlayMode(Animation.NORMAL);
attack.setPlayMode(Animation.NORMAL);
player = new Player(still, left, right, attack, start, (TiledMapTileLayer) map.getLayers().get(0));
MapLayer layer = map.getLayers().get("objects");
for(MapObject object : layer.getObjects())
if(object.getName().equals("playerstart"))
player.setPosition(object.getProperties().get("x", Integer.class), object.getProperties().get("y", Integer.class));
Gdx.input.setInputProcessor(player);
}
Btw는 나머지 아름답게 일 – user2873364