Hi all,
I'm just learning to get to grips with Sparrow, and I'm really loving it already
I was initially looking at cocos2d, but I just don't need all the extra stuff it allows for, the learning curve far outweighs the benefits I would have got. I only wanted a graphics and sound engine, and Sparrow fits the bill perfectly. So thanks!
Ok, my problem:
This is running on an iPad 1 with iOS5, xCode 4.2 and ARC semi-enabled.
Based on the example framework, this is a very simple app so far. It consists of the game class (spstage) and a BEParallaxSprite thingie (with 3 images scrolling) and a gameSprite class.
The gameSprite class is very simple, and contains one image (roughly 100px x 100px). It also has a velocity property.
The game class is the delegate for the accelerometer and is updating the gameSprite velocity at 1.0f/30.of
The game frame rate is also set at 1.0f/30.0f
I have set up the onEnterFrame listener for the gameSprite, and here is the code I have:
-(void)onEnterFrame:(SPEnterFrameEvent*)event { //SPTween *tween = [SPTween tweenWithTarget:self time:1.0f/30.0f]; if (self.x + velocity.x > 500) { self.x = 500; } else if (self.x + velocity.x < 0) { self.x = 0; } else { self.x += velocity.x; //[tween animateProperty:@"x" targetValue:self.x + velocity.x]; } if (self.y + velocity.y > 500) { self.y = 500; } else if (self.y + velocity.y < 0) { self.y = 0; } else { self.y += velocity.y; //[tween animateProperty:@"y" targetValue:self.y + velocity.y]; } //[self.stage.juggler addObject:tween]; }
You can see that I have the tween stuff commented out, and am manually updating the x and y properties.
This code is running just fine. Performance seems fine, the acclerometer works and moves the sprite around the screen.
Great, however because there is no animation due to updating the properties directly there is a slight blur on the sprite. If you look closely that is.
I thought some tweening would get rid of the blur (even though it's only a small blur).
So I switched around the comments in the previous code thus:
-(void)onEnterFrame:(SPEnterFrameEvent*)event { SPTween *tween = [SPTween tweenWithTarget:self time:1.0f/30.0f]; if (self.x + velocity.x > 500) { self.x = 500; } else if (self.x + velocity.x < 0) { self.x = 0; } else { //self.x += velocity.x; [tween animateProperty:@"x" targetValue:self.x + velocity.x]; } if (self.y + velocity.y > 500) { self.y = 500; } else if (self.y + velocity.y < 0) { self.y = 0; } else { //self.y += velocity.y; [tween animateProperty:@"y" targetValue:self.y + velocity.y]; } [self.stage.juggler addObject:tween]; }
Ok, this code works also, and gets rid of the blur.
However, there is an awful judder, so awful in fact that the blur is actually preferable!
It's as is it's putting a terrible performance strain on the engine, although for a single sprite/single background game this can't be right. Surely?
Now, does anyone know why I am experiencing a judder/stutter? Am I using the juggler and tweening correctly?
Is it anything to do with the update speed (1.0f/30.0f) being the same as the frame rate? I think not, but still...
Is it iOS5 related perhaps? Or maybe an iPad 1/iOS5 combo problem?
I have checked out the iOS5 performance thread btw and have already set DISABLE_MEMORY_POOLING as per the instructions.
Any insights as to what I can do will be greatly appreciated.
Thanks