Xylops

Clickable graphics line

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

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.