How do I use a Loop to change or progress through various spawn points?

0 favourites
  • 6 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • Hello -

    I am building a game based on Asteroids. I'm more than 50% complete, and results aren't bad. Methinks ;)

    As you progress through waves/levels, the game spawns one more large rock than in the previous level (I'll put in a max later on). Now, I would like the rocks to run through a loop that goes through image points - the corners, 1 through 4, and when adding 1 to the image point counter, it goes back to 1. This repeats until the last rock is spawned. For example, seven rocks would spawn at image points 1, 2, 3, 4, 1,2, 3.

    When I run this code, the rocks all spawn at image point 1, the top corner. What I am doing wrong?

  • To me that looks ok, maybe the spawner object doesn't have those image points for the current animation? Also you can try using the Browser object to log in console the values of the variable and see if they are as expected.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks and sorry for the late reply.

    Concerning your reply, here's a screen capture - it shows the object with the original image point 0 (center), 1 through 4 (corners), and 6 through 10 (various spots left and right). I am stuck on the 1 through 4 loop.

    As for your second sentence, I am not sure I understand how to proceed. Regards!

  • I can make other objects spawn at the image points (for example, spawn a UFO at a corner). It's possibly my loop "syntax".

  • The loop looks reasonable to me. The wait wouldn't do anything but shouldn't affect anything either. You say other objects work, in a different loop ? Compare the loops.

    The Browser object, add it to the project like you would with a Sprite. On the actions inside the loop you can use the log action to log RSLoop. You can then see in F12 console during the game if it prints out 1234123.

  • You're going to hate me, but I found the problem. Looking at the original image above, I was spawning using an object called Spawner. I should've been using the object "Nebula", which is basically the object from which I want to spawn from all those image points.

    The original code (substituting the object) actually works!

    Nothing beats looking at this stuff early in the morning before work, with a big cup of coffee and after a shower XD

    Thanks for your help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)