views:

1587

answers:

2

I'm using the cocos2d framework for various of my applications, and have run into the following problem. I have set up a few sequences of actions and CallFuncNDs, the actions have durations set up and when I run it in the iPhone simulator, it works just like I expect it to: transitions take the amount of time I set them to and they go in the correct order.

When I test it on my provisioned iPhone, it all plays out in less than one second. Correct order, timing is proportional between actions, but it's all compressed into one second.

Any one have any idea why the cocos2d animations would behave differently on a device? My code is all set up similar to the cocos2d effect demos, with the difference that I am animating a ParticleSystem and not a Sprite - though the problem still shows up with Sprites.

+2  A: 

I have experienced similar difficulties where testing the code in the simulator, it runs flawlessly. But when moved over to the device, the timing appears to be off. I've attributed this difference to the Simulator's use of the desktop CPU and Memory, where as the device is utilizing it's physical hardware and the timing is off because of how Cocos2d processes things (frame by frame, in a 'game loop'). When you start doing a couple things, the frame rate drops and Cocos miscues ... especially when you have schedules that run extremely close to each other, or schedules that cancel themself and reschedule with different timings (in increments as low as 0.1 and below is where I've run into this the most).

David Higgins
That was my initial thought, but I understood that when I say an animation will run for 0.1 seconds, it will do so regardless of the hardware. It does run for 0.1s in the simulator, but extremely fast on the iPhone - which I would expect to be actually slower than my MacBook when it comes to OpenGL.
Hector Ramos
I believe the problem is actually in the fact that the iPhone is in fact slower, so the animation 'appears' to play faster due to time synchronization being off. When update is called on the animation, the delta time is much higher than when it is called on the Simulator, which drives the animation to complete faster.
David Higgins
A: 

hai, i am new to iphone development.i used NSTimer scheduledTimerWithTimeInterval 0.01 seconds for game loop.the game consists drawscreen function inwhich i use CGContextClipToRect to clip the large images for animation.but the speed 0.01 seconds is working in simulator only not in the iphone(device).how can i overcome this problem? i respect your reply......you have told about it in previous post.but i could not understand..... the timer code is in view controller as

  • (void)viewDidLoad {

    GameView *main = [[GameView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; main.backgroundColor = [UIColor blackColor]; self.view = main; [main release]; self.tim = [NSTimer scheduledTimerWithTimeInterval: 0.01 target: self selector: @selector (gameloop:) userInfo: nil repeats: YES]; [super viewDidLoad];

}