cocos2d-iphone

cocos2d make object follow the touch/finger

放肆的年华 提交于 2019-12-13 20:35:09
问题 I make my first app with cocos2d, so I am very new here my first problem: I wont to make the object (boat) to follow my finger. -(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint location = [self convertTouchToNodeSpace: touch]; NSLog(@"location X: %f", location.x); NSLog(@"location Y: %f", location.y); if(startGameButtonIsPressed == YES) { [boat runAction: [CCMoveTo actionWithDuration:1 position:location]]; } } It do follow but it is not fluid. If I move my finger

strange problem playing cocos2d animation from another class?

随声附和 提交于 2019-12-13 20:22:23
问题 strange thing. if someone could please,please help me. its 3 days, and i think i am going to be fired :( i have cocos2d class with animation function,and another xcode class. if i call from the cocos2d class init function to animation function, the animation is being played when app is starts. if i call from another class to the cocos2d class-animation, so it does the init function and enter the animation,but i cant see it playing. so the animation is working only if called from within the

Gameplay Crashes From ipa file but runs fine from Xcode?

丶灬走出姿态 提交于 2019-12-13 18:00:46
问题 It is somewhat an awkward situation right now. When I run my project directly from Xcode to my device it runs perfect without any crashs. But when I create an ipa file of that project and install that ipa into my device by using iTunes, only for the first time when I launch my gameplay screen it crashes, later on when I starts my gameplay it runs fine. Remember, my gameplay starts after the user navigates 2 initial screens which works pretty fine in either conditions. (i.e running from Xcode

What exactly is the available file suffixes for Cocos2D, used for multi resolution support?

时间秒杀一切 提交于 2019-12-13 17:16:29
问题 I've been searching around for a while, but it's been hard to find a definit list of available suffixes which you can use for multi resolution support, if there is any? That is, loading images in a dimension depending on what device you're on. Especially for the interface. I know that the "-hd" suffix exists for ipad retina display support, but besides that it would also be nice if there is any suffix for regular iPad resolution as well as an iPhone suffix when the game is loaded on an iPhone

Cocos2d - Changing animations after one is over

二次信任 提交于 2019-12-13 16:11:37
问题 I've got a CCSprite with three animations: idle, walk and attack. I want to switch between idle and walk depending on whether or not the sprite is moving (if the joystick is beeing used). All of this works great. For the attacking animation, I want it to run once, and then return to the previous animation when done (ex.: idle) how do I detect when the animation is done? thanks, Dave 回答1: Alright, so here's what i've done, and it works, although I have no clue if its the right or the best way:

Change UIAlertView size

会有一股神秘感。 提交于 2019-12-13 16:00:32
问题 In my cocos2d game i can't change size of uialertview, i have changed statusbarorientation to landscape, and now want to init alertview with frame, and initwithframe method does not affect the size of alertview, every time the size of alert is the same, is there any way to change it ? 回答1: Here is what i did. Create your uialertview in your controller. then override the following class within your controller (after setting the uialertview delegate ... ie. myalertview.delegate=viewcontroller)

How to check the iPhone language settings?

心不动则不痛 提交于 2019-12-13 15:29:50
问题 I'm localizing my app which is cocos2d so there are no nib files, I'm localizing a label which is fine but want to check the device language to set an exact font and font size for each language. In short I want to do it as the following: If (device.language == en) { Set font to "fontname" and "fontsize" to x; } else { set it to "another font name" and font size to y; } How to check that the device language/settings is set to an exact language? 回答1: You can use: [[NSLocale preferredLanguages]

Subclassing bound type in mono touch

蹲街弑〆低调 提交于 2019-12-13 14:53:53
问题 I have an issue when I subclass a type which bind an obj-C type. In some cases, it fails at construction time. I can reproduce this right now with the cocos2d bindings and CCSprite. Here's my subclass public class MySprite : CCSprite { public MySprite (string filename) : base (filename) {} } When I instantiate it, it fails: Stacktrace: at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr) <IL 0x00025, 0xffffffff> at MonoTouch

How to detect collision of sprite in cocos2d [closed]

半世苍凉 提交于 2019-12-13 12:52:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . i want to detect collision of a sprite with another sprite. but i want to check whether the sprite is touched with left part of other sprite or touched with right part of sprite. i am using below code for detecting collision. but this detect the overall collision(sprite touched to at any point of other sprite).

Find destination position of ball

跟風遠走 提交于 2019-12-13 10:29:31
问题 How to move the ball dependent on touch angle and make the ball reflect if it touches the wall? CGFloat diffX = ballImg.position.x - tchLoc.x; CGFloat diffY = ballImg.position.y - tchLoc.y; CGFloat angleRadian = atan2f(diffY, diffX); float angleDegrees=CC_RADIANS_TO_DEGREES(angleRadian); 回答1: I am considering that you have taken your ball as a sprite. so in touchesBegan you will get the touch location and then you can use that location points in CCMoveTo action to move your ball which is a