Can anyone help me with Xcode?
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
Observing members:
0
Composing members:
0
7 Answers
What programming language are you using? Is there anymore information you can provide? Maybe the source code…
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.
Well I never got around to learning objC so I can’t really help you. Your school offers a class on iphone programming?
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.
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?
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.
@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
This question is in the General Section. Responses must be helpful and on-topic.