Hi everyone
I have an urgent task to complete but I run out of ideas, could anyone give me some advise.
I developing a game that the player will need to open a lock by just use 2 fingers. Putting 2 fingers in the centre where the lock is located, then stretch 2 fingers, if the 2 fingers point at the correct location and end at the correct location in the correct time (2seconds) then he will successfully unlock it, and it will load another the scene then the player will need to do the same thing in 20 seconds he must unlock 10 times. Then he will win. Could anyone give me some ways to implement this.
Thanks a lot. I am new to cocos game development
-(float)distanceBetween:(CGPoint)p1 withPoint:(CGPoint) p2{
float dx = p1.x-p2.x;
float dy = p1.y-p2.y;
return sqrt( dx*dx + dy*dy);
}
-(BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)events
{
NSSet *allTaps = [events allTouches];
for( UITouch *touch in allTaps)
{
CGPoint location = [touch locationInView: [touch view]];
location = [[Director sharedDirector] convertCoordinate:location];
NSLog(@"onli a tap x: %3.3f, y:%3.3f",location.x,location.y);
}
return kEventHandled;
}
//the fingers start moving at somewhere on the screen
-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)events
{
/*
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[Director sharedDirector] convertCoordinate:location];
lady.position = convertedLocation;
NSLog(@"2 touches here");
return kEventHandled;
*/
NSSet *allTouches2 = [events allTouches];
for( UITouch *touch in allTouches2)
{
CGPoint location2 = [touch locationInView: [touch view]];
location2 = [[Director sharedDirector] convertCoordinate: location2];
NSLog(@"move TOUCHed x: %3.3f, y: %3.3f",location2.x,location2.y);
}
return kEventHandled;
}
//where the fingers ended , this will determine the correct actions made.
-(BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)events
{
NSSet *allTouches2 = [events allTouches];
for( UITouch *touch in allTouches2)
{
CGPoint location2 = [touch locationInView: [touch view]];
location2 = [[Director sharedDirector] convertCoordinate: location2];
NSLog(@"end TOUCHed x: %3.3f, y: %3.3f",location2.x,location2.y);
}
return kEventHandled;
here is my code so far that i can detect multi touch