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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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