cocos2d-iphone

Game crashes when I try to destroy a b2Body, what should I do?

我只是一个虾纸丫 提交于 2019-12-22 12:32:29
问题 "Assertion failed: (m_bodyCount < m_bodyCapacity), function Add, file libs/Box2D/Dynamics/b2Island.h, line 65." That is what it the crash leaves in the console. [self removeChild:(CCSprite*)body->GetUserData() cleanup:YES]; body->SetTransform(b2Vec2(30, 30), 0); //moving the body out of the scene so it doesnt collide anymore! world->DestroyBody(body); I think im doing the right stuff.. @property (nonatomic, assign) b2Body *body; Here is how i "make it" a property I dont understand why it

Is there anyway to have a the menu work even when I pause the game?

£可爱£侵袭症+ 提交于 2019-12-22 12:19:34
问题 So I am making a menu: CCMenu *menu = [CCMenu menuWithItems:addThing1, addThing2, addThing3, nil]; [menu alignItemsVertically]; [self addChild:menu]; It works fine, but I also want to pause the game when this happens, so I do this: [[CCDirector sharedDirector] pause]; So, this works too, but the problem is that when I pause the game, it pauses the menu too. Is there anyway for this not to happen? It seems to me that its counter intuitive to pause the menu too... But anyways: Is there a way to

How can I display the anchorpoint for a CCNode in cocos2d?

≯℡__Kan透↙ 提交于 2019-12-22 12:09:07
问题 Is there a way to display a CCNode's anchor point? This would be very useful for debugging. 回答1: Not built-in, but you could draw a point or circle at the anchor point location using the anchorPointInPoints property. -(void) draw { [super draw]; ccDrawCircle(self.anchorPointInPoints, 20, 0, 8, YES); } Of course, I always recommend not to change the anchorPoint in the first place. The alternative is to add the node to a parent node, offset it from the parent, and then the parent's position

Update Label Value in Cocos2d

杀马特。学长 韩版系。学妹 提交于 2019-12-22 11:30:49
问题 I am making a game in cocos2d , In that while updating score the old score values get on the label and the new value get overwritten. I m using following code to display the score, LblScore = [CCLabel labelWithString:[NSString stringWithFormat:@"%d",score] dimensions:CGSizeMake(100, 300) alignment:UITextAlignmentCenter fontName:@"Arial" fontSize:32.0]; Because of this the score value are not shown and all things get massed up, If any one having idea how to update new score? 回答1: I don't

How to make an iphone and iphone4-retina compatible app (done in cocos2d) easily adapted to ipad?

六眼飞鱼酱① 提交于 2019-12-22 11:28:08
问题 My question is simple: 1. I made an iphone app all done in cocos2d. 2. I adapted it to iphone4-retina, with all PNG files have their -hd copy. Run in iPhone, the app displayed correctly (320x480). Run in iPhone4-retina, the app also displayed correctly (640x960). But run in iPad, if the app is set to iPhone only, it run correctly, but only as iPhone resolution (320x480). If the app is set to iPhone/iPad, of cause it will display wrong. I'm sure there should be an option that force a retina

How to move background images infinitely in iOS coco2d

别说谁变了你拦得住时间么 提交于 2019-12-22 09:41:07
问题 I have to move background images in iOS Coco2d but I am having a few difficulties. I have tried some solutions provided on some websites but have not been successful in getting them to work properly. Below is the code I am currently working on:- The background moves smoothly the first time but it is not working properly after that:- Code in init function :- bg1 = [CCSprite spriteWithFile: @"bg1.png"]; bg1.anchorPoint = CGPointZero; [self addChild:bg1 z:-2]; bg2 = [CCSprite spriteWithFile: @

OpenGL ES 1.1 to 2.0 a major change?

白昼怎懂夜的黑 提交于 2019-12-22 06:44:44
问题 I'm creating an iPhone app with cocos2d and I'm trying to make use of the following OpenGL ES 1.1 code. However, I'm not good with OpenGL and my app makes use of OpenGL ES 2.0 so I need to convert it. Thus I was wondering, how difficult would it be to convert the following code from ES 1.1 to ES 2.0? Is there some source that could tell me which methods need replacing etc? -(void) draw { glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_TEXTURE

How to stop the forces acting on a body in box2d

此生再无相见时 提交于 2019-12-22 03:16:06
问题 I am using box2d on the iphone to create a game. I have a body that is effected by gravity to move down and not right or left. It will get hit by another body and will then be moving right or left. I then have a reset button which moves the body back to its starting point. The only problem is that it is still moving right or left. How can I counteract the forces that a ball is already traveling? How can I get rid of this right and left movement when I reset my game? 回答1: box2d automatically

How to stop the forces acting on a body in box2d

爱⌒轻易说出口 提交于 2019-12-22 03:16:06
问题 I am using box2d on the iphone to create a game. I have a body that is effected by gravity to move down and not right or left. It will get hit by another body and will then be moving right or left. I then have a reset button which moves the body back to its starting point. The only problem is that it is still moving right or left. How can I counteract the forces that a ball is already traveling? How can I get rid of this right and left movement when I reset my game? 回答1: box2d automatically

Converting Flash Animation to Cocos2D

我的未来我决定 提交于 2019-12-22 00:27:44
问题 Abstract What I require is a technique, given a single, but layered Flash animation, to export the position and rotation of each key movie clip in every frame as XML. Code to read in this information into a cocos2d-ready format would save a lot of time but isn't necessary as I know how to achieve this. Our artists often draw vector using Flash and have wonderful and impressive animations. Our technique in the past to put this art into our games is to export the separate animations as a