2
所以我得到了这个工作:用ccTouchesMoved方法移动CCCamera? (cocos2d的,iphone)
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
for(UITouch *touch in touches) {
CGPoint touchLocation = [touch locationInView: [touch view]];
CGPoint prevLocation = [touch previousLocationInView: [touch view]];
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
prevLocation = [[CCDirector sharedDirector] convertToGL: prevLocation];
CGPoint diff = ccpSub(touchLocation,prevLocation);
[self setPosition: ccpAdd(self.position, diff)];
}
}
我可以用我的手指在层中移动,但我想移动的cccamera,但我没有与任何cccamera经验。
任何人都可以帮助我吗?
非常感谢您 有一个愉快的一天
:)
+1我会接受它;)但我有一个问题:当相机移动时触摸不能正确检测到。 – cocos2dbeginner 2011-05-28 18:47:57
如何更正触摸检测? – cocos2dbeginner 2011-05-28 19:15:05
,对于迟到的回复感到抱歉:) – cocos2dbeginner 2011-05-28 19:15:44