GameQuery 碰撞检测

发布于 2024-09-04 13:26:34 字数 313 浏览 2 评论 0原文

我在 GameQuery (jQuery) 碰撞检测方面遇到问题

他们似乎永远不会开火?!? 我已经检查了所有 .arrow 的存在以及 .bot 的相同,但它似乎从未调用过

我的主回调中有以下代码的函数:

$(".bot").each(function(){
 $(this).collision(".arrow").each(function(){
  alert("Test");
 });
});

您知道为什么这只是什么都不做吗?机器人行走(具有 x 值)向右移动到箭头上方。

非常感谢,

I am having a problem with GameQuery (jQuery) collision detection

Tthey just never seem to fire?!?
I have checked all the .arrow's exist and the same for the .bot's but it just never seems to call the function

I have the below code in my main callback:

$(".bot").each(function(){
 $(this).collision(".arrow").each(function(){
  alert("Test");
 });
});

Do you have any idea why this would just simply be doing nothing? The bot walks (has it's x value) moved right over the arrow.

Many thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2024-09-11 13:26:35

您的问题是箭头嵌套在一组中。因此,您需要将组添加到碰撞检测中:

$(this).collision(".arrow,.group").each(function(){

或者

$(this).collision(".arrow,#arrows").each(function(){

不用担心碰撞()函数不会返回组。您只需将它们包含在过滤器中,否则将不会检查它们的子级是否发生碰撞。

Your problem is that the arrows are nested in a group. So you need to add the group to the collision detection:

$(this).collision(".arrow,.group").each(function(){

or

$(this).collision(".arrow,#arrows").each(function(){

Don't worry the groups are not returned by the collision() function. You just need to include them in the filter otherwise their children won't be checked for collision.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文