2012-12-09 3 views
1

아마도이 질문은 여러 번 반복되었지만 유용한 자료를 찾지 못했습니다. 또한 이것은 cocos2D의 첫 프로젝트입니다. ProgressBar, cocos2D에서 CCProgressTimer를 구현하고 싶습니다. 나는 두 개의 스프라이트를 가지고 있는데, 첫번째는 움직이며 두 번째는 움직일 수있는 플레이어이다. 사용자가 첫 번째 움직이는 물체를 성공적으로 먹었다면 진행률을 증가시켜야한다. 그렇지 않으면 빠져 나가면 진행률이 감소한다. 도움이 필요해. 미리 감사드립니다.cocos2D의 CCProgressTimer

+0

플레이어가 이기면 진도 표시 줄에 다른 스프라이트를 추가하면됩니다. ccprogresstimer 필요가 없습니다. 또는 배열로 밀고, 당신이이기는 때마다, progressbar는 배열 카운트를 검사합니다. 그런 식으로 얼마나 많은 승리를 거둘 수 있는지 알 수 있습니다. –

답변

4

여기 내 코드는 둥근 CCProgressTimers (시계 모양)에 사용됩니다. 배경 스프라이트와 배경 스프라이트 위에 "이동 가능"스프라이트가 필요할 수 있습니다.

CCSprite *movableSprite = [CCSprite spriteWithFile:@"health100.png"]; 
CCProgressTimer *healthBar = [CCProgressTimer progressWithSprite:movableSprite]; 
healthBar.type = kCCProgressTimerTypeRadial; // This is for round progress timer. Possible value for horizontal bar will be kCCProgressTimerTypeHorizontalBarLR 

healthBar.midpoint = ccp(0,0.5); // Here is where all magic is 
healthBar.barChangeRate = ccp(1, 0); // If you need horizontal bar progress play with these parameters. 

// Here we will start an animation process. 
// You can do it without animation just setting up healthBar.progress = 45.0f; (45%) 
[healthBar runAction:[CCProgressFromTo actionWithDuration:2.0f from:0.0f to:100.0f]];   

healthBar.position = ccp(100, 100); // It's your position 

[self addChild:healthBar];