Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser animation get progress

preload ()
    {
        this.load.atlas('gems', 'assets/animations/diamond.png', 'assets/animations/diamond.json');
    }

    create ()
    {
        this.anims.create({
            key: 'diamond',
            frames: this.anims.generateFrameNames('gems', { prefix: 'diamond_', end: 15, zeroPad: 4 }),
            frameRate: 16,
            yoyo: true,
            repeat: -1,
            repeatDelay: 300
        });

        // this.gem is a local variable.
        this.gem = this.add.sprite(400, 480, 'gems')
            .play('diamond').setScale(4);

        this.debug = this.add.graphics();
    }

    update ()
    {
        this.debug.clear();

        const size = 672;

        this.debug.fillStyle(0x2d2d2d);
        this.debug.fillRect(64, 64, size, 48);

        this.debug.fillStyle(0x2dff2d);
        this.debug.fillRect(64, 64, size * this.gem.anims.getProgress(), 48);
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: phaser create animation from canvas texture 
Javascript :: phaser enable pixel art 
Javascript :: phaser muy bridge 
Javascript :: phaser play animation after repeat 
Javascript :: phaser animation yoyo 
Javascript :: lookbehind alternative regex 
Javascript :: scrolling text animation javascript 
Javascript :: on refresh action set position rainmeter 
Javascript :: pass only second argument 
Javascript :: node transitions 
Javascript :: Count the number of child records on the each parent object 
Javascript :: condition rendering using if-else 
Javascript :: vue mount modal to body 
Javascript :: Self Invoking Functions Can Also be Used To Make Variables Global In JavaScript 
Javascript :: compare text 
Javascript :: js foreach syntax 
Javascript :: js brightness 
Javascript :: javascript interview questions 
Javascript :: blur javascript 
Javascript :: react check if browser is in dark mode 
Javascript :: usesearchparams react router 
Javascript :: how to create scroll to top button in reactjs example code 
Javascript :: spread operator es6 
Javascript :: convert string to a number javascript 
Javascript :: spread operator react array 
Javascript :: add role to channel discord.js 
Javascript :: javascript wait for async function to finish 
Javascript :: maximum number of an array 
Javascript :: break loop after time javascript 
Javascript :: jquery set timezone 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =