作者ljuyentintho (小刘)
看板MacDev
标题[问题]电流急急棒有点像的object-c程式写法疑问
时间Tue Mar 10 18:21:28 2015
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://webptt.com/cn.aspx?n=bbs/MacDev/M.1425982891.A.ED8.html
※ 编辑: ljuyentintho (140.114.54.99), 03/10/2015 18:24:21
1F:→ ckvir: if 可以直接判断两个条件吗? 03/11 01:52
2F:→ ckvir: 是要加 && 分开吧 03/11 01:55
3F:推 fenir: 有没有办法取得背景图的pixel呢?如果可以我的想法是抓滑鼠 03/11 12:24
4F:→ fenir: 的位置(x,y) 如果pixel(x,y)!=redColor 就判定出界 03/11 12:25
5F:→ ljuyentintho: 因为我不会抓背景的pixel... 03/11 12:49
6F:推 howdiun: CGDisplayCreateImageForRect 03/11 14:35