Dragging issue with phaser 2.6.2


#1

hi all,
I am using phaser 2.6.2 …i created a function which play audio when dragging part passes from a particular area… it is working fine when i drag slowley but it does not play any sound when i dragg very fastly …

this is my function
t.moveColumn = function(e, a, r, l, o) {

        change = e.y - e.dY ,
        console.log("e.y:"+e.y),
        console.log("e.dY:"+e.dY),
        console.log("change:"+change),
		e.readyToDrag  && ((change /= 4),
										 console.log("index:"+t.index),
										 e.column.move(e.column.y + change),
										 e.dY = e.y,
										 e.totalDist += change,

										 Math.abs(e.totalDist) - tileH > 0 &&
										 (

// console.log(“Math.abs(e.totalDist) - tileH :”+(Math.abs(e.totalDist) - tileH)),
sfx_tick.play(),
e.timeLastPlay = game.time.totalElapsedSeconds(),
e.totalDist > 0 ? e.totalDist = e.totalDist - tileH : e.totalDist = e.totalDist + tileH)
)
}, t


#2

@arun15421 Can you please edit the code, right now it’s totally unreadable. It looks incomplete too.


#3

Hello! From what I understand your codes seem like they should work fine; I think that the reason for having ‘no sounds’ when dragged quickly might be that the sounds are overlapping each other because of how fast you drag - which triggers the sound to play constantly.
Please try creating a check to see if sfx_tick is playing before playing sfx_tick.
In Pseudocode:
if (tick sound still playing / tick sound has not ended){
//nothing will play
}
else{
play tick sound
}

This is my rough guess, hopefully it will be of some use to you. :sunny: