【发布时间】:2014-07-06 17:45:46
【问题描述】:
我在 libgdx 中使用平铺。我正在做一个类似于最终幻想 1、2 等的自上而下的 rpg。
我用 setX(getX() + velocity.x * delta);和 setY(getY() + velocity.y * delta); 在地图上移动玩家。 我怎样才能让玩家逐块移动。以及我将如何检查哪个瓷砖是 玩家在?有人能帮我吗。谢谢。
我发现了这个:
void update()(
// Getting the target tile
if ( rightArrowPressed ) {
targetX = (int)(currentX + 1); // Casting to an int to keep
// the target to next tile
}else if ( leftArrowPressed ){
targetX = (int)(currentX - 1);
}
// Updating the moving entity
if ( currentX < targetX ){
currentX += 0.1f;
}else if ( currentX > targetX ){
currentX -= 0.1f;
}
}
来自:libGDX: How to implement a smooth tile / grid based game character movement?
但我似乎可以在我的游戏中实现它。
【问题讨论】:
标签: java libgdx desktop-application