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


0 Members and 2 Guests are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #270 on: June 06, 2011, 10:33:19 PM »
It's actually my latest tutorial I've made. Haven't put it in the Gmg though.

I don't believe there's an easy way. Make your app fully and get the dev license when the app is ready.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #271 on: June 08, 2011, 10:22:43 PM »
Hi guys, using the new template I would like to draw some lines on the screen.
The old template did this extremely well so I cut and past some of the code (ie the drawline, drawoval, the drawstring etc) and placed it in gamescreen.
I then put this code in theviewdid launch to see if I could draw an oval:

position = CGPointMake(50, 50);
 Â   CGContextRef context;
//To set a color for a shape:
float color[] = {1.0,1.0,1.0,1.0};
 Â   
//ALL DRAWING CODE GOES HERE
[self drawOval:context translate:CGPointMake(0, 0) color:color point:position dimensions:CGPointMake(10, 10) rotation:0 filled:TRUE linesize:0.0];

The code likes it, I get no issues but I also get not oval.
I went through the help, and I downloaded a code example of drawing (QuatzDemo) but I am having trouble working out how to get some drawing on my screen. I really have tried to solve this on my own but am stuck.
Any help would be appreciated.
« Last Edit: June 08, 2011, 10:24:05 PM by breshi »

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #272 on: June 08, 2011, 10:57:26 PM »
To draw on a view you need to put drawing code in the DrawRect method. Then you need to update the view.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #273 on: June 09, 2011, 12:37:35 AM »
Sorry, I'm really trying elsewhere to understand this. Spent the last couple of hours reading streams of documentation other forums and very unhelpful apple documentation.
The new template is using UIViewController whilst the old is just using UIView and from what I understand that is where most of my problems lie.
I put the code in the DrawRect as suggested and also put in a NSLog to see if it ever gets called - it doesn't.
I know this is a problem with my lack of understanding so I am sorry for the frustration it must cause to try and answer it.
It is interesting that on the iPhone Dev SDK forum someone has the exact problem and the answer they were given was "Read the OS Programming Guide."

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #274 on: June 09, 2011, 07:57:01 AM »
Alright, so you got multiple ways of doing this. Some vary in quality and complexity.
(1) Make a new UIView class and set your view that the view controller controls as that new view class. Then you just put your code in that view. Of course using DrawRect can be slow and this method doesn't integrate well with other UIImageView graphics on the screen.
(2) Create a new UIView class with the drawing code. Make it update only when needed. Add it to your main view just like you do with UIImageViews. Now you can manipulate that drawable view just like you do UIImageViews.
(3) Find code to draw directly into a UIImage. Make a new one with your draw code, add it a UIImageView which you can then manipulate on screen.

Those are my suggestions, choose wisely cause each depends mostly on how you want the program set up.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #275 on: June 09, 2011, 05:33:32 PM »
Thanks Gan,
I think Im going to choose whats behind curtain no 3.
I need some images flying around the screen but need to do some drawing as well!

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #276 on: June 09, 2011, 06:20:23 PM »
Curtain no 3 was a winner!!
If anyone else has a similar sort of problem I did this:
1. Create a large empty UIImageView in xib
2. Created a referencing outlet called backgroundImage
3. put the following code in:


UIGraphicsBeginImageContext(CGSizeMake(300, 450));
CGContextRef context = UIGraphicsGetCurrentContext();
    
// drawing with a white stroke color
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
// drawing with a white fill color
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
// Add Filled Rectangle,
CGContextFillRect(context, CGRectMake(0.0, 0.0, 20, 40));
    
backgroundImage.image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

This then drew a small white rectangle at the top left of my image - perfect!!


Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: My iPhone Game Tutorials for Beginners
« Reply #277 on: June 09, 2011, 08:48:06 PM »
Congratz.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #278 on: June 11, 2011, 09:11:01 PM »
HI gan I had a question about a book I thought about getting.
It called "Coding in Object-C 2.0"

I looked for it on amazon, and found it, but it said that a new version of it was coming out "for Xcode 4 and iOS"
I have Xcode 3.5, but may get Xcode4 once I pay Apple the $100 if it isn't too different, and I'm probably only going to develop for the iOS. The books are the same price.

Which should I get?
And does "Coding in Object-C 2.0" have anything about development for the iOS?
« Last Edit: June 11, 2011, 09:11:18 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 #279 on: June 12, 2011, 09:46:57 AM »
Never read that book but Objective-C 2.0 is much different than 1.0.
XCode 4 is just a bit different that Xcode 3.

It may be useful to get them but it's up to you. I started out by going through free online resources, so that's what I suggest. Free resources and experimentation.

breshi


  • GMG Newbie

  • *


  • Posts: 31

  • Carpe Diem
Re: My iPhone Game Tutorials for Beginners
« Reply #280 on: June 16, 2011, 01:34:02 AM »
Got my first game on iTunes!!

http://itunes.apple.com/au/app/christmas-high-jinks/id443115778?mt=8

Thanks to everyone on the forum for their help!!!!!

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: My iPhone Game Tutorials for Beginners
« Reply #281 on: August 16, 2011, 12:15:34 PM »
Gan I finally started reading an Objective-C book. and your right it is a neat language. way better than C++.
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 #282 on: August 25, 2011, 03:23:48 PM »
If you know anything about me you know three things stay the same

1.) I'll always make a fool of myself on forums
2.) I never take a real vacation
3.) and I always self-impose due-dates

during my recent leave I learned Obj-C, and part of the foundation framework, and a little bit of making iPhone user interfaces, and I hope to make a iPhone game ofter my C/C++ tutorials.

P.S. and Gan you were right it is an awesome language! In the future it might be my main language.
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 #283 on: September 24, 2011, 06:54:58 PM »
hey sorry too bug you again, but can you resize a sprite? The game I'm making has the screen resize to show the entire room your in.

And also, how do you make image drawing work with a sprite sheet instead of separate images for 'left' 'right' 'walking' or 'idle'.
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 #284 on: September 24, 2011, 08:06:22 PM »
Quote
hey sorry too bug you again, but can you resize a sprite? The game I'm making has the screen resize to show the entire room your in.
Sounds like a fancy scaling thing. There are some ways of doing this, completely different in OpenGl vs CoreGraphics. Which are you using?

Quote
And also, how do you make image drawing work with a sprite sheet instead of separate images for 'left' 'right' 'walking' or 'idle'.
There is a way to do that. I can't remember off the top of my head... but there is a way. I guess I can just say to Google it.