- HTML5 2D game engine.

 - 씬 관리를 통해 게임 생성을 지원.

 - 씬매니져를 만들고 노드를 만들어서 씬매니져에 추가시키는 형식으로 사용.

 - 권장사양 : iOS5, Android 4.0 이상 

 - Backbone.Model을 상속받아 만들어짐. 

 - 직접 DOM 트리를 구성해줌으로써 웹 브라우저의 랜더링 시스템을 활용. 속도 향상에 장점.

 - Pig2d의 기본 객체는 node와 model을 합쳐서 만들어짐.

 - 엔진 구성

   - 노드(Pig2d.node)

     : 최소 단위의 장면 구성 요소

      - new Pig2d.node() : 생성자

      - clone() : 노드 복제

      - fineByName(name), fineByID(id) : name or id로 노드 검색 

      - add(child_node, parent) : 자식 노드 추가.

      - removeChild(node), removeChildAll() : 자식 노드 삭제

      - show(visible) : 일시적 노출 적용.

   - Pig2d.Model

     - Pig2d.model() : 모델 생성자.

     - Model Method

       - setPosition(x,y) : 이동 

       - getPosition() : 위치 조회

       - translate(delte, direction_vector) : 방향과 거리만큼 이동. 

         예. 초당 10의 속도로 오른쪽으로 이동

           node.get(‘model’).translate(deltaTime*10, new gbox3d.core.Vect2d(1,0));

       - setRotaion(degree) : 객체 회전.

       - getRotation() : 현재 회전값.

       - rotate() : 회전 증가.

       - setScale() : 확대값 조절.

       - getScale() : 크기 조회.

     - Animator Method

       - transition() : 애니메이션 표현.

     - SpriteModel

       - 스프라이트 애니메이션 기능이 있는 모델

       - new Pig2d.SpriteModel() 로 생성.

       - new Pig2d.SpriteModel( {

          data: {

             “name” : “”,

             “frames” : “” },

          imageObj:

          }

   - 장면 관리자 (SceneManager)

     - 생성자 

       new Pig2d.SceneManager({

          container : ,

          window_size : { width: , height: }

       });

     - 전반적인 장면 관리.

     - updateAll() : 엔진을 최신상태로 변경. 화면 갱신 등에 사용.

   - 그 외 노드 생성 헬퍼 함수

     - Pig2d.util.createDummy()

     - Pig2d.utils.createImage()

     - Pig2d.util.createSlicedImage()

     - Pig2d.util.createSprite()


 - 마우스 스팟 컨트롤(Mouse Spot Control)

   - 객체 생성

     new Pig2d.util.controller.MouseSpot({

       listener_element : , // 이벤트를 받아내는 엘리먼트 객체.

       node : ,   // 컨트롤하고 싶은 장면 노드.

       speed : ,  // 초당 이동 속도. 예. 200 : 초당 200 픽셀.

       setupCallBack : function() { }, // 컨트롤러가 세팅되고 초기화하는 시점에 호출되는 콜백.

       endCallBack : function() {},    // 이동 완료 후 호출되는 콜백 함수.

       startCallBack : function(evt) {}// 이동 시 시작될 때 호출되는 콜백 함수.

      });

 - 스프라이트 노드 객체 생성

   Pig2d.util.createSprite({

     texture : ,   // 이미지 등의 텍스쳐.

     animation : , // 애니메이션을 위한 프레임 배열.

   });

 - 애니메이션 상태 설정

   node.get(‘model’).setupAnimation({

     startFrame: ,      // 첫번째 애니메이션 프레임 지정.

     endFrame: ,        // 마지막 애니메이션 프레임 지정.

     isAnimationLoop: , // 애니메이션 반복 여부를 설정.

     AnimationStatus: , // 애니메이션 상태를 설정. (‘play’ : 재생, ’stop’ : 정지)

   });

 - 다중 스크롤 효과 객체 생성

   new Pig2d.util.scroller.type_finalfight({

     scroll_center: , // 사용자의 스크롤 입력 시 좌우 기준이 되는 값. 현재 스크롤 위치에서 상대적인 좌표. 

     speed : ,        // 스크롤 되는 속도.

     front_layer: ,   // 전경 레이어.

     back_layer: ,    // 배경 레이어

     backlayer_rate:  // 배경 레이어의 속도 비율. 일반적으로 전경 대비 배경 레이어의 가로 크기 비율로 정함.(배경 가로 크기/전경 가로 크기)

   })

  - 선간의 충돌 처리

    gbox3d.geo.Intersection.intersectionLineLine(a1, a2, b1, b2)


참고 : http://www.yes24.com/24/goods/12495696?scode=032&OzSrank=1

Posted by 프리지크
:

Storyboard 에서 iPad용 UI를 만들고 있는데, 가로/세로에 대해 서로 다른 UI를 만들어야 하는 경우가 생겼다.

문제는 iPad에서는 iPhone처럼 Regular/Compact을 조절해서는 안된다는 것.

아래와 같이 해결했음. 


UITraitCollection을 이용해서 화면에 따라 모드를 지정해 준다.


Storyboard 상에서는 아래 모드로 작업을 해두고

세로를 작업할 때는 Width:Any, Height:Regular 로 하고,

가로를 작업할 때는 Width:Regular, Height:Compact로 했음.


RootViewController나 ParentViewController에 아래 코드를 추가하면 된다는데, 나는 NavigationController에 해 줬음.


- (UITraitCollection *)overrideTraitCollectionForChildViewController:(UIViewController *)childViewController

{

    UITraitCollection *wRegular = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular];

    UITraitCollection *hCompact = [UITraitCollection traitCollectionWithVerticalSizeClass:UIUserInterfaceSizeClassCompact];

    UITraitCollection *horizontal = [UITraitCollection traitCollectionWithTraitsFromCollections:@[wRegular, hCompact]];

    

    UITraitCollection *wAny = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassUnspecified];

    UITraitCollection *hRegular = [UITraitCollection traitCollectionWithVerticalSizeClass:UIUserInterfaceSizeClassRegular];

    UITraitCollection *portrait = [UITraitCollection traitCollectionWithTraitsFromCollections:@[wAny, hRegular]];

    

    if (CGRectGetWidth(self.view.bounds) < CGRectGetHeight(self.view.bounds))

    {

        return portrait;

    }

    else

    {

        return horizontal;

    }

}


