HUD图层未添加到我的场景中 [英] HUD layer not being added on my scene

查看:93
本文介绍了HUD图层未添加到我的场景中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经拥有gameLayer的CCScene,我试图在其上添加HUD层,但是并没有在场景中添加HUD层,可以说是因为我已经在HUD层上设置了CCLabel,当我运行项目时,看不到该标签。

I have a CCScene which already holds my gameLayer and I am trying to add HUD layer on that.But the HUD layer is not getting added in my scene, I can say that because I have set up a CCLabel on HUD layer and when I run my project, I cannot see that label.

这就是我在做什么:
在我的gameLayer中:

Here's what I am doing : In my gameLayer:

+(id) scene
{

   CCScene *scene = [CCScene node];

   GameScreen *layer = [GameScreen node];
   [scene addChild: layer];

    HUDclass * otherLayer = [HUDclass node];
    [scene addChild:otherLayer];

    layer.HC = otherLayer;// HC is reference to my HUD layer in @Interface of gameLayer
    return scene;
}

然后在我的HUD层中,我刚刚在其init方法中添加了CCLabelTTF像这样:

And then in my HUD layer I have just added a CCLabelTTF in its init method like this :

-(id)init {

    if ((self = [super init])) {

    CCLabelTTF * label = [CCLabelTTF labelWithString:@"IN WEAPON CLASS" fontName:@"Arial"    fontSize:15];
     label.position = ccp(240,160);
     [self addChild:label];

    }

    return  self;
}

但是现在当我运行我的项目时,我看不到那个标签,我是什么在这里做错了..?

But now when I run my project I dont see that label, What am I doing wrong here ..?

任何想法..?

预先感谢您的时间。

推荐答案

hmmm,您没有将HUD实例添加到场景中。试试:

hmmm, you are not adding the HUD instance to the scene. try :

    HUDclass * otherLayer = [HUDclass node];
    [scene addChild:otherLayer];

    layer.HC = otherLayer;

这篇关于HUD图层未添加到我的场景中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