Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

phaser time event start at

function create ()
{
    image = this.add.image(400, 300, 'einstein');

    text = this.add.text(32, 32);

    //  A 10 second delay, but the first time it begins it'll start 5 seconds in, then on repeat will repeat for the full 10 seconds
    timedEvent = this.time.addEvent({ delay: 10000, callback: onEvent, callbackScope: this, repeat: 1, startAt: 5000 });
}

function update ()
{
    text.setText('Event.progress: ' + timedEvent.getProgress().toString().substr(0, 4) + '
Event.repeatCount: ' + timedEvent.repeatCount);
}

function onEvent ()
{
    image.scaleX *= 0.75;
    image.scaleY *= 0.75;
    image.rotation += 0.04;
}
Source by github.com #
 
PREVIOUS NEXT
Tagged: #phaser #time #event #start
ADD COMMENT
Topic
Name
7+8 =