0

Right now I have everything in place, but I'm trying to make it so that pipes objects that go off the screen get deleted and a new pipe is generated behind the one in front of you. So a drawing would look like this, where the objects inside the square brackets represent the screen.

(pipe gets deleted) [[[(bird)---><---(pipe) <---(pipe)]]] <---(pipe gets created)

At any given time, two pipes are visible on the screen. The one that leaves gets deleted, and another gets created.

The problem I'm having is that all of the pipes are in the same iterator, so if I want to delete one, I have to delete all. So, the pipes that are still on the screen get deleted as well, whereas I only want to delete the one that came off the screen.

5
  • I fail to understand your question. Iterators don't remove everything. Commented Mar 5, 2014 at 23:46
  • 6
    That is a very expensive way of doing it. Why not rather create 3 pipes and when one goes offscreen (behind your bird), just reset it's position and properties and use it as the new pipe. You could then store the pipes in a simple array and do allocation at startup. Commented Mar 5, 2014 at 23:52
  • 1
    Show us the code where you add and delete the pipes. Commented Mar 5, 2014 at 23:56
  • @zapl: What I meant was that they're in the same array. Commented Mar 6, 2014 at 5:41
  • And sorry, I figured out how to do it. I made this problem much more complicated than it needed to be: All I had to do was make 3 separate arrays (since there are 3 sets of pipes visible on the screen at any given time). Before, I was trying to do it all in one array, which was making it very difficult. Commented Mar 6, 2014 at 5:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.