Jump to content

Why isn't my collision working?


DanAmador
 Share

Recommended Posts

Good day, I'm trying to make a small game to get to know Phaser js but I'm having problems implementing collision detection with groups.
 
 
Once the maze is created and stored in a bi-dimensional array I fill the screen up with sprites using the following function(as I can't use physics with primitive graphics, if i'm not mistaken)

  //makes sprites out of the maze  function maekMaezDawg() {    console.log('hello frmo maekMaezDawg()');    for (var i = 0; i < mazeHeight; i++) {      for (var j = 0; j < mazeWidth; j++) {        if (maze[i][j] === 0) {          var tempBrick = game.add.sprite(j * tileSize, i * tileSize, 'brick');          tempBrick.scale.setTo(tileSize / 64, tileSize / 64);          brickMaze.create(tempBrick);        }      }    }    mazeGraphics.clear();  } 

But the collision isn't detected between my player object and the brickMaze group.

I'm using the following line in the update function 

game.physics.arcade.collide( brickMaze,player, collisionHandler)

The collision handler function is only supposed to print out a log confirming the collision, yet it never fires up.

 

Help would be greatly appreciated.

 

The full code can be found in the following github repo https://github.com/DanAmador/RandomMazeGame/tree/master/Game

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...