Tutorial

Page 3 of 12

Built In Particles

버튼을 만들었으니, 버튼이 눌러 폭죽을 만들어지도록 해봅니다. 파티클을 만드는 가장 간단한 방법으로는, GameMaker:Studio standard 버젼의 내장 파티클을 사용하는 겁니다.

Now we have our first button, we need to make our first firework effect for the button to create. This effect will be done using the simplest of all methods to generate particles, and that is by using the built in particle effects that come as standard with GameMaker:Studio.

시작하기 위해, 새 오브젝트를 만듧니다. 이름은, "obj_BuiltIn_Firework". 그리고 Create Event에 다음 코드를 추가합니다.

To start with, create a new object and call it "obj_BuiltIn_Firework", then add the following code into the Create Event:



지금 하고 있는 것은 조건을 만드는 겁니다.
폭죽은 룸 한가운데에서부터 시작해서 앞으로 이동하게끔 됩니다. x축의 어느 위치에서 만들어졌는지는 중요하지 않습니다. 중력(gravity) 효과에 의해 좀 더 자연스러운 곡선으로 불꼭처럼 떨어지게 됩니다.
코드에는 두개의 알람이 설정됩니다.
첫번째는 , alarm[0], 연기나는 꼬리를 만드는데 사용되고 두번째 alarm[1] 는 폭죽을 만듧니다. 이 이벤트를 추가합니다. Alarm[0] Event를 아래처럼 추가합니다.(드래그앤드드랍)
세모+느낌표 아이콘은 (Control->Code)의 Comment 액션입니다. 그냥 주석입니다.

What we are doing here is creating conditions so that the firework will always start to move towards the center of the room, no matter what part of the x-axis it is created on, and be affected by gravity which will give it a more "natural" looking curve as it is fired. The code also sets two alarms: the first one, alarm[0], will be used to create a smoke trail, and the second one, alarm[1], will be used to generate the firework itself. Let's add these events now!



효과 액션은 Draw Tab의 Other 항목에 있습니다. 설정은 이렇게 합니다.



우리가 만드려는 효과는 보통의 스모크입니다. x,y 위치 (0,0) 좌표는 움직임이 있는 인스턴스에 상대적인 위치 값을 갖게 됩니다. 인스턴스가 있는 위치가 (0,0)이라는 뜻입니다. ( 인스턴스가 움직일 경우, 스모크는 인스턴스가 있는 위치에 만들어지고 화면을 가로지르면 움직이게 됩니다.)

The effect we want is standard smoke, and the x/y position is at (0,0) since we are setting it relative to the instance with the action (which will be moving itself, so the smoke will be created at the position of the instance as it moves across the screen). For size we choose "small", as anything larger will be too much for this particular effect, and the color is grey with the effect being set to appear below all other instances and effects in the room.

알람 리셋 후 모든 움직임 스텝마다 인스턴스의 움직일때, 스모크 파티클을 만들게 되며, 스크린을 가로지르는 꼬리를 갖게 됩니다.

After that we reset the alarm so that every step that the instance is moving, we create a smoke particle effect, giving it a nice trail as it shoots across the screen.

폭죽을 터뜨려봅시다. Alarm[1] Event을 오브젝트에 추가합니다. ( 이건 Create Event에 설정 되어야 합니다. 오케?) 다음 아이콘들을 드래그앤드드랍 합니다.

Now we need to explode the firework, so we should add an Alarm[1] Event into the object too (we set it in the Create Event, remember?) with the following D'n'D icons:



보는 바와 같이, 같은 액션들을 드래그앤드드랍했습니다. 이번에는 이렇게 설정합니다:

As you can see, we use the same D'n'D action icon, but this time it should be set as follows:



이펙트 다음 항목으로 알람 액션을 배치하고 alarm[0]을 -1로 설정해서 (무조건 멈추게합니다.) 스모크가 나오지 않게 합니다. Alarm[2] Event를 새로 추가해서 폭죽효과가 끝났을때 인스턴스를 삭제하게 합니다. 사용하지 않는 인스턴스를 남겨두지 않도록 합니다. 남겨진 미사용 인스턴스는 궁극적으로 게임 랙의 원인이 됩니다. 추가된 알람 이벤트에 Instance Destroy 액션을 추가합니다. ( Objects 섹션의 Main1 Tab 에 있는 )

The alarm actions placed after the effect will set the alarm[0] to -1 (which stops it from running anymore) to prevent anymore smoke being created, and will set a new alarm in the Alarm[2] Event which we will use to simply destory the instance, since after the firework effect is finished, we don't want an instance that does nothing in the room as that will eventually lag the game as they build up. So add in that alarm event now, and in it add an Instance Destroy action from the Objects section of the Main1 Tab

마지막으로 룸 편집기를 엽니다. 이전 단계에서 추가한 버튼 인스턴스를 배치합니다. 게임을 실행합니다... 버튼을 누릅니다. 처음 만든 파티클이 튀는 것을 봅니다. 와옹. 만족하고 다음으로 갑니다.



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