Jump to content

Collision won't work


piotr409
 Share

Recommended Posts

Hey

I'm having troubles with collision group vs layout.

 

Many times debugger says :

  1. Uncaught TypeError: Cannot read property 'exists' of undefined phaser.js:35475
    1. Phaser.Physics.Arcade.collideGroupVsTilemapLayerphaser.js:35475
    2. Phaser.Physics.Arcade.collidephaser.js:35380
    3. Phaser.StateManager.updatephaser.js:9367
    4. Phaser.Game.updatephaser.js:13166
    5. Phaser.RequestAnimationFrame.updateRAFphaser.js:23204
    6. _onLoopphaser.js:23189
      game.js : 140game.physics.collide(layer,rbullets);Layer is normal tilemap made with Tiled.rbullets is group of sprites,   tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true);    layer = game.add.tilemapLayer(0, 0, map.layers[0].width * tileset.tileWidth, 480, tileset, map, 0);function rocket(x, y) { var rbullet = game.add.sprite(50, 19, 'cannonrocket'); rbullet.x = x; rbullet.y = y; rbullet.body.acceleration.x = -50; rbullets.add(rbullet); }; Collision player - layer works, collision rbullets - sprite work

       

Phaser 1.1.3

Link to comment
Share on other sites

I'm very new to this myself, but what is calling the .exists property?  A bullet?  If so, have you assigned it with something like this?  I had the same problem, and another member of the forum pointed out that while the sprite existed, I hadn't actually assigned it to a variable, and thus couldn't reference the "object" because I hadn't actually defined it at all.

bullets = game.add.group();for (var i = 0; i < 10; i++){    var bullet = bullets.create(xlocation, ylocation, 'spritename');}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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