cocos2d-iphone

CCMenu animating

Hi, I'm trying to animate my CCMenu. CCSpriteFrameCache * cache = [CCSpriteFrameCache sharedSpriteFrameCache]; [cache addSpriteFramesWithFile:@"PlayButton.plist"]; CCAnimation * animation = [[CCAnimation alloc] initWithName:@"idle" delay:1/20.0]; for ( int i=1; i < 6; ++i ) { NSString * fname = [NSString strin...

Add viewcontroller in cocos2d scene

Hi, Can anyone tell me the best way to add a viewcontroller with nib file to a cocos2d scene? Thanks ...

Making a Sprite unmovable...[Chipmunk & Cocos2D]

Hi all... Im using Chipmunk with Cocos2d to make a gravity based puzzle game, however I have reached a part of my project whereby I need a sprite that once drawn does not move and cannot be moved by the other sprites within the environment. In essence... Can I create a static (non moving) sprite that is not affected by in game gravity...

Random Sprite Destinations

Hello again, I was able to make the targets spawn randomly along the top of the screen and dissappear at the bottom of the screen. The only problem is that the targets only move to one fixed point every time. I want them to move to a random point on the bottom of the screen. Any ideas? Thanks. Here is the code: -(void)addTarget { ...

iPhone-Cocos2D: Making a layer that isnt transformable?

Is it possible to make a layer that wont be affected by transformations (scale, move) made to his parent? if so, how? For example, if a have layer A, I add a Layer named B as a child to layer A. now i scale down layer A, how can i make layer B unaffected by this scale action? so far i've found this property named honorParentTrasform, b...

cocos2d NAN ERROR when I called the "self.rotation" in the schedule!

There are the codes: - (void)startMoving:(ccTime)dt { CGPoint pos = CGPointZero; float objPOSX = self.position.x; float objPOSY = self.position.y; float angle = self.rotation; float radian = angle*M_PI/180; int quadrant = [self getObjQuadrant]; switch (quadrant) { case 1: pos.x = objPOSX + tan(radian) * (sqrt(2 * pow(objSpee...

Volume Control for entire app

My current app could probably be thought of as a sound board. There are a few buttons to click on which produce sounds. The sound are on on View Controller. Nested inside that is another View Controller with the settings which will pop up when called. This is where I need to put my volume slider. To produce the sounds the parent View...

Accelerometer Movement acting strange

Hello, Right now, I am trying to make my sprite move left when the device is tilting left and move right when the device is tilted right. There is no Y axis movement at all.(Which is good) The code I am using seems to be working just fine, except that when tilted left, the sprite only moves about a 3rd of the way across the screen ins...

subclassing CCNode, blitzing image with glTexImage2D

I've subclassed CCNode and would like to blitz an image stored in a member GLubyte* buffer on each draw call. This results in a black square being drawn, and a sibling CCLabel node is now also completely black. So there are two issues: Why isn't the square white? I'm memset-ing the buffer to 0xffffffff. There must be something wrong w...

Cocos2D changes the colours in the last row of pixles in a sprite?

I have never seen this issue before, its very strange. Just wondering if anyone else has come across this too. I have added a sprite to my game, its supposed to be the top left corner of a box to put text on to. I want to make it scalable without loosing anything so i have it broken up into sections. In the image above the one on top ...

CCSprite Touch Event!

I am using Cocos2d and CCSprite to create sprites in my application. I am wondering if there is any easier way to implement the touch event on the CCSprite object. I know the menuitem provides the selector but what does CCSprite provides to handle the touch events. ...

cocos2d:Interchange Sprite

Hi, I use the following to to interchange only the position of 2 sprite. CCSprite *sprite1 = (CCSprite*)[self getChildByTag:tagOfFirstSprite]; CCSprite *sprite2 = (CCSprite*)[self getChildByTag:tagOfSecondSprite]; CGPoint SpritePosition1 = [sprite1 position]; CGPoint SpritePosition2 = [sprite2 position]; [spri...

Problem with cocos2d and orientation changes, textures are deformed

I'm using cocos2d v0.99.5-beta2 and I have a strange problem only on iPhone 1st gen and iPhone 3g. When I change iPhone's orientation all my CCSprite are deformed and duplicated. I already have tested many methods to rotate my scene but I always have the same result. But I haven't this problem on simulator, iPhone 4 and iPad. See scr...

Progress Counter in Cocos2D

Hello, I need a counter that updates a CCLabel every second. I want it so the user can see how long they survived. I'm not totally sure how to explain this so let me know if I can make things clearer. ...

CCLabel line-height in cocos2d

I was wondering if it's possible to adjust the line-height of a CCLabel. I got a 3 lines of text but would like to reduce the lead and maybe the letter-spacing. I haven't found any solution at the moment. Would bitmap fonts help me? I haven't gone for them because I don't have to change the string value at all. thanks ...

iphone JSON Parsing.. How can i parse this data.

this is the print screen of nsmutablearray. this 2409,2410,2412 is not fix key. it coming dynamically. { 2409 = ( { AltSelectionPrice = "2.00"; }, { AltSelectionPrice = "3.00"; } ); 2410 = ( { AltSelectionPrice = "7.00"; }, { AltSelect...

Access Photo Library in cocos2d

Hi all, I am creating a game using cocos2d. Now what I want is I need to insert the image from Photo Library to my application. Can you please tell how can we access Photo Library through cocos2d? Thanks in ADVANCE... ...

Problem with adding sprite using CCSprite array in cocos2d

I have problem with following code. mySpriteArray=[[NSMutableArray alloc] init]; star=[CCSprite spriteWithFile:@"22.png"]; for(int i=0;i<10; i++) { [mySpriteArray insertObject:star atIndex:i]; } // NSLog(@"x=%i",[mySpriteArray count]); for (int i=0; i<10; i++) // Opponents is NSMutableA...

Integrate View and CCLayer/CCScene in iPhone

Hi all, I am developing a game in cocos2d. Now I had done a coding in my previous iPhone application which was doing functionalities like recording and playing the recorded sound. I want to implement that same thing in my cocos2d application also. So i want to integrate them in such a way that I can use that SoundViewController.h and...

cocos2d + box2d: Rotation towards point

I'm attempting to rotate a box2d body that's tied to a cocos2d sprite via box2d's GetUserData() in my iPhone application. Specifically, I'm attempting to grab the latest touch location and rotate my box2d body in that direction. I'm fairly inexperienced when it comes to box2d, so any advice would be appreciated. Below is a quick stab at...