cocos2d-iphone

Intersection Between 2 lines in COCOS2D

泄露秘密 提交于 2020-01-16 00:52:05
问题 I am developing a game using COCOS2D. In my game, there are 4 points, each point is connected with each other by one line. When user moves the point, the lines move with the point. At the time of moving, if a line intersects with another line, line color should become red. How can I do this, i.e. line to colored red? And how to detect the intersection of two lines? Can anyone help me to solve this intersection problem in COCOS2D? 回答1: You can detect whether 2 segments intersect using this

Game music does not resume when the player returns to the game after turning off iPhone/iPod music

我们两清 提交于 2020-01-15 14:49:19
问题 I want to be able to allow players to listen to their iPod/iPhone music while playing the game. I use use the following to enable that: -(void)applicationWillResignActive:(UIApplication *)application { [[CCDirector sharedDirector] pause]; [[CDAudioManager sharedManager] setResignBehavior:kAMRBStopPlay autoHandle:YES]; } This pauses the background music and allows the sound effects to play. So far works perfectly. But the problem is, when the user goes out of the game, stops the iPod/iPhone

CCSpriteFrame warning..AnchorPoint won't work as expected.Regenerate the .plist?

一笑奈何 提交于 2020-01-15 10:30:10
问题 i have three simple images of a hen which i am trying to animate(hen walking) using a very good tutorial by ray wenderlich http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d but i am getting this warning again and again and no sprite shows up on the screen original Width/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist i tried resizing and untrimming but the erro persists...i cannot figure out the problem??

Cocos2d iPhone CCClippingNode doesn't do the clip

半腔热情 提交于 2020-01-15 09:14:15
问题 Here are my code how I am trying to draw an image and a hole on it. (The code is from the cocos2d test project) CCSprite *target = [CCSprite spriteWithFile:@"blocks.png"]; target.anchorPoint = CGPointZero; target.scale = 3; CCClippingNode *outerClipper_ = [[CCClippingNode clippingNode] retain]; outerClipper_.contentSize = CGSizeApplyAffineTransform(target.contentSize, CGAffineTransformMakeScale(target.scale, target.scale)); outerClipper_.anchorPoint = ccp(0.5, 0.5); outerClipper_.position =

What collision detection method to use with hand drawn surface?

孤街浪徒 提交于 2020-01-15 06:26:42
问题 I have a lunar lander type game. I don't use any physics engines. My lander keeps falling if you do not use thruster and eventually lands on the ground. Ground is hand drawn, it is not a line, more like curve, and the land can be of any configuration or color. How do I properly use collision detection and its results? 回答1: Well it depends on what you want to do. I would recommend one of the following: Use physics engines. They are there for something. You could create different shapes what

rewrite the code cocos2d (objective-c) on cocos2d-x (c++)

早过忘川 提交于 2020-01-14 06:55:09
问题 Now rewrite the code from cocos2d (objective-c) to cocos2d-x (c + +) and collided with a problem: I have two classes, two CCLayer. In one class there CCMenu by pressing the button calls the second class: CCMenuItem * button = [CCMenuItemImage itemWithNormalImage: @ "1.png" selectedImage: nil block: ^ (id sender) { HelloWorldLayer * helloWorldLayer = (HelloWorldLayer *) [self.parent getChildByTag: 777]; [helloWorldLayer createSprite: self]; }]; And in the second grade, I assign Layer tag: self

How to create a new UIView programmatically in cocos2d?

前提是你 提交于 2020-01-14 04:23:11
问题 I want to create a new UIView on button click programmatically in cocos2d. Kindly help me with some sample code. Thanks in advance. 回答1: You have to create a button like- UIButton* myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.frame = CGRectMake(30, 70,100,38); //set frame for button [myButton setTitle:@"subview" forState:UIControlStateNormal]; [myButton addTarget:self action:@selector(buttonClicked:)forControlEvents:UIControlEventTouchUpInside]; Or you can use CCMenu as a

How to move point along circle?

一曲冷凌霜 提交于 2020-01-13 19:46:20
问题 I want to move a sprite in a circular motion by using a circle radius and movingangle. I know for instance that the sprite is moving in a circle with the radius 10 and It's current position is (387,38) and angle is 28 degrees. Now I wann't move it say, 100px along the circle perimeter. p1 = x&y coordinate, known (387,38) in example with movingangle 28 degrees r = radius, known (10 in example) l = distance to move along bend, known (100px in example) p2 = new point, what is this x and y value?

Requirements for learning Cocos2D?

旧巷老猫 提交于 2020-01-13 12:04:12
问题 I would like to make a 2D iPhone game, I've done some research and Cocos2D does seem like the best option, I am just wondering how much knowledge of Objective-C I will need before tackling Cocos2D. I know the fundamentals of programming in Objective-C - I can make a basic command line tool app. I've done some iOS SDK tutorials but I wouldn't know how to make an iOS app if I was asked because the tutorials I'm currently following are about three years old. What is required as prior learning

How to create single tile map for Universal(iPhone,iPad) for cocos2d?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 07:21:49
问题 Is there any possibility to create a single tile map that can be used for iPhone(Normal&Retina) and iPad. If Can't what is the alternative? 回答1: I also encountered this dilemma, and after a night of finding solutions, this is what I've found out. You only need ONE .tmx file, and it should just be for the non-iphone resolution. If you'd like to support all iOS devices, you'd have something like this in your Xcode Project: TileMap.tmx TileAtlas.png TileAtlas-hd.png TileAtlas-ipadhd.png TileMap