SpriteBuilder and parallax - cocos2d-iphone

Is there a way to get parallax going in the wysiwyg SpriteBuilder?
I am assuming for now that there is no way to do it, except change things around in code: define for instance a Level as decendant of CCParallaxNode instead of CCNode, then remove+readd stuff to the node, defining the parallax ratios.
(side note: there is no tag for cocos2d-iphone version 3)

Related

Cocos2d v3.x. It seems impossible to do automatic Z-ordering when using TileMaps

When creating an isometric tilemap-based game using Cocos2d 2.x, automatic Z-ordering was not a problem.
We can just read the vertexZ/zOrder value of the tiles (treaded as CCSprites) of every layer and update our nodes accordingly.
Now I use v3.3 of Cocos2d.
CCTMXTiledMaps have been replaced with CCTiledMaps
CCTMXLayers are replaced with CCTiledMapLayers
In versions 3.0+ we cannot treat individual tiles as CCSprite's and hence the tiles themselves has no zOrder or vertexZ property.
This makes it impossible to know what zOrder i should update my moving characters to in order for them to be rendered realistically.
Is it possible to do automatic zOrdering in some way using tiled maps and moving objects? How is it supposed to be done using cocos2d v3+?

Cocos2d: is it better to have single layer and add nodes or is it better to have multiple layers?

I've got this little game of mine and it consists of main game screen and of quite a few "windows" which appear on the screen on top of the main screen.
In most cases it's just one window [which is over 90% of the screen], sometimes window will open up another one.
Right now, my main screen is a layer and each window I have is a CCNode I add and remove from the layer.
I am not really using any touch detection on my nodes. If I want something touchable it will be a CCMenu.
I do have plenty of CCSprites added, if that has anything to do.
I'm wondering if it's a good [performance wise] way to go? Or in other words, if there's a rationale behind changing what I have to let say have each window as a layer.
As far as I know, two most important benefits of using multiple layers instead of single layer are touch detection and z-ordering:
Touch detection: Using multiple layers makes it easier to employ touch detection logic that makes use of the layer hierarchy since cocos2d engine passes any touch event to the layers one after another based on the hierarchy.
z-ordering: For scenarios where certain sprites are always in front of other sprites, using multiple layer makes it much easier to enforce the z-ordering rather than having to tinker with zOrder parameter when using single layer.
IMO there is not much difference performance wise between using single layer and multiple layers, but if you have plenty sprites on the screen at one time, and especially if there are lots of repeating sprites, I would highly recommend using CCSpriteBatchNode (previously known as Texture Atlas or CCSpriteSheet) which is the recommended cocos2d method of improving game performance when dealing with big number of sprites, so I'd say single layer with sprite batch nodes is better in term of performance then multiple layers with individual sprites added directly to the layers.

Can Cocos2D handle these graphic requirements?

I'm wanting to build a game with some simple effects.
I want to add the warping effect that you see in games like geometry wars and geodefence. I know how to implement this effect in OpenGL ES. Would I be able to add this to a Cocos2D created app?
I want to have a 3D model that only moves on a 2D plane. It may rotate. First, can I add OpenGL shading to the model? Second, can I have Box2D physics applied to it like it was a 2D sprite?
That's about it. Those are the main functionality I'm hoping I can add to a Cocos2D application and am trying to figure out if I can before I spend a lot of time learning how to use the game engine.
1) Yes, you can intermix Cocos2D and OpenGL ES together - you can override the CCNode's "draw" method and do just about anything you'd like in there (such as rotating, scaling, etc in OpenGL with the texture).
2) You can add the model, and you can shade the model - yes. If you create the body fixtures for the model from Box2D, but treat the Model as if it were a '2d sprite' (has set width/height) - yes, you can use Box2D - but understand that it will only react within the 2D Physics World, and won't have any depth applied to it.
It should be noted though, that though these are possible, you will still need to implement the code to do so on your own.

Chipmunk body move with Parallax?

I'm using Cocos2D, SpaceManager and Chipmunk. I have a parallax node with 4 layers on it, this is tied to the location of a playable chipmunk body. This body needs to collide with static objects on one of the parallax layers, the static bodies must start off screen then move into screen and collide.
I know you are not supposed to move static bodies with Chipmunk, unless you rehash. However, rehashing 60 time a second to keep up with the framerate seems messy. Can anyone think of an alternate way to do this?
Cheers.
One thing you could try is joining all the objects in each parallax layer to a non-colliding body using rigid joints. Then move that body along with the parallax layer to drag the objects along. THis may not be the best method, though.

Use Chipmunk body location to drive Cocos2D Parallax

I'm using Chipmunk with SpaceManager inside of Cocos2D. I have a body which is moving around with impulses, I'd like to be able to use that bodies location to drive a parallax node in Cocos2D.
So, when body 'a' moves to the left, the parallax follows but with a small time offset, or elastic effect. If you know AS3 and Flash, you can think of this as using a movieclip's x and y location to drive a constantly updating tween with an ease out effect. This is what I'd like to achieve, and after no sleep trying to work it out last night I've decided to ask you much more experienced people :)
Thanks.
You could associate an additional body with the parallax node, and attach it to body a with a suitable joint or set of joints. It is difficult to tell from the question what exact behaviour you are looking for, but at least one of slide, groove or damped-spring constraint should do the trick.
I worked this out, for future ref in case others need it you use:
[voidNode setPosition:(yourShape.position)];