游戏开发:射击游戏与粒子效果实现指南
射击游戏中的敌人与组件管理
在射击游戏开发中,敌人实体的管理和组件的运用至关重要。当敌人类型为 EnemyTypeBoss 时,会在 EnemyEntity 的 init 方法中添加 HealthbarComponent ,代码如下:
if (type == EnemyTypeBoss)
{
HealthbarComponent* healthbar = [HealthbarComponent
spriteWithSpriteFrameName:@"healthbar.png"];
[self addChild:healthbar];
}
spawn 方法也进行了扩展,用于重置敌人的生命值并调用可能添加到实体的 HealthbarComponent 的 reset 方法:
-(void) spawn
{
// Select a spawn location just outside the right side of the screen
CGRect screenRect = [GameScene screenRect];
CGSize spriteSize = [self contentSize];
超级会员免费看
订阅专栏 解锁全文
42

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



