tags:

views:

10

answers:

0

Hello everybody.

I'm a beginner and I need some help in one of my first game apps. I know it's a common problem, but I haven't found enough information about it, so I would be thankful to have it now: I don't know how to accelerate an image by holding a button, only it works for me with the simple TouchUpInside way, so the object moves linearly. How can I do? I've made a purpose... What's wrong with it? It compiles but doesn't work.... THANKS!!!

PS: It doesn't matter the NSTimer part, I could easily change it if I get the other part!

BOOL abc=NO;

-(IBAction)Up{
    [up addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchDown];
    [up addTarget:self action:@selector(notPressed) forControlEvents:UIControlEventTouchUpOutside];

    while(abc==YES){
        NSLog(@"ButtonPressed");
        [NSTimer scheduledTimerWithTimeInterval:1.0/10.0 target:self selector:@selector(moveBall) userInfo:nil repeats:YES];
        [mBall setSpeedX:x Y:y=y-5];

        abc=NO;
        [up addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchDown];
        [up addTarget:self action:@selector(notPressed) forControlEvents:UIControlEventTouchUpOutside];
    }
}

-(void)buttonPressed{
    abc=YES;
}

-(void)notPressed{
    abc=NO;
}