Collision detection not working in latest gameQuery version - migration issue
  • Hi everyone, I updated today to the latest version of gameQuery (from 0.5.0), and my collision detection no longer functions. I did see that I needed to change my setLoadBar to something else (as I saw that in the migration docs), but I don't see anything in there about a change to collision. I assume it has to do with that fact that I am still using .css() to move the elements. So I guess this is a larger question, how does the new movement work?

    For example, if I have:








    $(this).css("top", "" + (posy + HEART_SPEED) + "px");

    do I replace that with:

    $(this).y(posy + HEART_SPEED, true);

    And if I have:









    var posy = parseInt($(this).css("top"));

    Would I get that data like this: $(this).y();

    Can someone elaborate on that migration change?

    Thanks!

  • That's exactly what you're describing, the reason for this change it that I used to have a pretty hack and unstable way to detect changes in sprite position and geometry so I decided to add those new function. Furthermore they ended up making the code more readable. To summ up:

    To write the position .css("left", value) is replaced by .x(value) and .css("top", value) is replaced by .y(value).

    To read the position .css("left") is replaced by .x() and .css("top") by .y().

    The same for width with .w() and height with .h(). There is also combined function like .xy() and .wh() to read or write multiple value in one call.

    At the end of your migration there should be no more explicite modification of the left, right, height and width properties.
  • Awesome! Thanks for the prompt reply Selim, I'll let you know those changes turn out. I love programming with gameQuery btw. It just fits my eye better than other JS game libraries. Probably because of all the jQueryness involved.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!