GameQuery 碰撞检测
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是箭头嵌套在一组中。因此,您需要将组添加到碰撞检测中:
或者
不用担心碰撞()函数不会返回组。您只需将它们包含在过滤器中,否则将不会检查它们的子级是否发生碰撞。
Your problem is that the arrows are nested in a group. So you need to add the group to the collision detection:
or
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.