cocos2d-iphone

Member Variable Problems

若如初见. 提交于 2019-12-12 02:44:19
问题 I have a button in Spritebuilder. Characteristics are as follows: Doc root var: _playbutton | Selector: play Target: | Document root Code for the button in Xcode: CCButton *_playButton; - (void)play { CCScene *scene = [CCBReader loadAsScene:@"LevelSelect"]; [[CCDirector sharedDirector] replaceScene:scene]; } LevelSelect is a seperate scene in Spritebuilder. This code worked until I had problems with my Back button, which inhabits scene LevelSelect. To see characteristics, see my "Using

how do I add a menu to an already-made game in cocos2d and box2d for iphone?

送分小仙女□ 提交于 2019-12-12 02:34:53
问题 I have an existing game that I want to have a title screen with a button "play" to the app that loads the game. EDIT: The interface was made in Level Helper 回答1: Here's how you can implement a menu that changes scenes with a transition. In your HelloWorldLayer.m file, add this: -(id) init { if( (self=[super init])) { CCMenuItemImage *menuImage = [CCMenuItemImage itemFromNormalImage:@"yourimage.png" selectedImage:@"Icon.png" target:self selector:@selector(changeScene:)]; CCMenu *menu; menu =

Animate Sprite using color in top to bottom effect

为君一笑 提交于 2019-12-12 02:07:42
问题 How to spread color Top to Bottom using CCTintTo method in sprite. Because i am using CCTintTo method to spread color in sprite. But i want to look like spreading color in top to bottom. What to do for this types of animation. Thanks in advance. 回答1: Yes CCLayerGradient is what you are looking for.By the way what technique you are using for coloring.If you are using CGContextSetRGBFillColor method to fill the sprite color then it would be tricky but if you are using images to fill color then

Detect an open pinch - like UIPinchGestureRecognizer, programmatically in a Box2D/cocos2d world?

佐手、 提交于 2019-12-12 01:58:22
问题 I'm using the UIPinchRecognizer and an open pinch to detect when someone 'pulls apart' a sprite in a Box2D world. If I use UIPinchGestureRecognizer to detect pull aparts, it breaks my mouse joints when two objects are dragged together - which is less than ideal. I've tried to split my problem into two questions - how to detect an open pinch without UIPinchGestureRecognizer and is it is possible to suppress the close pinch. How can I write my own class to detect an open pinch? That is, two

How do I limit touch handling to one layer when layers overlap?

梦想的初衷 提交于 2019-12-12 01:49:17
问题 I have an interesting problem handling touch events in a cocos2D program I’m writing. I have 3 CCLayer sublassed layers in a CCScene: backgroundLayer – z:0 – simple static layer used to display a background image. planetLayer - z:3 – display layer – visualization of data changes are displayed here. gameControlsLayer – z:5 – layer used to display data controllers such as sliders and buttons. I separated the planet and control layers because I want to pan and zoom the planet layer without

How to dynamically create a 2d NSMutableArray with loops

一个人想着一个人 提交于 2019-12-12 01:40:58
问题 I made an original post here At first, I tried to fill up a CGPoint **allPaths. With the first dimension being "a path" and the second dimension being "the waypoint". And I get a CGPoint out of this. For example : allPaths[0][2] would give me the CGPoint of the first path, third waypoint. I successfully did it in plain C with nasty loops. And now I am trying to do the same thing in Obj-C with NSMutableArrays. Here is my code : CCTMXObjectGroup *path; NSMutableDictionary *waypoint; int

How to schedule or call a method at random time interval in cocos2d iphone

那年仲夏 提交于 2019-12-12 00:36:26
问题 I want to call a method at Irregular time interval means it should be random time plus i want it in some define range too. Like : it should call at any second between 3 to 8 . I tried this one : [NSTimer scheduledTimerWithInterval: 1.0 target:self selector:@selector(myMethod:) userInfo:nil repeats: YES]; void mymethod() { if(arc4random() % 10 == 1) { // calling my method here; } } This way , i am not getting randomization which i want. Any one can please help me on this !!! 回答1: Here you can

How can i override ccTouchbegan in cocos2d-android( removal of overlaying sprites)

孤街醉人 提交于 2019-12-12 00:22:52
问题 I have a set of sprite lists.i want to remove the topmost lying sprite if the sprites overlap. if ( popRect1.containsPoint( popRect1, location ) ) { BaloonList1.remove( baloons ); baloons.removeSelf(); } if ( popRect2.containsPoint( popRect2, location ) ) { BaloonList2.remove( baloons ); baloons.removeSelf(); } When two sprites of same list overlap and if i touch them only the topmost sprite will be removed...if 2 sprites are from different list and when i touch the topmost sprite both of

Adding Cocos2d to existing project

你。 提交于 2019-12-12 00:20:11
问题 I would like to appologize in advance however I think this question is overlooked. I have a project I have been working on and I would like to incorporate coco2d. How can I implement the coco2d-iphone-2.0 download. All the tutorials I have tried have either been outdated or left me with errors. I keep getting ARC Semantic Issue and ARC Restriction once I follow steps of other tutorials to add coco2d to an existing project. Thus, could someone be so kind as to put a step but step approach to

Move background - Cocos2D

核能气质少年 提交于 2019-12-11 23:40:09
问题 I am trying to develop a car game in which opponents are coming from opposite direction. And we have to avoid collision. For this I want to move my background as the opponent cars approach the good car. What should I do to move the background? Regards, Stone 回答1: 1.- You need to create a map: example with program "Tiled". 2.- Add to resources 3.- Insert code: CCTMXTiledMap * tmxMap = [CCTMXTiledMap tiledMapWithGMXFile:@"Map.tmx"]; [tmxMap runAction:[CCMoveBy actionWithDuration:1.0 position