The problem of cocos2dxschedule's delayed for loop scheduleonce

Source: Internet
Author: User
Scheduleonce only executes the time function once, which can be seen as delayed execution. The general idea of using scheduleonce to create a delayed for loop today is as follows: Global inti1; scheduleF (0.5f); call the time function voidhello: scheduleF (floatf) {if (i10 ){...... Scheduleonce (schedule_selector (

Scheduleonce only executes the time function once, which can be seen as delayed execution. The general idea of using scheduleonce to do a delayed for loop today is as follows: // global int I = 1; scheduleF (0.5f); // call // time function void hello :: scheduleF (float f) {if (i10 ){...... Scheduleonce (schedule_selector (

Scheduleonce only executes the time function once, which can be seen as delayed execution.

Today, I want to use scheduleonce for a delayed for loop.

The general idea is as follows:

// Global

Int I = 1;

ScheduleF (0.5f); // call

// Time Functions

Void hello: scheduleF (float f)

{

If (I <10)

{

......

Scheduleonce (schedule_selector (hello: scheduleF), 0.3f );

}

I ++;

}

I tried it. no, I = 2 at most. It should be manually called once. scheduleonce can do it for the first time.

So I think it may be that scheduleonce has already added this function and cannot be added multiple times. So I want to run the un command before adding it, but I didn't find the unscheduleonce method and used unschedule, the test still fails.

Instead, they all changed to schedule and unschedule.

Void hello: scheduleF (float f)

{

If (I <10)

{

......

Unschedule (schedule_selector (hello: scheduleF ));

Schedule (schedule_selector (hello: scheduleF), 0.3f );

}

Else

{

Unschedule (schedule_selector (hello: scheduleF ));

}

I ++;

}

This is enough, but the unscheduleonce method is missing. I wonder if it is a vulnerability ····

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.