espace Posted September 13, 2018 Share Posted September 13, 2018 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); Link to comment Share on other sites More sharing options...
Recommended Posts