카테고리 : 개발
2010/09/27 아이폰 개발 팁 : 진동(Vibrate) 기능 추가하기
2010/09/26 아이폰 개발 팁 : XCode에서 디버거 붙어 있는지 알아내기
쓰레드를 이용해서 자연스러운 로딩화면을 보여주면서
백그라운드로 로딩하는데는 여러가지 방법이 있겠지만,
cocos2d 에서 이용할 수 있는 간단한 방법 중엔 이런게 있네요.
원문 링크 중의 어느 댓글을 참고해서 테스트를 해보면..
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
.....
// app뜨면 바로 로딩씬을 불러와서 실행~
loadingScene = [[LoadingScene alloc] init];
[[CCDirector sharedDirector] runWithScene: loadingScene];
// 쓰레드 생성해서 로딩하기~
NSThread* thread = [[[NSThread alloc] initWithTarget:self selector:@selector(loadingProc) object:nil] autorelease];
[thread start];
}
- (void)loadingSceneProc {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// 이게 핵심 코드 없으면 텍스쳐 다 깨지고 난리납니다;
// 뭐하자는 얘기인지 감만 올 뿐이죠 =_=;;
EAGLContext *k_context = [[[EAGLContext alloc]
initWithAPI :kEAGLRenderingAPIOpenGLES1
sharegroup:[[[[CCDirector sharedDirector] openGLView] context] sharegroup]] autorelease];
[EAGLContext setCurrentContext:k_context];
// 여기서 필요한 것들을 백그라운드로 로딩!
// 실제로 사용할 MainScene에 로딩할게 잔뜩있다고 치고.. 생성해서 로딩~
mainScene = [[MainScene alloc] init];
// 이게 혹시(!) thread-safe하지 않으면 다른 방식으로 notification 처리 필요~
[[CCDirector sharedDirector] replaceScene:mainScene];
[pool release];
}
# by | 2010/10/31 03:03 | 개발 | 트랙백 | 덧글(1)
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static bool AmIBeingDebugged(void)
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
{
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info.kp_proc.p_flag = 0;
// Initialize mib, which tells sysctl the info we want, in this case
// we're looking for information about a specific process ID.
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
// Call sysctl.
size = sizeof(info);
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
assert(junk == 0);
// We're being debugged if the P_TRACED flag is set.
return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
}
# by | 2010/09/26 07:51 | 개발 | 트랙백 | 덧글(0)