1

I'm having little trouble accessing public ivars form the ccTouchesBegan method,

I have this Scene:

class introScene : public cocos2d::CCLayer {
public:
    virtual bool init();
    static cocos2d::CCScene* scene();
    bool autoScroll;

    virtual void ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
    void skip();

    CREATE_FUNC(introScene);
};

and from inside the .cpp file I try to access the variable autoScroll, but it insists that the variable doesn't exist, am I doing anything wrong here ??

void ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event){
        autoScroll = false;

}

This generates: use of undeclared identifier 'autoScroll'

4

1 に答える 1

2

cocos2dについては何も知りませんが、クラス名を見逃しているため、メソッドを誤って定義したと思います。これを試して:

void introScene::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event){
    // ^^^^^^^
    autoScroll = false;
}
于 2012-09-10T09:23:58.793 に答える