General Question

joeysefika's avatar

Deleting Sprites from frame (Xcode for iPhone)

Asked by joeysefika (3093points) March 18th, 2010

So, my first iPhone app is going pretty well, It is a pretty basic game, a space ship at the bottom of the screen that scrolls left or right, and random space junk that falls from the sky. The aim is to dodge it. All i need now is to be able to delete sprites as they either intersect with the player at the bottom of the screen, or as the intersect with an invisible bar at the bottom of the screen.
The bar at the bottom of the screen is how I determine score; has it hit the player or not.

My sprite is called ‘SpaceJunk’
Would it be something like;
if(CGRectIntersectsRect(SpaceJunk.frame,player.frame)) {
SpaceJunk = delete

I Know it wont be as simple as that but can you offer advice.
Thanks in advance

Observing members: 0 Composing members: 0

3 Answers

gorillapaws's avatar

Do you actually understand the Objective-C language? or are you just copying code from other people and trying to “wing it?” because “SpaceJunk = delete” makes no sense… or was that supposed to be psudocode?

joeysefika's avatar

Yeah it was psudocode, I thought that was apparent; hence the “I Know it wont be as simple as that but can you offer advice”
I’ve been doing most of my learning from tutorials, yet I cannot figure out how to remove a sprite from frame, ergo the question.

At the end of the day I’m not writing apps for the money, I’m doing it to learn and for the fun of it.

gorillapaws's avatar

The thing is that even with pseudo code you’ve performed a variable assignment instead of calling a method on an object which is typically how you would want to represent performing an action in pseudocode. I would highly recommend reading Steven Kochan’s Programming in Objective-C 2.0 if you have not already done so. I’m a self-taught Cocoa programmer (although I’ve been focusing my studies on OSX instead of Cocoa Touch), and I really struggled until I made my way through that book.

My apologies if I’m jumping to conclusions and underestimating your knowledge of programming based on false assumptions.

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther