您的位置:首页 > 移动开发 > IOS开发

(NO.00003)iOS游戏简单的机器人投射游戏成形记(十五)

2015-11-11 09:58 387 查看
在Xcode中打开Robot.h文件添加如下2个方法:

-(void)moveArm:(MoveDirection)direction;
-(void)armShoot;


在Robot.m中实现这2个方法:

-(void)armShoot{
[_arm armShoot];
}

-(void)moveArm:(MoveDirection)direction{
[_arm moveArm:direction];
}


由于玩家点击机器人时需要选中该机器人,所以要添加touchBegan方法:

-(void)touchBegan:(CCTouch *)touch withEvent:(CCTouchEvent *)event{
self.isSelected = YES;

LevelRestrict *lr = [LevelRestrict sharedInstance];
lr.selectedRobot = self;

[[MainScene sharedInstance] selectRobot:self];
//将触碰事件向下层节点传递
//[super touchBegan:touch withEvent:event];
}


现在在回到MainScene.m中添加selectRobot方法,其主要内容为选中一个机器人,必须反选其他机器人,任何时候只能有一个机器人被选中.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios arm xcode 机器人 游戏