Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser generate frame numbers

 preload ()
    {
        this.load.spritesheet('boom', 'assets/sprites/explosion.png', { frameWidth: 64, frameHeight: 64, endFrame: 23 });
    }

    create ()
    {
        this.add.text(400, 32, 'Check the source code for comments', { color: '#00ff00' }).setOrigin(0.5, 0);

        //  Our 'boom' spritesheet has 23 frames in it.
        //  This animation will use them all by just giving it the sprite sheet key:
        const config1 = {
            key: 'explode1',
            frames: 'boom',
            frameRate: 20,
            repeat: -1
        };

        //  Here we use the 'generateFrameNumbers' function instead to set the start and end frame:
        const config2 = {
            key: 'explode2',
            frames: this.anims.generateFrameNumbers('boom', { start: 0, end: 23 }),
            frameRate: 20,
            repeat: -1
        };

        //  Here we use the 'frames' array because we want to specify the exact frames to use:
        const config3 = {
            key: 'explode3',
            frames: this.anims.generateFrameNumbers('boom', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] }),
            frameRate: 20,
            repeat: -1
        };

        this.anims.create(config1);
        this.anims.create(config2);
        this.anims.create(config3);

        this.add.sprite(200, 300, 'boom').play('explode1');
        this.add.sprite(400, 300, 'boom').play('explode2');
        this.add.sprite(600, 300, 'boom').play('explode3');
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: null is not an object clipboard rn 
Javascript :: bogo sort js 
Javascript :: gsheet formula get last item in column 
Javascript :: onselect in zebra datepicker 
Javascript :: emergency food 
Javascript :: simbu react1 
Javascript :: mdi/js icons with vue 
Javascript :: some js es6 
Javascript :: string filter javascript 
Javascript :: input as html in console 
Javascript :: How create a function that return element in js 
Javascript :: add points to numbers js 
Javascript :: shadow generator react native 
Javascript :: jquery get table 
Javascript :: javascript function declaration vs arrow function 
Javascript :: register service worker 
Javascript :: vue router Async Scrolling 
Javascript :: check if all array elements are equal 
Javascript :: javascript create object from key value pairs 
Javascript :: change node bash root 
Javascript :: how to define cardTitle background image in mdl in reactjs 
Javascript :: javascript in pdf 
Javascript :: js addeventlistener input search phone 
Javascript :: json server start code 
Javascript :: how to get the lower triangular matrix out of a matrix matlab 
Javascript :: array from js 
Javascript :: nestjs AXIOS_INSTANCE_TOKEN 
Javascript :: javascript compare timestamp 
Javascript :: sequelize update index column 
Javascript :: capitalize first letter of a string 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =