0

我的 CCScene 遇到了问题。我正在尝试在播放器块上设置场景的位置。这是我的场景的初始化:

  - (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;
}

这是我的玩家块初始化:

    -(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;
}

当前发生的情况是它不关注玩家块。

谁能帮我解决这个问题?

4

1 回答 1

0

Needed to add this line to my scene:

self.contentSize=CGSizeMake(1000, 1000);

As my sprite lay outside of the scene bounds.

于 2014-03-19T02:04:07.853 回答