看板 MacDev 關於我們 聯絡資訊
http://imgur.com/fZDiu7F 目前我的想法是希望用滑鼠畫出黃色線 如果黃色超出了紅色路徑的範圍 那會跳出警告的視窗 目前用這種寫法: if(36<currentPoint.x<=50) { //第一段路 if (105<currentPoint.y<107) { ...//其他的if else來控制其他段路 } else { UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Wrong way!" message:@"Finger has been lifted off the screen." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; drawImage.image=nil; StartGame.hidden=NO; [Timer invalidate]; alertPressCount++; } } 不過一直不成功 而且始終覺得這個方法不是很好 有大大可以提供更好的寫法嗎? 檔案在這: https://drive.google.com/file/d/0B-4eybT3ZkTaeVJ0NldZVVRXa1E/view -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.54.99 ※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1425982891.A.ED8.html ※ 編輯: ljuyentintho (140.114.54.99), 03/10/2015 18:24:21
ckvir: if 可以直接判斷兩個條件嗎? 03/11 01:52
ckvir: 是要加 && 分開吧 03/11 01:55
fenir: 有沒有辦法取得背景圖的pixel呢?如果可以我的想法是抓滑鼠 03/11 12:24
fenir: 的位置(x,y) 如果pixel(x,y)!=redColor 就判定出界 03/11 12:25
ljuyentintho: 因為我不會抓背景的pixel... 03/11 12:49
howdiun: CGDisplayCreateImageForRect 03/11 14:35