scheduleUpdate not working

I’m trying to create a ScrollView class with cocos2d-2.0-rc2-x-2.0.1 and I mean to do something in update function to implement the auto-scroll effect.Unfortunately,I find the function has never been called.Though I’ve done a lot of work like searching on the internet,debuging step by step and so on,the possible solutions I found helped little.

As far as I know,my ScrollView class derive from CCNode and I’ve implemented the update function.The declaration of ScrollView is as following:

`class ScrollView:public CCNode,public CCTouchDelegate
{
ClippingNode* visible_view;
CCNode* content_view;
//CCArray* items;
float row_margin;
float col_margin;
float interval_margin;
float last_y;//起始y方向坐标
float interval_dis;//间隔时间段内y方向上的位移。
bool touch_stopped;//标识触摸是否停止,主要用于自动滚动。
float up_bounder_y,down_bounder_y;//content_view的y方向坐标上下限
int items_num;
public:
static ScrollView* New(CCSize visible_view_size,float row_margin,float col_margin,float interval_margin,CCNode* background = NULL);
void ccTouchBegin(cocos2d::CCNode *node,const cocos2d::CCPoint &point);
void ccTouchMove(cocos2d::CCNode node,const cocos2d::CCPoint &point);
void ccTouchEnd(cocos2d::CCNode node,const cocos2d::CCPoint &point);
virtual void onEnter();
protected:
CCNode
makeCard();
void initContent();
private:
ScrollView():visible_view(NULL),content_view(NULL),touch_stopped(true){}
virtual ~ScrollView();
bool init(CCSize visible_view_size,float row_margin,float col_margin,float interval_margin,CCNode
background);

void update(float dt);

};`

And here is the definition of update function:

void ScrollView::update(float dt) { CCLOG("update"); if(touch_stopped) { if(abs(interval_dis) < a) { interval_dis = 0.0f; this->unscheduleUpdate(); }else { if(interval_dis < 0) interval_dis += a; else interval_dis -= a; const float future_y = content_view->getPositionY() + interval_dis; if(future_y > down_bounder_y && future_y < up_bounder_y) { content_view->setPositionY(interval_dis); }else if(future_y <= down_bounder_y) { content_view->setPositionY(down_bounder_y); interval_dis = 0.0f; }else { content_view->setPositionY(up_bounder_y); interval_dis = 0.0f; } } } }

So I can ensure the type of the param is float instead of CCTime or ccTime which may cause update function never to be called.Moreover,I invoke the scheduleUpdate in the init method like the following:

`bool ScrollView::init(CCSize visible_view_size,float row_margin,float col_margin,float interval_margin,CCNode* background)
{
visible_view = ClippingNode::New(visible_view_size);
CHECK_RETURN(visible_view,NULL,false);
visible_view->retain();
content_view = CCNode::create();//node函数中已调用autorelease
CHECK_RETURN(content_view,NULL,false);
content_view->retain();
this->row_margin = row_margin;
this->col_margin = col_margin;
this->interval_margin = interval_margin;
this->setAnchorPoint(ccp(0.5f,0.5f));
this->setContentSize(visible_view_size);
visible_view->setPosition(0,0);
content_view->setAnchorPoint(ccp(0,1));
content_view->setPosition(row_margin,visible_view_size.height);
content_view->setContentSize(CCSize(visible_view_size.width - 2 * row_margin,2 * col_margin));
this->addChild(visible_view);
visible_view->addChild(content_view);
down_bounder_y = visible_view_size.height;
up_bounder_y = content_view->getContentSize().height > visible_view_size.height?content_view->getContentSize().height:visible_view_size.height;
UserData* user_data = UserData::getUserData(this,true);
CHECK_RETURN(user_data,NULL,false);
user_data->setContainer(true);
items_num = 0;
initContent();
if(background)
{
background->setScaleX(visible_view_size.width/background->getContentSize().width);
background->setScaleY(visible_view_size.height/background->getContentSize().height);
background->setAnchorPoint(ccp(0.5f,0.5f));
background->setPosition(visible_view_size.width/2,visible_view_size.height/2);
user_data = UserData::getUserData(background,true);
user_data->setHitable(false);
this->addChild(background,-1);
}

this->scheduleUpdate();
return true;

}`

Through debug,I can ensure the sentence “this->scheduleUpdate()” is invoked.In addition,I created a ScrollView object named scroll_view and added it to the main node through addChild function.So,where am I wrong?Any addvice would be appreciated and thanks for watching:p

I’ve found my problem.I redefined onEnter function in ScrollView class,but I didn’t invoke CCNode::onEnter() in my own onEnter function.Hope that can help others encountering the same problem;-)