Tutorial

Page 11 of 12

Complex Particle Effects

"궁극의" 불꽃을 만드는 마지막 버튼입니다! 여기에는 지금까지 공부한 모든 것을 쓰고 여태까지 쓴적이 없는 추가 고급 함수를 몇개 사용합니다.

시작은, 첫 번째 버튼 오브젝트를 복사하고 "spr_Button_Complex"를 할당합니다. 'Create Event'를 추가하고 다음 코드를 넣습니다 :



파티클 3개? 3개 중 한개를 다른 파티클의 "캐리어"로 쓸겁니다. 여기에는 많은 효과를 추가할 수 있는 굉장히 특별한 함수를 사용할겁니다.(아니면 이것 때문에 정말 엄하게 되거나) Create Event에 다음 코드를 추가합니다 :

Three particles? Yes, because we are going to use one as a "carrier" for the other two, as we are going to use two very special functions that can add a lot to your effects (or cause them to go horribly wrong). Add the following into the create event too:



이 두 함수는 각 스텝때마다 파티클에 다른 파티클을 만들도록 지시합니다. 또한 파티클이 소멸될때 다른 파티클을 만들게 합니다. 이 새로운 불꽃은 각 스텝마다 "플레어" 파티클을 만들고 10개의 "스모크" 파티클을 추가로 만들고 각 파트클이 사라질때 100개의 "불꽃"파티클을 만듭니다.(헉)

These two functions can be used to tell a particle to create another particle every step that it exists, and to create another particle when it's lifetime is over. So, in the context of our new firework, these lines of code tell our "flare" particle to generate 10 "smoke" particles every step and then, at the end of it's life, it will create 100 "firework" particles.

NOTE : These functions can quickly create many thousands of particles or even an infinite loop of particle creation which can slow down and crash your game, so take great care with these!

It is worth noting too that the "firework" particle uses a custom sprite for the particle and not one of the built in constants. This is an incredibly useful function that permits you to use your own images, to animate particles or to have random images for each particle (as is the case here).

We also need to create an emitter for this particle which we will use to create the "flare" particle in the step event. So, add this code into the event after everything else:



We now need to open up the step event and have it create this particle with the following code:



Then add in a Room End event for the clean up with this code:



You can now add this button into your room and check out the final effect! Maybe a bit overdown, but it certainly is spectacular...



Click on the Next button to go to the next page of the tutorial.