Ok thanks, I'll check out the menu test. I've mainly been looking at the sprite test
Add sprite
(162 posts) (19 voices)-
Posted 1 year ago #
-
Thanks for the help everyone.
Posted 1 year ago # -
I looked at the menu test, but I couldn't find anything. This is what I'm trying to do. I'm trying to have a menu that says Start, Instructions, and About The Developers. When you click on instructions/about the developers, I want the picture I made to appear. That's all I'm trying to do for now, then I'll start gameplay ( which I need to learn first ). Here's pictures of each file.


Posted 1 year ago # -
Like I said before, there aren't any errors, but I don't think I'm linking the pics and sprites correctly because when I build and run I get the main menu, but when I click on a button, nothing happens.
Posted 1 year ago # -
Can anyone help?
Posted 1 year ago # -
Hello, nothing happens because you are not defining any behaviour for your buttons. I mean, when touching the button "one" you call the "play:" method, but your play method is empty!
You must write the code that does what you want to do in there.Posted 1 year ago # -
Ok, i understand now. What kind of behavior do I need to add for that? Thanks for your help btw.
Posted 1 year ago # -
It's just an image. I just want it to appear when a user clicks on a button. Oh, but I haven't started the gameplay yet, so I don't want anything to happen yet for that button.
Posted 1 year ago # -
Sorry I'm asking so much, I just really want to start developing!
Posted 1 year ago # -
Take a look at this page : http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:lesson_3._menus_and_scenes
That should help you out with changing to the other scene.
Posted 1 year ago # -
Joethemonkey101: I know you really want to start making games, but you really should try to get some of the fundamentals down before jumping into cocos2d. Some people may disagree with me on this, but I would suggest starting out with an introductory book on programming in C, and then moving on to an introductory book on Objective-C. After that, all of this will make a lot more sense.
Posted 1 year ago # -
@cocos0d
I read a book on programming for objective-c, but then realized I wanted to learn cocos2d. Are there any books or websites on the fundamentals of cocos2d?
@xStoryTeller
Thanks for the link!Posted 1 year ago # -
Thanks so much xStoryTeller ! That link really helped. The thing is, I still have a little problem. When I click on a button, the app closes. Here's what I did with the code.

Posted 1 year ago # -
It says your Developers layer does not return a scene. Basically the tutorial and you are using different ways of getting the same thing done. Instead of [GamePlay scene] you could try [GamePlay node] ( Not sure about this actually but I think that should work. ) If you want to copy the code from that other link you should follow the tutorial for it =)
Posted 1 year ago # -
What do you mean by following the tutorial for it? All that page was was explaining scenes and giving that one line. Also, I changed " scene " to " node ". Then I build and run but it still did the same thing. Also, I think this is what you mean by returning a scene. I have it here in my developers.m file.

Do you mean " return self "?Posted 1 year ago # -
If you follow the full tutorial, I think it uses the base HelloWorld example, if you just take a look at that you will see how that layer returns the scene. I'm not at my Mac so I can't really post any snippets so you will have to find it yourself =)
Posted 1 year ago # -
Ok, I'll look at it again
Posted 1 year ago # -
@Joethemonkey101 here is a great website for learning cocos2d: learn-cocos2d.com and here is SDKTutor's youtube page http://www.youtube.com/user/sdktutor
Posted 1 year ago # -
Thanks so much guys! I finally got my About the Developers page and my Instructions page working! I only had to change 3 different things in my code. Now I can start gameplay! Does the cocos2d wiki site have info on gameplay???
Posted 1 year ago # -
Oh yeah, and before I get that far, I'll need to add back buttons for my instructions and about the developers pages. Does anyone know where I can find info on how to do that???
Posted 1 year ago # -
If you want a button to take you back to your main menu , just use
[[CCDirector sharedDirector] replaceScene: [YourMainMenuScene scene]];
if you want an actual back button , just create a i-var that stores the prior scene use it it to replace the current scence.
Posted 1 year ago # -
@GregK
I want an actual button that a user can tap on to go back to the main menu. I was just gonna put some text ( CCLabel ) but when i build and go it wasn't there. Then I realized I couldn't just put text over a picture ( that's what my instructions and about the developers pages are ). Can you explain what an i-var is and how to use it?
Thanks for your help.Posted 1 year ago # -
//Back Button CCSprite *backNormal = [CCSprite spriteWithFile:@"button_back_a.png" ]; CCSprite *backSelected = [CCSprite spriteWithFile:@"button_back_b.png" ]; CCSprite *backDisabled = [CCSprite spriteWithFile:@"button_back_b.png" ]; CCMenuItemSprite *item1 = [CCMenuItemSprite itemFromNormalSprite:backNormal selectedSprite:backSelected disabledSprite:Disabled target:self selector:@selector(menuCallback:)]; CCMenu *backButton = [CCMenu menuWithItems: item1, nil]; detonateButton.position = CGPointMake(965, 725); [self addChild:backButton];This is how I'm using buttons. You pretty much have to preload 3 sprites for the different states a button could be in. Then you assign them to a menu item. You then Assign that menu item to a menu. The @selector() then messages the method inside it. Inside the method you can just put in the code for the director to call your main menu like I posted above.
Hope this helps.
Ps: you should explore the code that cocoa project that came with the download , there's a bunch of great examples in it.
Posted 1 year ago # -
Thanks Greg. I'm trying to go over the sample code from time to time, but I don't see any tests that show gameplay for the time of app I'm looking to develop. I'll explore around with the code you gave me though.
Here's a couple of questions I have. Will this work if my whole scene is a picture? Why do I need 3 different sprites? I just want a back button in the Developers and Instructions files that when tapped will go back to the main menu ( HelloWorldScene ).
Posted 1 year ago # -
It should work in your entire game since it calls the director which got controll over the scenes.
You need 3 sprites because of button states. A button may look one way when not pressed and a little different when pressed. This is just eye candy though, so they can all be the same image, that's up to you. In the example I posted above I have backSelected and backDisabled point to the same image since I probably won't need to use disabled.
Posted 1 year ago # -
Oh ok, so I can use it in my HelloWorldScene. Thanks so much for your help. I'll tell you how it works out tomorrow!
Posted 1 year ago # -
Ok, I put all that code into HelloWorldScene, and I only used 1 sprite. Here's what happened.

I get 1 error and 1 warning. I think I had the warning before this though, because I don't have anything in my GamePlay scene.Posted 1 year ago # -
If I take out the detonateBackButton line, I lose the error, but when I build and run, the app just crashes and goes back to the home page of the iphone sim.
Posted 1 year ago # -
Sorry if it's hard to find where I added the button's code. I'm not even sure if I put it in the right place. I named it backButton.
Posted 1 year ago #
Topic Closed
This topic has been closed to new replies.