[問題] 兩個class之間互動問題
最近在寫小遊戲-丟垃圾(圖-可拖曳)到垃圾桶(圖-不可拖曳)
丟到垃圾桶時會加分
遇到一點問題,困擾許久
正常來說把垃圾丟到垃圾桶時會加分並將分數寫在計分板上
不過我寫來寫去計分的變數有收到,卻無法寫在計分板上
以下是程式碼
GameViewController是我主要元件的class
dragView是拖曳圖片動作的class
/*dragView*/
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
BOOL find = NO;
GameViewController *ccc =[[GameViewController alloc] init];
for (UIImageView *view in [[self superview] subviews]) {
if (view.tag != -1 && CGRectIntersectsRect(dragView.frame, view.frame))
[view setBackgroundColor:[UIColor clearColor]];
[dragView removeFromSuperview];
[ccc setScoreLabel];//設定計分板
find = YES;
}
}
if (!find) {
[self returnAnimation];
}
}
/*GameViewController*/
- (void)setScoreLabel{
score += 100;//有執行到這一行
ScoreLabel.text = [NSString stringWithFormat:@"%d",score];//卻沒執行這一行
}
有大大知道為什麼會這樣嗎?
--------------------------
以下是我的code
http://ppt.cc/SlUz
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.172.129.31
推
06/19 00:33, , 1F
06/19 00:33, 1F
→
06/19 00:57, , 2F
06/19 00:57, 2F
→
06/19 01:00, , 3F
06/19 01:00, 3F
→
06/19 01:37, , 4F
06/19 01:37, 4F
→
06/19 02:04, , 5F
06/19 02:04, 5F
→
06/19 02:04, , 6F
06/19 02:04, 6F
→
06/19 02:05, , 7F
06/19 02:05, 7F
→
06/19 05:18, , 8F
06/19 05:18, 8F
→
06/19 05:20, , 9F
06/19 05:20, 9F
推
06/19 09:24, , 10F
06/19 09:24, 10F
→
06/19 09:25, , 11F
06/19 09:25, 11F
→
06/19 11:16, , 12F
06/19 11:16, 12F
→
06/19 11:16, , 13F
06/19 11:16, 13F
→
06/19 11:20, , 14F
06/19 11:20, 14F
→
06/19 11:21, , 15F
06/19 11:21, 15F
→
06/19 11:21, , 16F
06/19 11:21, 16F
→
06/19 11:26, , 17F
06/19 11:26, 17F
→
06/19 11:27, , 18F
06/19 11:27, 18F
→
06/19 11:28, , 19F
06/19 11:28, 19F
→
06/19 11:32, , 20F
06/19 11:32, 20F
→
06/19 11:43, , 21F
06/19 11:43, 21F
→
06/19 11:44, , 22F
06/19 11:44, 22F
→
06/19 11:46, , 23F
06/19 11:46, 23F
※ 編輯: m87145999 來自: 1.172.129.31 (06/19 15:13)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
2
23
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章