Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser add frames to existing animation

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

    create ()
    {
        const text = this.add.text(400, 32, 'Click to add frames to current Animation', { color: '#00ff00' })
            .setOrigin(0.5, 0);

        //  Create an animation with 5 frames
        this.anims.create({ key: 'diamond', frames: this.anims.generateFrameNames('gems', { prefix: 'diamond_', end: 15, zeroPad: 4 }), repeat: -1 });

        const group = this.add.group({
            key: 'gems',
            frame: 'diamond_0000',
            frameQuantity: 6 * 6
        });

        group.playAnimation('diamond');

        Phaser.Actions.GridAlign(group.getChildren(), {
            width: 6,
            height: 6,
            cellWidth: 64,
            cellHeight: 64,
            x: 240,
            y: 160
        });

        this.input.once('pointerup', function () {

            const diamond = this.anims.get('diamond');

            //  Add in the new frames to the current animation
            const newFrames = this.anims.generateFrameNames('gems', { prefix: 'square_', end: 14, zeroPad: 4 });

            diamond.addFrame(newFrames);

        }, this);
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: regex to allow special characters 
Javascript :: phaser create animation without frame names 
Javascript :: phaser mixed animation 
Javascript :: phaser pause animation instances 
Javascript :: phaser stagger play 2 
Javascript :: test unitaire javascript 
Javascript :: apply multiple style objects in react js 
Javascript :: Six escape sequences are valid in JavaScript 
Javascript :: JS table with rows that have alternating colours 
Javascript :: check letter case 
Javascript :: JavaScript date format 2 
Javascript :: function Tom(a, b) { return a + b; } 
Javascript :: javascript list all elements in set 
Javascript :: javascript alert when site page opened not in chrome 
Javascript :: what is computed property in vue js 
Javascript :: how to delete an element from an array in javascript 
Javascript :: javascript brightness filter 
Javascript :: useselector 
Javascript :: javascript array map 
Javascript :: date pipe 
Javascript :: nodejs 
Javascript :: change css variable with javascript 
Javascript :: gitea 
Javascript :: update to new npm 
Javascript :: react native fast image webp ios 
Javascript :: custom js shopify 
Javascript :: input type for mobile number in react js 
Javascript :: remove item from array 
Javascript :: react map list render dictionary 
Javascript :: window open method for browser detection 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =