Class Cocos2D:从另一个类引用类TMXLayer

Class Cocos2D:从另一个类引用类TMXLayer,class,methods,map,cocos2d-iphone,subclass,Class,Methods,Map,Cocos2d Iphone,Subclass,使用Cocos2D。我目前已经将大部分玩家精灵和行为从调试映射中分为子类,现在我很难从精灵类中引用TMXLayer。我试着在这个方法中从sprite类中分配一个DebugZoneLayer类的实例,并以奇怪的结果释放它。编译时不会出错,但无法测试if(blocksCollidableGID | blocksCollidable2GID){条件,因为debugZoneLayer.blockscolliable目前对该方法没有任何意义 sprite类中的方法: -(BOOL) checkTileCo

使用Cocos2D。我目前已经将大部分玩家精灵和行为从调试映射中分为子类,现在我很难从精灵类中引用TMXLayer。我试着在这个方法中从sprite类中分配一个DebugZoneLayer类的实例,并以奇怪的结果释放它。编译时不会出错,但无法测试if(blocksCollidableGID | blocksCollidable2GID){条件,因为debugZoneLayer.blockscolliable目前对该方法没有任何意义

sprite类中的方法:

-(BOOL) checkTileCollisionForStrafing:(NSString*)omit{

    for(int j = 0; j < _collisPushPointsNums; j++){

        NSValue *val = [_collisPushPoints objectAtIndex:j];
        CGPoint p = [val CGPointValue];

        CGPoint tileCoord;



        if(omit==@"y"){
            tileCoord = [debugZoneLayer tileCoordForPosition:ccp(_heroSprite.position.x+_vel.x+p.x, _heroSprite.position.y+(p.y+.001))];
        }else{
            tileCoord = [debugZoneLayer tileCoordForPosition:ccp(_heroSprite.position.x+p.x, _heroSprite.position.y+_vel.y+p.y)];
        }

        int     blocksCollidableGID  = [debugZoneLayer.blocksCollidable  tileGIDAt:tileCoord];
        int     blocksCollidable2GID = [debugZoneLayer.blocksCollidable2 tileGIDAt:tileCoord];



        if (blocksCollidableGID | blocksCollidable2GID){
            NSLog(@"j = %i", j);
            return YES;
        }
    }

    return NO;
}
-(BOOL)选中TileCollisionForTrading:(NSString*)忽略{
对于(int j=0;j<_collisPushPointsNums;j++){
NSValue*val=[\u collisPushPoints objectAtIndex:j];
CGPoint=[val CGPointValue];
CGPoint-tileCoord;
如果(省略==@“y”){
TileCord=[debugZoneLayer TileCordForPosition:ccp(_heroSprite.position.x+_vel.x+p.x,_heroSprite.position.y+(p.y+.001));
}否则{
TileCord=[debugZoneLayer TileCordForPosition:ccp(_herospite.position.x+p.x,_herospite.position.y+_vel.y+p.y)];
}
int blocksCollidableGID=[debugZoneLayer.blocksCollidable tileGIDAt:tilecord];
int blocksCollidable2GID=[debugZoneLayer.blocksCollidable2 tileGIDAt:tilecord];
if(BLOCKSCLIDABLEGID | BLOCKSCLIDABLE2GID){
NSLog(@“j=%i”,j);
返回YES;
}
}
返回否;
}

我猜现在我必须做一些指针,但我不确定。实际上,我想我只是要从我的sprite类对我的DebugZoneLayer类执行一个方法调用,以获得blocksCollidableGID。