Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Clickable graphics line


Xylops
 Share

Recommended Posts

  

Sorry guys, I've just start using phaser, i wonder if it is possible for to create a line which is clickable?

Here's the code

    function create(){
        graphics = this.add.graphics();
        graphics.lineStyle(20, 0x33FF00);
        graphics.moveTo(100,200);
        graphics.lineTo(300, 200);

        graphics.inputEnabled = true;
        graphics.input.useHandCursor = true;
        graphics.events.onInputDown.add(function(){
            console.log('Clicked');
        });
    }

 

Image 2.png

 

When i use inputEnabled method,  it works on most of other things like sprite or image, but for graphics it wont respond. 

I've look into the offical example provide by phaser web
http://phaser.io/examples/v2/display/graphics-input-events

i saw them adding 

graphics.input.useHandCursor = true;

However for some reason it doesn't work like the example?

 

Thank You so much for the time

Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

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