I created a method in map.m
called createCategories:
all it did was assign the value to each instance variable which was created from the @property
's I declared in map.h
.
map.h
@interface map : SKNode
@property uint32_t buildingStructureCategory;
@property uint32_t buildingWindowCategory;
@property uint32_t buildingSignCategory;
@property uint32_t buiildingSignCategory;
@property uint32_t buildingDoorCategory;
@property uint32_t buildingRoofCategory;
map.m
-(void)createCategories{
_buildingStructureCategory = 0x1 << 0;
_buildingWindowCategory = 0x1 << 1;
_buildingSignCategory = 0x1 << 2;
_buiildingSignCategory = 0x1 << 3;
_buildingDoorCategory = 0x1 << 4;
_buildingRoofCategory = 0x1 << 5;
}
I then alloc
and init
an instance object of the map class
in game.m
after allocating and initialising the instance object I then called the method createCategories:
and used the variables from map.m
as I pleased with the dot syntax.
-(SKSpriteNode*)createCharacter{
categoryBitManager = [[ProceduralMapGeneration alloc]init]; //alloc and init instance object
[categoryBitManager createCategories]; //calling method to set property values
NSString *characterString = [NSString name:@"Player" andRetinaBool:_retina];
SKSpriteNode *character = [SKSpriteNode spriteNodeWithImageNamed:characterString];
character.name = @"character";
character.size = CGSizeMake(10, 10);
character.position = CGPointMake(self.scene.size.width/2, self.scene.size.height/2);
character.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:character.size];
character.physicsBody.categoryBitMask = playerCategory;
character.physicsBody.collisionBitMask = categoryBitManager.buildingStructureCategory; // accessing property
NSLog(@"the value is %u",character.physicsBody.collisionBitMask); //testing is value is same as in map.m
return character;
}