pawap90 / space-commit

The game where contributors become literal heroes! 🏆 Winner of the GitHub Actions Hackathon 2021
https://pawap90.github.io/space-commit/
MIT License
38 stars 9 forks source link

UI: Show player points #17

Closed pawap90 closed 2 years ago

pawap90 commented 2 years ago

Show player points on the top right corner of the scene Use a UI scene

pawap90 commented 2 years ago

To run the UI Scene within the main scene:

// on create
this.scene.run('game-ui')

To send information from one scene to another scene using events:

const sceneEvents = new Phaser.Events.EventEmitter()

// Emit from the main scene
sceneEvents.emit('points-changed', this.points)

// Listen in the UI scene
sceneEvents.on('points-changed', (points: number) => {
            pointsLabel.text = points.toLocaleString()
        })