Hey Guys,
I have been developing a game using the Cocos2d API, and all is going well, but I have run into a couple of little issues. The first of which is to do with the Positioning of AtlasSprite.
Explaination:
I have a menu sprite sheet which contains 2 button states for each button, dimentions are 153(w) x 37(h).
I create 6 AtlasSprite each with their own rect that points to a position on the spritesheet which i have double & tripple checked the values and all appares fine.
From here i compile to the Simulator, and all looks nice, and works fine, however when i compile this to the iphone... the FIRST menu item's normal state if offset by (0, 1), so the button shows one pixel from the selected state, BUT once selected, shows the correct selected area
Code:
AtlasSpriteManager *mgrMenuSprite = [AtlasSpriteManager spriteManagerWithFile:@"menuBtns.png"];
[mgrMenuSprite.textureAtlas.texture setAliasTexParameters];
[self addChild:mgrMenuSprite];
AtlasSprite *spriteStartGameNormal = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 153, 37) spriteManager:mgrMenuSprite];
AtlasSprite *spriteStartGameSelected = [AtlasSprite spriteWithRect:CGRectMake(0, 37, 153, 37) spriteManager:mgrMenuSprite];
AtlasSprite *spriteHelpNormal = [AtlasSprite spriteWithRect:CGRectMake(0, 74, 153, 37) spriteManager:mgrMenuSprite];
AtlasSprite *spriteHelpSelected = [AtlasSprite spriteWithRect:CGRectMake(0, 111, 153, 37) spriteManager:mgrMenuSprite];
AtlasSprite *spriteOptionsNormal = [AtlasSprite spriteWithRect:CGRectMake(0, 148, 153, 37) spriteManager:mgrMenuSprite];
AtlasSprite *spriteOptionsSelected = [AtlasSprite spriteWithRect:CGRectMake(0, 185, 153, 37) spriteManager:mgrMenuSprite];
[mgrMenuSprite addChild:spriteStartGameNormal];
[mgrMenuSprite addChild:spriteStartGameSelected];
[mgrMenuSprite addChild:spriteHelpNormal];
[mgrMenuSprite addChild:spriteHelpSelected];
[mgrMenuSprite addChild:spriteOptionsNormal];
[mgrMenuSprite addChild:spriteOptionsSelected];
MenuItemSprite *item1 = [MenuItemAtlasSprite itemFromNormalSprite:spriteStartGameNormal selectedSprite:spriteStartGameSelected target:self selector:@selector(startGame:)];
MenuItemSprite *item2 = [MenuItemAtlasSprite itemFromNormalSprite:spriteHelpNormal selectedSprite:spriteHelpSelected target:self selector:@selector(help:)];
MenuItemSprite *item3 = [MenuItemAtlasSprite itemFromNormalSprite:spriteOptionsNormal selectedSprite:spriteOptionsSelected target:self selector:@selector(options:)];
Menu *menu = [Menu menuWithItems:item1, item2, item3, nil];
menu.position = CGPointZero;
item1.position = ccp(480/2, 160);
item2.position = ccp(480/2, 119);
item3.position = ccp(480/2, 78);
[self addChild:menu];
Above is the code, if screenshots are needed, please ask and i will get back to you.
Thanks for the help.