从Cocos2D中的另一个类访问方法

我自己和我的手机

我正在尝试从Cocos2D中的另一个类访问我的自定义方法。这是我在使用Cocos2D之前所做的事情,但是由于某种原因,它现在无法正常工作。

heroNode.h(CCNode)

@interface heroNode()

    -(void) staminaCounter;

@end

#import "heroNode.h"

@implementation heroNode {
}
        -(void)staminaCounter {
        //My Code Here

    }
@end;

MainScene.h(CCScene)

#import "heroNode.h"

@implementation MainScene
{
    heroNode *HeroStuff;
}

//Using
    HeroStuff = [[heroNode alloc] init];

//Then this is where I am having the issue calling `staminaCounter`
//Do something like
//[heroStuff staminaCounter];
加布

声明-(void)staminaCounter“ heroNode.h”,因为如果不这样做,则该方法是私有的,因此只能在您的类内部使用它。

介于@interface之间@end

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章