kthss01 / HHP_DodgeGame

HangHaePlus Coding Athletics (코육대) Dodge game
MIT License
0 stars 0 forks source link

Score init #11

Closed kthss01 closed 11 months ago

kthss01 commented 11 months ago

간단하게 시간이 지날 때마다 문자열로 표현할 수 있게 처리하기

kthss01 commented 11 months ago

시간으로 표현하는 것도 좋은데 총알 수로 표현하고 총알이 0개되면 클리어 되도록 처리하는 것도 좋을거 같음

kthss01 commented 11 months ago

https://labs.phaser.io/edit.html?src=src\scenes\pause%20and%20resume.js

이 방법으로 게임 종료 부분 확인함

this.scene.pause(); // scene 멈춤
this.scene.launch('sceneB'); // 다른 scene으로 이동
this.scene.resume(); // scene 재시작
kthss01 commented 11 months ago

점수 표현은 아래보고 참고함 https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Text.html

this.add.text(0, 0, 'Hello World', { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif' });
kthss01 commented 11 months ago

text 만들고 바꾸는건 https://labs.phaser.io/edit.html?src=src/game%20objects\text\change%20text.js 이거보고 해결함

const title = this.add.text(100, 200, 'Static Text Object', { fontFamily: 'Arial', fontSize: 64, color: '#00ff00' });

        this.input.once('pointerdown', () =>
        {

            //  You can set the text proprety directly like this:
            title.text = 'Hello world';

            //  Or use the setText method if you need method chaining:
            title.setText('Hello world');

        });
kthss01 commented 11 months ago

남은 총알 수는 https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Group.html 이거보고 Group에서 countActive(false)로 발사되지 않은 총알을 확인함

        this.score.setText(`Left Bullet : ${this.bullets.countActive(false)}`);
        if (this.bullets.countActive(false) == 0) {
            this.pause();
        }

모두 발사시 종료 되도록 처리함