cocos2d-iphone

How to check whether there is internet connection with the device: cocos-2d

半世苍凉 提交于 2019-12-31 22:26:46
问题 In one of my iPhone app, I need to find out whether there is internet connection with the device or not. Anyone pls help? 回答1: Use Reachability class. if([self checkInternetConnected] ) { NSLog(@"Internet connected\n"); } - (BOOL)checkInternetConnected { Reachability *reachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [reachability currentReachabilityStatus]; return !(networkStatus == NotReachable); } You can get rechability class here : Download

How to check whether there is internet connection with the device: cocos-2d

為{幸葍}努か 提交于 2019-12-31 22:26:33
问题 In one of my iPhone app, I need to find out whether there is internet connection with the device or not. Anyone pls help? 回答1: Use Reachability class. if([self checkInternetConnected] ) { NSLog(@"Internet connected\n"); } - (BOOL)checkInternetConnected { Reachability *reachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [reachability currentReachabilityStatus]; return !(networkStatus == NotReachable); } You can get rechability class here : Download

CCLOG not displaying

假装没事ソ 提交于 2019-12-31 07:30:35
问题 I have written a code to display using CCLog the exact position of a sprite when a mousejoint moving it is released. Below is the Sprite.mm class and the ccTouchesEnded method (which is in the HelloWorldLayer.mm class). The CCLog is not displaying the message. Sprite.mm: -(id)addSprite:(CCLayer *)parentLayer inWorld:(b2World *)world { PhysicsSprite *aSprite = [PhysicsSprite spriteWithFile:@"spriteIm.png"]; aSprite.tag = 1; [parentLayer addChild:aSprite]; b2BodyDef spriteBodyDef; spriteBodyDef

How to change labels text from a button on a CCScrollView?

蓝咒 提交于 2019-12-31 04:59:07
问题 I posted something very similar earlier, but I think the post was confusing so I'm redoing it. Here's the setup. I am using SpriteBuilder. I have 2 CCB classes, MainScene.ccb and Scroll.ccb. The Scroll.ccb is a layer with a button on it. MainScene contains a CCScrollView and a CCLabelTTF. The CCScrollView is loading Scroll.ccb. The CCScrollView takes up half of the interface of MainScene, and on the other half is a CCColor that has the label on it. When I click the button on the CCScrollView,

Cocos2d and SpriteBatchNode: cannot identify which sprite frame is causing an Assertion to fail

久未见 提交于 2019-12-31 03:56:04
问题 I have already asked something similar but I can't figure out properly how to debug this. That's the question. I added some Exceptions handler (catches all Objective-C) exceptions and that's the result of what I see: The problem is with the setTexture method and it fails at the assertion verifying whether the texture name that needs to be displayed is the same as the one in the current sprite batch node. This happens when trying to replace one scene with another but doesn't happen all the

Cocos2D 2.0 OpenGL errors?

只谈情不闲聊 提交于 2019-12-30 15:00:22
问题 In my app it was working fine in Cocos2D version 1.1. When I upgraded to 2.0rc0a, I just see a black screen now and I get the following 4 errors nonstop until I quit the application: OpenGL error 0x0506 in -[CCSprite draw] 532 OpenGL error 0x0506 in -[CCParticleSystemQuad draw] 461 OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 543 OpenGL error 0x0506 in -[CCGLView swapBuffers] 280 So I googled this a bit and it seems that the app cannot find the shader files . What

Facebook posting error in ios

旧街凉风 提交于 2019-12-30 11:13:19
问题 Here i am trying to add a post to facebook using following code. FBAppCall *appCall = [FBDialogs presentShareDialogWithLink:urlToShare name:@"Title" caption:nil description:@"description" picture:nil clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) { if (error) { NSLog(@"Error: %@", error.description); } else { NSLog(@"Success!"); } }]; But this isn't working. It give following error. Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t

Rotate a Sprite on a bezier path with touch - Cocos2D/Box2D

懵懂的女人 提交于 2019-12-30 10:52:54
问题 I have an arrow that I rotate with touch. I was wondering if it was possible to rotate the arrow on a curved line? I've done some research and I think it is called a bezier path? Is it even possible to rotate a sprite on a bezier path using this code and if so how would I even incorporate it? UITouch *touch = [touches anyObject]; //acquire the previous touch location CGPoint firstLocation = [touch previousLocationInView:[touch view]]; CGPoint location = [touch locationInView:[touch view]]; /

What are good reasons to enable 2D projection with cocos2d-iphone?

﹥>﹥吖頭↗ 提交于 2019-12-30 09:58:12
问题 In cocos2d-iphone the default projection type is "3D" projection. But you can also set the projection to "2D" like so: [[CCDirector sharedDirector] setProjection:CCDirectorProjection2D]; Behind the scenes the 3D projection uses perspective projection whereas 2D projection is the OpenGL orthographic projection. The technical details about these two projection modes can be reviewed here, that's not what I'm interested in. What are the benefits and drawbacks of 2D projection for cocos2d users?

constant app memory increase ( IOAccelResource )

人走茶凉 提交于 2019-12-30 09:37:28
问题 I am trying to wrap my mind around an issue (eluded to in this question). The context is: turn-based game, developed with cocos2d version 2.0, obj-c, no ARC, currently prepping an AppStore update to account for some iOS 7 issues (mine, not iOS7). My own instrumentation, as well as Instruments, show no leaks, no abandoned memory, nothing... flat. This also used to be the case under iOS 4,5,6.1. However, in my test rundown prior to submission, when profiling on device, i see a 1Mb increase per