General Question

joeysefika's avatar

Can anyone help me with Xcode?

Asked by joeysefika (3098points) September 23rd, 2009
7 responses
“Great Question” (1points)

I’m building a basic app for my computer science project and need help spawning objects in game. It’s a basic app with the player at the bottom who is moved by the finger, the objective is to avoid missiles, asteroids and space junk etc. How can i get these objects to appear at the top of the screen and fall down randomly. Thanks

Topics: , , ,
Observing members: 0
Composing members: 0

Answers

styfle's avatar

What programming language are you using? Is there anymore information you can provide? Maybe the source code…

joeysefika's avatar

Um its the iPhone code (objective C maybe) yeah I’ll chuck it on pastebin.
BTW, iPhone programming is not very similar to anything else I’ve done and this question might actually need an understanding of iPhone programming.

styfle's avatar

Well I never got around to learning objC so I can’t really help you. Your school offers a class on iphone programming?

joeysefika's avatar

No, I’m doing Computer Science which teaches us Java. However for our major project we get free reign of what we want to do, I chose to do iPhone programming so yeah.

styfle's avatar

Oh thats cool. I’m taking a Java class right now. I tried watching the Stanford iTunes U but I got lost after a few videos. Every type of programming I’ve done so far has been command line stuff. How did you learn Obj C?

cwilbur's avatar

You have three problems:

* How do you create a new object?

* How do you draw the objects?

* How do you move them?

I’ll start now and say that my Cocoa experience predates Leopard, is based on desktop Mac programming, and it’s probably getting mixed in with old-school Mac programming, but the general outline should be sound.

Somewhere in your model class should be an NSSet of objects that you can interact with. When you create an object, you should generate X and Y coordinates for it that place it off-screen. You should also have rules for how it moves – the range of possible delta-X and delta-Y values per tick.

Then you can use an NSTimer to trigger each tick. When you get the timer event, you go through your NSSet of objects, update the position of each one of them. Check for a collision with the user’s finger. If you don’t have one, trigger the screen NSView to redraw. If you do have one, do whatever is appropriate.

Then in your custom NSView subclass for that screen, write a method that goes through that magic NSSet and redraws each of them. There’s a method that you override, that only gets called when the superview determines its subviews should be redrawn.

Most of this info should transfer to the iPhone, from what I understand. It should at least give you a starting point.

Good luck.

joeysefika's avatar

@cwilbur awesome thanks. This really will help
@styfle Yeah just from internet tutorials and stuff. Then just taking my java knowledge and applying similar principles

Answer this question

Login

or

Join

to answer.

Mobile | Desktop


Send Feedback   

`