多点触摸
来源:互联网 发布:java final关键字 对象 编辑:程序博客网 时间:2024/04/27 21:57
@implementation TouchLayer
- (id) init
{
if ((self = [super init])) {
touchSpriteA_ =[CCSprite spriteWithFile:@"Icon.png"];
[self addChild:touchSpriteA_];
touchSpriteB_ =[CCSprite spriteWithFile:@"Icon.png"];
[self addChild:touchSpriteB_];
}
return self;
}
- (void) dealloc
{
[super dealloc];
}
- (void) onEnter
{
[super onEnter];
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
- (void) onExit
{
[[CCTouchDispatcher sharedDispatcher] removeDelegate:self];
[super onExit];
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
return YES;
}
- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event;
{
CGPoint begen = [touch locationInView: [touch view]];
NSSet *allTouches = [event allTouches];//获得所有触摸点
int count = [[allTouches allObjects] count];//当前触摸点数量,单点触摸为1.
if (count == 1) {//单点触摸
UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];//获得第一个触摸点
switch ([touch1 tapCount]) {//判断是单击还是双击
case 1:
if (begen.y<550) {
}
NSLog(@"单击\n");
break;
case 2:
#pragma mark这里可以执行动画
NSLog(@"双击\n");
break;
}
}else if (count == 2) {//多点触摸
CGPoint touch0_point = [[[allTouches allObjects] objectAtIndex:0] locationInView: [touch view]];
CGPoint touch1_point = [[[allTouches allObjects] objectAtIndex:1] locationInView: [touch view]];
touchSpriteB_.position = touch0_point;
touchSpriteA_.position = touch1_point;
NSLog(@"两点触摸\n%f---%f",touch0_point.x,touch1_point.x);
}
}
- 多点触摸
- 多点触摸
- 多点触摸
- 多点触摸
- 多点触摸
- Cocos2d触摸:多点触摸
- Android-单点触摸-多点触摸
- 什么是多点触摸?
- 多点触摸技术
- 多点触摸技术
- Linux 多点触摸简介
- WPF4 多点触摸事件
- 多点触摸参考程序
- 多点触摸入门心得
- Andrioid 多点触摸
- 多点触摸 Handling Events
- android多点触摸demo
- iPhone 多点触摸
- Linux下Luabind编译和使用环境的搭建
- 后院 (组合数+线段判重)
- EXTJS4 MVC框架
- sqlite3的学习使用--轻量级数据库
- oracle 归档日志
- 多点触摸
- c++ union
- SharePoint 2010 Error: You must specify a value for this required field
- 网络通信函数
- IE6 CSS引起的卡死陷阱
- 自动取消选中行
- 一句话清晰总结协变(covariant)和逆变 (contravariant)
- TFS签入签出规范
- 老BIOS里面没有从USB启动这一项时,如何通过USB来进入WinPE或重装系统