Skip to content
Snippets Groups Projects
Commit d1d753a5 authored by dyddnrdl3@naver.com's avatar dyddnrdl3@naver.com
Browse files

adding kor ver

parent 6dcc4690
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ However, if you just started using phaser, you should know 3 basic Scene functio ...@@ -17,7 +17,7 @@ However, if you just started using phaser, you should know 3 basic Scene functio
</code></pre><br/> </code></pre><br/>
![phaser 3 scene basic cycle](./phaser_3_scene_basic_cycle.PNG) ![phaser 3 scene basic cycle](./phaser_3_scene_basic_cycle.PNG)
Usually, you can load images or other resources at **preload** and create Phaser objects at **create** like sprite objects or others. And make your own game logic at **update**. But you have to consider that **update** get executed periodically which is directed with FPS (if FPS is 30, that means **update** get executed 30 times in a second). However, you can set FPS and **update** execution rate different. Usually, you can load images or other resources at **preload** and create Phaser objects at **create** like sprite objects or others. And make your own game logic at **update**(If you are going to make event listner for logic, never write those codes in **update**). But you have to consider that **update** get executed periodically which is related with FPS.
--- ---
## Why we load resources at **preload** and make objects at **create**? ## Why we load resources at **preload** and make objects at **create**?
......
# Phaser 3 Life cycle
Phaser의 Scene은 크게 다음의 세 가지 상태로 이루어져 있습니다. **CREATE**, **UPDATE** 그리고 **STOP**입니다. 이벤트를 수동으로 발생시켜서 상태를 전환할 수도 있으며, 이벤트 리스너를 추가할 수도 있습니다. 자세한 상태 간의 전환 방식이나 보다 세부적인 상태를 확인하고 싶으시다면, <strong>[Phaser 3 Scene Note](https://rexrainbow.github.io/phaser3-rex-notes/docs/site/scene/)</strong>의 flow chart를 참고해주세요.<br/><br/>
하지만, 여러분이 이제 막 Phaser를 이용한 개발을 시작하셨다면 모든 세부 상태와 스탭을 알 필요는 없습니다. Phaser 게임 개발을 하기 위해서는 **preload**, **create** 그리고 **update**만 숙지해도 충분합니다.
<pre><code>
preload (){
// 이곳에 있는 코드는 게임이 실행되어 create 단계에 들어가기 전에 실행됩니다.
}
create (){
// 이곳에 있는 코드는 preload가 실행된 이후, update가 최초로 시작되기 전에 실행됩니다.
}
update(){
// 이곳에 있는 코드는 게임이 돌아가는 도중에 계속해서 실행됩니다.
}
</code></pre><br/>
![phaser 3 scene basic cycle](./phaser_3_scene_basic_cycle.PNG)
보통은 **preload** 에서 이미지 등의 리소스들을 불러와 저장해두며, **create** 에서 스프라이트 오브젝트를 비롯한 각종 게임 오브젝트를 생성합니다. 그리고 **update**에서 게임 로직을 구현하여, 게임이 로직에 맞게 돌아가도록 합니다(이벤트 리스너 등을 이용할 경우 **update**에서 작성하면 안 됩니다!). 하지만 **update** 는 주기적으로 실행되며, 이는 FPS와도 연관이 있음을 알고게셔야 합니다.
---
## Why we load resources at **preload** and make objects at **create**?
You may wonder why i suggest you to load resources at **preload** and create objects at **create**. Well, if you try you may see that some objects not being created well especially image related objects. This is because Phaser is based on JavaScript which makes loading resources asynchronously. Thus, to avoid such problem, i recommend you to load resources at preload and create phaser object at **create** but it is not mandatory nor official.
---
## How can i change update rate?
You may want to limi your update rate because of performance issue or other reason. And you can limit them since start by setting **config** for physics or using **physics.world.setFPS()** but it sometimes doesn't work depends on your Phaser version. Then, how should you do to do so? You can limit update rate by skipping some of update execution. Below is example
<pre><code>
function update(){
this.c += 1;
if(this.c > 1){
this.c = 0;
return;
}
...
}
</code></pre>
Above code would let Phaser run **update** as half of default rate whcih means, if your Phaser game execute **update** 60 times a second, then above code block will make it 30 time a second.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment