Vivern Posted April 7, 2014 Share Posted April 7, 2014 Need to find a collision objects (contact events). Now is not displayed function alert ("Eahh, collision!"), Ie not processed by the collision.What need to fix? Link to Project (visual studio 2013 + type script): https://drive.google.com/file/d/0B1BUvrgMgztwbWYwSzRob2pOMk0/edit?usp=sharing Code: class Game { game: Phaser.Game; constructor() { this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: this.preload, create: this.create }); this.game.input.maxPointers = 1; this.game.stage.disableVisibilityChange = true; } preload() { this.game.load.image('ShapeRect', 'assets/ShapeRect.png'); } create() { this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.gravity.y = 100; var sprite; var posY = 100; for (var i=1; i < 10; i++) { posY+= 100; sprite = this.game.add.sprite(350, posY, 'ShapeRect'); sprite.anchor.setTo(0.5, 0.5); this.game.physics.p2.enable(sprite); sprite.body.onBeginContact.add(this.blockHit, this); } } blockHit(body, shapeA, shapeB, equations) { alert("Eahh, collision!"); }}window.onload = () => { var game = new Game();}; Link to comment Share on other sites More sharing options...
Vivern Posted April 8, 2014 Author Share Posted April 8, 2014 ... Link to comment Share on other sites More sharing options...
Recommended Posts