Jump to content

How to pass a parameter within a delayedCall


AdamRyanGameDev
 Share

Recommended Posts

Probably more of an issue with my js knowledge but how can I pass a parameter, for example here one of the sprites?

(edited version of the lab, https://labs.phaser.io/edit.html?src=src\time\timer event.js )


 

function update() {

    atlasFrame.rotation += 0.01;
    singleImage.rotation += 0.01;
    let timedEvent = this.time.delayedCall(3000, stopRotation, [], this);
}

function stopRotation(spriteName){
    let spriteNamehere = spriteName;
window[spriteNamehere].rotation=0;

}

 

 

Link to comment
Share on other sites

UPDATE:

i tried just for double sure both the following lines

 let timedEvent = this.time.delayedCall(3000, stopRotation, ['atlasFrame'], this);

 let timedEvent = this.time.delayedCall(3000, stopRotation, [atlasFrame], this);

As per code in OQ, but in both cases it stops ALL rotations, not just the nameString/object passed to it... [which should be passed?]

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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