GameQuery Collision Detection

梦想与她 提交于 2019-12-11 08:18:38

问题


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,


回答1:


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.



来源:https://stackoverflow.com/questions/2981119/gamequery-collision-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!