Tilemap没有填满整个场景

时间:2014-09-04 05:16:24

标签: ios xcode cocos2d-iphone scene

我在Xcode 5中使用了cocos2d和一个viewcontroller。我创建了一个CCDirector作为子视图控制器,然后将其添加到故事板中的UIView。

myViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    CCDirector* director = (CCDirector *)[self childViewControllers][0];
    director.view.frame = CGRectMake(0, 0, 320, 176);
    [_sceneView addSubview:[director view]];
}

tilemap是在IntroLayer.m。

中创建的
-(id) initWithViewContoller:(MyCocosViewController *)viewController
{
    if( (self=[super init])) {

    _tileMap = [CCTMXTiledMap tiledMapWithTMXFile:@"apartmentWithWall.tmx"];
    [self addChild:_tileMap z:-1];
    _tileMap.scale = 1;

    _bgLayer = [_tileMap layerNamed:@"Floorplan"];
    self.wall = [_tileMap layerNamed:@"Walls"];
    _wall.visible = NO;
}

场景是在IntroLayer.m中制作的

+(CCScene *) sceneWithViewController:(MyCocosViewController *)viewController
{

    CCScene *scene = [CCScene node];


    IntroLayer *layer = [[IntroLayer node] initWithViewContoller:viewController];

    // add layer as a child to scene
    [scene addChild: layer];


    return scene;
}

此代码成功创建了tilemap并将其放入视图中。但是,tilemap不占用整个场景 - 它似乎只有一半大小。它位于视图的左下角,视图的其余部分仅为黑色。如果你触摸它,那么像素没有正确缩放 - 你可以触摸黑色部分,它仍然认为这是tilemap的一部分。这就是它的样子:http://i.imgur.com/hb0gMFI.png

左下方的白色和黑色平面图应该占据整个场景。

那么为什么它不能自然地正确缩放?我看过的教程似乎没有这个问题。

0 个答案:

没有答案
相关问题