cocos2d

"Beveled" Shapes with cocos2d

I would like to draw 2d shapes like this in an iPhone app: I asked a similar question here to see if I could do it easily with Quartz, but didn't get a solution. So I got to thinking that I might be able to leverage an exsiting 2d library out there, and then I thought of cocos2d. The goal is to draw these kinds of beveled shapes dyna...

Tick/Draw Method

I'm looking for the Tick and draw method, and I'm not sure where they are. Do I have to make them from scheduler, if so how? I've heard that the draw method is only called 4 frames per second when 'paused', so does it exist somewhere? ...

iPhone:Learning Cocos2D project

Hello all, I want to learn and develop game using Cocos2D free project in a month. Learning Cocos2D is a bit hard and i don't know how to create my project initially same like Cocos2D project and use the files from Cocos2D project to my project. I doubt whether it is possible? Can i learn and use Cocos2D project itself directly and modi...

Label and LabelAtlas comparison? LabelAtlas is hard to use

Hi everyone I have some confusion about how to use AtlasLabel. It seems Label consume a lot memory than LabelAtlas? Such as if I create 100 line of text. Each of them is created by Label, then will it consume more memory than 100 line of text created by LabelAtlas? Label *label1 = [[Label alloc] initWithString:@"text1" dimensions:CGSi...

iPhone Cocos2d: trying to render a sprite but i am only seeing a white rectangle

I'am trying to make the following code work but I only see white rectangles when rendering them :S; CCSprite *tempSprite = [[CCSprite spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:@"Icon.png"]] retain]; TapCircle *tapObject = [[TapCircle alloc] initWithSprite:tempSprite]; The TapCircle class is a subclass of TapEle...

What would cause a Cocos2d iPhone font to only showing 2/3rds of the letter/number?

I am trying to use this font in a cocos2d iPhone game. The font only shows 2/3rds of the letter/number. If I open the text editor installed with OS X and use the font, the letters appear fine. Any ideas to what may be wrong? Here's the code snippet showing how I display a string using the font: CCLabel* number = [CCLabel labelW...

Rendering overlapping translucent objects without darkening overlap

I'm not sure if there's a name for this, but essentially what I need to do is take two opaque sprites, draw them both at 50% opacity, and where they overlap, don't have it look darker. The image on the left is how it's rendered originally. Then, I want to decrease the alpha of the rendering, and by default, I get the image in the mid...

cocos2d iphone onenter method not being called

i'm using v99.0 onEnter is not being called when my sprite is added to the layer and the layer's scenee is displayed. the sprite appears correctly but onenter is not being called. the funny thing is that i'm doing exactly the same with other sprites and their onenter methods are being called fine. Is this a bug? In app delegate: [[...

iPhone, cocos2d coordinate system

Hi, I've created CocosNode, then inserted sprite in this node. I moved node and sprite separately. As result node has some coordinate, sprite has another coordinate. I see sprite on the screen, but sprite's coordinates are out of the screen borders. So could you please explain how can I convert sprite coordinates to screen coordinates? ...

removing bounce off colliding objects in box2d

Hi, I am trying to delete an object in box2d when 2 object collide. When my 2 objects do collide, one of the object bounces off the other. it does delete the other object, but i want it to make it look like it went through rather than a bounce. I have my body Def type set to b2_staticBody. Any help would be appreciated. ...

How to set the position of a sprite within a box2d body?

Basically I have 2 polygons for my body. When I add a sprite for userData, the position of the texture isn't where I want it to be. What I want to do is adjust the position of the texture within the body. Here's the code sample of where I am setting this: CCSpriteSheet *sheet = (CCSpriteSheet*) [self getChildByTag:kTagSpriteSheet]; CCSp...

action won't run on a CCSprite from within ccTouchBegan in cocos2d for iphone

Hi, I'm trying to basically scale up a button as soon as a touch is detected. Here's my Scene: @implementation HomeScene -(id) init { if((self = [super init])) { ... // sp_btn_story is retained... sp_btn_story = [[CCSprite spriteWithFile:@"main_menu_btn.png"] retain]; sp_btn_story.position = ccp(size.width - 146, 11...

How can I detect two distinct touches

Is there a way to detect just 2 distinct touches? I just want to track the touches for my two buttons, which is a sprite, but whenever I have another touch other than my first two touches, it affects my touch with my button. Is there a way to get rid of that third touch? I wish you could help me with this problem.Thank You! ...

How to get objects to react to touches in Cocos2D?

Alright, so I'm starting to learn more about Coco2D, but I'm kinda frusterated. A lot of the tutorials I have found are for outdated versions of the code, so when I look through and see how they do certain things, I can't translate it into my own program, because a lot has changed. With that being said, I am working in the latest versi...

Cocos2d on iPhone: Using Sprites Defined in Separate Class Files.

I'm trying to draw two sprites on the same screen. I have defined the two sprite objects in two separate class files. If I comment out two lines (see "item 1" comment below) then I get a display as [a backgroundimage[background2.jpg] with a sprite[grossini.png] on the left side. If I uncomment the two lines I do not get the background...

CCLabelAtlas setString doesn't update label

Hello! I have a CCLabelAtlas that I have on a layer to display the current score within my game...the problem that I am having with it is that it does not update when I use [scoreLabel setString:]. Here's how I have it laid out: In the header: @interface GameScene : CCLayer { ... CCLabelAtlas* scoreLabel; } And in the init: score...

Bitmapfontatlas cocos2d performance issue

This question was also asked in the cocos2d forums but they are a little slower than here. Hi, Im trying to resolve a performance issue in my game. I have all of my game images on the one spritesheet. I now have a score label for which i have generated a font file with the Hiero tool. Ideally I'd like to update my score label with th...

Cannot show scene with Cocos2D when using UITabBarController

Hi I'm new to Cocos2D but am having serious issues when trying to load a cocos scene in one of the UIViewControllers mixed with other normal UIKit UIViewControllers. My project uses a UITabBarController to manage four view controllers. Three are normal UIKit view controllers while one of them I want to use cocos2D for (to draw some spr...

UIScrollView and Cocos2D

I have created a UIScrollView in a cocos2d application. I am adding sprites dynamically, over 3 pages. On the first page, touch works perfectly on a sprite, however if I use the scroll view and navigate to the second page, touch does not work quite right... the sprite will respond to the touch when I touch the screen, approximately the a...

How to get the difference between two dates ?

I have two dates in format(MM/dd/yyyy hh:mm:ss:SS). For the both dates I have converted the two dates to strings by using (stringFromDate) method. But I could not get the difference between them and show them in my console. Please give me an idea how I should get it? Thank you. ...