저는 현재 cocos2d를 사용하여 아이폰 용 카드 게임을 개발 중입니다. 나는 현재 각 탭이 플레이어와 그/그녀의 카드 세트를 나타내는 탭보기가 필요합니다. 현재 저는 단 하나의 플레이어를 나타내는 단일 뷰를 가지고 있습니다. cocos2d가 실제로 빌드되지 않았고 여러 가지보기가있는 것처럼 보입니다. 코드를 해킹 할 때 심각한 양이 필요합니다. 이것을 달성하는 가장 효율적인 방법은 무엇입니까?멀티 플레이어 용 cocos2d 탭보기
여기서 명백히 잘못된 점을 발견 할 수 있습니까? PlayerController라는 새로운 클래스를 만들었습니다. (앱 델리게이트에서) app 대리자가 장면 메서드를 호출합니다.이 메서드는 이후 두 개의 "손"객체로 배열을 채우고 initWithPlayerHands를 호출합니다. 먼저 작업). 또한 열심히 요소 0 I이 사용적인 Cocos2D 비슷한 (다른 견해를 가진)을 수행 한
-(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
PlayerController *layer = [PlayerController node];
// add layer as a child to scene
[scene addChild: layer];
HelloWorldLayer *layer1 = [[HelloWorldLayer alloc] init];
HelloWorldLayer *layer2 = [[HelloWorldLayer alloc] init];
allLayers = [[NSMutableArray alloc] initWithCapacity:6];
[allLayers addObject:layer1];
[allLayers addObject:layer2];
[self initWithPlayerHands:allLayers];
// return the scene
return scene;
}
-(id)initWithPlayerHands:(NSMutableArray *)layers
{
NSMutableArray *allPlayers;
if ((self = [super init]))
{
currentScreen = 1;
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:-1 swallowsTouches:NO];
[self setIsTouchEnabled:YES];
scrollWidth = [[CCDirector sharedDirector] winSize].width;
scrollHeight = [[CCDirector sharedDirector] winSize].height;
startWidth = scrollWidth;
startHeight = scrollHeight;
allPlayers = [[NSMutableArray array] retain];
int count = [layers count];
int i = 0;
for (CCLayer *l in layers)
{
l.anchorPoint = ccp(0,0);
l.position = ccp((i*scrollWidth),0);
[self addChild:l ];
i=i+1;
count-=1;
}
totalScreens = i;
}
return self;
}
-(void) moveToPlayerHand:(int)hand //this represents the layer you want to move to
{
float dest = /*((currentScreen-1)*scrollHeight);*/ 0;
id changeHand = [CCEaseBounce actionWithAction:[CCMoveTo actionWithDuration:0.2 position:ccp(0,dest)]];
[self runAction:changeHand];
currentScreen = hand;
}
답장을 보내 주셔서 감사합니다. 내가 찾고있는 코드 일 수도 있습니다. 감사합니다. – godzilla
응답을위한 THanks Tams, 시도해 보았지만 나타납니다. 비록 내가 무엇인지 알 수는 없지만 나는 뭔가 잘못하고있는 것처럼 말입니다. 나는 그것을 하드 코딩하여 항상 첫 번째 "하위보기"즉 게임의 첫 손을 선택합니다. 여기 내 코드 중 일부입니다, 만약 당신이 조언 할 수 있다면 분명히 알 수있는 분명한 실수를 발견 할 수있다 : – godzilla
나는 그것을 정리하기 위해 내 게시물을 편집했다, 나는 이것이 도움이되기를 희망한다! – tams