AdamRyanGameDev Posted March 14, 2018 Share Posted March 14, 2018 I have stared in the face of madness with this little problem, converting some old games from a different engine I used phases to space out calls, but I hadn-t realised this wouldn-t work with the underlying js... eg I had a function with pointerdown that reset which sprite was selected input.on('pointerdown', function... following calling that function I LATER call a second function on pointerdown which relied on getting a possible new sprite selection (but the two functions couldnt be merged for technical purposes) input.on('pointerdown', function It didnt work well, it seemed the code was a click 'behind' , I tore my hair out, I drank coffee until i started itching all over, then i realised this was mitigated by a double click... ah ha! I simply made the second function pointerup. input.on('pointerdown', function... input.on('pointerup', function... Ok it isnt essential for me right now, but I would like to know how i could guarantee that two event driven functions are called in a certain order, is it possible? I appreciate this was probably javascript ignorance! Link to comment Share on other sites More sharing options...
rich Posted March 14, 2018 Share Posted March 14, 2018 The order in which handlers are set (for the same event) controls the order in which they are invoked. Link to comment Share on other sites More sharing options...
AdamRyanGameDev Posted March 14, 2018 Author Share Posted March 14, 2018 Thanks Rich! I will have to be careful because I normally use a modular code base divide into small reusable functions that generate my code server side (so order of event handlers is not always guaranteed...) Link to comment Share on other sites More sharing options...
Recommended Posts