2010년 10월 3일 일요일

OpenFeint를 이용한 안드로이드 App 개발

Social Game Nwtwork인 OpenFeint에도 Android 개발자 SDK가 얼마 전에 출시되었습니다. 아이폰을 이용해서 OpenFeint 기반의 게임을 하던 저도 관심이 있어서 제가 만든 Android App인 UCreep과 LogoQuiz에 지난 주말에 적용을 해 보았습니다.




생각보다 무척 쉽습니다. 간단히 이야기를 드리자면 다음과 같습니다.

1. OpenFeint 개발자 사이트(https://api.openfeint.com/) 에서 회원 가입을 하고 설치할 App을 등록한 후에 SDK 를 받습니다.

2. OpenFeint 개발자 사이트에서 점수 저장 게시판인 Leaderboard와 아이템 획득 게시판인 Achievement를 생성합니다.

3. 필요한 라리브러리와 리소스들을 SDK에서 개발 중인 App으로 복사합니다.

4. 개발 소스에서 점수와 아이템 획득 내용을 OpenFeint로 전달하는 소스 코드와 Leaderboard, Achievement 게시판으로 연결하는 링크를 추가하여 준다.


저는 처음 프로그램에 적용시에는 2시간 정도 걸렸는데 두 번째 프로그램에 적용하는데에는 30분 정도 소요된 것 같습니다.



자세한 것은 다음을 참조하시고 그대로 하시면 됩니다.

---------------------------------------------
---- Building OpenFeint With Your Project:
---------------------------------------------
1. Register an application using the OpenFeint developer dashboard at https://api.openfeint.com

2. Download the latest version of OpenFeint for Android

3. Extract the package

4. Copy libs/OpenFeint.jar into the libs/ subfolder of your Android project

5. Copy the res/ and assets/ folder into your Android project folder

6. Open up your AndroidManifest.xml file and add the following activities inside your tag:
Optionally, if your app is fullscreen, you can use "android:style/Theme.NoTitleBar_Fullscreen" as the theme for these activities.

7. Add the following permissions to AndroidManifest.xml outside of your tag:
Additionally, if you're targeting SDK 4 or later, make sure to add this line to your element in AndroidManifest.xml:

8. Add OpenFeint.jar to your CLASSPATH. In Eclipse:
* Right-click on your project and click Properties.
* Click 'Java Build Path'
* Click 'Libraries'
* Click 'Add JARs...'
* Navigate to OpenFeint.jar and click Ok

9. Initialize OpenFeint. This is typically done in the onCreate() method of your main activity (main menu):

OpenFeintSettings settings = new OpenFeintSettings("App Name", "App Key", "App Secret", "App ID");
OpenFeint.initialize(this, new OpenFeintDelegate() {});

Note that you must provide your game's name, key, secret, and id to OpenFeintSettings. You can find these in the developer dashboard at https://api.openfeint.com

10. Make sure that OpenFeint is notified whenever your top-level activity changes. Typically this is done in onResume():

@Override
public void onResume() {
super.onResume();
OpenFeint.setCurrentActivity(this);
}

This only needs to be done for fullscreen Activities (i.e. overlays) and not for Activities that OpenFeint.initialize(). If you're a one-Activity application, you don't need to worry about it.