Problem with Collision
  • Hello, my code for my block breaker game is:
    $('playground').playground("#playground", {height: 100, width: 100})
    .addGroup("group1",{overflow: "visible"})
    $("#playground").h()
    $("#blockbreker").collision("#ball").each(function(){
    alert('collide');
    });
    <div class="container">
    <div class="playground">
    <video id="v" conrols autoplay></video>
    <canvas id=c></canvas>
    <p id="test"> </p>
    <p id="test1"> </p>
    <p id="test2"> </p>
    <div id="blockbreker"> </div>
    <div id="ball"> </div>
    </div>
    </div>


    but if I use that I get this error:
    Uncaught TypeError: Cannot read property 'gameQuery' of undefined jquery.gamequery-0.7.1.js:1820
  • A few remarks on you code:
    • All the elements you use in you game have to be created with gQ's function. Here addSprite for blockbreker and ball (you could also use addGroup or addTilemap but here you don't seam to need them).
    • I don't understand what you trying to achieve with group1 and the call to .h()


    I don't know if it's there for some other purpose but you don't need any canvas element for gQ.

    Hopes it helps.

    p.s.: I recently recorder a small video tutorial about collision detection that can be of interest to you:

Howdy, Stranger!

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