some_id
some_id

Reputation: 29886

Moving a background in a timer

How does one move the background image in a timer using cocos2d.

-(void) update:(ccTime)delta

What would be set in this method to move the background only on its y axis? I would like to scroll the map/background downwards as if the player is moving upwards.

I would like to then call this update method somehow every second or so.

Upvotes: 0

Views: 499

Answers (1)

xuanweng
xuanweng

Reputation: 1939

-(void)update:(ccTime)delta

{
backgrd.position = ccp(backgrd.position.x,backgrd.position.y-10);
}

In your init:

-(id)init
{
self = [super init];
if(self)
{
//init your backgrd and stuff..
[self schedule:@selector(update:) interval: 1.0];
}
return self;
}

Upvotes: 1

Related Questions