cocos2d

Cocos2d iPhone: Rotate Sprite using Accelerometer

Hi, I'm trying to rotate a sprite using the accelerometer. when I tilt right, I want him to rotate slightly to the right, and when I tilt left, I want him to rotate slightly to the left... Thanks in advance, Reed ...

[Cocos2d] Pros and cons of using CCUIViewWrapper versus a ported functionality

I'm trying to understand the pros and cons of using something CCUIViewWrapper in Cocos2d versus a ported functionality. For instance, would it be better to use a UITableView in a CCUIViewWrapper, or to use the CCTableViewSuite. At first glance, I would assume the wrapper is the better approach since presumably it allows me to do everyt...

How can I reset cocos2d game state?

I am not entirely sure how to properly phrase this question so I'll explain what happens. I have a cocos2d game, and after I exit the game and start it again, it starts at the exact same point. Its as if it is "saving." Is there any way to prevent this? Thanks ...

cocos2d particle effects not appearing

Hi All Im just having an issue with particle effects not appearing all the time. Im coding using objective c and cocos2d for the iphone. Below is the code in question. CCParticleExplosion *emitter; emitter = [[CCParticleExplosion alloc] initWithTotalParticles:30]; emitter.texture = [[CCTextureCache sharedTextureCache] addImage:...

Cocos2d From iPad to iPhone

Hi there, I currently have an iPad application built entirely on Cocos2D and Chipmunk. I want to port my app to the iPhone now. All I can find are tips on how to rebuilt your app for the iPad. Is there a simple solution, like for say, scale down your cocos2D scene? Does anyone have some best practice tips on this? ...

App crashes on backgrounding because of SimpleAudioEngine

So I׳m trying to play some effects in my Cocos2D game using SimpleAudioEngine , but after I have added them my app crashes when it goes to background (multitasked). I searched for this problem in the internet but all the solutions that I found didn't work for me. What I did find out is that this problem happens because my app is somehow ...

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...

Disabling user interaction on CCSprite or CCScene in cocos2d for Iphone

Hello, I am developing a game on Iphone using cocos2d. I have a CClayer containing 20 CCSprite. I am playing a sound and I would like to disable the touch events on all the CCSprite or on the entire layer while the sound is playing. I looked at the property of CCLayer called isTouchEnabled but the behavior doesn't propagate to the chil...

iPhone cocos2d - Use the same animation actions for many sprites

Hey, I'm writing game for iPhone, using cocos2d framework. I have 100 sprites and I want to run on them the same animation. Do I have to create 100 separate actions for each sprite, or can I create one action and use it on every sprite? ...

How to create iPad Application in cocos2d

Hi, I am new to iphone game development, i have recently install cocoas2d. But the problem i whenever i search it always result in iPhone game tutorials. I want my game to use iPad screen resolution. Thanks Inam ...

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...

Objective-C: Passing a selector to an object

Hey, I'm implementing a button class in cocos2d, and I want to be able to pass the selector when the button is created. Here is Button.m: #import "CCButton.h" @implementation CCButton +(CCButton*) buttonFromImage:(NSString*)image selectedImage:(NSString*)selectedImage atPosition:(CGPoint)position selector:(SEL)selector_method { ...

[Cocos2d] anchorpoint issues with CCUIViewWrapper

I am having some issues understanding and using anchorPoint. As I understand it, the default anchor is (.5,.5) which applies transforms about the center of objects. However, when I placed a UIButton into a CCUIViewWrapper, I noticed that scaling it would scale about the right side of the object (i.e. if I scaled from 0 to 1, it would g...

Cocos2d MenuItem Selector and Accessing Instance Variable

I have an instance variable declared in the implementation file which can be accessed using the property defined by synthesize @synthesize myProperty Now, I want to assign this property something inside the Selector event of the MenuItem in cocos2d library. You can think of it as a accessing myProperty in a callback function. For som...

Problem with touches after closing OpenFeint windows

I've got a problem with registering touches in cocos2d game. Generally they work well with my layer (scene), however, when it is displayed after the OpenFeint dialog, the touches are not coming through. The touches are enabled in onEnter: -(void) onEnter { [super onEnter]; self.isTouchEnabled = YES; [[CCTouchDispatcher sh...

Is it better to preload all the sound files before the start of the game?

Hi, I am building a game with 20 levels and have around 15 music files. Currently I am preloading all the 15 sounds using cocos denshion at the start of the game. However the game crashes after a few levels. I get a 'Program received signal: “0”. Data Formatters temporarily unavailable' error. I assume this is because of lack of memory ...

Showing iPhone Keyboard Eats Large Memory Chunk

Hi all, I've seen several posts with people having this issue but no solutions. Basically clicking a UITextField to show the keyboard for the first time eats up ~4mb of memory (according to the activity monitor) and I never get that memory back (and I need it back :P). I know that UIKit will often take up a large chunk of memory for t...

Iphone Cocos2D - SpriteSheet Cocos2D (so confused...)

I have gotten 0 response from the Cocos2D board so thought Id try here. Ok. Im ripping out my hair over this. I did a complete re-haul of my code last night in hopes of fixing some iphone4 framerate issues. I created sprites in advance instead of doing some of the creation during the update methods. I only add them to the spritesheet no...

[cocos2d] detecting a touch anywhere without interfering with app

I'd like to be able to know when any location on the screen is touched so I can show an effect. I don't want to capture the input or otherwise interfere with it, though. I tried setting my scene as a targetted delegate with swallowsTouches to NO but it wouldn't capture the input when I touched a CCMenu I had on there. I then tried cre...

How to add a new line character to a string using a custom font in cocos2d?

How do you add a new line character to a string when using a custom font in cocos2d? I have my atlas font and i tell i put the new line character into it and then tell it what font to use. CCBitmapFontAtlas *text = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Something\nSomething else " fntFile:@"generic_font.fnt"]; In the .fnt fil...