I want a background CCSprite image to be ignored by camera zooms etc. How can I do this?
Camera ignore certain CCSprite
(6 posts) (2 voices)-
Posted 1 year ago #
-
By placing it in another layer. For instance
-CCScene --CCLayer GameWorld --enable the camera of GameWorld --CCLayer BackgroundPosted 1 year ago # -
How do you have two layers visible at once?
I copied http://www.cocos2d-iphone.org/forum/topic/6511
but it acts the same as a CCSprite in the same layer.
Posted 1 year ago # -
That setup looks good. Is your problem that one of the layers isn't visible or that the background still reacts to the camera?
If it is the latter, how are you enabling the camera?
Posted 1 year ago # -
If I do it to
+(id) scene { CCScene *scene = [CCScene node]; MenuScene *layer = [MenuScene node]; [scene addChild: layer]; return scene; }code like that, ot doesn't appear. If I add it to
-(id) init { if((self=[super init])) {It moves with the camera...
My camera is setup like:
// Called at each "frame" of the simulation - (void)tick:(NSTimer *)timer { // Tell Chipmuck to take another "step" in the simulation cpSpaceStep(space, 1.0f/60.0f); background.position = cpv(monkey.position.x, monkey.position.y); if( monkey.position.x < 0) { zPos = monkey.position.x; } else { zPos = 0; } [self.camera setCenterX:monkey.position.x-240 centerY:monkey.position.y-160 centerZ:zPos-1]; [self.camera setEyeX:monkey.position.x-240 eyeY:monkey.position.y-160 eyeZ:zPos+1]; // Call our function for each shape cpSpaceHashEach(space->activeShapes, &updateShape, nil); }Posted 1 year ago # -
You didn't copy the code from the topic you've linked to. You need to add multiple layers to the scene, not only one like you're doing now.
The self in your camera setup, where does it refer to? I presume a CCScene, that's why all layers will still react to the camera. You'll have to change it to something like this..
[worldLayer setCenterX:....]; [worldLayer setEyeX:..];Now the camera will only have influence on the things that you add to the worldLayer.
Posted 1 year ago #
Reply
You must log in to post.