Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Aurelian Spodarec
7,369 PointsProblem
When my helicopter goes down and i click on it , it goes back to my centre
Heli.center = CGPointMake(Heli.center.x, Heli.center.y + Y}
it always return to that code when i click . but it should go up from the place it started , whats wrong with this code?
//
// ViewController.m
// HelicopterGame
//
// Created by Dorota Pilch on 24/10/2014.
// Copyright (c) 2014 Aurelian. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)HeliMove{
Heli.center = CGPointMake(Heli.center.x, Heli.center.y + Y);
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (Start == YES) {
Intro1.hidden = YES;
Intro2.hidden = YES;
Intro3.hidden = YES;
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(HeliMove) userInfo:nil repeats:YES];
Start = NO;
}
Y = -7;
Heli.image = [UIImage imageNamed:@"HeliUp.png"];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
Y = 7;
Heli.image = [UIImage imageNamed:@"HeliDown.png"];
}
- (void)viewDidLoad {
Start = YES;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end