It looks like you're new here. If you want to get involved, click one of these buttons!
ahan.tm
Posts: 10New Users
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
marblebeingdragged = NO;
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(plusone.frame, location) && marblebeingdragged == NO) //Drag Plus One
{
marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
plusone.center = location;
}
if(CGRectContainsPoint(plustwo.frame, location) && marblebeingdragged == NO) //Drag Plus Two
{
marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
plustwo.center = location;
}
if(CGRectContainsPoint(plusthree.frame, location) && marblebeingdragged == NO) //Drag Plus Three
{
//marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
plusthree.center = location;
}
if(CGRectContainsPoint(minusone.frame, location) && marblebeingdragged == NO) //Drag Minus One
{
marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
minusone.center = location;
}
if(CGRectContainsPoint(minustwo.frame, location) && marblebeingdragged == NO) //Drag Minus Two
{
marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
minustwo.center = location;
}
if(CGRectContainsPoint(minusthree.frame, location) && marblebeingdragged == NO) //Drag Minus Three
{
marblebeingdragged = YES;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
minusthree.center = location;
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[self touchesBegan:touches withEvent:event];
marblebeingdragged = NO;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
if (CGRectIntersectsRect(striker.frame, plusone.frame)) { //Plus One Collision
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); //iPhone Vibrate
marbles = 1+marbles; // Add 1 To Marbles
marblesleft = marblesneeded - marbles;
marblesNeeded.text = [NSString stringWithFormat:@\"%i\", marblesleft];
NSNumber *marbleNumber = [NSNumber numberWithInt:marbles];
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef =CFBundleCopyResourceURL(mainBundle,
(CFStringRef) @\"1 Marble\", CFSTR (\"aif\"), NULL); //Sound Stuff
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
[[records objectAtIndex:pageControl.currentPage] setValue:marbleNumber forKey:@\"marbles\"]; //Set Marble Value
[self checkPrizeReached];
NSError *error;
[_managedObjectContext save:&error]; //Save
[UIView beginAnimations:nil context:nil]; //Move To Start Position With Animation
[UIView setAnimationDuration:0.5];
plusone.center = CGPointMake(36, 46);
[UIView commitAnimations];
marblebeingdragged = NO;
} else
{
marblebeingdragged = YES;
}
Replies
The simulator runs in native Intel machine code that is tens of times faster than the processor in even an iPad 2, and has hundreds of times more memory. The performance characteristics of the simulator are NOTHING like that of a real device.
Also, pick the base device you support, and be sure to test on that.
The iPhone 3G is dramatically slower than the 3Gs. Apple has dropped support of the 3G for iOS 5. I would suggest doing the same. It's just too slow for recent animation tricks to work slowly. The 3Gs, will a little slower than the 4 and 4s, is reasonable.
Are you saying that your software is much slower under iOS 5 on a device than it is in 4.x on the same device? That's a different story.
I didn't really follow your code. It seems odd to have your touchesMoved method call touchesBegan.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMy old 3GS would run the code perfectly fine until I updated to iOS 5..
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome