Jump to content

When a group rotate, the sprites belong to the group do not detect collision


alps56
 Share

Recommended Posts

Hi, all, I have learned Phaser for a couple of days. I have encountered a weird problem.

 

In the create() section, 

 

    this.sets = this.game.add.group();  // sets is a group

    this.sets.x = this.game.world.centerX;
    this.sets.y = this.game.world.centerY+40;
    this.player = this.sets.create(0, 0, 'player'); // add player to sets
    this.arrow = this.sets.create(0, -220, 'arrow'); // add arrow to sets
    this.arrow.body.immovable = true;
    this.sets.setAll('anchor.x', 0.5);
    this.sets.setAll('anchor.y', 0.5);
 
In the update() section,
 
    this.game.physics.collide(this.player, this.arrow);
 
When the player move to the arrow, the collision works well.
But when I rotate the sets, the collision does not work, the player and the arrow can be overlapped. 
 
Any ideas? Thanks a lot.
Link to comment
Share on other sites

On my experience before, rotating the sprite does not rotate the it's body. Try to render it on canvas and call "render" and see where the body of your sprite, is, to get a better idea.

game.debug.renderSpriteBody(sprite1);

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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