I want to scroll my map by touching. Could you give me basic concepts how to reach it? Here is my ugly simple code. Just modifying layer's position by each touch moving. It works, but it's not cute as could be.
.h
CGPoint *touchBegin;
CGPoint *touchmove;
.m
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [touch locationInView:[touch view]];
touchLocation = [[CCDirector sharedDirector]
convertToGL:touchLocation];
touchBegin=new CGPoint(touchLocation);
}
-(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [touch locationInView:[touch view]];
touchLocation =
[[CCDirector sharedDirector] convertToGL:touchLocation];
touchmove = new CGPoint(touchLocation);
[self setPosition:ccp(self.position.x/100-(touchBegin->x-touchmove->x),self.position.y/100.0f)];
delete touchmove;
touchmove=NULL;
}
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
if (touchBegin)
{
delete touchBegin;
touchBegin=NULL;
}
if (touchmove)
{
delete touchmove;
touchmove=NULL;
}
}