gloabal scheduler issue 全局调度器的一个问题


#1

I’m developing a game on windows now , which will be rebuilt on IOS and android .
我现在在windows上开发一个游戏,以后会被编译到ios和android平台发布。

here’s the thing
遇到如下问题

I started a global scheduler keeping repeating something using these codes below
我想启动一个全局的scheduler一直重复做一件事,代码如下

CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(FirstScene::loop), this, 0,false);

it works perfectly in that Scene I started it
在启动它之后,能正常运行

but after I called replaceScene , it doesn’t work anymore
但是我切换场景之后,它就不运行了

how can I fix this ?
我应该怎么办来解决这个问题

someone plz help
请多多帮助

I’m afraid my poor English can’t express myself very well , Chinese added , don’t be mind .
我担心英文水平不够,不能正确表达我的意思。所以加上了中文,请勿见怪。


#2

your target object for scheduleSelector (the parameter this you have passed in) is some object in this scene (for ex i am guessing a layer)? if so then when you do a replacescene this object also gets released. so whatever things were scheduled to run on this object would stop working.


#3

The parameter you passed in is “this”. I guess it’s only valid in your FirstScene object. When you replaceScene, this FirstScene object is no longer valid.


#4

PRakash Ramachandran wrote:

your target object for scheduleSelector (the parameter this you have passed in) is some object in this scene (for ex i am guessing a layer)? if so then when you do a replacescene this object also gets released. so whatever things were scheduled to run on this object would stop working.

thx man. I found out why finally.
what you say’s kinda close to the truth ,but not exactly .
the Scene is not released , but its cleanup method was called by the director
and I also knows how to fix it .

here’s the detail:
http://blog.csdn.net/dinko321/article/details/16337223

sorry , don’t have time to translate it


#5

Changjun Shuai wrote:

The parameter you passed in is “this”. I guess it’s only valid in your FirstScene object. When you replaceScene, this FirstScene object is no longer valid.

“this” object is valid , cuz it will be retained in schedule() function.

here’s the detail:
http://blog.csdn.net/dinko321/article/details/16337223

and 我也是成都的,有靠谱工作求推荐


#6

Dinko Chong wrote:

Changjun Shuai wrote:
> The parameter you passed in is “this”. I guess it’s only valid in your FirstScene object. When you replaceScene, this FirstScene object is no longer valid.
>
“this” object is valid , cuz it will be retained in schedule() function.
>
here’s the detail:
http://blog.csdn.net/dinko321/article/details/16337223
>
and 我也是成都的,有靠谱工作求推荐

Nice blog! 不过你好像是前端开发,我们公司缺的是后台开发。有兴趣联系我 shuaicj@gmail.com