Phyron Posted September 23, 2014 Share Posted September 23, 2014 Hi! I use a pixel perfect detection on a sprite with mouse.rect = game.add.sprite(0, 0, 'rect');rect.inputEnabled = true;rect.input.pixelPerfectClick = true;rect.input.useHandCursor = true;Now, how detect when mouse click on sprite? I only need execute a funciton when are clicked thanks! Link to comment Share on other sites More sharing options...
lewster32 Posted September 23, 2014 Share Posted September 23, 2014 I think just using the normal events.onInputDown method should work, like in this example: http://examples.phaser.io/_site/view_full.html?d=basics&f=02+-+click+on+an+image.js&t=02%20-%20click%20on%20an%20image&jsbin=http://jsbin.com/zagob/6/edit?js,output Link to comment Share on other sites More sharing options...
Phyron Posted September 24, 2014 Author Share Posted September 24, 2014 Yes, its work, but i need use a pixel perfect for only click in painted area of image, not on a transparency. In this example: http://examples.phaser.io/_site/view_full.html?d=input&f=pixel+perfect+click+detection.js&t=pixel%20perfect%20click%20detection use the pixel perfect, and read results with game.debug.spriteInputInfo(bunny, 32, 32); But not execute a function. I use images with trasparency. If i use debug line, i can see when click on painted area and transparency.. Thanks Link to comment Share on other sites More sharing options...
Phyron Posted September 24, 2014 Author Share Posted September 24, 2014 No idea? no method? Link to comment Share on other sites More sharing options...
lewster32 Posted September 24, 2014 Share Posted September 24, 2014 Looking at what the debug code does, this should work:rect.events.onInputDown.add(function(r) { if (r.input.pointerOver()) { // the pointer is over the object's opaque area and is down }}); Link to comment Share on other sites More sharing options...
Recommended Posts