I am trying to move the object around the screen using cocos2d. I have this code:
-(void) move
{
CGFloat upperLimit = mWinSize.height - (mGunda.contentSize.height / 2.0);
CGFloat upperLimit1 = mWinSize.height;
CGFloat lowerLimit = (mGunda.contentSize.height / 2.0);
CGFloat RightLimit = mWinSize.width - (mGunda.contentSize.width/2.0);
CGFloat Right = (mGunda.contentSize.width/2.0);
if(mImageGoingUpward ) {
mGunda.position = ccp( mGunda.position.x, mGunda.position.y + 5);
if(mGunda.position.y >= upperLimit) {
mImageGoingUpward = NO;
mHori = NO;
}
} else {
mGunda.position = ccp( mGunda.position.x, mGunda.position.y - 5);
if(mGunda.position.y <= lowerLimit) {
mGunda.position = ccp(mGunda.position.x +5, lowerLimit);
}
if(mGunda.position.x >= RightLimit) {
mGunda.position = ccp(mGunda.position.x, mGunda.position.y+10);
mHori = YES;
}
if(mHori) {
if(mGunda.position.y >= upperLimit) {
mGunda.position = ccp(mGunda.position.x - 5,mGunda.position.y);
}
}
}
}
It is supposed to move the object around the screen. The code mostly works, but it doesn't move the object from the top-right of the screen to the left of the screen.