ios - How to make this "tape rolling" effect - Objective C -


i'm creating game , i'm trying effect scenery on sides changing lot, i'm not using sprite kit or anything, uikit because simple game. have png double screen size of iphone 5 (568px x 2 = 1136px), starts in middle of screen when game starts, , scrolls down player navigates through game. want reset , roll through game after it's center has passed point, thought write this:

    if (scenery.center.y > 1136) {     scenery.center = cgpointmake(scenery.center.x, -568); } 

i chose scenery.center.y > 1136 because bottom of screen x2. makes point @ -568, there 1 full screen there no scenery. there better way go doing this, , making continuous?

i used cabasic animations accomplish this:

+(void)animateview:(uiview *)view {      cabasicanimation *animation = [cabasicanimation animationwithkeypath:@"position.x"];      animation.delegate = self;     animation.fromvalue = view.frame.origin.x - view.frame.size.width;     animation.tovalue = [uiscreen mainscreen].bounds.size.width;     animation.repeatcount = infinity;     animation.duration = 0.5;     animation.autoreverses = no;     animation.begintime = 0; // ignore delay time     animation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctionlinear];      [view.layer addanimation:animation forkey:@"horizontal_animation"]; 

}

the view represents uiimageview i'm moving across screen. start off screen (see fromvalue) , move opposite side off screen (see tovalue). if need vertical animations well, can create [cabasicanimation animationwithkeypath:@"position.y"] similar values shown above.

also, if want besides linear animation, replace kcamediatimingfunctionlinear. in place start typing kcamediatiming ... , let wonders of autocomplete take rest of way.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -