Jump to content

loss of speed with this function ...why ?


Recommended Posts


when i comment this function my game run well but without comments the speed is not optimal. Could you tell me what i'm doing wrong or what to improve ?

ps : i give the image of my sprite, it maybe help some solutions....

Big thanks to you.

// specific function to create an sprite object with these parameters
image: "flash_blanc"

//to lock a function and be sure that the function not run twice
f.lock = (obj, callback) => {
	if (obj.flag == false) {
		obj.flag = true;

// launch tween
	obj.tw =game.add.tween(p.o).to({ alpha: p.a }, p.t, p.e, true, p.d, p.i, p.y);
	// reset the flag of the obj oncomplete
        obj.tw.onComplete.add( ()=> {o.flash[1].flag=false},this)

//on input onDown launch the tween
f.stop_body = function () {
	if (o.paper[1].flag == false) {
		f.lock(o.flash[1], ()=> {f.anim_flash(o.flash[1],o.flash_tw_p1)})

// in update
game.input.onDown.add(f.stop_body, this);


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...