playh5 Posted October 28, 2015 Share Posted October 28, 2015 Hi, I want to fire an event when the sprite snaps to x/y. How would I do this? Thanks in advance! Link to comment Share on other sites More sharing options...
jmp909 Posted October 28, 2015 Share Posted October 28, 2015 could you elaborate on how you are moving your sprite and how it is snapping? not sure exactly what you need to do but take a look at thishttp://phaser.io/sandbox/ypTUiqwo/play every time my sprite passes through the intersection of lines, i set the alpha to 1 i check this by taking the modulo of the x & y with the gridif(s.x%grid===0 && s.y%grid===0) {and here's a totally different example ..http://phaser.io/sandbox/CMwwiIgQ/play if i drop the sprite (top left corner) on 320,320 it does somethingfunction onDragStop(s) { if(s.x==320 && s.y==320) {it really depends on what is causing your sprite to move, and what result you need. please clarify. do you actually want to fire a Phaser.Signal event? playh5 1 Link to comment Share on other sites More sharing options...
playh5 Posted October 28, 2015 Author Share Posted October 28, 2015 Thanks jmp909. Actually what I want to do is I'll fire a bullet when the sprite snaps to intersection while on drag and not on update. Something like 'onSnap' event. Link to comment Share on other sites More sharing options...
Igor Georgiev Posted July 11, 2016 Share Posted July 11, 2016 Looking for the same thing when developing a range slider. Any of you guys ever done it? I need and event on snap so I can change some numbers with it. Link to comment Share on other sites More sharing options...
Recommended Posts