I am creating a virtual gamepad for my game, It has one main SKSpriteNode with circle image and four child node(up, down, left, right) with image. When I am using default size for all it looks perfect but it's big in size and when I tried to resize the main circle SKSpriteNode all it's child node are bigger then it's parent and I am unable to calculate size for child node that will fit for every condition(different size of Main node).
-(id)initWithJoystickImage:(NSString *)baseImage
upImage:(NSString *)upImage downImage:(NSString *)downImage leftImage:(NSString *)leftImage rightImage:(NSString *)rightImage
{
if((self = [super initWithImageNamed:baseImage]))
{
SKSpriteNode *up = [[SKSpriteNode alloc] initWithImageNamed:upImage];
up.position = CGPointMake(0, up.frame.size.height/2);
[self addChild:up];
SKSpriteNode *down = [[SKSpriteNode alloc] initWithImageNamed:downImage];
down.position = CGPointMake(0, -down.frame.size.height/2);
[self addChild:down];
SKSpriteNode *right = [[SKSpriteNode alloc] initWithImageNamed:rightImage];
right.position = CGPointMake(right.frame.size.width/2, 0);
self.size.height/2.5);
[self addChild:right];
SKSpriteNode *left = [[SKSpriteNode alloc] initWithImageNamed:leftImage];
left.position = CGPointMake(-left.frame.size.width/2, 0);
self.size.height/2.5);
[self addChild:left];
}
return self;
}