나는 애니메이션 스프라이트를 만들려고 노력 해왔다. 그것들은 많은 튜토리얼이지만 Cocos2d 2.x를위한 것이다. 내 스프라이트 시트 flappbird.png 이름과 .plist는 flappbird.plist 이름스프라이트 프레임 애니메이션 Cocos2d 3.0
나는이 내 초기화에 방법이다,이 코드를하지만 난 그냥 충돌 장면을 시작할 때마다이
// -----------------------------------------------------------------------
_player = [CCSprite spriteWithImageNamed:@"monster1.png"]; // comes from your .plist file
_player.position = ccp(self.contentSize.width/28,self.contentSize.height/2);
_player.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, _player.contentSize} cornerRadius:0]; // 1
_player.physicsBody.collisionGroup = @"playerGroup";
_player.physicsBody.type = CCPhysicsBodyTypeStatic;
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"monster1.png"];
[batchNode addChild:_player];
[self addChild:batchNode];
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 1; i < 5; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"flapbird%d.png",i]];
[animFrames addObject:frame];
}
CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animFrames delay:0.2f];
[_player runAction:[CCActionRepeatForever actionWithAction:[CCActionAnimate actionWithAnimation:animation]]];
[_physicsWorld addChild:_player];
// -----------------------------------------------------------------------
중복 가능성을 [어떻게적인 Cocos2D 3.x의에서 CCSprite 애니메이션 없습니다? ] (http://stackoverflow.com/questions/21645953/how-to-animate-ccsprite-in-cocos2d-3-x) –
나는 분에 그 질문의 대답을 구현하려했지만 충돌이 일어나고 아무 일도 일어나지 않을 것이다. – Crazycriss
그것이 충돌 할 때 당신에게 무엇을 말합니까? – connor