Tutorial

Page 2 of 10

서피스란 무엇인가?

서피스를 써본적이 없거나 게임메이커를 처음 써보는거라라면, 이게 어떻게 동작되는지 무엇을 할 수 있는지 모를겁니다. 기본적으로, 서피스는 화면에 뭔가를 그리는 또 다른 방법입니다. 이 서피스는, 그 자체를 뭔가 조작할 수 있습니다. 또한 특수효과나 데칼, 그림자, 빛 효과 같은 부분에도 쓰입니다. 보다시피 다목적입니다.

If you have never used surfaces before, or are new to GameMaker, you may not be aware of how they work or what they can do. basically, a surface is an alternative to the screen that is used for drawing on. this surface can then be manipulated or used for many other things, like special effects, decals, shadows, lights... as you can see they are incredibly versatile!

게임 메이커의 그리는 기능(함수?)에 대해서 생각해보면, 스크린(화면)상에 바로 그려지는 것입니다. 드로우이벤트 draw event에 draw_circle를 쓴다면 화면에 그려지는 원을 보게 됩니다. 같은 방식으로 그리는 대상 drawing target을 서피스로 정할 수 있습니다. 그리고 나서 모든 그리기 작업이 화면에 그려지는 대신 서피스에 그려지도록 할 수 있습니다. 이건 draw_surface()함수로 실제 화면에 그리겠다고 정하기 전까지는 안보인다는 뜻입니다.

if you think of the drawing functions in GameMaker they draw straight to the screen, so if you have a draw_circle function in the draw event, you will see a circle (obviously). However you can change the drawing target to be a surface and all subsequent drawing will be done on that instead of the screen. This means that it will not be seen until you decide to draw the surface on the screen using the draw_surface() functions.

펜과 종이를 (즉, 화면screen) 떠올립니다. 종이 바로 쓰는 대신, 종이 위에 얇고 투명한 따라 그리기용 종이(즉, 서피스surface)를 대고 다른 것을 그리는겁니다. 방금 그린 그림은 따라그리기용 종이에 있습니다. 하지만 원본 위에 덮거나 다른 방법으로 쓰기 전에는 보이지 않는겁니다.

Think of a a pen and paper drawing (the screen) that you then place some tracing paper over (a surface). you then draw on the tracing paper and remove it from the main drawing. The image is still on the tracing paper, but can't be seen until you place it over the original drawing again, or use it for something else.


자, 다 좋아보이지만 불행히도 이게 간단하지 않습니다... 보다시피, 서피스는 휘발성입니다, 즉, 게임에서 언제든지 삭제 될 수 있다는겁니다. 그 이유는 비디오 메모리에 저장 되기 때문에 당신의 게임을 돌리는 디바이스에서 메모리를 더 필요로 하는 경우 또는 다른 경우 짤없이 뺏기게 됩니다. 즉, 서비스가 없어진다는 겁니다. 이런 경우를 대비하는 좀 특별한 함수가 있습니다. (앞으로 보게 됩니다.) 그래서 서피스에 필요한 것을 다시 그릴 수 있습니다.

Now, that all sounds great, but unfortunately it's not quite that simple... You see, surfaces are volatile, which means that they can be removed at any time from the game. This is because they are held in vram and if the device that is running your game needs that memory space for something else, it will just go ahead and take it, meaning that your surface is destroyed! However there is also a special function that can be used to check for this (as you will see) and you can use that to redraw the surface as needed.

또한 서피스 사용시 최소한만 사용하도록 주의하고 신경 써야 합니다. 비디오 메모리를 다 써버리지 않도록요. (서피스는 원래 크기의 두배 사이즈의 텍스쳐를 씁니다. 640x480 픽셀짜리 서피스를 쓴다면 실제 크기는 1024 x 512 만큼의 메모리를 씁니다.) 다른 문제가 더 있는데, 서피스에 뭔가 그릴 경우, 이 서피스의 위치는 룸(방)에서 항상 (0,0)에 있다는 생각을 하면서 그려야 합니다. 큰 룸에서 일부분만 보는 뷰를 사용하는데, 아주 작은 특수 효과를 만들더라도 오프셋(상대좌표)를 추가로 더해준 상태에서 작업을 해야 합니다.

This also means that you should try and keep surface sizes to a minimum too so as not to use up all the available vram (note that surfaces are stored as power of two textures, so that a 640x480px surface is actually a 1024 x 512 texture in memory), this adds another problem! When you draw to a surface, the surface is always considered to be at the position (0,0) within the room, so if you are using views in a large room, or only want a small surface for a special effect, you will need to offset all drawing to compensate for this.



Next 버튼을 눌러서 다음 페이지로 갑시다.