Thursday, July 14, 2016

cocos2d iphone - How to make Snake Body in Snake Game?


I'm new in cocos2d and game dev. I'm still learning in game dev. My goal is to make one game like Doodle Grub. But problem is snake body. I wrote like following



-(void)update:(ccTime)delta
{
//NSLog(@"%f",[GameScence sharedGameScence].playerVelocity.y);

CGPoint tmp=self.position;
float tmprotation;
self.position=[GameScence sharedGameScence].WormHeadPos;

[GameScence sharedGameScence].WormHeadPos=tmp;
tmprotation=self.rotation;


[self setRotation:[GameScence sharedGameScence].Headrotation];

[GameScence sharedGameScence].Headrotation=tmprotation;

}

snake is moving but problem is all of the body segments are same position when snake stop. And all of the body segments is so close and can't see segments like Doodle Grub. Any idea or Any suggestion ?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...