您当前的位置: 首页 >  游戏

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

发布时间:2015-11-11 09:58:42 ,浏览量:0

在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方法,其主要内容为选中一个机器人,必须反选其他机器人,任何时候只能有一个机器人被选中.

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    109273博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0489s