Jandeilson Posted March 14, 2014 Share Posted March 14, 2014 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 More sharing options...
kenray Posted March 14, 2014 Share Posted March 14, 2014 I experienced the same thing - basically as soon as you turn on physics for a sprite, it can no longer be dragged - I'm sure this is a bug in v2 that will hopefully be fixed quickly. Link to comment Share on other sites More sharing options...
Jandeilson Posted March 17, 2014 Author Share Posted March 17, 2014 Understand... I hope it is fixed as soon as possible. Thanks for the note. Link to comment Share on other sites More sharing options...
mariogarranz Posted March 18, 2014 Share Posted March 18, 2014 Same problem for me. As soon as I enable arcade physics on my sprites, drag stops working properly. onDragStart and onDragStop events are fired correctly, but the sprite wont move to the mouse/touch position. Link to comment Share on other sites More sharing options...
mpostma Posted March 18, 2014 Share Posted March 18, 2014 Similar issues are reported on https://github.com/photonstorm/phaser/issues/567 and https://github.com/photonstorm/phaser/issues/598 Link to comment Share on other sites More sharing options...
Recommended Posts