我的CCScene遇到了一个问题。我正在尝试设置我的场景在播放器块上的位置。这是我的场景的init:
- (id)init
{
// Apple recommend assigning self with supers return value
self = [super init];
if (!self) return(nil);
self.userInteractionEnabled = YES;
// Create a colored background (Dark Grey)
CCNodeColor *background = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0 green:0 blue:0 alpha:1.0f]];
[self addChild:background];
// Add a sprite
_player = [[PlayerBlock alloc]initWithX:[bp getPlayerX] withY:[bp getPlayerY] maxX:1000 maxY:1000 levelBlocks:blocks endBlock:fb];
[self addChild:_player];
self.positionType=CCPositionTypePoints;
self.position=_player.position;
// done
return self;
}这是我对player block的初始化:
-(id)initWithX:(double)x withY:(double)y maxX:(double)maxX maxY:(double)maxY levelBlocks:(NSMutableArray*)sprites endBlock:(FinishBlock*)finishBlock{
self=[self initWithImageNamed:@"player.png"];
self.position = ccp(x,y);
_finish=finishBlock;
_sprites=sprites;
_startX=x;
_startY=y;
_maxX=maxX;
_moving=0;
_maxY=maxY;
self.width=25;
self.height=25;
self.positionType=CCPositionTypePoints;
return self;
}目前发生的情况是,它不关注player块。
有人能帮我把这事说清楚吗?
发布于 2014-03-19 10:04:08
需要将这一行添加到我的场景中:
self.contentSize=CGSizeMake(1000, 1000);当我的精灵躺在场景边界之外时。
https://stackoverflow.com/questions/22494524
复制相似问题