0

I'm from Italy, and I'm creating after a while a new Cocos2D project that implements an HUD. The strange thing is that HUD used to work in my previous project, but even moving the files in the new one, nothing displays at all, just the main layer... I've tried to follow exactly Bob Ueland's tutorial (http://bobueland.com/cocos2d/2011/robin-hud/), step by step, bud nothing to do...

However these are my files, I've tried to remove stuff to make it as simple as possible, but the layer with the label "arrivederci" is always invisible...

Probably there is a stupid error that i can't see, maybe it has something to do with app delegate...

venezia.h

#import "cocos2d.h"
#import "HudLayer.h"

@interface venezia : CCLayer

{
 HudLayer *hud;
 CCSprite *sfondo2;
 CCLabelTTF *txt;  

}

@property (nonatomic, retain) HudLayer *hud;

+(CCScene *) scene;

@end

venezia.m

#import "venezia.h"

@implementation venezia
@synthesize hud;

+(CCScene *) scene
{
    CCScene *scene = [CCScene node];
    venezia *layer = [venezia node];
    [scene addChild: layer];

    //add another layer to the scene

    HudLayer *anotherLayer = [HudLayer node];
    [scene addChild: anotherLayer z:14];
    layer.hud = anotherLayer;


    return scene;
}    


- (id) init
{
    self = [super init];
    if (self != nil)
    {
        sfondo2 = [CCSprite spriteWithFile:@"sfondo.png"];
        [self addChild: sfondo2 z:1];
        sfondo2.position = ccp (240, 160);

        //TESTO        
        txt = [CCLabelTTF labelWithString:@"CIAO" dimensions: CGSizeMake(400,200) alignment: UITextAlignmentCenter fontName:@"Trebuchet MS" fontSize: 16];
        txt.position = ccp (110,110);
        [self addChild: txt z:12];
        txt.visible = YES;             
    }
    return self;
}

- (void) dealloc
{
    [super dealloc];
}
@end

HudLayer.h

#import "cocos2d.h"

@interface HudLayer : CCLayerColor

{
    CCLabelTTF *txt2;  
}

@end

HudLayer.m

#import "HudLayer.h"

@implementation HudLayer

-(id) init

{
    if( (self=[super initWithColor:ccc4(25, 225, 0, 128)])) {


        txt2 = [CCLabelTTF labelWithString:@"ARRIVEDERCI" dimensions: CGSizeMake(400,200) alignment: UITextAlignmentCenter fontName:@"Trebuchet MS" fontSize: 16];
        txt2.position = ccp (110,0);
        [self addChild: txt2 z:12];
        txt2.visible = YES;         
    }

    return self;

}


- (void) dealloc

{
     [super dealloc];
}

@end

Thank you in advance, I REALLY need this to continue with my project, it's just a section, but without this de development is stuck...

Leena
  • 2,678
  • 1
  • 30
  • 43
  • Just thinking of some cursory stuff as I'm looking at the code. Are you sure the font is bundled in the project or on the system correctly? Is the font being read and the TTF label being read correctly? Have you traced through the code to see if that's happening? – Rob Segal May 15 '14 at 18:51

1 Answers1

0

SOLVED

Very stupidly I've addressed

[[CCDirector sharedDirector] replaceScene: [venezia node]];

Instead of

[[CCDirector sharedDirector] replaceScene: [venezia scene]];

So it didn't load any other layer but the one contained in that node ;)