Jump to content

Image points [anchor] & Collision


geosith
 Share

Recommended Posts

Hi,

I'm new to phaser 3. In Construct 2 is really easy to add image points to a sprite.
Please look at the screenshots.

How can I add an imagepoint to a sprite like this in phaser?

I tried doing 

this.needle.setOrigin(this.needle.width / 2, 0 );

But it doesnt work, the sprite is just not displayed

 

Example2.png

 

 

Example.png

EDIT: So I managed to do it by setting 

this.needle.setOrigin(0.5 , 0);

 

Now, I'm trying to check collision between 2 objects.

create(){

this.wheel = this.physics.add.staticSprite(400,120,"wheel");

this.needle = this.physics.add.sprite(400, this.initPosY, "needle");

 this.physics.add.collision(this.needle, this.wheel, this.needleHit);

}


  needleHit(): void {
    console.log("AH!");
  }

needleHit() is being called every tick whenever the needles approaches a little bit to the wheel.
Is there any way to see the canvas size of the wheel , like for debugging? because they are not touching each other

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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