Jump to content

Problems group vs sprite collision and drag with Phaser 2


Jandeilson
 Share

Recommended Posts

Hi guys!

I'm trying to make a group collides with a sprite, but does not work. Whenever I add new physical parameters of the Phaser 2 in the group, drag and collide stops working. How do I group with drag collide with sprite?

 

 

MY CODE:

game.Level1 = {    	create: function () {                //Background        bg = this.game.add.sprite(0, 0, 'bg_game');        bg.animations.add('loop');        bg.animations.play('loop', 5, true);                        //Enemy Ball 1        enemyBall = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'enemyBall');                enemyBall.animations.add('loop');        enemyBall.animations.play('loop', 5, true);        	    enemyBall.pivot.x = enemyBall.width * 2.5;        enemyBall.pivot.y = enemyBall.height * 2.5;                //this.game.add.tween(enemyBall.scale).to( { x: 2.5, y: 2.5 }, 5000, Phaser.Easing.Linear.None, true, 0, 5000, true);        this.game.physics.enable(enemyBall, Phaser.Physics.ARCADE);        //enemyBall.body.angularVelocity = 100;                //Heart P1        hearts1 = this.game.add.group();                //For some reason this function disables the drag. See this example: http://goo.gl/mKt1Hs        hearts1.enableBody = true;        hearts1.physicsBodyType = Phaser.Physics.ARCADE;         for (var i = 0; i < 4; i++) {                heart1 = hearts1.create(i*176+32, 72, 'heart1');        heart1.inputEnabled = true;        heart1.input.enableDrag(false, true);          }            },    	update: function() {        this.game.physics.arcade.collide(hearts1, enemyBall);            },    };
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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