Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser animation yoyo

 preload ()
    {
        this.load.atlas('ryu', 'assets/animations/sf2ryu.png', 'assets/animations/sf2ryu.json');
        this.load.image('sea', 'assets/skies/sf2boat.png');
        this.load.image('ground', 'assets/skies/sf2floor.png');
    }

    create ()
    {
        this.add.image(100, 130, 'sea').setScale(3);
        this.add.image(400, 500, 'ground').setScale(3);

        var info = [ 'Click to toggle Animation.yoyo', 'yoyo: true' ];
        var text = this.add.text(400, 32, info, { color: '#113355', align: 'center' }).setOrigin(0.5, 0);

        this.anims.create({
            key: 'hadoken',
            frames: this.anims.generateFrameNames('ryu', { prefix: 'frame_', end: 15, zeroPad: 2 }),
            yoyo: true,
            repeat: -1
        });

        var ryu = this.add.sprite(400, 350).play('hadoken').setScale(3);

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

            //  Toggle 'yoyo' at runtime
            ryu.anims.yoyo = !ryu.anims.yoyo;

            info[1] = 'yoyo: ' + ryu.anims.yoyo;

            text.setText(info);

        });
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: accessing-nested-javascript-objects-and-arrays-by-string-path 
Javascript :: append input using js 
Javascript :: iterate cy.get(') elements 
Javascript :: NodeJS/express : Cached and 304 status code on chrome 
Javascript :: data tables ajust columns after init 
Javascript :: remove text in div JQuery zqqqqqqqqqqqqqqqzzzzzzzzzzzzzzzzzzzzzzzzzzzzzqqqqqqqqqqqqqqqqqq 
Javascript :: pass only second argument 
Javascript :: Expresion regular para validar contraseñas 
Javascript :: nodejs stream pipeline 
Javascript :: efectos javascript 
Javascript :: Access models in ExpressJS 
Javascript :: check change from service variable angular 
Javascript :: bootstrap 5 
Javascript :: js convert string to number 
Javascript :: redux-persist 
Javascript :: brightness javascript 
Javascript :: codesandbox react emet 
Javascript :: create a class variable js 
Javascript :: javascript add onclick to multiple elements 
Javascript :: Set CSS styles with javascript 
Javascript :: how to use the javascript console 
Javascript :: react native activity 
Javascript :: nodejs debug 
Javascript :: An unhandled exception occurred: Script file ../node_modules/jquery/dist/jquery.min.js does not exist. 
Javascript :: js array to object 
Javascript :: create file node 
Javascript :: use state in className 
Javascript :: javascript shell 
Javascript :: Javascript: 
Javascript :: regex javascript matching first letter to last 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =