【发布时间】:2013-05-31 16:09:15
【问题描述】:
我对 Libgdx 引擎真的很陌生。我一直在尝试让球随机移动并反弹边缘。我花了两天时间,我做不到。我只有球上下弹跳。该引擎缺乏文档,因此很难学习。任何帮助表示赞赏。
【问题讨论】:
-
我认为 libgdx 有很好的文档。谷歌一下吧..steigert.blogspot.ie/2012/02/… 是一个很好的教程...它使用了有点旧的 libgdx 0.9.2,但它会让你开始
我对 Libgdx 引擎真的很陌生。我一直在尝试让球随机移动并反弹边缘。我花了两天时间,我做不到。我只有球上下弹跳。该引擎缺乏文档,因此很难学习。任何帮助表示赞赏。
【问题讨论】:
一些伪代码:
If ball.radius + ball.x >= srceen.width or ball.x - ball.radius <= 0
ball.velocityx *= -1
【讨论】:
你可以试试这个:
rev=-1;
vy = intSpeedY;
vx = intSpeedX;
ball.x += vx;
ball.y += vy;
if (ball.x + ball.radius > right) {
ball.x = right - ball.radius;
vx *= rev;
} else if (ball.x - ball.radius < left) {
ball.x = left + ball.radius;
vx *= rev;
}
if (ball.y + ball.radius > bottom) {
ball.y = bottom - ball.radius;
vy *= rev;
} else if (ball.y - ball.radius < top) {
ball.y = top + ball.radius;
vy *= rev;
}
祝你好运。
【讨论】: