游戏角色创建:游戏引擎、图像角色与行为
在游戏开发中,角色的创建是至关重要的一环。本文将深入探讨如何创建游戏角色,包括游戏引擎的相关操作、图像角色的表示以及角色行为的定义。
1. 角色类的基本操作
首先,我们来看一些角色类的基本操作代码:
-(void)addBehavior:(NSObject<Behavior>*)behavior{
if (behaviors == nil){
behaviors = [NSMutableArray new];
}
[behaviors addObject:behavior];
}
-(void)dealloc{
[actorId release];
[behaviors removeAllObjects];
[behaviors release];
[representation release];
[super dealloc];
}
+(CGPoint)randomPointAround:(CGPoint)aCenter At:(float)aRadius{
float direction = arc4random()%1000/1000.0 * M_PI*2;
return CGPointMake(aCenter.x + cosf(direction)*aRadius, aCenter.y + sinf(direction)*aRadius);
}
在上述代码中:
- addBehavior:
游戏角色创建:引擎、图像与行为实现
超级会员免费看
订阅专栏 解锁全文
742

被折叠的 条评论
为什么被折叠?



