Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

markhtfc

macrumors newbie
Original poster
Hey,

Well let me start of by saying this is my first post and my name is Mark and I am 17 years old. Now how I came about programming? Well I wanted to do it when I was younger but never really took it up, I am in my second year at college and we are currently doing C++ and HTML. Since doing programming at college it has really got me wanting to do programming as a proffesion. I am really advanced in C++ (compared to other students)though as the teacher would like to set me some more challenging tasks. So maybe I have a brain for programming heh.

Well onto the purpose of my post. I have not had a Mac that long. Not long before Christmas. I am looking at creating a Managing Game, I am using Xcode and Interface Builder. At the moment before I make the whole background and everything first I want to try and understand how to make action buttons work. (if I knew how to provide screenshots from a Mac I would do so you can understand easier). Well anyway what I have got so far is a title, Start New game button and a Quit button. I also have a screen that I want my New Game button to connect to.

The question I have is how do I get my new game button to go to that screen? and how do I get my Quit button to quit the program? I have tried a few times but had no luck.

I hope that someone will be able to help me as I would really be able to make a game, I would love to be a programmer. I am looking at going to uni to do a course maybe but I don't want it to turn out as a lost cause. As I have known a few people who has had to move away to do work in that area.

Thank your for listening and I hope you can help.

Thank you

Mark
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Are you using Carbon or Cocoa? I assume Carbon as you are talking about C++ but without knowing we can't really help you (and if it's Carbon I can't help you)...
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
OK great. Cocoa is easy. But we need to agree on the normal terminology... What is this "screen"? Is it an NSWindow? An NSView? Something else?

Have you read up at all in the documentation on how the action messages get passed down the responder chain?

The simplest way to get this to work is to create a new object to use as the controller, instansiate that in IB and create the actions in there to deal with the windows.
 

markhtfc

macrumors newbie
Original poster

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Ok. There is no such thing as a screen. That's a Window. Do you want to allow multiple games at once or not? If the answer is yes then you need to use a Document Based app, otherwise not.

If the answer is a single game at once then why not just have the window appear on startup?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Ok I see what you are trying to do. But why? This is not anything like a Mac user interface. You should not have a Quit button. Or a new game button like that. You need to use the actual menus.
 

markhtfc

macrumors newbie
Original poster
Sorry about that, I should explain with the proper terminology. Sorry again.

About the multiple games not really know, As this is my first attempt.

I don't quite understand your last question, I would like a main menu so I can then move onto the Create manager Screen and so on.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
My point is that's not a menu. A menu is the thing at the top of the screen. It has a pre-populated perfectly functioning quit item. I understand a welcome view within the main window though. Give me 15 minutes: I'm knocking up a demo project...
 

markhtfc

macrumors newbie
Original poster
Ok I see what you are trying to do. But why? This is not anything like a Mac user interface. You should not have a Quit button. Or a new game button like that. You need to use the actual menus.

I am not generally looking for a Mac user interface right at this minute. I am mainly looking at how I can make them do actions as I would like them to do seen as this is my first attempt.
 

markhtfc

macrumors newbie
Original poster
Ok thank you. like I say programming is all new to me, The Mac is still new also. I am hoping to do programming though at a decent level so if I do go to Uni I will know what i am doing. Plus I find it very intresting and a great hobbie.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
So attached is an XCode project to demonstrate one of the possible ways of doing this. What we have is a single window that contains a NSTabView. This currently has 2 tabs one for each "screen" you want to display. The tabs themselves are hidden.

There is also an NSObject subclass that is our "controller" object. It has the action code in it to start the game. When the button is pressed this is called. All it does is select the next tab.

If this is all greek to you then you need to buy a book, or at the very least run through the guided, step by step demos on the Apple site that will take you through the basic design patterns you need to know, primarily MVC and how to connect the outlets and actions of objects in IB.
 

Attachments

  • Demo.zip
    36.5 KB · Views: 120

markhtfc

macrumors newbie
Original poster
Ok thank you for that. So by what you are saying what I am trying to do I can't actually do it?

I will have a look at the step by step guides tomorrow as I will have more time then.

Thank you for your help and producing the Demo for me. :)
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
No the demo does what you want to do (apart from the Quit button but that's really easy). I'm suggesting that you will need read up on the documentation to get anywhere.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
One thing to remember is that programming in Cocoa uses Objective-C, and not C or C++. Is that what you're writing in?

Not true, you can mix Objective-C and C++, just give your source files a .cpp extension. This will run them through the Objective-C++ compiler. I do this all the time as I much prefer C++ to Objective-C, but prefer to use Cocoa than Carbon.

b e n
 

markhtfc

macrumors newbie
Original poster
Thanks for your help everyone.

Thank you for the link Cazlar, I had a look at that this morning and I read the first article. It looks intrsesting. Going to go through each article to see if it will help me out more.
Mark
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.