참조 URL : http://stackoverflow.com/a/28268200

Posted by 프리지크
:

* Audio route 변경 시 Notification 수신 방법. (예. Headphones plugged/unplugged) 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(routeChanged:) name:AVAudioSessionRouteChangeNotification object:nil];


- (void)routeChanged:(NSNotification *)notification

{

   NSNumber *reason = [notification.userInfo objectForKey:AVAudioSessionRouteChangeReasonKey];

   

   if ([reason unsignedIntegerValue] == AVAudioSessionRouteChangeReasonNewDeviceAvailable) {

   } else if ([reason unsignedIntegerValue] == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) {       

   }

}


   - 연관 Notification : AVAudioSessionSilenceSecondaryAudioHintNotification, AVAudioSessionMediaServicesWereLostNotification, AVAudioSessionMediaServicesWereResetNotification, AVAudioSessionInterruptionNotification

Posted by 프리지크
:

* Headphone 이용 시 이벤트 수신 방법.

   // Headphones의 played/paused event 수신. (예. Apple EarPods 일 경우, Center Button 한번 클릭)

   // !!특이점

   //   - Apple EarPods 일 경우, togglePlayPauseCommand를 수신.

   //   - 일반 Bluetooth Headphones 일 경우, 아래의 playCommand/pauseCommand를 수신. (왜??? ;;;;)

   MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];

   [commandCenter.togglePlayPauseCommand addTarget:self action:@selector(command)];

   

   // Headphones의 played event 수신

   commandCenter.playCommand.enabled = YES;

   [commandCenter.playCommand addTarget:self action:@selector(playCommand)];

   

   // Headphones의 paused event 수신

   commandCenter.pauseCommand.enabled = YES;

   [commandCenter.pauseCommand addTarget:self action:@selector(pauseCommand)];

   

   // Headphones의 Next track event 수신. (예. Apple EarPods 일 경우, Volume up 버튼을 두번 클릭)

   commandCenter.nextTrackCommand.enabled = YES;

   [commandCenter.nextTrackCommand addTarget:self action:@selector(nextTrackCommand)];

   

   // Headphones의 Previous track event 수신. (예. Apple EarPods 일 경우, Volume down 버튼을 두번 클릭)

   commandCenter.previousTrackCommand.enabled = YES;

   [commandCenter.previousTrackCommand addTarget:self action:@selector(previousTrackCommand)];


또는, 


UIResponse를 상속받는 AppDelegate 에서 아래 메소드를 통해 이벤트를 받을 수 있음.


- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event


Posted by 프리지크
:

맥의 Finder에서 여러개의 파일명을 한번에 바꿀 때.

 ('무슨 툴이 있을까.' 싶어서 찾아볼렸는데, 이런게 있었네.)


1) Finder에서 여러개의 파일을 선택 후 마우스 우측 선택.  > '이름 변경'.



2) '텍스트 대치'에서 찾을 단어와 대치할 단어를 입력.


3) '이름변경'을 하면 바뀐것을 확인 할 수 있다.


