Xylops Posted July 29, 2016 Share Posted July 29, 2016 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'); }); } 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 webhttp://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 More sharing options...
squilibob Posted September 18, 2016 Share Posted September 18, 2016 Instead of using a line, you should be creating a rectangle and setting the onInputDown click handler on that. samme 1 Link to comment Share on other sites More sharing options...
samme Posted September 19, 2016 Share Posted September 19, 2016 Hi Xylops, Phaser tests only filled shapes for Graphics input. You can use a filled rectangle instead of a line (@squilibob) or you can add a `hitArea` rectangle for the Graphics object: http://codepen.io/anon/pen/BLLzKo?editors=0010 Link to comment Share on other sites More sharing options...
Recommended Posts