Jump to content

Make geometry Interactive


Pau
 Share

Recommended Posts

Hello!

I would like to make geometry interactive.

I have this code:

var puerta1 = new Phaser.Geom.Rectangle(500, 100, 230, 430).setInteractive()
var graphics = this.add.graphics({ fillStyle: { color: 0xff0000 } });
graphics.fillRectShape(puerta1);

But the console is telling me that setInteractive is not a function.

How can i make puerta1 object interactive?

Thanks in advance

Link to comment
Share on other sites

Hello!
I followed to advice and now the event triggers, but i happens when the mouse enter in the canvas :(

var puerta1 = new Phaser.Geom.Rectangle(500, 100, 230, 430)
var graphics1 = this.add.graphics({ fillStyle: { color: 0xff0000 } });
graphics1.fillRectShape(puerta1)
graphics1.setInteractive(puerta1, puertaPulsada)

...


function puertaPulsada(puerta){
alert("enter")
}

 

Link to comment
Share on other sites

I founded,

but i wanted to make a geometry interactive inside an sprite, and there is an special code for it:

 

var mazmorra = juego.add.sprite(480, 320, 'mazmorra');
var puerta1 = juego.add.zone(150, 140, 210, 410)
puerta1.setInteractive();
puerta1.on('pointerdown', puertaPulsada);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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