我是Libgdx引擎的新手。我一直在试图让球随机移动并且边缘反弹。这花了我两天,我无法做到。我只有球在上下跳动。这个引擎缺乏文档,所以很难学习它。任何帮助表示赞赏。Libgdx球类游戏
0
A
回答
2
一些伪代码:
If ball.radius + ball.x >= srceen.width or ball.x - ball.radius <= 0
ball.velocityx *= -1
+0
谢谢,但我想要实际的代码。 – Tareq
+3
不知道其余代码的布局,变量名等等,这几乎是不可能的。尝试并实施与上述类似的系统。 – Triclops200
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;
}
好运。
相关问题
- 1. 球类游戏 - 换球位置
- 2. AS3 - 抓球游戏
- 3. 桌面包libgdx游戏
- 4. Libgdx存储游戏物品
- 5. Android Studio LibGDX游戏问题
- 6. 设置延迟libgdx游戏
- 7. Libgdx游戏 - 纹理缩放
- 8. Libgdx tic tac toe游戏
- 9. libGDX游戏行事缓慢
- 10. Libgdx资产游戏设计
- 11. libGDX:游戏通用速度
- 12. LibGdx弓箭游戏物理
- 13. deWiTTERS游戏循环在LibGDX
- 14. 导入示例Libgdx游戏
- 15. 多人游戏 - 同步球
- 16. 制作乒乓球游戏
- 17. 游戏:球反弹逻辑
- 18. 撞球游戏不工作
- 19. Visual Basic - 跳球游戏
- 20. HTML基本弹球游戏
- 21. 为Android游戏生成球
- 22. 球不会加载游戏
- 23. C#XNA桨球游戏
- 24. 多线程多球游戏
- 25. 蟒蛇板球游戏
- 26. 桨游戏 - 球接触桨
- 27. Java弹跳球游戏 - 滚球场景
- 28. LibGdx Box2d游戏平台游戏跳转执行
- 29. Google Play多人游戏切换到游戏屏幕Libgdx
- 30. Libgdx scene2d 3D游戏与2D逻辑?
我认为libgdx有非常好的文档。只是谷歌它.. http://steigert.blogspot.ie/2012/02/1-libgdx-tutorial-introduction.html是一个很好的教程...它使用libgdx 0.9.2这是有点旧,但它会得到你开始 –