cocos2d-iphone

Need help fixing memory leak - NSMutableString

对着背影说爱祢 提交于 2020-01-25 08:05:06
问题 Have been playing around with instruments with not much luck in figuring out how to solve this memory leak. Firstly the code: -(NSString *) randomizeHint:(NSString *) wordToShuffle{ NSMutableString * outputstring = [NSMutableString stringWithCapacity:[wordToShuffle length]]; NSMutableSet * usedNumberSet = [NSMutableSet setWithCapacity:[wordToShuffle length]]; for (int i=0; i<[wordToShuffle length]; i++) { int randomnum = arc4random()%[wordToShuffle length]; while ([usedNumberSet

Cocos2d: How to Align CCLabelTtf vertically with different font size?

守給你的承諾、 提交于 2020-01-17 13:46:30
问题 How to aligh two CCLabelTtf vertically with different font size? Thanks This is how I am creating labels: for (int i = 0; i < 5; i++) { CCLabelTTF *label = [CCLabelTTF labelWithString:@"11km 90m" fontName:@"Limelight.ttf" fontSize:20]; label.anchorPoint = ccp(0.5, 0.5); label.position = ccp((size.width-225)/2 + 30, size.height - (size.height-260)/2 -i * 40 - 28); [self addChild:label]; CCLabelTTF *label1 = [CCLabelTTF labelWithString:@"2013/11/22" fontName:@"Limelight.ttf" fontSize:15];

Cocos2d: How to Align CCLabelTtf vertically with different font size?

自作多情 提交于 2020-01-17 13:46:14
问题 How to aligh two CCLabelTtf vertically with different font size? Thanks This is how I am creating labels: for (int i = 0; i < 5; i++) { CCLabelTTF *label = [CCLabelTTF labelWithString:@"11km 90m" fontName:@"Limelight.ttf" fontSize:20]; label.anchorPoint = ccp(0.5, 0.5); label.position = ccp((size.width-225)/2 + 30, size.height - (size.height-260)/2 -i * 40 - 28); [self addChild:label]; CCLabelTTF *label1 = [CCLabelTTF labelWithString:@"2013/11/22" fontName:@"Limelight.ttf" fontSize:15];

How to fix OALAudio Library for XCode 6 / Kobold2D (Linker Error)

十年热恋 提交于 2020-01-17 08:39:06
问题 trying to update a Kobold2D/Cocos2d 2.1 project for iOS 8.1/XCode 6 on Yosemite. After using the solution provided here (How to update Kobold2D 2.1 project to MacOS10.10 / XCode 6.1?), I get a linker error that, despite all attempts (restarting, cleaning, deleting and adding frameworks) persists, and makes my project unstartable. I'm at my wit's end; this is a 3 year project, and I'm hitting a brick wall... The XCode 6.1 linker error reads as such: Ld /Users/fabian/Library/Developer/Xcode

Adding a Hud Layer to Scene Cocos2d-3

随声附和 提交于 2020-01-17 03:53:05
问题 To keep it simple, what is the easiest way to make the default [ Menu ] in default HelloWorld Scene (for example) as it's own layer. Issue I'm having now is that the scene is completely black, with nothing showing up! GameLayer node: - (id)init { // Enable touch handling on scene node self.userInteractionEnabled = YES; self.theMap = [CCTiledMap tiledMapWithFile:@"AftermathRpg.tmx"]; self.contentSize = theMap.contentSize; self.metaLayer = [theMap layerNamed:@"Meta"]; metaLayer.visible = NO;

How to get absolute positions of touches and layer objects?

假如想象 提交于 2020-01-16 12:18:06
问题 I'm having a weird issue with cocos2d-x when trying to detect which character (currently a CCLayer-extending object) I'm touching. The problem is that the location of the sprite I'm clicking on never matches the touch location that is registered. I've tried different conversion functions but neither of them seem to work. Any idea about how can I detect in ccTouchesBegan where a map (CCLayer) is being touched in the same 'scale' than the characters (also CCLayer's)? How can I get the absolute

Split screen on Cocos2d

十年热恋 提交于 2020-01-16 11:42:13
问题 I'm thinking of developing a game where two players play against each other in a "world" but each have their own viewport following their character (split screen) but I'm not sure how to implement it. This is for Cocos2d. Ideally, the game events would occur in its own CCLayer and the code simply draws different sections of it onto different viewports. However, this doesn't seem to be possible with Cocos2d. The other solution I thought about was having two different layers and keep each in

Split screen on Cocos2d

喜你入骨 提交于 2020-01-16 11:41:57
问题 I'm thinking of developing a game where two players play against each other in a "world" but each have their own viewport following their character (split screen) but I'm not sure how to implement it. This is for Cocos2d. Ideally, the game events would occur in its own CCLayer and the code simply draws different sections of it onto different viewports. However, this doesn't seem to be possible with Cocos2d. The other solution I thought about was having two different layers and keep each in

Why can't I use this sprite in Cocos2d/Objective c?

时光毁灭记忆、已成空白 提交于 2020-01-16 08:06:45
问题 In my game in objective c, I have two classes, The main ArcherClass and the person class. Here is part of the .m of the person class. - (id)init{ self = [super init]; if (self) { _bow = [CCSprite spriteWithFile:@"bpw.png"]; } return self; } Here is part of main ArcherClass.m Player *object = nil; CCSprite *bow; bow = [object bow]; //bow = [CCSprite spriteWithFile:@"bow.png"]; [self addChild:bow z:1]; bow.position = ccp(150,150); The following code gets a sigbart error, because of the part I

Why can't I use this sprite in Cocos2d/Objective c?

允我心安 提交于 2020-01-16 08:06:12
问题 In my game in objective c, I have two classes, The main ArcherClass and the person class. Here is part of the .m of the person class. - (id)init{ self = [super init]; if (self) { _bow = [CCSprite spriteWithFile:@"bpw.png"]; } return self; } Here is part of main ArcherClass.m Player *object = nil; CCSprite *bow; bow = [object bow]; //bow = [CCSprite spriteWithFile:@"bow.png"]; [self addChild:bow z:1]; bow.position = ccp(150,150); The following code gets a sigbart error, because of the part I