* 텍스트 대치 : 이름 변경.

  텍스트 추가 : 파일명에 파일명 추가.

  포맷 : 특정 파일명에 숫자를 증가시켜서 변경.




Posted by 프리지크
:

* 맥에서 블루투스 연결이 안되고, 아이콘 선택 시 ‘BlueTooth, 사용 가능 하지 않음’ 이라고 뜰 때 해결책. 

 (USB 등의 특정 포트가 먹통일 때도 사용 가능한 듯.)


 방법 1) 모니터 선을 제외한 모든 연결선을 제거 

              > 전원선을 뽑고 30초~1분 대기 

              > 전원선을 다시 꼽고 5~10초 대기 후 부팅.  


 방법 2) PRAM 공장 초기화 

             - command + option(Alt) + r + p 누르고 재부팅. 

                 > 부팅음이 두번 들리면서 부팅하게 됨.

Posted by 프리지크
:

  예를 들어, 문자열을 4자리씩 끊어야 할 경우,


    NSString *number = @"1234567890";

    NSError *error = NULL;

    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@".{1,4}" options:0 error:&error];

    NSArray *matches = [regex matchesInString:number options:0 range:NSMakeRange(0, [number length])];


    for (NSTextCheckingResult *match in matches)

    {

        NSLog(@"%@", [number substringWithRange:match.range]];

    }


결과는

 1234

 5678

 90


Posted by 프리지크
:

XCode6 시뮬레이터에서 간혹(자주?) 한글 키보드가 안나오는 경우가 있다.

아래 설정을 해 주면 나온다.

그 전에 설정에서 키보드의 언어는 추가가 되어 있어야 한다.




Posted by 프리지크
:

iMac 2011 Mid를 사용할 때는 괜찮았는데, 이 후에 나온 2012나 2013에서 매직마우스나 트랙패드를 사용할 간혹 마우스 포인트가 튀는 현상이 발생했다. 움직이다보면 포인트가 워프. ㅎㅎㅎㅎ ;;; 

찾아보니 WiFi Hz간의 간섭 때문일 수도 있다는 얘기가 있길래 수정해 보았다.

어느 분은 공유기를 바꾸고 나서 잘 되었다는 분도 있으시지만, 나의 경우에는 맥으로 인터넷공유 기능을 켜 놓고 있었기 때문에 공유기능에서 채널을 바꿔 줌으로써 해결했다. 와이파이를 사용할 경우도 해당 될 지도. 어쩌면. 


1) 우측상단의 와이파이의 '공유 환경설정 열기' 선택.

    (아래는 이미 채널:44(5GHz)로 변경되어있음. 보통은 11(2.5GHz)로 되어 있음.)




2) '인터넷 공유 체크 해제 > Wi-Fi 옵션 > 채널 변경' 후 확인.



채널은 주변 환경에 따라 선택하면 됨.


참고

  - http://support.apple.com/kb/TS1449?viewlocale=ko_KR&locale=en_US

  - http://support.apple.com/kb/ht1365?viewlocale=ko_KR





Posted by 프리지크
:

간혹 XCode의 디버그창에서 포인터로 된 변수의 경우 메모리에 직접 접근해서 값을 봐야하는 경우가 있습니다. 


1. 우선 관련 라인에 브레이크 포인트가 지정된 상태에서 디버그 모드가 되어야합니다.



2. 원하는 변수에 대해 마우스 우클릭 또는 Ctrl+클릭을 하게 되면 옵션창이 뜹니다.  View Memory of * 를 선택합니다.



3. 아래와 같이 메모리를 직접 볼 수 있는 화면이 뜹니다.

   1) 현재 창에서 보이는 메모리의 주소를 지정할 수 있습니다. 

    2) 보이는 화면의 페이지 단위로 앞, 뒤 이동을 할 수 있습니다.

    3) 창에서 보이는 Byte의 크기를 지정할 수 있습니다.

    4) 바이트들을 묶음 단위로 볼 수 있습니다. 

    5) 확인 해 봤던 메모리의 위치들의 히스토리입니다.


참고 : https://developer.apple.com/library/mac/recipes/xcode_help-debugger/articles/viewing_memory.html

Posted by 프리지크
:

BLOG main image
인생에서는 찾고, 노력하고, 희생할 각오가 되어 있는 것만 얻을 수 있다. (조시 매슈 애덤스) by 프리지크

공지사항

카테고리

분류 전체보기 (121)
끄적끄적 (16)
좋은 글 (9)
자료 (19)
런닝&피트니스 (18)
기술 (43)
기사 스크랩 (1)
내가 본 공연 후기 (1)
내가 가 본 맛집 (5)
괜찮아 보이는 펜션들 (4)
(4)
한장한장 (0)
비공개 스크랩 (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :