Topic:   My iPhone Game Tutorials for Beginners   (Read 423185 times)


0 Members and 3 Guests are viewing this topic.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #225 on: May 05, 2011, 09:20:58 PM »
alright so I was trying to do the dice roller I was talking about earlier, and I was fine declaring variables in the .h files, the I went to the .m files and it went all bad
first of all what are those things with @ signs before their purple names, and what are their significance, and secondly wear do I put my code, and thirdly in .h files are you only able to declare variables, or are there other processes you can do?
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #226 on: May 05, 2011, 10:23:04 PM »
.h is only for declaring variables and functions.

.m is for code. There should be a whole lot of functions already in the .m that you can use.
@"test" is a string variable.
@synthesize prepares global variables to be accessible by outside classes.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #227 on: May 06, 2011, 02:51:28 PM »
okay I guess I can get that, but where do I put my code in? like do I have to separate them based on different functions (if so which where) or can I just put all of them in one function block?
P.S. i'm on chapter 11 now
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #228 on: May 06, 2011, 03:26:38 PM »
where do you put custom functions in? do you put them in the .h or .m files?
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #229 on: May 06, 2011, 03:40:21 PM »
Your custom function code goes in the .m while you declare it in the .h.

Somhairle1314


  • GMG Newbie

  • *


  • Posts: 1

  • I love YaBB 1G - SP1!
Re: My iPhone Game Tutorials for Beginners
« Reply #230 on: May 10, 2011, 08:16:47 PM »
I can not get the first tutorial to open/download.  When I try to open the file in a new window or when I save the file and open it I get the same message (Not Found url not found on this server).  The second and third tutorials work fine though.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: My iPhone Game Tutorials for Beginners
« Reply #231 on: May 10, 2011, 08:50:00 PM »
Yo, gan! I don't remember ever seeing a thread with 10,000+ views before! Nice work!
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #232 on: May 10, 2011, 10:29:38 PM »
Quote
I can not get the first tutorial to open/download.  When I try to open the file in a new window or when I save the file and open it I get the same message (Not Found url not found on this server).  The second and third tutorials work fine though.
I apologize, but the first tutorial has died.
So dead that I can't resuscitate it. Sorry. I might remake it sometime in the future.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #233 on: May 11, 2011, 03:50:52 PM »
so I've been looking through the classes and they always seem to have a .h file to make them work, and it says to import them, but all the information they give is the name (ie. UISwipeGestureRecognizer.h) so I create it, and then don't know what to put in there.
What am I supposed to do, to get, or make these .h files
« Last Edit: May 11, 2011, 03:51:27 PM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #234 on: May 11, 2011, 04:39:07 PM »
You don't need to create or get the .h files. You have the frameworks, to use their functions just put #import "name of framework" at the top of the class you want to use them in.

I'd suggest following a specific tutorial to learn the basics rather than attempting to study the structure and lingo.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #235 on: May 19, 2011, 01:39:08 AM »
I've been slowly working on swapping a game I wrote in the old Game Makers Template to the new one and I have to say the new template is FANTASTIC!!!!!!
Rather than wrap my mind around adding alert views for high score name entry I just use Interface Builder to bring hidden labels and textFields up - so much better.
It is much, much, much faster.
Adding new pages is easier so now I have Options, Credits, Info and High Score screens.
Just wanted to especially thank Gan the Flamer for all his help and making the template available.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #236 on: May 19, 2011, 07:17:22 PM »
Have got a question - how do a pass a variable (bool soundOption;) set up in my optionsScreen to my gameScreen.m?
I know how to assign a global variable throughout one .m file but how do you pass it to another?

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #237 on: May 20, 2011, 12:15:26 AM »
That's where I use the delegate.
At the top of your .m file if you add:
#import "DelegateName.h"
DelegateName *delegate;

Then in load you do:
delegate = [[UIApplication sharedApplication] delegate];

And voila. Put your global variables in delegate and you have easy access from everywhere. Or you could put your global variables in a singleton class and just pass that down through the delegate.

P.S. I don't know if this is the most professional way but I have found it to be efficient, quick, and easy.
« Last Edit: May 20, 2011, 12:16:34 AM by Gandolf »

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #238 on: May 20, 2011, 12:45:39 AM »
Do you have to declare the variables in all the .h files ie AppDelegate.h MainMenu.h HighScoreScreen.h and gameScreen.H?
Which .m file do you initially set the variables?

I have put the following code at the start of each of my .m files:
#import "AppDelegate.h"
AppDelegate *delegate;

I then put in the ViewDidLoad:
    delegate = [[UIApplication sharedApplication] delegate];

Is this what you meant? I only ask because it doesn't seam to be working.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #239 on: May 20, 2011, 08:10:55 AM »
Quote
Do you have to declare the variables in all the .h files ie AppDelegate.h MainMenu.h HighScoreScreen.h and gameScreen.H?
Which .m file do you initially set the variables?

I have put the following code at the start of each of my .m files:
#import "AppDelegate.h"
AppDelegate *delegate;

I then put in the ViewDidLoad:
 Â   delegate = [[UIApplication sharedApplication] delegate];

Is this what you meant? I only ask because it doesn't seam to be working.
Sorry, I did a poor job of explaining. Global variables go in the delegate's .h and must be propertied and synthesized in which you'll be able to access them from other classes through delegate.myVariable.
Later today when I wake up I'll post actual working code.