(NO.00003)iOS遊戲簡單的機器人投射遊戲成形記(十五)

來源:互聯網
上載者:User

(NO.00003)iOS遊戲簡單的機器人投射遊戲成形記(十五)

在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方法,其主要內容為選中一個機器人,必須反選其他機器人,任何時候只能有一個機器人被選中.

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.