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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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