Arijit Naskar Posted August 20, 2018 Share Posted August 20, 2018 (edited) I am tryning to implement a click event on a graphics object. I have added the graphics object as a child of a empty sprite. and then applied an onInputDown event. Below code of mine not working. The onclick event is not triggering. Please help. function create() { game.stage.backgroundColor = '#124184'; shapeGr = game.add.graphics(); shapeGr.lineStyle(5, 0xddff00, 1); shapeGr.moveTo(250, 100); shapeGr.lineTo(250, 0); shapeGr.boundsPadding = 0; var shapeSprite = game.add.sprite(0, 0); shapeSprite.addChild(shapeGr); shapeSprite.inputEnabled = true; game.physics.enable(shapeSprite, Phaser.Physics.ARCADE); // shapeSprite.body.velocity.x = 100; shapeSprite.events.onInputDown.add(onDown, this); } function onDown(sprite, pointer) { console.log("clicked"); } Edited August 21, 2018 by rich Removed 'phaser 3' from the title as it's v2 Link to comment Share on other sites More sharing options...
Recommended Posts