GameQuery碰撞检测 [英] GameQuery Collision Detection

查看:73
本文介绍了GameQuery碰撞检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

他们似乎从来没有开枪?!? 我已经检查了所有.arrow的存在和.bot的存在,但似乎从未调用过该函数

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");
 });
});

您知道为什么这只是什么都不做吗?机器人沿着箭头右移(具有x值).

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.

非常感谢,

推荐答案

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

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(){

$(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.

这篇关于GameQuery碰撞检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