Tutorial
Page 9 of 12
에미터(emitter, 폭발 촉발제)코딩하기
DnD(드래그앤드드랍)로 파티클 작업할때 봤듯, 에미터를 선언해서 파티클이 화면 여기 저기에서 효과가 생기도록 또는 분사 방식을 다르게 해서 쓸 수 있습니다. 강력한 기능으로 part_particles_create 보다 유용하게 쓸 수 있습니다.
As you saw with the D'n'D actions for particles, you can define emitters to create your particles at specific positions in your room, over defined areas, and with different distributions. This makes them
quite a powerful tool and certainly more flexible for certain things than using the previously mentioned part_particles_create function.
그렇지만 에미터는, 파티클과 파티클 시스템처러, 메모리에 저장되며 변수로 내부 처리 됩니다. 따라서 메모리 릭(사용 후 미삭제)외 에러를 조심해야 합니다.
However, it should be noted that emitters, like particles and particle systems, are stored in memory and indexed in a variable and so should be used carefully to prevent memory leaks or other errors.
효과 구현을 위해서 버튼 오브젝트가 필요합니다. 이 버튼은 에미터를 만드는데 사용합니다. 버튼은 룸 내부에 있어야 하면 눌렸 때 파티클을 터뜨립니다. 전에 사용한 버튼을 복사(duplicate)합니다. "spr_Button_Burst"를 할당합니다. Create Event를 추가하고 다음 코드를 넣습니다 :
For this effect, we only need a button object, as it will create the emitter we are going to use, position it within the room and burst the particles when it is pressed, so duplicate a previous button object and assign it the sprite "spr_Button_Burst" then open the Create Event and add the following lines of code:
새 파티클에 대해서 알아야 할게 있습니다...
There are some things to note with this new particle...
다른 종류의 색상함수와 숫자를 사용해서 색상값을 정했습니다. 그래서 더해지는 블렌딩(섞음) 효과가 더 예쁘게 나올겁니다.
We have defined the color using absolute numeric values here, which can be found by using the different color functions, and we have used additive blending too to make things prettier.
"wiggle"이라는 항목은 크기, 속도, 이동 방향을 더 동적으로 보여줍니다.
We have used "wiggle" on the size, speed and direction functions to make the effect more dynamic.
시작시 파티클의 크기를 1/4부터 시작합니다.
We have set the starting scale to be one quarter of the original particle sprite x and y scale.
움직이는 각도를 대략 90 ~ 45돌 135? 제한합니다.
We have limited the movement to a 90?angle between 45?and 135?
이미 위로 치솟다가 다시 중력에 의해 떨이지는 동적인 파티클을 볼 수 있었습니다. 에미터는 어떨까요? 다음 코드를 Create Event 에 추가합니다 :
So, you can already see that we have a dynamic particle that will be moving quickly upwards, then slow and fall as gravity pulls on it. Great! but what about the emitter? For that wee need to add one final line of code into the create event:
파티클과 시스템과 마찬가지로, 에미터도 생성해야 하며, 변수에 할당 지금부터이 방출을 상대 할 때는 변수를 사용해야합니다. 우리가 만든 터에서이 새로운 입자를 파열하는이 코드를 modfify 할 필요가대로, 만들기 이벤트를 닫고 지금 단계 이벤트를 열 수 있습니다.
As with particles and systems, the emitters must also be created and assigned to a variable and that variable should be used when dealing with this emitter from now onwards. You can close the create event and open the step event now, as we need to modfify the code there to burst this new particle from the created emitter.
일반적으로 당신은 만들기 이벤트에 방출을 정의하고 단지 그 일을하게하지만,이 불꽃 놀이에게 표시 되가요, 우리는 임의의 값에 따라 주변 에미 터를 이동하는거야
일에 조금 더 다양한을 제공합니다.
Normally you would define an emitter in the create event and then just let it do it's work, but as this is going to be a fireworks display, we are going to move the emitter around depending on a random value
to give a bit more variety to things. So change the step event code to the following:
You can see that not much has changed from previous buttons, but now, instead of creating a new instance for the firework, we are setting an emitter to a position and shape and then bursting 100 particles from it.
The emitter position is always defined as a rectangular area from x1,y1 to x2,y2 and then the shape chosen for the emitter is scaled to fit the over-all area. The shapes can be rectangle, ellipse, diamond or line and you can also specify different distributions within those shapes from gaussian (more in the middle), linear (equal distribution) or inverse gaussian (more at the edges).
the manual contains detailed information on the constants available for this function.
모두 끝냈으면, 오브젝트에 새로운 이벤트 Room End Event를 추가합니다. 전 단계의 불꽃 인스턴스 처럼, 남겨진 파티클이나 에미터가 남아서 메모리 누수가 되도록 하진 않을겁니다. 그래서 룸을 종료 할때는 일종의 정리 작업이 필요합니다. 새로운 이벤트를 추가하고 다음 코드를 넣습니다 :
Once you have that done, you need to add in a new event for the object, and that is a Room End Event.
just as before with the firework instances, we don't want to have any possible memory leaks or left over particles or emitters when the room ends and so we need to do some "cleaning" at the end of the room. Drag a code box into the new event and add the following:
You can now add this new button into your room and test it. Once you are happy, save the game.
Click on the Next button to go to the next page of the tutorial.