Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <footer><div id=version></div></footer>
              
            
!

CSS

              
                html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: #111;
  color: #eee;
  font: caption;
}

#version {
  position: absolute;
  left: 5px;
  top: 605px;
}
              
            
!

JS

              
                class Demo extends Phaser.Scene {
    constructor() {
        super({
            key: 'examples'
        })
    }

    preload() {
        this.load.plugin('rexdynamictextplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexdynamictextplugin.min.js', true);
      
        this.load.image('dude', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/assets/images/phaser-dude.png');
    }
  
    create() {
        var text = this.add.rexDynamicText(
            {
                x: 400, y: 300,
                width: 400, height: 200,  // Set width and height
          
                background: {
                    stroke: 'white',
                    cornerRadius: 20
                },
                innerBounds: {
                    stroke: '#A52A2A'
                },
                padding: 20,
                style: {
                    fontSize: '16px'
                },
            }
        )

        var content = [
            'Phaser is a fast, free, and fun open source HTML5 game framework\n',
            'that offers WebGL and DynamicText rendering across desktop and mobile web browsers.\n',
            'Games can be compiled to iOS, Android and native apps by using 3rd party tools.\n',
            'You can use JavaScript or TypeScript for development.'
        ];
        text
            .appendText('Dynamic text: Page-typing ')
            .appendImage('dude', undefined, { height: 20 })
            .appendText(' ' + content[0], { color: '#FFF8DC' })
            .appendText(content[1], { color: '#008B8B' })
            .appendText(content[2], { color: '#FF7F50' })
            .appendText(content[3], { color: '#F8F8FF' });

        TypingNextPage(text, {
            maxLines: 5,         // Show 5 lines per page
            padding: { bottom: 10 },
        });

        this.print = this.add.text(0, 580, '');
    }

    update() { }
}

var TypingNextPage = function (text, config) {
    var result = text.runWordWrap(config);

    var scene = text.scene;
    var tween = scene.tweens.add({
        targets: result.children,
        delay: scene.tweens.stagger(200),
        duration: 500,
        onStart: function (tween, targets) {
            for (var i = 0, cnt = targets.length; i < cnt; i++) {
                targets[i].setVisible(false);
            }
            text.background.stroke = 'green';
        },
        onUpdate: function (tween, target) {
            target.setVisible(true);
        },
        onComplete: function (tween, targets) {
            text.background.stroke = 'white';
            if (!result.isLastPage) {
                scene.print.setText('Click to continue');
                scene.input.once('pointerdown', function () {
                    scene.print.setText('');
                    TypingNextPage(text, result);
                })
            } else {
                // On typing complete
                scene.print.setText('Typing complete');
            }
        },
        y: '-=20',
        yoyo: true,
        ease: 'Cubic'
    });
}

var config = {
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  scene: Demo
};

console.clear();
var game = new Phaser.Game(config);
              
            
!
999px

Console