瓷砖碰撞问题
我正在研究瓷砖碰撞。目前,我只是以正常方式绘制图块地图(两个 for 循环)并且没有滚动。现在,要检查我的玩家是否位于图块上方,我使用tileX = (int)person1v.X / 16; tileY = (int)person1v.Y / 16; 但是,我想在撞到瓷砖之前检测到碰撞,以便它可以充当墙壁。如何在移动之前检测到碰撞?
I'm working on tile collision. Currently, I just draw the tile map the normal way (two for loops) and there is no scrolling. Right now, to check if my player is over a tile, I use tileX = (int)person1v.X / 16;
tileY = (int)person1v.Y / 16;
However, I want to detect collision before I hit the tile so it could act as a wall. How do I detect collision before even making the move?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果玩家一次移动 3 像素,则检查:
以及右侧的图块:
If the player moves 3 pixels at a time then check for:
And for the tile to the right:
与其先移动他,然后再检查碰撞,不如检查角色未来位置的碰撞,如果没有碰撞,则更改角色的位置。
well instead of moving him first and checking for collision afterwards, check for collision for the future position of the character and if there is no collision then change the character's position.