Jump to content

loss of speed with this function ...why ?


espace
 Share

Recommended Posts

hi,

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
o.flash={
//object
image: "flash_blanc"
flag:false,
}

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

// launch tween
f.anim_flash=(obj,p)=>{
	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);

flash_blanc_0.thumb.png.ab67fd8bda2d4d195a5cd5cb035473d2.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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