cocos2d-iphone

How to reuse actions

Of the three parts I want to move, only the last one actually moves. I can't seem to "recycle" the ease action I created. How is this done the correct way? - init { // initial setup [self moveParts]; } - (void)moveParts { id action = [CCMoveBy actionWithDuration:1 position:ccp(0,160)]; id ease = [CCEaseInOut...

objc[989] objc_exception_throw failed.

I was just adding some more CCSprites to a CCLayer and it just starts crashing giving me the error: objc[989] objc_exception_throw failed. Is there like a limit to the amount of CCSprites you can have on a screen or something? I added the CCSprites doing the following with the CCSprites already declared at interface: L1Circle1 = [CC...

iPhone OpenGLES textures - colour banding

I've got a problem with openGL on iPhone which I'm sure must have a simple solution! When I load a texture and display it, I get a lot of what I believe is called 'Colour Banding', whereby the colours, particularly on gradients, seem to get automatically 'optimized'. Just to demonstrate that this wasn't anything wrong with my own code...

How can we set time delay in animation of images to make them appear smooth ?

Hi, I have 10 CCSprite images. They are continues images. I am using, CCSprite *playerH = [CCSprite spriteWithFile:@"Player_01.png" ]; playerH.position = ccp(playerH.contentSize.width/2, windowSize.height/2); [self addChild:playerH z:1]; CCAnimation* animation = [CCAnimation animationWithName:@"dance" delay:0.20f]; for( int i = ...

small sprite touch

There are some games which have some small pictures as sprites and can move by touch.If the sprite is a larger picture,the touch is quite normal.And we can use the function CGRectContainsPoint check for the sprite.But when the sprite is quite small,this function looks not good.Is there other method can sovle the problem? ...

Dynamically create sprite images for Cocos2d-iPhone

Hey guys, I'm working on a platformer, and looking for a way to create a sprite for an arbitrarily sized platform. For example, I may know I have a platform that should appear 200 pixels wide by 32 pixels high, and, say, I have a texture of bricks that I can tile to fill that area. I may also want to draw a black border around the platf...

How can I add Copperplate Gothic Bold font in my iPhone program ?

Hi, I need to display some text in cocos2d layer. I added UITextView to it. I added the text in the text View. But, for setting the font by ( UIFont class), I could not do it. I saw the list of supported fonts for iPhone, In that list Copperplate Gothic Bold is not there. I downloaded it from net. It is working good for CCLabel and CCF...

Global NSMutableArray doesn't seem to be holding values

I have a Cocos2D iPhone application that requires a set of CGRects overlaid on an image to detect touches within them. "Data" below is a class that holds values parsed from an XML file. "delegateEntries" is a NSMutableArray that contains several "data" objects, pulled from another NSMutableArray called "entries" that lives in the appli...

Performance difference in simulator and device in my game. Why ?

Hi, I am writing a small shooting game using cocos2d. It's working good in simulator. But when testing in the device, the animations of sprites are slow and they are stucking. The images I used are CCSprites. And I used CCAnimation for the animation of the images. Why the game acting different in simulator and device ? Thank you. ...

JSON parer to get Image

How to get image from server using JSON parser. plz if possible post piece of code. Thnks in advance.. ...

Should we remove Child added by addChild method before going to next scene in cocos2d ?

Hi, I am writing a small game in cocos2d. I am adding child [ self addChild: sprite1]; Should I remove these before going to next scene by using [self removeChild: sprite1 cleanup:YES]; Does it increase the performance in device ? Thank You. ...

When we should use pushScene and replaceScene?

Hi, I cocos2d, I am using pushScene and replaceScene to move to next scene. But, I am confused which we should use? When I am using replaceScene in some places app is crashing and giving errors like -[UITextView length]: unrecognized selector sent to instance 0x842a750 Terminating app due to uncaught exception 'NSInvalidArg...

move sprite by using touchmoved in specified regions of screen

hi friends, I am making an application, in that I want to move the sprite in a specified region of the screen, With cocos2d I am not able to make move of sprite, I only know the method -(void)ccTouchMoved:(UITouch *)touches withEvent:(UIEvent *)event, but I don't know how to move a sprite, can any one help me???? Thanks in advance ...

buttons and menu items in cocos2d/objective-c

In my app, I'd like a method called whenever the user taps the screen (anywhere on the screen). Normally, I'd make a transparent UIButton that covers the whole screen. If I'm using the cocos2d framework, what's the best way to do this? Is it good practice to still use UIButtons? I've been reading about MenuItems but haven't found an eas...

How to tell if you touched a CCLabel?

How to tell if you touched a CCLabel? The following code obviously does not work well enough because it only tests for point equality. Naturally touch point will not necessarily be equal to the position property of the CCLabel (CCNode). How to I tell if a Touch point has fallen within the "rectangle?" of the CCLabel? - (void)ccTouches...

Change the background image in cocos2d

Hi all, I am making a game using cocos2d. in that I want to change the background after each second of time. I don't know how to do this in cocos2d. I am having 15 different images and one by one each image will be shown, i.e. after1 second next image will appear. I am new to cocos2d so, If any one can help me??? thank you in advance ...

Is there a way to make an executable from an Xcode project?

Hello, all! I feel it's quite a naive question I'm going to ask. Excuse me if it's foolish. I have made an iPhone game using Cocos2d, Box2d and OpenGL. I want to show the game to a potential employer for demonstration purposes, without giving him the source code. How can I make a .exe or .app file from the Xcode project? I've searched...

Memory management error, using cocos2d for iPhone

Hi, So I'm getting a EXC_BAD_ACCESS error in cocos2d. From what I've been searching so far it's mostly related to attempting to free an object which has already been released. I have encountered this error before, and its solution was simple and pretty much caused by freeing a released object. But now, using cocos2d (not sure if it's a ...

Need some help in runAction method in cocos2d .

I have a small doubt in CCAnimation. Is there any difference between the code1 and code 2 in performance ? code1: id Action1 = [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO]; id Action2 = [CCFadeOut actionWithDuration:0.1f]; id Action3 = [CCCallFunc actionWithTarget:self selector:@selector(...

Memory management in iphone cocos2d

hi guys, i am iphone developer very new to this field....i am developing a ebook app in iphone using cocos2d...i use more than 150 images(i guess) the problem while turning from one page to another images get hanged randomly...... i tried this also [[TextureMgr sharedTextureMgr] removeAllTextures]; but went in vain...i guess the the pro...