Accessing public variables from inside ccTouchesBegan method in cocos2d-x

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'

Answers


I don't know anything about cocos2d, but I reckon you've defined the method incorrectly as you've missed off the class name. Try this:

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

Need Your Help

How to retrieve all <select> tag options?

php html post html-select

I have a form with a drop down list that is being populated by the user using java script.