views:

295

answers:

0

Hello,

I'm new to objective c. My code has a scrolling back ground and in the fore ground is a spinning wheel.

I can scroll the back ground and rotate the wheel UIImage view just fine.

I'm having an issue with making the wheel rotate in the opposite direction when my background begins to scroll in the opposite direction.

Here's my code:

- (void) animateBG:(NSTimer *)animBGTimer {


    scrollingBG.center = CGPointMake(scrollingBG.center.x, scrollingBG.center.y + scrollingBGMovement.y);


    wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / 20.0f);

    if (scrollingBG.center.y > 1220 || scrollingBG.center.y < -770 )
        scrollingBGMovement.y = -scrollingBGMovement.y;

    if (scrollingBG.center.y > 1220){
        wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / -20.0f);
    }
}

I've tried putting the line

wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / -20.0f);

right under my first "if" statement, but no go.

Any ideas?

Thank you Michael