I am working with Cocos2d and I got this strange but simple problem. I wanted to slide the CCSptire called backgroundView 1 pixel every time the update loop is called. When I ran the program the background was gone so I added a NSLog to test the results. I then removed the code + 1 from the update method, "backgroundView.boundingBox.origin.x + 1". So now every time the update method is called the boundingbox.origin X and Y should remain the same. But the NSLog, displayed below, shows that it is still moving when it should remain the same? The PNG image is 1136 x 640. The image is moving -568 each loop, which is the hight of the iPhone.
What have I missed here?
What have I missed here?
Code:
- (id)init
{
// Apple recommend assigning self with supers return value
self = [super init];
if (!self) return(nil);
[B][self pageSetup];[/B]
return self;
}
-(void)update:(CCTime)delta{
backgroundView.position = ccp([B]backgroundView.boundingBox.origin.x[/B], backgroundView.boundingBox.origin.y);
NSLog(@"x%.0f", backgroundView.boundingBox.origin.x);
}
-(void)pageSetup{
backgroundView = [CCSprite spriteWithImageNamed:@"bgTest.png"];
backgroundView.position = ccp(0, 320);
[self addChild:backgroundView];
}
2014-07-04 13:13:09.540 Cannons[2440:90b] cocos2d: surface size: 1136x640
2014-07-04 13:13:09.711 Cannons[2440:90b] x-1136
2014-07-04 13:13:09.773 Cannons[2440:90b] x-1704
2014-07-04 13:13:09.806 Cannons[2440:90b] x-2272
2014-07-04 13:13:09.823 Cannons[2440:90b] x-2840
2014-07-04 13:13:09.840 Cannons[2440:90b] x-3408
2014-07-04 13:13:09.857 Cannons[2440:90b] x-3976
2014-07-04 13:13:09.873 Cannons[2440:90b] x-4544
2014-07-04 13:13:09.890 Cannons[2440:90b] x-5112
2014-07-04 13:13:09.906 Cannons[2440:90b] x-5680
2014-07-04 13:13:09.923 Cannons[2440:90b] x-6248
Last edited: