Skip to content

Instantly share code, notes, and snippets.

@rakkarage
Last active June 7, 2020 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakkarage/d86416820e878a149f340488ce9d7808 to your computer and use it in GitHub Desktop.
Save rakkarage/d86416820e878a149f340488ce9d7808 to your computer and use it in GitHub Desktop.
Callout.m
#import "Callout.h"
#import "GameLayer.h"
@implementation Callout
@synthesize delegate = _delegate;
- (void)lookTouched
{
playButtonSound();
if (_look)
{
_look = NO;
_callout1.opacity = 1.0f;
CCFadeOut *fade = [CCFadeOut actionWithDuration:0.2];
CCEaseExponentialOut *ease0 = [CCEaseExponentialOut actionWithAction:fade];
[_callout1 runAction:ease0];
_callout1.scale = 1.0f;
CCScaleTo *scale = [CCScaleTo actionWithDuration:0.2 scaleX:0.0f scaleY:1.0f];
CCEaseExponentialIn *ease1 = [CCEaseExponentialIn actionWithAction:scale];
[_callout1 runAction:ease1];
}
else
{
_look = YES;
_callout1.opacity = 0.0f;
CCFadeIn *fade = [CCFadeIn actionWithDuration:0.2];
CCEaseExponentialOut *ease0 = [CCEaseExponentialOut actionWithAction:fade];
[_callout1 runAction:ease0];
_callout1.scaleX = 0.0f;
CCScaleTo *scale = [CCScaleTo actionWithDuration:0.2 scaleX:1.0f scaleY:1.0f];
CCEaseExponentialOut *ease1 = [CCEaseExponentialOut actionWithAction:scale];
[_callout1 runAction:ease1];
}
}
- (void)walkTouched
{
playButtonSound();
[_delegate walkTouched];
[self hide];
}
- (void)upTouched
{
playButtonSound();
[_delegate upTouched];
[self hide];
}
- (void)downTouched
{
playButtonSound();
[_delegate downTouched];
[self hide];
}
- (void)useTouched
{
playButtonSound();
[_delegate useTouched];
[self hide];
}
- (void)attackTouched
{
playButtonSound();
[_delegate attackTouched];
[self hide];
}
- (void)menuTouched
{
playButtonSound();
[_delegate menuTouched];
[self hide];
}
- (void)passTouched
{
playButtonSound();
[_delegate passTouched];
[self hide];
}
- (void)useInventoryTouched
{
playButtonSound();
[_delegate useInventoryTouched:_p];
[self hide];
}
- (void)useEquipmentTouched
{
playButtonSound();
[_delegate useEquipmentTouched:_p];
[self hide];
}
- (void)useActionBarTouched
{
playButtonSound();
[_delegate useActionBarTouched:_p];
[self hide];
}
- (void)usePickupTouched
{
playButtonSound();
[_delegate usePickupTouched:_p];
[self hide];
}
- (void)equipInventoryTouched
{
playButtonSound();
[_delegate equipInventoryTouched:_p];
[self hide];
}
- (void)equipEquipmentTouched
{
playButtonSound();
[_delegate equipEquipmentTouched:_p];
[self hide];
}
- (void)equipActionBarTouched
{
playButtonSound();
[_delegate equipActionBarTouched:_p];
[self hide];
}
- (void)equipPickupTouched
{
playButtonSound();
[_delegate equipPickupTouched:_p];
[self hide];
}
- (void)pickupTouched
{
playButtonSound();
[_delegate pickupTouched:_p];
[self hide];
}
- (void)throwPickupTouched
{
playButtonSound();
[_delegate throwPickupTouched:_p];
[self hide];
}
- (void)throwInventoryTouched
{
playButtonSound();
[_delegate throwInventoryTouched:_p];
[self hide];
}
- (void)throwEquipmentTouched
{
playButtonSound();
[_delegate throwEquipmentTouched:_p];
[self hide];
}
- (void)throwActionBarTouched
{
playButtonSound();
[_delegate throwActionBarTouched:_p];
[self hide];
}
- (void)dropInventoryTouched
{
playButtonSound();
[_delegate dropInventoryTouched:_p];
[self hide];
}
- (void)dropEquipmentTouched
{
playButtonSound();
[_delegate dropEquipmentTouched:_p];
[self hide];
}
- (void)dropActionBarTouched
{
playButtonSound();
[_delegate dropActionBarTouched:_p];
[self hide];
}
- (void)buyTouched
{
playButtonSound();
[_delegate buyTouched:_p];
[self hide];
}
- (void)sellInventoryTouched
{
playButtonSound();
[_delegate sellInventoryTouched:_p];
[self hide];
}
- (void)sellEquipmentTouched
{
playButtonSound();
[_delegate sellEquipmentTouched:_p];
[self hide];
}
- (void)sellActionBarTouched
{
playButtonSound();
[_delegate sellActionBarTouched:_p];
[self hide];
}
- (void)groundUpTouched
{
playButtonSound();
[_delegate groundUpTouched];
[self hide];
}
- (void)groundDownTouched
{
playButtonSound();
[_delegate groundDownTouched];
[self hide];
}
- (void)moveNorth
{
CGFloat offset = ((_size * _scale) / 2) + _south.contentSize.height;
_callout0.anchorPoint = ccp(0.5f, 0.0f);
_callout0.position = ccp(_callout0.position.x, _callout0.position.y + offset);
}
- (void)moveSouth
{
CGFloat offset = ((_size * _scale) / 2) + _north.contentSize.height;
_callout0.anchorPoint = ccp(0.5f, 1.0f);
_callout0.position = ccp(_callout0.position.x, _callout0.position.y - offset);
}
- (void)moveWest
{
CGFloat offset = ((_size * _scale) / 2) + _east.contentSize.width;
_callout0.anchorPoint = ccp(1.0f, 0.5f);
_callout0.position = ccp(_callout0.position.x - offset, _callout0.position.y);
}
- (void)moveEast
{
CGFloat offset = ((_size * _scale) / 2) + _west.contentSize.width;
_callout0.anchorPoint = ccp(0.0f, 0.5f);
_callout0.position = ccp(_callout0.position.x + offset, _callout0.position.y);
}
- (void)moveSouthWest
{
CGFloat offset = ((_size * _scale) / 2) + _north.contentSize.width;
_callout0.anchorPoint = ccp(1.0f, 1.0f);
_callout0.position = ccp(_callout0.position.x - offset, _callout0.position.y - offset);
}
- (void)moveNorthWest
{
CGFloat offset = ((_size * _scale) / 2) + _south.contentSize.width;
_callout0.anchorPoint = ccp(1.0f, 0.0f);
_callout0.position = ccp(_callout0.position.x - offset, _callout0.position.y + offset);
}
- (void)moveNorthEast
{
CGFloat offset = ((_size * _scale) / 2) + _east.contentSize.width;
_callout0.anchorPoint = ccp(0.0f, 0.0f);
_callout0.position = ccp(_callout0.position.x + offset, _callout0.position.y + offset);
}
- (void)moveSouthEast
{
CGFloat offset = ((_size * _scale) / 2) + _west.contentSize.width;
_callout0.anchorPoint = ccp(0.0f, 1.0f);
_callout0.position = ccp(_callout0.position.x + offset, _callout0.position.y - offset);
}
- (BOOL)roomNorth
{
CGSize size = [[CCDirector sharedDirector] winSize];
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + offset;
CGFloat offsetY = _callout0.contentSize.height + _south.contentSize.height + offset;
if ((_callout0.position.x + (offsetX / 2)) > size.width) return NO;
if ((_callout0.position.x - (offsetX / 2)) < 0.0f) return NO;
if ((_callout0.position.y + offsetY) > size.height) return NO;
// if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)roomSouth
{
CGSize size = [[CCDirector sharedDirector] winSize];
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + offset;
CGFloat offsetY = _callout0.contentSize.height + _north.contentSize.height + offset;
if ((_callout0.position.x + (offsetX / 2)) > size.width) return NO;
if ((_callout0.position.x - (offsetX / 2)) < 0.0f) return NO;
// if ((_callout0.position.y + offsetY) > size.height) return NO;
if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)roomEast
{
CGSize size = [[CCDirector sharedDirector] winSize];
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + _west.contentSize.width + offset;
CGFloat offsetY = _callout0.contentSize.height + offset;
if ((_callout0.position.x + offsetX) > size.width) return NO;
// if ((_callout0.position.x - offsetX) < 0.0f) return NO;
if ((_callout0.position.y + (offsetY / 2)) > size.height) return NO;
if ((_callout0.position.y - (offsetY / 2)) < 0.0f) return NO;
return YES;
}
- (BOOL)roomWest
{
CGSize size = [[CCDirector sharedDirector] winSize];
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + _east.contentSize.width + offset;
CGFloat offsetY = _callout0.contentSize.height + offset;
// if ((_callout0.position.x + offsetX) > size.width) return NO;
if ((_callout0.position.x - offsetX) < 0.0f) return NO;
if ((_callout0.position.y + (offsetY / 2)) > size.height) return NO;
if ((_callout0.position.y - (offsetY / 2)) < 0.0f) return NO;
return YES;
}
static const CGFloat diagonalArrow = 15;
- (BOOL)roomSouthWest
{
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + diagonalArrow + offset;
CGFloat offsetY = _callout0.contentSize.height + diagonalArrow + offset;
// if ((_callout0.position.x + offsetX) > size.width) return NO;
if ((_callout0.position.x - offsetX) < 0.0f) return NO;
// if ((_callout0.position.y + offsetY) > size.height) return NO;
if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)roomNorthWest
{
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + diagonalArrow + offset;
CGFloat offsetY = _callout0.contentSize.height + diagonalArrow + offset;
CGSize size = [[CCDirector sharedDirector] winSize];
// if ((_callout0.position.x + offsetX) > size.width) return NO;
if ((_callout0.position.x - offsetX) < 0.0f) return NO;
if ((_callout0.position.y + offsetY) > size.height) return NO;
// if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)roomNorthEast
{
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + diagonalArrow + offset;
CGFloat offsetY = _callout0.contentSize.height + diagonalArrow + offset;
CGSize size = [[CCDirector sharedDirector] winSize];
if ((_callout0.position.x + offsetX) > size.width) return NO;
// if ((_callout0.position.x - offsetX) < 0.0f) return NO;
if ((_callout0.position.y + offsetY) > size.height) return NO;
// if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)roomSouthEast
{
CGFloat offset = (_size * _scale) / 2;
CGFloat offsetX = _callout0.contentSize.width + diagonalArrow + offset;
CGFloat offsetY = _callout0.contentSize.height + diagonalArrow + offset;
CGSize size = [[CCDirector sharedDirector] winSize];
if ((_callout0.position.x + offsetX) > size.width) return NO;
// if ((_callout0.position.x - offsetX) < 0.0f) return NO;
// if ((_callout0.position.y + offsetY) > size.height) return NO;
if ((_callout0.position.y - offsetY) < 0.0f) return NO;
return YES;
}
- (BOOL)tryNorth
{
BOOL found = NO;
if ([self roomNorth])
{
[self moveNorth];
_south.visible = YES;
found = YES;
}
return found;
}
- (BOOL)trySouth
{
BOOL found = NO;
if ([self roomSouth])
{
[self moveSouth];
_north.visible = YES;
found = YES;
}
return found;
}
- (BOOL)tryEast
{
BOOL found = NO;
if ([self roomEast])
{
[self moveEast];
_west.visible = YES;
found = YES;
}
return found;
}
- (BOOL)tryWest
{
BOOL found = NO;
if ([self roomWest])
{
[self moveWest];
_east.visible = YES;
found = YES;
}
return found;
}
- (BOOL)trySouthWest
{
BOOL found = NO;
if ([self roomSouthWest])
{
[self moveSouthWest];
_northEast.visible = YES;
found = YES;
}
return found;
}
- (BOOL)tryNorthWest
{
BOOL found = NO;
if ([self roomNorthWest])
{
[self moveNorthWest];
_southEast.visible = YES;
found = YES;
}
return found;
}
- (BOOL)tryNorthEast
{
BOOL found = NO;
if ([self roomNorthEast])
{
[self moveNorthEast];
_southWest.visible = YES;
found = YES;
}
return found;
}
- (BOOL)trySouthEast
{
BOOL found = NO;
if ([self roomSouthEast])
{
[self moveSouthEast];
_northWest.visible = YES;
found = YES;
}
return found;
}
- (void)layout
{
_north.visible = NO;
_south.visible = NO;
_east.visible = NO;
_west.visible = NO;
_northEast.visible = NO;
_northWest.visible = NO;
_southEast.visible = NO;
_southWest.visible = NO;
CGPoint characterPosition = [[[GameLayer gameLayer] gamePlayLayer] getCharacterPosition];
characterPosition = [self convertToNodeSpace:characterPosition];
CGPoint difference = ccpSub(_p, characterPosition);
if ((difference.x == 0.0f) && (difference.y == 0.0f))
{
if (![self tryNorth])
if (![self trySouth])
if (![self tryEast])
if (![self tryWest])
NSAssert(NO, @"Not Found!?");
}
if ((difference.x == 0.0f) && (difference.y > 0.0f)) //n
{
if (![self tryNorth])
if (![self trySouth])
if (![self tryEast])
if (![self tryWest])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x > 0.0f) && (difference.y > 0.0f)) //ne
{
if (![self tryNorth])
if (![self trySouth])
if (![self tryEast])
if (![self tryWest])
if (![self trySouthWest])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x > 0.0f) && (difference.y == 0.0f)) //e
{
if (![self tryNorth])
if (![self trySouth])
if (![self tryEast])
if (![self tryWest])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x > 0.0f) && (difference.y < 0.0f)) //se
{
if (![self trySouth])
if (![self tryNorth])
if (![self tryEast])
if (![self tryWest])
if (![self tryNorthWest])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x == 0.0f) && (difference.y < 0.0f)) //s
{
if (![self trySouth])
if (![self tryNorth])
if (![self tryWest])
if (![self tryEast])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x < 0.0f) && (difference.y < 0.0f)) //sw
{
if (![self trySouth])
if (![self tryNorth])
if (![self tryWest])
if (![self tryEast])
if (![self tryNorthEast])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x < 0.0f) && (difference.y == 0.0f)) //w
{
if (![self trySouth])
if (![self tryNorth])
if (![self tryWest])
if (![self tryEast])
NSAssert(NO, @"Not Found!?");
}
else if ((difference.x < 0.0f) && (difference.y > 0.0f)) //nw
{
if (![self tryNorth])
if (![self trySouth])
if (![self tryWest])
if (![self tryEast])
if (![self trySouthEast])
NSAssert(NO, @"Not Found!?");
}
CGFloat offset = 4.0f;
_north.position = ccp(_callout0.contentSize.width / 2, _callout0.contentSize.height - offset);
_south.position = ccp(_callout0.contentSize.width / 2, 0.0f + offset);
_east.position = ccp(_callout0.contentSize.width - offset, _callout0.contentSize.height / 2);
_west.position = ccp(0.0f + offset, _callout0.contentSize.height / 2);
CGFloat offset2 = offset + 15.0f;
_northEast.position = ccp(_callout0.contentSize.width - offset2, _callout0.contentSize.height - offset2);
_northWest.position = ccp(offset2, _callout0.contentSize.height - offset2);
_southEast.position = ccp(_callout0.contentSize.width - offset2, offset2);
_southWest.position = ccp(offset2, offset2);
}
- (void)showAt:(CGPoint)point type:(CalloutType)type size:(NSUInteger)size scale:(CGFloat)scale color:(ccColor3B)color sprite:(CCSprite *)sprite
text0:(NSString *)text0 text0color:(ccColor3B)text0color
text1:(NSString *)text1 text1color:(ccColor3B)text1color
text2:(NSString *)text2 text2color:(ccColor3B)text2color
elite:(BOOL)elite usable:(BOOL)usable equipable:(BOOL)equipable
{
BOOL both = usable && equipable;
BOOL either = usable || equipable;
CCSprite *look0 = [CCSprite spriteWithTexture:sprite.texture rect:sprite.textureRect];
CCSprite *look1 = [CCSprite spriteWithTexture:sprite.texture rect:sprite.textureRect];
tintForever(look1, colorDekoYellowLight, ccWHITE);
_menuLook = [CCMenuItemImage itemWithNormalSprite:look0 selectedSprite:look1 target:self selector:@selector(lookTouched)];
_menuLook.scale = normalScale;
look1.scale = selectedScale;
look1.anchorPoint = ccp(0.5f, 0.5f);
look1.position = ccp(look1.contentSize.width / 2, look1.contentSize.height / 2);
CCSprite *walk0 = [CCSprite spriteWithSpriteFrameName:atlasMove];
CCSprite *walk1 = [CCSprite spriteWithSpriteFrameName:atlasMove];
tintForever(walk1, colorDekoYellowLight, colorButtonBlue);
_menuWalk = [CCMenuItemImage itemWithNormalSprite:walk0 selectedSprite:walk1 target:self selector:@selector(walkTouched)];
_menuWalk.scale = normalScale;
_menuWalk.color = colorButtonBlue;
walk1.scale = selectedScale;
walk1.anchorPoint = ccp(0.5f, 0.5f);
walk1.position = ccp(walk1.contentSize.width / 2, walk1.contentSize.height / 2);
CCSprite *use0 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
CCSprite *use1 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
tintForever(use1, colorDekoYellowLight, colorButtonBlue);
_menuUse = [CCMenuItemImage itemWithNormalSprite:use0 selectedSprite:use1 target:self selector:@selector(useTouched)];
_menuUse.scale = normalScale;
_menuUse.color = colorButtonBlue;
use1.scale = selectedScale;
use1.anchorPoint = ccp(0.5f, 0.5f);
use1.position = ccp(use1.contentSize.width / 2, use1.contentSize.width / 2);
CCSprite *attack0 = [CCSprite spriteWithSpriteFrameName:atlasAttack];
CCSprite *attack1 = [CCSprite spriteWithSpriteFrameName:atlasAttack];
tintForever(attack1, colorDekoYellowLight, colorButtonBlue);
_menuAttack = [CCMenuItemImage itemWithNormalSprite:attack0 selectedSprite:attack1 target:self selector:@selector(attackTouched)];
_menuAttack.scale = normalScale;
_menuAttack.color = colorButtonBlue;
attack1.scale = selectedScale;
attack1.anchorPoint = ccp(0.5f, 0.5f);
attack1.position = ccp(attack1.contentSize.width / 2, attack1.contentSize.height / 2);
CCSprite *menu0 = [CCSprite spriteWithSpriteFrameName:atlasBag];
CCSprite *menu1 = [CCSprite spriteWithSpriteFrameName:atlasBag];
tintForever(menu1, colorDekoYellowLight, colorButtonBlue);
_menuMenu = [CCMenuItemImage itemWithNormalSprite:menu0 selectedSprite:menu1 target:self selector:@selector(menuTouched)];
_menuMenu.scale = normalScale;
_menuMenu.color = colorButtonBlue;
menu1.scale = selectedScale;
menu1.anchorPoint = ccp(0.5f, 0.5f);
menu1.position = ccp(menu1.contentSize.width / 2, menu1.contentSize.height / 2);
CCSprite *pass0 = [CCSprite spriteWithSpriteFrameName:atlasSkip];
CCSprite *pass1 = [CCSprite spriteWithSpriteFrameName:atlasSkip];
tintForever(pass1, colorDekoYellowLight, colorButtonBlue);
_menuPass = [CCMenuItemImage itemWithNormalSprite:pass0 selectedSprite:pass1 target:self selector:@selector(passTouched)];
_menuPass.scale = normalScale;
_menuPass.color = colorButtonBlue;
pass1.scale = selectedScale;
pass1.anchorPoint = ccp(0.5f, 0.5f);
pass1.position = ccp(pass1.contentSize.width / 2, pass1.contentSize.height / 2);
CCSprite *pickup0 = [CCSprite spriteWithSpriteFrameName:atlasPickup];
CCSprite *pickup1 = [CCSprite spriteWithSpriteFrameName:atlasPickup];
tintForever(pickup1, colorDekoYellowLight, colorButtonBlue);
_menuPickup = [CCMenuItemImage itemWithNormalSprite:pickup0 selectedSprite:pickup1 target:self selector:@selector(pickupTouched)];
_menuPickup.scale = normalScale;
_menuPickup.color = colorButtonBlue;
pickup1.scale = selectedScale;
pickup1.anchorPoint = ccp(0.5f, 0.5f);
pickup1.position = ccp(pickup1.contentSize.width / 2, pickup1.contentSize.height / 2);
CCSprite *throwInventory0 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
CCSprite *throwInventory1 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
tintForever(throwInventory1, colorDekoYellowLight, colorButtonBlue);
_menuThrowInventory = [CCMenuItemImage itemWithNormalSprite:throwInventory0 selectedSprite:throwInventory1 target:self selector:@selector(throwInventoryTouched)];
_menuThrowInventory.scale = normalScale;
_menuThrowInventory.color = colorButtonBlue;
throwInventory1.scale = selectedScale;
throwInventory1.anchorPoint = ccp(0.5f, 0.5f);
throwInventory1.position = ccp(throwInventory1.contentSize.width / 2, throwInventory1.contentSize.width / 2);
CCSprite *throwEquipment0 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
CCSprite *throwEquipment1 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
tintForever(throwEquipment1, colorDekoYellowLight, colorButtonBlue);
_menuThrowEquipment = [CCMenuItemImage itemWithNormalSprite:throwEquipment0 selectedSprite:throwEquipment1 target:self selector:@selector(throwEquipmentTouched)];
_menuThrowEquipment.scale = normalScale;
_menuThrowEquipment.color = colorButtonBlue;
throwEquipment1.scale = selectedScale;
throwEquipment1.anchorPoint = ccp(0.5f, 0.5f);
throwEquipment1.position = ccp(throwEquipment1.contentSize.width / 2, throwEquipment1.contentSize.width / 2);
CCSprite *throwActionBar0 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
CCSprite *throwActionBar1 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
tintForever(throwActionBar1, colorDekoYellowLight, colorButtonBlue);
_menuThrowActionBar = [CCMenuItemImage itemWithNormalSprite:throwActionBar0 selectedSprite:throwActionBar1 target:self selector:@selector(throwActionBarTouched)];
_menuThrowActionBar.scale = normalScale;
_menuThrowActionBar.color = colorButtonBlue;
throwActionBar1.scale = selectedScale;
throwActionBar1.anchorPoint = ccp(0.5f, 0.5f);
throwActionBar1.position = ccp(throwActionBar1.contentSize.width / 2, throwActionBar1.contentSize.width / 2);
CCSprite *throwPickup0 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
CCSprite *throwPickup1 = [CCSprite spriteWithSpriteFrameName:atlasThrow];
tintForever(throwPickup1, colorDekoYellowLight, colorButtonBlue);
_menuThrowPickup = [CCMenuItemImage itemWithNormalSprite:throwPickup0 selectedSprite:throwPickup1 target:self selector:@selector(throwPickupTouched)];
_menuThrowPickup.scale = normalScale;
_menuThrowPickup.color = colorButtonBlue;
throwPickup1.scale = selectedScale;
throwPickup1.anchorPoint = ccp(0.5f, 0.5f);
throwPickup1.position = ccp(throwPickup1.contentSize.width / 2, throwPickup1.contentSize.height / 2);
CCSprite *dropInventory0 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
CCSprite *dropInventory1 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
tintForever(dropInventory1, colorDekoYellowLight, colorButtonBlue);
_menuDropInventory = [CCMenuItemImage itemWithNormalSprite:dropInventory0 selectedSprite:dropInventory1 target:self selector:@selector(dropInventoryTouched)];
_menuDropInventory.scale = normalScale;
_menuDropInventory.color = colorButtonBlue;
dropInventory1.scale = selectedScale;
dropInventory1.anchorPoint = ccp(0.5f, 0.5f);
dropInventory1.position = ccp(dropInventory1.contentSize.width / 2, dropInventory1.contentSize.height / 2);
CCSprite *dropEquipment0 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
CCSprite *dropEquipment1 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
tintForever(dropEquipment1, colorDekoYellowLight, colorButtonBlue);
_menuDropEquipment = [CCMenuItemImage itemWithNormalSprite:dropEquipment0 selectedSprite:dropEquipment1 target:self selector:@selector(dropEquipmentTouched)];
_menuDropEquipment.scale = normalScale;
_menuDropEquipment.color = colorButtonBlue;
dropEquipment1.scale = selectedScale;
dropEquipment1.anchorPoint = ccp(0.5f, 0.5f);
dropEquipment1.position = ccp(dropEquipment1.contentSize.width / 2, dropEquipment1.contentSize.height / 2);
CCSprite *dropActionBar0 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
CCSprite *dropActionBar1 = [CCSprite spriteWithSpriteFrameName:atlasDrop];
tintForever(dropActionBar1, colorDekoYellowLight, colorButtonBlue);
_menuDropActionBar = [CCMenuItemImage itemWithNormalSprite:dropActionBar0 selectedSprite:dropActionBar1 target:self selector:@selector(dropActionBarTouched)];
_menuDropActionBar.scale = normalScale;
_menuDropActionBar.color = colorButtonBlue;
dropActionBar1.scale = selectedScale;
dropActionBar1.anchorPoint = ccp(0.5f, 0.5f);
dropActionBar1.position = ccp(dropActionBar1.contentSize.width / 2, dropActionBar1.contentSize.height / 2);
CCSprite *buy0 = [CCSprite spriteWithSpriteFrameName:atlasBuy];
CCSprite *buy1 = [CCSprite spriteWithSpriteFrameName:atlasBuy];
tintForever(buy1, colorDekoYellowLight, colorButtonBlue);
_menuBuy = [CCMenuItemImage itemWithNormalSprite:buy0 selectedSprite:buy1 target:self selector:@selector(buyTouched)];
_menuBuy.scale = normalScale;
_menuBuy.color = colorButtonBlue;
buy1.scale = selectedScale;
buy1.anchorPoint = ccp(0.5f, 0.5f);
buy1.position = ccp(buy1.contentSize.width / 2, buy1.contentSize.height / 2);
CCSprite *sellInventory0 = [CCSprite spriteWithSpriteFrameName:atlasSell];
CCSprite *sellInventory1 = [CCSprite spriteWithSpriteFrameName:atlasSell];
tintForever(sellInventory1, colorDekoYellowLight, colorButtonBlue);
_menuSellInventory = [CCMenuItemImage itemWithNormalSprite:sellInventory0 selectedSprite:sellInventory1 target:self selector:@selector(sellInventoryTouched)];
_menuSellInventory.scale = normalScale;
_menuSellInventory.color = colorButtonBlue;
sellInventory1.scale = selectedScale;
sellInventory1.anchorPoint = ccp(0.5f, 0.5f);
sellInventory1.position = ccp(sellInventory1.contentSize.width / 2, sellInventory1.contentSize.height / 2);
CCSprite *sellEquipment0 = [CCSprite spriteWithSpriteFrameName:atlasSell];
CCSprite *sellEquipment1 = [CCSprite spriteWithSpriteFrameName:atlasSell];
tintForever(sellEquipment1, colorDekoYellowLight, colorButtonBlue);
_menuSellEquipment = [CCMenuItemImage itemWithNormalSprite:sellEquipment0 selectedSprite:sellEquipment1 target:self selector:@selector(sellEquipmentTouched)];
_menuSellEquipment.scale = normalScale;
_menuSellEquipment.color = colorButtonBlue;
sellEquipment1.scale = selectedScale;
sellEquipment1.anchorPoint = ccp(0.5f, 0.5f);
sellEquipment1.position = ccp(sellEquipment1.contentSize.width / 2, sellEquipment1.contentSize.height / 2);
CCSprite *sellActionBar0 = [CCSprite spriteWithSpriteFrameName:atlasSell];
CCSprite *sellActionBar1 = [CCSprite spriteWithSpriteFrameName:atlasSell];
tintForever(sellActionBar1, colorDekoYellowLight, colorButtonBlue);
_menuSellActionBar = [CCMenuItemImage itemWithNormalSprite:sellActionBar0 selectedSprite:sellActionBar1 target:self selector:@selector(sellActionBarTouched)];
_menuSellActionBar.scale = normalScale;
_menuSellActionBar.color = colorButtonBlue;
sellActionBar1.scale = selectedScale;
sellActionBar1.anchorPoint = ccp(0.5f, 0.5f);
sellActionBar1.position = ccp(sellActionBar1.contentSize.width / 2, sellActionBar1.contentSize.height / 2);
CCSprite *useInventory0 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
CCSprite *useInventory1 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
tintForever(useInventory1, colorDekoYellowLight, colorButtonBlue);
_menuUseInventory = [CCMenuItemImage itemWithNormalSprite:useInventory0 selectedSprite:useInventory1 target:self selector:@selector(useInventoryTouched)];
_menuUseInventory.scale = normalScale;
_menuUseInventory.color = colorButtonBlue;
useInventory1.scale = selectedScale;
useInventory1.anchorPoint = ccp(0.5f, 0.5f);
useInventory1.position = ccp(useInventory1.contentSize.width / 2, useInventory1.contentSize.width / 2);
CCSprite *useEquipment0 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
CCSprite *useEquipment1 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
tintForever(useEquipment1, colorDekoYellowLight, colorButtonBlue);
_menuUseEquipment = [CCMenuItemImage itemWithNormalSprite:useEquipment0 selectedSprite:useEquipment1 target:self selector:@selector(useEquipmentTouched)];
_menuUseEquipment.scale = normalScale;
_menuUseEquipment.color = colorButtonBlue;
useEquipment1.scale = selectedScale;
useEquipment1.anchorPoint = ccp(0.5f, 0.5f);
useEquipment1.position = ccp(useEquipment1.contentSize.width / 2, useEquipment1.contentSize.width / 2);
CCSprite *useActionBar0 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
CCSprite *useActionBar1 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
tintForever(useActionBar1, colorDekoYellowLight, colorButtonBlue);
_menuUseActionBar = [CCMenuItemImage itemWithNormalSprite:useActionBar0 selectedSprite:useActionBar1 target:self selector:@selector(useActionBarTouched)];
_menuUseActionBar.scale = normalScale;
_menuUseActionBar.color = colorButtonBlue;
useActionBar1.scale = selectedScale;
useActionBar1.anchorPoint = ccp(0.5f, 0.5f);
useActionBar1.position = ccp(useActionBar1.contentSize.width / 2, useActionBar1.contentSize.width / 2);
CCSprite *usePickup0 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
CCSprite *usePickup1 = [CCSprite spriteWithSpriteFrameName:atlasWrench];
tintForever(usePickup1, colorDekoYellowLight, colorButtonBlue);
_menuUsePickup = [CCMenuItemImage itemWithNormalSprite:usePickup0 selectedSprite:usePickup1 target:self selector:@selector(usePickupTouched)];
_menuUsePickup.scale = normalScale;
_menuUsePickup.color = colorButtonBlue;
usePickup1.scale = selectedScale;
usePickup1.anchorPoint = ccp(0.5f, 0.5f);
usePickup1.position = ccp(usePickup1.contentSize.width / 2, usePickup1.contentSize.width / 2);
CCSprite *equipInventory0 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
CCSprite *equipInventory1 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
tintForever(equipInventory1, colorDekoYellowLight, colorButtonBlue);
_menuEquipInventory = [CCMenuItemImage itemWithNormalSprite:equipInventory0 selectedSprite:equipInventory1 target:self selector:@selector(equipInventoryTouched)];
_menuEquipInventory.scale = normalScale;
_menuEquipInventory.color = colorButtonBlue;
equipInventory1.scale = selectedScale;
equipInventory1.anchorPoint = ccp(0.5f, 0.5f);
equipInventory1.position = ccp(equipInventory1.contentSize.width / 2, equipInventory1.contentSize.width / 2);
CCSprite *equipEquipment0 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
CCSprite *equipEquipment1 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
tintForever(equipEquipment1, colorDekoYellowLight, colorButtonBlue);
_menuEquipEquipment = [CCMenuItemImage itemWithNormalSprite:equipEquipment0 selectedSprite:equipEquipment1 target:self selector:@selector(equipEquipmentTouched)];
_menuEquipEquipment.scale = normalScale;
_menuEquipEquipment.color = colorButtonBlue;
equipEquipment1.scale = selectedScale;
equipEquipment1.anchorPoint = ccp(0.5f, 0.5f);
equipEquipment1.position = ccp(equipEquipment1.contentSize.width / 2, equipEquipment1.contentSize.width / 2);
CCSprite *equipActionBar0 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
CCSprite *equipActionBar1 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
tintForever(equipActionBar1, colorDekoYellowLight, colorButtonBlue);
_menuEquipActionBar = [CCMenuItemImage itemWithNormalSprite:equipActionBar0 selectedSprite:equipActionBar1 target:self selector:@selector(equipActionBarTouched)];
_menuEquipActionBar.scale = normalScale;
_menuEquipActionBar.color = colorButtonBlue;
equipActionBar1.scale = selectedScale;
equipActionBar1.anchorPoint = ccp(0.5f, 0.5f);
equipActionBar1.position = ccp(equipActionBar1.contentSize.width / 2, equipActionBar1.contentSize.width / 2);
CCSprite *equipPickup0 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
CCSprite *equipPickup1 = [CCSprite spriteWithSpriteFrameName:atlasEquip];
tintForever(equipPickup1, colorDekoYellowLight, colorButtonBlue);
_menuEquipPickup = [CCMenuItemImage itemWithNormalSprite:equipPickup0 selectedSprite:equipPickup1 target:self selector:@selector(equipPickupTouched)];
_menuEquipPickup.scale = normalScale;
_menuEquipPickup.color = colorButtonBlue;
equipPickup1.scale = selectedScale;
equipPickup1.anchorPoint = ccp(0.5f, 0.5f);
equipPickup1.position = ccp(equipPickup1.contentSize.width / 2, equipPickup1.contentSize.width / 2);
CCSprite *groundUp0 = [CCSprite spriteWithSpriteFrameName:atlasArrowUp];
CCSprite *groundUp1 = [CCSprite spriteWithSpriteFrameName:atlasArrowUp];
tintForever(groundUp1, colorDekoYellowLight, colorButtonBlue);
_menuGroundUp = [CCMenuItemImage itemWithNormalSprite:groundUp0 selectedSprite:groundUp1 target:self selector:@selector(groundUpTouched)];
_menuGroundUp.scale = normalScale;
_menuGroundUp.color = colorButtonBlue;
groundUp1.scale = selectedScale;
groundUp1.anchorPoint = ccp(0.5f, 0.5f);
groundUp1.position = ccp(groundUp1.contentSize.width / 2, groundUp1.contentSize.width / 2);
CCSprite *groundDown0 = [CCSprite spriteWithSpriteFrameName:atlasArrowDown];
CCSprite *groundDown1 = [CCSprite spriteWithSpriteFrameName:atlasArrowDown];
tintForever(groundDown1, colorDekoYellowLight, colorButtonBlue);
_menuGroundDown = [CCMenuItemImage itemWithNormalSprite:groundDown0 selectedSprite:groundDown1 target:self selector:@selector(groundDownTouched)];
_menuGroundDown.scale = normalScale;
_menuGroundDown.color = colorButtonBlue;
groundDown1.scale = selectedScale;
groundDown1.anchorPoint = ccp(0.5f, 0.5f);
groundDown1.position = ccp(groundDown1.contentSize.width / 2, groundDown1.contentSize.width / 2);
_callout0.color = color;
_callout1.color = color;
_north.color = color;
_south.color = color;
_east.color = color;
_west.color = color;
_northEast.color = color;
_northWest.color = color;
_southEast.color = color;
_southWest.color = color;
_p = point;
_size = size;
_scale = scale;
_callout0.position = _p;
NSUInteger offset = frameCap0 * 3;
NSUInteger height = offset;
// NSUInteger width = offset;
NSUInteger padding = 2;
CGFloat lookHeight = _menuLook.contentSize.height * normalScale;
CGFloat lookWidth = _menuLook.contentSize.width * normalScale;
CGFloat walkHeight = _menuWalk.contentSize.height * normalScale;
// CGFloat walkWidth = _menuWalk.contentSize.width * normalScale;
CGFloat useHeight = _menuUse.contentSize.height * normalScale;
// CGFloat useWidth = _menuUse.contentSize.width * normalScale;
CGFloat attackHeight = _menuAttack.contentSize.height * normalScale;
// CGFloat attackWidth = _menuAttack.contentSize.width * normalScale;
CGFloat menuHeight = _menuMenu.contentSize.height * normalScale;
// CGFloat menuWidth = _menuMenu.contentSize.width * normalScale;
CGFloat pickupHeight = _menuPickup.contentSize.height * normalScale;
CGFloat throwHeight = _menuThrowPickup.contentSize.height * normalScale;
CGFloat dropHeight = _menuDropInventory.contentSize.height * normalScale;
CGFloat buyHeight = _menuBuy.contentSize.height * normalScale;
CGFloat sellHeight = _menuSellInventory.contentSize.height * normalScale;
CGFloat groundUpHeight = _menuGroundUp.contentSize.height * normalScale;
CGFloat groundDownHeight = _menuGroundDown.contentSize.height * normalScale;
CGFloat equipHeight = _menuEquipPickup.contentSize.height * normalScale;
[_menu removeAllChildrenWithCleanup:YES];
[_menu removeFromParentAndCleanup:YES];
switch (type)
{
case CalloutNothing:
_menu = [CCMenu menuWithItems:_menuGroundUp, _menuWalk, _menuLook, nil];
height += groundUpHeight + lookHeight + walkHeight + padding;
break;
case CalloutWall:
_menu = [CCMenu menuWithItems:_menuGroundDown, _menuWalk, _menuLook, nil];
height += groundDownHeight + lookHeight + walkHeight + padding;
break;
case CalloutFloor:
_menu = [CCMenu menuWithItems:_menuGroundUp, _menuGroundDown, _menuWalk, _menuLook, nil];
height += groundUpHeight + groundDownHeight + lookHeight + walkHeight + padding;
break;
case CalloutDoorOpen:
_menu = [CCMenu menuWithItems:_menuWalk, _menuUse, _menuLook, nil];
height += lookHeight + walkHeight + useHeight + (padding * 2);
break;
case CalloutSign:
case CalloutDoorShut:
_menu = [CCMenu menuWithItems:_menuUse, _menuWalk, _menuLook, nil];
height += lookHeight + walkHeight + useHeight + (padding * 2);
break;
case CalloutStairsUp:
_menu = [CCMenu menuWithItems:_menuWalk, _menuUse, _menuLook, nil];
height += lookHeight + walkHeight + useHeight + (padding * 2);
break;
case CalloutStairsDown:
_menu = [CCMenu menuWithItems:_menuWalk, _menuUse, _menuLook, nil];
height += lookHeight + walkHeight + useHeight + (padding * 2);
break;
case CalloutChest:
_menu = [CCMenu menuWithItems:_menuWalk, _menuUse, _menuLook, nil];
height += lookHeight + walkHeight + useHeight + (padding * 2);
break;
case CalloutMob:
case CalloutMobFriendly:
_menu = [CCMenu menuWithItems:_menuAttack, _menuWalk, _menuLook, nil];
height += lookHeight + walkHeight + attackHeight + (padding * 2);
break;
case CalloutMenu:
_menu = [CCMenu menuWithItems:_menuMenu, _menuPass, _menuLook, nil];
height += lookHeight + menuHeight + menuHeight + (padding * 2);
break;
case CalloutMenuUse:
_menu = [CCMenu menuWithItems:_menuMenu, _menuUse, _menuPass, _menuLook, nil];
height += lookHeight + menuHeight + useHeight + walkHeight + (padding * 3);
break;
case CalloutPickup:
if (both)
{
_menu = [CCMenu menuWithItems:_menuPickup, _menuThrowPickup, _menuUsePickup, _menuEquipPickup, _menuLook, nil];
height += pickupHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuPickup, _menuThrowPickup, (usable ? _menuUsePickup : _menuEquipPickup), _menuLook, nil];
height += pickupHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuPickup, _menuThrowPickup, _menuLook, nil];
height += pickupHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutInventory:
if (both)
{
_menu = [CCMenu menuWithItems:_menuDropInventory, _menuThrowInventory, _menuUseInventory, _menuEquipInventory, _menuLook, nil];
height += dropHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuDropInventory, _menuThrowInventory, (usable ? _menuUseInventory : _menuEquipInventory), _menuLook, nil];
height += dropHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuDropInventory, _menuThrowInventory, _menuLook, nil];
height += dropHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutEquipment:
if (both)
{
_menu = [CCMenu menuWithItems:_menuDropEquipment, _menuThrowEquipment, _menuUseEquipment, _menuEquipEquipment, _menuLook, nil];
height += dropHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuDropEquipment, _menuThrowEquipment, (usable ? _menuUseEquipment : _menuEquipEquipment), _menuLook, nil];
height += dropHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuDropEquipment, _menuThrowEquipment, _menuLook, nil];
height += dropHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutActionBar:
if (both)
{
_menu = [CCMenu menuWithItems:_menuDropActionBar, _menuThrowActionBar, _menuUseActionBar, _menuEquipActionBar, _menuLook, nil];
height += dropHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuDropActionBar, _menuThrowActionBar, (usable ? _menuUseActionBar : _menuEquipActionBar), _menuLook, nil];
height += dropHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuDropActionBar, _menuThrowActionBar, _menuLook, nil];
height += dropHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutBuy:
_menu = [CCMenu menuWithItems:_menuBuy, _menuLook, nil]; // todo: add equip and use with buy confirm!?
height += buyHeight + lookHeight + (padding * 2);
break;
case CalloutSellInventory:
if (both)
{
_menu = [CCMenu menuWithItems:_menuSellInventory, _menuThrowInventory, _menuUseInventory, _menuEquipInventory, _menuLook, nil];
height += sellHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuSellInventory, _menuThrowInventory, (usable ? _menuUseInventory : _menuEquipInventory), _menuLook, nil];
height += sellHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuSellInventory, _menuThrowInventory, _menuLook, nil];
height += sellHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutSellEquipment:
if (both)
{
_menu = [CCMenu menuWithItems:_menuSellEquipment, _menuThrowEquipment, _menuUseEquipment, _menuEquipEquipment, _menuLook, nil];
height += sellHeight + useHeight + equipHeight + throwHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuSellEquipment, _menuThrowEquipment, (usable ? _menuUseEquipment : _menuEquipEquipment), _menuLook, nil];
height += sellHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuSellEquipment, _menuThrowEquipment, _menuLook, nil];
height += sellHeight + throwHeight + lookHeight + (padding * 2);
}
break;
case CalloutSellActionBar:
if (both)
{
_menu = [CCMenu menuWithItems:_menuSellActionBar, _menuThrowActionBar, _menuUseActionBar, _menuEquipActionBar, _menuLook, nil];
height += sellHeight + throwHeight + useHeight + equipHeight + lookHeight + (padding * 2);
}
else if (either)
{
_menu = [CCMenu menuWithItems:_menuSellActionBar, _menuThrowActionBar, (usable ? _menuUseActionBar : _menuEquipActionBar), _menuLook, nil];
height += sellHeight + throwHeight + (usable ? useHeight : equipHeight) + lookHeight + (padding * 2);
}
else
{
_menu = [CCMenu menuWithItems:_menuSellActionBar, _menuThrowActionBar, _menuLook, nil];
height += sellHeight + throwHeight + lookHeight + (padding * 2);
}
break;
}
[_menu alignItemsVerticallyWithPadding:padding];
[_callout0 adaptiveScale9:CGSizeMake(lookWidth + offset, height)];
BOOL left = NO;
if ([CCDirector sharedDirector].screenCenter.x < point.x)
{
left = YES;
_callout1.anchorPoint = ccp(1.0f, 0.0f);
_callout1.position = ccp(_callout0.contentSize.width, 0.0f);
}
else
{
_callout1.anchorPoint = ccp(0.0f, 0.0f);
_callout1.position = CGPointZero;
}
[self layout];
CGFloat top = text1.length ? _callout0.contentSize.width / 6 * 4.5 : _callout0.contentSize.width / 2;
[_label0 removeFromParentAndCleanup:YES];
_label0 = [CCLabelBMFont labelWithString:text0 fntFile:pixelFontWhite];
if (left)
{
_label0.anchorPoint = ccp(0.0f, 0.5f);
_label0.position = ccp(frameCap0 * 2, top);
}
else
{
_label0.anchorPoint = ccp(0.0f, 0.5f);
_label0.position = ccp(_callout0.contentSize.width + frameCap0, top);
}
_label0.scale = 2.0f;
_label0.color = text0color;
[_callout1 addChild:_label0];
[_label1 removeFromParentAndCleanup:YES];
_label1 = nil;
if (text1.length)
{
_label1 = [CCLabelBMFont labelWithString:text1 fntFile:pixelFontWhite];
if (left)
{
_label1.anchorPoint = ccp(0.0f, 0.5f);
_label1.position = ccp(frameCap0 * 2, _callout0.contentSize.width / 2);
}
else
{
_label1.anchorPoint = ccp(0.0f, 0.5f);
_label1.position = ccp(_callout0.contentSize.width + frameCap0, _callout0.contentSize.width / 2);
}
_label1.scale = 2.0f;
_label1.color = text1color;
[_callout1 addChild:_label1];
}
[_label2 removeFromParentAndCleanup:YES];
_label2 = nil;
if (text2.length)
{
_label2 = [CCLabelBMFont labelWithString:text2 fntFile:pixelFontWhite];
if (left)
{
_label2.anchorPoint = ccp(0.0f, 0.5f);
_label2.position = ccp(frameCap0 * 2, _callout0.contentSize.width / 6 * 1.5);
}
else
{
_label2.anchorPoint = ccp(0.0f, 0.5f);
_label2.position = ccp(_callout0.contentSize.width + frameCap0, _callout0.contentSize.width / 6 * 1.5);
}
_label2.scale = 2.0f;
_label2.color = text2color;
[_callout1 addChild:_label2];
}
CGFloat maxLabelWidth = MAX(_label0.contentSize.width, _label1.contentSize.width);
maxLabelWidth = MAX(maxLabelWidth, _label2.contentSize.width);
[_callout1 adaptiveScale9:CGSizeMake(lookWidth + offset * 2 + maxLabelWidth * _label0.scale, lookWidth + offset)];
_menu.position = ccp(_callout0.contentSize.width / 2, _callout0.contentSize.height / 2);
[_callout0 addChild:_menu z:1];
if (elite)
{
_crown.position = ccp(_label0.position.x + (_label0.contentSize.width * _label0.scale) + ((_crown.contentSize.width * _crown.scale) / 2.0f), _label0.position.y);
_crown.visible = YES;
}
else
{
_crown.visible = NO;
}
_callout0.visible = YES;
[self lookTouched];
}
- (BOOL)visible
{
return _callout0.visible;
}
- (void)hide
{
_callout0.visible = NO;
_callout1.opacity = 0;
_look = NO;
}
- (id)init
{
KKLOG();
self = [super init];
if (self)
{
_look = NO;
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:fileGeneralPlist textureFilename:fileGeneral];
CCSpriteFrame *frame = [cache spriteFrameByName:atlasFrame2];
_callout0 = [CCSpriteScale9 spriteWithTexture:frame.texture rect:frame.rect andLeftCapWidth:frameCap0 andTopCapHeight:frameCap0];
_callout0.visible = NO;
[self addChild:_callout0];
_callout1 = [CCSpriteScale9 spriteWithTexture:frame.texture rect:frame.rect andLeftCapWidth:frameCap0 andTopCapHeight:frameCap0];
_callout1.opacity = 0;
_callout1.anchorPoint = ccp(0.0f, 0.0f);
[_callout0 addChild:_callout1];
_north = [CCSprite spriteWithSpriteFrameName:atlasCalloutNorth];
_north.anchorPoint = ccp(0.5f, 0.0f);
[_callout0 addChild:_north];
_south = [CCSprite spriteWithSpriteFrameName:atlasCalloutSouth];
_south.anchorPoint = ccp(0.5f, 1.0f);
[_callout0 addChild:_south];
_east = [CCSprite spriteWithSpriteFrameName:atlasCalloutEast];
_east.anchorPoint = ccp(0.0f, 0.5f);
[_callout0 addChild:_east];
_west = [CCSprite spriteWithSpriteFrameName:atlasCalloutWest];
_west.anchorPoint = ccp(1.0f, 0.5f);
[_callout0 addChild:_west];
_northEast = [CCSprite spriteWithSpriteFrameName:atlasCalloutNorthEast];
_northEast.anchorPoint = ccp(0.0f, 0.0f);
[_callout0 addChild:_northEast];
_northWest = [CCSprite spriteWithSpriteFrameName:atlasCalloutNorthWest];
_northWest.anchorPoint = ccp(1.0f, 0.0f);
[_callout0 addChild:_northWest];
_southEast = [CCSprite spriteWithSpriteFrameName:atlasCalloutSouthEast];
_southEast.anchorPoint = ccp(0.0f, 1.0f);
[_callout0 addChild:_southEast];
_southWest = [CCSprite spriteWithSpriteFrameName:atlasCalloutSouthWest];
_southWest.anchorPoint = ccp(1.0f, 1.0f);
[_callout0 addChild:_southWest];
_crown = [CCSprite spriteWithSpriteFrameName:atlasBarCrown];
_crown.scale = 4;
_crown.position = ccp(_label0.position.x + (_label0.contentSize.width * _label0.scale) + ((_crown.contentSize.width * _crown.scale) / 2.0f), _label0.position.y);
[_crown.texture setAliasTexParameters];
[_callout1 addChild:_crown];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment