Jump to content

How do I detach the sprite and move it independentely?


Recommended Posts

Hi Guys,

I have been battling with this for some time now. I'm kinda newbie with phaser too.

Currently I'm trying to build a football game where the player adds the ball (both are sprites) to his own sprite and moves around with it until is moment to "kick" the ball, sending it in any direction.

My problem is that I can't seem to be able to release the ball once its been attached. I tried "moveToXY" or "AccellerateToXY" but nothing seems to be doing it. I also tried bypassing the collision "attach" behavior as it seems that it may be a problem but I dont think that is the problem, unless someone tells me otherwise. 

Here's a screenshot of the game so you can have better context .

How can I release the ball from the sprite and send it on a given direction? What do you think is the problem?

	kick: function(direction, speed){
		var ball = this.sprite.getChildAt(0);
		game.physics.arcade.moveToXY(ball, direction.x, direction.y, speed);
		this.possession = false;


Screen Shot 2016-05-26 at 13.37.30.png

Link to comment
Share on other sites


  • Recently Browsing   0 members

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