我正在尝试更改android示例蛇应用程序的代码,当我按下右三角形并且蛇向右转时,.png文件(我认为它被称为'yellowstar.png')旋转90度,反之亦然. 我用真正的蛇头图像替换了 yellowstar.png,但目前的情况是,当蛇向右转时,蛇头保持在相同的“北面”方向。抱歉这个不具体的问题..我试图指定它们,所以你知道我的意思..
我更新了 Snakehead 的 PNG,现在我有 4 个 PNG。(头向左;头向上;头向右;头向下)头部使用哪种 PNG 取决于蛇的移动方向。有 4 个类(Backgroundview、Snake、SnakeView、TileView),我不确定在哪里加载我的 4 个新 PNG。
问题:
1.是否可以通过setTile()命令实现arkocal的建议?
2.如果 Q#1 是正确的:这是放置它的正确位置吗??:
//Figure out which way the snake is going, see if he's run into anything (the
//walls,himself, or an apple). If he's not going to die, we then add to the front
//and subtract from the rear in order to simulate motion. If we want to grow him, we
//don't subtract from the rear.
private void updateSnake() {
boolean growSnake = false;
// Grab the snake by the head
Coordinate head = mSnakeTrail.get(0);
Coordinate newHead = new Coordinate(1, 1);
mDirection = mNextDirection;
switch (mDirection) {
case EAST: {
newHead = new Coordinate(head.x + 1, head.y);
break;
}
case WEST: {
newHead = new Coordinate(head.x - 1, head.y);
break;
}
case NORTH: {
newHead = new Coordinate(head.x, head.y - 1);
break;
}
case SOUTH: {
newHead = new Coordinate(head.x, head.y + 1);
break;
}
}
3.如果这是错误的地方,请告诉我放在哪里
谢谢你的回答,
朱利安