[問題]跟電流急急棒有點像的object-c程式寫法疑問

看板MacDev作者 (小劉)時間9年前 (2015/03/10 18:21), 9年前編輯推噓2(204)
留言6則, 4人參與, 最新討論串1/1
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

03/11 01:52, , 1F
if 可以直接判斷兩個條件嗎?
03/11 01:52, 1F

03/11 01:55, , 2F
是要加 && 分開吧
03/11 01:55, 2F

03/11 12:24, , 3F
有沒有辦法取得背景圖的pixel呢?如果可以我的想法是抓滑鼠
03/11 12:24, 3F

03/11 12:25, , 4F
的位置(x,y) 如果pixel(x,y)!=redColor 就判定出界
03/11 12:25, 4F

03/11 12:49, , 5F
因為我不會抓背景的pixel...
03/11 12:49, 5F

03/11 14:35, , 6F
CGDisplayCreateImageForRect
03/11 14:35, 6F
文章代碼(AID): #1K_iMhxO (MacDev)