cocos2d-iphone

Changing label color of a label in a different layer

穿精又带淫゛_ 提交于 2019-12-13 08:27:15
问题 So I have a scene called MainScene where CCScrollView UpgradesScroller containing layer called UpgradesNew is located. I have a button that when tapped in MainScene , should set hasItem boolean to YES and then when the layer UpgradesNew is unhidden, a labels color should be changed based on the output of the boolean. Here is what I tried. Setting hasItem to true: -(void) buyItem { hasItem = true; } } In MainScene this is the method used when UpgradesNew is unhidden. -(void)Upgrades {

Cocos2D making a isometric hexagonal tileMap

ぃ、小莉子 提交于 2019-12-13 08:18:22
问题 I'd like to create a simple game with an isometric map with Cocos2D, but I can't figure how I should use an hexagonal tile (always isometric) map. Any hints? 回答1: This link is probably your best bet for tile maps using cocos2d. I believe that the cocos2d sample code that comes with it has a hex tile map as well. 来源: https://stackoverflow.com/questions/9531535/cocos2d-making-a-isometric-hexagonal-tilemap

return a class as a layer

做~自己de王妃 提交于 2019-12-13 07:58:13
问题 This question is using cocos2d with xcode , but i think general objective c guys can handle it. I have a class which is a CCLayer and i want to return it as a layer to my main class and show it in there(and all actions happens in that layer class) . so the "other" class is : CCSprite *r; -(id)set { r=[CCSprite spriteWithFile:@"c5.png"]; r.position=ccp(50,50); [self addChild:r z:3]; return self; } and from main class i call it with : recieverCircleLayer *r=[recieverCircleLayer alloc] ; [self

How to properly keep a local reference to a child CCNode in a custom class in ARC

心不动则不痛 提交于 2019-12-13 07:35:21
问题 So, I want to hold a local reference to a child CCNode in a CCNode custom class without creating a retain cycle or without having the compiler complaining that the property or instance variable may be unpredictable set to nil For instance with this custom class @interface MyNode : CCNode @property (nonatomic, strong) CCNode *background; + (id)nodeWithBackground:(id)background; @end @implementation MyNode + (id)nodeWithBackground:(id)background { MyNode *node = [MyNode node]; node.background =

How to combine two cocos2D projects to one app?

喜欢而已 提交于 2019-12-13 06:44:18
问题 I have developed two different games (two different projects), I have been assigned to combine/ merge them to one app. So I am confused about the way that I should follow, should I just add Game2 to Game1 as a third party library or is there a way to change the target at the runtime? Simply Click Button 1 -----> run Game1's MainScene Click Button 2 -----> run Game2's MainScene Followed this Xcode 4.2 how include one project into another one? question and added Game 2 to Game 1 like a static

ApplyLinearImpulse doesnt work when called within UIPanGestureRecognizer function

我与影子孤独终老i 提交于 2019-12-13 06:29:59
问题 I am using Box2d and Cocos2d to develop an iPhone game. I have a ball in the center of the screen with a simple boundary created using fixtures etc. What I want to do is add the functionality so that a user can "swipe" the ball to apply force and basically flick it across the screen. I am using the following code to achieve this: b2Vec2 force = b2Vec2(30, 30); _body->ApplyLinearImpulse(force, _ballBodyDef->position); If I apply a linear impulse during the init function the ball fires off in

How to kill a cocos2d scene directly without replacing scene

可紊 提交于 2019-12-13 06:26:12
问题 I'm starting the game with a UIViewController in this way: navController = [[MyNavigationController alloc] initWithRootViewController:myController]; and when you push the game button the game start the scene in this way: [[CCDirector sharedDirector] runWithScene:gameScene]; ok, now when I want to quit I just replace the UIViewController (because I did the menu with UIKit and the game with cocos2d) with the starting view controller to do the animation I want, it works fine... but obviously the

Cocos2d and UIScrollView

时间秒杀一切 提交于 2019-12-13 06:23:22
问题 I am developing an IPhone cocos2d app with a scene like the the one depicted in the following image (I hope you can see that): On the right there is a vertically scrollable menu contained in a separated layer (menulayer) which is itself contained in the main scene's layer. On the left there is a back button contained in the main scene's layer. I am trying to exploit the UIScrollView as described in this link. However, despite I can see the UIScrollView working I am experimenting some problems

Images won't show up

爱⌒轻易说出口 提交于 2019-12-13 06:18:05
问题 Using cocos2d I put images on desktop and drag them to resource file in my project. It worked before but not any more. Any tips to solve this? The error: 012-08-10 15:30:55.884 again[9753:1be03] cocos2d: Couldn't add image:soundoff.png in CCTextureCache 回答1: Two possible reasons why you could observer that behavior: the filename contains mixed lowercase/uppercase; this is typical, since iOS is case sensitive, while MacOS is not; so, it may happen that it works in the simulator, but fails on

Play background music outside of app bundle using SimpleAudioEngine

孤街浪徒 提交于 2019-12-13 06:12:05
问题 I need to play background music residing in the app's document folder (using hosted content downloads which I put in the document folder after download). It seems that SimpleAudioEngine's way of playing background music is to take a relative path and find it inside the app bundle (CDAudioManager does it): @"mysong.mp3" becomes @"...19E17B5B/myapp.app/mysong.mp3" Which is not helpful because the file saved into the Documents folder looks like this @"...19E17B5B/Documents/mysong.mp3" Edit: It