We will now move on to examine how we move the bike. Because the walls are central to the bike movement code, we left the movement until we understood the walls. The movement is broken down into two methods.
-(void) move { // Move this bike (if local player) [self moveForDistance:self.bikeSpeed]; // Remote game }
This is the easy method. This looks a little silly now, but it will make more sense once we add the "remote game" functionality later. For now, this is just a pass-through to the moveForDistance
method, passing the
bikeSpeed
parameter.
-(void)moveForDistance:(float)dist { // Update bike position and scales the currentWall switch (self.bikeDirection) { case kUp: [self setPosition:ccp(self.position.x, self.position.y + dist)]; [self.currentWall setScaleY: ABS(self.currentWall.position.y...