Fix a potential crash in Scheduler

Sometimes the program crashes if we use `ccSchedulerFunc` together with `SEL_SCHEDULE` in one scheduler.
The crash is caused by invalid `static_cast`, and now it's fixed by using `dynamic_cast`.

I'm not sure whether to add a test case for this. Please tell me. Thanks!