iPhone frame rate drops when rotation CCLayer 90 degrees with cocos2d - cocos2d-iphone

I am finished my cocos2d project, which uses the accelerometer to rotate the current CCLayer for a particular game mechanic. I've always noticed a 10-15 fps drop of which I couldn't find and decided to take look now. I thought it would have something to do with iterating over objects but it doesn't.
The drop occurs when the CCLayer is not rotated at 90/270 degrees, so as it approaches 0 degrees I lose 10 - 15 frames...super annoying.
I don't use the CCLayer for anything unusual, does anyone have any idea?
TL; DR: fps drops when CCLayer is rotated 90 degrees...Why?

Related

Rotating stars like Cut the Rope

I am working on cocos2d-iPhone. I want to rotate stars with respect to its y Axis like it is in CUT THE ROPE game. I know we can rotate star to its x axis simply by ccRotateto action. Here is the link of CUT THE ROPE GAME.
http://www.youtube.com/watch?v=qoYJMaGPas4
In this link all the stars are rotating at its Y axis. You can see that in first star as it is steady.
Anyone has any idea how can we implement this??
Cocos2D has the CCOrbitCamera action that might work for you:
[[CCDirector sharedDirector] setProjection:kCCDirectorProjection3D];
CCOrbitCamera *orbit = [CCOrbitCamera actionWithDuration:1.0f radius:1 deltaRadius:0 angleZ:0 deltaAngleZ:360 angleX:0 deltaAngleX:0];
[mySprite runAction: orbit];
You can modify the angles to get the effect you're looking for.
that is done by animation frames. you need to have the rotation animation frames and you can run animation with frames to get that effect.

Accelometer different sensitivity at different tilts?

In my cocos2d game I would like to use tilt controls. The game is in landscape left only, for keeping it simple.
Now, if the user tilt device backwards, eg, tilt the screen upwards, the player sprite is moving up(+y). If the tilt is in the other direction(turning screen downwards) the sprite moves down. -(y)
The problem is that the device is pretty much in downward tilt from start and the player sprite moves down quickly. To get it moving up I have to tilt the device so far that I canĀ“t see the screen.
So is there anyway to make the tilt less/more sensitive based on what direction the said tilt is?
You need to set a filtering factor for this. Take a look at the tutorial at http://www.raywenderlich.com/3611/how-to-make-a-space-shooter-iphone-game which goes through how to use the accelerometer for this type of movement.

Sprite radial interpolation to each degree from 45 degree sprites

Question on how this could be done, if possible.
I have sprites in each of the following directions (up, down, left, right, upright, upleft, downright, and downleft). I am making a similar game to the old school zelda, running around a tile map (using tiled editor). This is working well, until now, I want to be able to shoot arrows/spells at any location on the map. I can do so, but the graphics look horrible because my guy will only turn each 45 degrees.
I have corrected this so I can only shoot in the direction my guy is facing, but now I can't hit them if they are not at a 45 degree angle from me. To fix this, I need to have a sprite at every 1 degree, or somehow combine the images say at 0 degrees (up) and 45 degrees (upright) to be able to get say 10 degrees via interpolation. Is this possible? Any ideas on how to do this?
I am looking into working with key animations since I wouldn't have to have so many sprites and use much less video memory (and smoother animations), but I still run into this same problem. Would like to know if this is conceptually possible and if so, a little psuedo code or snipit would be much appreciated.
One other question, if this is possible, do I need to be rendering this via openGL in 3D? Didn't really know if 3d would help in a 2d (orthogonal tile) game, but it might help spells falling look like they are falling downward more than moving across tiles from above to below?

Box2d coordinate system vs Pixels retina display

I am feeling difficult in understanding box2d coordinate system vs pixels or points in cocos2d.I am using retina display too.
i tried with PTM_RATIO 32 and 30 also.
But,I think box2d is not linear with pixels.Could you suggest me how to sync them.
I need to design a game that need to use pixels exactly.
Thank you
PTM_RATIO stands for Pixel to Meter Ratio, so this number is just scaling what Box2D thinks is a meter to pixels. You don't want to have a 1-1 ratio because each pixel would be a meter high from the physics engine's stand point and that might make your game behave oddy.
I use a PTM_RATIO of 16 and that seems to work in a lot of cases, so give that a try.
Just make sure you convert from the internal Box2D coordinate to your screen coordinates using the PTM_RATIO multiplier when you draw/position sprites/graphics and everything should come out fine and be as close to pixel perfect as a physics engine can be.

Running an animation on a CCSprite

How does one run an animation or a series of pngs(e.g. 4 pngs) on a CCSprite?
Constantly make the CCSprites image be this animation series?
Also, how does one rotate a CCSprite's orientation? e.g. 45 degrees rotation to the left or right
Thanks
Yes, you want to update the sprite's source every so often according to a timer.
For rotating, check out this tutorial: http://www.raywenderlich.com/692/rotating-turrets