How do I resume a performSelector method after being paused?

I've looked around on stack overflow for days and have not seen an answer to my problem. I have several methods in my main game scene that are called by

[self performSelector:@selector(MethodName) withObject:nil afterDelay:.1];

When I leave the game and come back, it looks like all of my methods run at once. I assume this is because the delay time is calculating in the background, but I do not understand how to correct this in cocos2d. I thought I didn't need to deal with NSTimers with the pause/resume functions in cocos2d? What simple piece of information am I missing here?


You can use cocos-2d schedulers to solve this problem. See the below code:

 [className schedule: @selector(selectorName) interval:2];

When you pause the game using : [[CCDirector sharedDirector] pause]; this timer's will paused. And when you resume the game using : [[CCDirector sharedDirector] resume]; It will also resume.

Also you can create sequence of actions to make delayed single method call.

id delay = [CCDelayTime actionWithDuration: yourDuration];
id call = [CCCallFunc actionWithTarget:yourTarget selector:yourSelector];
id sequence = [CCSequence methodOne: delay two: call];
[someNode runAction:sequence];

Need Your Help

Is it possible to use C# FtpWebRequest through a FTP proxy?

c# .net proxy ftp ftpwebrequest

As I understand it, the FtpWebRequest.Proxy property denotes an HTTP proxy. I have to issue FTP requests to an external server via an FTP proxy.

How to pass multiple parameter in Task

c# multithreading performance task

I have a function GetPivotedDataTable(data, "date", "id", "flag") is returning data in Pivoted format. I want to call this method using Task but how to pass multiple parameter in Task.