2015년 6월 20일 토요일

corona sdk 에서 tiled 사용하기 03 – Building the Physical World



https://github.com/anthonymoralez/lime-tutorials/tree/master/tutorial-03


NOTE: This tutorial is copied from the original at OutlawGameTools.com

03 – Building the Physical World(물리 세계 만들기)

Difficulty: Beginner 초보자가
Duration: 10 minutes 10분만 해봐
Description:
Being able to include Coronas physics features in your map is both fun and easy, at the time of writing there are two ways to do so and more will be added at a later time.
This tutorial is going to deal with the first method, using tile properties just like we did in the previous tutorial.

Step 1: Creating your properties (프로퍼티를 생성하기)

The first thing you will need to do is decide which tile you want to add physics too, I have decided to use the little red brick tile. Now just bring up the Property window as before and add a HasBody property like this:
일단 어떤 블럭을 물리효과를 넣을거냐를 결정해야 하는데, 여기에서는 빨간색 블럭 타일을 선택했습니다. 그리고 그 블럭을 타일셋에서 선택한뒤 HasBody 프로퍼티를 추가합니다.
추가방법은 앞의 예제에서 다루었으니 참고하하세요.
Body Property
This is the only property that you need to give this tile physics properties, now just add atleast one of those tiles into your map.
타일셋에 프로퍼티를 넣었으면 그걸 실제로 map에 표시해봐야겠죠. 아래는 물리 속성을 넣은 타일을 화면에 올린 화면 입니다.
Tile In Map

Step 2: Building your world (세상을 만들기)

If you ran your map now nothing new would happen apart from having a random red tile just floating there staring at you, what we need to do is build the world. This can be done in one line of code placed sometime after you have created your visual, like this:
이전 소스에 아래와 같이 한줄 추가하면 됩니다.
local physical = lime.buildPhysical(map)

화면에 보이게한뒤 물리 설정을 해야합니다.
local visual = lime.createVisual(map)
local physical = lime.buildPhysical(map)
Now run your game and notice your new tile fall according to gravity, nice and simple. You will also notice that your tile will fall off the map and just keep going like the little trooper that it is, what we need is to add some collisions for those platforms. We will do this in a later tutorial after we have covered Objects.
위와 같이 해서 해서 실행하면 중력이 작용하면서 블럭이 위에서 아래로 떨어집니다. 다른것과의 충돌에 관해서는 나중에 진행할 예정입니다.
What you can do now to have a play is add any Corona physics properties to your tile, like so:
코로나 물리에 사용하는 프로퍼티를 아래와같이 추가하여 사용할 수 있습니다.
More Properties
Using the property of bodyType with the value of static on the platform tiles in your tileset you would be able to give the rest of your world some collision, however in a later tutorial we will see how this can be acomplished easier and more efficiently.
bodyType를 변경하여 충돌처리하는 부분에 대해서는 나중 예제에서 다룰 예정입니다.

Completed Project: git clone https://github.com/anthonymoralez/lime-tutorials


꼭 알아두세요.
1. lime은 프로젝트 최상위 폴더에 lime폴더 통째로 복사해서 넣습니다.
2. Layer는 높은쪽이 위쪽 레이어입니다.
3. Tiled에서 tileset의 프로퍼티는 이름과 값으로 구성됩니다.
4. 화면에 보이게한뒤 물리 설정을 해야합니다. local visual = lime.createVisual(map) => local physical = lime.buildPhysical(map)
5. 타일셋에 물리 객체는 HasBody로 합니다.


댓글 없음:

댓글 쓰기