cocos2d-iphone

Transitions and setting up Layers/Scenes in cocos2d iPhone

I am looking to setup a transition between two levels(after one level is complete, use one of cocos2d's slick transition to transition into the next level). In my GameLayer implementation, I have methods setup to do things like [self buildLevel: 3] to build the playfield. What do I need to do to instantiate a new GameLayer or Layer nod...

Problem with cocos2D for iPhone and touch detection

I just don't get it. I use cocos2d for development of a small game on the iPhone/Pod. The framework is just great, but I fail at touch detection. I read that you just need to overwrite the proper functions (e.g. "touchesBegan" ) in the implementation of a class wich subclasses CocosNode. But it doesn't work. What could I do wrong? the f...

Is there any cocos2d based open-source iphone game exist?

I want to study cocos2d, seems it's a good framework for iphone game programming. So is there any cocos-2d based open-source iphone game exist? ...

Possible to change the alpha value of certain pixels on iPhone?

Is it possible to change just a portion of a Sprite's alpha in response to user interaction? A good example of what I mean is iFog or iSteam, where the user can wipe "steam" off the iPhone's screen. Swapping images out wouldn't be feasible due to the sheer number of possibilities where the user could touch and move... For example, say ...

Sprites appear blue using cocos 2d-iphone, but only in the simulator

I'm running this sample code located here: http://monoclestudios.com/cocos2d_whitepaper.html using cocos 2d-iphone 0.7.2, and the sprites are being drawn coloured blue. But this is only happening on the simulator. On an actual device, everything looks fine. Has anyone else run into this problem? ...

Run-Time Dynamic Length Actions list for Sequence

Cocos2D defines the static method 'actions' for the Sequence class as such: +(id) actions: (FiniteTimeAction *) action1, ... { /* omitted */ } How could I build a list of actions to perform at run-time, perhaps read from a disk file or such? I read that the variable length argument list can be translated into a (char *) and passed in...

Method calls and declarations in objective-c for cocos2d-iphone

I am an absolute objective-c, c, and openGL newbie. Hence, when I found coco2d I was pretty thankful for having a lot of stuff done for me. Regardless, I'm still having issues. After I managed to get an animated sprite moving around based on touches I decided to clean up my code a bit into a updateLogic method and than a updateDrawing ...

Refrencing sprites from an array cocos2d

Normally when adding sprites to a layer in cocos2d I'd just add a pointer to the layer's interface for each sprite to allow it to be referenced in that layer. However, I'm now using for loops to create an array of sprites: -(void) make5Gobs { Sprite *gobs[5]; for(int i = 0; i < 3; i++) { gobs[i] = [Sprite spriteWithFil...

How to draw a solid circle with cocos2d for iPhone

Is it possible to draw a filled circle with cocos2d ? An outlined circle can be done using the drawCircle() function, but is there a way to fill it in a certain color? Perhaps by using pure OpenGL? ...

cocos2d particle performance

I am using particles for an iphone application using cocos2d. The framerate drops as the particles are shown. What is the best way to clean these up as not to affect performance? ...

How can I disable the touch detection???

How can I disable the touch detection within the action that running, because I don't want the character flying in the sky like a superman if the player clicking and clicking within the action, the character will never land if they keep clicking. I found the method "isDone", is that relate to this method?? player click -> action(cannot c...

cocos2d Sprite contentSize Problem

I've defined a sprite using the spriteWithFile method, providing a 120px by 30px .png Sprite *trampoline = [Sprite spriteWithFile:@"trampoline.png"]; [self addChild:trampoline]; When I add this to my Layer and position it, it is where I expect it to be on the screen. trampoline = [Trampoline node]; trampoline.position = ccp(160,15)...

Car turning circle and moving the sprite

I would like to use Cocos2d on the iPhone to draw a 2D car and make it steer from left to right in a natural way. Here is what I tried: Calculate the angle of the wheels and just move it to the destination point where the wheels point to. But this creates a very unnatural feel. The car drifts half the time After that I started some r...

Multi-threaded OpenGL Programming in Cocos2D-iPhone

In an attempt to create a loading bar for an iPhone game I'm developing (using Cocos2D), I wanted to use a multithreaded approach. One thread shows a loading screen and runs the main application event loop while a new thread silently loads all the Sprites in the background (through spriteWithFile) and then adds them to a layer. I creat...

Multiple ParticleSystems in cocos2d

I wonder about what road I should go with ParticleSystem. In this particular case I want to create 1-20 small explosions at the same time but with different positions. Right now I'm creating a new ParticleSystem for each explosion and then release it, but of course this is very punishing to the performance. My question is: Is there a wa...

Make irregular movement in cocos2d?

I am making a simple app in which filled circles bounce around the screen. Right now, the speed of the circles is fixed, but I want them to speed up or slow down randomly. I originally tried to use NSTimer, but I discovered that the time interval could not be made irregular. According to Apple's documentation, with the NSAnimation c...

Flipping sprite in Cocos2d

I have a card sprite I want to look like its flipping using orbitcamera. But everytime I use it it flips the sprite around the middle axis of the screen. I want the camera to rotate around the screen position where the card is drawn. ...

Sprite backgrounds

I use cocos2d for iphone and in my game I'm using a sprite as static background image. I've noticed that when removing code for adding the sprite the framerate goes from ~30fps to over 40fps. Is it any other way to show a static background that is less expensive? I'm not moving the background sprite at all. To code right now: backgrou...

Can the cocos2d Director return time?

I am currently using the cocos2d Director for controlling my animation with the pause, resume, and stopAnimation methods. Is it also possible to use the Director to return the time that the animation has played? I am currently using this method: -(void)stopAnimation:(id)sender { //Timer initialized elsewhere: startTimer = [NSDate ...

Count the number of times a method is called in Cocoa-Touch?

I have a small app that uses cocos2d to run through four "levels" of a game in which each level is exactly the same thing. After the fourth level is run, I want to display an end game scene. The only way I have been able to handle this is by making four methods, one for each level. Gross. I have run into this situation several times ...