用的是cocos2dx 3.4 final, 开发工具VS2013。
在.h文件里已经声明了Sprite * sprite; ,怎么就sprite未声明标识符?求大神
MainScene.h
#ifndef __MAIN_SCENE_H__ #define __MAIN_SCENE_H__ #include "cocos2d.h" class MainScene: public cocos2d::Layer { public: virtual bool init(); static cocos2d::Scene * createScene(); CREATE_FUNC(MainScene); private: void update(float t); Sprite * sprite; }; #endif ``` MainScene.app#include "MainScene.h" USING_NS_CC; Scene* MainScene::createScene(){ auto scene = Scene::create(); auto layer = MainScene::create(); scene->addChild(layer); return scene; } bool MainScene::init(){ if (!Layer::init()){ return false; } sprite = Sprite::create("star.png"); sprite->setPosition(CCPointMake(480, 320)); this->addChild(sprite); schedule(schedule_selector(MainScene::update)); return true; } void MainScene::update(float t){ sprite->setPosition(ccpAdd(sprite->getPosition(), ccp(1, 0))); } ```