cocos2d-iphone

cocos2d fruit ninja parabola math

主宰稳场 提交于 2019-12-24 15:09:57
问题 i am making a game similar to fruit ninja. birds flying down the water and then up (just like fruits up side down) but some of the birds fly too far and the others too near. can someone check my code? vy should quite close to each other.(vx is not a problem) static float tuna = 10.0f; -(void) reset { float vy = 0.0f; float vx = 0.0f; int sign = 1; if (CCRANDOM_0_1() >= 0.5) { sign = -1; } float hurry = 0.0f; if (CCRANDOM_0_1() <= 0.1) { hurry = 1.0f; } switch (birdType) { case BirdType1: vx =

How to install cocos-2d templates in Xcode 5?

社会主义新天地 提交于 2019-12-24 14:30:41
问题 When i am trying to execute following command from Terminal in Maverick os(Xcode 5) to install templates of cocos2d 3.0 rc-1, I am getting following message. -bash: install.sh: command not found What could be the reason ? Please help by giving some meaningful comments/hint... 回答1: Download Latest Cocos2d. Open the terminal (Don't type anything). Drag the install file (install-templates.sh/install.sh) into the terminal. Finally press enter only. Now,you check the Xcode->New Project there you

Add spriteframe from documents folder in Cocos2D-v2

江枫思渺然 提交于 2019-12-24 14:10:11
问题 I need to add downloaded spriteframe (plist/png set) from Documents folder to the spriteframe cache in Cocos2D v2. I had this codebase working for a long time, but it doesn't work anymore and I just can't figure out right now how to add spriteframe contents that do not exist right down in the root of the bundle. From what it looks like, I used to add the plist/png pair of spriteframes by using a relative path and send that to CCSpriteFrameCache. Something like ../Documents/hosteddownloads

How velocity impacts on CCSprite in Cocos2d Chipmunk?

浪子不回头ぞ 提交于 2019-12-24 14:05:04
问题 I am in need of the basic understanding of how velocity changing works? i.e. how CCSprite is able to jump at particular height when some velocity is set? Let me give you an example on which I am working currently. I am preparing a demo like flappy bird, in which I wanted my bird to land on vertical pipes. So, it is like, my birdy jumps from the pipe to another pipe :smile:. Check the gif I place here: https://www.dropbox.com/s/n46vak6qy5wu4x4/jumpyBall_15_jul_152.gif?dl=0 I am using Sprite

Cocos2d node over uikit element

為{幸葍}努か 提交于 2019-12-24 11:29:27
问题 I've got a CCScene with few UIKit elements [UITextView for example]. After some user interaction I want to open a popup over the scene to also cover part of the UITextView. It doesn't matter what z index I am using, it will always appear under the text view. Any tips on how to do it? 回答1: Your CCNodes are drawn within the EAGLView Cocos is using. You need to manage the order of EAGLView(s) relative to other UIViews. Take a look at http://www.gdcvault.com/play/1012504/The-Best-of-Both-Worlds

Black screen on iPad retina display

青春壹個敷衍的年華 提交于 2019-12-24 10:57:50
问题 I've a problem with a little game application running on iPad. When I lunch the simulator iOS 5.1 with iPad retina display, the application start with my default image @x2 and after show the image go to a black screen. In normal iPad iOS 5.1 simulator run well. Xcode tell me only this: 2012-04-25 14:24:26.978 AppName[83696:10a03] cocos2d: Frame interval: 1 2012-04-25 14:24:26.980 AppName[83696:10a03] cocos2d: surface size: 1536x2048 Any idea? Thank you @Smamim Hossain: Same error I put my

anchorpoint issues with CCUIViewWrapper

孤者浪人 提交于 2019-12-24 10:57:13
问题 I am having some issues understanding and using anchorPoint. As I understand it, the default anchor is (.5,.5) which applies transforms about the center of objects. However, when I placed a UIButton into a CCUIViewWrapper, I noticed that scaling it would scale about the right side of the object (i.e. if I scaled from 0 to 1, it would grow from right to left). I wasn't sure what to make of this, but with tinkering found that I had to adjust the anchor point to (0,0) in order to make scaling

CCNode recursive getChildByTag

烂漫一生 提交于 2019-12-24 10:34:36
问题 As far as I understand the CCNode::getChildByTag method only searches among direct children. But is there any way to recursively find a CCNode's child by tag in all its descendant hierarchy ? I'm loading a CCNode from a CocosBuilder ccb file and I'd like to retrieve subnodes knowing only their tags (not their position/level in the hierarchy) 回答1: One way - to create your own method. Or create category for CCNode with this method. It will look like smth like this - (CCNode*)

cocos2d: LabelAtlas text alignment?

拜拜、爱过 提交于 2019-12-24 10:24:54
问题 Is there a way in cocos2d 0.7.1 to specify the text alignment in a LabelAtlas? I'm using a LabelAtlas for a score (displayed in the upper right corner) but when the score goes above 10, the second digit is cut off. I can implement code to detect that and move the LabelAtlas, but is there a way to have cocos2d do it for me? Thanks. 回答1: While that works, you'll have the same problem if the score goes above 1000. You can use the anchorPosition property to change where the position is defined.

In Cocos2d, with buttons on multiple layers, how can I control which button to react to user's touch?

妖精的绣舞 提交于 2019-12-24 10:04:27
问题 Now I have a CCLayer of gameplay, where there are a few buttons. And I want to pop up a dialog layer, where there are also a few buttons. How can I deactivate the background buttons and only make the foreground buttons activated? 回答1: Use CCMenuItem setIsEnabled method to disable button. 回答2: What about a lot of buttons on gameplay? Disable every button looks like not the best solution... Is it possible to disactivate all buttons in one fell swoop as topic starter requested? 来源: https:/