《30天精通iPhone手机编程》-Day28-触屏移动
来源:互联网 发布:电脑网络技术培训 编辑:程序博客网 时间:2024/06/02 09:08
在原来的游戏中经常的动作就是点到什么地方,游戏中的任务就跑到什么地方,这在网游中尤其常见,下面实现的就是在屏幕上面点击某个位置,设置的图片就到手指所点的那个坐标位置去。
//播放音频文件 -(void)playSound:(NSString*)soundAct{//音频文件的路径名称 NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], soundAct];NSLog(@"%@\n", path);//声明一个系统声音标识符SystemSoundID soundID;//转换字符类型变量的路径文件为URL连接 NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; //使用AudioToolbox框架提供的创建声音服务,定义音频的路径和创建声音标识符 AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);//播放指定的音频标识符AudioServicesPlaySystemSound(soundID);[filePath release];}//获取手指的触摸事件方法,- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {//touches参数获得事件,定制事件中的任何触摸对象UITouch *touch = [touches anyObject];//定义图形位置变量对象的坐标,locationInView表示视图中触摸点的坐标currentTouch = [touch locationInView:self.view];[UIImageView beginAnimations:nil context:NULL];[UIImageView setAnimationDuration:1.0];UFO.center=CGPointMake(currentTouch.x, currentTouch.y);[UIImageView commitAnimations];soundFile = [NSString stringWithFormat:@"/Sound.wav"];[self playSound: soundFile];}
- 《30天精通iPhone手机编程》-Day28-触屏移动
- 《30天精通iPhone手机编程》-Day6-移动网站导航
- 《30天精通iPhone手机编程》-Day23-移动的方块
- 《30天精通iPhone手机编程》-Day17-老虎机
- 《30天精通iPhone手机编程》-Day19-电子琴
- 《30天精通iPhone手机编程》-Day24-烟花
- 《30天精通iPhone手机编程》-Day25-雪花
- 《30天精通iPhone手机编程》-Day26-弹球
- ios7版 30天精通iPhone手机编程 第6天 移动网站导航
- 《30天精通iPhone手机编程》-Day1-macos和iphonesdk简介
- 《30天精通iPhone手机编程》-Day2-hello world
- 《30天精通iPhone手机编程》-Day3-打开网站url连接
- 《30天精通iPhone手机编程》-Day4-设置文件setting bundle
- 《30天精通iPhone手机编程》-Day5-文字长度
- 《30天精通iPhone手机编程》-Day7-长度单位转换器
- 《30天精通iPhone手机编程》-Day8-分歧解决器
- 《30天精通iPhone手机编程》-Day9-密码生成器
- 《30天精通iPhone手机编程》-Day10-迷你秒表
- 【转载】Zynga的数据分析
- The USB composite framework
- Linux下Bash的数据流重导向,stdin,stdout,stderr
- malloc/free与new/delete的区别
- 一个最基本的渐变
- 《30天精通iPhone手机编程》-Day28-触屏移动
- 医院营销 民营医院企划的内涵及形式与内容
- 创业 股份比例与合伙人
- c++操作符重载
- 13 个应该记住的最不寻常的搜索引擎
- How to recover after rebooting the LFS procession
- 休みの日本語二課
- 剖析Shapefile
- MyEclipse8.6生成注册码