0

im trying to create a gameover view in my sprite builder project. i have 2 problems. firstly when i copy an image to the Gameover.ccb xcode throws an error saying it cannot find that image.I dont understand this because the file is located exactly where xcode says it cant find it.

cocos2d: Couldn't find file:ccbResources/apple.jpg

Second problem is ive created a button in my GameOverScene.ccb. ive assigned the doc root var to "_restartGameover" and i have selected the selector as "resgame" with target document root. then in my GameOverScene.m on xcode i have the following code

    "#import "GameOverScene.h"

@implementation GameOverScene{
CCButton *_restartGameover;
}



- (void)resgame {
    [CCBReader loadAsScene:@"MainScene"];
}
@end" 

but when i run the project in xcode and click the button, i get an error saying "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CCNode resgame]: unrecognized selector sent to instance 0x14d6ffa0'". If anyone could help me with this i would be grateful as ive been stuck on it for a few hours now. Also i am fairly new to this so if you could clearly explain your solutions that would also be great.

http://tinypic.com/r/29mom7n/8

so thats my spritebuilder screen, when i run the xcode project the ccnodegradient and ccbutton are displayed but not the apple.jpg. and when the ccbutton is pressed it throws that error

claustro
  • 13
  • 5

1 Answers1

0

In SpriteBuilder, you need to set your scene class to GameOverScene. This is likely why you're getting an error about the unrecognized selector (your error message suggests that it's trying to call the method on a CCNode instead of your subclass).

Taum
  • 2,511
  • 18
  • 18
  • where would i set the scene class? all i can see is the "name" in CC node tab and "custom class" in code connections and "selector" in CCControl – claustro May 06 '14 at 13:33
  • It's under code connections, next to properties. Check the right side panel's tab view (2nd tab from the left). – CodeSmile May 06 '14 at 14:11
  • i still cannot find it, under code connections tab i have the following options, "custom class", a dropdown which is selected at "doc root var", "selector" and "target" i dont see a scene class? when i try assign custom class it just freezes my phone. So i assume custom class is not what you meant. – claustro May 06 '14 at 14:24
  • Yes, you need to set `GameOverScene` as the "custom class" for the root `CCNode` of your scene. This will make `CCBReader` instantiate your subclass instead of a generic `CCNode` when loading the ccb file. – Taum May 06 '14 at 14:31
  • I dont know what im doing wrong. I added the custom class of "GameOverScene" and kept the doc root var to _restartGameover. this crashed my project, i then selected "dont assign" and it again crashed my project. Basically assigning a custom class crashes my project. What i dont understand is that i have buttons on my "MainScene" which i created and they work perfectly fine, neither of those buttons have a "custom class" they only have "doc root var". – claustro May 06 '14 at 14:41
  • Did you set the custom class on your button ? It needs to be set on the root `CCNode` instead. – Taum May 06 '14 at 14:48
  • ahhh i feel like an idiot, i understand you now, i added the GameOverScene custom class to the CCNode but it still throws the exact same error, "unrecognized selector" and file not found apple.jpg – claustro May 06 '14 at 14:48
  • thank you very much!! that fixed the selector error. How would i go about fixing the "file not found" error? – claustro May 06 '14 at 15:00
  • Sorry, I don't really know what to do about your other problem. It's usually best to create another question about it since they are two distinct problem. – Taum May 06 '14 at 15:13