Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser play animation with config.js

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

    create ()
    {
        //  Our global 'spin' animation
        this.anims.create({
            key: 'spin',
            frames: this.anims.generateFrameNames('cube', { prefix: 'frame', start: 1, end: 23 }),
            frameRate: 50,
            repeat: -1
        });

        const colors = [ 0xef658c, 0xff9a52, 0xffdf00, 0x31ef8c, 0x21dfff, 0x31aade, 0x5275de, 0x9c55ad, 0xbd208c ];

        const sprite1 = this.add.sprite(200, 300, 'cube').setTint(colors[0]);
        const sprite2 = this.add.sprite(400, 300, 'cube').setTint(colors[1]);
        const sprite3 = this.add.sprite(600, 300, 'cube').setTint(colors[2]);

        //  Play the 'spin' animation
        sprite1.play({ key: 'spin' });

        //  Play the animation and override the default frameRate with a new one
        sprite2.play({ key: 'spin', frameRate: 20 });

        //  Play the animation and set the repeatDelay to 250ms
        sprite3.play({ key: 'spin', repeatDelay: 250 });
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: phaser show animation play through js 
Javascript :: phaser tween timescale 
Javascript :: How to call the API when the search value changes 
Javascript :: .every() Accepts a test function and returns a boolean if all the elements of the array pass the test. 
Javascript :: apply multiple style objects in react js 
Javascript :: toast waning 
Javascript :: template literal inside a key in react 
Javascript :: on click insert into element time 
Javascript :: ray intersection js 
Javascript :: filter text js 
Javascript :: add filter category to react native flatslit 
Javascript :: mongo db backup node js daily 
Javascript :: javascript detect if browser is not google chrome 
Javascript :: .pop javascript 
Javascript :: change text color according to background js 
Javascript :: javascript get date value from input 
Javascript :: react native ios firebase push notifications not working 
Javascript :: reactnative timepicker 
Javascript :: grid in js 
Javascript :: react native scrollview item bottom 
Javascript :: mongoose get method 
Javascript :: how to get nested array using lodash 
Javascript :: last item of array javascript 
Javascript :: js get array object from local storage 
Javascript :: context menus use 
Javascript :: ajax form submit 
Javascript :: React Redux store exemple 
Javascript :: javascript expression 
Javascript :: how to add function in javascript 
Javascript :: javascript async await returns undefined 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =