objective-c,cocos2d-iphone,cocos2d,cctexturecacheRelated issues-Collection of common programming errors


  • user1765037
    objective-c xcode sup
    I am a beginner in native development.I made a project using xcode in objective C.It builded successfully.But when I run the project ,an error came like ‘unrecognized selector sent to instance’.Why this is happening ?can anyone help me to solve this?I am attaching the error that I am getting with this..And I am posting the code with this….ConnectionController.m#import “ConnectionController.h” #import “SUPApplication.h” #import “Flight_DetailsFlightDB.h” #import “CallbackHandler.h”@interface C

  • Brock Woolf
    objective-c cocoa cocoa-touch nsstring
    I have an NSString like so:@”200hello”or @”0 something”What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @”200hello” would become int = 200.and @”0 something” would become int = 0.

  • Bartosz Ciechanowski
    objective-c lambda objective-c-blocks continuations structured-programming
    When using methods which return blocks they can be very convenient. However, when you have to string a few of them together it gets messy really quicklyfor instance, you have to call 4 URLs in succession:[remoteAPIWithURL:url1 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){[remoteAPIWithURL:url3 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){//succes!!!}];}];}]; }];So for every iteration I go one level deeper, and I don’t even handle errors in the nested

  • Davoda
    ios objective-c facebook-graph-api facebook-ios-sdk
    I have a token but keep getting this error: “An active access token must be used to query information about the current user.” Any help is appreciated 🙂 NSLog(@”TOKEN : %@”,[[FBSession activeSession] accessToken]);NSString *picture = [NSString stringWithFormat:@”http://www.prowebdev.org/WooF/API/OpenGraph.php”];NSString *image = [NSString stringWithFormat:@”http://www.prowebdev.org/WooF/API/upload/356.jpg”];NSString *imageBool = [NSString stringWithFormat:@”true”];NSMutableDictionary *myDiction

  • Rakhe Kara
    ios iphone objective-c cocoa-touch
    Actually this crash is not reproducing every time, even not frequently but we got this crash in our production app. I am not sure where is the problem. It is telling crash is happening in thread 4 in Environments class line number 38.Code:NSBundle* bundle = [NSBundle mainBundle];NSString* envsPListPath = [bundle pathForResource:@”Environment” ofType:@”plist”];Line 38: NSDictionary *environments = [[NSDictionary alloc] initWithContentsOfFile:envsPListPath];But according to exception type:00000020

  • Musterknabe
    ios objective-c
    I have the following problem. I have a Model, called User. When the user now logins with Facebook, my app checks if the user exists already in the database. To not freeze the UI (since I’m coming from Android) I thought to use NSURLConnection sendAsynchronousRequest. What worked at first was the following:My User Model had a method to do the whole task of the AsynchronousRequest and then when finished would set a variable to loading. Then other classes, could simply check with while ( !user.loa

  • Andy
    ios objective-c unity3d
    I have a very tiny Objective-C library built for iOS and I want to export it to Unity. I understand the basic process of writing a csharp wrapper that marshals all the invocations to native library, but I completely have no idea where to start. Could anyone please explain step-by-step how to create a unity package with my library so I could also distribute it to other developers.Unity3d documentation is pretty brief and does not explain anything.Thanks.

  • Josh Bradley
    objective-c sockets bsd-sockets
    Ok, I have a problem with building a socket using Objective-C. If you’ll take a look at my code below, through help with example code and other sources, I was able to build a complete socket I believe. The problem is that when I compile it, it builds fine (no syntax problems), but there are no sockets being created. As you’ll notice I’ve commented out a lot of things in Server2.m and have isolated the problem to the very beginning when I create the struct for the listeningSocket. By the way, if

  • zioolek
    objective-c cocoa nsimage pgm
    Hi everyone! It is my first post here.I am quite new in objective-c so maybe my question is not so hard but It is a problem for me. I’ve searched the web and didn’t find any useful hints for me… I am writing a program in Objective-c in Xcode. I need to read and display a pgm file (P5 with two bytes per pixel). To do that i’m trying to subclass NSImageRep but I don’t know how to create a proper bitmap for this file and how to draw it. Below is my code so far:header:@interface CTPWTPGMImageRep :

  • Todd Ditchendorf
    objective-c xcode frameworks compiler-errors parsekit
    I am trying to add the Parsekit framework to my OSX Xcode project. I’ve never added a 3rd party framework before and I can’t get it to work right.I dragged the included Xcode project into my ‘Groups & Files’ pane and chose to Add it to my project. I then dragged Parsekit.framework underneath the Link Binary With Libraries heading. Then I double-clicked my target app and added Parsekit as a Direct Dependency. I also added libicucore.dylib as a Linked Library (as it says to do this on their si

  • Waneck
    iphone ios opengl-es cocos2d-iphone antialiasing
    I am new to opengl programming, but I am doing something very basic, and the difference of quality between a custom opengl code and cocos2d is huge!I am trying just to load an image and continuously rotate it every frame. With my code, I get a lot of flickering, sharp edges, while cocos2d has it all nice and smooth. I’ve set up 4x Multi-Sampling Anti-Aliasing using apple’s recommended code for iOs 4 on my code, and still it looks very bad in comparison to cocos2d without any MSAA.You can see the

  • rmaddy
    xcode opengl-es cocos2d-iphone
    I’ve created an iPhone game which utilizes some code from an old version of the Cocos2D iPhone game development framework and I’ve got a wee bit of a problem running it on iOS 7.The version of Cocos2d from which the code was used was probably 0.98.The actual class is called QuadParticleSystem (in newer versions it’s been deprecated by CCParticleSystemQuad).The actual issue is that the game runs fine on iOS 6 and below. It even runs fine on iOS 7 if the deployment target is set to iOS 6.0 and SDK

  • Stephane Delcroix
    cocos2d-iphone monotouch xamarin.ios
    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 subclasspublic 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.Cocos2D.CC

  • dropcode
    c++ cocos2d-iphone box2d box2d-iphone
    I don’t know much C++ and I am trying to implement a solution I found – (Getting the world’s contactListener in Box2D) using Cocos2d-box2d. Here is the Contact Listener.SubcContactListener.h:#import <Foundation/Foundation.h> #import “cocos2d.h” #import “Box2D.h” #import <vector> typedef std::pair<b2Fixture*, b2Fixture*> fixturePair; typedef std::vector<fixturePair> thingsThatTouched;extern thingsThatTouched g_touchingFixtures;class SubcContactListener : public b2ContactLi

  • James Webster
    cocos2d-iphone callback game-physics chipmunk
    I’m using Cocos2d v3 and want to change a body from dynamic to static after colliding with another body. At the moment I’ve got:-(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB {_player.physicsBody.type = CCPhysicsBodyTypeStatic; }or-(BOOL)ccPhysicsCollisionPreSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB {_player.physicsBody.type = CCPhysicsBodyTypeStatic;return YES; }but neither works. I get

  • Guru
    objective-c cocos2d-iphone core-audio simpleaudioengine
    I read about preloading sounds in SimpleAudioEngine through [[SimpleAudioEngine sharedEngine] preloadEffect:@”bell.wav”];But, with this there are memory leaks which I read on couple of sites. On some websites it was used like this: –(void)loadSoundFilesInBackground {NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];[[SimpleAudioEngine sharedEngine] preloadEffect:@”bell.wav”];[pool release]; }What is the best way to load sound files in background through SimpleAudioEngine ? What is the

  • Just Kidding
    cocos2d-iphone
    cocos2d-iphone 1.0.1.I have noticed this with other cocos2d-iphone games installed in my device, like Kingdom Rush.Basically, most of the times, the audio is fine (almost always). But suddenly, at an unexpected moment, the background music stops playing and only the sound effects work. Sometimes, killing the application will not be enough to fix it.With my cocos2d-iphone game this happens as well, with no hint in the console. I use SimpleAudioEngine to play background music and sound effects.Kil

  • Tiddly
    iphone ios cocos2d-iphone cocos2d
    I’m using cocos2d for iOS. Not sure if I’m doing something wrong here or if CCParallaxNode does something strange that I just don’t understand.I’m trying to create a few layers of parallax scrolling in the background of my game, at the moment I just have one layer added to the parallax node till I can figure out what’s going wrong. When the game loads the layer it’s always offset down and left by about 30% of the image size. I’ve uploaded an image demonstrating the difference in position here ht

  • kender
    iphone cocoa-touch memory-management cocos2d-iphone
    I have an iPhone application in Cocos2d that sometimes crashes on actual device, due to memory problems. What I have so far found out is that the scenes, when switched, aren’t fully released – the [retainCount] for them is somewhat about 4-10 🙂 The dealloc method never gets called, and then I assume, when I switch the scenes a few times, the memory issue shows up. I’m wondering – where should I relese the scene? Since it has number of children, I suppose I should be doing a cleanup-removal of t

  • LearnCocos2D
    cocos2d-iphone uialertview
    I am trying to lay buttons on top of a background image for a UIAlertView in Cocos2d. Its not working with the code below. any suggestions?UIAlertView *Win=[[UIAlertView alloc] initWithTitle:@”You Win” message:nil delegate:self cancelButtonTitle:@”Next” otherButtonTitles:@”Replay”,@”Quit”, nil];UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-50, -30, 400, 300)];NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathCom

  • Ricardo Cerqueira
    ios xcode crash cocos2d adhoc
    my app runs fine on development mode, but for some reason on ad hoc i get a crash right after loading screen.I really can’t understand what could be wrong, any tips on how to test it better?Apple rejected it with this message:We found that your app failed to launch on an iPhone 5 and iPad 3rd gen running iOS 6.1.3, on both Wi-Fi and cellular networks.We encountered the issue when selecting the application on the Home screen – the app displayed a launch image then quit unexpectedly. This may be b

  • Clever
    ios objective-c cocos2d
    How would you go about protecting a shared resources in cocos2d so that only one class or method is allowed to access or change it at one time? My initial though was to setup a class that handles Lock / Unlock coordination as follows: – (BOOL)requestLock {if (self.lockAvailable == YES) {self.lockAvailable = NO;return YES;}return NO; }- (void)returnLock:(CGFloat)time {self.timer = 0;self.timeToUnlock = time; }- (void)update:(CGFloat)dt {self.timer += dt;if (self.timer > self.timeToUnlock) {sel

  • ohthepain
    android c++ eclipse cocos2d
    I am new to Eclipse/Android. I have a cocos2d-x project and have added Box2D based on the responses to http://www.cocos2d-x.org/boards/6/topics/20827.When I do Project/Clean/(Clean all projects) I getClean: box2d_static [armeabi]rm -rf (TARGET_OBJS)/bin/sh: -c: line 0: syntax error near unexpected token `(‘I haven’t been able to find the rm -rf (TARGET_OBJS) line in any shell scripts, so I have no idea where this error is coming from.My hunch is that I may be mixing up a copy of the Box2D source

  • Tiddly
    iphone ios cocos2d-iphone cocos2d
    I’m using cocos2d for iOS. Not sure if I’m doing something wrong here or if CCParallaxNode does something strange that I just don’t understand.I’m trying to create a few layers of parallax scrolling in the background of my game, at the moment I just have one layer added to the parallax node till I can figure out what’s going wrong. When the game loads the layer it’s always offset down and left by about 30% of the image size. I’ve uploaded an image demonstrating the difference in position here ht

  • user2225302
    xcode cocos2d malloc
    I’ve got a big project on cocos2d with ARC enabled. Some days ago I began to get theese strange errors:outfighter(16344,0×601000) malloc: * error for object 0x1c8eaa00: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debugoutfighter(16359,0x3afe8b78) malloc: * error for object 0x1c5da4e4: incorrect checksum for freed object – object was probably modified after being freed. * set a breakpoint in malloc_error_break to debugoutfighter(16374,0×705000) malloc: * erro

  • Paul Renton
    objective-c data-structures cocos2d
    Some Context: In my destructible terrain library for Cocos2D, one of the features is collapsable terrain. In order to collapse efficiently, I store the columns whose pixels have been altered in a NSMutableSet which contains NSNumbers which contain integers. I am using this data structure because I don’t want to iterate over duplicate columns.My first instinct for how to loop through the NSMutableSet was to use a ‘for in’ loop.for (NSNumber * col in [alteredColumns allObjects]) { // Works // for

  • jason white
    ios cocos2d
    I have several custom obects inside the coco2d environment that needed to be retained. so I set @property(nonatomic, assign) int score;@property(nonatomic, assign) Object *obj1;inside my CCLayer scene, I synthesize score and obj1, during the init function I set the value for score, and obj1, however later on , I find score and obj1 have no value or not assigned score=0; and obj1 = 0x0; what’s going on? can things be retained under coco2d environment?

  • redux
    cocos2d
    I can’t get my head around what’s going on here and I know I’m being stupid, but here’s whats going on:I have two images, one is 1024×768, one is 2048×1536. They are “background” textures. I’m trying to switch from one texture to the other:CCSprite *bg = [CCSprite spriteWithFile:@”one.jpg”]; bg.scale = 0.5; [self addChild:bg]; … CCTexture2D* tex = [[CCTextureCache sharedTextureCache] addImage:two.jpg]; [bg setTexture: tex];OK this is totally normal, the 2nd image fits perfectly into the same

  • Zennichimaro
    android ios cocos2d cocos2d-x
    I have 2 MyGameScreen objects that extends cocos2d::CCLayer. I am capturing the ccTouchesMove of the first screen so that I can create the moving effect exactly like sliding between pages of iOS application screen.My class is like so:class MyGameScreen: public cocos2d::CCLayer {cocos2d::CCLayer* m_pNextScreen; }bool MyGameScreen::init() {m_pNextScreen = MyOtherScreen::create(); }void MyGameScreen::ccTouchesMoved(CCSet *touches, CCEvent *event){// it crashes here… on the setPosition… m_pNextS

  • Ben
    cocos2d cocos2d-x
    In the cocos2d-x HelloWorld project, I am trying to add another layer to the scene and keep a reference to this layer in a data member. Since the function HelloWorld::scene() is static, I cannot add the layer within this function (because I cannot set the data member for the layer).So I tried getting the scene in the init() function as follows, however this leads to scene = 0x00000000.What am I doing wrong?bool HelloWorld::init() {bool bRet = false;do {CC_BREAK_IF(! CCLayer::init());CCScene* sce

  • iSeeker
    ios cocos2d-iphone didreceivememorywarning cctexturecache
    To find a solution I have gone thru this similar link: TextureCache Error from Cocos2d when integrated into UIKit App but seems like it is dealing with this error in a different context..Question: I have a UIKit project integrated with Cocos2d. When build, succeeds and runs but, at times crashes after receiving a memory warning with this error:Assertion failure in -[CCTextureCache init], /Users/MyName/Documents/CSProject/CSProject/libs/cocos2d/CCTextureCache.m:90Terminating app due to uncaught

  • Guru
    objective-c cocos2d-iphone cocos2d cctexturecache
    I want to change a sprite texture with another texture from a sprite sheet//normal sprite character = [CCSprite spriteWithSpriteFrameName:@”char1.png”];//change texture [character setTexture:[[CCTextureCache sharedTextureCache] addImage:[CCSprite spriteWithSpriteFrameName:@”char2.png”]]];but this gives me an error.I have tried without spriteWithSpriteFrameName and it gives me a blank texture.//error Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[CCSprite last

Web site is in building

I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money